Skip to main content

LiveCC

Struct LiveCC 

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

SRT Live Congestion Control — sender-side pacing state (draft-sharabayko-srt-01 §5.1.2).

Tracks the EWMA average payload size and recomputes the inter-packet send period on each ACK.

Sans-IO: all timing is caller-driven — LiveCC::on_data_packet, LiveCC::on_ack_received, and LiveCC::tick take explicit inputs and return computed values; the controller never reads a wall clock internally.

Implementations§

Source§

impl LiveCC

Source

pub fn new(max_bw_config: MaxBwConfig) -> Self

Create a new LiveCC pacing controller.

max_bw_config — the MAX_BW mode (§5.1.1). Use Default::default() for the default 1 Gbps fixed MAXBW_SET mode.

Initial AvgPayloadSize is set to the initial cap (1456 bytes), per specs/rules/srt-livecc.md §5.1.2 (L3222-3223).

Source

pub fn on_data_packet(&mut self, packet_payload_size: u64)

Update the EWMA average payload size on sending a data packet (specs/rules/srt-livecc.md §5.1.2, L3216-3223).

packet_payload_size — the payload size (bytes) of the just-sent data packet (original or retransmitted, L3216-3217).

Formula (L3219, verbatim):

AvgPayloadSize = 7/8 * AvgPayloadSize + 1/8 * PacketPayloadSize
Source

pub fn avg_payload_size(&self) -> u64

The current average payload size estimate, in bytes.

Source

pub fn max_bw_config(&self) -> &MaxBwConfig

The current MAX_BW configuration.

Source

pub fn set_max_bw_config(&mut self, config: MaxBwConfig)

Reconfigure the MAX_BW mode at runtime.

Source

pub fn on_ack_received(&self) -> Duration

Compute the current inter-packet send period in microseconds (specs/rules/srt-livecc.md §5.1.2, L3225-3238).

Call this on ACK reception (method (2), L3225). The period is also used after any state change (e.g. reconfiguration).

Returns Duration::ZERO when bandwidth is unbounded (infinite mode), meaning “send as fast as possible”.

Step 1 — PktSize (L3227-3229, paraphrased):

PktSize = AvgPayloadSize + SRT header size

Step 2 — PKT_SND_PERIOD (L3234, verbatim):

PKT_SND_PERIOD = PktSize * 1000000 / MAX_BW
Source

pub fn tick(&mut self) -> Option<Duration>

Time-driven tick — currently a no-op for LiveCC (the §5.1.2 algorithm is driven by packet/ACK events only; an RTO timeout also triggers on_data_packet, per L3240-3241).

Provided for forward compatibility: the sender loop should call this every cycle. Returns None.

Trait Implementations§

Source§

impl Clone for LiveCC

Source§

fn clone(&self) -> LiveCC

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 LiveCC

Source§

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

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

impl Default for LiveCC

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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.