Index: net/quic/congestion_control/tcp_cubic_sender_bytes_test.cc |
diff --git a/net/quic/congestion_control/tcp_cubic_sender_bytes_test.cc b/net/quic/congestion_control/tcp_cubic_sender_bytes_test.cc |
index 9203ac6a798dcd2d69dbed20cfe90c2eba9538bb..eaacb5bc0bb1050b5ac9dbd29fca1ff03375bfbb 100644 |
--- a/net/quic/congestion_control/tcp_cubic_sender_bytes_test.cc |
+++ b/net/quic/congestion_control/tcp_cubic_sender_bytes_test.cc |
@@ -60,6 +60,10 @@ class TcpCubicSenderBytesTest : public ::testing::Test { |
bytes_in_flight_(0) {} |
int SendAvailableSendWindow() { |
+ return SendAvailableSendWindow(kDefaultTCPMSS); |
+ } |
+ |
+ int SendAvailableSendWindow(QuicPacketLength packet_length) { |
// Send as long as TimeUntilSend returns Zero. |
int packets_sent = 0; |
bool can_send = |
@@ -92,17 +96,19 @@ class TcpCubicSenderBytesTest : public ::testing::Test { |
clock_.AdvanceTime(one_ms_); |
} |
- void LoseNPackets(int n) { |
+ void LoseNPackets(int n) { LoseNPackets(n, kDefaultTCPMSS); } |
+ |
+ void LoseNPackets(int n, QuicPacketLength packet_length) { |
SendAlgorithmInterface::CongestionVector acked_packets; |
SendAlgorithmInterface::CongestionVector lost_packets; |
for (int i = 0; i < n; ++i) { |
++acked_packet_number_; |
lost_packets.push_back( |
- std::make_pair(acked_packet_number_, kDefaultTCPMSS)); |
+ std::make_pair(acked_packet_number_, packet_length)); |
} |
sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets, |
lost_packets); |
- bytes_in_flight_ -= n * kDefaultTCPMSS; |
+ bytes_in_flight_ -= n * packet_length; |
} |
// Does not increment acked_packet_number_. |
@@ -280,6 +286,39 @@ TEST_F(TcpCubicSenderBytesTest, SlowStartPacketLossWithLargeReduction) { |
EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
} |
+TEST_F(TcpCubicSenderBytesTest, SlowStartHalfPacketLossWithLargeReduction) { |
+ FLAGS_quic_sslr_byte_conservation = true; |
+ QuicConfig config; |
+ QuicTagVector options; |
+ options.push_back(kSSLR); |
+ QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
+ sender_->SetFromConfig(config, Perspective::IS_SERVER); |
+ |
+ sender_->SetNumEmulatedConnections(1); |
+ const int kNumberOfAcks = 10; |
+ for (int i = 0; i < kNumberOfAcks; ++i) { |
+ // Send our full send window in half sized packets. |
+ SendAvailableSendWindow(kDefaultTCPMSS / 2); |
+ AckNPackets(2); |
+ } |
+ SendAvailableSendWindow(kDefaultTCPMSS / 2); |
+ QuicByteCount expected_send_window = |
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ |
+ // Lose a packet to exit slow start. We should now have fallen out of |
+ // slow start with a window reduced by 1. |
+ LoseNPackets(1); |
+ expected_send_window -= kDefaultTCPMSS; |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ |
+ // Lose 10 packets in recovery and verify that congestion window is reduced |
+ // by 5 packets. |
+ LoseNPackets(10, kDefaultTCPMSS / 2); |
+ expected_send_window -= 5 * kDefaultTCPMSS; |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+} |
+ |
TEST_F(TcpCubicSenderBytesTest, NoPRRWhenLessThanOnePacketInFlight) { |
SendAvailableSendWindow(); |
LoseNPackets(kInitialCongestionWindowPackets - 1); |