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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 EXPECT_EQ(expected_ss_tresh, sender_->GetSlowStartThreshold()); | 243 EXPECT_EQ(expected_ss_tresh, sender_->GetSlowStartThreshold()); |
244 EXPECT_EQ(140u, sender_->slowstart_threshold()); | 244 EXPECT_EQ(140u, sender_->slowstart_threshold()); |
245 | 245 |
246 // Now RTO and ensure slow start gets reset. | 246 // Now RTO and ensure slow start gets reset. |
247 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | 247 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
248 sender_->OnRetransmissionTimeout(true); | 248 sender_->OnRetransmissionTimeout(true); |
249 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 249 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
250 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | 250 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
251 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, | 251 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, |
252 sender_->slowstart_threshold()); | 252 sender_->slowstart_threshold()); |
253 | |
254 // Now revert the RTO and ensure the CWND and slowstart threshold revert. | |
255 sender_->RevertRetransmissionTimeout(); | |
256 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | |
257 EXPECT_EQ(140u, sender_->slowstart_threshold()); | |
258 } | 253 } |
259 | 254 |
260 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { | 255 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
261 sender_->SetNumEmulatedConnections(1); | 256 sender_->SetNumEmulatedConnections(1); |
262 const int kNumberOfAcks = 10; | 257 const int kNumberOfAcks = 10; |
263 for (int i = 0; i < kNumberOfAcks; ++i) { | 258 for (int i = 0; i < kNumberOfAcks; ++i) { |
264 // Send our full send window. | 259 // Send our full send window. |
265 SendAvailableSendWindow(); | 260 SendAvailableSendWindow(); |
266 AckNPackets(2); | 261 AckNPackets(2); |
267 } | 262 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // Send 2 packets to simulate PRR-SSRB. | 409 // Send 2 packets to simulate PRR-SSRB. |
415 EXPECT_EQ(2, SendAvailableSendWindow()); | 410 EXPECT_EQ(2, SendAvailableSendWindow()); |
416 | 411 |
417 // Exit recovery and return to sending at the new rate. | 412 // Exit recovery and return to sending at the new rate. |
418 for (int i = 0; i < kNumberOfAcks; ++i) { | 413 for (int i = 0; i < kNumberOfAcks; ++i) { |
419 AckNPackets(1); | 414 AckNPackets(1); |
420 EXPECT_EQ(1, SendAvailableSendWindow()); | 415 EXPECT_EQ(1, SendAvailableSendWindow()); |
421 } | 416 } |
422 } | 417 } |
423 | 418 |
424 TEST_F(TcpCubicSenderTest, RTOCongestionWindowAndRevert) { | 419 TEST_F(TcpCubicSenderTest, RTOCongestionWindow) { |
425 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 420 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
426 EXPECT_EQ(kMaxTcpCongestionWindow, sender_->slowstart_threshold()); | 421 EXPECT_EQ(kMaxTcpCongestionWindow, sender_->slowstart_threshold()); |
427 | 422 |
428 // Expect the window to decrease to the minimum once the RTO fires | 423 // Expect the window to decrease to the minimum once the RTO fires |
429 // and slow start threshold to be set to 1/2 of the CWND. | 424 // and slow start threshold to be set to 1/2 of the CWND. |
430 sender_->OnRetransmissionTimeout(true); | 425 sender_->OnRetransmissionTimeout(true); |
431 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | 426 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
432 EXPECT_EQ(5u, sender_->slowstart_threshold()); | 427 EXPECT_EQ(5u, sender_->slowstart_threshold()); |
433 | |
434 // Now repair the RTO and ensure the slowstart threshold reverts. | |
435 sender_->RevertRetransmissionTimeout(); | |
436 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | |
437 EXPECT_EQ(kMaxTcpCongestionWindow, sender_->slowstart_threshold()); | |
438 } | 428 } |
439 | 429 |
440 TEST_F(TcpCubicSenderTest, RTOCongestionWindowNoRetransmission) { | 430 TEST_F(TcpCubicSenderTest, RTOCongestionWindowNoRetransmission) { |
441 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 431 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
442 | 432 |
443 // Expect the window to remain unchanged if the RTO fires but no | 433 // Expect the window to remain unchanged if the RTO fires but no |
444 // packets are retransmitted. | 434 // packets are retransmitted. |
445 sender_->OnRetransmissionTimeout(false); | 435 sender_->OnRetransmissionTimeout(false); |
446 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 436 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
447 } | 437 } |
448 | 438 |
449 TEST_F(TcpCubicSenderTest, RTOTwiceOnlyHalvesSsthresh) { | |
450 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | |
451 | |
452 sender_->OnRetransmissionTimeout(true); | |
453 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | |
454 EXPECT_EQ(5u, sender_->slowstart_threshold()); | |
455 | |
456 sender_->OnRetransmissionTimeout(true); | |
457 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | |
458 EXPECT_EQ(5u, sender_->slowstart_threshold()); | |
459 | |
460 AckNPackets(2); | |
461 | |
462 EXPECT_EQ(4 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | |
463 EXPECT_EQ(5u, sender_->slowstart_threshold()); | |
464 | |
465 sender_->OnRetransmissionTimeout(true); | |
466 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | |
467 EXPECT_EQ(2u, sender_->slowstart_threshold()); | |
468 } | |
469 | |
470 TEST_F(TcpCubicSenderTest, RetransmissionDelay) { | 439 TEST_F(TcpCubicSenderTest, RetransmissionDelay) { |
471 const int64 kRttMs = 10; | 440 const int64 kRttMs = 10; |
472 const int64 kDeviationMs = 3; | 441 const int64 kDeviationMs = 3; |
473 EXPECT_EQ(QuicTime::Delta::Zero(), sender_->RetransmissionDelay()); | 442 EXPECT_EQ(QuicTime::Delta::Zero(), sender_->RetransmissionDelay()); |
474 | 443 |
475 sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(kRttMs), | 444 sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(kRttMs), |
476 QuicTime::Delta::Zero(), clock_.Now()); | 445 QuicTime::Delta::Zero(), clock_.Now()); |
477 | 446 |
478 // Initial value is to set the median deviation to half of the initial | 447 // Initial value is to set the median deviation to half of the initial |
479 // rtt, the median in then multiplied by a factor of 4 and finally the | 448 // rtt, the median in then multiplied by a factor of 4 and finally the |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 | 721 |
753 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 722 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
754 (kMinCongestionWindowForBandwidthResumption - 1) * kMaxPacketSize); | 723 (kMinCongestionWindowForBandwidthResumption - 1) * kMaxPacketSize); |
755 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); | 724 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); |
756 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption, | 725 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption, |
757 sender_->congestion_window()); | 726 sender_->congestion_window()); |
758 } | 727 } |
759 | 728 |
760 } // namespace test | 729 } // namespace test |
761 } // namespace net | 730 } // namespace net |
OLD | NEW |