<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY rfc5170 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5170.xml"> <!-- ldpc -->
<!ENTITY rfc6363 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6363.xml">
<!ENTITY rfc6364 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6364.xml">
<!ENTITY rfc6726 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6726.xml"> <!-- flute -->
<!ENTITY rfc6816 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6816.xml"> <!-- ldpc-staircase for ff -->
<!ENTITY rfc6865 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6865.xml"> <!-- r-s for ff -->
]>

<?rfc toc="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc rfcedstyle="yes" ?>


<rfc category="std" docName="draft-roca-tsvwg-rlc-fec-scheme-01" ipr="trust200902">

<front>
	<title abbrev="RLC FEC Scheme">The Sliding Window Random Linear Code (RLC) Forward Erasure Correction (FEC) Scheme for FECFRAME</title>

	<author fullname="Vincent Roca" initials="V" surname="Roca">
		<organization>INRIA</organization>
		<address>
		<postal>
			<street></street>
			<city>Grenoble</city>
			<code></code>
			<country>France</country>
		</postal>
		<email>vincent.roca@inria.fr</email>
		</address>
	</author>

<!--
	<author fullname="Belkacem Teibi" initials="B" surname="Teibi">
		<organization>INRIA</organization>
		<address>
		<postal>
			<street></street>
			<city>Grenoble</city>
			<code></code>
			<country>France</country>
		</postal>
		<email>belkacem.teibi@inria.fr</email>
		</address>
	</author>
-->

	<!-- <date month="February" year="2017" /> -->
	<date/>

	<workgroup>TSVWG</workgroup>

	<abstract>
<t>
This document describes a fully-specified FEC scheme for the Sliding Window Random Linear Codes (RLC) over GF(2^^m), where m equals 1 (binary case), 4 or 8,
that can be used to protect arbitrary media streams along the lines defined by FECFRAME extended to sliding window codes.
These sliding window FEC codes rely on an encoding window that slides over the source symbols, generating new repair symbols whenever needed.
Compared to block FEC codes, these sliding window FEC codes offer key advantages with real-time flows in terms of reduced FEC-related latency while often providing improved erasure recovery capabilities.
</t>
	</abstract>

</front>

<middle>

	<section anchor="introduction" title="Introduction">
	<!-- ====================== -->

<t>
Application-Level Forward Erasure Correction (AL-FEC) codes are a key element of communication systems.
They are used to recover from packet losses (or erasures) during content delivery sessions to a large number of receivers (multicast/broadcast transmissions).
This is the case with the FLUTE/ALC protocol <xref target="RFC6726"/> in case of reliable file transfers over lossy networks, and the FECFRAME protocol for reliable continuous media transfers over lossy networks.
</t>

<t>
The present document only focusses on the FECFRAME protocol, used in multicast/broadcast delivery mode, with contents that feature stringent real-time constraints: each source packet has a maximum validity period after which it will not be considered by the destination application.
</t>

		<section anchor="intro:block_codes" title="Limits of Block Codes with Real-Time Flows">
		<!-- ====================== -->

<t>
With FECFRAME, there is a single FEC encoding point (either a end-host/server (source) or a middlebox) and a single FEC decoding point (either a end-host (receiver) or middlebox).
In this context, currently standardized AL-FEC codes for FECFRAME like Reed-Solomon <xref target="RFC6865"/>, LDPC-Staircase <xref target="RFC6816"/>, or Raptor/RaptorQ, are all linear block codes: they require the data flow to be segmented into blocks of a predefined maximum size.
The block size is a balance between robustness (in particular in front of long erasure bursts for which there is an incentive to increase the block size) and maximum decoding latency (for which there is an incentive to decrease the block size).
Therefore, with a multicast/broadcast session, the block code is dimensioned by considering the worst communication channel one wants to support, and this choice impacts all receivers, no matter their individual channel quality.
</t>

		</section>

		<section anchor="intro:conv_codes" title="Lower Latency and Better Protection of Real-Time Flows with the Sliding Window RLC Codes">
		<!-- ====================== -->

<t>
This document introduces a fully-specified FEC scheme that follows a totally different approach: the Sliding Window Random Linear Codes (RLC) over GF(2^^m), where m equals 1, 4 or 8.
This FEC scheme is used to protect arbitrary media streams along the lines defined by FECFRAME extended to sliding window codes <xref target="fecframe-ext"/>.
This FEC scheme is extremely efficient for instance with media that feature real-time constraints sent within a multicast/broadcast session.
</t>

<t>
The RLC codes belong to the broad class of sliding window AL-FEC codes (A.K.A. convolutional codes).
The encoding process is based on an encoding window that slides over the set of source packets (in fact source symbols as we will see in <xref target="CommonProc_adui_creation"/>), and which is either of fixed or variable size (elastic window).
Repair packets (symbols) are generated and sent on-the-fly, after computing a random linear combination of the source symbols present in the current encoding window.
</t>

<t>
At the receiver, a linear system is managed from the set of received source and repair packets.
New variables (representing source symbols) and equations (representing the linear combination of each repair symbol received) are added upon receiving new packets.
Variables are removed when they are too old with respect to their validity period (real-time constraints), as well as the associated equations they are involved in (<xref target="decodingBeyondMaxLatency"/> introduces an optimisation that extends the time a variable is considered in the system).
Erased source symbols are then recovered thanks this linear system whenever its rank permits it.
</t>

<t>
With RLC codes (more generally with sliding window codes), the protection of a multicast/broadcast session also needs to be dimensioned by considering the worst communication channel one wants to support.
However the receivers experiencing a good to medium channel quality observe a FEC-related latency close to zero <xref target="Roca16"/> since an isolated erased source packet is quickly recovered by the following repair packet.
On the opposite, with a block code, recovering an isolated erased source packet always requires waiting the end of the block for the first repair packet to arrive.
Additionally, under certain situations (e.g., with a limited FEC-related latency budget and with constant bit rate transmissions after FECFRAME encoding), sliding window codes achieve more easily a target transmission quality (e.g., measured by the residual loss after FEC decoding) by sending fewer repair packets (i.e., higher code rate) than block codes.
<!-- <xref target="Roca17"/> -->
</t>

		</section>

		<section anchor="intro:low_tx_overhead" title="Small Transmission Overheads with the Sliding Window RLC FEC Scheme">
		<!-- ====================== -->

