nquic_cc behaviour (nquic v1.0.0)
View SourceCongestion control behaviour and dispatch per RFC 9002 Section 7.
Defines the nquic_cc behaviour that congestion control algorithms must implement.
Provides a dispatch layer that wraps the algorithm module and its opaque state.
Currently ships with nquic_cc_newreno.
Summary
Functions
Get the current congestion window size in bytes.
Get the current maximum datagram size.
Get the current slow start threshold.
Create a new congestion control state for the given algorithm.
Create a new congestion control state with options.
CUBIC understands slow_start => standard | hystart_plus_plus
(RFC 9406). Other algorithms ignore unknown keys.
Notify the congestion controller of a loss event.
Reset the congestion controller after an idle period (RFC 9002 Section 7.8). The window collapses to the initial window so the sender does not burst beyond the path's available capacity after a long pause.
Notify the congestion controller that a packet was acknowledged.
Notify the congestion controller that a packet was sent.
Notify the congestion controller that persistent congestion has been
detected (RFC 9002 Section 7.6). The congestion window must collapse to
the minimum window (2 * max_datagram_size).
Notify the congestion controller that the most recent congestion-event reduction was triggered by a spurious loss (RFC 9002 Appendix A.10). Implementations should restore the pre-reduction snapshot of the window state. If no snapshot is available (no rollback pending), this is a no-op.
Set the maximum datagram size for congestion window calculations.
Types
Callbacks
-callback get_cwnd(dynamic()) -> non_neg_integer().
-callback get_ssthresh(dynamic()) -> non_neg_integer() | undefined.
-callback init() -> dynamic().
-callback on_congestion_event(dynamic(), non_neg_integer(), non_neg_integer(), non_neg_integer()) -> dynamic().
-callback on_packet_acked(dynamic(), #sent_packet{packet_number :: nquic_packet_number:t(), time_sent :: non_neg_integer(), size :: non_neg_integer(), ack_eliciting :: boolean(), in_flight :: boolean(), frames :: [nquic_frame:t()]}, non_neg_integer(), map()) -> dynamic().
-callback on_packet_sent(dynamic(), non_neg_integer(), non_neg_integer()) -> dynamic().
Functions
-spec get_cwnd(cc_state()) -> non_neg_integer().
Get the current congestion window size in bytes.
-spec get_max_datagram_size({module(), dynamic()}) -> pos_integer().
Get the current maximum datagram size.
-spec get_ssthresh(cc_state()) -> non_neg_integer() | undefined.
Get the current slow start threshold.
Create a new congestion control state for the given algorithm.
Create a new congestion control state with options.
CUBIC understands slow_start => standard | hystart_plus_plus
(RFC 9406). Other algorithms ignore unknown keys.
-spec on_congestion_event(cc_state(), non_neg_integer(), non_neg_integer(), non_neg_integer()) -> cc_state().
Notify the congestion controller of a loss event.
Reset the congestion controller after an idle period (RFC 9002 Section 7.8). The window collapses to the initial window so the sender does not burst beyond the path's available capacity after a long pause.
-spec on_packet_acked(cc_state(), #sent_packet{packet_number :: nquic_packet_number:t(), time_sent :: non_neg_integer(), size :: non_neg_integer(), ack_eliciting :: boolean(), in_flight :: boolean(), frames :: [nquic_frame:t()]}, non_neg_integer(), map()) -> cc_state().
Notify the congestion controller that a packet was acknowledged.
-spec on_packet_sent(cc_state(), non_neg_integer(), non_neg_integer()) -> cc_state().
Notify the congestion controller that a packet was sent.
Notify the congestion controller that persistent congestion has been
detected (RFC 9002 Section 7.6). The congestion window must collapse to
the minimum window (2 * max_datagram_size).
Notify the congestion controller that the most recent congestion-event reduction was triggered by a spurious loss (RFC 9002 Appendix A.10). Implementations should restore the pre-reduction snapshot of the window state. If no snapshot is available (no rollback pending), this is a no-op.
-spec set_max_datagram_size({module(), dynamic()}, pos_integer()) -> {module(), dynamic()}.
Set the maximum datagram size for congestion window calculations.