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
impl LiveCC
Sourcepub fn new(max_bw_config: MaxBwConfig) -> Self
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).
Sourcepub fn on_data_packet(&mut self, packet_payload_size: u64)
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 * PacketPayloadSizeSourcepub fn avg_payload_size(&self) -> u64
pub fn avg_payload_size(&self) -> u64
The current average payload size estimate, in bytes.
Sourcepub fn max_bw_config(&self) -> &MaxBwConfig
pub fn max_bw_config(&self) -> &MaxBwConfig
The current MAX_BW configuration.
Sourcepub fn set_max_bw_config(&mut self, config: MaxBwConfig)
pub fn set_max_bw_config(&mut self, config: MaxBwConfig)
Reconfigure the MAX_BW mode at runtime.
Sourcepub fn on_ack_received(&self) -> Duration
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 sizeStep 2 — PKT_SND_PERIOD (L3234, verbatim):
PKT_SND_PERIOD = PktSize * 1000000 / MAX_BWSourcepub fn tick(&mut self) -> Option<Duration>
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.