Skip to main content

Link

Struct Link 

Source
pub struct Link { /* private fields */ }
Available on crate feature 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

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.

Source

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.

Source

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.

Source

pub fn epoch(&self) -> Instant

The now this link measures its protocol time from.

Source

pub fn is_ended(&self) -> bool

Whether the link has ended: it delivers and sends nothing more.

Source

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.

Source

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.

Source

pub fn next_release(&self) -> u32

The sequence number the scheduler releases next: every packet below it is delivered or given up on.

Source

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.

Source

pub fn set_max_bw(&mut self, max_bw: MaxBwConfig)

Set the LiveCC bandwidth policy that paces DATA packets from here on.

Source

pub fn next_ack(&self) -> Option<Instant>

The next Full ACK / NAK instant of the receive direction, if it has one.

Source

pub fn pacing_period(&self) -> Duration

The pacing period one DATA packet’s slot advances by under the current policy.

Source

pub fn queued_len(&self) -> usize

How many DATA and control datagrams are still queued for the wire.

Source

pub fn buffered_count(&self) -> usize

How many DATA packets are buffered, acknowledged or not.

Source

pub fn pending_retransmit_count(&self) -> usize

How many sequence numbers are waiting to be retransmitted.

Source

pub fn average_payload_size(&self) -> u64

The mean DATA payload size LiveCC paces from.

Source

pub fn staged_len(&self) -> usize

How many received packets are staged, waiting for TSBPD to release them.

Source

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.

Source

pub fn loss_list_len(&self) -> usize

How many received packets are missing between the delivery cursor and the highest one seen.

Source

pub fn rtt(&self) -> Duration

The receive direction’s round-trip estimate (rule 33).

Source

pub fn counts(&self) -> LinkCounts

What this link has counted about the DATA it received.

Source

pub fn next_send_seq(&self) -> u32

The sequence number the next first transmission carries.

Source

pub fn next_message_number(&self) -> u32

The message number the next first transmission carries.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn on_datagram(&mut self, datagram: &[u8], now: Instant) -> Delivered

Process one datagram from the peer at now, returning what it delivered.

Source

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.

Source

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.

Source

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.

Source

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.

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more