Skip to main content

ReliableUdpReceiver

Struct ReliableUdpReceiver 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn nudge_feedback(&mut self) -> Result<()>

Send one feedback round to every live peer without waiting for a datagram.

Source

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.

Source

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.

Source

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.

Source

pub fn with_feedback_delay(self, delay: Duration) -> Self

Inject a one-way feedback delay, to model a link’s return latency.

Source

pub fn with_nak_batch(self, batch: usize) -> Self

Cap how many gaps one selective-NAK cycle re-requests.

Source

pub fn with_feedback_drop(self, pct: u32) -> Self

Drop pct percent of outbound feedback datagrams (diagnostics).

Source

pub fn with_block_drop_mod(self, m: u32) -> Self

Drop every shard of any data block whose id is a multiple of m.

Source

pub fn with_burst_loss(self, at: u64, len: u64) -> Self

Drop every data datagram arriving in [at, at + len) by arrival index.

Source

pub fn local_addr(&self) -> Result<SocketAddr>

The bound local address (useful when binding to port 0).

Source

pub fn net_event_count(&self) -> u64

Count of OS path events this end’s active observer has seen.

Source

pub fn local_pmtu(&self) -> u16

This endpoint’s egress path MTU in bytes (0 = unknown).

Source

pub fn net_event_shift(&self) -> f32

The observer’s current decaying path-shift (telemetry).

Source

pub fn net_event_shift_peak(&self) -> f32

The peak path shift reached over the run (telemetry).

Source

pub fn inject_path_event(&self)

Synthetically fire a path event on this end (demo path).

Source

pub fn inject_pmtu(&self, mtu: u16)

Synthetically set this endpoint’s egress MTU (demo path).

Source

pub fn recv_count(&self) -> u64

Datagrams read off the socket, summed over peers.

Source

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.

Source

pub fn peer_pmtu_of(&self, epoch: u32) -> Option<u16>

The path MTU reported by one peer.

Source

pub fn live_sessions(&self) -> Vec<u32>

The session epochs with a live decode window, in first-seen order.

Source

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.

Source

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.

Source

pub fn peak_loss_x255(&self) -> u8

Peak per-block loss seen, x255, over every peer.

Source

pub fn false_recovery_count(&self) -> u64

Blocks the decoder reconstructed that later proved already complete, summed over peers.

Source

pub fn set_ge_burst(&mut self, on: bool)

Drive the Gilbert-Elliott injector’s bad state on every live session.

Source

pub fn set_debug_loss(&mut self, pct: u32)

Set the injected data-loss percentage on every live session.

Source

pub fn mean_burst_len(&self) -> f32

Mean burst length of the newest peer’s fitted loss model.

Source

pub fn owd_skew(&self) -> f64

One-way-delay skew of the newest peer’s path.

Source

pub fn owd_trend_debiased(&self) -> f64

Debiased one-way-delay trend of the newest peer’s path.

Source

pub fn ack_interval(&self) -> Duration

The newest peer’s current ACK cadence.

Source

pub fn feedback_loss_est(&self) -> f32

Reverse-path (feedback) loss fraction toward the newest peer.

The newest peer’s reported (link_class, link_quality).

Source

pub fn accecn_counts(&self) -> (u64, u64)

AccECN (ce_count, ect_count) observed from the newest peer.

Source

pub fn forecast_bps(&self) -> u64

Arrival-rate forecast for the newest peer, bits per second.

Source

pub fn leo_cadence(&self) -> Option<(f64, f64, f64)>

LEO handover cadence detected on the newest peer’s path.

Source

pub fn wbest_bps(&self) -> (u64, u64)

WBest (available, capacity) estimate for the newest peer, bits/s.

Source

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).

Source

pub fn take_session_changed(&mut self) -> bool

Whether a window was admitted since the last call. Edge-triggered.

Source

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.

Auto Trait Implementations§

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.