Skip to main content

Module fec

Module fec 

Source
Expand description

Reed-Solomon forward error correction — the erasure codec that lets a lossy transport reconstruct dropped packets without a retransmit round-trip.

Given k data shards we compute m parity shards; the n = k + m shards are Maximum Distance Separable (MDS): any k of the n shards reconstruct the original data exactly. Losing up to m shards is fully recoverable.

The construction is a systematic Reed-Solomon code over GF(2^8) (the crate::gf256 field). Start from an n×k Vandermonde matrix V on n distinct field nodes 0,1,…,n-1: every k×k submatrix of a Vandermonde on distinct nodes is invertible (its determinant is ∏_{a<b}(x_b − x_a) ≠ 0), which is exactly the MDS property. Right-multiplying by the inverse of V’s top k×k block yields the generator G = V · V_top⁻¹, whose top k rows are the identity — so the first k encoded shards are the data (systematic), the rest are parity, and every k-row submatrix stays invertible (invertible · invertible). Encoding is G applied per byte-column; erasure recovery inverts the k×k submatrix of the surviving rows. All exact, no floating point.

Structs§

ReedSolomon
A systematic Reed-Solomon erasure code with k data shards and m = n − k parity shards. Cheap to clone (holds only the n×k generator matrix); construct once with ReedSolomon::new and reuse across many messages of the same shape.