3.1.1.6.3 FEC Decoding
An FEC decoding operation is the reverse of the FEC encoding (section 3.1.1.6.2) operation. The FEC decoding operation solves the linear equation that is used to recover the lost Source Packets. Each FEC Packet can be used to recover only one Source Packet in the range covered by that FEC Packet.
To decode, or recover a missing datagram using FEC, the following matrix is constructed where packet F1 is the FEC block for Source Packets S1 – Sn.
For simplicity, assume n=5. If packet S4 is missing, it can be recovered by using the following matrix operation.

Figure 11: Matrix operation for FEC decoding
Here, matrix S’ contains an unknown term (S4) that needs to be computed. This can be done by converting Cd to an identity matrix using the Gauss-Jordan elimination. For more details on the Gauss-Jordan elimination, see [Press] section 2.1.
Not all matrices have an inverse, and in some cases, Cd’ doesn’t exist. For such operations, the FEC Packet cannot be used to recover from that particular Source Packet. Thus, not all FEC operations are reversible, and not being able to decode a FEC Packet is not fatal. The missing Source Packet is always retransmitted in RDP-UDP-R mode (section 3.1.1.7), and can be ignored for RDP-UDP-L mode (section 3.1.1.7).
Pseudo-code example:
-
// Regenerate Coefficient array from fecIndex. // RegenerateCoeffArrayFromFecIndex(CoEfficientArray, 5, fecIndex, 1, 5); // // Compute the missing packet (S3) by inverting the matrix. // This is the algebraic equivalent // of a matrix inverse. // for (int i = 0; i < 22; i++) { printf("%d ", Div(Mul(CoEfficientArray[0], S1.m_pbPacket[i]) ^ Mul(CoEfficientArray[1], S2.m_pbPacket[i]) ^ Mul(CoEfficientArray[3], S4.m_pbPacket[i]) ^ Mul(CoEfficientArray[4], S5.m_pbPacket[i]) ^ F15.m_pbPacket[i],CoEfficientArray[2])); } printf("\n");