pub struct ReliableUdpReceiver { /* private fields */ }Expand description
Receiver side of the block-RS code. Owns the socket and the drain, and
routes each datagram to the RsSession holding its session epoch.
Point-to-point by default: the socket connects to its one peer and reads
through the GRO / recvmmsg / WSARecvMsg fast paths.
with_multi_peer keeps it unconnected and reads
per datagram with the source captured.
Implementations§
Source§impl ReliableUdpReceiver
impl ReliableUdpReceiver
Sourcepub fn bind(local: impl ToSocketAddrs) -> Result<Self>
pub fn bind(local: impl ToSocketAddrs) -> Result<Self>
Bind local. The socket gets a short read timeout so the receiver parks
on data yet wakes often enough to drive tail-ARQ feedback. No session
exists until a peer is seen; each session epoch that arrives opens one.
Sourcepub fn poll_from(&mut self) -> Result<Vec<(u32, Vec<u8>)>>
pub fn poll_from(&mut self) -> Result<Vec<(u32, Vec<u8>)>>
Receive whatever has arrived and deliver in-order items, each tagged with the session epoch of the peer that sent it.
Items are ordered within an epoch and unordered across epochs.
Sourcepub fn poll(&mut self) -> Result<Vec<Vec<u8>>>
pub fn poll(&mut self) -> Result<Vec<Vec<u8>>>
Receive one datagram, decode it, send feedback, and return any items
that became deliverable in stream order. Peer attribution is dropped;
use poll_from when several peers are live.
Sourcepub fn with_multi_peer(self) -> Self
pub fn with_multi_peer(self) -> Self
Serve several peers concurrently. The socket stays unconnected and each
datagram is read singly, its source captured, and routed by the session
epoch it carries. Gives up the GRO / recvmmsg / WSARecvMsg fast
paths, which read an address-associated socket, so throughput is below
the point-to-point figures.
Sourcepub fn set_sock(&mut self, sock: DgramSock)
pub fn set_sock(&mut self, sock: DgramSock)
Swap the datagram socket for one the caller already built (a demux socket the unified endpoint shares across both codes). Live sessions pick it up, since they hold the same handle.
Sourcepub fn session_epoch(&self) -> Option<u32>
pub fn session_epoch(&self) -> Option<u32>
The epoch of the most recently opened session, or None before any peer
is seen. Ambiguous once several peers are live - prefer
live_sessions.
Sourcepub fn nudge_feedback(&mut self) -> Result<()>
pub fn nudge_feedback(&mut self) -> Result<()>
Send one feedback round to every live peer without waiting for a datagram.
Sourcepub fn with_debug_loss(self, pct: u32, seed: u64) -> Self
pub fn with_debug_loss(self, pct: u32, seed: u64) -> Self
Drop pct percent of incoming data datagrams (seeded, reproducible) to
exercise FEC / ARQ on a lossless link. Stamped onto each session as it
opens, so every peer sees the same injected rate.
Sourcepub fn with_gilbert_loss(
self,
p_per_10k: u32,
r_per_10k: u32,
seed: u64,
) -> Self
pub fn with_gilbert_loss( self, p_per_10k: u32, r_per_10k: u32, seed: u64, ) -> Self
Gilbert-Elliott burst-loss injection, per-10000 transition probabilities.
Sourcepub fn with_max_hold(self, hold: Duration) -> Self
pub fn with_max_hold(self, hold: Duration) -> Self
How long a gap is held while FEC and ARQ recover it before the stream is advanced past it.
Sourcepub fn with_feedback_delay(self, delay: Duration) -> Self
pub fn with_feedback_delay(self, delay: Duration) -> Self
Inject a one-way feedback delay, to model a link’s return latency.
Sourcepub fn with_nak_batch(self, batch: usize) -> Self
pub fn with_nak_batch(self, batch: usize) -> Self
Cap how many gaps one selective-NAK cycle re-requests.
Sourcepub fn with_feedback_drop(self, pct: u32) -> Self
pub fn with_feedback_drop(self, pct: u32) -> Self
Drop pct percent of outbound feedback datagrams (diagnostics).
Sourcepub fn with_block_drop_mod(self, m: u32) -> Self
pub fn with_block_drop_mod(self, m: u32) -> Self
Drop every shard of any data block whose id is a multiple of m.
Sourcepub fn with_burst_loss(self, at: u64, len: u64) -> Self
pub fn with_burst_loss(self, at: u64, len: u64) -> Self
Drop every data datagram arriving in [at, at + len) by arrival index.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
The bound local address (useful when binding to port 0).
Sourcepub fn net_event_count(&self) -> u64
pub fn net_event_count(&self) -> u64
Count of OS path events this end’s active observer has seen.
Sourcepub fn local_pmtu(&self) -> u16
pub fn local_pmtu(&self) -> u16
This endpoint’s egress path MTU in bytes (0 = unknown).
Sourcepub fn net_event_shift(&self) -> f32
pub fn net_event_shift(&self) -> f32
The observer’s current decaying path-shift (telemetry).
Sourcepub fn net_event_shift_peak(&self) -> f32
pub fn net_event_shift_peak(&self) -> f32
The peak path shift reached over the run (telemetry).
Sourcepub fn inject_path_event(&self)
pub fn inject_path_event(&self)
Synthetically fire a path event on this end (demo path).
Sourcepub fn inject_pmtu(&self, mtu: u16)
pub fn inject_pmtu(&self, mtu: u16)
Synthetically set this endpoint’s egress MTU (demo path).
Sourcepub fn recv_count(&self) -> u64
pub fn recv_count(&self) -> u64
Datagrams read off the socket, summed over peers.
Sourcepub fn peer_pmtu(&self) -> u16
pub fn peer_pmtu(&self) -> u16
The path MTU last reported by the most recently opened peer (0 = none
yet). Per-peer by nature; use peer_pmtu_of when
several are live.
Sourcepub fn peer_pmtu_of(&self, epoch: u32) -> Option<u16>
pub fn peer_pmtu_of(&self, epoch: u32) -> Option<u16>
The path MTU reported by one peer.
Sourcepub fn live_sessions(&self) -> Vec<u32>
pub fn live_sessions(&self) -> Vec<u32>
The session epochs with a live decode window, in first-seen order.
Sourcepub fn with_session_ceiling(self, max: usize) -> Self
pub fn with_session_ceiling(self, max: usize) -> Self
Bound the live windows and the candidates under challenge at max.
Unbounded unless set. A peer turned away by the ceiling is counted in
session_refusals rather than dropped
silently.
Sourcepub fn session_refusals(&self) -> u64
pub fn session_refusals(&self) -> u64
Peers refused a decode window by a declared ceiling. Non-zero means a peer that reached this receiver was not served.
Sourcepub fn peak_loss_x255(&self) -> u8
pub fn peak_loss_x255(&self) -> u8
Peak per-block loss seen, x255, over every peer.
Sourcepub fn false_recovery_count(&self) -> u64
pub fn false_recovery_count(&self) -> u64
Blocks the decoder reconstructed that later proved already complete, summed over peers.
Sourcepub fn set_ge_burst(&mut self, on: bool)
pub fn set_ge_burst(&mut self, on: bool)
Drive the Gilbert-Elliott injector’s bad state on every live session.
Sourcepub fn set_debug_loss(&mut self, pct: u32)
pub fn set_debug_loss(&mut self, pct: u32)
Set the injected data-loss percentage on every live session.
Sourcepub fn mean_burst_len(&self) -> f32
pub fn mean_burst_len(&self) -> f32
Mean burst length of the newest peer’s fitted loss model.
Sourcepub fn owd_trend_debiased(&self) -> f64
pub fn owd_trend_debiased(&self) -> f64
Debiased one-way-delay trend of the newest peer’s path.
Sourcepub fn ack_interval(&self) -> Duration
pub fn ack_interval(&self) -> Duration
The newest peer’s current ACK cadence.
Sourcepub fn feedback_loss_est(&self) -> f32
pub fn feedback_loss_est(&self) -> f32
Reverse-path (feedback) loss fraction toward the newest peer.
Sourcepub fn accecn_counts(&self) -> (u64, u64)
pub fn accecn_counts(&self) -> (u64, u64)
AccECN (ce_count, ect_count) observed from the newest peer.
Sourcepub fn forecast_bps(&self) -> u64
pub fn forecast_bps(&self) -> u64
Arrival-rate forecast for the newest peer, bits per second.
Sourcepub fn leo_cadence(&self) -> Option<(f64, f64, f64)>
pub fn leo_cadence(&self) -> Option<(f64, f64, f64)>
LEO handover cadence detected on the newest peer’s path.
Sourcepub fn wbest_bps(&self) -> (u64, u64)
pub fn wbest_bps(&self) -> (u64, u64)
WBest (available, capacity) estimate for the newest peer, bits/s.
Sourcepub fn head_status(&self) -> Option<(u32, u32, usize, bool)>
pub fn head_status(&self) -> Option<(u32, u32, usize, bool)>
The block blocking in-order delivery on the newest peer:
(block_id, received_shards, k, decoded).
Sourcepub fn take_session_changed(&mut self) -> bool
pub fn take_session_changed(&mut self) -> bool
Whether a window was admitted since the last call. Edge-triggered.
Sourcepub fn session_adoption_counts(&self) -> (u64, u64)
pub fn session_adoption_counts(&self) -> (u64, u64)
(admitted, challenges that went unanswered). The second rising
without the first is what a forged epoch looks like from here.