OLD | NEW |
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 AckNPackets(2); | 200 AckNPackets(2); |
201 } | 201 } |
202 const QuicByteCount cwnd = sender_->GetCongestionWindow(); | 202 const QuicByteCount cwnd = sender_->GetCongestionWindow(); |
203 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd); | 203 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd); |
204 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate()); | 204 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate()); |
205 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta( | 205 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta( |
206 cwnd, sender_->rtt_stats_.smoothed_rtt()), | 206 cwnd, sender_->rtt_stats_.smoothed_rtt()), |
207 sender_->BandwidthEstimate()); | 207 sender_->BandwidthEstimate()); |
208 } | 208 } |
209 | 209 |
210 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { | |
211 sender_->SetNumEmulatedConnections(1); | |
212 EXPECT_EQ(kMaxTcpCongestionWindow * kDefaultTCPMSS, | |
213 sender_->GetSlowStartThreshold()); | |
214 | |
215 // Make sure that we fall out of slow start when we send ACK train longer | |
216 // than half the RTT, in this test case 30ms, which is more than 30 calls to | |
217 // Ack2Packets in one round. | |
218 // Since we start at 10 packet first round will be 5 second round 10 etc | |
219 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30 | |
220 const int kNumberOfAcks = 65; | |
221 for (int i = 0; i < kNumberOfAcks; ++i) { | |
222 // Send our full send window. | |
223 SendAvailableSendWindow(); | |
224 AckNPackets(2); | |
225 } | |
226 QuicByteCount expected_send_window = | |
227 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); | |
228 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | |
229 | |
230 // We should now have fallen out of slow start. | |
231 // Testing Reno phase. | |
232 // We should need 140(65*2+10) ACK:ed packets before increasing window by | |
233 // one. | |
234 for (int i = 0; i < 69; ++i) { | |
235 SendAvailableSendWindow(); | |
236 AckNPackets(2); | |
237 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | |
238 } | |
239 SendAvailableSendWindow(); | |
240 AckNPackets(2); | |
241 QuicByteCount expected_ss_tresh = expected_send_window; | |
242 expected_send_window += kDefaultTCPMSS; | |
243 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | |
244 EXPECT_EQ(expected_ss_tresh, sender_->GetSlowStartThreshold()); | |
245 EXPECT_EQ(140u, sender_->slowstart_threshold()); | |
246 | |
247 // Now RTO and ensure slow start gets reset. | |
248 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | |
249 sender_->OnRetransmissionTimeout(true); | |
250 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | |
251 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | |
252 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, | |
253 sender_->slowstart_threshold()); | |
254 } | |
255 | |
256 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { | 210 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
257 sender_->SetNumEmulatedConnections(1); | 211 sender_->SetNumEmulatedConnections(1); |
258 const int kNumberOfAcks = 10; | 212 const int kNumberOfAcks = 10; |
259 for (int i = 0; i < kNumberOfAcks; ++i) { | 213 for (int i = 0; i < kNumberOfAcks; ++i) { |
260 // Send our full send window. | 214 // Send our full send window. |
261 SendAvailableSendWindow(); | 215 SendAvailableSendWindow(); |
262 AckNPackets(2); | 216 AckNPackets(2); |
263 } | 217 } |
264 SendAvailableSendWindow(); | 218 SendAvailableSendWindow(); |
265 QuicByteCount expected_send_window = kDefaultWindowTCP + | 219 QuicByteCount expected_send_window = kDefaultWindowTCP + |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 HAS_RETRANSMITTABLE_DATA)); | 513 HAS_RETRANSMITTABLE_DATA)); |
560 } | 514 } |
561 | 515 |
562 TEST_F(TcpCubicSenderTest, ConfigureInitialWindow) { | 516 TEST_F(TcpCubicSenderTest, ConfigureInitialWindow) { |
563 QuicConfig config; | 517 QuicConfig config; |
564 | 518 |
565 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10. | 519 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10. |
566 QuicTagVector options; | 520 QuicTagVector options; |
567 options.push_back(kIW10); | 521 options.push_back(kIW10); |
568 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 522 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
569 sender_->SetFromConfig(config, Perspective::IS_SERVER, | 523 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
570 /* using_pacing= */ false); | |
571 EXPECT_EQ(10u, sender_->congestion_window()); | 524 EXPECT_EQ(10u, sender_->congestion_window()); |
572 } | 525 } |
573 | 526 |
574 TEST_F(TcpCubicSenderTest, ConfigureMinimumWindow) { | 527 TEST_F(TcpCubicSenderTest, ConfigureMinimumWindow) { |
575 QuicConfig config; | 528 QuicConfig config; |
576 | 529 |
577 // Verify that kCOPT: kMIN1 forces the min CWND to 1 packet. | 530 // Verify that kCOPT: kMIN1 forces the min CWND to 1 packet. |
578 QuicTagVector options; | 531 QuicTagVector options; |
579 options.push_back(kMIN1); | 532 options.push_back(kMIN1); |
580 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 533 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
581 sender_->SetFromConfig(config, Perspective::IS_SERVER, | 534 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
582 /* using_pacing= */ false); | |
583 sender_->OnRetransmissionTimeout(true); | 535 sender_->OnRetransmissionTimeout(true); |
584 EXPECT_EQ(1u, sender_->congestion_window()); | 536 EXPECT_EQ(1u, sender_->congestion_window()); |
585 } | 537 } |
586 | 538 |
587 TEST_F(TcpCubicSenderTest, DisableAckTrainDetectionWithPacing) { | |
588 EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection()); | |
589 | |
590 QuicConfig config; | |
591 sender_->SetFromConfig(config, Perspective::IS_SERVER, | |
592 /* using_pacing= */ true); | |
593 EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection()); | |
594 } | |
595 | |
596 TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { | 539 TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { |
597 sender_->SetNumEmulatedConnections(2); | 540 sender_->SetNumEmulatedConnections(2); |
598 // Ack 10 packets in 5 acks to raise the CWND to 20. | 541 // Ack 10 packets in 5 acks to raise the CWND to 20. |
599 const int kNumberOfAcks = 5; | 542 const int kNumberOfAcks = 5; |
600 for (int i = 0; i < kNumberOfAcks; ++i) { | 543 for (int i = 0; i < kNumberOfAcks; ++i) { |
601 // Send our full send window. | 544 // Send our full send window. |
602 SendAvailableSendWindow(); | 545 SendAvailableSendWindow(); |
603 AckNPackets(2); | 546 AckNPackets(2); |
604 } | 547 } |
605 SendAvailableSendWindow(); | 548 SendAvailableSendWindow(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 // Resume to the max value. | 679 // Resume to the max value. |
737 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( | 680 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( |
738 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); | 681 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); |
739 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, true)); | 682 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, true)); |
740 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, | 683 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, |
741 sender_->GetCongestionWindow()); | 684 sender_->GetCongestionWindow()); |
742 } | 685 } |
743 | 686 |
744 } // namespace test | 687 } // namespace test |
745 } // namespace net | 688 } // namespace net |
OLD | NEW |