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

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

Issue 1037643002: Land Recent QUIC Changes until 03/22/2015. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: deleted duplicated using statements in net/tools/quic/test_tools/quic_test_utils.cc Created 5 years, 8 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "net/quic/congestion_control/tcp_cubic_bytes_sender.h" 5 #include "net/quic/congestion_control/tcp_cubic_bytes_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 QuicPacketSequenceNumber sequence_number_; 120 QuicPacketSequenceNumber sequence_number_;
121 QuicPacketSequenceNumber acked_sequence_number_; 121 QuicPacketSequenceNumber acked_sequence_number_;
122 QuicByteCount bytes_in_flight_; 122 QuicByteCount bytes_in_flight_;
123 TransmissionInfo standard_packet_; 123 TransmissionInfo standard_packet_;
124 }; 124 };
125 125
126 TEST_F(TcpCubicBytesSenderTest, SimpleSender) { 126 TEST_F(TcpCubicBytesSenderTest, SimpleSender) {
127 // At startup make sure we are at the default. 127 // At startup make sure we are at the default.
128 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 128 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
129 // At startup make sure we can send. 129 // At startup make sure we can send.
130 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 130 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
131 .IsZero()); 131 HAS_RETRANSMITTABLE_DATA).IsZero());
132 // Make sure we can send. 132 // Make sure we can send.
133 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 133 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
134 .IsZero()); 134 HAS_RETRANSMITTABLE_DATA).IsZero());
135 // And that window is un-affected. 135 // And that window is un-affected.
136 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 136 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
137 137
138 // Fill the send window with data, then verify that we can't send. 138 // Fill the send window with data, then verify that we can't send.
139 SendAvailableSendWindow(); 139 SendAvailableSendWindow();
140 EXPECT_FALSE(sender_->TimeUntilSend(clock_.Now(), 140 EXPECT_FALSE(sender_->TimeUntilSend(clock_.Now(),
141 sender_->GetCongestionWindow(), 141 sender_->GetCongestionWindow(),
142 HAS_RETRANSMITTABLE_DATA).IsZero()); 142 HAS_RETRANSMITTABLE_DATA).IsZero());
143 } 143 }
144 144
145 TEST_F(TcpCubicBytesSenderTest, ApplicationLimitedSlowStart) { 145 TEST_F(TcpCubicBytesSenderTest, ApplicationLimitedSlowStart) {
146 // Send exactly 10 packets and ensure the CWND ends at 14 packets. 146 // Send exactly 10 packets and ensure the CWND ends at 14 packets.
147 const int kNumberOfAcks = 5; 147 const int kNumberOfAcks = 5;
148 // At startup make sure we can send. 148 // At startup make sure we can send.
149 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 149 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
150 .IsZero()); 150 HAS_RETRANSMITTABLE_DATA).IsZero());
151 // Make sure we can send. 151 // Make sure we can send.
152 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 152 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
153 .IsZero()); 153 HAS_RETRANSMITTABLE_DATA).IsZero());
154 154
155 SendAvailableSendWindow(); 155 SendAvailableSendWindow();
156 for (int i = 0; i < kNumberOfAcks; ++i) { 156 for (int i = 0; i < kNumberOfAcks; ++i) {
157 AckNPackets(2); 157 AckNPackets(2);
158 } 158 }
159 QuicByteCount bytes_to_send = sender_->GetCongestionWindow(); 159 QuicByteCount bytes_to_send = sender_->GetCongestionWindow();
160 // It's expected 2 acks will arrive when the bytes_in_flight are greater than 160 // It's expected 2 acks will arrive when the bytes_in_flight are greater than
161 // half the CWND. 161 // half the CWND.
162 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send); 162 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send);
163 } 163 }
164 164
165 TEST_F(TcpCubicBytesSenderTest, ExponentialSlowStart) { 165 TEST_F(TcpCubicBytesSenderTest, ExponentialSlowStart) {
166 const int kNumberOfAcks = 20; 166 const int kNumberOfAcks = 20;
167 // At startup make sure we can send. 167 // At startup make sure we can send.
168 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 168 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
169 .IsZero()); 169 HAS_RETRANSMITTABLE_DATA).IsZero());
170 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate()); 170 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate());
171 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate()); 171 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate());
172 // Make sure we can send. 172 // Make sure we can send.
173 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 173 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
174 .IsZero()); 174 HAS_RETRANSMITTABLE_DATA).IsZero());
175 175
176 for (int i = 0; i < kNumberOfAcks; ++i) { 176 for (int i = 0; i < kNumberOfAcks; ++i) {
177 // Send our full send window. 177 // Send our full send window.
178 SendAvailableSendWindow(); 178 SendAvailableSendWindow();
179 AckNPackets(2); 179 AckNPackets(2);
180 } 180 }
181 const QuicByteCount cwnd = sender_->GetCongestionWindow(); 181 const QuicByteCount cwnd = sender_->GetCongestionWindow();
182 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd); 182 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd);
183 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate()); 183 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate());
184 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta( 184 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta(
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 HAS_RETRANSMITTABLE_DATA)); 473 HAS_RETRANSMITTABLE_DATA));
474 } 474 }
475 475
476 TEST_F(TcpCubicBytesSenderTest, ConfigureMaxInitialWindow) { 476 TEST_F(TcpCubicBytesSenderTest, ConfigureMaxInitialWindow) {
477 QuicConfig config; 477 QuicConfig config;
478 478
479 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10. 479 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10.
480 QuicTagVector options; 480 QuicTagVector options;
481 options.push_back(kIW10); 481 options.push_back(kIW10);
482 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 482 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
483 sender_->SetFromConfig(config, 483 sender_->SetFromConfig(config, Perspective::IS_SERVER,
484 /* is_server= */ Perspective::IS_SERVER,
485 /* using_pacing= */ false); 484 /* using_pacing= */ false);
486 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); 485 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow());
487 } 486 }
488 487
489 TEST_F(TcpCubicBytesSenderTest, DisableAckTrainDetectionWithPacing) { 488 TEST_F(TcpCubicBytesSenderTest, DisableAckTrainDetectionWithPacing) {
490 EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection()); 489 EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection());
491 490
492 QuicConfig config; 491 QuicConfig config;
493 sender_->SetFromConfig(config, 492 sender_->SetFromConfig(config, Perspective::IS_SERVER,
494 /* is_server= */ Perspective::IS_SERVER,
495 /* using_pacing= */ true); 493 /* using_pacing= */ true);
496 EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection()); 494 EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection());
497 } 495 }
498 496
499 TEST_F(TcpCubicBytesSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { 497 TEST_F(TcpCubicBytesSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) {
500 sender_->SetNumEmulatedConnections(2); 498 sender_->SetNumEmulatedConnections(2);
501 // Ack 10 packets in 5 acks to raise the CWND to 20. 499 // Ack 10 packets in 5 acks to raise the CWND to 20.
502 const int kNumberOfAcks = 5; 500 const int kNumberOfAcks = 5;
503 for (int i = 0; i < kNumberOfAcks; ++i) { 501 for (int i = 0; i < kNumberOfAcks; ++i) {
504 // Send our full send window. 502 // Send our full send window.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 const QuicPacketCount kNumberOfPackets = 123; 606 const QuicPacketCount kNumberOfPackets = 123;
609 const int kBandwidthEstimateBytesPerSecond = 607 const int kBandwidthEstimateBytesPerSecond =
610 kNumberOfPackets * kDefaultTCPMSS; 608 kNumberOfPackets * kDefaultTCPMSS;
611 cached_network_params.set_bandwidth_estimate_bytes_per_second( 609 cached_network_params.set_bandwidth_estimate_bytes_per_second(
612 kBandwidthEstimateBytesPerSecond); 610 kBandwidthEstimateBytesPerSecond);
613 cached_network_params.set_min_rtt_ms(1000); 611 cached_network_params.set_min_rtt_ms(1000);
614 612
615 // Ensure that an old estimate is not used for bandwidth resumption. 613 // Ensure that an old estimate is not used for bandwidth resumption.
616 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - 614 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() -
617 (kNumSecondsPerHour + 1)); 615 (kNumSecondsPerHour + 1));
618 EXPECT_FALSE(sender_->ResumeConnectionState(cached_network_params)); 616 EXPECT_FALSE(sender_->ResumeConnectionState(cached_network_params, false));
619 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); 617 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow());
620 618
621 // If the estimate is new enough, make sure it is used. 619 // If the estimate is new enough, make sure it is used.
622 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - 620 cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() -
623 (kNumSecondsPerHour - 1)); 621 (kNumSecondsPerHour - 1));
624 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); 622 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false));
625 EXPECT_EQ(kNumberOfPackets * kDefaultTCPMSS, sender_->GetCongestionWindow()); 623 EXPECT_EQ(kNumberOfPackets * kDefaultTCPMSS, sender_->GetCongestionWindow());
626 624
627 // Resumed CWND is limited to be in a sensible range. 625 // Resumed CWND is limited to be in a sensible range.
628 cached_network_params.set_bandwidth_estimate_bytes_per_second( 626 cached_network_params.set_bandwidth_estimate_bytes_per_second(
629 (kMaxTcpCongestionWindow + 1) * kDefaultTCPMSS); 627 (kMaxTcpCongestionWindow + 1) * kDefaultTCPMSS);
630 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); 628 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false));
631 EXPECT_EQ(kMaxTcpCongestionWindow * kDefaultTCPMSS, 629 EXPECT_EQ(kMaxTcpCongestionWindow * kDefaultTCPMSS,
632 sender_->GetCongestionWindow()); 630 sender_->GetCongestionWindow());
633 631
634 cached_network_params.set_bandwidth_estimate_bytes_per_second( 632 cached_network_params.set_bandwidth_estimate_bytes_per_second(
635 (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS); 633 (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS);
636 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); 634 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, false));
637 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS, 635 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS,
638 sender_->GetCongestionWindow()); 636 sender_->GetCongestionWindow());
637
638 // Resume to the max value.
639 cached_network_params.set_max_bandwidth_estimate_bytes_per_second(
640 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS);
641 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, true));
642 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS,
643 sender_->GetCongestionWindow());
639 } 644 }
640 645
641 } // namespace test 646 } // namespace test
642 } // namespace net 647 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_bytes_sender.cc ('k') | net/quic/congestion_control/tcp_cubic_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698