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
| Algorithm | Best for | Behaviour |
|---|---|---|
Aimd | General-purpose, matches NFD consumers | Linear increase, multiplicative decrease |
Cubic | High-bandwidth, long-RTT links | Cubic function ramp-up after loss |
Fixed | Benchmarks, known-capacity links | Constant 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
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
Fixed
Fixed window — no adaptation.
Implementations§
Source§impl CongestionController
impl CongestionController
Sourcepub fn with_window(self, w: f64) -> Self
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.
Sourcepub fn with_min_window(self, w: f64) -> Self
pub fn with_min_window(self, w: f64) -> Self
Set the minimum window (floor after decrease). Ignored by Fixed.
Sourcepub fn with_max_window(self, w: f64) -> Self
pub fn with_max_window(self, w: f64) -> Self
Set the maximum window (ceiling). Ignored by Fixed.
Sourcepub fn with_additive_increase(self, ai: f64) -> Self
pub fn with_additive_increase(self, ai: f64) -> Self
Set AIMD additive increase per RTT (default: 1.0). Only affects AIMD.
Sourcepub fn with_decrease_factor(self, md: f64) -> Self
pub fn with_decrease_factor(self, md: f64) -> Self
Set AIMD/CUBIC multiplicative decrease factor (default: 0.5 for AIMD, 0.7 for CUBIC).
Sourcepub fn with_cubic_c(self, c_val: f64) -> Self
pub fn with_cubic_c(self, c_val: f64) -> Self
Set CUBIC scaling constant C (default: 0.4). Only affects CUBIC.
Sourcepub fn with_ssthresh(self, ss: f64) -> Self
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.
Sourcepub fn window(&self) -> f64
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.
Sourcepub fn on_congestion_mark(&mut self)
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.
Sourcepub fn on_timeout(&mut self)
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.
Trait Implementations§
Source§impl Clone for CongestionController
impl Clone for CongestionController
Source§fn clone(&self) -> CongestionController
fn clone(&self) -> CongestionController
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more