Index: net/quic/congestion_control/tcp_cubic_sender_test.cc |
diff --git a/net/quic/congestion_control/tcp_cubic_sender_test.cc b/net/quic/congestion_control/tcp_cubic_sender_test.cc |
index c01e0c7498eaed0ec6c95bdf4e3a5eb4c6b1e259..851c1a1091851ce847b7f8d9a52cc8a4369a2b25 100644 |
--- a/net/quic/congestion_control/tcp_cubic_sender_test.cc |
+++ b/net/quic/congestion_control/tcp_cubic_sender_test.cc |
@@ -201,6 +201,7 @@ TEST_F(TcpCubicSenderTest, ExponentialSlowStart) { |
} |
TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { |
+ sender_->SetNumEmulatedConnections(1); |
EXPECT_EQ(kDefaultMaxCongestionWindowTCP * kDefaultTCPMSS, |
sender_->GetSlowStartThreshold()); |
@@ -251,6 +252,7 @@ TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { |
} |
TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
+ sender_->SetNumEmulatedConnections(1); |
const int kNumberOfAcks = 10; |
for (int i = 0; i < kNumberOfAcks; ++i) { |
// Send our full send window. |
@@ -314,6 +316,7 @@ TEST_F(TcpCubicSenderTest, NoPRRWhenLessThanOnePacketInFlight) { |
} |
TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { |
+ sender_->SetNumEmulatedConnections(1); |
// Test based on the first example in RFC6937. |
// Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. |
const int kNumberOfAcks = 5; |
@@ -362,6 +365,7 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { |
} |
TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) { |
+ sender_->SetNumEmulatedConnections(1); |
// Test based on the second example in RFC6937, though we also implement |
// forward acknowledgements, so the first two incoming acks will trigger |
// PRR immediately. |
@@ -591,7 +595,62 @@ TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) { |
EXPECT_EQ(congestion_window, sender_->congestion_window()); |
} |
-TEST_F(TcpCubicSenderTest, CongestionAvoidanceAtEndOfRecovery) { |
+TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { |
+ sender_->SetNumEmulatedConnections(2); |
+ // Ack 10 packets in 5 acks to raise the CWND to 20. |
+ const int kNumberOfAcks = 5; |
+ for (int i = 0; i < kNumberOfAcks; ++i) { |
+ // Send our full send window. |
+ SendAvailableSendWindow(); |
+ AckNPackets(2); |
+ } |
+ SendAvailableSendWindow(); |
+ QuicByteCount expected_send_window = kDefaultWindowTCP + |
+ (kDefaultTCPMSS * 2 * kNumberOfAcks); |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ |
+ LoseNPackets(1); |
+ |
+ // We should now have fallen out of slow start, and window should be cut in |
+ // half by Reno. New cwnd should be 10. |
+ expected_send_window /= 2; |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ |
+ // No congestion window growth should occur in recovery phase, i.e., until the |
+ // currently outstanding 20 packets are acked. |
+ for (int i = 0; i < 10; ++i) { |
+ // Send our full send window. |
+ SendAvailableSendWindow(); |
+ EXPECT_TRUE(sender_->InRecovery()); |
+ AckNPackets(2); |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ } |
+ EXPECT_FALSE(sender_->InRecovery()); |
+ |
+ // Out of recovery now. Congestion window should not grow for half an RTT. |
+ SendAvailableSendWindow(); |
+ AckNPackets(2); |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ |
+ // Next ack will be the 5th and should increase congestion window by 1MSS. |
+ AckNPackets(2); |
+ expected_send_window += kDefaultTCPMSS; |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ |
+ for (int i = 0; i < 2; ++i) { |
+ SendAvailableSendWindow(); |
+ AckNPackets(2); |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+ } |
+ |
+ // Next ack should cause congestion window to grow by 1MSS. |
+ AckNPackets(2); |
+ expected_send_window += kDefaultTCPMSS; |
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
+} |
+ |
+TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) { |
+ sender_->SetNumEmulatedConnections(1); |
// Ack 10 packets in 5 acks to raise the CWND to 20. |
const int kNumberOfAcks = 5; |
for (int i = 0; i < kNumberOfAcks; ++i) { |
@@ -616,9 +675,11 @@ TEST_F(TcpCubicSenderTest, CongestionAvoidanceAtEndOfRecovery) { |
for (int i = 0; i < 10; ++i) { |
// Send our full send window. |
SendAvailableSendWindow(); |
+ EXPECT_TRUE(sender_->InRecovery()); |
AckNPackets(2); |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
} |
+ EXPECT_FALSE(sender_->InRecovery()); |
// Out of recovery now. Congestion window should not grow during RTT. |
for (int i = 0; i < 4; ++i) { |