Skip to main content

Gcc

Struct Gcc 

Source
pub struct Gcc { /* private fields */ }
Expand description

Google Congestion Control.

§The two halves

reports ─┬─▶ SlopeEstimator ─▶ OveruseDetector ─▶ RateController ─┐
         │   group, filter      usage + adaptive   AIMD           ├─▶ min ─▶ target
         │                      threshold                         │
         ├─▶ RateCalculator ────────────────────────────────────▶─┘
         │   what is actually arriving
         └─▶ LossController ────────────────────────────────────▶─┘

The two are combined by min: whichever signal is more pessimistic wins. A path can be congested in either way independently — a deep buffer queues without losing, a shallow or lossy one loses without queueing — so neither half alone is sufficient and taking the lower of the two is the only combination that responds to both.

§Deliberate divergences from upstream

  • D3 — one clamp. Applied once, here, from configuration. Upstream clamps inside the loss controller to a hard-coded 100 kb/s–100 Mb/s and again in the rate controller to the configured range, and the two disagree.
  • D4 — loss may move the target alone. See LossController.
  • No hidden headroom. target_bitrate is what the pacer is asked for. Upstream’s pacer silently multiplies by 1.5, so its reported target and its wire rate differ by half again.
  • No clock. Every instant is a parameter, which is what makes a bitrate trajectory reproducible.

Implementations§

Source§

impl Gcc

Source

pub fn new(initial: f64, min: f64, max: f64) -> Self

An estimator starting at initial, held within min..=max.

Source

pub fn with_loss_at_queue_limit_as_overuse(self, enabled: bool) -> Self

Whether a packet lost out of a queue at its limit counts as over-use for the delay-based controller (the default), or only for the loss-based one as draft-ietf-rmcat-gcc-02 has it.

The draft’s over-use signal is the delay gradient: a queue that is growing. A tail-drop queue that has filled to its limit no longer grows, whatever is sent into it: the gradient is zero, the detector reads normal and the delay-based estimate keeps climbing, while the loss-based controller holds anywhere between 2% and 10% loss (section 6). A flow in that state never yields. Measured on a shared FIFO bottleneck (rtci-interceptor/tests/rfc8836_multi_flow.rs): a second flow joining an established one fell to the floor, and against a Reno-like transfer Gcc took 97% of the path, both against RFC 8836 section 2 (requirements 2a, a MUST, and 3). With the default, a feedback batch that lost a packet while every packet of it that arrived waited near the highest queueing delay seen of late (QueueLimitDetector) is over-use: the estimate backs off as from a growing queue, and the queue drains. Loss with little or no queue (a radio link, a policer) is left to the loss-based controller, as before. false is the draft as written.

Source

pub fn with_one_decrease_per_round_trip(self, enabled: bool) -> Self

Whether over-use lowers the estimate at most once per round trip (libwebrtc’s form) or on every update while it lasts, as draft-ietf-rmcat-gcc-02 section 5.5 has it (the default). See RateController::with_one_decrease_per_round_trip.

Source

pub fn with_received_rate_bound( self, received_rate_bound: ReceivedRateBound, ) -> Self

What the bound of the estimate by the received rate (draft-ietf-rmcat-gcc-02 section 5.5, A_hat(i) < 1.5 * R_hat(i)) does to an estimate above it: nothing but stop its increase (ReceivedRateBound::LimitsIncrease, the default), or bring it down to the bound (ReceivedRateBound::Clamps). See ReceivedRateBound.

With the default an application that sends less than the estimate (audio alone, a camera turned off, the first moments of a call) keeps the estimate it had: it is lowered by over-use, by loss, and by feedback that stops while packets it covers are sent, and by nothing else.

Source

pub fn with_feedback_timeout(self, feedback_timeout: Duration) -> Self

How long feedback may be missing, while packets are being sent, before the target is halved (and halved again each time the same period passes).

Source

pub fn with_threshold_time_base(self, time_base: ThresholdTimeBase) -> Self

The time step of the adaptive threshold (draft-ietf-rmcat-gcc-02 section 5.4): ThresholdTimeBase::Departure (the default), the draft’s ThresholdTimeBase::Arrival or libwebrtc’s ThresholdTimeBase::ArrivalCapped.

Source

pub fn threshold_time_base(&self) -> ThresholdTimeBase

See ThresholdTimeBase: the time step of the adaptive threshold (draft-ietf-rmcat-gcc-02 section 5.4), the departure gaps by default.

Source

pub fn with_loss_estimate_capped_by_delay_estimate(self, capped: bool) -> Self

Whether the loss-based estimate As_hat is held at or below the delay-based estimate A_hat after every update (the default), or left free with only the minimum of the two taken as the sending rate.

