Skip to main content

Sender

Struct Sender 

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

ARQ sender-side state (draft-sharabayko-srt-01 §4.8). See the module doc for the sans-IO contract.

Implementations§

Source§

impl Sender

Source

pub fn new(dest_socket_id: u32, bounds: SenderBounds) -> Self

A fresh sender addressing dest_socket_id (the peer’s SRT Socket ID, carried in every packet header, §3), held to the caller’s bounds.

Source

pub fn rtt(&self) -> Duration

The current RTT estimate (rule 33 — updated from each Full ACK’s carried value).

Source

pub fn rtt_var(&self) -> Duration

The current RTTVar estimate.

Source

pub fn buffered_count(&self) -> usize

Number of packets still buffered, unacknowledged.

Source

pub fn pending_retransmit_count(&self) -> usize

Number of sequence numbers currently pending retransmission.

Source

pub fn on_data( &mut self, seq: u32, message_number: u32, payload: &[u8], now: Instant, ) -> Result<Vec<u8>>

Submit a new data packet for first transmission (rule 1: the sender buffers every sent packet to enable retransmission). Returns the wire bytes to send now — see the module doc’s priority note.

seq must increase (circularly) from one call to the next — the send buffer is searched by binary search, and a debug build asserts it.

§Errors

crate::error::Error::FieldOverflow if seq does not fit its 31-bit field or message_number its 26-bit one; nothing is buffered then.

Source

pub fn on_data_keyed( &mut self, seq: u32, message_number: u32, payload: &[u8], key_flag: EncryptionKeyField, now: Instant, ) -> Result<Vec<u8>>

Like Self::on_data but records a KK flag for the packet (used by the tokio adapter’s encrypted data path). The payload is already encrypted by the caller.

Source

pub fn on_nak(&mut self, nak: &NakPacket)

Record a NAK’s loss-list entries for prioritized retransmission (private/specs-verified/rules/srt-arq.md rules 5, 15, 16, 18). Entries no longer in the send buffer (already freed by a since-received ACK) are silently ignored (rule 17).

Each entry is resolved against the send buffer by binary search, and a range is intersected with the buffered window rather than expanded, so the work is bounded by the buffer and by SenderBounds::max_nak_seqs_per_packet no matter what range a (possibly spoofed) NAK declares. A range whose end precedes its start is malformed and ignored.

Source

pub fn tick(&mut self, now: Instant) -> Vec<(u32, Vec<u8>)>

Drain the pending retransmit queue, returning each retransmission’s sequence number and wire bytes (rules 16, 18 — the R flag is set, the resend counter incremented). A queued sequence number no longer in the buffer (freed by a since-received ACK) is dropped without emitting anything (rule 17).

A sequence number already queued in the caller’s outbound queue (Self::on_retransmit_sent clears it once the datagram leaves) or retransmitted less than SenderBounds::min_retransmit_interval ago stays pending: a peer re-sending the same NAK cannot queue a second copy (#2819).

Source

pub fn on_retransmit_sent(&mut self, seq: u32)

The retransmission of seq left the caller’s outbound queue: it may be queued again by a later Self::tick (a NAK asking for it again, or the rate limit having passed).

Source

pub fn on_retransmit_dropped(&mut self, seq: u32)

The retransmission of seq was dropped instead of queued (the caller’s outbound queue was full): clear the queued mark and put it back in the pending set, so a later tick offers it again.

Source

pub fn on_ack(&mut self, ack: &AckPacket, now: Instant) -> Option<Vec<u8>>

Process an incoming ACK: free every acknowledged packet (rules 7, 8, 16, 17), and — for a Full ACK only — update RTT/RTTVar (rule 33) and return the ACKACK reply (rules 3, 9).

Trait Implementations§

Source§

impl Debug for Sender

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Sender

§

impl Freeze for Sender
where *const u8 is !null: Freeze, PhantomData<SentPacket>: Freeze, *const LeafNode<u32, SetValZST> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(u32, SetValZST)>>: Freeze,

§

impl Move for Sender

§

impl RefUnwindSafe for Sender

§

impl Send for Sender
where RawVecInner: Send, NodeRef<Owned, u32, SetValZST, LeafOrInternal>: Send, BoxRaw<(u32, SetValZST)>: Send,

§

impl Sync for Sender
where RawVecInner: Sync, NodeRef<Owned, u32, SetValZST, LeafOrInternal>: Sync, BoxRaw<(u32, SetValZST)>: Sync,

§

impl Unpin for Sender
where *const u8 is !null: Unpin, *const LeafNode<u32, SetValZST> is !null: Unpin, Box<(u32, SetValZST)>: Unpin,

§

impl UnsafeUnpin for Sender
where *const u8 is !null: UnsafeUnpin, PhantomData<SentPacket>: UnsafeUnpin, *const LeafNode<u32, SetValZST> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(u32, SetValZST)>>: UnsafeUnpin,

§

impl UnwindSafe for Sender
where RawVecInner: UnwindSafe, BTreeMap<u32, SetValZST>: UnwindSafe,

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