Skip to main content

History

Struct History 

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

Records outgoing packets and matches incoming feedback against them.

The two feedback formats identify a packet differently — TWCC by its own transport-wide sequence number, RFC 8888 by the stream’s SSRC and RTP sequence number — so both indexes are kept, pointing at one record.

Implementations§

Source§

impl History

Source

pub fn new() -> Self

An empty history.

Source

pub fn len(&self) -> usize

How many packets are being tracked.

Source

pub fn is_empty(&self) -> bool

Whether nothing is being tracked.

Source

pub fn add_outgoing( &mut self, ssrc: u32, rtp_sequence_number: u16, is_twcc: bool, twcc_sequence_number: u16, size: usize, departure: Instant, ) -> u64

Record a packet as it leaves.

departure must be the instant the packet was released to the network, not the instant the application handed it over. A pacer can hold a packet for tens of milliseconds, and counting that as network delay is exactly the error that makes a bandwidth estimate collapse (chain contract rule 3).

Source

pub fn on_twcc_feedback( &mut self, received_at: Instant, acknowledgement: Acknowledgement, ) -> Option<Duration>

Apply TWCC feedback, returning the round trip time it implies.

None when the feedback names a packet this endpoint has no record of — which happens routinely at startup and after the history has been pruned, and is not an error.

Source

pub fn on_ccfb_feedback( &mut self, received_at: Instant, ssrc: u32, acknowledgement: Acknowledgement, ) -> Option<Duration>

Apply RFC 8888 feedback for one stream, returning the round trip time it implies.

Source

pub fn on_twcc_feedback_count(&mut self, feedback_packet_count: u8) -> u8

Note the feedback packet count of a TWCC feedback just read, and return how many feedback packets the receiver sent between the previous one and this one that never arrived.

The count is the only thing that tells a lost feedback packet from a quiet receiver (draft-holmer-rmcat-transport-wide-cc-extensions-01 section 3.1). The packets a lost feedback would have described get no verdict at all, see take_reports; this is the measure of how often that happened.

Source

pub fn lost_feedback(&self) -> u64

How many TWCC feedback packets were sent by the receiver and never read here.

Source

pub fn unreported(&self) -> u64

How many sent packets were released without any feedback describing them.

Source

pub fn take_reports(&mut self) -> Vec<PacketReport>

Take every packet a feedback described, up to the highest arrived one, since the last call, in send order.

A packet the receiver reported as not received is a loss. A packet below the highest arrival that no feedback described is neither: the feedback that covered it was lost, or the receiver does not report on its stream (no transport-wide sequence number, an SSRC outside the RFC 8888 report). The draft is explicit that such packets are ignored, not counted as lost or received (section 3), so they are released here without a report. Loss feedback alone does not advance the reporting window; losses are emitted when a later packet is reported as arrived.

Source

pub fn forget_sent(&mut self)

Forget every packet sent so far, as on a new path: those went into the path that was left, and what a later feedback says of them is neither a loss nor a delivery of the new one’s. libwebrtc’s TransportFeedbackAdapter::SetNetworkRoute does the same, so that “the feedback adapter only reports packets sent on the new route” (RtpTransportControllerSend::OnNetworkRouteChanged). A feedback that names one of them later matches nothing, as for a packet pruned.

Source

pub fn recovered(&self) -> u64

Packets reported as not received that a later feedback reported as received.

Source

pub fn prune_before(&mut self, cutoff: Instant)

Drop records of packets sent before cutoff that were never acknowledged.

Without this the history grows without bound on a lossy path: an unacknowledged packet is never reported and never removed, so nothing else would ever release it.

Trait Implementations§

Source§

impl Debug for History

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for History

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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.