Index: net/quic/congestion_control/tcp_cubic_sender_packets_test.cc |
diff --git a/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc b/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc |
index 0b37f1c10c6159e647ae30d42e06db2c144ce67d..f4a4227eabef8e2d87507d12e3d490c8a2352a8c 100644 |
--- a/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc |
+++ b/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc |
@@ -69,6 +69,10 @@ class TcpCubicSenderPacketsTest : 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 = |
@@ -101,17 +105,19 @@ class TcpCubicSenderPacketsTest : 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_. |
@@ -289,6 +295,39 @@ TEST_F(TcpCubicSenderPacketsTest, SlowStartPacketLossWithLargeReduction) { |
EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
} |
+TEST_F(TcpCubicSenderPacketsTest, 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(TcpCubicSenderPacketsTest, NoPRRWhenLessThanOnePacketInFlight) { |
SendAvailableSendWindow(); |
LoseNPackets(kInitialCongestionWindowPackets - 1); |