Skip to main content

RateController

Struct RateController 

Source
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

Source

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.

Source

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.

Source

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).

Source

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

How hard to back off, as a fraction of the received rate.

Source

pub fn target(&self) -> f64

The current target, in bits per second.

Source

pub fn state(&self) -> RateControlState

The current state.

Source

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).

Source

pub fn set_bounds(&mut self, min: f64, max: f64)

Change the range the target is held in, and bring the target into it.

Source

pub fn set_target(&mut self, target: f64)

Replace the target, as when the path changed and the old estimate describes nothing.

Source

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.

Source

pub fn reset_convergence(&mut self)

Forget where the path’s capacity was thought to be: the next climb is multiplicative.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for RateController

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RateController

Source§

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

Formats the value using the given formatter. Read more

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.