Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Unified Diff: net/quic/congestion_control/tcp_cubic_sender_test.cc

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/crypto/common_cert_set.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9193941052ff14e8672ff3d4c28323dd35e8aaf8..4fe8dbfb5014ddb89aa5b2a88a050b86b7253fa8 100644
--- a/net/quic/congestion_control/tcp_cubic_sender_test.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender_test.cc
@@ -23,6 +23,7 @@ namespace test {
const int64 kInitialCongestionWindow = 10;
const uint32 kDefaultWindowTCP = kInitialCongestionWindow * kDefaultTCPMSS;
+const float kRenoBeta = 0.7f; // Reno backoff factor.
// TODO(ianswett): Remove 10000 once b/10075719 is fixed.
const QuicPacketCount kDefaultMaxCongestionWindowTCP = 10000;
@@ -48,6 +49,10 @@ class TcpCubicSenderPeer : public TcpCubicSender {
return hybrid_slow_start_;
}
+ float GetRenoBeta() const {
+ return RenoBeta();
+ }
+
RttStats rtt_stats_;
QuicConnectionStats stats_;
};
@@ -264,32 +269,26 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) {
// Lose a packet to exit slow start.
LoseNPackets(1);
+ size_t packets_in_recovery_window = expected_send_window / kDefaultTCPMSS;
- // We should now have fallen out of slow start.
- // We expect window to be cut in half by Reno.
- expected_send_window /= 2;
+ // We should now have fallen out of slow start with a reduced window.
+ expected_send_window *= kRenoBeta;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- // Testing Reno phase.
- // We need to ack half of the pending packet before we can send again.
+ // Recovery phase. We need to ack every packet in the recovery window before
+ // we exit recovery.
size_t number_of_packets_in_window = expected_send_window / kDefaultTCPMSS;
- AckNPackets(number_of_packets_in_window);
+ DVLOG(1) << "number_packets: " << number_of_packets_in_window;
+ AckNPackets(packets_in_recovery_window);
+ SendAvailableSendWindow();
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- // We need to ack every packet in the window before we exit recovery.
- for (size_t i = 0; i < number_of_packets_in_window; ++i) {
- AckNPackets(1);
- SendAvailableSendWindow();
- EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- }
-
- // We need to ack another window before we increase CWND by 1.
- for (size_t i = 0; i < number_of_packets_in_window - 2; ++i) {
- AckNPackets(1);
- SendAvailableSendWindow();
- EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- }
+ // We need to ack an entire window before we increase CWND by 1.
+ AckNPackets(number_of_packets_in_window - 2);
+ SendAvailableSendWindow();
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
+ // Next ack should increase cwnd by 1.
AckNPackets(1);
expected_send_window += kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
@@ -330,27 +329,27 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) {
LoseNPackets(1);
- // We should now have fallen out of slow start.
- // We expect window to be cut in half by Reno.
- expected_send_window /= 2;
+ // We should now have fallen out of slow start with a reduced window.
+ size_t send_window_before_loss = expected_send_window;
+ expected_send_window *= kRenoBeta;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
// Testing TCP proportional rate reduction.
- // We should send one packet for every two received acks over the remaining
- // 18 outstanding packets.
- size_t number_of_packets_in_window = expected_send_window / kDefaultTCPMSS;
- // The number of packets before we exit recovery is the original CWND minus
- // the packet that has been lost and the one which triggered the loss.
- size_t remaining_packets_in_recovery = number_of_packets_in_window * 2 - 1;
- for (size_t i = 0; i < remaining_packets_in_recovery - 1; i += 2) {
- AckNPackets(2);
- EXPECT_TRUE(sender_->TimeUntilSend(
- clock_.Now(), bytes_in_flight_, HAS_RETRANSMITTABLE_DATA).IsZero());
- EXPECT_EQ(1, SendAvailableSendWindow());
+ // We should send packets paced over the received acks for the remaining
+ // outstanding packets. The number of packets before we exit recovery is the
+ // original CWND minus the packet that has been lost and the one which
+ // triggered the loss.
+ size_t remaining_packets_in_recovery =
+ send_window_before_loss / kDefaultTCPMSS - 2;
+
+ for (size_t i = 0; i < remaining_packets_in_recovery; ++i) {
+ AckNPackets(1);
+ SendAvailableSendWindow();
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
}
// We need to ack another window before we increase CWND by 1.
+ size_t number_of_packets_in_window = expected_send_window / kDefaultTCPMSS;
for (size_t i = 0; i < number_of_packets_in_window; ++i) {
AckNPackets(1);
EXPECT_EQ(1, SendAvailableSendWindow());
@@ -367,8 +366,8 @@ TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) {
// Test based on the second example in RFC6937, though we also implement
// forward acknowledgements, so the first two incoming acks will trigger
// PRR immediately.
- // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example.
- const int kNumberOfAcks = 5;
+ // Ack 20 packets in 10 acks to raise the CWND to 30.
+ const int kNumberOfAcks = 10;
for (int i = 0; i < kNumberOfAcks; ++i) {
// Send our full send window.
SendAvailableSendWindow();
@@ -379,17 +378,20 @@ TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) {
(kDefaultTCPMSS * 2 * kNumberOfAcks);
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- // Ack a packet with a 15 packet gap, losing 13 of them due to FACK.
- LoseNPackets(13);
+ // Lose one more than the congestion window reduction, so that after loss,
+ // bytes_in_flight is lesser than the congestion window.
+ size_t send_window_after_loss = kRenoBeta * expected_send_window;
+ size_t num_packets_to_lose =
+ (expected_send_window - send_window_after_loss) / kDefaultTCPMSS + 1;
+ LoseNPackets(num_packets_to_lose);
// Immediately after the loss, ensure at least one packet can be sent.
// Losses without subsequent acks can occur with timer based loss detection.
EXPECT_TRUE(sender_->TimeUntilSend(
clock_.Now(), bytes_in_flight_, HAS_RETRANSMITTABLE_DATA).IsZero());
AckNPackets(1);
- // We should now have fallen out of slow start.
- // We expect window to be cut in half by Reno.
- expected_send_window /= 2;
+ // We should now have fallen out of slow start with a reduced window.
+ expected_send_window *= kRenoBeta;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
// Only 2 packets should be allowed to be sent, per PRR-SSRB
@@ -409,15 +411,6 @@ TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) {
// Send 2 packets to simulate PRR-SSRB.
EXPECT_EQ(2, SendAvailableSendWindow());
- AckNPackets(1);
- EXPECT_EQ(2, SendAvailableSendWindow());
-
- AckNPackets(1);
- EXPECT_EQ(2, SendAvailableSendWindow());
-
- // The window should not have changed.
- EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
-
// Exit recovery and return to sending at the new rate.
for (int i = 0; i < kNumberOfAcks; ++i) {
AckNPackets(1);
@@ -609,9 +602,8 @@ TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) {
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;
+ // We should now have fallen out of slow start with a reduced window.
+ expected_send_window = expected_send_window * sender_->GetRenoBeta();
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
// No congestion window growth should occur in recovery phase, i.e., until the
@@ -626,22 +618,25 @@ TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) {
EXPECT_FALSE(sender_->InRecovery());
// Out of recovery now. Congestion window should not grow for half an RTT.
+ size_t packets_in_send_window = expected_send_window / kDefaultTCPMSS;
SendAvailableSendWindow();
- AckNPackets(2);
+ AckNPackets(packets_in_send_window / 2 - 2);
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- // Next ack will be the 5th and should increase congestion window by 1MSS.
+ // Next ack should increase congestion window by 1MSS.
+ SendAvailableSendWindow();
AckNPackets(2);
expected_send_window += kDefaultTCPMSS;
+ packets_in_send_window += 1;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- for (int i = 0; i < 2; ++i) {
- SendAvailableSendWindow();
- AckNPackets(2);
- EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
- }
+ // Congestion window should remain steady again for half an RTT.
+ SendAvailableSendWindow();
+ AckNPackets(packets_in_send_window / 2 - 1);
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
// Next ack should cause congestion window to grow by 1MSS.
+ SendAvailableSendWindow();
AckNPackets(2);
expected_send_window += kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
@@ -663,9 +658,8 @@ TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) {
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;
+ // We should now have fallen out of slow start with a reduced window.
+ expected_send_window *= kRenoBeta;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
// No congestion window growth should occur in recovery phase, i.e., until the
@@ -680,7 +674,7 @@ TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) {
EXPECT_FALSE(sender_->InRecovery());
// Out of recovery now. Congestion window should not grow during RTT.
- for (int i = 0; i < 4; ++i) {
+ for (uint64 i = 0; i < expected_send_window / kDefaultTCPMSS - 2; i += 2) {
// Send our full send window.
SendAvailableSendWindow();
AckNPackets(2);
@@ -688,6 +682,7 @@ TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) {
}
// Next ack should cause congestion window to grow by 1MSS.
+ SendAvailableSendWindow();
AckNPackets(2);
expected_send_window += kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/crypto/common_cert_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698