| 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 <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "net/quic/core/congestion_control/rtt_stats.h" | 10 #include "net/quic/core/congestion_control/rtt_stats.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 last_cycle_start_(QuicTime::Zero()), | 92 last_cycle_start_(QuicTime::Zero()), |
| 93 is_at_full_bandwidth_(false), | 93 is_at_full_bandwidth_(false), |
| 94 rounds_without_bandwidth_gain_(0), | 94 rounds_without_bandwidth_gain_(0), |
| 95 bandwidth_at_last_round_(QuicBandwidth::Zero()), | 95 bandwidth_at_last_round_(QuicBandwidth::Zero()), |
| 96 exiting_quiescence_(false), | 96 exiting_quiescence_(false), |
| 97 exit_probe_rtt_at_(QuicTime::Zero()), | 97 exit_probe_rtt_at_(QuicTime::Zero()), |
| 98 probe_rtt_round_passed_(false), | 98 probe_rtt_round_passed_(false), |
| 99 last_sample_is_app_limited_(false), | 99 last_sample_is_app_limited_(false), |
| 100 recovery_state_(NOT_IN_RECOVERY), | 100 recovery_state_(NOT_IN_RECOVERY), |
| 101 end_recovery_at_(0), | 101 end_recovery_at_(0), |
| 102 recovery_window_(max_congestion_window_) { | 102 recovery_window_(max_congestion_window_), |
| 103 enforce_startup_pacing_rate_increase_( |
| 104 FLAGS_quic_bbr_faster_startup) { |
| 103 EnterStartupMode(); | 105 EnterStartupMode(); |
| 104 } | 106 } |
| 105 | 107 |
| 106 BbrSender::~BbrSender() {} | 108 BbrSender::~BbrSender() {} |
| 107 | 109 |
| 108 bool BbrSender::InSlowStart() const { | 110 bool BbrSender::InSlowStart() const { |
| 109 return mode_ == STARTUP; | 111 return mode_ == STARTUP; |
| 110 } | 112 } |
| 111 | 113 |
| 112 bool BbrSender::OnPacketSent(QuicTime sent_time, | 114 bool BbrSender::OnPacketSent(QuicTime sent_time, |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 449 } |
| 448 break; | 450 break; |
| 449 } | 451 } |
| 450 } | 452 } |
| 451 | 453 |
| 452 void BbrSender::CalculatePacingRate() { | 454 void BbrSender::CalculatePacingRate() { |
| 453 if (BandwidthEstimate().IsZero()) { | 455 if (BandwidthEstimate().IsZero()) { |
| 454 return; | 456 return; |
| 455 } | 457 } |
| 456 | 458 |
| 457 pacing_rate_ = pacing_gain_ * BandwidthEstimate(); | 459 QuicBandwidth target_rate = pacing_gain_ * BandwidthEstimate(); |
| 460 |
| 461 // Ensure that the pacing rate does not drop too low during the startup. |
| 462 if (!is_at_full_bandwidth_ && enforce_startup_pacing_rate_increase_) { |
| 463 // Pace at the rate of initial_window / RTT as soon as RTT measurements are |
| 464 // available. |
| 465 if (pacing_rate_.IsZero() && !rtt_stats_->min_rtt().IsZero()) { |
| 466 pacing_rate_ = QuicBandwidth::FromBytesAndTimeDelta( |
| 467 initial_congestion_window_, rtt_stats_->min_rtt()); |
| 468 return; |
| 469 } |
| 470 |
| 471 // Do not decrease the pacing rate during the startup. |
| 472 pacing_rate_ = std::max(pacing_rate_, target_rate); |
| 473 return; |
| 474 } |
| 475 |
| 476 pacing_rate_ = target_rate; |
| 458 } | 477 } |
| 459 | 478 |
| 460 void BbrSender::CalculateCongestionWindow(QuicByteCount bytes_acked) { | 479 void BbrSender::CalculateCongestionWindow(QuicByteCount bytes_acked) { |
| 461 if (mode_ == PROBE_RTT) { | 480 if (mode_ == PROBE_RTT) { |
| 462 return; | 481 return; |
| 463 } | 482 } |
| 464 | 483 |
| 465 QuicByteCount target_window = | 484 QuicByteCount target_window = |
| 466 GetTargetCongestionWindow(congestion_window_gain_); | 485 GetTargetCongestionWindow(congestion_window_gain_); |
| 467 | 486 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() | 575 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() |
| 557 << std::endl; | 576 << std::endl; |
| 558 | 577 |
| 559 os << "Last sample is app-limited: " | 578 os << "Last sample is app-limited: " |
| 560 << (state.last_sample_is_app_limited ? "yes" : "no"); | 579 << (state.last_sample_is_app_limited ? "yes" : "no"); |
| 561 | 580 |
| 562 return os; | 581 return os; |
| 563 } | 582 } |
| 564 | 583 |
| 565 } // namespace net | 584 } // namespace net |
| OLD | NEW |