| 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" |
| 11 #include "net/quic/congestion_control/tcp_receiver.h" | 11 #include "net/quic/congestion_control/tcp_receiver.h" |
| 12 #include "net/quic/crypto/crypto_protocol.h" |
| 12 #include "net/quic/quic_utils.h" | 13 #include "net/quic/quic_utils.h" |
| 13 #include "net/quic/test_tools/mock_clock.h" | 14 #include "net/quic/test_tools/mock_clock.h" |
| 14 #include "net/quic/test_tools/quic_config_peer.h" | 15 #include "net/quic/test_tools/quic_config_peer.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using std::min; | 18 using std::min; |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 namespace test { | 21 namespace test { |
| 21 | 22 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 MockClock clock_; | 124 MockClock clock_; |
| 124 scoped_ptr<TcpCubicSenderPeer> sender_; | 125 scoped_ptr<TcpCubicSenderPeer> sender_; |
| 125 scoped_ptr<TcpReceiver> receiver_; | 126 scoped_ptr<TcpReceiver> receiver_; |
| 126 QuicPacketSequenceNumber sequence_number_; | 127 QuicPacketSequenceNumber sequence_number_; |
| 127 QuicPacketSequenceNumber acked_sequence_number_; | 128 QuicPacketSequenceNumber acked_sequence_number_; |
| 128 QuicByteCount bytes_in_flight_; | 129 QuicByteCount bytes_in_flight_; |
| 129 TransmissionInfo standard_packet_; | 130 TransmissionInfo standard_packet_; |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 TEST_F(TcpCubicSenderTest, SimpleSender) { | 133 TEST_F(TcpCubicSenderTest, SimpleSender) { |
| 133 QuicCongestionFeedbackFrame feedback; | |
| 134 // At startup make sure we are at the default. | 134 // At startup make sure we are at the default. |
| 135 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 135 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
| 136 // At startup make sure we can send. | 136 // At startup make sure we can send. |
| 137 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), | 137 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
| 138 0, | 138 0, |
| 139 HAS_RETRANSMITTABLE_DATA).IsZero()); | 139 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 140 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 141 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 142 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 143 // Make sure we can send. | 140 // Make sure we can send. |
| 144 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), | 141 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
| 145 0, | 142 0, |
| 146 HAS_RETRANSMITTABLE_DATA).IsZero()); | 143 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 147 // And that window is un-affected. | 144 // And that window is un-affected. |
| 148 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 145 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
| 149 | 146 |
| 150 // Fill the send window with data, then verify that we can't send. | 147 // Fill the send window with data, then verify that we can't send. |
| 151 SendAvailableSendWindow(); | 148 SendAvailableSendWindow(); |
| 152 EXPECT_FALSE(sender_->TimeUntilSend(clock_.Now(), | 149 EXPECT_FALSE(sender_->TimeUntilSend(clock_.Now(), |
| 153 sender_->GetCongestionWindow(), | 150 sender_->GetCongestionWindow(), |
| 154 HAS_RETRANSMITTABLE_DATA).IsZero()); | 151 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 155 } | 152 } |
| 156 | 153 |
| 157 TEST_F(TcpCubicSenderTest, ApplicationLimitedSlowStart) { | 154 TEST_F(TcpCubicSenderTest, ApplicationLimitedSlowStart) { |
| 158 // Send exactly 10 packets and ensure the CWND ends at 14 packets. | 155 // Send exactly 10 packets and ensure the CWND ends at 14 packets. |
| 159 const int kNumberOfAcks = 5; | 156 const int kNumberOfAcks = 5; |
| 160 QuicCongestionFeedbackFrame feedback; | |
| 161 // At startup make sure we can send. | 157 // At startup make sure we can send. |
| 162 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), | 158 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
| 163 0, | 159 0, |
| 164 HAS_RETRANSMITTABLE_DATA).IsZero()); | 160 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 165 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 166 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 167 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 168 // Make sure we can send. | 161 // Make sure we can send. |
| 169 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), | 162 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
| 170 0, | 163 0, |
| 171 HAS_RETRANSMITTABLE_DATA).IsZero()); | 164 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 172 | 165 |
| 173 SendAvailableSendWindow(); | 166 SendAvailableSendWindow(); |
| 174 for (int i = 0; i < kNumberOfAcks; ++i) { | 167 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 175 AckNPackets(2); | 168 AckNPackets(2); |
| 176 } | 169 } |
| 177 QuicByteCount bytes_to_send = sender_->SendWindow(); | 170 QuicByteCount bytes_to_send = sender_->SendWindow(); |
| 178 // It's expected 2 acks will arrive when the bytes_in_flight are greater than | 171 // It's expected 2 acks will arrive when the bytes_in_flight are greater than |
| 179 // half the CWND. | 172 // half the CWND. |
| 180 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, | 173 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, |
| 181 bytes_to_send); | 174 bytes_to_send); |
| 182 } | 175 } |
| 183 | 176 |
| 184 TEST_F(TcpCubicSenderTest, ExponentialSlowStart) { | 177 TEST_F(TcpCubicSenderTest, ExponentialSlowStart) { |
| 185 const int kNumberOfAcks = 20; | 178 const int kNumberOfAcks = 20; |
| 186 QuicCongestionFeedbackFrame feedback; | |
| 187 // At startup make sure we can send. | 179 // At startup make sure we can send. |
| 188 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), | 180 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
| 189 0, | 181 0, |
| 190 HAS_RETRANSMITTABLE_DATA).IsZero()); | 182 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 191 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 192 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 193 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 194 // Make sure we can send. | 183 // Make sure we can send. |
| 195 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), | 184 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
| 196 0, | 185 0, |
| 197 HAS_RETRANSMITTABLE_DATA).IsZero()); | 186 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 198 | 187 |
| 199 for (int i = 0; i < kNumberOfAcks; ++i) { | 188 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 200 // Send our full send window. | 189 // Send our full send window. |
| 201 SendAvailableSendWindow(); | 190 SendAvailableSendWindow(); |
| 202 AckNPackets(2); | 191 AckNPackets(2); |
| 203 } | 192 } |
| 204 QuicByteCount bytes_to_send = sender_->SendWindow(); | 193 QuicByteCount bytes_to_send = sender_->SendWindow(); |
| 205 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, | 194 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, |
| 206 bytes_to_send); | 195 bytes_to_send); |
| 207 } | 196 } |
| 208 | 197 |
| 209 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { | 198 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { |
| 210 EXPECT_EQ(kDefaultMaxCongestionWindowTCP * kDefaultTCPMSS, | 199 EXPECT_EQ(kDefaultMaxCongestionWindowTCP * kDefaultTCPMSS, |
| 211 sender_->GetSlowStartThreshold()); | 200 sender_->GetSlowStartThreshold()); |
| 212 | 201 |
| 213 // Make sure that we fall out of slow start when we send ACK train longer | 202 // Make sure that we fall out of slow start when we send ACK train longer |
| 214 // than half the RTT, in this test case 30ms, which is more than 30 calls to | 203 // than half the RTT, in this test case 30ms, which is more than 30 calls to |
| 215 // Ack2Packets in one round. | 204 // Ack2Packets in one round. |
| 216 // Since we start at 10 packet first round will be 5 second round 10 etc | 205 // Since we start at 10 packet first round will be 5 second round 10 etc |
| 217 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30 | 206 // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30 |
| 218 const int kNumberOfAcks = 65; | 207 const int kNumberOfAcks = 65; |
| 219 QuicCongestionFeedbackFrame feedback; | |
| 220 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 221 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 222 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 223 | |
| 224 for (int i = 0; i < kNumberOfAcks; ++i) { | 208 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 225 // Send our full send window. | 209 // Send our full send window. |
| 226 SendAvailableSendWindow(); | 210 SendAvailableSendWindow(); |
| 227 AckNPackets(2); | 211 AckNPackets(2); |
| 228 } | 212 } |
| 229 QuicByteCount expected_send_window = | 213 QuicByteCount expected_send_window = |
| 230 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); | 214 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
| 231 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 215 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 232 | 216 |
| 233 // We should now have fallen out of slow start. | 217 // We should now have fallen out of slow start. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 255 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, | 239 EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, |
| 256 sender_->slowstart_threshold()); | 240 sender_->slowstart_threshold()); |
| 257 | 241 |
| 258 // Now revert the RTO and ensure the CWND and slowstart threshold revert. | 242 // Now revert the RTO and ensure the CWND and slowstart threshold revert. |
| 259 sender_->RevertRetransmissionTimeout(); | 243 sender_->RevertRetransmissionTimeout(); |
| 260 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 244 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 261 EXPECT_EQ(140u, sender_->slowstart_threshold()); | 245 EXPECT_EQ(140u, sender_->slowstart_threshold()); |
| 262 } | 246 } |
| 263 | 247 |
| 264 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { | 248 TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
| 265 // Make sure that we fall out of slow start when we encounter a packet loss. | |
| 266 QuicCongestionFeedbackFrame feedback; | |
| 267 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 268 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 269 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 270 | |
| 271 const int kNumberOfAcks = 10; | 249 const int kNumberOfAcks = 10; |
| 272 for (int i = 0; i < kNumberOfAcks; ++i) { | 250 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 273 // Send our full send window. | 251 // Send our full send window. |
| 274 SendAvailableSendWindow(); | 252 SendAvailableSendWindow(); |
| 275 AckNPackets(2); | 253 AckNPackets(2); |
| 276 } | 254 } |
| 277 SendAvailableSendWindow(); | 255 SendAvailableSendWindow(); |
| 278 QuicByteCount expected_send_window = kDefaultWindowTCP + | 256 QuicByteCount expected_send_window = kDefaultWindowTCP + |
| 279 (kDefaultTCPMSS * 2 * kNumberOfAcks); | 257 (kDefaultTCPMSS * 2 * kNumberOfAcks); |
| 280 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 258 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 290 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 313 | 291 |
| 314 // Now RTO and ensure slow start gets reset. | 292 // Now RTO and ensure slow start gets reset. |
| 315 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | 293 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
| 316 sender_->OnRetransmissionTimeout(true); | 294 sender_->OnRetransmissionTimeout(true); |
| 317 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 295 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
| 318 } | 296 } |
| 319 | 297 |
| 320 TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { | 298 TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { |
| 321 // Test based on the first example in RFC6937. | 299 // Test based on the first example in RFC6937. |
| 322 // Make sure that we fall out of slow start when we encounter a packet loss. | |
| 323 QuicCongestionFeedbackFrame feedback; | |
| 324 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 325 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 326 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 327 | |
| 328 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. | 300 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. |
| 329 const int kNumberOfAcks = 5; | 301 const int kNumberOfAcks = 5; |
| 330 for (int i = 0; i < kNumberOfAcks; ++i) { | 302 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 331 // Send our full send window. | 303 // Send our full send window. |
| 332 SendAvailableSendWindow(); | 304 SendAvailableSendWindow(); |
| 333 AckNPackets(2); | 305 AckNPackets(2); |
| 334 } | 306 } |
| 335 SendAvailableSendWindow(); | 307 SendAvailableSendWindow(); |
| 336 QuicByteCount expected_send_window = kDefaultWindowTCP + | 308 QuicByteCount expected_send_window = kDefaultWindowTCP + |
| 337 (kDefaultTCPMSS * 2 * kNumberOfAcks); | 309 (kDefaultTCPMSS * 2 * kNumberOfAcks); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 368 | 340 |
| 369 AckNPackets(1); | 341 AckNPackets(1); |
| 370 expected_send_window += kDefaultTCPMSS; | 342 expected_send_window += kDefaultTCPMSS; |
| 371 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 343 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 372 } | 344 } |
| 373 | 345 |
| 374 TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) { | 346 TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) { |
| 375 // Test based on the second example in RFC6937, though we also implement | 347 // Test based on the second example in RFC6937, though we also implement |
| 376 // forward acknowledgements, so the first two incoming acks will trigger | 348 // forward acknowledgements, so the first two incoming acks will trigger |
| 377 // PRR immediately. | 349 // PRR immediately. |
| 378 // Make sure that we fall out of slow start when we encounter a packet loss. | |
| 379 QuicCongestionFeedbackFrame feedback; | |
| 380 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 381 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 382 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 383 | |
| 384 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. | 350 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. |
| 385 const int kNumberOfAcks = 5; | 351 const int kNumberOfAcks = 5; |
| 386 for (int i = 0; i < kNumberOfAcks; ++i) { | 352 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 387 // Send our full send window. | 353 // Send our full send window. |
| 388 SendAvailableSendWindow(); | 354 SendAvailableSendWindow(); |
| 389 AckNPackets(2); | 355 AckNPackets(2); |
| 390 } | 356 } |
| 391 SendAvailableSendWindow(); | 357 SendAvailableSendWindow(); |
| 392 QuicByteCount expected_send_window = kDefaultWindowTCP + | 358 QuicByteCount expected_send_window = kDefaultWindowTCP + |
| 393 (kDefaultTCPMSS * 2 * kNumberOfAcks); | 359 (kDefaultTCPMSS * 2 * kNumberOfAcks); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 sender_->rtt_stats_.SmoothedRtt().ToMicroseconds()), | 465 sender_->rtt_stats_.SmoothedRtt().ToMicroseconds()), |
| 500 sender_->BandwidthEstimate().ToBytesPerSecond()); | 466 sender_->BandwidthEstimate().ToBytesPerSecond()); |
| 501 } | 467 } |
| 502 | 468 |
| 503 TEST_F(TcpCubicSenderTest, SlowStartMaxSendWindow) { | 469 TEST_F(TcpCubicSenderTest, SlowStartMaxSendWindow) { |
| 504 const QuicTcpCongestionWindow kMaxCongestionWindowTCP = 50; | 470 const QuicTcpCongestionWindow kMaxCongestionWindowTCP = 50; |
| 505 const int kNumberOfAcks = 100; | 471 const int kNumberOfAcks = 100; |
| 506 sender_.reset( | 472 sender_.reset( |
| 507 new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindowTCP)); | 473 new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindowTCP)); |
| 508 | 474 |
| 509 QuicCongestionFeedbackFrame feedback; | |
| 510 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 511 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 512 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 513 | |
| 514 for (int i = 0; i < kNumberOfAcks; ++i) { | 475 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 515 // Send our full send window. | 476 // Send our full send window. |
| 516 SendAvailableSendWindow(); | 477 SendAvailableSendWindow(); |
| 517 AckNPackets(2); | 478 AckNPackets(2); |
| 518 } | 479 } |
| 519 QuicByteCount expected_send_window = | 480 QuicByteCount expected_send_window = |
| 520 kMaxCongestionWindowTCP * kDefaultTCPMSS; | 481 kMaxCongestionWindowTCP * kDefaultTCPMSS; |
| 521 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 482 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 522 } | 483 } |
| 523 | 484 |
| 524 TEST_F(TcpCubicSenderTest, TcpRenoMaxCongestionWindow) { | 485 TEST_F(TcpCubicSenderTest, TcpRenoMaxCongestionWindow) { |
| 525 const QuicTcpCongestionWindow kMaxCongestionWindowTCP = 50; | 486 const QuicTcpCongestionWindow kMaxCongestionWindowTCP = 50; |
| 526 const int kNumberOfAcks = 1000; | 487 const int kNumberOfAcks = 1000; |
| 527 sender_.reset( | 488 sender_.reset( |
| 528 new TcpCubicSenderPeer(&clock_, true, kMaxCongestionWindowTCP)); | 489 new TcpCubicSenderPeer(&clock_, true, kMaxCongestionWindowTCP)); |
| 529 | 490 |
| 530 QuicCongestionFeedbackFrame feedback; | |
| 531 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 532 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 533 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 534 | |
| 535 SendAvailableSendWindow(); | 491 SendAvailableSendWindow(); |
| 536 AckNPackets(2); | 492 AckNPackets(2); |
| 537 // Make sure we fall out of slow start. | 493 // Make sure we fall out of slow start. |
| 538 LoseNPackets(1); | 494 LoseNPackets(1); |
| 539 | 495 |
| 540 for (int i = 0; i < kNumberOfAcks; ++i) { | 496 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 541 // Send our full send window. | 497 // Send our full send window. |
| 542 SendAvailableSendWindow(); | 498 SendAvailableSendWindow(); |
| 543 AckNPackets(2); | 499 AckNPackets(2); |
| 544 } | 500 } |
| 545 | 501 |
| 546 QuicByteCount expected_send_window = | 502 QuicByteCount expected_send_window = |
| 547 kMaxCongestionWindowTCP * kDefaultTCPMSS; | 503 kMaxCongestionWindowTCP * kDefaultTCPMSS; |
| 548 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 504 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 549 } | 505 } |
| 550 | 506 |
| 551 TEST_F(TcpCubicSenderTest, TcpCubicMaxCongestionWindow) { | 507 TEST_F(TcpCubicSenderTest, TcpCubicMaxCongestionWindow) { |
| 552 const QuicTcpCongestionWindow kMaxCongestionWindowTCP = 50; | 508 const QuicTcpCongestionWindow kMaxCongestionWindowTCP = 50; |
| 553 // Set to 10000 to compensate for small cubic alpha. | 509 // Set to 10000 to compensate for small cubic alpha. |
| 554 const int kNumberOfAcks = 10000; | 510 const int kNumberOfAcks = 10000; |
| 555 | 511 |
| 556 sender_.reset( | 512 sender_.reset( |
| 557 new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindowTCP)); | 513 new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindowTCP)); |
| 558 | 514 |
| 559 QuicCongestionFeedbackFrame feedback; | |
| 560 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 561 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 562 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 563 | |
| 564 SendAvailableSendWindow(); | 515 SendAvailableSendWindow(); |
| 565 AckNPackets(2); | 516 AckNPackets(2); |
| 566 // Make sure we fall out of slow start. | 517 // Make sure we fall out of slow start. |
| 567 LoseNPackets(1); | 518 LoseNPackets(1); |
| 568 | 519 |
| 569 for (int i = 0; i < kNumberOfAcks; ++i) { | 520 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 570 // Send our full send window. | 521 // Send our full send window. |
| 571 SendAvailableSendWindow(); | 522 SendAvailableSendWindow(); |
| 572 AckNPackets(2); | 523 AckNPackets(2); |
| 573 } | 524 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 HAS_RETRANSMITTABLE_DATA)); | 556 HAS_RETRANSMITTABLE_DATA)); |
| 606 } | 557 } |
| 607 | 558 |
| 608 TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) { | 559 TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) { |
| 609 QuicTcpCongestionWindow congestion_window = sender_->congestion_window(); | 560 QuicTcpCongestionWindow congestion_window = sender_->congestion_window(); |
| 610 QuicConfig config; | 561 QuicConfig config; |
| 611 QuicConfigPeer::SetReceivedInitialWindow(&config, 2 * congestion_window); | 562 QuicConfigPeer::SetReceivedInitialWindow(&config, 2 * congestion_window); |
| 612 | 563 |
| 613 sender_->SetFromConfig(config, true); | 564 sender_->SetFromConfig(config, true); |
| 614 EXPECT_EQ(2 * congestion_window, sender_->congestion_window()); | 565 EXPECT_EQ(2 * congestion_window, sender_->congestion_window()); |
| 566 |
| 567 // Verify that kCOPT: kIW10 forces the congestion window to the |
| 568 // default of 10 regardless of ReceivedInitialWindow. |
| 569 QuicTagVector options; |
| 570 options.push_back(kIW10); |
| 571 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 572 sender_->SetFromConfig(config, true); |
| 573 EXPECT_EQ(congestion_window, sender_->congestion_window()); |
| 615 } | 574 } |
| 616 | 575 |
| 617 TEST_F(TcpCubicSenderTest, CongestionAvoidanceAtEndOfRecovery) { | 576 TEST_F(TcpCubicSenderTest, CongestionAvoidanceAtEndOfRecovery) { |
| 618 // Make sure that we fall out of slow start when we encounter a packet loss. | |
| 619 QuicCongestionFeedbackFrame feedback; | |
| 620 // Get default QuicCongestionFeedbackFrame from receiver. | |
| 621 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); | |
| 622 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now()); | |
| 623 // Ack 10 packets in 5 acks to raise the CWND to 20. | 577 // Ack 10 packets in 5 acks to raise the CWND to 20. |
| 624 const int kNumberOfAcks = 5; | 578 const int kNumberOfAcks = 5; |
| 625 for (int i = 0; i < kNumberOfAcks; ++i) { | 579 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 626 // Send our full send window. | 580 // Send our full send window. |
| 627 SendAvailableSendWindow(); | 581 SendAvailableSendWindow(); |
| 628 AckNPackets(2); | 582 AckNPackets(2); |
| 629 } | 583 } |
| 630 SendAvailableSendWindow(); | 584 SendAvailableSendWindow(); |
| 631 QuicByteCount expected_send_window = kDefaultWindowTCP + | 585 QuicByteCount expected_send_window = kDefaultWindowTCP + |
| 632 (kDefaultTCPMSS * 2 * kNumberOfAcks); | 586 (kDefaultTCPMSS * 2 * kNumberOfAcks); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 657 } | 611 } |
| 658 | 612 |
| 659 // Next ack should cause congestion window to grow by 1MSS. | 613 // Next ack should cause congestion window to grow by 1MSS. |
| 660 AckNPackets(2); | 614 AckNPackets(2); |
| 661 expected_send_window += kDefaultTCPMSS; | 615 expected_send_window += kDefaultTCPMSS; |
| 662 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 616 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 663 } | 617 } |
| 664 | 618 |
| 665 } // namespace test | 619 } // namespace test |
| 666 } // namespace net | 620 } // namespace net |
| OLD | NEW |