| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/core/congestion_control/bbr_sender.h" | 5 #include "net/quic/core/congestion_control/bbr_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 bbr_sender_(&simulator_, | 71 bbr_sender_(&simulator_, |
| 72 "BBR sender", | 72 "BBR sender", |
| 73 "Receiver", | 73 "Receiver", |
| 74 Perspective::IS_CLIENT, | 74 Perspective::IS_CLIENT, |
| 75 42), | 75 42), |
| 76 receiver_(&simulator_, | 76 receiver_(&simulator_, |
| 77 "Receiver", | 77 "Receiver", |
| 78 "BBR sender", | 78 "BBR sender", |
| 79 Perspective::IS_SERVER, | 79 Perspective::IS_SERVER, |
| 80 42) { | 80 42) { |
| 81 FLAGS_quic_bbr_faster_startup = true; |
| 82 |
| 81 rtt_stats_ = bbr_sender_.connection()->sent_packet_manager().GetRttStats(); | 83 rtt_stats_ = bbr_sender_.connection()->sent_packet_manager().GetRttStats(); |
| 82 sender_ = new BbrSender(simulator_.GetClock(), rtt_stats_, | 84 sender_ = new BbrSender(simulator_.GetClock(), rtt_stats_, |
| 83 QuicSentPacketManagerPeer::GetUnackedPacketMap( | 85 QuicSentPacketManagerPeer::GetUnackedPacketMap( |
| 84 QuicConnectionPeer::GetSentPacketManager( | 86 QuicConnectionPeer::GetSentPacketManager( |
| 85 bbr_sender_.connection(), kDefaultPathId)), | 87 bbr_sender_.connection(), kDefaultPathId)), |
| 86 kInitialCongestionWindowPackets, | 88 kInitialCongestionWindowPackets, |
| 87 kDefaultMaxCongestionWindowPackets, &random_); | 89 kDefaultMaxCongestionWindowPackets, &random_); |
| 88 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), | 90 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), |
| 89 kDefaultPathId, sender_); | 91 kDefaultPathId, sender_); |
| 90 | 92 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 228 |
| 227 // Test the number of losses incurred by the startup phase in a situation when | 229 // Test the number of losses incurred by the startup phase in a situation when |
| 228 // the buffer is less than BDP. | 230 // the buffer is less than BDP. |
| 229 TEST_F(BbrSenderTest, PacketLossOnSmallBufferStartup) { | 231 TEST_F(BbrSenderTest, PacketLossOnSmallBufferStartup) { |
| 230 CreateSmallBufferSetup(); | 232 CreateSmallBufferSetup(); |
| 231 | 233 |
| 232 DriveOutOfStartup(); | 234 DriveOutOfStartup(); |
| 233 float loss_rate = | 235 float loss_rate = |
| 234 static_cast<float>(bbr_sender_.connection()->GetStats().packets_lost) / | 236 static_cast<float>(bbr_sender_.connection()->GetStats().packets_lost) / |
| 235 bbr_sender_.connection()->GetStats().packets_sent; | 237 bbr_sender_.connection()->GetStats().packets_sent; |
| 236 EXPECT_LE(loss_rate, 0.20); | 238 EXPECT_LE(loss_rate, 0.27); |
| 237 } | 239 } |
| 238 | 240 |
| 239 // Ensures the code transitions loss recovery states correctly (NOT_IN_RECOVERY | 241 // Ensures the code transitions loss recovery states correctly (NOT_IN_RECOVERY |
| 240 // -> CONSERVATION -> GROWTH -> NOT_IN_RECOVERY). | 242 // -> CONSERVATION -> GROWTH -> NOT_IN_RECOVERY). |
| 241 TEST_F(BbrSenderTest, RecoveryStates) { | 243 TEST_F(BbrSenderTest, RecoveryStates) { |
| 242 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(10); | 244 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(10); |
| 243 bool simulator_result; | 245 bool simulator_result; |
| 244 CreateSmallBufferSetup(); | 246 CreateSmallBufferSetup(); |
| 245 | 247 |
| 246 bbr_sender_.AddBytesToTransfer(100 * 1024 * 1024); | 248 bbr_sender_.AddBytesToTransfer(100 * 1024 * 1024); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 bbr_sender_.AddBytesToTransfer(1.3 * kTestBdp); | 425 bbr_sender_.AddBytesToTransfer(1.3 * kTestBdp); |
| 424 simulator_result = simulator_.RunUntilOrTimeout( | 426 simulator_result = simulator_.RunUntilOrTimeout( |
| 425 [this]() { return sender_->ExportDebugState().gain_cycle_index == 1; }, | 427 [this]() { return sender_->ExportDebugState().gain_cycle_index == 1; }, |
| 426 timeout); | 428 timeout); |
| 427 ASSERT_TRUE(simulator_result); | 429 ASSERT_TRUE(simulator_result); |
| 428 simulator_.RunFor(0.75 * sender_->ExportDebugState().min_rtt); | 430 simulator_.RunFor(0.75 * sender_->ExportDebugState().min_rtt); |
| 429 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); | 431 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
| 430 EXPECT_EQ(2, sender_->ExportDebugState().gain_cycle_index); | 432 EXPECT_EQ(2, sender_->ExportDebugState().gain_cycle_index); |
| 431 } | 433 } |
| 432 | 434 |
| 435 // Ensure that the pacing rate does not drop at startup. |
| 436 TEST_F(BbrSenderTest, NoBandwidthDropOnStartup) { |
| 437 CreateDefaultSetup(); |
| 438 |
| 439 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5); |
| 440 bool simulator_result; |
| 441 |
| 442 QuicBandwidth initial_rate = QuicBandwidth::FromBytesAndTimeDelta( |
| 443 kInitialCongestionWindowPackets * kDefaultTCPMSS, |
| 444 QuicTime::Delta::FromMicroseconds(rtt_stats_->initial_rtt_us())); |
| 445 EXPECT_GE(sender_->PacingRate(0), initial_rate); |
| 446 |
| 447 // Send a packet. |
| 448 bbr_sender_.AddBytesToTransfer(1000); |
| 449 simulator_result = simulator_.RunUntilOrTimeout( |
| 450 [this]() { return receiver_.bytes_received() == 1000; }, timeout); |
| 451 ASSERT_TRUE(simulator_result); |
| 452 EXPECT_GE(sender_->PacingRate(0), initial_rate); |
| 453 |
| 454 // Wait for a while. |
| 455 simulator_.RunFor(QuicTime::Delta::FromSeconds(2)); |
| 456 EXPECT_GE(sender_->PacingRate(0), initial_rate); |
| 457 |
| 458 // Send another packet. |
| 459 bbr_sender_.AddBytesToTransfer(1000); |
| 460 simulator_result = simulator_.RunUntilOrTimeout( |
| 461 [this]() { return receiver_.bytes_received() == 2000; }, timeout); |
| 462 ASSERT_TRUE(simulator_result); |
| 463 EXPECT_GE(sender_->PacingRate(0), initial_rate); |
| 464 } |
| 465 |
| 433 } // namespace test | 466 } // namespace test |
| 434 } // namespace net | 467 } // namespace net |
| OLD | NEW |