<t>
The Sliding Window RLC FEC scheme is designed so as to reduce the transmission overhead.
The main requirement is that each repair packet header must enable a receiver to reconstruct the list of source symbols and the associated random coefficients used during the encoding process.
In order to minimize packet overhead, the set of symbols in the encoding window as well as the set of coefficients over GF(2^^m) used in the linear combination are not individually listed in the repair packet header.
Instead, each FEC repair packet header contains:<list style="symbols">
	<t>the Encoding Symbol Identifier (ESI) of the first source symbol in the encoding window as well as the number of symbols (since this number may vary with a variable size, elastic window).
	These two pieces of information enable each receiver to easily reconstruct the set of source symbols considered during encoding, the only constraint being that there cannot be any gap;</t>
	<t>the seed used by a coding coefficients generation function (<xref target="CommonProc_coef_generation_func"/>).
	This information enables each receiver to generate the same set of coding coefficients over GF(2^^m) as the sender;</t>
</list>
</t>

<t>
Therefore, no matter the number of source symbols present in the encoding window, each FEC repair packet features a fixed 64-bit long header, called Repair FEC Payload ID (<xref target="fig_repair_fpi"/>).
Similarly, each FEC source packet features a fixed 32-bit long trailer, called Explicit Source FEC Payload ID (<xref target="fig_src_fpi"/>), that contains the ESI of the first source symbol (see the ADUI and source symbol mapping, <xref target="CommonProc_adui_creation"/>).
</t>

		</section>

		<section title="Document Organization">
		<!-- ====================== -->
<t>
This fully-specified FEC scheme follows the structure required by <xref target="RFC6363"/>, section 5.6. "FEC Scheme Requirements", namely:
<list style="hanging">
<t hangText="3. Procedures:">
	This section describes procedures specific to this FEC scheme, namely: RLC parameters derivation, ADUI and source symbols mapping, pseudo-random number generator, and coding coefficients generation function;</t>
<t hangText="4. Formats and Codes:">
	This section defines the Source FEC Payload ID and Repair FEC Payload ID formats, carrying the signalling information associated to each source or repair symbol.
	It also defines the FEC Framework Configuration Information (FFCI) carrying signalling information for the session;</t>
<t hangText="5. FEC Code Specification:">
	Finally this section provides the code specification.</t>
</list>
</t>

		</section>

	</section>


	<section anchor="definitionsAndAbbreviations" title="Definitions and Abbreviations">
	<!-- ====================== -->

<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <xref target="RFC2119"/>.
</t>


<t>This document uses the following definitions and abbreviations: <list style="hanging">
<t hangText="GF(q)">		denotes a finite field (also known as the Galois Field) with q elements.
				We assume that q = 2^^m in this document</t>
<t hangText="m">		defines the length of the elements in the finite field, in bits.
				In this document, m is equal to 1, 4 or 8</t>
<t hangText="ADU:">		Application Data Unit</t>
<t hangText="ADUI:">		Application Data Unit Information (includes the F, L and padding fields in addition to the ADU)</t>
<t hangText="E:">		encoding symbol size (i.e., source or repair symbol), assumed fixed (in bytes)</t>
<t hangText="br_out:">		transmission bitrate at the output of the FECFRAME sender, assumed fixed (in bits/s)</t>
<t hangText="max_lat:"> 	maximum FEC-related latency within FECFRAME (in seconds)</t>
<t hangText="cr:">		AL-FEC coding rate</t>
<t hangText="plr:">		packet loss rate on the erasure channel</t>
<t hangText="ew_size:">		encoding window current size at a sender (in symbols)</t>
<t hangText="ew_max_size:">	encoding window maximum size at a sender (in symbols)</t>
<t hangText="dw_size:">		decoding window current size at a receiver (in symbols)</t>
<t hangText="dw_max_size:">	decoding window maximum size at a receiver (in symbols)</t>
<t hangText="ls_max_size:">	linear system maximum size (or width) at a receiver (in symbols)</t>
<t hangText="ls_size:">		linear system current size (or width) at a receiver (in symbols)</t>

<t hangText="PRNG:">		pseudo-random number generator</t>
<t hangText="pmms_rand(maxv):">	PRNG defined in <xref target="CommonProc_prng"/> and used in this
				specification, that returns a new random integer in [0; maxv-1]</t>
</list></t>

	</section>


<!-- =========================================================================================== -->


<!-- <section anchor="CommonProcedures" title="Common Procedures Related to the Encoding Window Creation"> -->
<section anchor="CommonProcedures" title="Procedures">
<!-- ================ -->
<t>
This section introduces the procedures that are used by this FEC scheme.
</t>

		<section anchor="CommonProc_rlcParametersDerivation" title="Parameters Derivation">
		<!-- ====================== -->

