quic_cc_bbr (quic v1.3.1)
View SourceQUIC BBRv3 congestion control implementation.
BBRv3 (Bottleneck Bandwidth and Round-trip propagation time) is a model-based congestion control algorithm that aims to maximize throughput while minimizing latency and packet loss.
HyStart++ (RFC 9406) provides additional RTT-based startup exit detection alongside BBR's bandwidth plateau detection for earlier, safer exits.
States
1. Startup: Exponential bandwidth probing (2.77x pacing gain) with HyStart++ RTT monitoring 2. Drain: Reduce queue built during startup (0.35x pacing gain) 3. ProbeBW: Steady-state with cycling phases (DOWN/CRUISE/REFILL/UP) 4. ProbeRTT: Periodic RTT measurement with reduced cwnd
Key Concepts
- BDP (Bandwidth-Delay Product): max_bw * min_rtt - Pacing Rate: pacing_gain * max_bw * 0.99 - CWND: cwnd_gain * BDP (minimum 4 packets) - Delivery Rate: Measured bandwidth from ACK feedback
Summary
Functions
Get the available congestion window.
Get bytes currently in flight.
Check if we can send more bytes.
Check if a control message can be sent.
Get the current congestion window.
Detect persistent congestion from lost packets.
Get the current ECN-CE counter.
Get tokens for sending.
Check if in recovery phase.
Check if in slow start phase (Startup state for BBR).
Get the current max datagram size.
Get minimum recovery duration setting (milliseconds, matching the public option contract; stored internally as microseconds).
Create a new BBRv3 congestion control state.
Handle a congestion event (packet loss detected).
Handle ECN-CE signal.
Record that a packet was sent.
Process acknowledged packets (2-arg version).
Process acknowledged packets with timing info. AckTime is the sent-time of the largest acked packet, in ms (supplied by quic_connection). We convert to µs on entry and work in microsecond precision throughout — loopback RTTs round to 0 ms otherwise, which collapses BDP.
Process lost packets.
Handle persistent congestion.
Check if pacing allows sending Size bytes.
Calculate pacing delay.
Fused cwnd + pacing check for the hot send path.
Get the slow start threshold. BBR doesn't use ssthresh; returns infinity.
Update congestion control state when MTU changes.
Update pacing rate based on smoothed RTT. Note: BBR primarily uses its own pacing_rate calculation, but this callback allows external RTT info integration.
Types
Functions
-spec available_cwnd(cc_state()) -> non_neg_integer().
Get the available congestion window.
-spec bytes_in_flight(cc_state()) -> non_neg_integer().
Get bytes currently in flight.
-spec can_send(cc_state(), non_neg_integer()) -> boolean().
Check if we can send more bytes.
-spec can_send_control(cc_state(), non_neg_integer()) -> boolean().
Check if a control message can be sent.
-spec cwnd(cc_state()) -> non_neg_integer().
Get the current congestion window.
-spec detect_persistent_congestion([{non_neg_integer(), non_neg_integer()}], non_neg_integer(), cc_state()) -> boolean().
Detect persistent congestion from lost packets.
-spec ecn_ce_counter(cc_state()) -> non_neg_integer().
Get the current ECN-CE counter.
-spec get_pacing_tokens(cc_state(), non_neg_integer()) -> {non_neg_integer(), cc_state()}.
Get tokens for sending.
Check if in recovery phase.
Check if in slow start phase (Startup state for BBR).
-spec max_datagram_size(cc_state()) -> pos_integer().
Get the current max datagram size.
-spec min_recovery_duration(cc_state()) -> non_neg_integer().
Get minimum recovery duration setting (milliseconds, matching the public option contract; stored internally as microseconds).
-spec new(quic_cc:cc_opts()) -> cc_state().
Create a new BBRv3 congestion control state.
-spec on_congestion_event(cc_state(), non_neg_integer()) -> cc_state().
Handle a congestion event (packet loss detected).
-spec on_ecn_ce(cc_state(), non_neg_integer()) -> cc_state().
Handle ECN-CE signal.
-spec on_packet_sent(cc_state(), non_neg_integer()) -> cc_state().
Record that a packet was sent.
-spec on_packets_acked(cc_state(), non_neg_integer()) -> cc_state().
Process acknowledged packets (2-arg version).
-spec on_packets_acked(cc_state(), non_neg_integer(), non_neg_integer()) -> cc_state().
Process acknowledged packets with timing info. AckTime is the sent-time of the largest acked packet, in ms (supplied by quic_connection). We convert to µs on entry and work in microsecond precision throughout — loopback RTTs round to 0 ms otherwise, which collapses BDP.
-spec on_packets_lost(cc_state(), non_neg_integer()) -> cc_state().
Process lost packets.
Handle persistent congestion.
-spec pacing_allows(cc_state(), non_neg_integer()) -> boolean().
Check if pacing allows sending Size bytes.
-spec pacing_delay(cc_state(), non_neg_integer()) -> non_neg_integer().
Calculate pacing delay.
-spec send_check(cc_state(), non_neg_integer(), non_neg_integer()) -> {ok, cc_state()} | {blocked_cwnd, non_neg_integer()} | {blocked_pacing, non_neg_integer()}.
Fused cwnd + pacing check for the hot send path.
-spec ssthresh(cc_state()) -> non_neg_integer() | infinity.
Get the slow start threshold. BBR doesn't use ssthresh; returns infinity.
-spec update_mtu(cc_state(), pos_integer()) -> cc_state().
Update congestion control state when MTU changes.
-spec update_pacing_rate(cc_state(), non_neg_integer()) -> cc_state().
Update pacing rate based on smoothed RTT. Note: BBR primarily uses its own pacing_rate calculation, but this callback allows external RTT info integration.