| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 CreateSmallBufferSetup(); | 217 CreateSmallBufferSetup(); |
| 218 | 218 |
| 219 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(30)); | 219 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(30)); |
| 220 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); | 220 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
| 221 ExpectApproxEq(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth, | 221 ExpectApproxEq(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth, |
| 222 0.01f); | 222 0.01f); |
| 223 EXPECT_GE(bbr_sender_.connection()->GetStats().packets_lost, 0u); | 223 EXPECT_GE(bbr_sender_.connection()->GetStats().packets_lost, 0u); |
| 224 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); | 224 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Test the number of losses incurred by the startup phase in a situation when |
| 228 // the buffer is less than BDP. |
| 229 TEST_F(BbrSenderTest, PacketLossOnSmallBufferStartup) { |
| 230 CreateSmallBufferSetup(); |
| 231 |
| 232 DriveOutOfStartup(); |
| 233 float loss_rate = |
| 234 static_cast<float>(bbr_sender_.connection()->GetStats().packets_lost) / |
| 235 bbr_sender_.connection()->GetStats().packets_sent; |
| 236 EXPECT_LE(loss_rate, 0.20); |
| 237 } |
| 238 |
| 239 // Ensures the code transitions loss recovery states correctly (NOT_IN_RECOVERY |
| 240 // -> CONSERVATION -> GROWTH -> NOT_IN_RECOVERY). |
| 241 TEST_F(BbrSenderTest, RecoveryStates) { |
| 242 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(10); |
| 243 bool simulator_result; |
| 244 CreateSmallBufferSetup(); |
| 245 |
| 246 bbr_sender_.AddBytesToTransfer(100 * 1024 * 1024); |
| 247 ASSERT_EQ(BbrSender::NOT_IN_RECOVERY, |
| 248 sender_->ExportDebugState().recovery_state); |
| 249 |
| 250 simulator_result = simulator_.RunUntilOrTimeout( |
| 251 [this]() { |
| 252 return sender_->ExportDebugState().recovery_state != |
| 253 BbrSender::NOT_IN_RECOVERY; |
| 254 }, |
| 255 timeout); |
| 256 ASSERT_TRUE(simulator_result); |
| 257 ASSERT_EQ(BbrSender::CONSERVATION, |
| 258 sender_->ExportDebugState().recovery_state); |
| 259 |
| 260 simulator_result = simulator_.RunUntilOrTimeout( |
| 261 [this]() { |
| 262 return sender_->ExportDebugState().recovery_state != |
| 263 BbrSender::CONSERVATION; |
| 264 }, |
| 265 timeout); |
| 266 ASSERT_TRUE(simulator_result); |
| 267 ASSERT_EQ(BbrSender::GROWTH, sender_->ExportDebugState().recovery_state); |
| 268 |
| 269 simulator_result = simulator_.RunUntilOrTimeout( |
| 270 [this]() { |
| 271 return sender_->ExportDebugState().recovery_state != BbrSender::GROWTH; |
| 272 }, |
| 273 timeout); |
| 274 ASSERT_TRUE(simulator_result); |
| 275 ASSERT_EQ(BbrSender::NOT_IN_RECOVERY, |
| 276 sender_->ExportDebugState().recovery_state); |
| 277 } |
| 278 |
| 227 // Verify the behavior of the algorithm in the case when the connection sends | 279 // Verify the behavior of the algorithm in the case when the connection sends |
| 228 // small bursts of data after sending continuously for a while. | 280 // small bursts of data after sending continuously for a while. |
| 229 TEST_F(BbrSenderTest, ApplicationLimitedBursts) { | 281 TEST_F(BbrSenderTest, ApplicationLimitedBursts) { |
| 230 CreateDefaultSetup(); | 282 CreateDefaultSetup(); |
| 231 | 283 |
| 232 DriveOutOfStartup(); | 284 DriveOutOfStartup(); |
| 233 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); | 285 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); |
| 234 | 286 |
| 235 SendBursts(20, 512, QuicTime::Delta::FromSeconds(3)); | 287 SendBursts(20, 512, QuicTime::Delta::FromSeconds(3)); |
| 236 EXPECT_TRUE(sender_->ExportDebugState().last_sample_is_app_limited); | 288 EXPECT_TRUE(sender_->ExportDebugState().last_sample_is_app_limited); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 [this]() { return sender_->ExportDebugState().gain_cycle_index == 1; }, | 425 [this]() { return sender_->ExportDebugState().gain_cycle_index == 1; }, |
| 374 timeout); | 426 timeout); |
| 375 ASSERT_TRUE(simulator_result); | 427 ASSERT_TRUE(simulator_result); |
| 376 simulator_.RunFor(0.75 * sender_->ExportDebugState().min_rtt); | 428 simulator_.RunFor(0.75 * sender_->ExportDebugState().min_rtt); |
| 377 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); | 429 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
| 378 EXPECT_EQ(2, sender_->ExportDebugState().gain_cycle_index); | 430 EXPECT_EQ(2, sender_->ExportDebugState().gain_cycle_index); |
| 379 } | 431 } |
| 380 | 432 |
| 381 } // namespace test | 433 } // namespace test |
| 382 } // namespace net | 434 } // namespace net |
| OLD | NEW |