<t>
The Sliding Window RLC FEC Scheme relies on several key internal parameters:
<list style="hanging">
	<t hangText="Maximum FEC-related latency budget, max_lat (in seconds)">
			A source ADU flow can have real-time constraints, and therefore any FECFRAME related operation must take place within the validity period of each ADU.
			When there are multiple flows with different real-time constraints, we consider the most stringent constraints (see <xref target="RFC6363"/>,
			Section 10.2, item 6, for recommendations when several flows are globally protected).
			This maximum FEC-related latency accounts for all sources of latency added by FEC encoding (sender) and FEC decoding (receiver).
			Other sources of latency (e.g., added by network communications) are out of scope and must be considered separately (e.g., they have already been deducted).
			It can be regarded as the latency budget permitted for all FEC-related operations.
			This is also an input parameter that enables to derive other internal parameters;
			</t>

	<t hangText="Encoding window current (resp. maximum) size, ew_size (resp. ew_max_size) (in symbols):">
			these parameters are used by a sender during FEC encoding.
			More precisely, each repair symbol is a linear combination of the ew_size source symbols present in the encoding window when RLC encoding took place.
			In all situations, we MUST have ew_size &le; ew_max_size;</t>

	<t hangText="Decoding window current (resp. maximum) size, dw_size (resp. dw_max_size) (in symbols):">
			these parameters are used by a receiver when managing the linear system used for decoding.
			dw_size is the current size of the decoding window, i.e., the set of received or erased source symbols that are currently part of the linear system.
			In all situations, we MUST have dw_size &le; dw_max_size;</t>
</list>
</t>

<!--
Each time the decoding window slides by a certain number of source symbols to the right, the same number of old source symbols MUST be removed from the left.
An equation of this linear system cannot include source symbols that extend beyond this decoding window, and moving the window to the right can trigger the removal of equations from the linear system;</t>
-->

<t>
In order to comply with the maximum FEC-related latency budget, assuming a constant transmission bitrate at the output of the FECFRAME sender (br_out), encoding symbol size (E), and code rate (cr), we have:
<list style="none">
	<t> dw_max_size = (max_lat * br_out * cr) / (8 * E) </t>
</list>
This dw_max_size defines the maximum delay after which an old source symbol may be recovered: after this delay, this old source symbol symbol will be removed from the decoding window.
</t>

<t>
It is often good practice to choose:
<list style="none">
	<t> ew_max_size = dw_max_size / 2 </t>
</list>
However any value ew_max_size &lt; dw_max_size can be used without impact on the FEC-related latency budget.
Finding the optimal value can depend on the erasure channel one wants to support and should be determined after simulations or field trials.
</t>

<t>
Note that the decoding beyond maximum latency optimisation (<xref target="decodingBeyondMaxLatency"/>) enables an old source symbol to be kept in the linear system beyond the FEC-related latency budget, but not delivered to the receiving application.
Here we have: ls_size &ge; dw_max_size
</t>


		</section>
	<section anchor="CommonProc_adui_creation" title="ADU, ADUI and Source Symbols Mappings">
	<!-- ==================================== -->

<t>
An ADU, coming from the application, cannot be mapped to source symbols directly.
Indeed, an erased ADU recovered at a receiver must contain enough information to be assigned to the right application flow
(UDP port numbers and IP addresses cannot be used to that purpose as they are not protected by FEC encoding).
This requires adding the flow identifier to each ADU before doing FEC encoding.
</t>

<t>
Additionally, since ADUs are of variable size, padding is needed so that each ADU (with its flow identifier) contribute
to an integral number of source symbols.
This requires adding the original ADU length to each ADU before doing FEC encoding.
Because of these requirements, an intermediate format, the ADUI, or ADU Information, is considered <xref target="RFC6363"/>.
</t>

<t>
For each incoming ADU, an ADUI is created as follows.
First of all, 3 bytes are prepended:
(<xref target="fig_adui_creation"/>):
<list style="hanging">
<t hangText="Flow ID (F) (8-bit field):">
	this unsigned byte contains the integer identifier associated to the source ADU flow to which this ADU belongs.
	It is assumed that a single byte is sufficient, which implies that no more than 256 flows will be protected by
	a single FECFRAME instance.</t>

<t hangText="Length (L) (16-bit field):">
	this unsigned integer contains the length of this ADU, in network byte order (i.e., big endian).
	This length is for the ADU itself and does not include the F, L, or Pad fields.
	</t>
</list>
</t>

<t>
Then, zero padding is added to the ADU if needed:
<list style="hanging">
<t hangText="Padding (Pad) (variable size field):">
	this field contains zero padding to  align the F, L, ADU and padding 
	up to a size that is multiple of E bytes (i.e., the source and repair symbol length).
	</t>
</list>
Each ADUI contributes to an integral number of source symbols.
The data unit resulting from the ADU and the F, L, and Pad fields is called ADU Information (or ADUI).
Since ADUs can be of different size, this is also the case for ADUIs.
</t>


<figure anchor="fig_adui_creation" title="ADUI Creation example (here 3 source symbols are created for this ADUI).">
        <artwork><![CDATA[
   symbol length, E              E                     E
< ------------------ >< ------------------ >< ------------------ >
+-+--+---------------------------------------------+-------------+
|F| L|                     ADU                     |     Pad     |
+-+--+---------------------------------------------+-------------+]]></artwork>
</figure>

<t>
Note that neither the initial 3 bytes nor the optional padding are sent over the network.
However, they are considered during FEC encoding.
It means that a receiver who lost a certain FEC source packet (e.g., the UDP datagram containing this FEC source packet) will be able
to recover the ADUI if FEC decoding succeeds.
Thanks to the initial 3 bytes, this receiver will get rid of the padding (if any) and identify the corresponding ADU flow.
</t>

	</section>


	<section anchor="encodingWindowManagement" title="Encoding Window Management">
	<!-- ====================== -->

<t>
Source symbols and the corresponding ADUs are removed from the encoding window:
<list style="symbols">
	<t> when the sliding encoding window has reached its maximum size, ew_max_size.
	In that case the oldest symbol MUST be removed before adding a new symbol, so that the current encoding window size always
	remains inferior or equal to the maximum size: ew_size &le; ew_max_size;</t>

	<t> when an ADU has reached its maximum validity duration in case of a real-time flow.
	When this happens, all source symbols corresponding to the ADUI that expired SHOULD be removed from the encoding window; </t>
</list>
</t>

<t>
Source symbols are added to the sliding encoding window each time a new ADU arrives, once the ADU to ADUI and then to source symbols
mapping has been performed (<xref target="CommonProc_adui_creation"/>).
The current size of the encoding window, ew_size, is updated after adding new source symbols.
This process may require to remove old source symbols so that: ew_size &le; ew_max_size.
</t>


