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
impl Sender
Sourcepub fn new(dest_socket_id: u32) -> Self
pub fn new(dest_socket_id: u32) -> Self
A fresh sender addressing dest_socket_id (the peer’s SRT Socket ID,
carried in every packet header, §3).
Sourcepub fn rtt(&self) -> Duration
pub fn rtt(&self) -> Duration
The current RTT estimate (rule 33 — updated from each Full ACK’s carried value).
Sourcepub fn buffered_count(&self) -> usize
pub fn buffered_count(&self) -> usize
Number of packets still buffered, unacknowledged.
Sourcepub fn pending_retransmit_count(&self) -> usize
pub fn pending_retransmit_count(&self) -> usize
Number of sequence numbers currently pending retransmission.
Sourcepub fn on_data(
&mut self,
seq: u32,
message_number: u32,
payload: &[u8],
now: Timestamp,
) -> Result<Vec<u8>>
pub fn on_data( &mut self, seq: u32, message_number: u32, payload: &[u8], now: Timestamp, ) -> 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.
Sourcepub fn on_data_keyed(
&mut self,
seq: u32,
message_number: u32,
payload: &[u8],
key_flag: EncryptionKeyField,
now: Timestamp,
) -> Result<Vec<u8>>
pub fn on_data_keyed( &mut self, seq: u32, message_number: u32, payload: &[u8], key_flag: EncryptionKeyField, now: Timestamp, ) -> 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.
Sourcepub fn on_nak(&mut self, nak: &NakPacket)
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 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.
Sourcepub fn tick(&mut self, now: Timestamp) -> Vec<(u32, Vec<u8>)>
pub fn tick(&mut self, now: Timestamp) -> 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 MIN_RETRANSMIT_INTERVAL ago stays pending:
a peer re-sending the same NAK cannot queue a second copy (#2819).
Sourcepub fn on_retransmit_sent(&mut self, seq: u32)
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).
Sourcepub fn on_retransmit_dropped(&mut self, seq: u32)
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.