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: Duration,
) -> Result<Vec<u8>>
pub fn on_data( &mut self, seq: u32, message_number: u32, payload: &[u8], now: Duration, ) -> 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
Error::FieldTooWide 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: Duration,
) -> Result<Vec<u8>>
pub fn on_data_keyed( &mut self, seq: u32, message_number: u32, payload: &[u8], key_flag: EncryptionKeyField, now: Duration, ) -> 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
(specs/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: Duration) -> Vec<Vec<u8>>
pub fn tick(&mut self, now: Duration) -> Vec<Vec<u8>>
Drain the pending retransmit queue, returning the wire bytes of each
retransmission (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).