pub struct RateController { /* private fields */ }Expand description
The AIMD controller: a usage signal and a received rate in, a target bitrate out.
§Additive versus multiplicative increase
Climbing multiplicatively is fast but overshoots, which on a path already known to be near its limit means congesting it again immediately. So the controller climbs multiplicatively only while it is far from the rate that last caused a backoff, and switches to additive — one packet per round trip — as it approaches. Upstream does the same; it is the difference between probing for capacity and hammering at a known ceiling.
Implementations§
Source§impl RateController
impl RateController
Sourcepub fn new(initial: f64, min: f64, max: f64) -> Self
pub fn new(initial: f64, min: f64, max: f64) -> Self
A controller starting at initial, clamped to min..=max.
One clamp, from configuration — see D3. Upstream clamps in two places with two different hard-coded ranges, and they disagree.
Sourcepub fn with_decrease_factor(self, decrease_factor: f64) -> Self
pub fn with_decrease_factor(self, decrease_factor: f64) -> Self
How hard to back off, as a fraction of the received rate.
Sourcepub fn state(&self) -> RateControlState
pub fn state(&self) -> RateControlState
What the controller is doing.
Sourcepub fn update(
&mut self,
now: Instant,
usage: Usage,
received: Option<f64>,
) -> f64
pub fn update( &mut self, now: Instant, usage: Usage, received: Option<f64>, ) -> f64
Fold in a usage signal and the rate the far end is receiving.
received is None when the window holds too little to say; the controller then holds
rather than guessing, because every action it could take needs a rate to compute from.
Trait Implementations§
Source§impl Clone for RateController
impl Clone for RateController
Source§fn clone(&self) -> RateController
fn clone(&self) -> RateController
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more