RFC 8831 | WebRTC Data Channels | January 2021 |
Jesup, et al. | Standards Track | [Page] |
The WebRTC framework specifies protocol support for direct, interactive,rich communication using audio, video, and data between two peers' web browsers.This document specifies the non-media data transport aspects of the WebRTCframework. It provides an architectural overview of how the Stream ControlTransmission Protocol (SCTP) is used in the WebRTC context as a generictransport service that allows web browsers to exchange generic data from peer topeer.¶
This is an Internet Standards Track document.¶
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.¶
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained athttps://www.rfc-editor.org/info/rfc8831.¶
Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.¶
In the WebRTC framework, communication between the parties consists of media(for example, audio and video) and non-media data.Media is sent using the Secure Real-time Transport Protocol (SRTP)and is not specified further here.Non-media data is handled by using the Stream Control Transmission Protocol (SCTP)[RFC4960] encapsulatedin DTLS. DTLS 1.0 is defined in[RFC4347]; the presentlatest version, DTLS 1.2, is defined in[RFC6347]; and an upcoming version, DTLS 1.3, is defined in[TLS-DTLS13].¶
+----------+| SCTP |+----------+| DTLS |+----------+| ICE/UDP |+----------+
The encapsulation of SCTP over DTLS(see[RFC8261]) over ICE/UDP(see[RFC8445]) provides a NAT traversalsolution together with confidentiality, source authentication, andintegrity-protected transfers.This data transport service operates in parallel to the SRTP media transports,and all of them can eventually share a single UDP port number.¶
SCTP, as specified in[RFC4960] with the partial reliabilityextension (PR-SCTP) defined in[RFC3758] and the additional policiesdefined in[RFC7496],provides multiple streams natively with reliable, and the relevantpartially reliable, delivery modes for user messages.Using the reconfiguration extension defined in[RFC6525]allows an increase in the number of streams during the lifetime of an SCTPassociation and allows individual SCTP streams to be reset.Using[RFC8260] allows the interleave of large messages toavoid monopolization and adds support forprioritizing SCTP streams.¶
The remainder of this document is organized as follows:Sections3 and4 provide use casesand requirements for both unreliable and reliable peer-to-peer data channels;Section 5 discusses SCTP over DTLS over UDP; andSection 6 specifies how SCTP should beused by the WebRTC protocol framework for transporting non-media databetween web browsers.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14[RFC2119][RFC8174] when, and only when, they appear in all capitals, as shown here.¶
This section defines use cases specific to data channels.Please note that this section is informational only.¶
This section lists the requirements for Peer-to-Peer (P2P) data channels betweentwo browsers.Please note that this section is informational only.¶
The important features of SCTP in the WebRTC context are the following:¶
The WebRTC data channel mechanism does not support SCTP multihoming.The SCTP layer will simply act as if it were running on a single-homed host,since that is the abstraction that the DTLS layer (a connection-oriented,unreliable datagram service) exposes.¶
The encapsulation of SCTP over DTLS defined in[RFC8261] provides confidentiality,source authentication, and integrity-protected transfers.Using DTLS over UDP in combination with Interactive Connectivity Establishment (ICE)[RFC8445] enables middlebox traversalin IPv4- and IPv6-based networks.SCTP as specified in[RFC4960]MUST be used incombination with the extension defined in[RFC3758] andprovides the following features for transporting non-media data betweenbrowsers:¶
Each SCTP user message contains a Payload Protocol Identifier (PPID)that is passed to SCTP by its upper layer on the sending side andprovided to its upper layer on the receiving side.The PPID can be used to multiplex/demultiplex multiple upper layers overa single SCTP association.In the WebRTC context, the PPID is used to distinguish betweenUTF-8 encoded user data,binary-encoded user data, andthe Data Channel Establishment Protocol (DCEP) defined in[RFC8832].Please note that the PPID is not accessible via the JavaScript API.¶
The encapsulation of SCTP over DTLS, together with the SCTP features listedabove, satisfies all the requirements listed inSection 4.¶
The layering of protocols for WebRTC is shown inFigure 2.¶
+------+------+------+ | DCEP | UTF-8|Binary| | | Data | Data | +------+------+------+ | SCTP |+----------------------------------+| STUN | SRTP | DTLS |+----------------------------------+| ICE |+----------------------------------+| UDP1 | UDP2 | UDP3 | ... |+----------------------------------+
This stack (especially in contrast to DTLS over SCTP[RFC6083] andin combination with SCTP over UDP[RFC6951])has been chosen for the following reasons:¶
Referring to the protocol stack shown inFigure 2:¶
Please note that the demultiplexing Session Traversal Utilities for NAT (STUN)[RFC5389] vs. SRTP vs. DTLS is doneas described inSection 5.1.2 of [RFC5764], and SCTPis the only payload of DTLS.¶
Since DTLS is typically implemented in user application space, the SCTPstack also needs to be a user application space stack.¶
The ICE/UDP layer can handle IP address changes during a session withoutneeding interaction with the DTLS and SCTP layers.However, SCTPSHOULD be notified when an address change has happened.In this case, SCTPSHOULD retest the Path MTU and reset the congestionstate to the initial state.In the case of window-based congestion control like the one specified in[RFC4960], this means setting the congestion window andslow-start threshold to its initial values.¶
Incoming ICMP or ICMPv6 messages can't be processed bythe SCTP layer, since there is no way to identify the correspondingassociation. Therefore, SCTPMUST support performing Path MTU discoverywithout relying on ICMP or ICMPv6 as specified in[RFC4821]by using probing messages specified in[RFC4820].The initial Path MTU at the IP layerSHOULD NOT exceed 1200 bytes for IPv4and 1280 bytes for IPv6.¶
In general, the lower-layer interface of an SCTP implementation should beadapted to address the differences between IPv4 and IPv6 (being connectionless)or DTLS (being connection oriented).¶
When the protocol stack shown inFigure 2 is used, DTLSprotects the complete SCTP packet, so it provides confidentiality, integrity, andsource authentication of the complete SCTP packet.¶
SCTP provides congestion control on a per-association basis. This meansthat all SCTP streams within a single SCTP association share the samecongestion window. Traffic not being sent over SCTP is not covered bySCTP congestion control.Using a congestion control different from the standard one might improvethe impact on the parallel SRTP media streams.¶
SCTP uses the same port number concept as TCP and UDP.Therefore, an SCTP association uses two port numbers, one at each SCTPendpoint.¶
The DTLS encapsulation of SCTP packets as described in[RFC8261]MUST be used.¶
This SCTP stack and its upper layerMUST support the usage of multipleSCTP streams.A user message can be sent ordered or unordered and with partial or fullreliability.¶
The following SCTP protocol extensions are required:¶
The support for message interleaving as defined in[RFC8260]SHOULD be used.¶
In the WebRTC context, the SCTP association will be set up when thetwo endpoints of the WebRTC PeerConnection agree on opening it, as negotiatedby the JavaScript Session Establishment Protocol (JSEP), which is typically anexchange of the Session Description Protocol (SDP)[RFC8829].It will use the DTLS connection selected via ICE, and typically this will beshared via BUNDLE or equivalent with DTLS connections used to key theSRTP media streams.¶
The number of streams negotiated during SCTP association setupSHOULDbe 65535, which is the maximum number of streams that can be negotiated duringthe association setup.¶
SCTP supports two ways of terminating an SCTP association.The first method is a graceful one, where a procedure that ensures no messagesare lost during the shutdown of the association is used.The second method is a non-graceful one, where one side can just abort theassociation.¶
Each SCTP endpoint continuously supervises the reachability of its peer bymonitoring the number of retransmissions of user messages and test messages.In case of excessive retransmissions, the association is terminated in anon-graceful way.¶
If an SCTP association is closed in a graceful way, all of its data channelsare closed.In case of a non-graceful teardown, all data channels are also closed,but an error indicationSHOULD be provided if possible.¶
SCTP defines a stream as a unidirectional logical channel existing withinan SCTP association to another SCTP endpoint. The streams are used toprovide the notion of in-sequence delivery and for multiplexing.Each user message is sent on a particular stream, either ordered or unordered.Ordering is preserved only for ordered messages sent on the same stream.¶
Data channels are defined such that their accompanying application-level APIcan closely mirror the API for WebSockets, which implies bidirectional streamsof data and a textual field called 'label' used to identify the meaning of thedata channel.¶
The realization of a data channel is a pair of one incoming stream andone outgoing SCTP stream having the same SCTP stream identifier.How these SCTP stream identifiers are selected is protocol and implementationdependent. This allows a bidirectional communication.¶
Additionally, each data channel has the following properties in eachdirection:¶
Note that for a data channel being negotiated with the protocolspecified in[RFC8832], all of the aboveproperties are the same in both directions.¶
Data channels can be opened by using negotiation within the SCTP association(called in-band negotiation) or out-of-band negotiation.Out-of-band negotiation is defined as any method that results in an agreementas to the parameters of a channel and the creation thereof.The details are out of scope of this document. Applications using datachannels need to use the negotiation methods consistently on both endpoints.¶
A simple protocol for in-band negotiation is specified in[RFC8832].¶
When one side wants to open a channel using out-of-band negotiation, itpicks a stream.Unless otherwise defined or negotiated, the streams are picked based onthe DTLS role (the client picks even stream identifiers, andthe server picks odd stream identifiers).However, the application is responsible for avoiding collisions withexisting streams.If it attempts to reuse a stream that is part of an existing data channel,the additionMUST fail.In addition to choosing a stream, the applicationSHOULD also determinethe options to be used for sending messages.The applicationMUST ensure in an application-specific manner thatthe application at the peer will also know the selected stream tobe used, as well as the options for sending data from that side.¶
All data sent on a data channel in both directionsMUST be sent over theunderlying stream using the reliability defined when the data channel wasopened, unless the options are changed or per-message options are specifiedby a higher level.¶
The message orientation of SCTP is used to preserve the message boundariesof user messages. Therefore, sendersMUST NOT put more than one applicationmessage into an SCTP user message. Unless the deprecated PPID-basedfragmentation and reassembly is used, the senderMUST include exactly oneapplication message in each SCTP user message.¶
The SCTP Payload Protocol Identifiers (PPIDs) are used to signal theinterpretation of the "payload data". The following PPIDsMUST be used(seeSection 8):¶
SCTP does not support the sending of empty user messages. Therefore, if anempty message has to be sent, the appropriate PPID (WebRTC String Empty orWebRTC Binary Empty) is used, and the SCTP user message of one zero byte issent. When receiving an SCTP user message with one of these PPIDs, the receiverMUST ignore the SCTP user message and process it as an empty message.¶
The usage of the PPIDs "WebRTC String Partial" and "WebRTC Binary Partial"is deprecated. They were used for a PPID-based fragmentation and reassemblyof user messages belonging to reliable and ordered data channels.¶
If a message with an unsupported PPID is received or some error conditionrelated to the received message is detected by the receiver(for example, illegal ordering), the receiverSHOULD close the correspondingdata channel. This implies in particular that extensions using additionalPPIDs can't be used without prior negotiation.¶
The SCTP base protocol specified in[RFC4960] does notsupport the interleaving of user messages. Therefore, sending a large usermessage can monopolize the SCTP association.To overcome this limitation,[RFC8260]defines an extension to support message interleaving, whichSHOULD be used.As long as message interleaving is not supported, the senderSHOULD limit the maximum message size to 16 KB to avoid monopolization.¶
It is recommended that the message size be kept within certain size bounds,as applications will not be able to support arbitrarily large singlemessages. This limit has to be negotiated, for example, by using[RFC8841].¶
The senderSHOULD disable the Nagle algorithm (see[RFC1122])to minimize the latency.¶
Closing of a data channelMUST be signaled by resetting the correspondingoutgoing streams[RFC6525]. This means that if one sidedecides to close the data channel, it resets the corresponding outgoing stream.When the peer sees that an incoming stream was reset, it also resets itscorresponding outgoing stream. Once this is completed, the data channel is closed.Resetting a stream sets the Stream Sequence Numbers (SSNs) of the stream back to'zero' with a corresponding notification to the application layerthat the reset has been performed. Streams are available for reuse after a resethas been performed.¶
[RFC6525] also guarantees that all the messages are delivered(or abandoned) before the stream is reset.¶
This document does not add any additional considerations to the ones given in[RFC8826] and[RFC8827].¶
It should be noted that a receiver must be prepared for a sender that triesto send arbitrarily large messages.¶
This document uses six already registered SCTP Payload ProtocolIdentifiers (PPIDs):"DOMString Last","Binary Data Partial","Binary Data Last","DOMString Partial","WebRTC String Empty", and"WebRTC Binary Empty".[RFC4960] creates the "SCTP Payload Protocol Identifiers" registryfrom which these identifiers were assigned.IANA has updated the reference of these six assignments to pointto this document and changed the names of the first four PPIDs.The corresponding dates remain unchanged.¶
The six assignments have been updated to read:¶
Value | SCTP PPID | Reference | Date |
---|---|---|---|
WebRTC String | 51 | RFC 8831 | 2013-09-20 |
WebRTC Binary Partial (deprecated) | 52 | RFC 8831 | 2013-09-20 |
WebRTC Binary | 53 | RFC 8831 | 2013-09-20 |
WebRTC String Partial (deprecated) | 54 | RFC 8831 | 2013-09-20 |
WebRTC String Empty | 56 | RFC 8831 | 2014-08-22 |
WebRTC Binary Empty | 57 | RFC 8831 | 2014-08-22 |
Many thanks for comments, ideas, and text fromHarald Alvestrand,Richard Barnes,Adam Bergkvist,Alissa Cooper,Benoit Claise,Spencer Dawkins,Gunnar Hellström,Christer Holmberg,Cullen Jennings,Paul Kyzivat,Eric Rescorla,Adam Roach,Irene Rüngeler,Randall Stewart,Martin Stiemerling,Justin Uberti, andMagnus Westerlund.¶