A Rust library for implementing Forward Error Correction (FEC) using Raptor codes.
Raptor codes are a class of FEC codes that are designed to be highly efficient in the presence of packet erasures. This library provides functionality for encoding source blocks into encoding symbols and decoding source blocks from a set of encoding symbols.
This library implements on the fly Gaussian Elimination to spread decoding complexity during packets reception.
Encode and decode a source block using raptor_code::encode_source_block
and raptor_code::decode_source_block
```rust
let sourceblockdata: Vec
// Step 1 - Generate the encoding symbols (source symbols + repair symbols) let (encodingsymbols, nbsourcesymbols) = raptorcode::encodesourceblock(&sourceblockdata, maxsourcesymbols, nb_repair);
// Step 2 - Re-construct the source data from the encoding symbols let mut receivedsymbols: Vecsymbols.intoiter() .map(|symbols| Some(symbols)) .collect(); // simulate encoding symbol lost receivedsymbols[0] = None;
let reconstructeddata = raptorcode::decodesourceblock(&receivedsymbols, nbsourcesymbols as usize, sourceblock_length) .unwrap();
// Source data and decoded data should be identical assert!(reconstructeddata == sourceblock_data) ```
```rust
let sourcedata: Vec
let mut encoder = raptorcode::SourceBlockEncoder::new(&sourcedata, maxsourcesymbols); let n = encoder.nbsourcesymbols() + nb_repair;
for esi in 0..n as u32 { let encodingsymbol = encoder.fountain(esi); //TODO transfer symbol over Network // networkpushpkt(encodingsymbol); }
```
```rust let encodingsymbollength = 1024; let sourceblocksize = 4; // Number of source symbols in the source block let mut n = 0u32; let mut decoder = raptorcode::SourceBlockDecoder::new(sourceblock_size);
while decoder.fullyspecified() == false { //TODO replace the following line with pkt received from network let (encodingsymbol, esi) = (vec![0; encodingsymbollength],n); decoder.pushencodingsymbol(&encoding_symbol, esi); n += 1; }
let sourceblocksize = encodingsymbollength * sourceblocksize; let sourceblock = decoder.decode(sourceblock_size as usize);
```
RFC 5053 https://www.rfc-editor.org/rfc/rfc5053.html
On the fly Gaussian Elimination for LT codes, Valerio Bioglio, Marco Grangetto, 2009
Reuse ideas and concepts of gofountain