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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 AckNPackets(1); | 225 AckNPackets(1); |
226 expected_send_window += kDefaultTCPMSS; | 226 expected_send_window += kDefaultTCPMSS; |
227 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 227 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
228 | 228 |
229 // Now RTO and ensure slow start gets reset. | 229 // Now RTO and ensure slow start gets reset. |
230 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | 230 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
231 sender_->OnRetransmissionTimeout(true); | 231 sender_->OnRetransmissionTimeout(true); |
232 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 232 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
233 } | 233 } |
234 | 234 |
| 235 TEST_F(TcpCubicBytesSenderTest, SlowStartPacketLossWithLargeReduction) { |
| 236 QuicConfig config; |
| 237 QuicTagVector options; |
| 238 options.push_back(kSSLR); |
| 239 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 240 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
| 241 |
| 242 sender_->SetNumEmulatedConnections(1); |
| 243 const int kNumberOfAcks = 10; |
| 244 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 245 // Send our full send window. |
| 246 SendAvailableSendWindow(); |
| 247 AckNPackets(2); |
| 248 } |
| 249 SendAvailableSendWindow(); |
| 250 QuicByteCount expected_send_window = |
| 251 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
| 252 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 253 |
| 254 // Lose a packet to exit slow start. We should now have fallen out of |
| 255 // slow start with a window reduced by 1. |
| 256 LoseNPackets(1); |
| 257 expected_send_window -= kDefaultTCPMSS; |
| 258 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 259 |
| 260 // Lose 5 packets in recovery and verify that congestion window is reduced |
| 261 // further. |
| 262 LoseNPackets(5); |
| 263 expected_send_window -= 5 * kDefaultTCPMSS; |
| 264 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 265 |
| 266 size_t packets_in_recovery_window = expected_send_window / kDefaultTCPMSS; |
| 267 |
| 268 // Recovery phase. We need to ack every packet in the recovery window before |
| 269 // we exit recovery. |
| 270 size_t number_of_packets_in_window = expected_send_window / kDefaultTCPMSS; |
| 271 DVLOG(1) << "number_packets: " << number_of_packets_in_window; |
| 272 AckNPackets(packets_in_recovery_window); |
| 273 SendAvailableSendWindow(); |
| 274 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 275 |
| 276 // We need to ack an entire window before we increase CWND by 1. |
| 277 AckNPackets(number_of_packets_in_window - 1); |
| 278 SendAvailableSendWindow(); |
| 279 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 280 |
| 281 // Next ack should increase cwnd by 1. |
| 282 AckNPackets(1); |
| 283 expected_send_window += kDefaultTCPMSS; |
| 284 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 285 |
| 286 // Now RTO and ensure slow start gets reset. |
| 287 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
| 288 sender_->OnRetransmissionTimeout(true); |
| 289 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
| 290 } |
| 291 |
235 TEST_F(TcpCubicBytesSenderTest, NoPRRWhenLessThanOnePacketInFlight) { | 292 TEST_F(TcpCubicBytesSenderTest, NoPRRWhenLessThanOnePacketInFlight) { |
236 SendAvailableSendWindow(); | 293 SendAvailableSendWindow(); |
237 LoseNPackets(kInitialCongestionWindowPackets - 1); | 294 LoseNPackets(kInitialCongestionWindowPackets - 1); |
238 AckNPackets(1); | 295 AckNPackets(1); |
239 // PRR will allow 2 packets for every ack during recovery. | 296 // PRR will allow 2 packets for every ack during recovery. |
240 EXPECT_EQ(2, SendAvailableSendWindow()); | 297 EXPECT_EQ(2, SendAvailableSendWindow()); |
241 // Simulate abandoning all packets by supplying a bytes_in_flight of 0. | 298 // Simulate abandoning all packets by supplying a bytes_in_flight of 0. |
242 // PRR should now allow a packet to be sent, even though prr's state variables | 299 // PRR should now allow a packet to be sent, even though prr's state variables |
243 // believe it has sent enough packets. | 300 // believe it has sent enough packets. |
244 EXPECT_EQ(QuicTime::Delta::Zero(), | 301 EXPECT_EQ(QuicTime::Delta::Zero(), |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 // Resets cwnd and slow start threshold on connection migrations. | 734 // Resets cwnd and slow start threshold on connection migrations. |
678 sender_->OnConnectionMigration(); | 735 sender_->OnConnectionMigration(); |
679 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 736 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
680 EXPECT_EQ(kMaxCongestionWindow * kDefaultTCPMSS, | 737 EXPECT_EQ(kMaxCongestionWindow * kDefaultTCPMSS, |
681 sender_->GetSlowStartThreshold()); | 738 sender_->GetSlowStartThreshold()); |
682 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 739 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
683 } | 740 } |
684 | 741 |
685 } // namespace test | 742 } // namespace test |
686 } // namespace net | 743 } // namespace net |
OLD | NEW |