pub struct Link { /* private fields */ }link only.Expand description
One established SRT connection, driven by datagrams and the caller’s clock.
The host reads datagrams off its socket and calls Link::on_datagram, wakes at the next
Link::next_deadline and calls Link::poll, sends what Link::take_sent hands back,
and feeds application payloads in with Link::send. A host that owns an asynchronous socket
wakes on both at once and calls Link::poll_io after every wake-up.
Implementations§
Source§impl Link
impl Link
Sourcepub fn start_idle_clock(&mut self, now: Instant)
pub fn start_idle_clock(&mut self, now: Instant)
Starts the silence clocks (peer idle and keep-alive) at now, the instant the connection
was concluded, when the link’s own clock began earlier, at the handshake’s start.
Sourcepub fn new(now: Instant, setup: &LinkSetup, params: &CallerParams) -> Self
pub fn new(now: Instant, setup: &LinkSetup, params: &CallerParams) -> Self
An established link to the peer setup settled with, whose clock reads now at its start.
Sourcepub fn peer_socket_id(&self) -> u32
pub fn peer_socket_id(&self) -> u32
The peer’s SRT Socket ID: the dest_socket_id of every packet sent, and the one a
SHUTDOWN names.
Sourcepub fn send_window_open(&self) -> bool
pub fn send_window_open(&self) -> bool
Room in the send window: fewer than a full flow window of packets are buffered unacknowledged (§3.2.1), so the host may hand another payload over.
Sourcepub fn shutdown_datagram(&self, now: Instant) -> Option<Vec<u8>>
pub fn shutdown_datagram(&self, now: Instant) -> Option<Vec<u8>>
The SHUTDOWN datagram (§3.2.7) telling the peer this side is leaving. None once the
link has ended: the peer is already gone and has nothing left to be told.
Sourcepub fn next_release(&self) -> u32
pub fn next_release(&self) -> u32
The sequence number the scheduler releases next: every packet below it is delivered or given up on.
Sourcepub fn tlpktdrop_enabled(&self) -> bool
pub fn tlpktdrop_enabled(&self) -> bool
Whether Too-Late Packet Drop was negotiated (§4.6): only then may the receiver skip a gap nothing filled in time.
Sourcepub fn set_max_bw(&mut self, max_bw: MaxBwConfig)
pub fn set_max_bw(&mut self, max_bw: MaxBwConfig)
Set the LiveCC bandwidth policy that paces DATA packets from here on.
Sourcepub fn next_ack(&self) -> Option<Instant>
pub fn next_ack(&self) -> Option<Instant>
The next Full ACK / NAK instant of the receive direction, if it has one.
Sourcepub fn pacing_period(&self) -> Duration
pub fn pacing_period(&self) -> Duration
The pacing period one DATA packet’s slot advances by under the current policy.
Sourcepub fn queued_len(&self) -> usize
pub fn queued_len(&self) -> usize
How many DATA and control datagrams are still queued for the wire.
Sourcepub fn buffered_count(&self) -> usize
pub fn buffered_count(&self) -> usize
How many sent DATA packets are still unacknowledged. A closing sender drains these before sending SHUTDOWN so the tail of a stream is not lost to an unheard retransmission.
Sourcepub fn pending_retransmit_count(&self) -> usize
pub fn pending_retransmit_count(&self) -> usize
How many sequence numbers are waiting to be retransmitted.
Sourcepub fn average_payload_size(&self) -> u64
pub fn average_payload_size(&self) -> u64
The mean DATA payload size LiveCC paces from.
Sourcepub fn staged_len(&self) -> usize
pub fn staged_len(&self) -> usize
How many received packets are staged, waiting for TSBPD to release them.
Sourcepub fn ack_point(&self) -> u32
pub fn ack_point(&self) -> u32
The cumulative ACK point of the receive direction: every sequence number below it is accounted for, delivered or given up on.
Sourcepub fn loss_list_len(&self) -> usize
pub fn loss_list_len(&self) -> usize
How many received packets are missing between the delivery cursor and the highest one seen.
Sourcepub fn counts(&self) -> LinkCounts
pub fn counts(&self) -> LinkCounts
What this link has counted about the DATA it received.
Sourcepub fn next_send_seq(&self) -> u32
pub fn next_send_seq(&self) -> u32
The sequence number the next first transmission carries.
Sourcepub fn next_message_number(&self) -> u32
pub fn next_message_number(&self) -> u32
The message number the next first transmission carries.
Sourcepub fn next_deadline(&self, now: Instant) -> Option<Instant>
pub fn next_deadline(&self, now: Instant) -> Option<Instant>
The next instant this link must act without any inbound event: the next Full ACK / NAK, the
next TSBPD release, the Keep-Alive when idle, the peer-idle expiry, a pending KMREQ resend
and the next pacing slot. A deadline the clock cannot name is no deadline; the others still
bind. None once the link has ended.
Sourcepub fn next_paced_send_wait(&self, now: Instant) -> Option<Duration>
pub fn next_paced_send_wait(&self, now: Instant) -> Option<Duration>
How long until the DATA packet at the front of the queue may go out: None
when the queue is empty or its slot has already arrived.
Sourcepub fn send(&mut self, payload: &[u8], now: Instant)
pub fn send(&mut self, payload: &[u8], now: Instant)
Feed one application payload for first transmission at now. It is encrypted (§6) when
the connection negotiated it, queued behind any retransmission, and sent by the next
Link::poll or Link::poll_io.
Sourcepub fn take_sent(&mut self) -> Vec<Vec<u8>>
pub fn take_sent(&mut self) -> Vec<Vec<u8>>
Take the datagrams queued for the peer since the last call, in send order: first
transmissions, retransmissions and control feedback alike. They may leave at once — a host
that writes them calls Link::flush instead, which applies the pacing slot and records the
transmission the Keep-Alive period counts from.
Sourcepub fn on_datagram(&mut self, datagram: &[u8], now: Instant) -> Delivered
pub fn on_datagram(&mut self, datagram: &[u8], now: Instant) -> Delivered
Process one datagram from the peer at now, returning what it delivered.
Sourcepub fn on_owned_datagram(
&mut self,
datagram: Vec<u8>,
now: Instant,
) -> Delivered
pub fn on_owned_datagram( &mut self, datagram: Vec<u8>, now: Instant, ) -> Delivered
Link::on_datagram for a datagram the host owns: a payload it delivers stays in this
datagram’s allocation (see Payload), so receiving it costs no copy.
Sourcepub fn poll(&mut self, now: Instant) -> Delivered
pub fn poll(&mut self, now: Instant) -> Delivered
Run the timers at now — retransmissions, ACK/NAK, the Keep-Alive, a KMREQ resend and
the TSBPD release — returning what it delivered.
Sourcepub fn poll_io(&mut self, now: Instant, sent: &mut Vec<Vec<u8>>) -> Delivered
pub fn poll_io(&mut self, now: Instant, sent: &mut Vec<Vec<u8>>) -> Delivered
The timer pass and the outbound flush a host loop runs after every wake-up: the engines at
now, then every datagram due — appended to sent — control at once and DATA at its
pacing slot. Returns what the timer pass delivered; a host that also keeps a delivery
channel hands it on.
Sourcepub fn flush(&mut self, now: Instant, sent: &mut Vec<Vec<u8>>)
pub fn flush(&mut self, now: Instant, sent: &mut Vec<Vec<u8>>)
Append every outbound datagram due at now, in order, without blocking on the pacing
delay itself: control in full, then DATA while its pacing slot has arrived. Link::poll_io
runs the timers first, as a host loop does after every wake-up.
§5.1.2 paces DATA packets only: control feedback (ACK/NAK/ACKACK/Keep-Alive) goes out
immediately, or loss recovery would be throttled along with the data it unblocks. DATA is
scheduled against next_data_send_at_us, a token-bucket-style deadline rather than a sleep:
the schedule advances from whichever is later of the previous slot or now, but never more
than SenderBounds::pacing_burst_packets periods of catch-up credit in one pass, so a burst after an idle
gap sends at once while a sustained flood stays throttled.