<t>
Note that a FEC codec may feature practical limits in the number of source symbols in the encoding window (e.g., for computational complexity reasons).
This factor may further limit the ew_max_lat value, in addition to the maximum FEC-related latency budget (<xref target="CommonProc_rlcParametersDerivation"/>).
</t>

<!--
<t>
Limitations MAY exist that impact the encoding window management. For instance:
<list style="symbols">
<t> at the FEC Framework level: the source flows can have real-time constraints that limit the number of ADUs in the encoding window;</t>
<t> at the FEC scheme level: there may be theoretical or practical limitations (e.g., because of computational complexity aspect or field size limits in the signalling headers) that limit the number of ADUs in the encoding window.</t>
</list>
The most stringent limitation defines the maximum encoding window size, either in terms of number of source symbols or number of ADUs, whichever applies.
</t>
-->

	</section>


	<section  anchor="CommonProc_prng" title="Pseudo-Random Number Generator">
	<!-- ======================================= -->

<t>
The RLC codes rely on the following Pseudo-Random Number Generator (PRNG), identical to
the PRNG used with LDPC-Staircase codes (<xref target="RFC5170"/>, section 5.7).
</t>

<t>
The Park-Miler "minimal standard" PRNG <xref target="PM88"/> MUST be used.
It defines a simple multiplicative congruential algorithm: Ij+1 = A * Ij
(modulo M), with the following choices: A = 7^^5 = 16807 and
M = 2^^31 - 1 = 2147483647.
A validation criteria of such a PRNG is the following:
if seed = 1, then the 10,000th value returned MUST be equal to 1043618065.
</t>

<t>
Several implementations of this PRNG are known and discussed in the literature.
An optimized implementation of this algorithm, using only
32-bit mathematics, and which does not require any division,
can be found in <xref target="rand31pmc"/>.
It uses the Park and Miller algorithm <xref target="PM88"/> with the
optimization suggested by D. Carta in <xref target="CA90"/>.
The history behind this algorithm is detailed in <xref target="WI08"/>.
Yet, any other implementation of the PRNG algorithm that matches the above validation
criteria, like the ones detailed in <xref target="PM88"/>, is appropriate.
</t>

<t>
This PRNG produces, natively, a 31-bit value between 1 and 0x7FFFFFFE (2^^31-2) inclusive.
Since it is desired to scale the pseudo-random number between 0 and maxv-1
inclusive, one must keep the most significant bits of the value returned by the
PRNG (the least significant bits are known to be less random, and modulo-based
solutions should be avoided <xref target="PTVF92"/>).
The following algorithm MUST be used:
</t>

<t> Input:
<list style="empty">
<t>raw_value:	random integer generated by the inner PRNG algorithm,
		between 1 and 0x7FFFFFFE (2^^31-2) inclusive.</t>
<t>maxv:	upper bound used during the scaling operation.</t>
</list>
Output:
<list style="empty">
<t>scaled_value: random integer between 0 and maxv-1 inclusive.</t>
</list>
Algorithm:
<list style="empty">
	<t>scaled_value = (unsigned long) ((double)maxv * (double)raw_value / (double)0x7FFFFFFF);</t>
	<t>(NB: the above C type casting to unsigned long is equivalent to using floor() with positive
	floating point values.)</t>
</list>
</t>

<t>
In this document, pmms_rand(maxv) denotes the PRNG function that implements the
Park-Miller "minimal standard" algorithm, defined above, and that scales
the raw value between 0 and maxv-1 inclusive, using the above scaling
algorithm.
</t>

<t>
Additionally, the pmms_srand(seed) function must be provided to enable the initialization
of the PRNG with a seed before calling pmms_rand(maxv) the first time.
The seed is a 31-bit integer between 1 and 0x7FFFFFFE inclusive.
In this specification, the seed is restricted to a value between 1 and 0xFFFF inclusive, as this is the
Repair_Key 16-bit field value of the Repair FEC Payload ID (<xref target="ArbitraryFlows_repair_fpi"/>).
</t>

	</section>


	<section anchor="CommonProc_coef_generation_func" title="Coding Coefficients Generation Function">
	<!-- ====================== -->

<t>
The coding coefficients, used during the encoding process, are generated at the RLC encoder by the following function each time a new repair symbol needs to be produced:
</t>

<figure anchor="fig_coef_generation_func" title="Coding Coefficients Generation Function pseudo-code">
        <artwork><![CDATA[
<CODE BEGINS>
/*
 * Fills in the table of coding coefficients (of the right size)
 * provided with the appropriate number of coding coefficients to
 * use for the repair symbol key provided.
 *
 * (in) repair_key    key associated to this repair symbol
 * (in) cc_tab[]      pointer to a table of the right size to store
 *                    coding coefficients. All coefficients are
 *                    stored as bytes, regardless of the m parameter,
 *                    upon return of this function.
 * (in) cc_nb[]       number of entries in the table. This value is
 *                    equal to the current encoding window size.
 * (in) m             Finite Field GF(2^^m) parameter.
 * (out)              returns an error code
 */
int generate_coding_coefficients (UINT16    repair_key,
                                  UINT8     cc_tab[],
                                  UINT16    cc_nb,
                                  UINT8     m)
{
    UINT32    i;

    if (repair_key == 0) {
        return SOMETHING_WENT_WRONG;
    }
    pmms_srand(repair_key);
    if (m == 1) {
        /* 0 is a valid coefficient value in binary GF */
        for (i = 0 ; i < cc_nb ; i ++) {
            cc_tab[i] = (UINT8) pmms_rand(2);
        }
    } else {
        /* coefficient 0 is avoided in non-binary GF to consider each
         * source symbol */
        UINT32    maxv;
        maxv = get_gf_size(); /* i.e., 16 if m=4 or 256 if m=8 */
        for (i = 0 ; i < cc_nb ; i ++) {
            do {
                cc_tab[i] = (UINT8) pmms_rand(maxv);
            } while (cc_tab[i] == 0)
        }
    }
    return EVERYTHING_IS_OKAY;
}
<CODE ENDS>
]]></artwork>
</figure>

	</section>


