CongestionController

Enum CongestionController 

Source
pub enum CongestionController {
    Aimd {
        window: f64,
        min_window: f64,
        max_window: f64,
        additive_increase: f64,
        multiplicative_decrease: f64,
        ssthresh: f64,
    },
    Cubic {
        window: f64,
        min_window: f64,
        max_window: f64,
        w_max: f64,
        acks_since_loss: u64,
        c: f64,
        beta: f64,
        ssthresh: f64,
    },
    Fixed {
        window: f64,
    },
}
Expand description

Consumer-side congestion control algorithm.

Each variant carries its own internal state. The caller drives events (on_data, on_congestion_mark, on_timeout) and reads the current window via window().

§Variants

AlgorithmBest forBehaviour
AimdGeneral-purpose, matches NFD consumersLinear increase, multiplicative decrease
CubicHigh-bandwidth, long-RTT linksCubic function ramp-up after loss
FixedBenchmarks, known-capacity linksConstant window, no adaptation

Variants§

§

Aimd

Additive-Increase Multiplicative-Decrease.

Standard algorithm used by ndncatchunks. Window grows by additive_increase / window per ack (≈ +1 per RTT) and is multiplied by multiplicative_decrease on congestion/timeout.

Fields

§window: f64
§min_window: f64
§max_window: f64
§additive_increase: f64
§multiplicative_decrease: f64
§ssthresh: f64

Slow-start threshold. While window < ssthresh, window grows by 1.0 per ack (exponential); above it, grows additively.

§

Cubic

CUBIC (RFC 8312).

Concave/convex window growth based on time since last loss event. More aggressive ramp-up than AIMD on high-bandwidth links.

Fields

§window: f64
§min_window: f64
§max_window: f64
§w_max: f64

Window size at last loss event.

§acks_since_loss: u64

Ack count since last loss event (proxy for time).

§c: f64

CUBIC scaling constant (default: 0.4).

§beta: f64

Multiplicative decrease factor (default: 0.7).

§ssthresh: f64
§

Fixed

Fixed window — no adaptation.

Fields

§window: f64

Implementations§

Source§

impl CongestionController

Source

pub fn aimd() -> Self

AIMD with standard parameters (matches ndncatchunks).

Source

pub fn cubic() -> Self

CUBIC with standard parameters (RFC 8312).

Source

pub fn fixed(window: f64) -> Self

Fixed window (no adaptation).

Source

pub fn with_window(self, w: f64) -> Self

Set the initial and current window size.

For Cubic, this also updates w_max to match so the cubic formula’s “recovery target” reflects the user’s intent. Without this, a caller that does cubic().with_window(N).with_ssthresh(N) for large N would leave w_max at its tiny default value (2.0), and the first on_data() call would take the cubic branch (since window >= ssthresh) and collapse the window back toward w_max = 2. See the cubic_does_not_collapse_at_large_initial_window regression test.

Source

pub fn with_min_window(self, w: f64) -> Self

Set the minimum window (floor after decrease). Ignored by Fixed.

Source

pub fn with_max_window(self, w: f64) -> Self

Set the maximum window (ceiling). Ignored by Fixed.

Source

pub fn with_additive_increase(self, ai: f64) -> Self

Set AIMD additive increase per RTT (default: 1.0). Only affects AIMD.

Source

pub fn with_decrease_factor(self, md: f64) -> Self

Set AIMD/CUBIC multiplicative decrease factor (default: 0.5 for AIMD, 0.7 for CUBIC).

Source

pub fn with_cubic_c(self, c_val: f64) -> Self

Set CUBIC scaling constant C (default: 0.4). Only affects CUBIC.

Source

pub fn with_ssthresh(self, ss: f64) -> Self

Set the slow-start threshold.

By default ssthresh is f64::MAX (unbounded slow start). Setting this to the initial window size prevents the exponential ramp from overshooting the link capacity on the first flow.

Source

pub fn window(&self) -> f64

Current window size (number of Interests allowed in flight).

Callers should use window().floor() as usize for the actual limit.

Source

pub fn on_data(&mut self)

A Data packet was received successfully (no congestion mark).

Source

pub fn on_congestion_mark(&mut self)

A CongestionMark was received on a Data packet.

Reduces the window but does NOT trigger retransmission — the Data was delivered successfully, only the sending rate should decrease.

Source

pub fn on_timeout(&mut self)

An Interest timed out (no Data received within lifetime).

More aggressive reduction than congestion mark since timeout indicates actual packet loss, not just queue buildup.

Source

pub fn reset(&mut self)

Reset to initial state (e.g. on route change or new flow).

Trait Implementations§

Source§

impl Clone for CongestionController

Source§

fn clone(&self) -> CongestionController

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CongestionController

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CongestionController

Source§

fn default() -> Self

Default: AIMD with standard parameters.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.