Skip to main content

Receiver

Struct Receiver 

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

ARQ receiver-side state (draft-sharabayko-srt-01 §4.8.1/§4.8.2/§4.10).

Implementations§

Source§

impl Receiver

Source

pub fn new( dest_socket_id: u32, initial_seq: u32, max_flow_window: u32, mtu: u32, bounds: ReceiverBounds, ) -> Self

A fresh receiver expecting initial_seq first (the peer’s ISN), addressing dest_socket_id (the peer’s SRT Socket ID, §3), advertising max_flow_window (§3.2.1) as its Full ACK’s Available Buffer Size, sizing periodic NAKs against mtu (the handshake’s Maximum Transmission Unit Size, §3.2.1) and held to the caller’s bounds.

Source

pub fn with_mtu(self, mtu: u32) -> Self

Size periodic NAK datagrams against mtu (the handshake’s negotiated Maximum Transmission Unit Size, §3.2.1) instead of the 1500-byte default: a loss list too long for one datagram is split across several NAK packets rather than emitted as one the socket cannot send.

Source

pub fn ack_point(&self) -> u32

The cumulative ack point — every seq strictly before this has been delivered in order (rule 8’s ACK n + 1 semantics).

Source

pub fn rtt(&self) -> Duration

The current RTT estimate (rules 26-31).

Source

pub fn rtt_var(&self) -> Duration

The current RTTVar estimate.

Source

pub fn loss_list_len(&self) -> usize

Number of sequence numbers currently believed lost.

Source

pub fn feed_data(&mut self, seq_number: u32, now: Instant) -> FeedOutcome

Process one arriving data packet’s sequence number.

A packet more than the flow window ahead of the ack point is ignored (FeedOutcome::out_of_window): a crafted sequence jump therefore never grows the loss list or the out-of-order set past the window.

Source

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

Advance to absolute time now and emit any periodic control packets now due: a Full ACK every super::FULL_ACK_PERIOD (rule 11), a Light ACK once super::LIGHT_ACK_THRESHOLD packets have arrived since the last ACK (rule 12), and a periodic NAK once NAKInterval has elapsed and the loss list is non-empty (rules 21, 22) — never a NAK when nothing is believed lost.

Source

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

Absolute (since the connection epoch) time of the next periodic Full ACK or, while the loss list is non-empty, the next periodic NAK — whichever is earlier and still representable. The 10 ms Full ACK is unconditional (rule 11), so an idle connection still has a deadline; None means a deadline past the end of the clock, which never fires (a deadline is Instant::checked_add, never a saturated instant that reads as “due now” forever).

Source

pub fn on_ackack(&mut self, ackack: &AckAckPacket, now: Instant)

Process an incoming ACKACK: match it against the outstanding Full ACK it acknowledges and update RTT/RTTVar from the round-trip sample (rules 26-30). An ACKACK for an unknown/already-matched Acknowledgement Number is ignored.

Source

pub fn skip_range(&mut self, first: u32, last: u32)

Handle a peer’s DROPREQ (draft-sharabayko-srt-01 §3.2.9): the sender has given up on delivering the inclusive sequence range first..=last, so they will never arrive.

Without this, loss detection would NAK those numbers forever and the cumulative ack point (next_expected) would stall below the gap for the life of the connection. The range is removed from the loss list (stop asking) and the out-of-order set (the sender has given up on them, so anything they unblocked can no longer be delivered in order), and when the range covers next_expected the ack point jumps to the sequence after last. A last preceding first is a malformed (empty) range and ignored.

Trait Implementations§

Source§

impl Debug for Receiver

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Receiver

§

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

§

impl Move for Receiver

§

impl RefUnwindSafe for Receiver

§

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

§

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

§

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

§

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

§

impl UnwindSafe for Receiver

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