</section>


<section anchor="ArbitraryFlows" title="Sliding Window RLC FEC Scheme for Arbitrary ADU Flows">
<!-- ==================================== -->

	<section anchor="ArbitraryFlows_formatsAndCodes" title="Formats and Codes">
	<!-- ==================================== -->

		<section title="FEC Framework Configuration Information">
		<!-- ================ -->
<t>
The FEC Framework Configuration Information (or FFCI) includes information
that MUST be communicated between the sender and receiver(s).
More specifically, it enables the synchronization of the FECFRAME sender
and receiver instances.
It includes both mandatory elements and scheme-specific elements,
as detailed below.
</t>

			<section title="Mandatory Information">
			<!-- ================ -->
<t>
<list style="symbols">
<t>FEC Encoding ID:
	the value assigned to this fully specified FEC scheme MUST be XXXX,
	as assigned by IANA (<xref target="iana"/>).</t>
</list>
</t>

<t>
When SDP is used to communicate the FFCI, this FEC Encoding ID is carried in
the 'encoding-id' parameter.
</t>
			</section>

			<section title="FEC Scheme-Specific Information" anchor="ArbitraryFlows_fssi">
			<!-- ================ -->
<t>
The FEC Scheme-Specific Information (FSSI) includes elements that are specific to the present FEC scheme.
More precisely:
<list style="hanging">
<t hangText="Encoding symbol size (E):">
	a non-negative integer that indicates the size of each encoding symbol in bytes;</t>
<t hangText="m parameter (m):">
	the length of the elements in the finite field, in bits, where m is equal to 1, 4 or 8;</t>
</list>
These elements are required both by the sender (RLC encoder) and the receiver(s) (RLC decoder).
</t>

<t>
When SDP is used to communicate the FFCI, this FEC scheme-specific information is carried in
the 'fssi' parameter in textual representation as specified in <xref target="RFC6364"/>.
For instance:
</t>
<t>
fssi=E:1400,m:8
</t>

<t>
If another mechanism requires the FSSI to be carried as an opaque octet string
(for instance, after a Base64 encoding), the encoding format consists of the following 2 octets:
<list style="hanging">
    <t> Encoding symbol length (E): 16-bit field.</t>
    <t> m parameter (m): 8-bit field.</t>
</list>
</t>
<figure anchor="fig_ArbitraryFlows_fssi_binary" title="FSSI Encoding Format"> 
  <artwork>
 0                   1                   2
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Encoding Symbol Length (E)  |       m       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  </artwork>
</figure>

			</section>

		</section>


		<section anchor="ArbitraryFlows_src_fpi" title="Explicit Source FEC Payload ID">
		<!-- ================ -->

<t>
A FEC source packet MUST contain an Explicit Source FEC Payload ID that is appended to the
end of the packet as illustrated in <xref target="fig_src_pkt_format"/>.
</t>

<figure anchor="fig_src_pkt_format" title="Structure of an FEC Source Packet with the
Explicit Source FEC Payload ID"> 
  <artwork>
+--------------------------------+
|           IP Header            |
+--------------------------------+
|        Transport Header        |
+--------------------------------+
|              ADU               |
+--------------------------------+
| Explicit Source FEC Payload ID |
+--------------------------------+
  </artwork>
</figure>

<t>
More precisely, the Explicit Source FEC Payload ID is composed of the following field
(<xref target="fig_src_fpi"/>):
<list style="hanging">
	<t hangText="Encoding Symbol ID (ESI) (32-bit field):">
		this unsigned integer identifies the first source symbol of the ADUI corresponding to this FEC source packet.
		The ESI is incremented for each new source symbol, and after reaching the maximum value
		(2^32-1), wrapping to zero occurs.
		</t>
</list></t>

<figure anchor="fig_src_fpi" title="Source FEC Payload ID Encoding Format"> 
  <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Encoding Symbol ID (ESI)                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  </artwork>
</figure>

		</section>

		<section anchor="ArbitraryFlows_repair_fpi" title="Repair FEC Payload ID">
		<!-- ================ -->

<t>
A FEC repair packet MUST contain a Repair FEC Payload ID that is prepended to the
repair symbol as illustrated in <xref target="fig_repair_pkt_format"/>.
There can be one or more repair symbol per FEC repair packet.
When this is the case, the number of repair symbols within this FEC repair packet is easily deduced by
comparing the known received FEC repair packet size (equal to the UDP payload size when UDP is the underlying
transport protocol) and the symbol size, E, communicated in the FFCI.
</t>

<figure anchor="fig_repair_pkt_format" title="Structure of an FEC Repair Packet with the Repair FEC Payload ID"> 
  <artwork>
+--------------------------------+
|           IP Header            |
+--------------------------------+
|        Transport Header        |
+--------------------------------+
|     Repair FEC Payload ID      |
+--------------------------------+
|         Repair Symbol          |
+--------------------------------+
  </artwork>
</figure>

<t>
More precisely, the Repair FEC Payload ID is composed of the following fields (<xref target="fig_repair_fpi"/>):
<list style="hanging">
<t hangText="Repair_Key (16-bit field):">
	this unsigned integer is used as a seed by the coefficient generation function (<xref target="CommonProc_coef_generation_func"/>)
	in order to generate the desired number of coding coefficients.
	Value 0 MUST NOT be used.
	When a FEC repair packet contains several repair packets, this repair key value is that of the first repair symbol.
	The remaining repair keys can be deduced by incrementing by 1 this value, up to a maximum value of 65535 after which it loops back to 1.</t>

