Librecast RaptorQ FEC Library (lcrq)

IP Multicast is based on UDP, which is inherently unreliable. Packets may arrive out of order, or not at all. TCP provides unicast with a reliable messaging layer on top of this unreliable, connectionless medium.

Unicast, however, is one-to-one only. Multicast could, in theory, use all of the same reliability options (ACKs etc.) as TCP, at the cost of not being scalable any more.

Fortunately there are other ways to achieve similar reliability. RFC3208 describes Pragmatic General Multicast (PGM) based on NAKs (negative acknowledgements). This, too, has scaling issues.

Forward Error Correction (FEC) offers us another approach.

Thanks to parity checking in the network stack, we don't generally need to worry about errors within packets. Every packet has a checksum, and if that doesn't match, the packet is dropped before it reaches us. Our encryption provides further checking of data received. We need only concern ourselves with erasures. ie. dropped packets.

RaptorQ (RFC6330) is an implementation of a class of systematic erasure codes called fountain codes.

The data we want to send is split into blocks, and then pre-encoded into a set of intermediate symbols. From these intermediate symbols we can generate both our original source symbols, and also additional repair symbols.

Provided the recipient receives at least a minimum value K' of these symbols (any unique combination of source and repair) the intermediate symbols can be reconstituted, and the original data recovered.

RaptorQ is what is called a systematic encoding, because the set of symbols we send includes our original data as plain text. Provided all source symbols are received, the original data has been transmitted with no decoding overhead. It is only in the case where we need to supplement the source symbols with repair symbols that we must perform the decoding process.

Support for LCRQ is integrated into the Librecast library. Enabling FEC with RaptorQ is a matter of turning on this encoding with lc_channel_coding_set(3).

Code

Code is available on Codeberg.

Coverity Scan Build Status

Packaging status

Debian

Alternatively, on Debian you can install the library from Debian with `apt install liblcrq`. To get the development package use `apt install liblcrq-dev`. lcrq is available for all supported Debian architectures (and quite a few others).

License

GPLv2 or (at your option) GPLv3