| 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 19 matching lines...) Expand all Loading... |
| 30 bool reno, | 30 bool reno, |
| 31 QuicTcpCongestionWindow max_tcp_congestion_window) | 31 QuicTcpCongestionWindow max_tcp_congestion_window) |
| 32 : TcpCubicSender( | 32 : TcpCubicSender( |
| 33 clock, &rtt_stats_, reno, max_tcp_congestion_window, &stats_) { | 33 clock, &rtt_stats_, reno, max_tcp_congestion_window, &stats_) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 QuicTcpCongestionWindow congestion_window() { | 36 QuicTcpCongestionWindow congestion_window() { |
| 37 return congestion_window_; | 37 return congestion_window_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 QuicTcpCongestionWindow slowstart_threshold() { |
| 41 return slowstart_threshold_; |
| 42 } |
| 43 |
| 40 const HybridSlowStart& hybrid_slow_start() const { | 44 const HybridSlowStart& hybrid_slow_start() const { |
| 41 return hybrid_slow_start_; | 45 return hybrid_slow_start_; |
| 42 } | 46 } |
| 43 | 47 |
| 44 RttStats rtt_stats_; | 48 RttStats rtt_stats_; |
| 45 QuicConnectionStats stats_; | 49 QuicConnectionStats stats_; |
| 46 | 50 |
| 47 using TcpCubicSender::SendWindow; | 51 using TcpCubicSender::SendWindow; |
| 48 }; | 52 }; |
| 49 | 53 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // one. | 233 // one. |
| 230 for (int i = 0; i < 69; ++i) { | 234 for (int i = 0; i < 69; ++i) { |
| 231 SendAvailableSendWindow(); | 235 SendAvailableSendWindow(); |
| 232 AckNPackets(2); | 236 AckNPackets(2); |
| 233 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 237 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 234 } | 238 } |
| 235 SendAvailableSendWindow(); | 239 SendAvailableSendWindow(); |
| 236 AckNPackets(2); | 240 AckNPackets(2); |
| 237 expected_send_window += kDefaultTCPMSS; | 241 expected_send_window += kDefaultTCPMSS; |
| 238 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 242 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 243 EXPECT_EQ(140u, sender_->slowstart_threshold()); |
| 239 | 244 |
| 240 // Now RTO and ensure slow start gets reset. | 245 // Now RTO and ensure slow start gets reset. |
| 241 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | 246 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
| 242 sender_->OnRetransmissionTimeout(true); | 247 sender_->OnRetransmissionTimeout(true); |
| 243 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 248 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
| 249 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
| 250 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, |
| 251 sender_->slowstart_threshold()); |
| 252 |
| 253 // Now revert the RTO and ensure the CWND and slowstart threshold revert. |
| 254 sender_->RevertRetransmissionTimeout(); |
| 255 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 256 EXPECT_EQ(140u, sender_->slowstart_threshold()); |
| 244 } | 257 } |
| 245 | 258 |
| 246 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { | 259 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
| 247 // Make sure that we fall out of slow start when we encounter a packet loss. | 260 // Make sure that we fall out of slow start when we encounter a packet loss. |
| 248 QuicCongestionFeedbackFrame feedback; | 261 QuicCongestionFeedbackFrame feedback; |
| 249 // Get default QuicCongestionFeedbackFrame from receiver. | 262 // Get default QuicCongestionFeedbackFrame from receiver. |
| 250 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | 263 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); |
| 251 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | 264 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); |
| 252 | 265 |
| 253 const int kNumberOfAcks = 10; | 266 const int kNumberOfAcks = 10; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // The window should not have changed. | 427 // The window should not have changed. |
| 415 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 428 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 416 | 429 |
| 417 // Exit recovery and return to sending at the new rate. | 430 // Exit recovery and return to sending at the new rate. |
| 418 for (int i = 0; i < kNumberOfAcks; ++i) { | 431 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 419 AckNPackets(1); | 432 AckNPackets(1); |
| 420 EXPECT_EQ(1, SendAvailableSendWindow()); | 433 EXPECT_EQ(1, SendAvailableSendWindow()); |
| 421 } | 434 } |
| 422 } | 435 } |
| 423 | 436 |
| 424 TEST_F(TcpCubicSenderTest, RTOCongestionWindow) { | 437 TEST_F(TcpCubicSenderTest, RTOCongestionWindowAndRevert) { |
| 425 EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); | 438 EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); |
| 439 EXPECT_EQ(10000u, sender_->slowstart_threshold()); |
| 426 | 440 |
| 427 // Expect the window to decrease to the minimum once the RTO fires. | 441 // Expect the window to decrease to the minimum once the RTO fires |
| 442 // and slow start threshold to be set to 1/2 of the CWND. |
| 428 sender_->OnRetransmissionTimeout(true); | 443 sender_->OnRetransmissionTimeout(true); |
| 429 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->SendWindow()); | 444 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->SendWindow()); |
| 445 EXPECT_EQ(5u, sender_->slowstart_threshold()); |
| 446 |
| 447 // Now repair the RTO and ensure the slowstart threshold reverts. |
| 448 sender_->RevertRetransmissionTimeout(); |
| 449 EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); |
| 450 EXPECT_EQ(10000u, sender_->slowstart_threshold()); |
| 430 } | 451 } |
| 431 | 452 |
| 432 TEST_F(TcpCubicSenderTest, RTOCongestionWindowNoRetransmission) { | 453 TEST_F(TcpCubicSenderTest, RTOCongestionWindowNoRetransmission) { |
| 433 EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); | 454 EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); |
| 434 | 455 |
| 435 // Expect the window to remain unchanged if the RTO fires but no | 456 // Expect the window to remain unchanged if the RTO fires but no |
| 436 // packets are retransmitted. | 457 // packets are retransmitted. |
| 437 sender_->OnRetransmissionTimeout(false); | 458 sender_->OnRetransmissionTimeout(false); |
| 438 EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); | 459 EXPECT_EQ(kDefaultWindowTCP, sender_->SendWindow()); |
| 439 } | 460 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 } | 652 } |
| 632 | 653 |
| 633 // Next ack should cause congestion window to grow by 1MSS. | 654 // Next ack should cause congestion window to grow by 1MSS. |
| 634 AckNPackets(2); | 655 AckNPackets(2); |
| 635 expected_send_window += kDefaultTCPMSS; | 656 expected_send_window += kDefaultTCPMSS; |
| 636 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 657 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 637 } | 658 } |
| 638 | 659 |
| 639 } // namespace test | 660 } // namespace test |
| 640 } // namespace net | 661 } // namespace net |
| OLD | NEW |