| 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 // Send our full send window. | 200 // Send our full send window. |
| 201 SendAvailableSendWindow(); | 201 SendAvailableSendWindow(); |
| 202 AckNPackets(2); | 202 AckNPackets(2); |
| 203 } | 203 } |
| 204 QuicByteCount bytes_to_send = sender_->SendWindow(); | 204 QuicByteCount bytes_to_send = sender_->SendWindow(); |
| 205 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, | 205 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, |
| 206 bytes_to_send); | 206 bytes_to_send); |
| 207 } | 207 } |
| 208 | 208 |
| 209 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { | 209 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { |
| 210 EXPECT_EQ(kDefaultMaxCongestionWindowTCP * kDefaultTCPMSS, |
| 211 sender_->GetSlowStartThreshold()); |
| 212 |
| 210 // Make sure that we fall out of slow start when we send ACK train longer | 213 // Make sure that we fall out of slow start when we send ACK train longer |
| 211 // than half the RTT, in this test case 30ms, which is more than 30 calls to | 214 // than half the RTT, in this test case 30ms, which is more than 30 calls to |
| 212 // Ack2Packets in one round. | 215 // Ack2Packets in one round. |
| 213 // Since we start at 10 packet first round will be 5 second round 10 etc | 216 // Since we start at 10 packet first round will be 5 second round 10 etc |
| 214 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30 | 217 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30 |
| 215 const int kNumberOfAcks = 65; | 218 const int kNumberOfAcks = 65; |
| 216 QuicCongestionFeedbackFrame feedback; | 219 QuicCongestionFeedbackFrame feedback; |
| 217 // Get default QuicCongestionFeedbackFrame from receiver. | 220 // Get default QuicCongestionFeedbackFrame from receiver. |
| 218 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | 221 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); |
| 219 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | 222 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 231 // Testing Reno phase. | 234 // Testing Reno phase. |
| 232 // We should need 140(65*2+10) ACK:ed packets before increasing window by | 235 // We should need 140(65*2+10) ACK:ed packets before increasing window by |
| 233 // one. | 236 // one. |
| 234 for (int i = 0; i < 69; ++i) { | 237 for (int i = 0; i < 69; ++i) { |
| 235 SendAvailableSendWindow(); | 238 SendAvailableSendWindow(); |
| 236 AckNPackets(2); | 239 AckNPackets(2); |
| 237 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 240 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 238 } | 241 } |
| 239 SendAvailableSendWindow(); | 242 SendAvailableSendWindow(); |
| 240 AckNPackets(2); | 243 AckNPackets(2); |
| 244 QuicByteCount expected_ss_tresh = expected_send_window; |
| 241 expected_send_window += kDefaultTCPMSS; | 245 expected_send_window += kDefaultTCPMSS; |
| 242 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 246 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 247 EXPECT_EQ(expected_ss_tresh, sender_->GetSlowStartThreshold()); |
| 243 EXPECT_EQ(140u, sender_->slowstart_threshold()); | 248 EXPECT_EQ(140u, sender_->slowstart_threshold()); |
| 244 | 249 |
| 245 // Now RTO and ensure slow start gets reset. | 250 // Now RTO and ensure slow start gets reset. |
| 246 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | 251 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
| 247 sender_->OnRetransmissionTimeout(true); | 252 sender_->OnRetransmissionTimeout(true); |
| 248 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 253 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
| 249 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); | 254 EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
| 250 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, | 255 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, |
| 251 sender_->slowstart_threshold()); | 256 sender_->slowstart_threshold()); |
| 252 | 257 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 657 } |
| 653 | 658 |
| 654 // Next ack should cause congestion window to grow by 1MSS. | 659 // Next ack should cause congestion window to grow by 1MSS. |
| 655 AckNPackets(2); | 660 AckNPackets(2); |
| 656 expected_send_window += kDefaultTCPMSS; | 661 expected_send_window += kDefaultTCPMSS; |
| 657 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 662 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 658 } | 663 } |
| 659 | 664 |
| 660 } // namespace test | 665 } // namespace test |
| 661 } // namespace net | 666 } // namespace net |
| OLD | NEW |