| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // The margin here is high, because the aggregation greatly increases | 343 // The margin here is high, because the aggregation greatly increases |
| 344 // smoothed rtt. | 344 // smoothed rtt. |
| 345 EXPECT_GE(kTestRtt * 4.5, rtt_stats_->smoothed_rtt()); | 345 EXPECT_GE(kTestRtt * 4.5, rtt_stats_->smoothed_rtt()); |
| 346 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); | 346 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); |
| 347 } | 347 } |
| 348 | 348 |
| 349 // Test a simple long data transfer with 2 rtts of aggregation. | 349 // Test a simple long data transfer with 2 rtts of aggregation. |
| 350 TEST_F(BbrSenderTest, SimpleTransferAckDecimation) { | 350 TEST_F(BbrSenderTest, SimpleTransferAckDecimation) { |
| 351 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true; | 351 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true; |
| 352 // Decrease the CWND gain so extra CWND is required with stretch acks. | 352 // Decrease the CWND gain so extra CWND is required with stretch acks. |
| 353 SetQuicFlag(&FLAGS_quic_bbr_cwnd_gain, 1.0); | 353 FLAGS_quic_bbr_cwnd_gain = 1.0; |
| 354 sender_ = new BbrSender( | 354 sender_ = new BbrSender( |
| 355 rtt_stats_, | 355 rtt_stats_, |
| 356 QuicSentPacketManagerPeer::GetUnackedPacketMap( | 356 QuicSentPacketManagerPeer::GetUnackedPacketMap( |
| 357 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), | 357 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), |
| 358 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, | 358 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, |
| 359 &random_); | 359 &random_); |
| 360 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); | 360 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); |
| 361 // Enable Ack Decimation on the receiver. | 361 // Enable Ack Decimation on the receiver. |
| 362 QuicConnectionPeer::SetAckMode(receiver_.connection(), | 362 QuicConnectionPeer::SetAckMode(receiver_.connection(), |
| 363 QuicConnection::AckMode::ACK_DECIMATION); | 363 QuicConnection::AckMode::ACK_DECIMATION); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 380 // smoothed rtt. | 380 // smoothed rtt. |
| 381 EXPECT_GE(kTestRtt * 2, rtt_stats_->smoothed_rtt()); | 381 EXPECT_GE(kTestRtt * 2, rtt_stats_->smoothed_rtt()); |
| 382 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); | 382 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); |
| 383 } | 383 } |
| 384 | 384 |
| 385 TEST_F(BbrSenderTest, SimpleTransferAckDecimationKeepSending) { | 385 TEST_F(BbrSenderTest, SimpleTransferAckDecimationKeepSending) { |
| 386 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = false; | 386 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = false; |
| 387 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = true; | 387 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = true; |
| 388 FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate = true; | 388 FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate = true; |
| 389 // Decrease the CWND gain so extra CWND is required with stretch acks. | 389 // Decrease the CWND gain so extra CWND is required with stretch acks. |
| 390 SetQuicFlag(&FLAGS_quic_bbr_cwnd_gain, 1.0); | 390 FLAGS_quic_bbr_cwnd_gain = 1.0; |
| 391 sender_ = new BbrSender( | 391 sender_ = new BbrSender( |
| 392 rtt_stats_, | 392 rtt_stats_, |
| 393 QuicSentPacketManagerPeer::GetUnackedPacketMap( | 393 QuicSentPacketManagerPeer::GetUnackedPacketMap( |
| 394 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), | 394 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), |
| 395 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, | 395 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, |
| 396 &random_); | 396 &random_); |
| 397 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); | 397 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); |
| 398 // Enable Ack Decimation on the receiver. | 398 // Enable Ack Decimation on the receiver. |
| 399 QuicConnectionPeer::SetAckMode(receiver_.connection(), | 399 QuicConnectionPeer::SetAckMode(receiver_.connection(), |
| 400 QuicConnection::AckMode::ACK_DECIMATION); | 400 QuicConnection::AckMode::ACK_DECIMATION); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 419 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); | 419 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Test a simple long data transfer with 2 rtts of aggregation. | 422 // Test a simple long data transfer with 2 rtts of aggregation. |
| 423 TEST_F(BbrSenderTest, | 423 TEST_F(BbrSenderTest, |
| 424 SimpleTransfer2RTTAggregationBytesWithIncreasedInflightLimit) { | 424 SimpleTransfer2RTTAggregationBytesWithIncreasedInflightLimit) { |
| 425 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = false; | 425 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = false; |
| 426 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false; | 426 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false; |
| 427 FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate = false; | 427 FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate = false; |
| 428 FLAGS_quic_reloadable_flag_quic_bbr_slow_recent_delivery = true; | 428 FLAGS_quic_reloadable_flag_quic_bbr_slow_recent_delivery = true; |
| 429 SetQuicFlag(&FLAGS_quic_bbr_slow_delivery_threshold_multiplier, 0.5); | 429 FLAGS_quic_bbr_slow_delivery_threshold_multiplier = 0.5; |
| 430 SetQuicFlag(&FLAGS_quic_bbr_slow_delivery_cwnd_gain, 4.0); | 430 FLAGS_quic_bbr_slow_delivery_cwnd_gain = 4.0; |
| 431 CreateDefaultSetup(); | 431 CreateDefaultSetup(); |
| 432 // 2 RTTs of aggregation, with a max of 10kb. | 432 // 2 RTTs of aggregation, with a max of 10kb. |
| 433 EnableAggregation(10 * 1024, 2 * kTestRtt); | 433 EnableAggregation(10 * 1024, 2 * kTestRtt); |
| 434 | 434 |
| 435 // Transfer 12MB. | 435 // Transfer 12MB. |
| 436 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); | 436 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); |
| 437 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); | 437 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); |
| 438 // It's possible to read a bandwidth as much as 50% too high with aggregation. | 438 // It's possible to read a bandwidth as much as 50% too high with aggregation. |
| 439 EXPECT_LE(kTestLinkBandwidth * 0.99f, | 439 EXPECT_LE(kTestLinkBandwidth * 0.99f, |
| 440 sender_->ExportDebugState().max_bandwidth); | 440 sender_->ExportDebugState().max_bandwidth); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 sender_->ResumeConnectionState(params, false); | 808 sender_->ResumeConnectionState(params, false); |
| 809 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); | 809 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); |
| 810 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); | 810 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); |
| 811 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f); | 811 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f); |
| 812 | 812 |
| 813 DriveOutOfStartup(); | 813 DriveOutOfStartup(); |
| 814 } | 814 } |
| 815 | 815 |
| 816 } // namespace test | 816 } // namespace test |
| 817 } // namespace net | 817 } // namespace net |
| OLD | NEW |