quic_cc_bbr (quic v3.1.2)
View SourceBBRv3 congestion control, following draft-ietf-ccwg-bbr-07.
BBR builds a model of the path from delivery rate and RTT samples and paces at the estimated bandwidth, bounding data in flight to a multiple of the estimated bandwidth-delay product.
States (Section 5.1)
- Startup: pacing gain 2.77, cwnd gain 2; exits on a bandwidth plateau or on excessive loss. - Drain: pacing gain 0.5 until in flight drops to the BDP, or after 3 rounds. - ProbeBW: DOWN (0.90), CRUISE (1.0), REFILL (1.0), UP (1.25, cwnd gain 2.25). - ProbeRTT: cwnd gain 0.5 for 200 ms and one round when min_rtt has not been refreshed for 10 seconds.
Units
Volumes are bytes, times are microseconds of erlang:monotonic_time, rates are bytes per second.
Per-packet state
The quic_cc callbacks report bytes, not packets, so the delivery rate sampler (Section 4.1) keeps the per-packet snapshots in send order and matches acknowledged, lost and discarded bytes against the oldest outstanding ones. QUIC acknowledges and declares packets lost mostly in send order, so a reordered acknowledgment only shifts a sample to a neighbouring packet's snapshot.
The *_at functions take the current time and are what the behaviour callbacks call with the clock; info/1 returns the model.
Summary
Functions
The ACK frequency to ask of the peer in the current phase: Ack-Eliciting Threshold, Requested Max Ack Delay (microseconds) and Reordering Threshold.
Get the available congestion window.
Get bytes currently in flight.
Check if we can send more bytes.
Get the current congestion window.
Get tokens for sending.
Whether the last packet of a flight should carry IMMEDIATE_ACK: in ProbeRTT, for a timely min_rtt sample.
Check if in recovery phase.
Startup plays the role of slow start.
The model and control parameters, for logging and tests.
The window this controller was configured with.
Get the current max datagram size.
Minimum recovery duration setting, in milliseconds.
Create a new BBRv3 congestion control state.
Create a new state at time Now (microseconds).
The peer was asked for this ACK frequency.
The sender has no data queued: mark the connection application-limited if cwnd has room (Section 4.1.2.4).
A congestion event, a loss or an ECN-CE increase (RFC 9002 Section 7.1), enters recovery unless the packet was sent before the current recovery period started (RFC 9002 Section 7.3.2).
Congestion event for a packet sent at SentTimeMs, at Now.
Record that a packet was sent.
Record that a packet was sent at time Now (microseconds).
Process acknowledged packets.
Process acknowledged packets. The sent time of the largest acknowledged packet is not needed: the sampler keeps its own.
Process AckedBytes newly acknowledged at time Now.
Drop bytes for a discarded packet number space. Not a congestion event: no window or recovery change.
Process lost packets.
Process LostBytes declared lost at time Now.
Persistent congestion is QUIC's retransmission timeout. cwnd drops to the minimum window (RFC 9002 Section 7.6.2 and Appendix B.8). As on an RTO, BBR first saves cwnd and its model (draft-ietf-ccwg-bbr-07 Sections 5.5.11.1 and 5.6.4.4) and restores cwnd when the recovery this starts ends.
Persistent congestion declared at time Now.
Undo a loss recovery episode found to be spurious (Section 5.5.11.2).
Check if pacing allows sending Size bytes.
Pacing delay in milliseconds before Size bytes may be sent.
Start over after a Retry, keeping every configured value.
Fused cwnd + pacing check for the hot send path.
BBR has no slow start threshold.
Update congestion control state when MTU changes.
BBR paces from its own model; the smoothed RTT is not used.
Types
Functions
-spec ack_frequency(cc_state(), non_neg_integer()) -> quic_cc:ack_frequency() | none.
The ACK frequency to ask of the peer in the current phase: Ack-Eliciting Threshold, Requested Max Ack Delay (microseconds) and Reordering Threshold.
-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 cwnd(cc_state()) -> non_neg_integer().
Get the current congestion window.
-spec get_pacing_tokens(cc_state(), non_neg_integer()) -> {non_neg_integer(), cc_state()}.
Get tokens for sending.
Whether the last packet of a flight should carry IMMEDIATE_ACK: in ProbeRTT, for a timely min_rtt sample.
Check if in recovery phase.
Startup plays the role of slow start.
The model and control parameters, for logging and tests.
-spec initial_window(cc_state()) -> non_neg_integer().
The window this controller was configured with.
-spec max_datagram_size(cc_state()) -> pos_integer().
Get the current max datagram size.
-spec min_recovery_duration(cc_state()) -> non_neg_integer().
Minimum recovery duration setting, in milliseconds.
-spec new(quic_cc:cc_opts()) -> cc_state().
Create a new BBRv3 congestion control state.
-spec new_at(quic_cc:cc_opts(), integer()) -> cc_state().
Create a new state at time Now (microseconds).
-spec on_ack_frequency(cc_state(), quic_cc:ack_frequency()) -> cc_state().
The peer was asked for this ACK frequency.
The sender has no data queued: mark the connection application-limited if cwnd has room (Section 4.1.2.4).
-spec on_congestion_event(cc_state(), non_neg_integer()) -> cc_state().
A congestion event, a loss or an ECN-CE increase (RFC 9002 Section 7.1), enters recovery unless the packet was sent before the current recovery period started (RFC 9002 Section 7.3.2).
-spec on_congestion_event_at(cc_state(), non_neg_integer(), integer()) -> cc_state().
Congestion event for a packet sent at SentTimeMs, at Now.
-spec on_packet_sent(cc_state(), non_neg_integer()) -> cc_state().
Record that a packet was sent.
-spec on_packet_sent_at(cc_state(), non_neg_integer(), integer()) -> cc_state().
Record that a packet was sent at time Now (microseconds).
-spec on_packets_acked(cc_state(), non_neg_integer()) -> cc_state().
Process acknowledged packets.
-spec on_packets_acked(cc_state(), non_neg_integer(), non_neg_integer()) -> cc_state().
Process acknowledged packets. The sent time of the largest acknowledged packet is not needed: the sampler keeps its own.
-spec on_packets_acked_at(cc_state(), non_neg_integer(), integer()) -> cc_state().
Process AckedBytes newly acknowledged at time Now.
-spec on_packets_discarded(cc_state(), non_neg_integer()) -> cc_state().
Drop bytes for a discarded packet number space. Not a congestion event: no window or recovery change.
-spec on_packets_lost(cc_state(), non_neg_integer()) -> cc_state().
Process lost packets.
-spec on_packets_lost_at(cc_state(), non_neg_integer(), integer()) -> cc_state().
Process LostBytes declared lost at time Now.
Persistent congestion is QUIC's retransmission timeout. cwnd drops to the minimum window (RFC 9002 Section 7.6.2 and Appendix B.8). As on an RTO, BBR first saves cwnd and its model (draft-ietf-ccwg-bbr-07 Sections 5.5.11.1 and 5.6.4.4) and restores cwnd when the recovery this starts ends.
Persistent congestion declared at time Now.
Undo a loss recovery episode found to be spurious (Section 5.5.11.2).
-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().
Pacing delay in milliseconds before Size bytes may be sent.
Start over after a Retry, keeping every configured value.
-spec send_check(cc_state(), 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.
BBR has no slow start threshold.
-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().
BBR paces from its own model; the smoothed RTT is not used.