Skip to main content

RlcDecoder

Struct RlcDecoder 

Source
pub struct RlcDecoder { /* private fields */ }
Expand description

Sliding-window RLC decoder: stores received source and repair symbols and recovers lost source symbols by Gaussian elimination over GF(2^8).

Implementations§

Source§

impl RlcDecoder

Source

pub fn new(symbol_len: usize) -> Self

Build a decoder over symbol_len-byte symbols.

Source

pub fn with_horizon(self, horizon: u32) -> Self

Set the RLC recovery horizon (source ids back from the newest that the solver considers). Should comfortably exceed the encoder’s window so a repair’s whole window is in scope; gaps older than this fall to ARQ.

Source

pub fn on_source(&mut self, source_id: u32, payload: &[u8]) -> Vec<u32>

Record a received source symbol. A source arrival fills its own slot directly; recovery of OTHER symbols is driven by repair arrivals (on_repair), so this does NOT run the (potentially expensive) Gaussian solve - that would otherwise fire on every single packet under loss, re-solving the whole in-horizon system each time, when a new source adds no equation. A late source that completes a pending system is recovered on the next repair (one arrives every step symbols), and anything that slips through is caught by the ARQ floor.

Source

pub fn on_repair(&mut self, r: RepairSymbol) -> Vec<u32>

Record a received repair symbol. Returns any source ids newly recovered.

Source

pub fn add_repair(&mut self, r: RepairSymbol)

Store a repair WITHOUT solving, for a caller that drains a batch of datagrams first (stamping their arrival before any decode) and then runs one recover over the whole batch - keeping the expensive Gaussian solve out of the receive/timing path.

Source

pub fn recover(&mut self) -> Vec<u32>

Run one recovery pass over the currently-stored source and repair symbols, returning any source ids newly recovered. Pairs with add_repair.

Source

pub fn get(&self, source_id: u32) -> Option<&[u8]>

The bytes of source symbol source_id, if received or recovered.

Source

pub fn has(&self, source_id: u32) -> bool

Whether source symbol source_id is present (received or recovered).

Source

pub fn forget_below(&mut self, floor: u32)

Drop delivered source symbols and spent repairs below floor, to bound memory on a long-lived flow. A source symbol a remaining repair still references is kept regardless (the decoder must subtract its known contribution when solving), so the source floor is capped at the oldest remaining repair’s window start - forgetting it otherwise would make a received symbol look unknown and corrupt the linear system.

Source

pub fn rebase_to(&mut self, base: u32)

Re-base the decoder to deliver from base: drop all stored source and repair symbols (they belong to the pre-rebase id range another code now owns) and anchor the recovery horizon at base. The receiver moves its delivery frontier to base in lockstep, so nothing below base is ever looked up again.

Trait Implementations§

Source§

impl Debug for RlcDecoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.