<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent"> <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> <rfc xmlns:xi="http://www.w3.org/2001/XInclude" number="8854" docName="draft-ietf-rtcweb-fec-10" submissionType="IETF" consensus="true" category="std" ipr="trust200902" obsoletes="" updates="" sortRefs="true" symRefs="true" tocInclude="true" xml:lang="en" version="3"> <front> <title abbrev="WebRTC FEC">WebRTC Forward Error Correction Requirements</title> <seriesInfo name="RFC" value="8854"/> <author fullname="Justin Uberti" initials="J." surname="Uberti"> <organization>Google</organization> <address> <postal> <street>747 6th St S</street> <city>Kirkland</city> <region>WA</region> <code>98033</code> <country>United States of America</country> </postal> <email>justin@uberti.name</email> </address> </author> <date year="2020" month="May"/> <area>RAI</area> <keyword>RTP</keyword> <keyword>FEC</keyword> <abstract> <t>This document provides information and requirements for the use of Forward Error Correction (FEC) by WebRTC implementations.</t> </abstract> </front> <middle> <section numbered="true" toc="default"> <name>Introduction</name> <t>In situations where packet loss is high, or perfect media quality is essential, Forward Error Correction (FEC) can be used to proactively recover from packet losses. This specification provides guidance on which FEC mechanisms to use, and how to use them, for WebRTC implementations.</t> </section> <section numbered="true" toc="default"> <name>Terminology</name> <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t> </section> <section numbered="true" toc="default"> <name>Types of FEC</name> <t>FEC describes the sending of redundant information in an outgoing packet stream so that information can still be recovered even in the event of packet loss. There are multiple ways this can be accomplished for RTP media streams <xref target="RFC3550" format="default"/>; this section enumerates the various mechanisms available and describes their trade-offs.</t> <section numbered="true" toc="default"> <name>Separate FEC Stream</name> <t>This approach, as described in <xref target="RFC5956" sectionFormat="comma" section="4.3" format="default"/>, sends FEC packets as an independent RTP stream with its own synchronization source (SSRC) <xref target="RFC3550" format="default"/> and payload type, multiplexed with the primary encoding. While this approach can protect multiple packets of the primary encoding with a single FEC packet, each FEC packet will have its own IP/UDP/RTP/FEC header, and this overhead can be excessive in some cases, e.g., when protecting each primary packet with a FEC packet.</t> <t>This approach allows for recovery of entire RTP packets, including the full RTP header.</t> </section> <section anchor="redundant-encoding" numbered="true" toc="default"> <name>Redundant Encoding</name> <t>This approach, as described in <xref target="RFC2198" format="default"/>, allows for redundant data to be piggybacked on an existing primary encoding, all in a single packet. This redundant data may be an exact copy of a previous payload, or for codecs that support variable-bitrate encodings, the redundant data may possibly be a smaller, lower-quality representation. In certain cases, the redundant data could include encodings of multiple prior audio frames.</t> <t>Since there is only a single set of packet headers, this approach allows for a very efficient representation of primary and redundant data. However, this savings is only realized when the data all fits into a single packet (i.e. the size is less than a MTU). As a result, this approach is generally not useful for video content.</t> <t>As described in <xref target="RFC2198" sectionFormat="comma" section="4" format="default"/>, this approach cannot recover certain parts of the RTP header, including the marker bit, contributing source (CSRC) information, and header extensions.</t> </section> <section numbered="true" toc="default"> <name>Codec-Specific In-Band FEC</name> <t>Some audio codecs, notably Opus <xref target="RFC6716" format="default"/> and Adaptive Multi-Rate (AMR) <xref target="RFC4867" format="default"/>, support their own in-band FEC mechanism, where redundant data is included in the codec payload. This is similar to the redundant encoding mechanism described above, but as it adds no additional framing, it can be slightly more efficient.</t> <t>For Opus, audio frames deemed important are re-encoded at a lower bitrate and appended to the next payload, allowing partial recovery of a lost packet. This scheme is fairly efficient; experiments performed indicate that when Opus FEC is used, the overhead imposed is only about 20-30%, depending on the amount of protection needed. Note that this mechanism can only carry redundancy information for the immediately preceding audio frame; thus the decoder cannot fully recover multiple consecutive lost packets, which can be a problem on wireless networks. See <xref target="RFC6716" sectionFormat="comma" section="2.1.7" format="default"/>, and <xref target="OpusFEC" format="default">this Opus mailing list post</xref> for more details.</t> <t>For AMR and AMR-Wideband (AMR-WB), packets can contain copies or lower-quality encodings of multiple prior audio frames. See <xref target="RFC4867" sectionFormat="comma" section="3.7.1" format="default"/>, for details on this mechanism.</t> <t>In-band FEC mechanisms cannot recover any of the RTP header.</t> </section> </section> <section anchor="audio-fec" numbered="true" toc="default"> <name>FEC for Audio Content</name> <t>The following section provides guidance on how to best use FEC for transmitting audio data. As indicated in <xref target="adaptive-fec" format="default"/> below, FEC should only be activated if network conditions warrant it, or upon explicit application request.</t> <section numbered="true" toc="default"> <name>Recommended Mechanism</name> <t>When using variable-bitrate codecs without an internal FEC, redundant encoding (as described in <xref target="redundant-encoding" format="default"/>) with lower-fidelity version(s) of the previous packet(s) is <bcp14>RECOMMENDED</bcp14>. This provides reasonable protection of the payload with only moderate bitrate increase, as the redundant encodings can be significantly smaller than the primary encoding.</t> <t>When using the Opus codec, use of the built-in Opus FEC mechanism is <bcp14>RECOMMENDED</bcp14>. This provides reasonable protection of the audio stream against individual losses, with minimal overhead. Note that, as indicated above, the built-in Opus FEC only provides single-frame redundancy; if multi-packet protection is needed, the aforementioned redundant encoding with reduced-bitrate Opus encodings <bcp14>SHOULD</bcp14> be used instead.</t> <t>When using the AMR/AMR-WB codecs, use of their built-in FEC mechanism is <bcp14>RECOMMENDED</bcp14>. This provides slightly more efficient protection of the audio stream than redundant encoding does.</t> <t>When using constant-bitrate codecs, e.g., PCMU <xref target="RFC5391" format="default"/>, redundant encoding <bcp14>MAY</bcp14> be used, but this will result in a potentially significant bitrate increase, and suddenly increasing bitrate to deal with losses from congestion may actually make things worse.</t> <t>Because of the lower packet rate of audio encodings, usually a single packet per frame, use of a separate FEC stream comes with a higher overhead than other mechanisms, and therefore is <bcp14>NOT RECOMMENDED</bcp14>.</t> <t>As mentioned above, the recommended mechanisms do not allow recovery of parts of the RTP header that may be important in certain audio applications, e.g., CSRCs and RTP header extensions like those specified in <xref target="RFC6464" format="default"/> and <xref target="RFC6465" format="default"/>. Implementations <bcp14>SHOULD</bcp14> account for this and attempt to approximate this information, using an approach similar to those described in <xref target="RFC2198" sectionFormat="comma" section="4" format="default"/>, and <xref target="RFC6464" sectionFormat="comma" section="5" format="default"/>.</t> </section> <section numbered="true" toc="default"> <name>Negotiating Support</name> <t>Support for redundant encoding of a given RTP stream <bcp14>SHOULD</bcp14> be indicated by including audio/red <xref target="RFC2198" format="default"/> as an additional supported media type for the associated "m=" section in the SDP offer <xref target="RFC3264" format="default"/>. Answerers can reject the use of redundant encoding by not including the audio/red media type in the corresponding "m=" section in the SDP answer.</t> <t>Support for codec-specific FEC mechanisms are typically indicated via "a=fmtp" parameters.</t> <t>For Opus, a receiver <bcp14>MUST</bcp14> indicate that it is prepared to use incoming FEC data with the "useinbandfec=1" parameter, as specified in <xref target="RFC7587" format="default"/>. This parameter is declarative and can be negotiated separately for either media direction.</t> <t>For AMR/AMR-WB, support for redundant encoding, and the maximum supported depth, are controlled by the "max-red" parameter, as specified in <xref target="RFC4867" sectionFormat="comma" section="8.1" format="default"/>. Receivers <bcp14>MUST</bcp14> include this parameter, and set it to an appropriate value, as specified in <xref target="TS.26114" format="default"/>, Table 6.3.</t> </section> </section> <section anchor="video-fec" numbered="true" toc="default"> <name>FEC for Video Content</name> <t>The following section provides guidance on how to best use FEC for transmitting video data. As indicated in <xref target="adaptive-fec" format="default"/> below, FEC should only be activated if network conditions warrant it, or upon explicit application request.</t> <section numbered="true" toc="default"> <name>Recommended Mechanism</name> <t>Video frames, due to their size, often require multiple RTP packets. As discussed above, a separate FEC stream can protect multiple packets with a single FEC packet. In addition, the Flexible FEC mechanism described in <xref target="RFC8627" format="default"/> is also capable of protecting multiple RTP streams via a single FEC stream, including all the streams that are part of a BUNDLE group <xref target="RFC8843" format="default"/>. As a result, for video content, use of a separate FEC stream with the Flexible FEC RTP payload format is <bcp14>RECOMMENDED</bcp14>.</t> <t>To process the incoming FEC stream, the receiver can demultiplex it by SSRC, and then correlate it with the appropriate primary stream(s) via the CSRC(s) present in the RTP header of Flexible FEC repair packets, or the SSRC field present in the FEC header of Flexible FEC retransmission packets.</t> </section> <section numbered="true" toc="default"> <name>Negotiating Support</name> <t>Support for an SSRC-multiplexed Flexible FEC stream to protect a given RTP stream <bcp14>SHOULD</bcp14> be indicated by including video/flexfec (described in <xref target="RFC8627" sectionFormat="comma" section="5.1.2" format="default"/>) as an additional supported media type for the associated "m=" section in the SDP offer <xref target="RFC3264" format="default"/>. As mentioned above, when BUNDLE is used, only a single Flexible FEC repair stream will be created for each BUNDLE group, even if Flexible FEC is negotiated for each primary stream.</t> <t>Answerers can reject the use of SSRC-multiplexed FEC by not including the video/flexfec media type in the corresponding "m=" section in the SDP answer.</t> <t>Use of FEC-only "m=" lines, and grouping using the SDP group mechanism as described in <xref target="RFC5956" sectionFormat="comma" section="4.1" format="default"/>, is not currently defined for WebRTC, and <bcp14>SHOULD NOT</bcp14> be offered.</t> <t>Answerers <bcp14>SHOULD</bcp14> reject any FEC-only "m=" lines, unless they specifically know how to handle such a thing in a WebRTC context (perhaps defined by a future version of the WebRTC specifications).</t> </section> </section> <section numbered="true" toc="default"> <name>FEC for Application Content</name> <t>WebRTC also supports the ability to send generic application data, and provides transport-level retransmission mechanisms to support full and partial (e.g., timed) reliability. See <xref target="RFC8831" format="default"/> for details.</t> <t>Because the application can control exactly what data to send, it has the ability to monitor packet statistics and perform its own application-level FEC if necessary.</t> <t>As a result, this document makes no recommendations regarding FEC for the underlying data transport.</t> </section> <section numbered="true" toc="default"> <name>Implementation Requirements</name> <t>To support the functionality recommended above, implementations <bcp14>MUST</bcp14> be able to receive and make use of the relevant FEC formats for their supported audio codecs, and <bcp14>MUST</bcp14> indicate this support, as described in <xref target="audio-fec" format="default"/>. Use of these formats when sending, as mentioned above, is <bcp14>RECOMMENDED</bcp14>.</t> <t>The general FEC mechanism described in <xref target="RFC8627" format="default"/> <bcp14>SHOULD</bcp14> also be supported, as mentioned in <xref target="video-fec" format="default"/>.</t> <t>Implementations <bcp14>MAY</bcp14> support additional FEC mechanisms if desired, e.g., <xref target="RFC5109" format="default"/>.</t> </section> <section anchor="adaptive-fec" numbered="true" toc="default"> <name>Adaptive Use of FEC</name> <t>Because use of FEC always causes redundant data to be transmitted, and the total amount of data must remain within any bandwidth limits indicated by congestion control and the receiver, this will lead to less bandwidth available for the primary encoding, even when the redundant data is not being used. This is in contrast to methods like RTX <xref target="RFC4588" format="default"/> or Flexible FEC's retransmission mode (<xref target="RFC8627" sectionFormat="comma" section="1.1.7" format="default"/>), which only transmit redundant data when necessary, at the cost of an extra round trip and thereby increased media latency.</t> <t>Given this, WebRTC implementations <bcp14>SHOULD</bcp14> prefer using RTX or Flexible FEC retransmissions instead of FEC when the connection RTT is within the application's latency budget, and otherwise <bcp14>SHOULD</bcp14> only transmit the amount of FEC needed to protect against the observed packet loss (which can be determined, e.g., by monitoring transmit packet loss data from RTP Control Protocol (RTCP) receiver reports <xref target="RFC3550" format="default"/>), unless the application indicates it is willing to pay a quality penalty to proactively avoid losses.</t> <t>Note that when probing bandwidth, i.e., speculatively sending extra data to determine if additional link capacity exists, FEC data <bcp14>SHOULD</bcp14> be used as the additional data. Given that extra data is going to be sent regardless, it makes sense to have that data protect the primary payload; in addition, FEC can typically be applied in a way that increases bandwidth only modestly, which is necessary when probing.</t> <t>When using FEC with layered codecs, e.g., <xref target="RFC6386" format="default"/>, where only base layer frames are critical to the decoding of future frames, implementations <bcp14>SHOULD</bcp14> only apply FEC to these base layer frames.</t> <t>Finally, it should be noted that, although applying redundancy is often useful in protecting a stream against packet loss, if the loss is caused by network congestion, the additional bandwidth used by the redundant data may actually make the situation worse and can lead to significant degradation of the network.</t> </section> <section numbered="true" toc="default"> <name>Security Considerations</name> <t>In the WebRTC context, FEC is specifically concerned with recovering data from lost packets; any corrupted packets will be discarded by the Secure Real-Time Transport Protocol (SRTP) <xref target="RFC3711" format="default"/> decryption process. Therefore, as described in <xref target="RFC3711" sectionFormat="comma" section="10" format="default"/>, the default processing when using FEC with SRTP is to perform FEC followed by SRTP at the sender, and SRTP followed by FEC at the receiver. This ordering is used for all the SRTP protection profiles used in DTLS-SRTP <xref target="RFC5763" format="default"/>, which are enumerated in <xref target="RFC5764" sectionFormat="comma" section="4.1.2" format="default"/>.</t> <t>Additional security considerations for each individual FEC mechanism are enumerated in their respective documents.</t> </section> <section numbered="true" toc="default"> <name>IANA Considerations</name> <t>This document requires no actions from IANA.</t> </section> </middle> <back> <references> <name>References</name> <references> <name>Normative References</name> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2119.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2198.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.3264.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.4867.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.5956.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.7587.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8174.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8627.xml"/> <reference anchor="TS.26114" target="http://www.3gpp.org/ftp/Specs/html-info/26114.htm"> <front> <title>IP Multimedia Subsystem (IMS); Multimedia telephony; Media handling and interaction</title> <seriesInfo name="3GPP TS" value="26.114 15.0.0"/> <author> <organization>3GPP</organization> </author> <date day="22" month="September" year="2017"/> </front> </reference> </references> <references> <name>Informative References</name> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.3550.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.3711.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.4588.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.5109.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.5391.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.5763.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.5764.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.6386.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.6464.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.6465.xml"/> <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.6716.xml"/> <reference anchor="RFC8843" target="https://www.rfc-editor.org/info/rfc8843"> <front> <title>Negotiating Media Multiplexing Using the Session Description Protocol (SDP)</title> <author initials="C" surname="Holmberg" fullname="Christer Holmberg"> <organization/> </author> <author initials="H" surname="Alvestrand" fullname="Harald Alvestrand"> <organization/> </author> <author initials="C" surname="Jennings" fullname="Cullen Jennings"> <organization/> </author> <date month="April" year="2020"/> </front> <seriesInfo name="RFC" value="8843"/> <seriesInfo name="DOI" value="10.17487/RFC8843"/> </reference> <reference anchor="RFC8831" target="https://www.rfc-editor.org/info/rfc8831"> <front> <title>WebRTC Data Channels</title> <author initials="R" surname="Jesup" fullname="Randell Jesup"> <organization/> </author> <author initials="S" surname="Loreto" fullname="Salvatore Loreto"> <organization/> </author> <author initials="M" surname="Tuexen" fullname="Michael Tuexen"> <organization/> </author> <date month='April' year='2020'/> </front> <seriesInfo name="RFC" value="8831"/> <seriesInfo name="DOI" value="10.17487/RFC8831"/> </reference> <reference anchor="OpusFEC" target="http://lists.xiph.org/pipermail/opus/2013-January/001904.html"> <front> <title>Subject: Opus FEC</title> <author fullname="Tim Terriberry" initials="T." surname="Terriberry"> <organization>Xiph</organization> </author> <date day="28" month="January" year="2013"/> </front> <refcontent>message to the opus mailing list</refcontent> </reference> </references> </references> <section numbered="false" toc="default"> <name>Acknowledgements</name> <t>Several people provided significant input into this document, including <contact fullname="Bernard Aboba"/>, <contact fullname="Jonathan Lennox"/>, <contact fullname="Giri Mandyam"/>, <contact fullname="Varun Singh"/>, <contact fullname="Tim Terriberry"/>, <contact fullname="Magnus Westerlund"/>, and <contact fullname="Mo Zanaty"/>.</t> </section> </back> </rfc>