Skip to main content

Module fec

Module fec 

Source
Expand description

Forward error correction over GF(256): systematic Cauchy Reed-Solomon erasure coding.

Packet loss on UDP is an erasure - the receiver knows WHICH packet is missing from the gap in the sequence numbers - so the decoder recovers from any K survivors out of K + R coded packets without needing to locate the error. This is the FEC half of the reliable-UDP transport’s FEC-primary / ARQ-fallback design: a block of K source packets ships with R parity packets, and up to R losses per block are recovered with no retransmit round-trip.

The code is systematic (the K source shards are transmitted verbatim; only the R parity shards are computed) and MDS (any K of the K + R shards reconstruct the block). The MDS property comes from a Cauchy parity matrix: every square submatrix of a Cauchy matrix is invertible, so any K-row submatrix of the [I_K ; Cauchy] encoding matrix is invertible.

GF(256) uses the primitive polynomial 0x11D with log / antilog tables computed at compile time (const fn), so there is no runtime initialization.

Modules§

gf
GF(256) arithmetic with the primitive polynomial x^8 + x^4 + x^3 + x^2 + 1 (0x11D) and generator 2.

Structs§

RsCode
A systematic Cauchy Reed-Solomon erasure code: k data shards plus r parity shards, recovering any k of the k + r.

Enums§

FecError
Error from constructing or decoding an RsCode.
GfBackend
GF(256) multiply-add backend, exposed so an A/B bench can compare every SIMD rung against the scalar baseline and so the GFNI / AVX-512 logic can be validated on a host without the silicon via the bit-exact software affine emulation. The production hot loop (gf_mul_add) auto-selects the fastest rung this host can run; the ladder always bottoms out at Scalar.

Functions§

gf_mul_add_auto
out[i] ^= gf::mul(coef, src[i]) through the auto-detected fastest backend. The public entry point for callers outside RsCode (the sliding-window RLC FEC) that want the SIMD-accelerated GF(2^8) multiply-add without managing a backend. The coef == 0 / 1 shortcuts skip the multiply.
gf_mul_add_backend
Run gf_mul_add through a specific GfBackend - the A/B-bench and emulation-validation entry point. The hardware rungs require their ISA feature; call only those GfBackend::available() reports (the debug_assert catches a mismatch in test builds).