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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); | 289 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
290 ExpectApproxEq(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth, | 290 ExpectApproxEq(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth, |
291 0.01f); | 291 0.01f); |
292 EXPECT_GE(bbr_sender_.connection()->GetStats().packets_lost, 0u); | 292 EXPECT_GE(bbr_sender_.connection()->GetStats().packets_lost, 0u); |
293 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); | 293 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); |
294 } | 294 } |
295 | 295 |
296 // Test a simple long data transfer with 2 rtts of aggregation. | 296 // Test a simple long data transfer with 2 rtts of aggregation. |
297 TEST_F(BbrSenderTest, SimpleTransfer2RTTAggregationBytes) { | 297 TEST_F(BbrSenderTest, SimpleTransfer2RTTAggregationBytes) { |
298 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true; | 298 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true; |
| 299 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2 = false; |
299 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false; | 300 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false; |
300 CreateDefaultSetup(); | 301 CreateDefaultSetup(); |
301 // 2 RTTs of aggregation, with a max of 10kb. | 302 // 2 RTTs of aggregation, with a max of 10kb. |
302 EnableAggregation(10 * 1024, 2 * kTestRtt); | 303 EnableAggregation(10 * 1024, 2 * kTestRtt); |
303 | 304 |
304 // Transfer 12MB. | 305 // Transfer 12MB. |
305 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); | 306 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); |
306 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); | 307 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
307 // It's possible to read a bandwidth as much as 50% too high with aggregation. | 308 // It's possible to read a bandwidth as much as 50% too high with aggregation. |
308 EXPECT_LE(kTestLinkBandwidth * 0.99f, | 309 EXPECT_LE(kTestLinkBandwidth * 0.99f, |
309 sender_->ExportDebugState().max_bandwidth); | 310 sender_->ExportDebugState().max_bandwidth); |
310 // TODO(ianswett): Tighten this bound once we understand why BBR is | 311 // TODO(ianswett): Tighten this bound once we understand why BBR is |
311 // overestimating bandwidth with aggregation. b/36022633 | 312 // overestimating bandwidth with aggregation. b/36022633 |
312 EXPECT_GE(kTestLinkBandwidth * 1.5f, | 313 EXPECT_GE(kTestLinkBandwidth * 1.5f, |
313 sender_->ExportDebugState().max_bandwidth); | 314 sender_->ExportDebugState().max_bandwidth); |
314 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures | 315 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures |
315 // bandwidth higher than the link rate. | 316 // bandwidth higher than the link rate. |
316 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); | 317 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); |
317 // The margin here is high, because the aggregation greatly increases | 318 // The margin here is high, because the aggregation greatly increases |
318 // smoothed rtt. | 319 // smoothed rtt. |
319 EXPECT_GE(kTestRtt * 4, rtt_stats_->smoothed_rtt()); | 320 EXPECT_GE(kTestRtt * 4, rtt_stats_->smoothed_rtt()); |
320 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.12f); | 321 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.12f); |
321 } | 322 } |
322 | 323 |
323 // Test a simple long data transfer with 2 rtts of aggregation. | 324 // Test a simple long data transfer with 2 rtts of aggregation. |
324 TEST_F(BbrSenderTest, SimpleTransferAckDecimation) { | 325 TEST_F(BbrSenderTest, SimpleTransferAckDecimation) { |
325 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true; | 326 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true; |
| 327 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2 = false; |
326 // Decrease the CWND gain so extra CWND is required with stretch acks. | 328 // Decrease the CWND gain so extra CWND is required with stretch acks. |
327 FLAGS_quic_bbr_cwnd_gain = 1.0; | 329 FLAGS_quic_bbr_cwnd_gain = 1.0; |
328 sender_ = new BbrSender( | 330 sender_ = new BbrSender( |
| 331 rtt_stats_, |
| 332 QuicSentPacketManagerPeer::GetUnackedPacketMap( |
| 333 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), |
| 334 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, |
| 335 &random_); |
| 336 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); |
| 337 // Enable Ack Decimation on the receiver. |
| 338 QuicConnectionPeer::SetAckMode(receiver_.connection(), |
| 339 QuicConnection::AckMode::ACK_DECIMATION); |
| 340 CreateDefaultSetup(); |
| 341 |
| 342 // Transfer 12MB. |
| 343 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); |
| 344 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
| 345 // It's possible to read a bandwidth as much as 50% too high with aggregation. |
| 346 EXPECT_LE(kTestLinkBandwidth * 0.99f, |
| 347 sender_->ExportDebugState().max_bandwidth); |
| 348 // TODO(ianswett): Tighten this bound once we understand why BBR is |
| 349 // overestimating bandwidth with aggregation. b/36022633 |
| 350 EXPECT_GE(kTestLinkBandwidth * 1.5f, |
| 351 sender_->ExportDebugState().max_bandwidth); |
| 352 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures |
| 353 // bandwidth higher than the link rate. |
| 354 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); |
| 355 // The margin here is high, because the aggregation greatly increases |
| 356 // smoothed rtt. |
| 357 EXPECT_GE(kTestRtt * 2, rtt_stats_->smoothed_rtt()); |
| 358 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); |
| 359 } |
| 360 |
| 361 // Test a simple long data transfer with 2 rtts of aggregation. |
| 362 TEST_F(BbrSenderTest, SimpleTransfer2RTTAggregationBytes2) { |
| 363 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2 = true; |
| 364 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false; |
| 365 CreateDefaultSetup(); |
| 366 // 2 RTTs of aggregation, with a max of 10kb. |
| 367 EnableAggregation(10 * 1024, 2 * kTestRtt); |
| 368 |
| 369 // Transfer 12MB. |
| 370 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); |
| 371 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
| 372 // It's possible to read a bandwidth as much as 50% too high with aggregation. |
| 373 EXPECT_LE(kTestLinkBandwidth * 0.99f, |
| 374 sender_->ExportDebugState().max_bandwidth); |
| 375 // TODO(ianswett): Tighten this bound once we understand why BBR is |
| 376 // overestimating bandwidth with aggregation. b/36022633 |
| 377 EXPECT_GE(kTestLinkBandwidth * 1.5f, |
| 378 sender_->ExportDebugState().max_bandwidth); |
| 379 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures |
| 380 // bandwidth higher than the link rate. |
| 381 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); |
| 382 // The margin here is high, because the aggregation greatly increases |
| 383 // smoothed rtt. |
| 384 EXPECT_GE(kTestRtt * 4, rtt_stats_->smoothed_rtt()); |
| 385 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.12f); |
| 386 } |
| 387 |
| 388 // Test a simple long data transfer with 2 rtts of aggregation. |
| 389 TEST_F(BbrSenderTest, SimpleTransferAckDecimation2) { |
| 390 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2 = true; |
| 391 // Decrease the CWND gain so extra CWND is required with stretch acks. |
| 392 FLAGS_quic_bbr_cwnd_gain = 1.0; |
| 393 sender_ = new BbrSender( |
329 rtt_stats_, | 394 rtt_stats_, |
330 QuicSentPacketManagerPeer::GetUnackedPacketMap( | 395 QuicSentPacketManagerPeer::GetUnackedPacketMap( |
331 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), | 396 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), |
332 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, | 397 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, |
333 &random_); | 398 &random_); |
334 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); | 399 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); |
335 // Enable Ack Decimation on the receiver. | 400 // Enable Ack Decimation on the receiver. |
336 QuicConnectionPeer::SetAckMode(receiver_.connection(), | 401 QuicConnectionPeer::SetAckMode(receiver_.connection(), |
337 QuicConnection::AckMode::ACK_DECIMATION); | 402 QuicConnection::AckMode::ACK_DECIMATION); |
338 CreateDefaultSetup(); | 403 CreateDefaultSetup(); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 sender_->ResumeConnectionState(params, false); | 802 sender_->ResumeConnectionState(params, false); |
738 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); | 803 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); |
739 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); | 804 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); |
740 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f); | 805 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f); |
741 | 806 |
742 DriveOutOfStartup(); | 807 DriveOutOfStartup(); |
743 } | 808 } |
744 | 809 |
745 } // namespace test | 810 } // namespace test |
746 } // namespace net | 811 } // namespace net |
OLD | NEW |