quic_cc_cubic (quic v1.3.1)

View Source

QUIC CUBIC congestion control implementation.

This module implements the CUBIC congestion control algorithm with: - RFC 9438 CUBIC window function - HyStart++ slow start enhancement (RFC 9406) - Fast convergence for rapid bandwidth discovery - TCP-friendly mode for fairness - Application-limited epoch handling - Pacing support

Phases

1. Slow Start with HyStart++: Exponential growth with RTT-based exit 2. Congestion Avoidance: CUBIC window function W(t) = C*(t-K)^3 + W_max 3. Recovery: Multiplicative decrease by beta=0.7 (30% reduction)

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.

Get the current max datagram size.

Get minimum recovery duration.

Create a new CUBIC congestion control state with options.

Handle a congestion event (packet loss detected).

Handle ECN-CE signal.

Record that a packet was sent.

Process acknowledged packets.

Process acknowledged packets with largest acked sent time.

Reset to minimum window on persistent congestion.

Check if pacing allows sending.

Calculate pacing delay.

Fused cwnd + pacing check for the hot send path.

Get the slow start threshold.

Update congestion control state when MTU changes.

Update pacing rate based on smoothed RTT.

Types

cc_state/0

-opaque cc_state()

Functions

available_cwnd(Cubic_state)

-spec available_cwnd(cc_state()) -> non_neg_integer().

Get the available congestion window.

bytes_in_flight(Cubic_state)

-spec bytes_in_flight(cc_state()) -> non_neg_integer().

Get bytes currently in flight.

can_send(Cubic_state, Size)

-spec can_send(cc_state(), non_neg_integer()) -> boolean().

Check if we can send more bytes.

can_send_control(Cubic_state, Size)

-spec can_send_control(cc_state(), non_neg_integer()) -> boolean().

Check if a control message can be sent.

cwnd(Cubic_state)

-spec cwnd(cc_state()) -> non_neg_integer().

Get the current congestion window.

detect_persistent_congestion(LostPackets, PTO, State)

-spec detect_persistent_congestion([{non_neg_integer(), non_neg_integer()}],
                                   non_neg_integer(),
                                   cc_state()) ->
                                      boolean().

Detect persistent congestion from lost packets.

ecn_ce_counter(Cubic_state)

-spec ecn_ce_counter(cc_state()) -> non_neg_integer().

Get the current ECN-CE counter.

get_pacing_tokens(Cubic_state, Size)

-spec get_pacing_tokens(cc_state(), non_neg_integer()) -> {non_neg_integer(), cc_state()}.

Get tokens for sending.

in_recovery(Cubic_state)

-spec in_recovery(cc_state()) -> boolean().

Check if in recovery phase.

in_slow_start(Cubic_state)

-spec in_slow_start(cc_state()) -> boolean().

Check if in slow start phase.

max_datagram_size(Cubic_state)

-spec max_datagram_size(cc_state()) -> pos_integer().

Get the current max datagram size.

min_recovery_duration(Cubic_state)

-spec min_recovery_duration(cc_state()) -> non_neg_integer().

Get minimum recovery duration.

new(Opts)

-spec new(quic_cc:cc_opts()) -> cc_state().

Create a new CUBIC congestion control state with options.

on_congestion_event(Cubic_state, SentTime)

-spec on_congestion_event(cc_state(), non_neg_integer()) -> cc_state().

Handle a congestion event (packet loss detected).

on_ecn_ce(Cubic_state, NewCECount)

-spec on_ecn_ce(cc_state(), non_neg_integer()) -> cc_state().

Handle ECN-CE signal.

on_packet_sent(Cubic_state, Size)

-spec on_packet_sent(cc_state(), non_neg_integer()) -> cc_state().

Record that a packet was sent.

on_packets_acked(State, AckedBytes)

-spec on_packets_acked(cc_state(), non_neg_integer()) -> cc_state().

Process acknowledged packets.

on_packets_acked(Cubic_state, AckedBytes, LargestAckedSentTime)

-spec on_packets_acked(cc_state(), non_neg_integer(), non_neg_integer()) -> cc_state().

Process acknowledged packets with largest acked sent time.

on_packets_lost(Cubic_state, LostBytes)

-spec on_packets_lost(cc_state(), non_neg_integer()) -> cc_state().

Process lost packets.

on_persistent_congestion(Cubic_state)

-spec on_persistent_congestion(cc_state()) -> cc_state().

Reset to minimum window on persistent congestion.

pacing_allows(Cubic_state, Size)

-spec pacing_allows(cc_state(), non_neg_integer()) -> boolean().

Check if pacing allows sending.

pacing_delay(Cubic_state, Size)

-spec pacing_delay(cc_state(), non_neg_integer()) -> non_neg_integer().

Calculate pacing delay.

send_check(Cubic_state, Size, Urgency)

-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.

ssthresh(Cubic_state)

-spec ssthresh(cc_state()) -> non_neg_integer() | infinity.

Get the slow start threshold.

update_mtu(Cubic_state, NewMTU)

-spec update_mtu(cc_state(), pos_integer()) -> cc_state().

Update congestion control state when MTU changes.

update_pacing_rate(Cubic_state, SmoothedRTT)

-spec update_pacing_rate(cc_state(), non_neg_integer()) -> cc_state().

Update pacing rate based on smoothed RTT.