draft-ietf-rmcat-gcc-02 section 6 has the loss-based controller work from the available bandwidth estimate of the delay-based one. Left free, As_hat grows 5% per interval whenever loss is under 2%, whatever the path carries: after five quiet seconds it is several times the rate being sent, and As_hat(i) = As_hat(i-1)(1 - 0.5p) then has to cut it back through all of that before the sending rate moves at all. Capped, a loss cut is taken from the rate actually being sent, and the climb back starts from there.

Source

pub fn delay_based_bitrate(&self) -> f64

The delay-based half’s current target, in bits per second.

Source

pub fn loss_based_bitrate(&self) -> f64

The loss-based half’s current target, in bits per second.

Trait Implementations§

Source§

impl BandwidthEstimator for Gcc

Source§

fn on_congestion_marks(&mut self, now: Instant, marked: u64, packets: u64)

RFC 6679 section 7.3.3: CE marks counted by the receiver’s ECN reports go to the loss-based controller as losses would; the target can only fall by them.

Source§

fn on_unreported_packet_sent(&mut self, now: Instant, _size: usize)

A packet that no per-packet feedback will report: the flow is not paused, and its feedback is not awaited.

Source§

fn on_path_change(&mut self, _now: Instant)

A new path (another candidate pair selected) starts the estimate over from the starting estimate. The estimate describes the path it was measured on (RFC 8836 section 2, requirement 1d: the flow reacts to a change of the path; draft-ietf-rmcat-gcc-02 says nothing of it). Kept, it is right for a change between like paths and wrong in either direction otherwise: too high for a slower network, and, after an outage that the missing feedback halved it through, far too low for the network the connection came back on. libwebrtc starts over as well (call/rtp_transport_controller_send.cc:356-357, OnNetworkRouteChanged: “If it is, restart BWE.”, restart_bwe = IsRelevantRouteChange(old_route, network_route), sent to the controller at line 393 as msg.restart_bwe).

Source§

fn on_reports(&mut self, now: Instant, reports: &[PacketReport])

Packets whose fate the remote has now reported, in send order. Read more
Source§

fn on_packet_sent(&mut self, now: Instant, size: usize)

A packet left for the network. With on_reports this is what lets an estimator tell “nothing was sent” from “something was sent and nothing came back”.
Source§

fn on_round_trip_time(&mut self, _now: Instant, round_trip_time: Duration)

A round trip time measured from feedback: the instant a packet left to the instant the feedback naming it was read, less nothing, so it includes the receiver’s reporting delay.
Source§

fn min_bitrate(&self) -> Option<f64>

The floor the target never goes under, in bits per second, when the estimator has one. It rides with the target as MinimumTarget, so the NACK responder knows where the original media cannot be lowered for retransmissions (RFC 4588 section 7).
Source§

fn set_external_bounds(&mut self, min: Option<f64>, max: Option<f64>)

Limits from outside the algorithm, in bits per second: what was negotiated (b=AS, b=TIAS), what the receiver asked for (TMMBR, REMB), what the circuit breaker allows. The interceptor combines them and hands over the tightest; None lifts the limit. An estimator that honours them keeps its target at or below max whatever it measures.
Source§

fn on_receiver_report(&mut self, now: Instant, fraction_lost: f64)

The fraction lost a receiver report gave for a stream this endpoint sends, handed over only while the receiver sends no per-packet feedback (no TWCC, no RFC 8888): the loss-based half of an estimator can still run on it (draft-ietf-rmcat-gcc-02 section 7).
Source§

fn on_probe_result(&mut self, now: Instant, bits_per_second: f64)

A probe cluster showed the path carries bits_per_second (probe_estimate). Called only when bandwidth probing is on (CongestionControlBuilder::with_bandwidth_probing). An estimator that ignores it loses nothing but the faster start.
Source§

fn handle_timeout(&mut self, now: Instant)

Periodic work, for an estimator that has any. Most do not.
Source§

fn poll_timeout(&self) -> Option<Instant>

When this estimator next wants waking, or None if it does not. Read more
Source§

fn target_bitrate(&self) -> f64

The current estimate, in bits per second. Read more
Source§

fn stats(&self) -> EstimatorStats

Whatever the algorithm wants to expose. Never load-bearing.
Source§

impl Default for Gcc

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Gcc

§

impl Freeze for Gcc

§

impl Move for Gcc

§

impl RefUnwindSafe for Gcc

§

impl Send for Gcc

§

impl Sync for Gcc

§

impl Unpin for Gcc

§

impl UnsafeUnpin for Gcc

§

impl UnwindSafe for Gcc

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