| 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_sender_bytes.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender_bytes.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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class TcpCubicSenderBytesTest : public ::testing::Test { | 53 class TcpCubicSenderBytesTest : public ::testing::Test { |
| 54 protected: | 54 protected: |
| 55 TcpCubicSenderBytesTest() | 55 TcpCubicSenderBytesTest() |
| 56 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), | 56 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), |
| 57 sender_(new TcpCubicSenderBytesPeer(&clock_, true)), | 57 sender_(new TcpCubicSenderBytesPeer(&clock_, true)), |
| 58 packet_number_(1), | 58 packet_number_(1), |
| 59 acked_packet_number_(0), | 59 acked_packet_number_(0), |
| 60 bytes_in_flight_(0) {} | 60 bytes_in_flight_(0) {} |
| 61 | 61 |
| 62 int SendAvailableSendWindow() { | 62 int SendAvailableSendWindow() { |
| 63 return SendAvailableSendWindow(kDefaultTCPMSS); |
| 64 } |
| 65 |
| 66 int SendAvailableSendWindow(QuicPacketLength packet_length) { |
| 63 // Send as long as TimeUntilSend returns Zero. | 67 // Send as long as TimeUntilSend returns Zero. |
| 64 int packets_sent = 0; | 68 int packets_sent = 0; |
| 65 bool can_send = sender_ | 69 bool can_send = |
| 66 ->TimeUntilSend(clock_.Now(), bytes_in_flight_, | 70 sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero(); |
| 67 HAS_RETRANSMITTABLE_DATA) | |
| 68 .IsZero(); | |
| 69 while (can_send) { | 71 while (can_send) { |
| 70 sender_->OnPacketSent(clock_.Now(), bytes_in_flight_, packet_number_++, | 72 sender_->OnPacketSent(clock_.Now(), bytes_in_flight_, packet_number_++, |
| 71 kDefaultTCPMSS, HAS_RETRANSMITTABLE_DATA); | 73 kDefaultTCPMSS, HAS_RETRANSMITTABLE_DATA); |
| 72 ++packets_sent; | 74 ++packets_sent; |
| 73 bytes_in_flight_ += kDefaultTCPMSS; | 75 bytes_in_flight_ += kDefaultTCPMSS; |
| 74 can_send = sender_ | 76 can_send = |
| 75 ->TimeUntilSend(clock_.Now(), bytes_in_flight_, | 77 sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero(); |
| 76 HAS_RETRANSMITTABLE_DATA) | |
| 77 .IsZero(); | |
| 78 } | 78 } |
| 79 return packets_sent; | 79 return packets_sent; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Normal is that TCP acks every other segment. | 82 // Normal is that TCP acks every other segment. |
| 83 void AckNPackets(int n) { | 83 void AckNPackets(int n) { |
| 84 sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(60), | 84 sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(60), |
| 85 QuicTime::Delta::Zero(), clock_.Now()); | 85 QuicTime::Delta::Zero(), clock_.Now()); |
| 86 SendAlgorithmInterface::CongestionVector acked_packets; | 86 SendAlgorithmInterface::CongestionVector acked_packets; |
| 87 SendAlgorithmInterface::CongestionVector lost_packets; | 87 SendAlgorithmInterface::CongestionVector lost_packets; |
| 88 for (int i = 0; i < n; ++i) { | 88 for (int i = 0; i < n; ++i) { |
| 89 ++acked_packet_number_; | 89 ++acked_packet_number_; |
| 90 acked_packets.push_back( | 90 acked_packets.push_back( |
| 91 std::make_pair(acked_packet_number_, kDefaultTCPMSS)); | 91 std::make_pair(acked_packet_number_, kDefaultTCPMSS)); |
| 92 } | 92 } |
| 93 sender_->OnCongestionEvent(true, bytes_in_flight_, acked_packets, | 93 sender_->OnCongestionEvent(true, bytes_in_flight_, acked_packets, |
| 94 lost_packets); | 94 lost_packets); |
| 95 bytes_in_flight_ -= n * kDefaultTCPMSS; | 95 bytes_in_flight_ -= n * kDefaultTCPMSS; |
| 96 clock_.AdvanceTime(one_ms_); | 96 clock_.AdvanceTime(one_ms_); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void LoseNPackets(int n) { | 99 void LoseNPackets(int n) { LoseNPackets(n, kDefaultTCPMSS); } |
| 100 |
| 101 void LoseNPackets(int n, QuicPacketLength packet_length) { |
| 100 SendAlgorithmInterface::CongestionVector acked_packets; | 102 SendAlgorithmInterface::CongestionVector acked_packets; |
| 101 SendAlgorithmInterface::CongestionVector lost_packets; | 103 SendAlgorithmInterface::CongestionVector lost_packets; |
| 102 for (int i = 0; i < n; ++i) { | 104 for (int i = 0; i < n; ++i) { |
| 103 ++acked_packet_number_; | 105 ++acked_packet_number_; |
| 104 lost_packets.push_back( | 106 lost_packets.push_back( |
| 105 std::make_pair(acked_packet_number_, kDefaultTCPMSS)); | 107 std::make_pair(acked_packet_number_, packet_length)); |
| 106 } | 108 } |
| 107 sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets, | 109 sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets, |
| 108 lost_packets); | 110 lost_packets); |
| 109 bytes_in_flight_ -= n * kDefaultTCPMSS; | 111 bytes_in_flight_ -= n * packet_length; |
| 110 } | 112 } |
| 111 | 113 |
| 112 // Does not increment acked_packet_number_. | 114 // Does not increment acked_packet_number_. |
| 113 void LosePacket(QuicPacketNumber packet_number) { | 115 void LosePacket(QuicPacketNumber packet_number) { |
| 114 SendAlgorithmInterface::CongestionVector acked_packets; | 116 SendAlgorithmInterface::CongestionVector acked_packets; |
| 115 SendAlgorithmInterface::CongestionVector lost_packets; | 117 SendAlgorithmInterface::CongestionVector lost_packets; |
| 116 lost_packets.push_back(std::make_pair(packet_number, kDefaultTCPMSS)); | 118 lost_packets.push_back(std::make_pair(packet_number, kDefaultTCPMSS)); |
| 117 sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets, | 119 sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets, |
| 118 lost_packets); | 120 lost_packets); |
| 119 bytes_in_flight_ -= kDefaultTCPMSS; | 121 bytes_in_flight_ -= kDefaultTCPMSS; |
| 120 } | 122 } |
| 121 | 123 |
| 122 const QuicTime::Delta one_ms_; | 124 const QuicTime::Delta one_ms_; |
| 123 MockClock clock_; | 125 MockClock clock_; |
| 124 scoped_ptr<TcpCubicSenderBytesPeer> sender_; | 126 scoped_ptr<TcpCubicSenderBytesPeer> sender_; |
| 125 QuicPacketNumber packet_number_; | 127 QuicPacketNumber packet_number_; |
| 126 QuicPacketNumber acked_packet_number_; | 128 QuicPacketNumber acked_packet_number_; |
| 127 QuicByteCount bytes_in_flight_; | 129 QuicByteCount bytes_in_flight_; |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 TEST_F(TcpCubicSenderBytesTest, SimpleSender) { | 132 TEST_F(TcpCubicSenderBytesTest, SimpleSender) { |
| 131 // At startup make sure we are at the default. | 133 // At startup make sure we are at the default. |
| 132 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 134 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
| 133 // At startup make sure we can send. | 135 // At startup make sure we can send. |
| 134 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) | 136 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero()); |
| 135 .IsZero()); | |
| 136 // Make sure we can send. | 137 // Make sure we can send. |
| 137 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) | 138 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero()); |
| 138 .IsZero()); | |
| 139 // And that window is un-affected. | 139 // And that window is un-affected. |
| 140 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 140 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
| 141 | 141 |
| 142 // Fill the send window with data, then verify that we can't send. | 142 // Fill the send window with data, then verify that we can't send. |
| 143 SendAvailableSendWindow(); | 143 SendAvailableSendWindow(); |
| 144 EXPECT_FALSE(sender_ | 144 EXPECT_FALSE( |
| 145 ->TimeUntilSend(clock_.Now(), sender_->GetCongestionWindow(), | 145 sender_->TimeUntilSend(clock_.Now(), sender_->GetCongestionWindow()) |
| 146 HAS_RETRANSMITTABLE_DATA) | 146 .IsZero()); |
| 147 .IsZero()); | |
| 148 } | 147 } |
| 149 | 148 |
| 150 TEST_F(TcpCubicSenderBytesTest, ApplicationLimitedSlowStart) { | 149 TEST_F(TcpCubicSenderBytesTest, ApplicationLimitedSlowStart) { |
| 151 // Send exactly 10 packets and ensure the CWND ends at 14 packets. | 150 // Send exactly 10 packets and ensure the CWND ends at 14 packets. |
| 152 const int kNumberOfAcks = 5; | 151 const int kNumberOfAcks = 5; |
| 153 // At startup make sure we can send. | 152 // At startup make sure we can send. |
| 154 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) | 153 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero()); |
| 155 .IsZero()); | |
| 156 // Make sure we can send. | 154 // Make sure we can send. |
| 157 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) | 155 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero()); |
| 158 .IsZero()); | |
| 159 | 156 |
| 160 SendAvailableSendWindow(); | 157 SendAvailableSendWindow(); |
| 161 for (int i = 0; i < kNumberOfAcks; ++i) { | 158 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 162 AckNPackets(2); | 159 AckNPackets(2); |
| 163 } | 160 } |
| 164 QuicByteCount bytes_to_send = sender_->GetCongestionWindow(); | 161 QuicByteCount bytes_to_send = sender_->GetCongestionWindow(); |
| 165 // It's expected 2 acks will arrive when the bytes_in_flight are greater than | 162 // It's expected 2 acks will arrive when the bytes_in_flight are greater than |
| 166 // half the CWND. | 163 // half the CWND. |
| 167 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send); | 164 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send); |
| 168 } | 165 } |
| 169 | 166 |
| 170 TEST_F(TcpCubicSenderBytesTest, ExponentialSlowStart) { | 167 TEST_F(TcpCubicSenderBytesTest, ExponentialSlowStart) { |
| 171 const int kNumberOfAcks = 20; | 168 const int kNumberOfAcks = 20; |
| 172 // At startup make sure we can send. | 169 // At startup make sure we can send. |
| 173 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) | 170 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero()); |
| 174 .IsZero()); | |
| 175 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate()); | 171 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate()); |
| 176 // Make sure we can send. | 172 // Make sure we can send. |
| 177 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) | 173 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero()); |
| 178 .IsZero()); | |
| 179 | 174 |
| 180 for (int i = 0; i < kNumberOfAcks; ++i) { | 175 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 181 // Send our full send window. | 176 // Send our full send window. |
| 182 SendAvailableSendWindow(); | 177 SendAvailableSendWindow(); |
| 183 AckNPackets(2); | 178 AckNPackets(2); |
| 184 } | 179 } |
| 185 const QuicByteCount cwnd = sender_->GetCongestionWindow(); | 180 const QuicByteCount cwnd = sender_->GetCongestionWindow(); |
| 186 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd); | 181 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd); |
| 187 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta( | 182 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta( |
| 188 cwnd, sender_->rtt_stats_.smoothed_rtt()), | 183 cwnd, sender_->rtt_stats_.smoothed_rtt()), |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 AckNPackets(1); | 279 AckNPackets(1); |
| 285 expected_send_window += kDefaultTCPMSS; | 280 expected_send_window += kDefaultTCPMSS; |
| 286 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 281 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 287 | 282 |
| 288 // Now RTO and ensure slow start gets reset. | 283 // Now RTO and ensure slow start gets reset. |
| 289 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | 284 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
| 290 sender_->OnRetransmissionTimeout(true); | 285 sender_->OnRetransmissionTimeout(true); |
| 291 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 286 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
| 292 } | 287 } |
| 293 | 288 |
| 289 TEST_F(TcpCubicSenderBytesTest, SlowStartHalfPacketLossWithLargeReduction) { |
| 290 FLAGS_quic_sslr_byte_conservation = true; |
| 291 QuicConfig config; |
| 292 QuicTagVector options; |
| 293 options.push_back(kSSLR); |
| 294 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 295 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
| 296 |
| 297 sender_->SetNumEmulatedConnections(1); |
| 298 const int kNumberOfAcks = 10; |
| 299 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 300 // Send our full send window in half sized packets. |
| 301 SendAvailableSendWindow(kDefaultTCPMSS / 2); |
| 302 AckNPackets(2); |
| 303 } |
| 304 SendAvailableSendWindow(kDefaultTCPMSS / 2); |
| 305 QuicByteCount expected_send_window = |
| 306 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
| 307 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 308 |
| 309 // Lose a packet to exit slow start. We should now have fallen out of |
| 310 // slow start with a window reduced by 1. |
| 311 LoseNPackets(1); |
| 312 expected_send_window -= kDefaultTCPMSS; |
| 313 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 314 |
| 315 // Lose 10 packets in recovery and verify that congestion window is reduced |
| 316 // by 5 packets. |
| 317 LoseNPackets(10, kDefaultTCPMSS / 2); |
| 318 expected_send_window -= 5 * kDefaultTCPMSS; |
| 319 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 320 } |
| 321 |
| 294 TEST_F(TcpCubicSenderBytesTest, NoPRRWhenLessThanOnePacketInFlight) { | 322 TEST_F(TcpCubicSenderBytesTest, NoPRRWhenLessThanOnePacketInFlight) { |
| 295 SendAvailableSendWindow(); | 323 SendAvailableSendWindow(); |
| 296 LoseNPackets(kInitialCongestionWindowPackets - 1); | 324 LoseNPackets(kInitialCongestionWindowPackets - 1); |
| 297 AckNPackets(1); | 325 AckNPackets(1); |
| 298 // PRR will allow 2 packets for every ack during recovery. | 326 // PRR will allow 2 packets for every ack during recovery. |
| 299 EXPECT_EQ(2, SendAvailableSendWindow()); | 327 EXPECT_EQ(2, SendAvailableSendWindow()); |
| 300 // Simulate abandoning all packets by supplying a bytes_in_flight of 0. | 328 // Simulate abandoning all packets by supplying a bytes_in_flight of 0. |
| 301 // PRR should now allow a packet to be sent, even though prr's state variables | 329 // PRR should now allow a packet to be sent, even though prr's state variables |
| 302 // believe it has sent enough packets. | 330 // believe it has sent enough packets. |
| 303 EXPECT_EQ(QuicTime::Delta::Zero(), | 331 EXPECT_EQ(QuicTime::Delta::Zero(), sender_->TimeUntilSend(clock_.Now(), 0)); |
| 304 sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)); | |
| 305 } | 332 } |
| 306 | 333 |
| 307 TEST_F(TcpCubicSenderBytesTest, SlowStartPacketLossPRR) { | 334 TEST_F(TcpCubicSenderBytesTest, SlowStartPacketLossPRR) { |
| 308 sender_->SetNumEmulatedConnections(1); | 335 sender_->SetNumEmulatedConnections(1); |
| 309 // Test based on the first example in RFC6937. | 336 // Test based on the first example in RFC6937. |
| 310 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. | 337 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. |
| 311 const int kNumberOfAcks = 5; | 338 const int kNumberOfAcks = 5; |
| 312 for (int i = 0; i < kNumberOfAcks; ++i) { | 339 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 313 // Send our full send window. | 340 // Send our full send window. |
| 314 SendAvailableSendWindow(); | 341 SendAvailableSendWindow(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 398 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 372 | 399 |
| 373 // Lose one more than the congestion window reduction, so that after loss, | 400 // Lose one more than the congestion window reduction, so that after loss, |
| 374 // bytes_in_flight is lesser than the congestion window. | 401 // bytes_in_flight is lesser than the congestion window. |
| 375 size_t send_window_after_loss = kRenoBeta * expected_send_window; | 402 size_t send_window_after_loss = kRenoBeta * expected_send_window; |
| 376 size_t num_packets_to_lose = | 403 size_t num_packets_to_lose = |
| 377 (expected_send_window - send_window_after_loss) / kDefaultTCPMSS + 1; | 404 (expected_send_window - send_window_after_loss) / kDefaultTCPMSS + 1; |
| 378 LoseNPackets(num_packets_to_lose); | 405 LoseNPackets(num_packets_to_lose); |
| 379 // Immediately after the loss, ensure at least one packet can be sent. | 406 // Immediately after the loss, ensure at least one packet can be sent. |
| 380 // Losses without subsequent acks can occur with timer based loss detection. | 407 // Losses without subsequent acks can occur with timer based loss detection. |
| 381 EXPECT_TRUE(sender_ | 408 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero()); |
| 382 ->TimeUntilSend(clock_.Now(), bytes_in_flight_, | |
| 383 HAS_RETRANSMITTABLE_DATA) | |
| 384 .IsZero()); | |
| 385 AckNPackets(1); | 409 AckNPackets(1); |
| 386 | 410 |
| 387 // We should now have fallen out of slow start with a reduced window. | 411 // We should now have fallen out of slow start with a reduced window. |
| 388 expected_send_window *= kRenoBeta; | 412 expected_send_window *= kRenoBeta; |
| 389 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 413 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 390 | 414 |
| 391 // Only 2 packets should be allowed to be sent, per PRR-SSRB. | 415 // Only 2 packets should be allowed to be sent, per PRR-SSRB. |
| 392 EXPECT_EQ(2, SendAvailableSendWindow()); | 416 EXPECT_EQ(2, SendAvailableSendWindow()); |
| 393 | 417 |
| 394 // Ack the next packet, which triggers another loss. | 418 // Ack the next packet, which triggers another loss. |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 QuicConfig config; | 714 QuicConfig config; |
| 691 | 715 |
| 692 // Verify that kCOPT: kMIN4 forces the min CWND to 1 packet, but allows up | 716 // Verify that kCOPT: kMIN4 forces the min CWND to 1 packet, but allows up |
| 693 // to 4 to be sent. | 717 // to 4 to be sent. |
| 694 QuicTagVector options; | 718 QuicTagVector options; |
| 695 options.push_back(kMIN4); | 719 options.push_back(kMIN4); |
| 696 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 720 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 697 sender_->SetFromConfig(config, Perspective::IS_SERVER); | 721 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
| 698 sender_->OnRetransmissionTimeout(true); | 722 sender_->OnRetransmissionTimeout(true); |
| 699 EXPECT_EQ(kDefaultTCPMSS, sender_->GetCongestionWindow()); | 723 EXPECT_EQ(kDefaultTCPMSS, sender_->GetCongestionWindow()); |
| 700 EXPECT_TRUE(sender_ | 724 EXPECT_TRUE( |
| 701 ->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS, | 725 sender_->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS).IsZero()); |
| 702 HAS_RETRANSMITTABLE_DATA) | 726 EXPECT_TRUE( |
| 703 .IsZero()); | 727 sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS).IsZero()); |
| 704 EXPECT_TRUE(sender_ | 728 EXPECT_TRUE( |
| 705 ->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, | 729 sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS).IsZero()); |
| 706 HAS_RETRANSMITTABLE_DATA) | 730 EXPECT_FALSE( |
| 707 .IsZero()); | 731 sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS).IsZero()); |
| 708 EXPECT_TRUE(sender_ | |
| 709 ->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, | |
| 710 HAS_RETRANSMITTABLE_DATA) | |
| 711 .IsZero()); | |
| 712 EXPECT_FALSE(sender_ | |
| 713 ->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, | |
| 714 HAS_RETRANSMITTABLE_DATA) | |
| 715 .IsZero()); | |
| 716 } | 732 } |
| 717 | 733 |
| 718 TEST_F(TcpCubicSenderBytesTest, ResetAfterConnectionMigration) { | 734 TEST_F(TcpCubicSenderBytesTest, ResetAfterConnectionMigration) { |
| 719 // Starts from slow start. | 735 // Starts from slow start. |
| 720 sender_->SetNumEmulatedConnections(1); | 736 sender_->SetNumEmulatedConnections(1); |
| 721 const int kNumberOfAcks = 10; | 737 const int kNumberOfAcks = 10; |
| 722 for (int i = 0; i < kNumberOfAcks; ++i) { | 738 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 723 // Send our full send window. | 739 // Send our full send window. |
| 724 SendAvailableSendWindow(); | 740 SendAvailableSendWindow(); |
| 725 AckNPackets(2); | 741 AckNPackets(2); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 741 // Resets cwnd and slow start threshold on connection migrations. | 757 // Resets cwnd and slow start threshold on connection migrations. |
| 742 sender_->OnConnectionMigration(); | 758 sender_->OnConnectionMigration(); |
| 743 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 759 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
| 744 EXPECT_EQ(kMaxCongestionWindow * kDefaultTCPMSS, | 760 EXPECT_EQ(kMaxCongestionWindow * kDefaultTCPMSS, |
| 745 sender_->GetSlowStartThreshold()); | 761 sender_->GetSlowStartThreshold()); |
| 746 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 762 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
| 747 } | 763 } |
| 748 | 764 |
| 749 } // namespace test | 765 } // namespace test |
| 750 } // namespace net | 766 } // namespace net |
| OLD | NEW |