Raptorq (raptorq v0.1.0)

Copy Markdown View Source

RaptorQ forward error correction (RFC 6330).

Quick start

# Encode: split data into K symbols and compute intermediate symbols C
data = File.read!("myfile.dat")
{:ok, state} = Raptorq.encode(data, 10)

# Generate repair symbols for any ISI ≥ K'
c = Map.get(state, :c)
p = Map.get(state, :params)
repair_1 = Raptorq.repair(c, p, 100_000)
repair_2 = Raptorq.repair(c, p, 100_001)

# Decode: recover from any K' of the (source + repair) symbols
received = [{0, sym_0}, {3, sym_3}, {100_000, repair_1} | ...]
{:ok, data} = Raptorq.decode(received, 10, byte_size(data))

Architecture

The source data is split into K equal-sized symbols. Using the SIOP table, K' ≥ K is chosen, and the K'-K tail symbols are zero- padded. The constraint matrix A (L = S+H+K' rows/columns) is built linking intermediate symbols C to the source symbols via A·C = D.

Encoding symbols for any ISI (0 … 2²⁰−1) are linear combinations of C produced by Tuple[K', ISI] (RFC 6330 §5.3.5.4). The receiver builds a system from LDPC+HDPC rows (always D=0) and G_ENC rows for received ISIs, then solves for C to recover the source data.

Performance

Uses the 5-phase sparse solver (Raptorq.Solver) for efficient O(L²) decoding of the intermediate symbols C.

Summary

Functions

Decode received symbols to recover original source data.

Encode source data for block of K source symbols.

Generate one repair symbol for the given ISI.

Functions

decode(received, k, data_size \\ nil)

Decode received symbols to recover original source data.

received is a list of {isi, symbol_binary} tuples. k is the number of source symbols in the original block. data_size (optional) truncates output to the original data size.

encode(data, k)

Encode source data for block of K source symbols.

data is the source data as a binary. k is the number of source symbols in the block.

Returns {:ok, %{c: intermediate_symbols, params: siop_params, symbol_size: sym_size, k_prime: kp, source_symbols: source_syms}}.

repair(c_syms, params, isi)

Generate one repair symbol for the given ISI.

c_syms is the list of L intermediate symbols. params is the SIOP parameter map produced by encode/2. isi is the encoding symbol ID (any non-negative integer; use ISIs ≥ K' for true repair symbols, or < K' to regenerate source symbols). The symbol size is inferred from c_syms.

Returns the repair symbol as a binary.