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 keeps the average and the deviation of the received rate measured each time it backed off, and climbs additively, about half a packet per response time, while the received rate is within three deviations of that average (“close to convergence”). When the received rate rises above the band the path has changed: the average is forgotten and the climb is multiplicative again, 8% per second.
§The bound
The estimate is verified by over-using the path, so it must not drift away from what is
actually sent: it is not increased past 1.5 times the received rate. Without the bound a
sender that has less to send than the estimate allows (a muted source, a static screen) lets
the estimate climb to the configured maximum, and overshoots by that much when it has
something to send again. An estimate that is above the bound because the sender now sends
less than it did is held, not lowered (ReceivedRateBound): only over-use lowers it.
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_received_rate_bound(
self,
received_rate_bound: ReceivedRateBound,
) -> Self
pub fn with_received_rate_bound( self, received_rate_bound: ReceivedRateBound, ) -> Self
What the bound by the received rate does to an estimate above it: see
ReceivedRateBound.
Sourcepub fn with_one_decrease_per_round_trip(self, enabled: bool) -> Self
pub fn with_one_decrease_per_round_trip(self, enabled: bool) -> Self
Whether over-use lowers the target at most once per round trip, or on every update while it lasts (the default).
draft-ietf-rmcat-gcc-02 section 5.5 stays in Decrease while over-use lasts and sets
A_hat = beta * R_hat on each update: false, the default. The estimate then follows
the received rate down as its measurement window empties of what arrived before the
path changed, which is what matters when a path loses most of its capacity at once
(tests/capacity_cap_video_rtc2rtc.rs: a 300 kbit/s cap under a sender at 1 Mbit/s
freezes the video 0.56 to 1.26 s and leaves the oldest picture 1.68 to 2.48 s old;
with one decrease per round trip 0.85 to 1.36 s and 2.33 to 2.61 s).
true is libwebrtc’s form (AimdRateControl::TimeToReduceFurther): a further cut
waits one round trip (held within 10 to 200 ms) unless the received rate has fallen
below half the target. Two flows sharing a bottleneck then keep a shorter queue
(rtci-interceptor/tests/rfc8836_multi_flow.rs: mean 2.8 ms and 95th percentile 10.8 ms
of queueing delay, against 18.5 ms and 93 ms with the draft’s form; the shares are
0.48 / 0.50 and 0.49 / 0.49).
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
The current state.
Sourcepub fn set_round_trip_time(&mut self, round_trip_time: Duration)
pub fn set_round_trip_time(&mut self, round_trip_time: Duration)
The round trip time the additive increase is scaled by (response_time = 100 ms + rtt).
Sourcepub fn set_bounds(&mut self, min: f64, max: f64)
pub fn set_bounds(&mut self, min: f64, max: f64)
Change the range the target is held in, and bring the target into it.
Sourcepub fn set_target(&mut self, target: f64)
pub fn set_target(&mut self, target: f64)
Replace the target, as when the path changed and the old estimate describes nothing.
Sourcepub fn set_measured_rate(&mut self, measured: Option<f64>)
pub fn set_measured_rate(&mut self, measured: Option<f64>)
A rate the path was measured to deliver apart from the running received rate (a probe
cluster), or None to forget it. While set, the estimate may be as high as this
measurement even where one and a half times the received rate (the bound of section
5.5) is less: the received rate lags a sender that has only just been told it may
send more, and would pull the estimate straight back to where it was. Over-use lowers
it to where the estimate backs off to.
Sourcepub fn reset_convergence(&mut self)
pub fn reset_convergence(&mut self)
Forget where the path’s capacity was thought to be: the next climb is multiplicative.
Sourcepub fn convergence_band(&self) -> Option<(f64, f64)>
pub fn convergence_band(&self) -> Option<(f64, f64)>
The band of received rates within which the controller considers itself close to convergence, in bits per second, once a decrease has measured one.
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
Advance the state with a usage signal and move the target accordingly.
received is what the remote is actually getting (R_hat), from
RateCalculator. It is None until enough has
arrived to measure, and while it is unknown a decrease holds and an increase is unbounded
by it — there is no meaningful figure to act on.