| OLD | NEW |
| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 185 cwnd, sender_->rtt_stats_.smoothed_rtt()), | 185 cwnd, sender_->rtt_stats_.smoothed_rtt()), |
| 186 sender_->BandwidthEstimate()); | 186 sender_->BandwidthEstimate()); |
| 187 } | 187 } |
| 188 | 188 |
| 189 TEST_F(TcpCubicBytesSenderTest, SlowStartAckTrain) { | |
| 190 sender_->SetNumEmulatedConnections(1); | |
| 191 | |
| 192 // Make sure that we fall out of slow start when we send ACK train longer | |
| 193 // than half the RTT, in this test case 30ms, which is more than 30 calls to | |
| 194 // Ack2Packets in one round. | |
| 195 // Since we start at 10 packet first round will be 5 second round 10 etc | |
| 196 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30. | |
| 197 const int kNumberOfAcks = 65; | |
| 198 for (int i = 0; i < kNumberOfAcks; ++i) { | |
| 199 // Send our full send window. | |
| 200 SendAvailableSendWindow(); | |
| 201 AckNPackets(2); | |
| 202 } | |
| 203 QuicByteCount expected_send_window = | |
| 204 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); | |
| 205 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | |
| 206 | |
| 207 // We should now have fallen out of slow start. | |
| 208 // Testing Reno phase. | |
| 209 // We should need 140(65*2+10) ACK:ed packets before increasing window by | |
| 210 // one. | |
| 211 for (int i = 0; i < 69; ++i) { | |
| 212 SendAvailableSendWindow(); | |
| 213 AckNPackets(2); | |
| 214 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | |
| 215 } | |
| 216 SendAvailableSendWindow(); | |
| 217 AckNPackets(2); | |
| 218 QuicByteCount expected_ss_tresh = expected_send_window; | |
| 219 expected_send_window += kDefaultTCPMSS; | |
| 220 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | |
| 221 EXPECT_EQ(expected_ss_tresh, sender_->GetSlowStartThreshold()); | |
| 222 | |
| 223 // Now RTO and ensure slow start gets reset. | |
| 224 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | |
| 225 sender_->OnRetransmissionTimeout(true); | |
| 226 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | |
| 227 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | |
| 228 EXPECT_EQ(expected_send_window / 2, sender_->GetSlowStartThreshold()); | |
| 229 } | |
| 230 | |
| 231 TEST_F(TcpCubicBytesSenderTest, SlowStartPacketLoss) { | 189 TEST_F(TcpCubicBytesSenderTest, SlowStartPacketLoss) { |
| 232 sender_->SetNumEmulatedConnections(1); | 190 sender_->SetNumEmulatedConnections(1); |
| 233 const int kNumberOfAcks = 10; | 191 const int kNumberOfAcks = 10; |
| 234 for (int i = 0; i < kNumberOfAcks; ++i) { | 192 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 235 // Send our full send window. | 193 // Send our full send window. |
| 236 SendAvailableSendWindow(); | 194 SendAvailableSendWindow(); |
| 237 AckNPackets(2); | 195 AckNPackets(2); |
| 238 } | 196 } |
| 239 SendAvailableSendWindow(); | 197 SendAvailableSendWindow(); |
| 240 QuicByteCount expected_send_window = | 198 QuicByteCount expected_send_window = |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 HAS_RETRANSMITTABLE_DATA)); | 431 HAS_RETRANSMITTABLE_DATA)); |
| 474 } | 432 } |
| 475 | 433 |
| 476 TEST_F(TcpCubicBytesSenderTest, ConfigureMaxInitialWindow) { | 434 TEST_F(TcpCubicBytesSenderTest, ConfigureMaxInitialWindow) { |
| 477 QuicConfig config; | 435 QuicConfig config; |
| 478 | 436 |
| 479 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10. | 437 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10. |
| 480 QuicTagVector options; | 438 QuicTagVector options; |
| 481 options.push_back(kIW10); | 439 options.push_back(kIW10); |
| 482 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 440 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 483 sender_->SetFromConfig(config, Perspective::IS_SERVER, | 441 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
| 484 /* using_pacing= */ false); | |
| 485 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); | 442 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
| 486 } | 443 } |
| 487 | 444 |
| 488 TEST_F(TcpCubicBytesSenderTest, DisableAckTrainDetectionWithPacing) { | |
| 489 EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection()); | |
| 490 | |
| 491 QuicConfig config; | |
| 492 sender_->SetFromConfig(config, Perspective::IS_SERVER, | |
| 493 /* using_pacing= */ true); | |
| 494 EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection()); | |
| 495 } | |
| 496 | |
| 497 TEST_F(TcpCubicBytesSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { | 445 TEST_F(TcpCubicBytesSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { |
| 498 sender_->SetNumEmulatedConnections(2); | 446 sender_->SetNumEmulatedConnections(2); |
| 499 // Ack 10 packets in 5 acks to raise the CWND to 20. | 447 // Ack 10 packets in 5 acks to raise the CWND to 20. |
| 500 const int kNumberOfAcks = 5; | 448 const int kNumberOfAcks = 5; |
| 501 for (int i = 0; i < kNumberOfAcks; ++i) { | 449 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 502 // Send our full send window. | 450 // Send our full send window. |
| 503 SendAvailableSendWindow(); | 451 SendAvailableSendWindow(); |
| 504 AckNPackets(2); | 452 AckNPackets(2); |
| 505 } | 453 } |
| 506 SendAvailableSendWindow(); | 454 SendAvailableSendWindow(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // Resume to the max value. | 586 // Resume to the max value. |
| 639 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( | 587 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( |
| 640 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); | 588 (kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS); |
| 641 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, true)); | 589 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params, true)); |
| 642 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, | 590 EXPECT_EQ((kMinCongestionWindowForBandwidthResumption + 10) * kDefaultTCPMSS, |
| 643 sender_->GetCongestionWindow()); | 591 sender_->GetCongestionWindow()); |
| 644 } | 592 } |
| 645 | 593 |
| 646 } // namespace test | 594 } // namespace test |
| 647 } // namespace net | 595 } // namespace net |
| OLD | NEW |