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_bitrateis 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
impl Gcc
Sourcepub fn new(initial: f64, min: f64, max: f64) -> Self
pub fn new(initial: f64, min: f64, max: f64) -> Self
An estimator starting at initial, held within min..=max.
Sourcepub fn with_loss_at_queue_limit_as_overuse(self, enabled: bool) -> Self
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.
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 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.
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 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.
Sourcepub fn with_feedback_timeout(self, feedback_timeout: Duration) -> Self
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).
Sourcepub fn with_threshold_time_base(self, time_base: ThresholdTimeBase) -> Self
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.
Sourcepub fn threshold_time_base(&self) -> ThresholdTimeBase
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.
Sourcepub fn with_loss_estimate_capped_by_delay_estimate(self, capped: bool) -> Self
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.
Sourcepub fn delay_based_bitrate(&self) -> f64
pub fn delay_based_bitrate(&self) -> f64
The delay-based half’s current target, in bits per second.
Sourcepub fn loss_based_bitrate(&self) -> f64
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
impl BandwidthEstimator for Gcc
Source§fn on_congestion_marks(&mut self, now: Instant, marked: u64, packets: u64)
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)
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)
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])
fn on_reports(&mut self, now: Instant, reports: &[PacketReport])
Source§fn on_packet_sent(&mut self, now: Instant, size: usize)
fn on_packet_sent(&mut self, now: Instant, size: usize)
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)
fn on_round_trip_time(&mut self, _now: Instant, round_trip_time: Duration)
Source§fn min_bitrate(&self) -> Option<f64>
fn min_bitrate(&self) -> Option<f64>
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>)
fn set_external_bounds(&mut self, min: Option<f64>, max: Option<f64>)
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)
fn on_receiver_report(&mut self, now: Instant, fraction_lost: f64)
Source§fn on_probe_result(&mut self, now: Instant, bits_per_second: f64)
fn on_probe_result(&mut self, now: Instant, bits_per_second: f64)
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)
fn handle_timeout(&mut self, now: Instant)
Source§fn poll_timeout(&self) -> Option<Instant>
fn poll_timeout(&self) -> Option<Instant>
None if it does not. Read more