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

Side by Side Diff: net/quic/congestion_control/tcp_cubic_sender_test.cc

Issue 610053002: Allow the number of connections QUIC's send algorithms simulate to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Remove_QUIC_VERSION_16_76286812
Patch Set: Created 6 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "net/quic/congestion_control/rtt_stats.h" 9 #include "net/quic/congestion_control/rtt_stats.h"
10 #include "net/quic/congestion_control/tcp_cubic_sender.h" 10 #include "net/quic/congestion_control/tcp_cubic_sender.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // Send our full send window. 194 // Send our full send window.
195 SendAvailableSendWindow(); 195 SendAvailableSendWindow();
196 AckNPackets(2); 196 AckNPackets(2);
197 } 197 }
198 QuicByteCount bytes_to_send = sender_->SendWindow(); 198 QuicByteCount bytes_to_send = sender_->SendWindow();
199 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, 199 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks,
200 bytes_to_send); 200 bytes_to_send);
201 } 201 }
202 202
203 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { 203 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) {
204 sender_->SetNumEmulatedConnections(1);
204 EXPECT_EQ(kDefaultMaxCongestionWindowTCP * kDefaultTCPMSS, 205 EXPECT_EQ(kDefaultMaxCongestionWindowTCP * kDefaultTCPMSS,
205 sender_->GetSlowStartThreshold()); 206 sender_->GetSlowStartThreshold());
206 207
207 // Make sure that we fall out of slow start when we send ACK train longer 208 // Make sure that we fall out of slow start when we send ACK train longer
208 // than half the RTT, in this test case 30ms, which is more than 30 calls to 209 // than half the RTT, in this test case 30ms, which is more than 30 calls to
209 // Ack2Packets in one round. 210 // Ack2Packets in one round.
210 // Since we start at 10 packet first round will be 5 second round 10 etc 211 // Since we start at 10 packet first round will be 5 second round 10 etc
211 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30 212 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30
212 const int kNumberOfAcks = 65; 213 const int kNumberOfAcks = 65;
213 for (int i = 0; i < kNumberOfAcks; ++i) { 214 for (int i = 0; i < kNumberOfAcks; ++i) {
(...skipping 30 matching lines...) Expand all
244 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, 245 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS,
245 sender_->slowstart_threshold()); 246 sender_->slowstart_threshold());
246 247
247 // Now revert the RTO and ensure the CWND and slowstart threshold revert. 248 // Now revert the RTO and ensure the CWND and slowstart threshold revert.
248 sender_->RevertRetransmissionTimeout(); 249 sender_->RevertRetransmissionTimeout();
249 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 250 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
250 EXPECT_EQ(140u, sender_->slowstart_threshold()); 251 EXPECT_EQ(140u, sender_->slowstart_threshold());
251 } 252 }
252 253
253 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { 254 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) {
255 sender_->SetNumEmulatedConnections(1);
254 const int kNumberOfAcks = 10; 256 const int kNumberOfAcks = 10;
255 for (int i = 0; i < kNumberOfAcks; ++i) { 257 for (int i = 0; i < kNumberOfAcks; ++i) {
256 // Send our full send window. 258 // Send our full send window.
257 SendAvailableSendWindow(); 259 SendAvailableSendWindow();
258 AckNPackets(2); 260 AckNPackets(2);
259 } 261 }
260 SendAvailableSendWindow(); 262 SendAvailableSendWindow();
261 QuicByteCount expected_send_window = kDefaultWindowTCP + 263 QuicByteCount expected_send_window = kDefaultWindowTCP +
262 (kDefaultTCPMSS * 2 * kNumberOfAcks); 264 (kDefaultTCPMSS * 2 * kNumberOfAcks);
263 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 265 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // PRR will allow 2 packets for every ack during recovery. 309 // PRR will allow 2 packets for every ack during recovery.
308 EXPECT_EQ(2, SendAvailableSendWindow()); 310 EXPECT_EQ(2, SendAvailableSendWindow());
309 // Simulate abandoning all packets by supplying a bytes_in_flight of 0. 311 // Simulate abandoning all packets by supplying a bytes_in_flight of 0.
310 // PRR should now allow a packet to be sent, even though prr's state 312 // PRR should now allow a packet to be sent, even though prr's state
311 // variables believe it has sent enough packets. 313 // variables believe it has sent enough packets.
312 EXPECT_EQ(QuicTime::Delta::Zero(), 314 EXPECT_EQ(QuicTime::Delta::Zero(),
313 sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)); 315 sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA));
314 } 316 }
315 317
316 TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { 318 TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) {
319 sender_->SetNumEmulatedConnections(1);
317 // Test based on the first example in RFC6937. 320 // Test based on the first example in RFC6937.
318 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. 321 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example.
319 const int kNumberOfAcks = 5; 322 const int kNumberOfAcks = 5;
320 for (int i = 0; i < kNumberOfAcks; ++i) { 323 for (int i = 0; i < kNumberOfAcks; ++i) {
321 // Send our full send window. 324 // Send our full send window.
322 SendAvailableSendWindow(); 325 SendAvailableSendWindow();
323 AckNPackets(2); 326 AckNPackets(2);
324 } 327 }
325 SendAvailableSendWindow(); 328 SendAvailableSendWindow();
326 QuicByteCount expected_send_window = kDefaultWindowTCP + 329 QuicByteCount expected_send_window = kDefaultWindowTCP +
(...skipping 28 matching lines...) Expand all
355 EXPECT_EQ(1, SendAvailableSendWindow()); 358 EXPECT_EQ(1, SendAvailableSendWindow());
356 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 359 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
357 } 360 }
358 361
359 AckNPackets(1); 362 AckNPackets(1);
360 expected_send_window += kDefaultTCPMSS; 363 expected_send_window += kDefaultTCPMSS;
361 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 364 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
362 } 365 }
363 366
364 TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) { 367 TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) {
368 sender_->SetNumEmulatedConnections(1);
365 // Test based on the second example in RFC6937, though we also implement 369 // Test based on the second example in RFC6937, though we also implement
366 // forward acknowledgements, so the first two incoming acks will trigger 370 // forward acknowledgements, so the first two incoming acks will trigger
367 // PRR immediately. 371 // PRR immediately.
368 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. 372 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example.
369 const int kNumberOfAcks = 5; 373 const int kNumberOfAcks = 5;
370 for (int i = 0; i < kNumberOfAcks; ++i) { 374 for (int i = 0; i < kNumberOfAcks; ++i) {
371 // Send our full send window. 375 // Send our full send window.
372 SendAvailableSendWindow(); 376 SendAvailableSendWindow();
373 AckNPackets(2); 377 AckNPackets(2);
374 } 378 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 588
585 // Verify that kCOPT: kIW10 forces the congestion window to the 589 // Verify that kCOPT: kIW10 forces the congestion window to the
586 // default of 10 regardless of ReceivedInitialWindow. 590 // default of 10 regardless of ReceivedInitialWindow.
587 QuicTagVector options; 591 QuicTagVector options;
588 options.push_back(kIW10); 592 options.push_back(kIW10);
589 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 593 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
590 sender_->SetFromConfig(config, true); 594 sender_->SetFromConfig(config, true);
591 EXPECT_EQ(congestion_window, sender_->congestion_window()); 595 EXPECT_EQ(congestion_window, sender_->congestion_window());
592 } 596 }
593 597
594 TEST_F(TcpCubicSenderTest, CongestionAvoidanceAtEndOfRecovery) { 598 TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) {
599 sender_->SetNumEmulatedConnections(2);
595 // Ack 10 packets in 5 acks to raise the CWND to 20. 600 // Ack 10 packets in 5 acks to raise the CWND to 20.
596 const int kNumberOfAcks = 5; 601 const int kNumberOfAcks = 5;
597 for (int i = 0; i < kNumberOfAcks; ++i) { 602 for (int i = 0; i < kNumberOfAcks; ++i) {
603 // Send our full send window.
604 SendAvailableSendWindow();
605 AckNPackets(2);
606 }
607 SendAvailableSendWindow();
608 QuicByteCount expected_send_window = kDefaultWindowTCP +
609 (kDefaultTCPMSS * 2 * kNumberOfAcks);
610 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
611
612 LoseNPackets(1);
613
614 // We should now have fallen out of slow start, and window should be cut in
615 // half by Reno. New cwnd should be 10.
616 expected_send_window /= 2;
617 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
618
619 // No congestion window growth should occur in recovery phase, i.e., until the
620 // currently outstanding 20 packets are acked.
621 for (int i = 0; i < 10; ++i) {
622 // Send our full send window.
623 SendAvailableSendWindow();
624 EXPECT_TRUE(sender_->InRecovery());
625 AckNPackets(2);
626 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
627 }
628 EXPECT_FALSE(sender_->InRecovery());
629
630 // Out of recovery now. Congestion window should not grow for half an RTT.
631 SendAvailableSendWindow();
632 AckNPackets(2);
633 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
634
635 // Next ack will be the 5th and should increase congestion window by 1MSS.
636 AckNPackets(2);
637 expected_send_window += kDefaultTCPMSS;
638 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
639
640 for (int i = 0; i < 2; ++i) {
641 SendAvailableSendWindow();
642 AckNPackets(2);
643 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
644 }
645
646 // Next ack should cause congestion window to grow by 1MSS.
647 AckNPackets(2);
648 expected_send_window += kDefaultTCPMSS;
649 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
650 }
651
652 TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) {
653 sender_->SetNumEmulatedConnections(1);
654 // Ack 10 packets in 5 acks to raise the CWND to 20.
655 const int kNumberOfAcks = 5;
656 for (int i = 0; i < kNumberOfAcks; ++i) {
598 // Send our full send window. 657 // Send our full send window.
599 SendAvailableSendWindow(); 658 SendAvailableSendWindow();
600 AckNPackets(2); 659 AckNPackets(2);
601 } 660 }
602 SendAvailableSendWindow(); 661 SendAvailableSendWindow();
603 QuicByteCount expected_send_window = kDefaultWindowTCP + 662 QuicByteCount expected_send_window = kDefaultWindowTCP +
604 (kDefaultTCPMSS * 2 * kNumberOfAcks); 663 (kDefaultTCPMSS * 2 * kNumberOfAcks);
605 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 664 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
606 665
607 LoseNPackets(1); 666 LoseNPackets(1);
608 667
609 // We should now have fallen out of slow start, and window should be cut in 668 // We should now have fallen out of slow start, and window should be cut in
610 // half by Reno. New cwnd should be 10. 669 // half by Reno. New cwnd should be 10.
611 expected_send_window /= 2; 670 expected_send_window /= 2;
612 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 671 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
613 672
614 // No congestion window growth should occur in recovery phase, i.e., 673 // No congestion window growth should occur in recovery phase, i.e.,
615 // until the currently outstanding 20 packets are acked. 674 // until the currently outstanding 20 packets are acked.
616 for (int i = 0; i < 10; ++i) { 675 for (int i = 0; i < 10; ++i) {
617 // Send our full send window. 676 // Send our full send window.
618 SendAvailableSendWindow(); 677 SendAvailableSendWindow();
678 EXPECT_TRUE(sender_->InRecovery());
619 AckNPackets(2); 679 AckNPackets(2);
620 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 680 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
621 } 681 }
682 EXPECT_FALSE(sender_->InRecovery());
622 683
623 // Out of recovery now. Congestion window should not grow during RTT. 684 // Out of recovery now. Congestion window should not grow during RTT.
624 for (int i = 0; i < 4; ++i) { 685 for (int i = 0; i < 4; ++i) {
625 // Send our full send window. 686 // Send our full send window.
626 SendAvailableSendWindow(); 687 SendAvailableSendWindow();
627 AckNPackets(2); 688 AckNPackets(2);
628 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 689 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
629 } 690 }
630 691
631 // Next ack should cause congestion window to grow by 1MSS. 692 // Next ack should cause congestion window to grow by 1MSS.
632 AckNPackets(2); 693 AckNPackets(2);
633 expected_send_window += kDefaultTCPMSS; 694 expected_send_window += kDefaultTCPMSS;
634 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 695 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
635 } 696 }
636 697
637 } // namespace test 698 } // namespace test
638 } // namespace net 699 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698