pub struct Encoder { /* private fields */ }Expand description
Sender side: groups items into FEC-protected blocks and answers ARQ retransmit requests.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn epoch(&self) -> u32
pub fn epoch(&self) -> u32
Create an encoder. k data shards per block, initial r parity
shards (clamped to r_min..=r_max), max_item largest item
byte length.
This encoder’s session epoch, as stamped into every data datagram
and announced on the heartbeat.
pub fn new(k: usize, r: usize, max_item: usize) -> Self
Sourcepub fn coding_counts(&self) -> (u64, u64)
pub fn coding_counts(&self) -> (u64, u64)
Blocks sealed at zero parity (Passthrough) so far, and blocks sealed with parity. A nonzero first value proves FEC actually switched off on the wire; the ratio shows how much of the stream rode unprotected.
Sourcepub fn enable_tower(&mut self, d: usize, r_outer: usize)
pub fn enable_tower(&mut self, d: usize, r_outer: usize)
Enable the tower outer code: every d data blocks ship with
r_outer fire-and-forget outer-parity blocks that recover whole
lost data blocks without a retransmit. (0, _) or (_, 0)
disables it.
Sourcepub fn with_flow_window(self, blocks: u32) -> Self
pub fn with_flow_window(self, blocks: u32) -> Self
Set the in-flight flow window (blocks sent but not yet acked).
Match this to the receiver’s Decoder::with_window.
Sourcepub fn set_flow_window(&mut self, blocks: u32)
pub fn set_flow_window(&mut self, blocks: u32)
Adjust the in-flight flow window at runtime - the bufferbloat pacer shrinks it toward the BDP to drain a self-induced queue, and restores it when the queue clears. The receiver’s window is the hard ceiling, so the pacer only ever clamps DOWN from the configured maximum.
Sourcepub fn flow_window(&self) -> u32
pub fn flow_window(&self) -> u32
Current in-flight flow window (blocks).
Sourcepub fn flow_blocked(&self) -> bool
pub fn flow_blocked(&self) -> bool
true when the producer should pause sending new blocks until an
ack frees window space (keeps the receiver’s bounded window from
dropping far-ahead blocks).
Sourcepub fn next_block_id(&self) -> u32
pub fn next_block_id(&self) -> u32
Sourcepub fn push(&mut self, item: &[u8]) -> Vec<Vec<u8>>
pub fn push(&mut self, item: &[u8]) -> Vec<Vec<u8>>
Stage item for transmission. Returns the datagrams to send when
the staged set reaches k items (a full block); otherwise an
empty vec. Call flush to force a short final
block.
Sourcepub fn flush(&mut self) -> Vec<Vec<u8>>
pub fn flush(&mut self) -> Vec<Vec<u8>>
Force the staged items (fewer than k) into a final padded
block. Returns its datagrams, or empty if nothing is staged.
Sourcepub fn set_parity(&mut self, r: usize)
pub fn set_parity(&mut self, r: usize)
Set the parity shards per new block, clamped to the encoder’s
[r_min, r_max]. The fusion controller drives this from the
control table; the encoder no longer self-adapts parity.
Sourcepub fn set_parity_covering(&mut self, floor: usize, loss: f32)
pub fn set_parity_covering(&mut self, floor: usize, loss: f32)
Set parity to at least floor (the fusion controller’s burst / feed-forward
signal) AND enough to FEC-recover a loss fraction of THIS block: to
recover a fraction p of the k + r shards, r / (k + r) >= p, i.e.
r >= p * k / (1 - p). A 20% margin covers a spike above the mean. Capped at
r_max (the bitmap ceiling). Without this, parity tracked only the
controller’s modest floor and a high-loss block fell to ARQ round trips
instead of recovering in-FEC; this lets block-RS provision to the loss the
way the sliding-window RLC rate law already does.
Sourcepub fn on_feedback(&mut self, fb: &Feedback) -> Vec<Vec<u8>>
pub fn on_feedback(&mut self, fb: &Feedback) -> Vec<Vec<u8>>
Apply receiver feedback: free acked blocks and return any ARQ
retransmit datagrams. Parity adaptation is the controller’s job
(see set_parity), not this method’s.
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Number of unacked blocks held for ARQ.
Sourcepub fn oldest_pending(&self) -> Option<u32>
pub fn oldest_pending(&self) -> Option<u32>
The oldest unacked block id - the one the receiver’s in-order frontier
is waiting on - or None if everything is acked.
Sourcepub fn probe_block(&self, block_id: u32) -> Vec<Vec<u8>>
pub fn probe_block(&self, block_id: u32) -> Vec<Vec<u8>>
Retransmit datagrams (flagged RETRANSMIT) for the k DATA shards of
one pending block - a liveness probe that also pre-positions the block
the receiver’s frontier is stalled on. Empty if the block is already
acked.
Sourcepub fn retransmit_all_data(&self) -> Vec<Vec<u8>>
pub fn retransmit_all_data(&self) -> Vec<Vec<u8>>
Retransmit datagrams (flagged RETRANSMIT) for the k DATA shards of
EVERY pending block, oldest-first - the proactive burst on link recovery
that resends the whole unacked window WITHOUT waiting for the receiver’s
NAKs (the sender already holds the exact unacked set, so no estimation
is needed). The receiver dedups any datagram it already has via its
D-SACK / false-recovery path, so over-resending is safe. k data shards
per block suffice to decode a fully-lost block; any shard still missing
after the burst is recovered by the normal reactive NAK.