<t hangText="Number of Source Symbols in the Encoding Window, NSS (16-bit field):">
   this unsigned integer indicates the number of source symbols in the encoding window when this repair symbol was generated.</t>

<t hangText="ESI of first source symbol in encoding window, FSS_ESI (32-bit field):">
    this unsigned integer indicates the ESI of the first source symbol in the encoding window when this repair symbol was generated.</t>
</list>
</t>

<figure anchor="fig_repair_fpi" title="Repair FEC Payload ID Encoding Format">
  <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       Repair_Key              |  NSS (# source symbols in ew) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            FSS_ESI                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  </artwork>
</figure>

		</section>

		<section anchor="ArbitraryFlows_Procedures" title="Additional Procedures">
		<!-- ================ -->
<t>
The following procedure applies:

<list style="symbols">
	<t>
	The ESI of source symbols MUST start with value 0 for the first source symbol and
	MUST be managed sequentially.
	Wrapping to zero will happen after reaching the maximum 32-bit value.
	</t>
</list>
</t>

		</section>

	</section> <!-- ArbitraryFlows_formatsAndCodes -->


</section> <!-- ArbitraryFlows -->


	<section anchor="ArbitraryFlows_FECCodeSpecification" title="FEC Code Specification">
	<!-- ================ -->

		<section anchor="ArbitraryFlows_FECCodeSpecification_encoding" title="Encoding Side">
		<!-- ================ -->

<t>
This section provides a high level description of a Sliding Window RLC encoder.
</t>

<t>
Whenever a new FEC repair packet is needed, the RLC encoder instance first gathers the ew_size source symbols currently in the sliding encoding window. 
Then it chooses a repair key, which can be a non zero monotonically increasing integer value, incremented for each repair symbol up to a maximum
value of 65535 (as it is carried within a 16-bit field) after which it loops back to 1 (indeed, being used as a PRNG seed, value 0 is prohibited).
This repair key is communicated to the coefficient generation function (Section <xref target="CommonProc_coef_generation_func"/>) in order to generate
ew_size coding coefficients.
Finally, the FECFRAME sender computes the repair symbol as a linear combination of the ew_size source symbols using the ew_size coding coefficients.
When E is small and when there is an incentive to pack several repair symbols within the same FEC Repair Packet, the appropriate number of repair symbols
are computed.
The only constraint is to increment by 1 the repair key for each of them, keeping the same ew_size source symbols, since only the first repair key will
be carried in the Repair FEC Payload ID.
The FEC repair packet can then be sent.
The source versus repair FEC packet transmission order is out of scope of this document and several approaches exist that are implementation specific.
</t>

		</section>


		<section anchor="ArbitraryFlows_FECCodeSpecification_decoding" title="Decoding Side">
		<!-- ================ -->

<t>
This section provides a high level description of a Sliding Window RLC decoder.
</t>

<t>
A FECFRAME receiver needs to maintain a linear system whose variables are the received and lost source symbols.
Upon receiving a FEC repair packet, a receiver first extracts all the repair symbols it contains (in case several repair symbols are packed together).
For each repair symbol, when at least one of the corresponding source symbols it protects has been lost, the receiver adds an equation to the linear system
(or no equation if this repair packet does not change the linear system rank).
This equation of course re-uses the ew_size coding coefficients that are computed by the same coefficient generation function
(Section <xref target="CommonProc_coef_generation_func"/>), using the repair key and encoding window descriptions carried in the Repair FEC Payload ID.
Whenever possible (i.e., when a sub-system covering one or more lost source symbols is of full rank), decoding is performed in order to recover
lost source symbols.
Each time an ADUI can be totally recovered, it is assigned to the corresponding application flow (thanks to the Flow ID (F) field of the ADUI) and padding
(if any) removed (thanks to the Length (L) field of the ADUI).
This ADU is finally passed to the corresponding upper application.
Received FEC source packets, containing an ADU, can be passed to the application either immediately or after some time to guaranty an ordered delivery to
the application(s). 
This document does not mandate any approach as this is an operational and management decision.
</t>

<t>
With real-time flows, a lost ADU that is decoded after the maximum latency (or an ADU received far too late) should not be considered by the application.
Instead the associated source symbols should be removed from the linear system maintained by the receiver(s).
<xref target="decodingBeyondMaxLatency"/> discusses a backward compatible optimization whereby those late source symbols may still be useful to improve
the global loss recovery performance.
</t>

		</section>

	</section>


	<section anchor="implementationStatus" title="Implementation Status">
	<!-- ====================== -->

<t>
Editor's notes: RFC Editor, please remove this section motivated by RFC 6982 before publishing the RFC. Thanks.
</t>

<t>An implementation of the Sliding Window RLC FEC Scheme for FECFRAME exists:
<list style="symbols">
	<t>Organisation: Inria</t>
	<t>Description: This is an implementation of the Sliding Window RLC FEC Scheme.
	It relies on a modified version of our OpenFEC (http://openfec.org) FEC code library.
	It is integrated in our FECFRAME software (see <xref target="fecframe-ext"/>).</t>
	<t>Maturity: prototype.</t>
	<t>Coverage: this software complies with the Sliding Window RLC FEC Scheme (limited to m=8 as of June, 2017).</t>
	<t>Lincensing: proprietary.</t>
	<t>Contact: vincent.roca@inria.fr</t>
</list></t>

	</section>


<!-- =========================================================================================== -->

	<section anchor="SecurityConsiderations" title="Security Considerations">
	<!-- ====================== -->

<t>
The FEC Framework document <xref target="RFC6363"/> provides a comprehensive
analysis of security considerations applicable to FEC schemes.
Therefore, the present section follows the security considerations section of
<xref target="RFC6363"/> and only discusses specific topics.
</t>

		<section title="Attacks Against the Data Flow">
		<!-- ====================== -->

			<section title="Access to Confidential Content">
			<!-- ====================== -->

<t>The Sliding Window RLC FEC Scheme specified in this document does not change the
recommendations of <xref target="RFC6363"/>.
To summarize, if confidentiality is a concern, it is RECOMMENDED that one of the
solutions mentioned in <xref target="RFC6363"/> is used with special
considerations to the way this solution is applied (e.g., is encryption applied
before or after FEC protection, within the end-system or in a middlebox) to the operational 
constraints (e.g., performing FEC decoding in a protected environment may be
complicated or even impossible) and to the threat model.
</t>

			</section>

			<section title="Content Corruption" anchor="sec_content_corruption">
			<!-- ====================== -->

<t>The Sliding Window RLC FEC Scheme specified in this document does not change the
recommendations of <xref target="RFC6363"/>.
To summarize, it is RECOMMENDED that one of the solutions mentioned in
<xref target="RFC6363"/> is used on both the FEC Source and Repair Packets.  
</t>

			</section>

		</section>

		<section title="Attacks Against the FEC Parameters">
		<!-- ====================== -->

<t>
The FEC Scheme specified in this document defines parameters that
can be the basis of attacks.
More specifically, the following parameters of the FFCI may be modified
by an attacker who only targets receivers (<xref target="ArbitraryFlows_fssi"/>):
<list style="symbols">
	<t>FEC Encoding ID:
		changing this parameter leads the receivers to consider a different
		FEC Scheme, which enables an attacker to create a Denial of Service (DoS);
	</t>
	<t>Encoding symbol length (E):
		setting this E parameter to a different value will confuse the receivers
		and create a DoS. More precisely, the FEC Repair Packets received
		will probably no longer be multiple of E, leading receivers to reject them;
	</t>
	<t>m parameter:
		changing this parameter triggers a DoS since the receivers will generate
		a different set of coding coefficients.
		The recovered source symbols (and thereafter ADUs) will be corrupted.
	</t>
</list>
An attacker who only targets a sender will achieve the same results.
However if the attacker targets both sender and receivers at the same time (the same wrong
piece of information is communicated to everybody), the results will be suboptimal but less
severe.
</t>

<t>
It is therefore RECOMMENDED that security measures are taken to
guarantee the FFCI integrity, as specified in <xref target="RFC6363"/>.
How to achieve this depends on the way the FFCI is communicated from the sender
to the receiver, which is not specified in this document.
</t>

<t>
Similarly, attacks are possible against the Explicit Source FEC Payload ID
and Repair FEC Payload ID: by modifying the Encoding Symbol ID (ESI), or the
repair key, NSS or FSS_ESI.
It is therefore RECOMMENDED that security measures are taken to guarantee the
FEC Source and Repair Packets as stated in <xref target="RFC6363"/>.
</t>

		</section>

		<section title="When Several Source Flows are to be Protected Together">
		<!-- ====================== -->

<t>The Sliding Window RLC FEC Scheme specified in this document does not change the
recommendations of <xref target="RFC6363"/>.</t>

		</section>

		<section title="Baseline Secure FEC Framework Operation">
		<!-- ====================== -->

<t>The Sliding Window RLC FEC Scheme specified in this document does not change the
recommendations of <xref target="RFC6363"/> concerning the use of
the IPsec/ESP security protocol as a mandatory to implement (but not mandatory
to use) security scheme.
This is well suited to situations where the only insecure domain is the one
over which the FEC Framework operates.
</t>

		</section>

	</section>

	<section title="Operations and Management Considerations">
	<!-- ====================== -->

<t>
The FEC Framework document <xref target="RFC6363"/> provides a comprehensive
analysis of operations and management considerations applicable to FEC schemes.
Therefore, the present section only discusses specific topics.
</t>


		<section title="Operational Recommendations: Finite Field Element Size (m Parameter)">
		<!-- ================ -->

<t>
The present document requires that m equals 1 (binary case), 4 or 8.
It is expected that m&nbsp;=&nbsp;8 will be mostly used since it warrants a high loss protection.
Additionally, elements in the finite field are 8 bits long, which makes
read/write memory operations aligned on bytes during encoding and decoding.
</t>

<t>
An alternative when one can accommodate a lower loss protection is m&nbsp;=&nbsp;4.
Elements in the finite field are 4 bits long, so if 2 elements are accessed at a time,
read/write memory operations are aligned on bytes during encoding and decoding.
</t>

<t>
Finally, in particular when dealing with large encoding windows, an alternative
is m&nbsp;=&nbsp;1.
In that case operations symbols can be directly XORed together which warrants high bitrate
encoding and decoding operations.
</t>

<t> 
Since several values for the m parameter are possible, the use case SHOULD define which
value or values need to be supported.
In any case, any compliant implementation MUST support at least the default m = 8 value.
</t>

		</section>

	</section>


	<section anchor="iana" title="IANA Considerations">
	<!-- ====================== -->

<t>
This document registers one value in the "FEC Framework (FECFRAME)
FEC Encoding IDs" registry <xref target="RFC6363"/> as follows:
<list style="symbols">
        <t>XXX refers to the Sliding Window Random Linear Codes (RLC) FEC Scheme for Arbitrary Packet Flows, as defined in Section XXX of this document.</t>
</list>
</t>

	</section>

	<section title="Acknowledgments">
	<!-- ====================== -->

<t>
The authors would like to thank Belkacem Teibi (Inria) who in particular implemented the RLC codec.
The author would also like to thank Marie-Jose Montpetit for her valuable feedbacks on this document.
</t>

	</section>

</middle>

<back>
	<references title="Normative References">
	<!-- ====================== -->
	&rfc2119;

	&rfc6363;
	&rfc6364;

	<reference anchor="fecframe-ext" target="https://tools.ietf.org/html/draft-roca-tsvwg-fecframev2">
		<front>
			<title>Forward Error Correction (FEC) Framework Extension to Sliding Window Codes</title>
			<author initials='V.' surname='Roca'>  <organization /> </author>
			<author initials='A.' surname='Begen'> <organization /> </author>
			<date month="June" year="2017" />
		</front>
		<seriesInfo name='Transport Area Working Group (TSVWG)' value='draft-roca-tsvwg-fecframev2 (Work in Progress)' />
	</reference>

	</references>

	<references title="Informative References">

	&rfc5170;
	&rfc6726;
	&rfc6816;	<!-- ldpc-staircase for ff -->
	&rfc6865;	<!-- r-s for ff -->

	<reference anchor="Roca16" target=" https://hal.inria.fr/hal-01395937/en/">
		<front>
			<title>Block or Convolutional AL-FEC Codes? A Performance Comparison for Robust Low-Latency Communications</title>
			<author initials='V.' surname='Roca'>  <organization /> </author>
			<author initials='B.' surname='Teibi'>  <organization /> </author>
			<author initials='C.' surname='Burdinat'>  <organization /> </author>
			<author initials='T.' surname='Tran'>  <organization /> </author>
			<author initials='C.' surname='Thienot'>  <organization /> </author>
			<date month="November" year="2016" />
		</front>
		<seriesInfo name='Submitted for publication' value='https://hal.inria.fr/hal-01395937/en/' />
	</reference>

<!--
	<reference anchor="Roca17" target=" https://hal.inria.fr/TBD/en/">
		<front>
			<title>Reducing FEC-Related Latency with Convolutional AL-FEC Codes: a Case Study for Robust Low-Latency Multimedia Broadcast Communications</title>
			<author initials='V.' surname='Roca'>  <organization /> </author>
			<author initials='B.' surname='Teibi'>  <organization /> </author>
			<author initials='C.' surname='Burdinat'>  <organization /> </author>
			<author initials='T.' surname='Tran'>  <organization /> </author>
			<author initials='C.' surname='Thienot'>  <organization /> </author>
			<date month="January" year="2017" />
		</front>
		<seriesInfo name='Submitted for publication' value='https://hal.inria.fr/TBD/en/' />
	</reference>
-->

      <reference anchor="PM88">
	<front>
	  <title>Random Number Generators: Good Ones are Hard to Find</title>
          <author initials="S.K." surname="Park">
            <organization />
          </author>
          <author initials="K.W." surname="Miller">
            <organization />
          </author>
          <date month="" year="1988" />
        </front>
        <seriesInfo name="" value="Communications of the ACM, Vol. 31, No. 10, pp.1192-1201" />
      </reference>

      <reference anchor="CA90">
	<front>
	  <title>Two Fast Implementations of the Minimal Standard Random Number Generator</title>
          <author initials="D.G." surname="Carta">
            <organization />
          </author>
          <date month="January" year="1990" />
        </front>
        <seriesInfo name="" value="Communications of the ACM, Vol. 33, No. 1, pp.87-88" />
      </reference>

      <reference anchor="WI08" target="http://www.firstpr.com.au/dsp/rand31/">
	<front>
	  <title>Park-Miller-Carta Pseudo-Random Number Generator</title>
          <author initials="R." surname="Whittle">
            <organization />
          </author>
          <date month="January" year="2008" />
        </front>
        <seriesInfo name="" value="http://www.firstpr.com.au/dsp/rand31/" />
      </reference>

      <reference anchor="rand31pmc" target="http://www.firstpr.com.au/dsp/rand31/rand31-park-miller-carta.cc.txt">
	<front>
	  <title>31 bit pseudo-random number generator</title>
          <author initials="R." surname="Whittle">
            <organization />
          </author>
          <date month="September" year="2005" />
        </front>
      </reference>

      <reference anchor="PTVF92">
	<front>
	  <title>Numerical Recipies in C; Second Edition</title>
          <author initials="W." surname="Press"> <organization /> </author>
          <author initials="S." surname="Teukolsky"> <organization /> </author>
          <author initials="W." surname="Vetterling"> <organization /> </author>
          <author initials="B." surname="Flannery"> <organization /> </author>
          <date year="1992" />
        </front>
        <seriesInfo name="Cambridge University Press," value="ISBN: 0-521-43108-5" />
      </reference>

	</references>


	<section anchor="decodingBeyondMaxLatency" title="Decoding Beyond Maximum Latency Optimization">
	<!-- ====================== -->

<t>
This annex introduces non normative considerations.
They are provided as suggestions, without any impact on interoperability.
For more information see <xref target="Roca16"/>.
</t>

<t>
It is possible to improve the decoding performance of sliding window codes without impacting maximum latency, at the cost of extra CPU overhead.
The optimization consists, for a receiver, to extend the linear system beyond the decoding window:
<list style="none">
	<t> ls_max_size > dw_max_size </t>
</list>
Usually the following choice is a good trade-off between decoding performance and extra CPU overhead:
<list style="none">
	<t> ls_max_size = 2 * dw_max_size </t>
</list>
</t>

<figure anchor="fig_decoding_beyond_max_laetency" title="Relationship between parameters to decode beyond maximum latency."> 
  <artwork>
                             ls_max_size
/---------------------------------^-------------------------------\

        late source symbols
 (pot. decoded but not delivered)            dw_max_size
/--------------^-----------------\ /--------------^---------------\
src0 src1 src2 src3 src4 src5 src6 src7 src8 src9 src10 src11 src12
  </artwork>
</figure>

<t>
It means that source symbols (and therefore ADUs) may be decoded even if their transport protocol added latency exceeds the maximum value permitted by the application.
It follows that these source symbols SHOULD NOT be delivered to the application and SHOULD be dropped once they are no longer needed.
However, decoding these late symbols significantly improves the global robustness in bad reception conditions and is therefore recommended for receivers experiencing bad channels<xref target="Roca16"/>.
In any case whether or not to use this facility and what exact value to use for the ls_max_size parameter are decisions made by each receiver independently, without any impact on others, neither the other receivers nor the source.
</t>

	</section>


</back>
</rfc>
