[
RFC 8445] defines ICE candidate exchange as the process for ICE agents (initiator and responder) to exchange their candidate information required for ICE processing at the agents. For the purposes of this specification, the candidate exchange process corresponds to the Offer/Answer protocol [
RFC 3264], and the terms "offerer" and "answerer" correspond to the initiator and responder roles from [
RFC 8445] respectively.
Once the initiating agent has gathered, pruned, and prioritized its set of candidates [
RFC 8445], the candidate exchange with the peer agent begins.
Section 5 provides detailed rules for constructing various SDP attributes defined in this specification.
Each data stream [
RFC 8445] is represented by an SDP media description ("m=" section).
Within an "m=" section, each candidate (including the default candidate) associated with the data stream is represented by an SDP "candidate" attribute.
Prior to nomination, the "c=" line associated with an "m=" section contains the connection address of the default candidate, while the "m=" line contains the port and transport protocol of the default candidate for that "m=" section.
After nomination, the "c=" line for a given "m=" section contains the connection address of the nominated candidate (the local candidate of the nominated candidate pair), and the "m=" line contains the port and transport protocol corresponding to the nominated candidate for that "m=" section.
The ICE username is represented by an SDP "ice-ufrag" attribute, and the ICE password is represented by an SDP "ice-pwd" attribute.
An ICE-lite implementation [
RFC 8445]
MUST include an SDP "ice-lite" attribute. A full implementation
MUST NOT include that attribute.
An agent uses the SDP "ice-options" attribute to indicate support of ICE extensions.
An agent compliant with this specification
MUST include an SDP "ice-options" attribute with an "ice2" attribute value [
RFC 8445]. If an agent receives an SDP offer or answer that indicates ICE support, but that does not contain an SDP "ice-options" attribute with an "ice2" attribute value, the agent can assume that the peer is compliant to [
RFC 5245].
If an "m=" section is marked as inactive [
RFC 4566], or has a bandwidth value of zero [
RFC 4566], the agent
MUST still include ICE-related SDP attributes.
If the port value associated with an "m=" section is set to zero (implying a disabled stream) as defined in
Section 8.2 of
RFC 3264, the agent
SHOULD NOT include ICE-related SDP "candidate" attributes in that "m=" section, unless an SDP extension specifying otherwise is used.
If an agent utilizes both RTP and RTCP, and separate ports are used for RTP and RTCP, the agent
MUST include SDP "candidate" attributes for both the RTP and RTCP components.
The agent includes an SDP "rtcp" attribute following the procedures in [
RFC 3605]. Hence, in the cases where the RTCP port value is one higher than the RTP port value and the RTCP component address the same as the address of the RTP component, the SDP "rtcp" attribute might be omitted.
NOTE: [
RFC 5245] required that an agent always includes the SDP "rtcp" attribute, even if the RTCP port value was one higher than the RTP port value. This specification aligns the "rtcp" attribute procedures with [
RFC 3605].
If the agent does not utilize RTCP, it indicates that by including "RS:0" and "RR:0" SDP attributes as described in [
RFC 3556].
The offerer acts as the initiating agent. The answerer acts as the responding agent. The ICE roles (controlling and controlled) are determined using the procedures in [
RFC 8445].
Once an agent has provided its local candidates to its peer in an SDP offer or answer, the agent
MUST be prepared to receive STUN (Session Traversal Utilities for NAT, [
RFC 5389]) connectivity check Binding requests on those candidates.
An ICE agent indicates support of ICE by including at least the SDP "ice-pwd" and "ice-ufrag" attributes in an offer or answer. An ICE agent compliant with this specification
MUST also include an SDP "ice-options" attribute with an "ice2" attribute value.
The agents will proceed with the ICE procedures defined in [
RFC 8445] and this specification if, for each data stream in the SDP it received, the default destination for each component of that data stream appears in a "candidate" attribute. For example, in the case of RTP, the connection address, port, and transport protocol in the "c=" and "m=" lines, respectively, appear in a "candidate" attribute, and the value in the "rtcp" attribute appears in a "candidate" attribute.
This specification provides no guidance on how an agent should proceed in the cases where the above condition is not met with the few exceptions noted below:
-
The presence of certain Application Layer Gateways might modifythe transport address information as described in Section 8.The behavior of the responding agent in such a situation isimplementation dependent. Informally, the responding agent mightconsider the mismatched transport address information as aplausible new candidate learned from the peer and continue itsICE processing with that transport address included.Alternatively, the responding agent MAY include an "ice-mismatch"attribute in its answer for such data streams. If an agent chooses toinclude an "ice-mismatch" attribute in its answer for a data stream,then it MUST also omit "candidate" attributes, MUST terminatethe usage of ICE procedures, and [RFC 3264] procedures MUST be used instead for this data stream.
-
The transport address from the peer for the default destinationis set to IPv4/IPv6 address values "0.0.0.0"/"::" and port value of "9".This MUST NOT be considered as an ICE failure by the peer agent, andthe ICE processing MUST continue as usual.
-
In some cases, the controlling/initiator agent may receive an SDP answerthat may omit "candidate" attributes for the data stream, and insteadinclude a media-level "ice-mismatch" attribute. This signals to theofferer that the answerer supports ICE, but that ICE processing was notused for this data stream. In this case, ICE processing MUST be terminatedfor this data stream, and [RFC 3264] procedures MUST be followed instead.
-
The transport address from the peer for the default destination isan FQDN. Regardless of the procedures used to resolve FQDN or theresolution result, this MUST NOT be considered as an ICE failure bythe peer agent, and the ICE processing MUST continue as usual.
The following is an example SDP message that includes ICE attributes (lines folded for readability):
v=0
o=jdoe 2890844526 2890842807 IN IP4 203.0.113.141
s=
c=IN IP4 192.0.2.3
t=0 0
a=ice-options:ice2
a=ice-pacing:50
a=ice-pwd:asd88fgpdd777uzjYhagZg
a=ice-ufrag:8hhY
m=audio 45664 RTP/AVP 0
b=RS:0
b=RR:0
a=rtpmap:0 PCMU/8000
a=candidate:1 1 UDP 2130706431 203.0.113.141 8998 typ host
a=candidate:2 1 UDP 1694498815 192.0.2.3 45664 typ srflx raddr
203.0.113.141 rport 8998
When an offerer generates the initial offer, in each "m=" section it
MUST include SDP "candidate" attributes for each available candidate associated with the "m=" section. In addition, the offerer
MUST include an SDP "ice-ufrag" attribute, an SDP "ice-pwd" attribute, and an SDP "ice-options" attribute with an "ice2" attribute value in the offer. If the offerer is a full ICE implementation, it
SHOULD include an "ice-pacing" attribute in the offer (if not included, the default value will apply). A lite ICE implementation
MUST NOT include the "ice-pacing" attribute in the offer (as it will not perform connectivity checks).
It is valid for an offer "m=" line to include no SDP "candidate" attributes and have the default destination set to the IP address values "0.0.0.0"/"::" and the port value to "9". This implies that the offering agent is only going to use peer-reflexive candidates or will provide additional candidates in subsequent signaling messages.
-
Note:
-
Within the scope of this document, "initial offer" refers to the firstSDP offer that is sent in order to negotiate usage of ICE. It might, ormight not, be the initial SDP offer of the SDP session.
-
Note:
-
The procedures in this document only consider "m=" sections associatedwith data streams where ICE is used.
When an answerer receives an initial offer indicating that the offerer supports ICE, and if the answerer accepts the offer and the usage of ICE, the answerer
MUST include in each "m=" section within the answer the SDP "candidate" attributes for each available candidate associated with the "m=" section. In addition, the answerer
MUST include an SDP "ice-ufrag" attribute, an SDP "ice-pwd" attribute, and an SDP "ice-options" attribute with an "ice2" attribute value in the answer. If the answerer is a full ICE implementation, it
SHOULD include an "ice-pacing" attribute in the answer (if not included, the default value will apply). A lite ICE implementation
MUST NOT include the "ice-pacing" attribute in the answer (as it will not perform connectivity checks).
In each "m=" line, the answerer
MUST use the same transport protocol as was used in the offer "m=" line. If none of the candidates in the "m=" line in the answer uses the same transport protocol as indicated in the offer "m=" line, then, in order to avoid ICE mismatch, the default destination
MUST be set to IP address values "0.0.0.0"/"::" and port value of "9".
It is also valid for an answer "m=" line to include no SDP "candidate" attributes and have the default destination set to the IP address values "0.0.0.0"/"::" and the port value to "9". This implies that the answering agent is only going to use peer-reflexive candidates or that additional candidates would be provided in subsequent signaling messages.
Once the answerer has sent the answer, it can start performing connectivity checks towards the peer candidates that were provided in the offer.
If the offer does not indicate support of ICE (
Section 4.2.5), the answerer
MUST NOT accept the usage of ICE. If the answerer still accepts the offer, the answerer
MUST NOT include any ICE-related SDP attributes in the answer. Instead, the answerer will generate the answer according to normal offer/answer procedures [
RFC 3264].
If the answerer detects a possibility of an ICE mismatch, procedures described in
Section 4.2.5 are followed.
When an offerer receives an initial answer that indicates that the answerer supports ICE, it can start performing connectivity checks towards the peer candidates that were provided in the answer.
If the answer does not indicate that the answerer supports ICE, or if the answerer included "ice-mismatch" attributes for all the active data streams in the answer, the offerer
MUST terminate the usage of ICE for the entire session, and [
RFC 3264] procedures
MUST be followed instead.
On the other hand, if the answer indicates support for ICE but includes "ice-mismatch" in certain active data streams, then the offerer
MUST terminate the usage of ICE procedures, and [
RFC 3264] procedures
MUST be used instead for only these data streams. Also, ICE procedures
MUST be used for data streams where an "ice-mismatch" attribute was not included.
If the offerer detects an ICE mismatch for one or more data streams in the answer, as described in
Section 4.2.5, the offerer
MUST terminate the usage of ICE for the entire session. The subsequent actions taken by the offerer are implementation dependent and are out of the scope of this specification.
Once the agent has successfully nominated a pair [
RFC 8445], the state of the checklist associated with the pair is set to Completed. Once the state of each checklist is set to either Completed or Failed, for each Completed checklist, the agent checks whether the nominated pair matches the default candidate pair. If there are one or more pairs that do not match, and the peer did not indicate support for the 'ice2' ice-option, the controlling agent
MUST generate a subsequent offer in which the connection address, port, and transport protocol in the "c=" and "m=" lines associated with each data stream match the corresponding local information of the nominated pair for that data stream (
Section 4.4.1.2.2). If the peer did indicate support for the 'ice2' ice-option, the controlling agent does not immediately need to generate an updated offer in order to align a connection address, port, and protocol with a nominated pair. However, later in the session, whenever the controlling agent does send a subsequent offer, it
MUST do the alignment as described above.
If there are one or more checklists with the state set to Failed, the controlling agent
MUST generate a subsequent offer in order to remove the associated data streams by setting the port value of the data streams to zero (
Section 4.4.1.1.2), even if the peer did indicate support for the 'ice2' ice-option. If needed, such offer is used to align the connection address, port, and transport protocol, as described above.
As described in [
RFC 8445], once the controlling agent has nominated a candidate pair for a checklist, the agent
MUST NOT nominate another pair for that checklist during the lifetime of the ICE session (i.e., until ICE is restarted).
[
RFC 8863] provides a mechanism for allowing the ICE process to run long enough in order to find working candidate pairs, by waiting for potential peer-reflexive candidates, even though no candidate pairs were received from the peer or all current candidate pairs associated with a checklist have either failed or been discarded.
Either agent
MAY generate a subsequent offer at any time allowed by [
RFC 3264]. This section defines rules for construction of subsequent offers and answers.
Should a subsequent offer fail, ICE processing continues as if the subsequent offer had never been made.
An agent
MAY restart ICE processing for an existing data stream [
RFC 8445].
The rules governing the ICE restart imply that setting the connection address in the "c=" line to "0.0.0.0" (for IPv4)/ "::" (for IPv6) will cause an ICE restart. Consequently, ICE implementations
MUST NOT utilize this mechanism for call hold, and instead
MUST use "inactive" and "sendonly" as described in [
RFC 3264].
To restart ICE, an agent
MUST change both the "ice-pwd" and the "ice-ufrag" for the data stream in an offer. However, it is permissible to use a session-level attribute in one offer, but to provide the same "ice-pwd" or "ice-ufrag" as a media-level attribute in a subsequent offer. This
MUST NOT be considered as ICE restart.
An agent sets the rest of the ICE-related fields in the SDP for this data stream as it would in an initial offer of this data stream (
Section 4.2.1). Consequently, the set of candidates
MAY include some, none, or all of the previous candidates for that data stream and
MAY include a totally new set of candidates. The agent
MAY modify the attribute values of the SDP "ice-options" and SDP "ice-pacing" attributes, and it
MAY change its role using the SDP "ice-lite" attribute. The agent
MUST NOT modify the SDP "ice-options", "ice-pacing", and "ice-lite" attributes in a subsequent offer unless the offer is sent in order to request an ICE restart.
If an agent removes a data stream by setting its port to zero, it
MUST NOT include any "candidate" attributes for that data stream and
SHOULD NOT include any other ICE-related attributes defined in
Section 5 for that data stream.
If an agent wishes to add a new data stream, it sets the fields in the SDP for this data stream as if this were an initial offer for that data stream (
Section 4.2.1). This will cause ICE processing to begin for this data stream.
This section describes additional procedures for full implementations, covering existing data streams.
When an offerer sends a subsequent offer; in each "m=" section for which a candidate pair has not yet been nominated, the offer
MUST include the same set of ICE-related information that the offerer included in the previous offer or answer. The agent
MAY include additional candidates it did not offer previously, but which it has gathered since the last offer/answer exchange, including peer-reflexive candidates.
The agent
MAY change the default destination for media. As with initial offers, there
MUST be a set of "candidate" attributes in the offer matching this default destination.
Once a candidate pair has been nominated for a data stream, the connection address, port, and transport protocol in each "c=" and "m=" line associated with that data stream
MUST match the data associated with the nominated pair for that data stream. In addition, the offerer only includes SDP "candidate" attributes (one per component) representing the local candidates of the nominated candidate pair. The offerer
MUST NOT include any other SDP "candidate" attributes in the subsequent offer.
In addition, if the agent is controlling, it
MUST include the "remote-candidates" attribute for each data stream whose checklist is in the Completed state. The attribute contains the remote candidates corresponding to the nominated pair in the valid list for each component of that data stream. It is needed to avoid a race condition whereby the controlling agent chooses its pairs, but the updated offer beats the connectivity checks to the controlled agent, which doesn't even know these pairs are valid, let alone selected. See
Appendix B for elaboration on this race condition.
If the ICE state is Running, a lite implementation
MUST include all of its candidates for each component of each data stream in "candidate" attributes in any subsequent offer. The candidates are formed identically to the procedures for initial offers.
A lite implementation
MUST NOT add additional host candidates in a subsequent offer, and
MUST NOT modify the username fragments and passwords. If an agent needs to offer additional candidates, or to modify the username fragments and passwords, it
MUST request an ICE restart (
Section 4.4.1.1.1) for that data stream.
If ICE has completed for a data stream, and if the agent is controlled, the default destination for that data stream
MUST be set to the remote candidate of the candidate pair for that component in the valid list. For a lite implementation, there is always just a single candidate pair in the valid list for each component of a data stream. Additionally, the agent
MUST include a "candidate" attribute for each default destination.
If the ICE state is Completed, and if the agent is controlling (which only happens when both agents are lite), the agent
MUST include the "remote-candidates" attribute for each data stream. The attribute contains the remote candidates from the candidate pairs in the valid list (one pair for each component of each data stream).
If ICE is Completed for a data stream, and the offer for that data stream lacked the "remote-candidates" attribute, the rules for construction of the answer are identical to those for the offerer, except that the answerer
MUST NOT include the "remote-candidates" attribute in the answer.
A controlled agent will receive an offer with the "remote-candidates" attribute for a data stream when its peer has concluded ICE processing for that data stream. This attribute is present in the offer to deal with a race condition between the receipt of the offer, and the receipt of the Binding response that tells the answerer the candidate that will be selected by ICE. See
Appendix B for an explanation of this race condition. Consequently, processing of an offer with this attribute depends on the winner of the race.
The agent forms a candidate pair for each component of the data stream by:
-
Setting the remote candidate equal to the offerer's defaultdestination for that component (i.e., the contents of the "m=" and"c=" lines for RTP, and the "rtcp" attribute for RTCP)
-
Setting the local candidate equal to the transport address forthat same component in the "remote-candidates" attribute in theoffer.
The agent then sees if each of these candidate pairs is present in the valid list. If a particular pair is not in the valid list, the check has "lost" the race. Call such a pair a "losing pair".
The agent finds all the pairs in the checklist whose remote candidates equal the remote candidate in the losing pair:
-
If none of the pairs is In-Progress, and at least one is Failed,it is most likely that a network failure, such as a networkpartition or serious packet loss, has occurred. The agent SHOULDgenerate an answer for this data stream as if the "remote-candidates" attribute had not been present, and then restart ICEfor this stream.
-
If at least one of the pairs is In-Progress, the agent SHOULD waitfor those checks to complete, and as each completes, redo theprocessing in this section until there are no losing pairs.
Once there are no losing pairs, the agent can generate the answer. It
MUST set the default destination for media to the candidates in the "remote-candidates" attribute from the offer (each of which will now be the local candidate of a candidate pair in the valid list). It
MUST include a "candidate" attribute in the answer for each candidate in the "remote-candidates" attribute in the offer.
If the offerer in a subsequent offer requested an ICE restart (
Section 4.4.1.1.1) for a data stream, and if the answerer accepts the offer, the answerer follows the procedures for generating an initial answer.
For a given data stream, the answerer
MAY include the same candidates that were used in the previous ICE session, but it
MUST change the SDP "ice-pwd" and "ice-ufrag" attribute values.
The answerer
MAY modify the attribute values of the SDP "ice-options" and SDP "ice-pacing" attributes, and it
MAY change its role using the SDP "ice-lite" attribute. The answerer
MUST NOT modify the SDP "ice-options", "ice-pacing", and "ice-lite" attributes in a subsequent answer unless the answer is sent for an offer that was used to request an ICE restart (
Section 4.4.1.1.1). If any of the SDP attributes have been modified in a subsequent offer that is not used to request an ICE restart, the answerer
MUST reject the offer.
If the received offer contains the "remote-candidates" attribute for a data stream, the agent forms a candidate pair for each component of the data stream by:
-
Setting the remote candidate equal to the offerer's default destinationfor that component (i.e., the contents of the "m=" and "c=" lines for RTP,and the "rtcp" attribute for RTCP).
-
Setting the local candidate equal to the transport address for that samecomponent in the "remote-candidates" attribute in the offer.
The state of the checklist associated with that data stream is set to Completed.
Furthermore, if the agent believed it was controlling, but the offer contained the "remote-candidates" attribute, both agents believe they are controlling. In this case, both would have sent updated offers around the same time.
However, the signaling protocol carrying the offer/answer exchanges will have resolved this glare condition, so that one agent is always the 'winner' by having its offer received before its peer has sent an offer. The winner takes the role of controlling, so that the loser (the answerer under consideration in this section)
MUST change its role to controlled.
Consequently, if the agent was controlling based on the rules in
Section 8.2 of
RFC 8445 and was going to send an updated offer, it no longer needs to.
Besides the potential role change, change in the valid list, and state changes, the construction of the answer is performed identically to the construction of an offer.
There may be certain situations where the offerer receives an SDP answer that lacks ICE candidates although the initial answer included them. One example of such an "unexpected" answer might happen when an ICE-unaware Back-to-Back User Agent (B2BUA) introduces a media server during call hold using third party call control procedures [
RFC 3725]. Omitting further details on how this is done, this could result in an answer that was constructed by the B2BUA being received at the holding UA. With the B2BUA being ICE-unaware, that answer would not include ICE candidates.
Receiving an answer without ICE attributes in this situation might be unexpected, but would not necessarily impair the user experience.
When the offerer receives an answer indicating support for ICE, the offer performs one of the following actions:
-
If the offer was a restart, the agent MUST perform ICE restartprocedures as specified in Section 4.4.3.1.1.
-
If the offer/answer exchange removed a data stream, or ananswer rejected an offered data stream, an agent MUST flush thevalid list for that data stream. It MUST also terminate anySTUN transactions in progress for that data stream.
-
If the offer/answer exchange added a new data stream, the agentMUST create a new checklist for it (and an empty valid list tostart of course), which in turn triggers the candidateprocessing procedures [RFC 8445].
-
If the checklist state associated with a data stream is Running, the agentrecomputes the checklist. If a pair on the new checklist wasalso on the previous checklist, its candidate pair state is copied over. Otherwise, its candidate pair state is set to Frozen. If none of the checklists are active (meaning that the candidate pair states in each checklist are Frozen), appropriate procedures in [RFC 8445] are performed to move candidate pair(s) to the Waiting state to further continue ICE processing.
-
If the ICE state is Completed, and the SDP answer conforms toSection 4.4.2, the agent MUST remain in the Completed ICE state.
However, if the ICE support is no longer indicated in the SDP answer, the agent
MUST fall back to [
RFC 3264] procedures and
SHOULD NOT drop the dialog because of the missing ICE support or unexpected answer. When the agent sends a new offer, it
MUST perform an ICE restart.
The agent
MUST remember the nominated pair in the valid list for each component of the data stream, called the "previous selected pair", prior to the restart. The agent will continue to send media using this pair, as described in
Section 12 of
RFC 8445. Once these destinations are noted, the agent
MUST flush the valid lists and checklists, and then recompute the checklist and its states, thus triggering the candidate processing procedures [
RFC 8445].
If ICE is restarting for a data stream, the agent
MUST create a new valid list for that data stream. It
MUST remember the nominated pair in the previous valid list for each component of the data stream, called the "previous selected pairs", and continue to send media there as described in
Section 12 of
RFC 8445. The state of each checklist for each data stream
MUST change to Running, and the ICE state
MUST be set to Running.