pub struct CongestionControlInterceptor<E: BandwidthEstimator> { /* private fields */ }Expand description
Records every departing packet, resolves the remote’s feedback against it, and drives a
BandwidthEstimator.
§Where this belongs in the chain
Wire-most. It is the only position that sees every byte that leaves: nothing exits the chain except through the interceptors ahead of it in the walk, so a retransmission emitted by the NACK responder and a repair packet emitted by the FEC encoder both arrive here, already paced and already numbered. An estimator reading a history that omits them sees fewer bytes than are on the wire, infers headroom, and raises the target during loss — a positive feedback loop that is hard to spot, because the estimator’s own accounting stays internally consistent throughout.
It also has to be below the pacer, so packet.now is the instant the packet was released
rather than the instant the application enqueued it. A pacer can hold a packet for tens of
milliseconds; counting that as network delay is exactly the error that makes a delay-based
estimate collapse.
§How the estimate gets out
On the read leg, as Attribute::TargetBitrateChanged: attached to the feedback packet that
produced it, or, when the estimate moved on a timer with no packet to ride on, on an empty
RTCP packet, the chain’s attribute carrier. The pacer sits application-ward of this
interceptor and reads the attribute on its way past. An application pulls the same number
from CongestionControlHandle.
§Limits from outside the algorithm
The estimator’s target is held under the tightest of: the negotiated session bit rate
(CongestionControlHandle::set_session_bitrate_limit), the receiver’s REMB, the TMMBR
bounding set (RFC 5104; every TMMBR is answered with a TMMBN), and the circuit breaker’s
reduced rate.
Implementations§
Source§impl<E: BandwidthEstimator> CongestionControlInterceptor<E>
impl<E: BandwidthEstimator> CongestionControlInterceptor<E>
Sourcepub fn lost_feedback(&self) -> u64
pub fn lost_feedback(&self) -> u64
How many TWCC feedback packets the receiver sent that never arrived here, by the gaps in the feedback packet count.
Sourcepub fn outstanding(&self) -> usize
pub fn outstanding(&self) -> usize
How many sent packets are still awaiting a verdict.
Trait Implementations§
Source§impl<E: BandwidthEstimator> Interceptor for CongestionControlInterceptor<E>
impl<E: BandwidthEstimator> Interceptor for CongestionControlInterceptor<E>
Source§fn bind_remote_stream(&mut self, info: &StreamInfo)
fn bind_remote_stream(&mut self, info: &StreamInfo)
A remote stream that negotiated ccm tmmbr can be asked for a limit
(TmmbrControl); one that did not is never sent a TMMBR (RFC 5104 section 7.2).
Source§fn bind_local_stream(&mut self, info: &StreamInfo)
fn bind_local_stream(&mut self, info: &StreamInfo)
Source§fn unbind_local_stream(&mut self, info: &StreamInfo)
fn unbind_local_stream(&mut self, info: &StreamInfo)
Source§fn unbind_remote_stream(&mut self, info: &StreamInfo)
fn unbind_remote_stream(&mut self, info: &StreamInfo)
Source§fn with<O, F>(self, f: F) -> O
fn with<O, F>(self, f: F) -> O
f, for nested (#[next]-field)
interceptors written with the Interceptor derive. The result is an
ordinary interceptor and can be placed in a Registry slot. Read moreSource§fn move_local_stream_out(&mut self, info: &StreamInfo)
fn move_local_stream_out(&mut self, info: &StreamInfo)
info moves to another RTP session (its m= section moved to another
transport, as a bundling answer does): it leaves this one without ending, so nothing
says it left (no RTCP BYE, RFC 3550 section 6.6). Unbinds it by default.Source§impl<E: BandwidthEstimator> Protocol<TransportMessage<AttributedPacket>, TransportMessage<AttributedPacket>, ()> for CongestionControlInterceptor<E>
impl<E: BandwidthEstimator> Protocol<TransportMessage<AttributedPacket>, TransportMessage<AttributedPacket>, ()> for CongestionControlInterceptor<E>
Source§fn poll_timeout(&mut self) -> Option<Self::Time>
fn poll_timeout(&mut self) -> Option<Self::Time>
Whatever the estimator and the outside limits want, and None when they want nothing.
This interceptor has no timer of its own: pruning is bounded work that can ride any wake-up, and asking for one on its own account would wake the whole chain on an idle connection.