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
impl Receiver
Sourcepub fn new(
dest_socket_id: u32,
initial_seq: u32,
max_flow_window: u32,
mtu: u32,
bounds: ReceiverBounds,
) -> Self
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.
Sourcepub fn with_mtu(self, mtu: u32) -> Self
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.
Sourcepub fn ack_point(&self) -> u32
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).
Sourcepub fn loss_list_len(&self) -> usize
pub fn loss_list_len(&self) -> usize
Number of sequence numbers currently believed lost.
Sourcepub fn feed_data(&mut self, seq_number: u32, now: Instant) -> FeedOutcome
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.
Sourcepub fn tick(&mut self, now: Instant) -> Vec<Vec<u8>>
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.
Sourcepub fn next_deadline(&self) -> Option<Instant>
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).
Sourcepub fn on_ackack(&mut self, ackack: &AckAckPacket, now: Instant)
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.
Sourcepub fn skip_range(&mut self, first: u32, last: u32)
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.