blob: b64dc99d8542578352f796af799b51338dc3a4a8 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/quic/core/congestion_control/bbr_sender.h"
#include <algorithm>
#include <sstream>
#include "net/quic/core/congestion_control/rtt_stats.h"
#include "net/quic/core/crypto/crypto_protocol.h"
#include "net/quic/core/quic_flags.h"
#include "net/quic/platform/api/quic_bug_tracker.h"
#include "net/quic/platform/api/quic_flag_utils.h"
#include "net/quic/platform/api/quic_logging.h"
namespace net {
namespace {
// Constants based on TCP defaults.
const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS;
// The minimum CWND to ensure delayed acks don't reduce bandwidth measurements.
// Does not inflate the pacing rate.
const QuicByteCount kMinimumCongestionWindow = 4 * kMaxSegmentSize;
// The gain used for the slow start, equal to 2/ln(2).
const float kHighGain = 2.885f;
// The gain used to drain the queue after the slow start.
const float kDrainGain = 1.f / kHighGain;
// The cycle of gains used during the PROBE_BW stage.
const float kPacingGain[] = {1.25, 0.75, 1, 1, 1, 1, 1, 1};
// The length of the gain cycle.
const size_t kGainCycleLength = sizeof(kPacingGain) / sizeof(kPacingGain[0]);
// The size of the bandwidth filter window, in round-trips.
const QuicRoundTripCount kBandwidthWindowSize = kGainCycleLength + 2;
// The time after which the current min_rtt value expires.
const QuicTime::Delta kMinRttExpiry = QuicTime::Delta::FromSeconds(10);
// The minimum time the connection can spend in PROBE_RTT mode.
const QuicTime::Delta kProbeRttTime = QuicTime::Delta::FromMilliseconds(200);
// If the bandwidth does not increase by the factor of |kStartupGrowthTarget|
// within |kRoundTripsWithoutGrowthBeforeExitingStartup| rounds, the connection
// will exit the STARTUP mode.
const float kStartupGrowthTarget = 1.25;
const QuicRoundTripCount kRoundTripsWithoutGrowthBeforeExitingStartup = 3;
} // namespace
BbrSender::DebugState::DebugState(const BbrSender& sender)
: mode(sender.mode_),
max_bandwidth(sender.max_bandwidth_.GetBest()),
round_trip_count(sender.round_trip_count_),
gain_cycle_index(sender.cycle_current_offset_),
congestion_window(sender.congestion_window_),
is_at_full_bandwidth(sender.is_at_full_bandwidth_),
bandwidth_at_last_round(sender.bandwidth_at_last_round_),
rounds_without_bandwidth_gain(sender.rounds_without_bandwidth_gain_),
min_rtt(sender.min_rtt_),
min_rtt_timestamp(sender.min_rtt_timestamp_),
recovery_state(sender.recovery_state_),
recovery_window(sender.recovery_window_),
last_sample_is_app_limited(sender.last_sample_is_app_limited_),
end_of_app_limited_phase(sender.sampler_.end_of_app_limited_phase()) {}
BbrSender::DebugState::DebugState(const DebugState& state) = default;
BbrSender::BbrSender(const RttStats* rtt_stats,
const QuicUnackedPacketMap* unacked_packets,
QuicPacketCount initial_tcp_congestion_window,
QuicPacketCount max_tcp_congestion_window,
QuicRandom* random)
: rtt_stats_(rtt_stats),
unacked_packets_(unacked_packets),
random_(random),
mode_(STARTUP),
sampler_(),
round_trip_count_(0),
last_sent_packet_(0),
current_round_trip_end_(0),
max_bandwidth_(kBandwidthWindowSize, QuicBandwidth::Zero(), 0),
max_ack_spacing_(kBandwidthWindowSize, QuicTime::Delta::Zero(), 0),
largest_acked_time_(QuicTime::Zero()),
largest_acked_sent_time_(QuicTime::Zero()),
max_ack_height_(kBandwidthWindowSize, 0, 0),
aggregation_epoch_start_time_(QuicTime::Zero()),
aggregation_epoch_bytes_(0),
min_rtt_(QuicTime::Delta::Zero()),
min_rtt_timestamp_(QuicTime::Zero()),
congestion_window_(initial_tcp_congestion_window * kDefaultTCPMSS),
initial_congestion_window_(initial_tcp_congestion_window *
kDefaultTCPMSS),
max_congestion_window_(max_tcp_congestion_window * kDefaultTCPMSS),
pacing_rate_(QuicBandwidth::Zero()),
pacing_gain_(1),
congestion_window_gain_(1),
congestion_window_gain_constant_(
static_cast<float>(base::GetFlag(FLAGS_quic_bbr_cwnd_gain))),
rtt_variance_weight_(static_cast<float>(
base::GetFlag(FLAGS_quic_bbr_rtt_variation_weight))),
num_startup_rtts_(kRoundTripsWithoutGrowthBeforeExitingStartup),
cycle_current_offset_(0),
last_cycle_start_(QuicTime::Zero()),
is_at_full_bandwidth_(false),
rounds_without_bandwidth_gain_(0),
bandwidth_at_last_round_(QuicBandwidth::Zero()),
exiting_quiescence_(false),
exit_probe_rtt_at_(QuicTime::Zero()),
probe_rtt_round_passed_(false),
last_sample_is_app_limited_(false),
recovery_state_(NOT_IN_RECOVERY),
end_recovery_at_(0),
recovery_window_(max_congestion_window_) {
EnterStartupMode();
}
BbrSender::~BbrSender() {}
bool BbrSender::InSlowStart() const {
return mode_ == STARTUP;
}
bool BbrSender::OnPacketSent(QuicTime sent_time,
QuicByteCount bytes_in_flight,
QuicPacketNumber packet_number,
QuicByteCount bytes,
HasRetransmittableData is_retransmittable) {
last_sent_packet_ = packet_number;
if (bytes_in_flight == 0 && sampler_.is_app_limited()) {
exiting_quiescence_ = true;
}
sampler_.OnPacketSent(sent_time, packet_number, bytes, bytes_in_flight,
is_retransmittable);
return is_retransmittable == HAS_RETRANSMITTABLE_DATA;
}
QuicTime::Delta BbrSender::TimeUntilSend(QuicTime /* now */,
QuicByteCount bytes_in_flight) const {
if (bytes_in_flight < GetCongestionWindow()) {
return QuicTime::Delta::Zero();
}
return QuicTime::Delta::Infinite();
}
QuicBandwidth BbrSender::PacingRate(QuicByteCount /*bytes_in_flight*/) const {
if (pacing_rate_.IsZero()) {
return kHighGain * QuicBandwidth::FromBytesAndTimeDelta(
initial_congestion_window_, GetMinRtt());
}
return pacing_rate_;
}
QuicBandwidth BbrSender::BandwidthEstimate() const {
return max_bandwidth_.GetBest();
}
QuicByteCount BbrSender::GetCongestionWindow() const {
if (mode_ == PROBE_RTT) {
return kMinimumCongestionWindow;
}
if (InRecovery()) {
return std::min(congestion_window_, recovery_window_);
}
return congestion_window_;
}
QuicByteCount BbrSender::GetSlowStartThreshold() const {
return 0;
}
bool BbrSender::InRecovery() const {
return recovery_state_ != NOT_IN_RECOVERY;
}
void BbrSender::SetFromConfig(const QuicConfig& config,
Perspective perspective) {
if (FLAGS_quic_reloadable_flag_quic_allow_2_rtt_bbr_startup) {
QUIC_FLAG_COUNT(quic_reloadable_flag_quic_allow_2_rtt_bbr_startup);
if (config.HasClientRequestedIndependentOption(k1RTT, perspective)) {
num_startup_rtts_ = 1;
}
if (config.HasClientRequestedIndependentOption(k2RTT, perspective)) {
num_startup_rtts_ = 2;
}
}
}
void BbrSender::OnCongestionEvent(bool /*rtt_updated*/,
QuicByteCount prior_in_flight,
QuicTime event_time,
const CongestionVector& acked_packets,
const CongestionVector& lost_packets) {
const QuicByteCount total_bytes_acked_before = sampler_.total_bytes_acked();
bool is_round_start = false;
bool min_rtt_expired = false;
DiscardLostPackets(lost_packets);
// Input the new data into the BBR model of the connection.
if (!acked_packets.empty()) {
QuicPacketNumber last_acked_packet = acked_packets.rbegin()->first;
is_round_start = UpdateRoundTripCounter(last_acked_packet);
min_rtt_expired = UpdateBandwidthAndMinRtt(event_time, acked_packets);
UpdateRecoveryState(last_acked_packet, !lost_packets.empty(),
is_round_start);
if (FLAGS_quic_reloadable_flag_quic_bbr_ack_spacing2) {
QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_spacing2, 1, 2);
UpdateAckSpacing(event_time, last_acked_packet, acked_packets);
}
if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes) {
QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes, 1,
2);
UpdateAckAggregationBytes(
event_time, sampler_.total_bytes_acked() - total_bytes_acked_before);
}
}
// Handle logic specific to PROBE_BW mode.
if (mode_ == PROBE_BW) {
UpdateGainCyclePhase(event_time, prior_in_flight, !lost_packets.empty());
}
// Handle logic specific to STARTUP and DRAIN modes.
if (is_round_start && !is_at_full_bandwidth_) {
CheckIfFullBandwidthReached();
}
MaybeExitStartupOrDrain(event_time);
// Handle logic specific to PROBE_RTT.
MaybeEnterOrExitProbeRtt(event_time, is_round_start, min_rtt_expired);
// After the model is updated, recalculate the pacing rate and congestion
// window.
QuicByteCount bytes_acked =
sampler_.total_bytes_acked() - total_bytes_acked_before;
CalculatePacingRate();
CalculateCongestionWindow(bytes_acked);
CalculateRecoveryWindow(bytes_acked);
// Cleanup internal state.
sampler_.RemoveObsoletePackets(unacked_packets_->GetLeastUnacked());
}
CongestionControlType BbrSender::GetCongestionControlType() const {
return kBBR;
}
QuicTime::Delta BbrSender::GetMinRtt() const {
return !min_rtt_.IsZero()
? min_rtt_
: QuicTime::Delta::FromMicroseconds(rtt_stats_->initial_rtt_us());
}
QuicByteCount BbrSender::GetTargetCongestionWindow(float gain) const {
QuicByteCount bdp = GetMinRtt() * BandwidthEstimate();
QuicByteCount congestion_window = gain * bdp;
// BDP estimate will be zero if no bandwidth samples are available yet.
if (congestion_window == 0) {
congestion_window = gain * initial_congestion_window_;
}
return std::max(congestion_window, kMinimumCongestionWindow);
}
void BbrSender::EnterStartupMode() {
mode_ = STARTUP;
pacing_gain_ = kHighGain;
congestion_window_gain_ = kHighGain;
}
void BbrSender::EnterProbeBandwidthMode(QuicTime now) {
mode_ = PROBE_BW;
congestion_window_gain_ = congestion_window_gain_constant_;
// Pick a random offset for the gain cycle out of {0, 2..7} range. 1 is
// excluded because in that case increased gain and decreased gain would not
// follow each other.
cycle_current_offset_ =
random_->RandUint64() % (sizeof(kGainCycleLength) - 1);
if (cycle_current_offset_ >= 1) {
cycle_current_offset_ += 1;
}
last_cycle_start_ = now;
pacing_gain_ = kPacingGain[cycle_current_offset_];
}
void BbrSender::DiscardLostPackets(const CongestionVector& lost_packets) {
for (const auto& packet : lost_packets) {
sampler_.OnPacketLost(packet.first);
}
}
bool BbrSender::UpdateRoundTripCounter(QuicPacketNumber last_acked_packet) {
if (last_acked_packet > current_round_trip_end_) {
round_trip_count_++;
current_round_trip_end_ = last_sent_packet_;
return true;
}
return false;
}
bool BbrSender::UpdateBandwidthAndMinRtt(
QuicTime now,
const CongestionVector& acked_packets) {
QuicTime::Delta sample_min_rtt = QuicTime::Delta::Infinite();
for (const auto& packet : acked_packets) {
BandwidthSample bandwidth_sample =
sampler_.OnPacketAcknowledged(now, packet.first);
last_sample_is_app_limited_ = bandwidth_sample.is_app_limited;
if (!bandwidth_sample.rtt.IsZero()) {
sample_min_rtt = std::min(sample_min_rtt, bandwidth_sample.rtt);
}
if (!bandwidth_sample.is_app_limited ||
bandwidth_sample.bandwidth > BandwidthEstimate()) {
max_bandwidth_.Update(bandwidth_sample.bandwidth, round_trip_count_);
}
}
// If none of the RTT samples are valid, return immediately.
if (sample_min_rtt.IsInfinite()) {
return false;
}
// Do not expire min_rtt if none was ever available.
bool min_rtt_expired =
!min_rtt_.IsZero() && (now > (min_rtt_timestamp_ + kMinRttExpiry));
if (min_rtt_expired || sample_min_rtt < min_rtt_ || min_rtt_.IsZero()) {
QUIC_DVLOG(2) << "Min RTT updated, old value: " << min_rtt_
<< ", new value: " << sample_min_rtt
<< ", current time: " << now.ToDebuggingValue();
min_rtt_ = sample_min_rtt;
min_rtt_timestamp_ = now;
}
return min_rtt_expired;
}
void BbrSender::UpdateGainCyclePhase(QuicTime now,
QuicByteCount prior_in_flight,
bool has_losses) {
// In most cases, the cycle is advanced after an RTT passes.
bool should_advance_gain_cycling = now - last_cycle_start_ > GetMinRtt();
// If the pacing gain is above 1.0, the connection is trying to probe the
// bandwidth by increasing the number of bytes in flight to at least
// pacing_gain * BDP. Make sure that it actually reaches the target, as long
// as there are no losses suggesting that the buffers are not able to hold
// that much.
if (pacing_gain_ > 1.0 && !has_losses &&
prior_in_flight < GetTargetCongestionWindow(pacing_gain_)) {
should_advance_gain_cycling = false;
}
// If pacing gain is below 1.0, the connection is trying to drain the extra
// queue which could have been incurred by probing prior to it. If the number
// of bytes in flight falls down to the estimated BDP value earlier, conclude
// that the queue has been successfully drained and exit this cycle early.
if (pacing_gain_ < 1.0 && prior_in_flight <= GetTargetCongestionWindow(1)) {
should_advance_gain_cycling = true;
}
if (should_advance_gain_cycling) {
cycle_current_offset_ = (cycle_current_offset_ + 1) % kGainCycleLength;
last_cycle_start_ = now;
pacing_gain_ = kPacingGain[cycle_current_offset_];
}
}
void BbrSender::CheckIfFullBandwidthReached() {
if (last_sample_is_app_limited_) {
return;
}
QuicBandwidth target = bandwidth_at_last_round_ * kStartupGrowthTarget;
if (BandwidthEstimate() >= target) {
bandwidth_at_last_round_ = BandwidthEstimate();
rounds_without_bandwidth_gain_ = 0;
return;
}
rounds_without_bandwidth_gain_++;
if (rounds_without_bandwidth_gain_ >= num_startup_rtts_) {
is_at_full_bandwidth_ = true;
}
}
void BbrSender::MaybeExitStartupOrDrain(QuicTime now) {
if (mode_ == STARTUP && is_at_full_bandwidth_) {
mode_ = DRAIN;
pacing_gain_ = kDrainGain;
congestion_window_gain_ = kHighGain;
}
if (mode_ == DRAIN &&
unacked_packets_->bytes_in_flight() <= GetTargetCongestionWindow(1)) {
EnterProbeBandwidthMode(now);
}
}
void BbrSender::MaybeEnterOrExitProbeRtt(QuicTime now,
bool is_round_start,
bool min_rtt_expired) {
if (min_rtt_expired && !exiting_quiescence_ && mode_ != PROBE_RTT) {
mode_ = PROBE_RTT;
pacing_gain_ = 1;
// Do not decide on the time to exit PROBE_RTT until the |bytes_in_flight|
// is at the target small value.
exit_probe_rtt_at_ = QuicTime::Zero();
}
if (mode_ == PROBE_RTT) {
sampler_.OnAppLimited();
if (exit_probe_rtt_at_ == QuicTime::Zero()) {
// If the window has reached the appropriate size, schedule exiting
// PROBE_RTT. The CWND during PROBE_RTT is kMinimumCongestionWindow, but
// we allow an extra packet since QUIC checks CWND before sending a
// packet.
if (unacked_packets_->bytes_in_flight() <
kMinimumCongestionWindow + kMaxPacketSize) {
exit_probe_rtt_at_ = now + kProbeRttTime;
probe_rtt_round_passed_ = false;
}
} else {
if (is_round_start) {
probe_rtt_round_passed_ = true;
}
if (now >= exit_probe_rtt_at_ && probe_rtt_round_passed_) {
min_rtt_timestamp_ = now;
if (!is_at_full_bandwidth_) {
EnterStartupMode();
} else {
EnterProbeBandwidthMode(now);
}
}
}
}
exiting_quiescence_ = false;
}
void BbrSender::UpdateRecoveryState(QuicPacketNumber last_acked_packet,
bool has_losses,
bool is_round_start) {
// Exit recovery when there are no losses for a round.
if (has_losses) {
end_recovery_at_ = last_sent_packet_;
}
switch (recovery_state_) {
case NOT_IN_RECOVERY:
// Enter conservation on the first loss.
if (has_losses) {
recovery_state_ = CONSERVATION;
// Since the conservation phase is meant to be lasting for a whole
// round, extend the current round as if it were started right now.
current_round_trip_end_ = last_sent_packet_;
}
break;
case CONSERVATION:
if (is_round_start) {
recovery_state_ = GROWTH;
}
case GROWTH:
// Exit recovery if appropriate.
if (!has_losses && last_acked_packet > end_recovery_at_) {
recovery_state_ = NOT_IN_RECOVERY;
}
break;
}
}
// TODO(ianswett): Move this logic into BandwidthSampler.
void BbrSender::UpdateAckSpacing(QuicTime ack_time,
QuicPacketNumber largest_newly_acked,
const CongestionVector& acked_packets) {
// Ignore acks of reordered packets.
if (largest_newly_acked < unacked_packets_->largest_observed()) {
return;
}
// Ignore acks of only one packet to filter out delayed acks.
if (acked_packets.size() == 1) {
return;
}
QuicTime largest_newly_acked_sent_time =
unacked_packets_->GetTransmissionInfo(largest_newly_acked).sent_time;
// Initialize on the first ack.
if (!largest_acked_time_.IsInitialized()) {
largest_acked_time_ = ack_time;
largest_acked_sent_time_ = largest_newly_acked_sent_time;
return;
}
QuicTime::Delta ack_delta = ack_time - largest_acked_time_;
QuicTime::Delta send_delta =
largest_newly_acked_sent_time - largest_acked_sent_time_;
largest_acked_time_ = ack_time;
largest_acked_sent_time_ = largest_newly_acked_sent_time;
if (ack_delta <= send_delta) {
return;
}
// Limit the ack spacing to SRTT to filter outliers.
QuicTime::Delta ack_spacing =
std::min(ack_delta - send_delta, rtt_stats_->smoothed_rtt());
max_ack_spacing_.Update(ack_spacing, round_trip_count_);
}
// TODO(ianswett): Move this logic into BandwidthSampler.
void BbrSender::UpdateAckAggregationBytes(QuicTime ack_time,
QuicByteCount newly_acked_bytes) {
// Compute how many bytes are expected to be delivered, assuming max bandwidth
// is correct.
QuicByteCount expected_bytes_acked =
max_bandwidth_.GetBest() * (ack_time - aggregation_epoch_start_time_);
// Reset the current aggregation epoch as soon as the ack arrival rate is less
// than or equal to the max bandwidth.
if (aggregation_epoch_bytes_ <= expected_bytes_acked) {
// Reset to start measuring a new aggregation epoch.
aggregation_epoch_bytes_ = newly_acked_bytes;
aggregation_epoch_start_time_ = ack_time;
return;
}
// Compute how many extra bytes were delivered vs max bandwidth.
// Include the bytes most recently acknowledged to account for stretch acks.
aggregation_epoch_bytes_ += newly_acked_bytes;
max_ack_height_.Update(aggregation_epoch_bytes_ - expected_bytes_acked,
round_trip_count_);
}
void BbrSender::CalculatePacingRate() {
if (BandwidthEstimate().IsZero()) {
return;
}
QuicBandwidth target_rate = pacing_gain_ * BandwidthEstimate();
if (is_at_full_bandwidth_) {
pacing_rate_ = target_rate;
return;
}
// Pace at the rate of initial_window / RTT as soon as RTT measurements are
// available.
if (pacing_rate_.IsZero() && !rtt_stats_->min_rtt().IsZero()) {
pacing_rate_ = QuicBandwidth::FromBytesAndTimeDelta(
initial_congestion_window_, rtt_stats_->min_rtt());
return;
}
// Do not decrease the pacing rate during the startup.
pacing_rate_ = std::max(pacing_rate_, target_rate);
}
void BbrSender::CalculateCongestionWindow(QuicByteCount bytes_acked) {
if (mode_ == PROBE_RTT) {
return;
}
QuicByteCount target_window =
GetTargetCongestionWindow(congestion_window_gain_);
if (rtt_variance_weight_ > 0.f && !BandwidthEstimate().IsZero()) {
target_window += rtt_variance_weight_ * rtt_stats_->mean_deviation() *
BandwidthEstimate();
} else if (FLAGS_quic_reloadable_flag_quic_bbr_ack_spacing2 &&
is_at_full_bandwidth_) {
QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_spacing2, 2, 2);
// Add CWND for inter-ack spacing once STARTUP has been exited.
target_window += max_ack_spacing_.GetBest() * BandwidthEstimate();
} else if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes &&
is_at_full_bandwidth_) {
QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes, 2,
2);
target_window += max_ack_height_.GetBest();
}
// Instead of immediately setting the target CWND as the new one, BBR grows
// the CWND towards |target_window| by only increasing it |bytes_acked| at a
// time.
if (is_at_full_bandwidth_) {
congestion_window_ =
std::min(target_window, congestion_window_ + bytes_acked);
} else if (congestion_window_ < target_window ||
sampler_.total_bytes_acked() < initial_congestion_window_) {
// If the connection is not yet out of startup phase, do not decrease the
// window.
congestion_window_ = congestion_window_ + bytes_acked;
}
// Enforce the limits on the congestion window.
congestion_window_ = std::max(congestion_window_, kMinimumCongestionWindow);
congestion_window_ = std::min(congestion_window_, max_congestion_window_);
}
void BbrSender::CalculateRecoveryWindow(QuicByteCount bytes_acked) {
switch (recovery_state_) {
case CONSERVATION:
recovery_window_ = unacked_packets_->bytes_in_flight() + bytes_acked;
break;
case GROWTH:
recovery_window_ = unacked_packets_->bytes_in_flight() + 2 * bytes_acked;
break;
default:
break;
}
recovery_window_ = std::max(kMinimumCongestionWindow, recovery_window_);
}
std::string BbrSender::GetDebugState() const {
std::ostringstream stream;
stream << ExportDebugState();
return stream.str();
}
void BbrSender::OnApplicationLimited(QuicByteCount bytes_in_flight) {
if (bytes_in_flight >= GetCongestionWindow()) {
return;
}
sampler_.OnAppLimited();
QUIC_DVLOG(2) << "Becoming application limited. Last sent packet: "
<< last_sent_packet_ << ", CWND: " << GetCongestionWindow();
}
BbrSender::DebugState BbrSender::ExportDebugState() const {
return DebugState(*this);
}
static std::string ModeToString(BbrSender::Mode mode) {
switch (mode) {
case BbrSender::STARTUP:
return "STARTUP";
case BbrSender::DRAIN:
return "DRAIN";
case BbrSender::PROBE_BW:
return "PROBE_BW";
case BbrSender::PROBE_RTT:
return "PROBE_RTT";
}
return "???";
}
std::ostream& operator<<(std::ostream& os, const BbrSender::Mode& mode) {
os << ModeToString(mode);
return os;
}
std::ostream& operator<<(std::ostream& os, const BbrSender::DebugState& state) {
os << "Mode: " << ModeToString(state.mode) << std::endl;
os << "Maximum bandwidth: " << state.max_bandwidth << std::endl;
os << "Round trip counter: " << state.round_trip_count << std::endl;
os << "Gain cycle index: " << static_cast<int>(state.gain_cycle_index)
<< std::endl;
os << "Congestion window: " << state.congestion_window << " bytes"
<< std::endl;
if (state.mode == BbrSender::STARTUP) {
os << "(startup) Bandwidth at last round: " << state.bandwidth_at_last_round
<< std::endl;
os << "(startup) Rounds without gain: "
<< state.rounds_without_bandwidth_gain << std::endl;
}
os << "Minimum RTT: " << state.min_rtt << std::endl;
os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue()
<< std::endl;
os << "Last sample is app-limited: "
<< (state.last_sample_is_app_limited ? "yes" : "no");
return os;
}
} // namespace net