Skip to main content

FileCc

Struct FileCc 

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

SRT File Transfer Congestion Control — sender-side window + pacing state (draft-sharabayko-srt-01 §5.2). See the module doc for the full formula mapping, the sans-IO contract, and the two flagged spec gaps.

Implementations§

Source§

impl FileCc

Source

pub fn new(initial_seqno: u32) -> Self

A fresh FileCC engine in Slow Start (rule 4: “runs exactly once at the beginning of a connection”).

initial_seqno seeds LAST_ACK_SEQNO (see the field doc) — pass the connection’s initial sequence number (ISN) minus one, or the ISN itself if no data has been sent yet; either way the first ACK’s CWND_SIZE growth (Step 3) reflects exactly the packets actually acknowledged since then.

Source

pub fn phase(&self) -> Phase

The current algorithm phase.

Source

pub fn cwnd_size(&self) -> f64

The current CWND_SIZE, in packets.

Source

pub fn pkt_snd_period_us(&self) -> f64

The current PKT_SND_PERIOD, in microseconds (as an f64 — the Congestion Avoidance formulas are inherently fractional).

Source

pub fn pkt_snd_period(&self) -> Duration

The current PKT_SND_PERIOD as a Duration, for a sender to consult before transmitting the next packet (same role as crate::livecc::LiveCC::on_ack_received’s return value).

Truncates the microsecond value toward zero (consistent with this crate’s existing integer-truncation convention, e.g. LiveCC’s PKT_SND_PERIOD).

Source

pub fn max_cwnd_size(&self) -> f64

The current MAX_CWND_SIZE (rule 8), in packets.

Source

pub fn set_max_cwnd_size(&mut self, packets: f64)

Reconfigure MAX_CWND_SIZE — rule 8 calls the 12 MB-derived default a settable/recommended value, not a hardwired constant.

Source

pub fn max_bw_bytes_per_sec(&self) -> Option<u64>

The current MAX_BW clamp, in bytes/sec (None = unbounded).

Source

pub fn set_max_bw_bytes_per_sec(&mut self, max_bw: Option<u64>)

Reconfigure MAX_BW (rule 15: MAXBW_SET mode only applies to file transfer; there is no default, None is unbounded).

Source

pub fn receiving_rate_pps(&self) -> u64

The last RECEIVING_RATE fed via FileCc::on_ack, packets/sec.

The last EST_LINK_CAPACITY fed via FileCc::on_ack, packets/sec.

Source

pub fn rtt(&self) -> Duration

The last RTT fed via FileCc::on_ack (or the initial 100 ms default before the first ACK).

Source

pub fn b_loss(&self) -> bool

bLosstrue if a loss has been reported since the last rate increase (rule 11-12).

Source

pub fn avg_nak_num(&self) -> f64

AvgNAKNum — the average number of NAKs per congestion period (rule 20’s EWMA).

Source

pub fn nak_count(&self) -> u32

NAKCount — NAKs received so far in the current congestion period.

Source

pub fn dec_count(&self) -> u32

DecCount — rate decreases applied so far in the current congestion period.

Source

pub fn last_dec_seq(&self) -> Option<u32>

LastDecSeq — the largest sent sequence number at the last rate decrease / congestion-period boundary, or None if no Congestion-Avoidance-phase loss has occurred yet.

Source

pub fn last_dec_period_us(&self) -> f64

LastDecPeriod, in microseconds (item under Step 5; initial value 1 microsecond).

Source

pub fn on_ack( &mut self, now: Duration, ack_seqno: u32, receiving_rate_pps: u64, est_link_capacity_pps: u64, rtt: Duration, )

On full-ACK packet reception (specs/rules/srt-congestion.md, §5.2.1.1 “(1) On ACK packet reception” / §5.2.1.2 “(1) On ACK packet reception”). Only full ACKs trigger a rate increase (rule 3, L3313-3314) — a light ACK must not be passed to this method.

now — the current time (Step 1’s currTime). ack_seqno — the ACK’s acknowledged sequence number (ACK_SEQNO). receiving_rate_pps / est_link_capacity_pps — the ACK-carried, receiver-reported rate estimates (§5.2.1.3); see the module doc’s gap-1 resolution for why these are stored verbatim, not smoothed here. rtt — the current (already-smoothed elsewhere) RTT estimate.

Source

pub fn on_loss( &mut self, lost_seqno: u32, largest_sent_seqno: u32, loss_ratio: f64, )

On a loss report (NAK) packet reception.

  • During Slow Start (rule 9): ends slow start; PKT_SND_PERIOD is set exactly as in the ACK Step 5 formula. lost_seqno, largest_sent_seqno, and loss_ratio are not consulted by this phase’s handling (the draft’s rule 9 gives no further formula).
  • During Congestion Avoidance (§5.2.1.2 “(2)”, L3568-3658): runs the full bLoss/loss-ratio-tolerance/congestion-period/repeat-decrease state machine.

lost_seqno — the sequence number reported lost by this NAK. largest_sent_seqno — the largest sequence number sent so far (recorded as the new LastDecSeq on a decrease, rules 22/29). loss_ratio — the sender’s current estimated loss ratio (rule 16’s “less than 2%” tolerance check), e.g. lost/sent over a recent window.

Source

pub fn on_timeout(&mut self)

On a retransmission timeout (RTO) event.

During Slow Start (rule 10): ends slow start, PKT_SND_PERIOD set exactly as in the ACK Step 5 formula (same as FileCc::on_loss’s slow-start handling). Once in Congestion Avoidance, this section does not describe an RTO-specific FileCC reaction (RTO-driven retransmission itself is the ARQ engine’s concern, srt-arq.md) — calling this while already in Congestion Avoidance is a no-op.

Source

pub fn tick(&mut self, _now: Duration)

Time-driven tick — currently a no-op (mirrors crate::livecc::LiveCC::tick). Provided for forward compatibility: this section’s algorithm is driven entirely by the three named events (send / ACK / timeout, rule 5); there is no additional periodic-only state transition to run here.

Trait Implementations§

Source§

impl Clone for FileCc

Source§

fn clone(&self) -> FileCc

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 FileCc

Source§

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

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

impl Default for FileCc

Source§

fn default() -> Self

A fresh engine with initial_seqno = 0 (see FileCc::new).

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.