idnits 2.17.1 draft-ietf-ice-rfc5245bis-19.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- == There are 15 instances of lines with private range IPv4 addresses in the document. If these are generic example addresses, they should be changed to use any of the ranges defined in RFC 6890 (or successor): 192.0.2.x, 198.51.100.x or 203.0.113.x. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 1522 has weird spacing: '... | f-cp f-cp ...' == Line 1524 has weird spacing: '... | f-cp f-cp ...' == Line 1534 has weird spacing: '... | w-cp w-cp ...' == Line 1536 has weird spacing: '... | f-cp f-cp ...' == Line 2721 has weird spacing: '...Address mnemo...' == (1 more instance...) == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (March 5, 2018) is 2237 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Obsolete normative reference: RFC 4941 (Obsoleted by RFC 8981) ** Obsolete normative reference: RFC 5389 (Obsoleted by RFC 8489) ** Obsolete normative reference: RFC 5766 (Obsoleted by RFC 8656) ** Obsolete normative reference: RFC 6336 (Obsoleted by RFC 8839) -- Obsolete informational reference (is this intentional?): RFC 3489 (Obsoleted by RFC 5389) -- Obsolete informational reference (is this intentional?): RFC 4566 (Obsoleted by RFC 8866) -- Obsolete informational reference (is this intentional?): RFC 4091 (Obsoleted by RFC 5245) -- Obsolete informational reference (is this intentional?): RFC 4092 (Obsoleted by RFC 5245) -- Obsolete informational reference (is this intentional?): RFC 5245 (Obsoleted by RFC 8445, RFC 8839) == Outdated reference: A later version (-39) exists of draft-ietf-mmusic-ice-sip-sdp-16 == Outdated reference: A later version (-12) exists of draft-ietf-rtcweb-ip-handling-06 Summary: 4 errors (**), 0 flaws (~~), 11 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 ICE A. Keranen 3 Internet-Draft C. Holmberg 4 Obsoletes: 5245 (if approved) Ericsson 5 Intended status: Standards Track J. Rosenberg 6 Expires: September 6, 2018 jdrosen.net 7 March 5, 2018 9 Interactive Connectivity Establishment (ICE): A Protocol for Network 10 Address Translator (NAT) Traversal 11 draft-ietf-ice-rfc5245bis-19 13 Abstract 15 This document describes a protocol for Network Address Translator 16 (NAT) traversal for UDP-based communication. This protocol is called 17 Interactive Connectivity Establishment (ICE). ICE makes use of the 18 Session Traversal Utilities for NAT (STUN) protocol and its 19 extension, Traversal Using Relay NAT (TURN). 21 This document obsoletes RFC 5245. 23 Status of This Memo 25 This Internet-Draft is submitted in full conformance with the 26 provisions of BCP 78 and BCP 79. 28 Internet-Drafts are working documents of the Internet Engineering 29 Task Force (IETF). Note that other groups may also distribute 30 working documents as Internet-Drafts. The list of current Internet- 31 Drafts is at http://datatracker.ietf.org/drafts/current/. 33 Internet-Drafts are draft documents valid for a maximum of six months 34 and may be updated, replaced, or obsoleted by other documents at any 35 time. It is inappropriate to use Internet-Drafts as reference 36 material or to cite them other than as "work in progress." 38 This Internet-Draft will expire on September 6, 2018. 40 Copyright Notice 42 Copyright (c) 2018 IETF Trust and the persons identified as the 43 document authors. All rights reserved. 45 This document is subject to BCP 78 and the IETF Trust's Legal 46 Provisions Relating to IETF Documents 47 (http://trustee.ietf.org/license-info) in effect on the date of 48 publication of this document. Please review these documents 49 carefully, as they describe your rights and restrictions with respect 50 to this document. Code Components extracted from this document must 51 include Simplified BSD License text as described in Section 4.e of 52 the Trust Legal Provisions and are provided without warranty as 53 described in the Simplified BSD License. 55 This document may contain material from IETF Documents or IETF 56 Contributions published or made publicly available before November 57 10, 2008. The person(s) controlling the copyright in some of this 58 material may not have granted the IETF Trust the right to allow 59 modifications of such material outside the IETF Standards Process. 60 Without obtaining an adequate license from the person(s) controlling 61 the copyright in such materials, this document may not be modified 62 outside the IETF Standards Process, and derivative works of it may 63 not be created outside the IETF Standards Process, except to format 64 it for publication as an RFC or to translate it into languages other 65 than English. 67 Table of Contents 69 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 5 70 2. Overview of ICE . . . . . . . . . . . . . . . . . . . . . . . 6 71 2.1. Gathering Candidates . . . . . . . . . . . . . . . . . . 8 72 2.2. Connectivity Checks . . . . . . . . . . . . . . . . . . . 10 73 2.3. Nominating Candidate Pairs And Concluding ICE . . . . . . 12 74 2.4. ICE Restart . . . . . . . . . . . . . . . . . . . . . . . 13 75 2.5. Lite Implementations . . . . . . . . . . . . . . . . . . 13 76 3. ICE Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 13 77 4. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 13 78 5. ICE Candidate Gathering and Exchange . . . . . . . . . . . . 17 79 5.1. Full Implementation . . . . . . . . . . . . . . . . . . . 17 80 5.1.1. Gathering Candidates . . . . . . . . . . . . . . . . 17 81 5.1.1.1. Host Candidates . . . . . . . . . . . . . . . . . 18 82 5.1.1.2. Server Reflexive and Relayed Candidates . . . . . 19 83 5.1.1.3. Computing Foundations . . . . . . . . . . . . . . 21 84 5.1.1.4. Keeping Candidates Alive . . . . . . . . . . . . 21 85 5.1.2. Prioritizing Candidates . . . . . . . . . . . . . . . 22 86 5.1.2.1. Recommended Formula . . . . . . . . . . . . . . . 22 87 5.1.2.2. Guidelines for Choosing Type and Local 88 Preferences . . . . . . . . . . . . . . . . . . . 23 89 5.1.3. Eliminating Redundant Candidates . . . . . . . . . . 23 90 5.2. Lite Implementation Procedures . . . . . . . . . . . . . 23 91 5.3. Exchanging Candidate Information . . . . . . . . . . . . 24 92 5.4. ICE Mismatch . . . . . . . . . . . . . . . . . . . . . . 26 93 6. ICE Candidate Processing . . . . . . . . . . . . . . . . . . 26 94 6.1. Procedures for Full Implementation . . . . . . . . . . . 26 95 6.1.1. Determining Role . . . . . . . . . . . . . . . . . . 26 96 6.1.2. Forming the Check Lists . . . . . . . . . . . . . . . 28 97 6.1.2.1. Check List State . . . . . . . . . . . . . . . . 28 98 6.1.2.2. Forming Candidate Pairs . . . . . . . . . . . . . 28 99 6.1.2.3. Computing Pair Priority and Ordering Pairs . . . 31 100 6.1.2.4. Pruning the Pairs . . . . . . . . . . . . . . . . 31 101 6.1.2.5. Removing lower-priority Pairs . . . . . . . . . . 31 102 6.1.2.6. Computing Candidate Pair States . . . . . . . . . 32 103 6.1.3. ICE State . . . . . . . . . . . . . . . . . . . . . . 35 104 6.1.4. Scheduling Checks . . . . . . . . . . . . . . . . . . 35 105 6.1.4.1. Triggered Check Queue . . . . . . . . . . . . . . 35 106 6.1.4.2. Performing Connectivity Checks . . . . . . . . . 36 107 6.2. Lite Implementation Procedures . . . . . . . . . . . . . 37 108 7. Performing Connectivity Checks . . . . . . . . . . . . . . . 37 109 7.1. STUN Extensions . . . . . . . . . . . . . . . . . . . . . 37 110 7.1.1. PRIORITY . . . . . . . . . . . . . . . . . . . . . . 38 111 7.1.2. USE-CANDIDATE . . . . . . . . . . . . . . . . . . . . 38 112 7.1.3. ICE-CONTROLLED and ICE-CONTROLLING . . . . . . . . . 38 113 7.2. STUN Client Procedures . . . . . . . . . . . . . . . . . 38 114 7.2.1. Creating Permissions for Relayed Candidates . . . . . 38 115 7.2.2. Forming Credentials . . . . . . . . . . . . . . . . . 38 116 7.2.3. DiffServ Treatment . . . . . . . . . . . . . . . . . 39 117 7.2.4. Sending the Request . . . . . . . . . . . . . . . . . 39 118 7.2.5. Processing the Response . . . . . . . . . . . . . . . 39 119 7.2.5.1. Role Conflict . . . . . . . . . . . . . . . . . . 40 120 7.2.5.2. Failure . . . . . . . . . . . . . . . . . . . . . 40 121 7.2.5.2.1. Non-Symmetric Transport Addresses . . . . . . 40 122 7.2.5.2.2. ICMP Error . . . . . . . . . . . . . . . . . 41 123 7.2.5.2.3. Timeout . . . . . . . . . . . . . . . . . . . 41 124 7.2.5.2.4. Unrecoverable STUN Response . . . . . . . . . 41 125 7.2.5.3. Success . . . . . . . . . . . . . . . . . . . . . 41 126 7.2.5.3.1. Discovering Peer Reflexive Candidates . . . . 41 127 7.2.5.3.2. Constructing a Valid Pair . . . . . . . . . . 42 128 7.2.5.3.3. Updating Candidate Pair States . . . . . . . 43 129 7.2.5.3.4. Updating the Nominated Flag . . . . . . . . . 43 130 7.2.5.4. Check List State Updates . . . . . . . . . . . . 44 131 7.3. STUN Server Procedures . . . . . . . . . . . . . . . . . 44 132 7.3.1. Additional Procedures for Full Implementations . . . 45 133 7.3.1.1. Detecting and Repairing Role Conflicts . . . . . 45 134 7.3.1.2. Computing Mapped Address . . . . . . . . . . . . 46 135 7.3.1.3. Learning Peer Reflexive Candidates . . . . . . . 46 136 7.3.1.4. Triggered Checks . . . . . . . . . . . . . . . . 47 137 7.3.1.5. Updating the Nominated Flag . . . . . . . . . . . 48 138 7.3.2. Additional Procedures for Lite Implementations . . . 48 139 8. Concluding ICE Processing . . . . . . . . . . . . . . . . . . 49 140 8.1. Procedures for Full Implementations . . . . . . . . . . . 49 141 8.1.1. Nominating Pairs . . . . . . . . . . . . . . . . . . 49 142 8.1.2. Updating States . . . . . . . . . . . . . . . . . . . 50 143 8.2. Procedures for Lite Implementations . . . . . . . . . . . 51 144 8.3. Freeing Candidates . . . . . . . . . . . . . . . . . . . 52 145 8.3.1. Full Implementation Procedures . . . . . . . . . . . 52 146 8.3.2. Lite Implementation Procedures . . . . . . . . . . . 52 147 9. ICE Restarts . . . . . . . . . . . . . . . . . . . . . . . . 53 148 10. ICE Option . . . . . . . . . . . . . . . . . . . . . . . . . 53 149 11. Keepalives . . . . . . . . . . . . . . . . . . . . . . . . . 54 150 12. Data Handling . . . . . . . . . . . . . . . . . . . . . . . . 55 151 12.1. Sending Data . . . . . . . . . . . . . . . . . . . . . . 55 152 12.1.1. Procedures for Lite Implementations . . . . . . . . 55 153 12.2. Receiving Data . . . . . . . . . . . . . . . . . . . . . 56 154 13. Extensibility Considerations . . . . . . . . . . . . . . . . 56 155 14. Setting Ta and RTO . . . . . . . . . . . . . . . . . . . . . 57 156 14.1. General . . . . . . . . . . . . . . . . . . . . . . . . 57 157 14.2. Ta . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 158 14.3. RTO . . . . . . . . . . . . . . . . . . . . . . . . . . 58 159 15. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 59 160 15.1. Example with IPv4 Addresses . . . . . . . . . . . . . . 59 161 15.2. Example with IPv6 Addresses . . . . . . . . . . . . . . 65 162 16. STUN Extensions . . . . . . . . . . . . . . . . . . . . . . . 69 163 16.1. New Attributes . . . . . . . . . . . . . . . . . . . . . 69 164 16.2. New Error Response Codes . . . . . . . . . . . . . . . . 69 165 17. Operational Considerations . . . . . . . . . . . . . . . . . 70 166 17.1. NAT and Firewall Types . . . . . . . . . . . . . . . . . 70 167 17.2. Bandwidth Requirements . . . . . . . . . . . . . . . . . 70 168 17.2.1. STUN and TURN Server Capacity Planning . . . . . . . 70 169 17.2.2. Gathering and Connectivity Checks . . . . . . . . . 71 170 17.2.3. Keepalives . . . . . . . . . . . . . . . . . . . . . 71 171 17.3. ICE and ICE-lite . . . . . . . . . . . . . . . . . . . . 72 172 17.4. Troubleshooting and Performance Management . . . . . . . 72 173 17.5. Endpoint Configuration . . . . . . . . . . . . . . . . . 72 174 18. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 72 175 18.1. Problem Definition . . . . . . . . . . . . . . . . . . . 73 176 18.2. Exit Strategy . . . . . . . . . . . . . . . . . . . . . 73 177 18.3. Brittleness Introduced by ICE . . . . . . . . . . . . . 74 178 18.4. Requirements for a Long-Term Solution . . . . . . . . . 75 179 18.5. Issues with Existing NAPT Boxes . . . . . . . . . . . . 75 180 19. Security Considerations . . . . . . . . . . . . . . . . . . . 75 181 19.1. IP Address Privacy . . . . . . . . . . . . . . . . . . . 76 182 19.2. Attacks on Connectivity Checks . . . . . . . . . . . . . 76 183 19.3. Attacks on Server Reflexive Address Gathering . . . . . 79 184 19.4. Attacks on Relayed Candidate Gathering . . . . . . . . . 80 185 19.5. Insider Attacks . . . . . . . . . . . . . . . . . . . . 80 186 19.5.1. STUN Amplification Attack . . . . . . . . . . . . . 80 187 20. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 81 188 20.1. STUN Attributes . . . . . . . . . . . . . . . . . . . . 81 189 20.2. STUN Error Responses . . . . . . . . . . . . . . . . . . 82 190 20.3. ICE Options . . . . . . . . . . . . . . . . . . . . . . 82 191 21. Changes from RFC 5245 . . . . . . . . . . . . . . . . . . . . 83 192 22. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 84 193 23. References . . . . . . . . . . . . . . . . . . . . . . . . . 84 194 23.1. Normative References . . . . . . . . . . . . . . . . . . 84 195 23.2. Informative References . . . . . . . . . . . . . . . . . 85 196 Appendix A. Lite and Full Implementations . . . . . . . . . . . 89 197 Appendix B. Design Motivations . . . . . . . . . . . . . . . . . 90 198 B.1. Pacing of STUN Transactions . . . . . . . . . . . . . . . 90 199 B.2. Candidates with Multiple Bases . . . . . . . . . . . . . 92 200 B.3. Purpose of the Related Address and Related Port 201 Attributes . . . . . . . . . . . . . . . . . . . . . . . 94 202 B.4. Importance of the STUN Username . . . . . . . . . . . . . 94 203 B.5. The Candidate Pair Priority Formula . . . . . . . . . . . 96 204 B.6. Why Are Keepalives Needed? . . . . . . . . . . . . . . . 96 205 B.7. Why Prefer Peer Reflexive Candidates? . . . . . . . . . . 97 206 B.8. Why Are Binding Indications Used for Keepalives? . . . . 97 207 B.9. Selecting Candidate Type Preference . . . . . . . . . . . 97 208 Appendix C. Connectivity Check Bandwidth . . . . . . . . . . . . 98 209 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 99 211 1. Introduction 213 Protocols establishing communication sessions between peers typically 214 involve exchanging IP addresses and ports for the data sources and 215 sinks. However, this poses challenges when operated through Network 216 Address Translators (NATs) [RFC3235]. These protocols also seek to 217 create a data flow directly between participants, so that there is no 218 application layer intermediary between them. This is done to reduce 219 data latency, decrease packet loss, and reduce the operational costs 220 of deploying the application. However, this is difficult to 221 accomplish through NATs. A full treatment of the reasons for this is 222 beyond the scope of this specification. 224 Numerous solutions have been defined for allowing these protocols to 225 operate through NATs. These include Application Layer Gateways 226 (ALGs), the Middlebox Control Protocol [RFC3303], the original Simple 227 Traversal of UDP Through NAT (STUN) [RFC3489] specification, and 228 Realm Specific IP [RFC3102] [RFC3103] along with session description 229 extensions needed to make them work, such as the Session Description 230 Protocol (SDP) [RFC4566] attribute for the Real Time Control Protocol 231 (RTCP) [RFC3605]. Unfortunately, these techniques all have pros and 232 cons that make each one optimal in some network topologies, but a 233 poor choice in others. The result is that administrators and 234 implementers are making assumptions about the topologies of the 235 networks in which their solutions will be deployed. This introduces 236 complexity and brittleness into the system. 238 This specification defines Interactive Connectivity Establishment 239 (ICE) as a technique for NAT traversal for UDP-based data streams 240 (though ICE has been extended to handle other transport protocols, 241 such as TCP [RFC6544]). ICE works by exchanging a multiplicity of IP 242 addresses and ports which are then tested for connectivity by peer- 243 to-peer connectivity checks. The IP addresses and ports are 244 exchanged using ICE usage-specific mechanisms (e.g., including in a 245 offer/answer exchange) and the connectivity checks are performed 246 using STUN [RFC5389]. ICE also makes use of Traversal Using Relays 247 around NAT (TURN) [RFC5766], an extension to STUN. Because ICE 248 exchanges a multiplicity of IP addresses and ports for each media 249 stream, it also allows for address selection for multihomed and dual- 250 stack hosts. For this reason, RFC 5245 [RFC5245] deprecated the 251 solutions previously defined in RFC 4091 [RFC4091] and RFC 4092 252 [RFC4092]. 254 Appendix B provides background information and motivations regarding 255 the design decisions that were made when designing ICE. 257 2. Overview of ICE 259 In a typical ICE deployment, there are two endpoints (ICE agents) 260 that want to communicate. Note that ICE is not intended for NAT 261 traversal for the signaling protocol, which is assumed to be provided 262 via another mechanism. ICE assumes that the agents are able to 263 establish a signaling connection between each other. 265 Initially, the agents are ignorant of their own topologies. In 266 particular, the agents may or may not be behind NATs (or multiple 267 tiers of NATs). ICE allows the agents to discover enough information 268 about their topologies to potentially find one or more paths by which 269 they can establish a data session. 271 Figure 1 shows a typical ICE deployment. The agents are labelled L 272 and R. Both L and R are behind their own respective NATs though they 273 may not be aware of it. The type of NAT and its properties are also 274 unknown. L and R are capable of engaging in a candidate exchange 275 process, whose purpose is to set up a data session between L and R. 276 Typically, this exchange will occur through a signaling server (e.g., 277 SIP proxy). 279 In addition to the agents, a signaling server, and NATs, ICE is 280 typically used in concert with STUN or TURN servers in the network. 281 Each agent can have its own STUN or TURN server, or they can be the 282 same. 284 +---------+ 285 +--------+ |Signaling| +--------+ 286 | STUN | |Server | | STUN | 287 | Server | +---------+ | Server | 288 +--------+ / \ +--------+ 289 / \ 290 / \ 291 / <- Signaling -> \ 292 / \ 293 +--------+ +--------+ 294 | NAT | | NAT | 295 +--------+ +--------+ 296 / \ 297 / \ 298 +-------+ +-------+ 299 | Agent | | Agent | 300 | L | | R | 301 +-------+ +-------+ 303 Figure 1: ICE Deployment Scenario 305 The basic idea behind ICE is as follows: each agent has a variety of 306 candidate transport addresses (combination of IP address and port for 307 a particular transport protocol, which is always UDP in this 308 specification) it could use to communicate with the other agent. 309 These might include: 311 o A transport address on a directly attached network interface 313 o A translated transport address on the public side of a NAT (a 314 "server reflexive" address) 316 o A transport address allocated from a TURN server (a "relayed 317 address") 319 Potentially, any of L's candidate transport addresses can be used to 320 communicate with any of R's candidate transport addresses. In 321 practice, however, many combinations will not work. For instance, if 322 L and R are both behind NATs, their directly attached interface 323 addresses are unlikely to be able to communicate directly (this is 324 why ICE is needed, after all!). The purpose of ICE is to discover 325 which pairs of addresses will work. The way that ICE does this is to 326 systematically try all possible pairs (in a carefully sorted order) 327 until it finds one or more that work. 329 2.1. Gathering Candidates 331 In order to execute ICE, an ICE agent identifies and gathers one or 332 more address candidates. A candidate has a transport address -- a 333 combination of IP address and port for a particular transport 334 protocol (with only UDP specified here). There are different types 335 of candidates, some derived from physical or logical network 336 interfaces, others discoverable via STUN and TURN. 338 The first category of candidates are those with a transport address 339 obtained directly from a local interface. Such a candidate is called 340 a host candidate. The local interface could be Ethernet or WiFi, or 341 it could be one that is obtained through a tunnel mechanism, such as 342 a Virtual Private Network (VPN) or Mobile IP (MIP). In all cases, 343 such a network interface appears to the agent as a local interface 344 from which ports (and thus candidates) can be allocated. 346 Next, the agent uses STUN or TURN to obtain additional candidates. 347 These come in two flavors: translated addresses on the public side of 348 a NAT (server reflexive candidates) and addresses on TURN servers 349 (relayed candidates). When TURN servers are utilized, both types of 350 candidates are obtained from the TURN server. If only STUN servers 351 are utilized, only server reflexive candidates are obtained from 352 them. The relationship of these candidates to the host candidate is 353 shown in Figure 2. In this figure, both types of candidates are 354 discovered using TURN. In the figure, the notation X:x means IP 355 address X and UDP port x. 357 To Internet 359 | 360 | 361 | /------------ Relayed 362 Y:y | / Address 363 +--------+ 364 | | 365 | TURN | 366 | Server | 367 | | 368 +--------+ 369 | 370 | 371 | /------------ Server 372 X1':x1'|/ Reflexive 373 +------------+ Address 374 | NAT | 375 +------------+ 376 | 377 | /------------ Local 378 X:x |/ Address 379 +--------+ 380 | | 381 | Agent | 382 | | 383 +--------+ 385 Figure 2: Candidate Relationships 387 When the agent sends a TURN Allocate request from IP address and port 388 X:x, the NAT (assuming there is one) will create a binding X1':x1', 389 mapping this server reflexive candidate to the host candidate X:x. 390 Outgoing packets sent from the host candidate will be translated by 391 the NAT to the server reflexive candidate. Incoming packets sent to 392 the server reflexive candidate will be translated by the NAT to the 393 host candidate and forwarded to the agent. The host candidate 394 associated with a given server reflexive candidate is the BASE. 396 Note: "Base" refers to the address an agent sends from for a 397 particular candidate. Thus, as a degenerate case, host candidates 398 also have a base, but it's the same as the host candidate. 400 When there are multiple NATs between the agent and the TURN server, 401 the TURN request will create a binding on each NAT, but only the 402 outermost server reflexive candidate (the one nearest the TURN 403 server) will be discovered by the agent. If the agent is not behind 404 a NAT, then the base candidate will be the same as the server 405 reflexive candidate and the server reflexive candidate is redundant 406 and will be eliminated. 408 The Allocate request then arrives at the TURN server. The TURN 409 server allocates a port y from its local IP address Y, and generates 410 an Allocate response, informing the agent of this relayed candidate. 411 The TURN server also informs the agent of the server reflexive 412 candidate, X1':x1' by copying the source transport address of the 413 Allocate request into the Allocate response. The TURN server acts as 414 a packet relay, forwarding traffic between L and R. In order to send 415 traffic to L, R sends traffic to the TURN server at Y:y, and the TURN 416 server forwards that to X1':x1', which passes through the NAT where 417 it is mapped to X:x and delivered to L. 419 When only STUN servers are utilized, the agent sends a STUN Binding 420 request [RFC5389] to its STUN server. The STUN server will inform 421 the agent of the server reflexive candidate X1':x1' by copying the 422 source transport address of the Binding request into the Binding 423 response. 425 2.2. Connectivity Checks 427 Once L has gathered all of its candidates, it orders them in highest 428 to lowest-priority and sends them to R over the signaling channel. 429 When R receives the candidates from L, it performs the same gathering 430 process and responds with its own list of candidates. At the end of 431 this process, each ICE agent has a complete list of both its 432 candidates and its peer's candidates. It pairs them up, resulting in 433 candidate pairs. To see which pairs work, each agent schedules a 434 series of connectivity checks. Each check is a STUN request/response 435 transaction that the client will perform on a particular candidate 436 pair by sending a STUN request from the local candidate to the remote 437 candidate. 439 The basic principle of the connectivity checks is simple: 441 1. Sort the candidate pairs in priority order. 443 2. Send checks on each candidate pair in priority order. 445 3. Acknowledge checks received from the other agent. 447 With both agents performing a check on a candidate pair, the result 448 is a 4-way handshake: 450 L R 451 - - 452 STUN request -> \ L's 453 <- STUN response / check 455 <- STUN request \ R's 456 STUN response -> / check 458 Figure 3: Basic Connectivity Check 460 It is important to note that the STUN requests are sent to and from 461 the exact same IP addresses and ports that will be used for data 462 (e.g., RTP, RTCP, or other protocols). Consequently, agents 463 demultiplex STUN and data using the contents of the packets, rather 464 than the port on which they are received. 466 Because a STUN Binding request is used for the connectivity check, 467 the STUN Binding response will contain the agent's translated 468 transport address on the public side of any NATs between the agent 469 and its peer. If this transport address is different from that of 470 other candidates the agent already learned, it represents a new 471 candidate (peer reflexive candidate), which then gets tested by ICE 472 just the same as any other candidate. 474 Because the algorithm above searches all candidate pairs, if a 475 working pair exists it will eventually find it no matter what order 476 the candidates are tried in. In order to produce faster (and better) 477 results, the candidates are sorted in a specified order. The 478 resulting list of sorted candidate pairs is called the check list. 480 The agent works through the check list by sending a STUN request for 481 the next candidate pair on the list periodically. These are called 482 "ordinary checks". When a STUN transaction succeeds, one or more 483 candidate pairs will become so called valid pairs, and will be added 484 to a candidate pair list called the valid list. 486 As an optimization, as soon as R gets L's check message, R schedules 487 a connectivity check message to be sent to L on the same candidate 488 pair. This is called a "triggered check", and accelerates the 489 process of finding valid pairs. 491 At the end of this handshake, both L and R know that they can send 492 (and receive) messages end-to-end in both directions. 494 In general, the priority algorithm is designed so that candidates of 495 similar type get similar priorities and so that more direct routes 496 (that is, routes without data relays or NATs) are preferred over 497 indirect routes (routes with data relays or NATs). Within those 498 guidelines, however, agents have a fair amount of discretion about 499 how to tune their algorithms. 501 A data stream might consist of multiple components (pieces of a data 502 stream that require their own set of candidates, e.g., RTP and RTCP). 504 2.3. Nominating Candidate Pairs And Concluding ICE 506 ICE assigns one of the ICE agents in the role of the controlling 507 agent, and the other of the controlled agent. For each component of 508 a data stream, the controlling agent nominates a valid pair (from the 509 valid list) to be used for data. The exact timing of the nomination 510 is based on local policy. 512 When nominating, the controlling agent lets the checks continue until 513 at least one valid pair for each component of a data stream is found 514 and then picks a valid pair and sends a STUN request on the valid 515 pair, using an attribute to indicate to the controlled peer that it 516 has nominated the pair. This is shown in Figure 4. 518 L R 519 - - 520 STUN request -> \ L's 521 <- STUN response / check 523 <- STUN request \ R's 524 STUN response -> / check 526 STUN request + attribute -> \ L's 527 <- STUN response / check 529 Figure 4: Nomination 531 Once the controlled agent receives the STUN request with the 532 attribute, it will check (unless the check has already been done) the 533 same pair. If the transactions above succeed, the agents will set 534 the nominated flag for the pairs, and will cancel any future checks 535 for that component of the data stream. Once an agent has set the 536 nominated flag for each component of a data stream, the pairs become 537 the selected pairs. After that, only the selected pairs will be used 538 for sending and receiving data associated with that data stream. 540 2.4. ICE Restart 542 Once ICE is concluded, it can be restarted at any time for one or all 543 of the data streams by either ICE agent. This is done by sending 544 updated candidate information indicating a restart. 546 2.5. Lite Implementations 548 Certain ICE agents will always be connected to the public Internet 549 and have a public IP address at which it can receive packets from any 550 correspondent. To make it easier for these devices to support ICE, 551 ICE defines a special type of implementation called lite (in contrast 552 to the normal full implementation). Lite agents only use host 553 candidates and do not generate connectivity checks or run the state 554 machines, though they need to be able to respond to connectivity 555 checks. 557 3. ICE Usage 559 This document specifies generic use of ICE with protocols that 560 provide means to exchange candidate information between the ICE 561 agents. The specific details (i.e., how to encode candidate 562 information and the actual candidate exchange process) for different 563 protocols using ICE (referred to as "using protocol") are described 564 in separate usage documents. 566 One mechanism for agents to exchange the candidate information by 567 using [RFC3264] based Offer/Answer semantics as part of the SIP 568 [RFC3261] protocol [I-D.ietf-mmusic-ice-sip-sdp]. 570 [RFC7825] defines an ICE usage for the Real-Time Streaming Protocol 571 (RTSP). Note, however, that the ICE usage is based on RFC 5245. 573 4. Terminology 575 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 576 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 577 "OPTIONAL" in this document are to be interpreted as described in RFC 578 2119 [RFC2119]. 580 Readers need to be familiar with the terminology defined in 581 [RFC5389], and NAT Behavioral requirements for UDP [RFC4787]. 583 This specification makes use of the following additional terminology: 585 ICE Session: An ICE session consists of all ICE-related actions 586 starting with the candidate gathering, followed by the 587 interactions (candidate exchange, connectivity checks, nominations 588 and keepalives) between the ICE agents until all the candidates 589 are released or ICE restart is triggered. 591 ICE Agent, Agent: An ICE agent (sometimes simply referred to as an 592 agent) is the protocol implementation involved in the ICE 593 candidate exchange. There are two agents involved in a typical 594 candidate exchange. 596 Initiating Peer, Initiating Agent, Initiator: An initiating agent is 597 an ICE agent that initiates the ICE candidate exchange process. 599 Responding Peer, Responding Agent, Responder: A responding agent is 600 an ICE agent that receives and responds to the candidate exchange 601 process initiated by the initiating agent. 603 ICE Candidate Exchange, Candidate Exchange: The process where the 604 ICE agents exchange information (e.g., candidates and passwords) 605 that is needed to perform ICE. [RFC3264] Offer/Answer with SDP 606 encoding is one example of a protocol that can be used for 607 exchanging the candidate information. 609 Peer: From the perspective of one of the ICE agents in a session, 610 its peer is the other agent. Specifically, from the perspective 611 of the initiating agent, the peer is the responding agent. From 612 the perspective of the responding agent, the peer is the 613 initiating agent. 615 Transport Address: The combination of an IP address and transport 616 protocol (such as UDP or TCP) port. 618 Data, Data Stream, Data Session: When ICE is used to setup data 619 sessions, the data is transported using some protocol. Media is 620 usually transported over RTP, composed of a stream of RTP packets. 621 Data session refers to data packets that are exchanged between the 622 peer on the path created and tested with ICE. 624 Candidate, Candidate Information: A transport address that is a 625 potential point of contact for receipt of data. Candidates also 626 have properties -- their type (server reflexive, relayed, or 627 host), priority, foundation, and base. 629 Component: A component is a piece of a data stream. A data stream 630 may require multiple components, each of which has to work in 631 order for the data stream as a whole to work. For RTP/RTCP data 632 streams, unless RTP and RTCP are multiplexed in the same port, 633 there are two components per data stream -- one for RTP, and one 634 for RTCP. A component has a candidate pair, which cannot be used 635 by other components. 637 Host Candidate: A candidate obtained by binding to a specific port 638 from an IP address on the host. This includes IP addresses on 639 physical interfaces and logical ones, such as ones obtained 640 through Virtual Private Networks (VPNs). 642 Server Reflexive Candidate: A candidate whose IP address and port 643 are a binding allocated by a NAT for an ICE agent when it sent a 644 packet through the NAT to a server, such as a STUN server. 646 Peer Reflexive Candidate: A candidate whose IP address and port are 647 a binding allocated by a NAT for an ICE agent when it sent a 648 packet through the NAT to its peer. 650 Relayed Candidate: A candidate obtained from a relay server, such as 651 a TURN server. 653 Base: The transport address that an ICE agent sends from for a 654 particular candidate. For host, server reflexive and peer 655 reflexive candidates the base is the same as the host candidate. 656 For relayed candidates the base is the same as the relayed 657 candidate (i.e., the transport address used by the TURN server to 658 send from). 660 Related Address and Port: A transport address related to a 661 candidate, useful for diagnostics and other purposes. If a 662 candidate is server or peer reflexive, the related address and 663 port is equal to the base for that server or peer reflexive 664 candidate. If the candidate is relayed, the related address and 665 port is equal to the mapped address in the Allocate response that 666 provided the client with that relayed candidate. If the candidate 667 is a host candidate, the related address and port is identical to 668 the host candidate. 670 Foundation: An arbitrary string used in the freezing algorithm to 671 group similar candidates. Is the same for two candidates that 672 have the same type, base IP address, protocol (UDP, TCP, etc.), 673 and STUN or TURN server. If any of these are different, then the 674 foundation will be different. 676 Local Candidate: A candidate that an ICE agent has obtained and may 677 send to its peer. 679 Remote Candidate: A candidate that an ICE agent received from its 680 peer. 682 Default Destination/Candidate: The default destination for a 683 component of a data stream is the transport address that would be 684 used by an ICE agent that is not ICE-aware. A default candidate 685 for a component is one whose transport address matches the default 686 destination for that component. 688 Candidate Pair: A pair of a local candidate and a remote candidate. 690 Check, Connectivity Check, STUN Check: A STUN Binding request for 691 the purposes of verifying connectivity. A check is sent from the 692 base of the local candidate to the remote candidate of a candidate 693 pair. 695 Check List: An ordered set of candidate pairs that an ICE agent will 696 use to generate checks. 698 Ordinary Check: A connectivity check generated by an ICE agent as a 699 consequence of a timer that fires periodically, instructing it to 700 send a check. 702 Triggered Check: A connectivity check generated as a consequence of 703 the receipt of a connectivity check from the peer. 705 Valid Pair: A candidate pair whose local candidate equals the mapped 706 address of a successful connectivity check response, and whose 707 remote candidate equals the destination address to which the 708 connectivity check request was sent. 710 Valid List: An ordered set of candidate pairs for a data stream that 711 have been validated by a successful STUN transaction. 713 Check List Set: The ordered list of all check lists. The order is 714 determined by each ICE usage. 716 Full Implementation: An ICE implementation that performs the 717 complete set of functionality defined by this specification. 719 Lite Implementation: An ICE implementation that omits certain 720 functions, implementing only as much as is necessary for a peer 721 implementation that is full to gain the benefits of ICE. Lite 722 implementations do not maintain any of the state machines and do 723 not generate connectivity checks. 725 Controlling Agent: The ICE agent that nominates a candidate pair. 726 In any session, one agent is always controlling. The other is the 727 controlled agent. 729 Controlled Agent: The ICE agent that waits for the controlling agent 730 to nominate a candidate pair. 732 Nomination: The process of the controlling agent indicating to the 733 controlled agent which candidate pair the ICE agents will use for 734 sending and receiving data. The nomination process defined in 735 this specification was referred to "regular nomination" in RFC 736 5245. The nomination process that was referred to "aggressive 737 nomination" in RFC 5245 has been deprecated in this specification. 739 Nominated, Nominated Flag: Once the nomination of a candidate pair 740 has succeeded, the candidate pair has become nominated, and the 741 value of its nominated flag is set to true. 743 Selected Pair, Selected Candidate Pair: The candidate pair used for 744 sending and receiving data for a component of a data stream is 745 referred to as the selected pair. Before selected pairs have been 746 produced for a data stream, any valid pair associated with a 747 component of a data stream can be used for sending and receiving 748 data for the component. Once there are nominated pairs for each 749 component of a data stream, the nominated pairs become the 750 selected pairs for the data stream. The candidates associated 751 with the selected pairs are referred to as selected candidates. 753 Using Protocol, ICE Usage: The protocol that uses ICE for NAT 754 traversal. A usage specification defines the protocol-specific 755 details on how the procedures defined here are applied to that 756 protocol. 758 Timer Ta: The timer for generating new STUN or TURN transactions. 760 Timer RTO (Retransmission Timout): The retransmission timer for a 761 given STUN or TURN transaction. 763 5. ICE Candidate Gathering and Exchange 765 As part of ICE processing, both the initiating and responding agents 766 gather candidates, prioritize and eliminate redundant candidates, and 767 exchange candidate information with the peer as defined by the Usage 768 Protocol (ICE Usage). Specifics of the candidate encoding mechanism 769 and the semantics of candidate information exchange is out of scope 770 of this specification. 772 5.1. Full Implementation 774 5.1.1. Gathering Candidates 776 An ICE agent gathers candidates when it believes that communication 777 is imminent. An initiating agent can do this based on a user 778 interface cue, or based on an explicit request to initiate a session. 779 Every candidate has a transport address. It also has a type and a 780 base. Four types are defined and gathered by this specification -- 781 host candidates, server reflexive candidates, peer reflexive 782 candidates, and relayed candidates. The server reflexive candidates 783 are gathered using STUN or TURN, and relayed candidates are obtained 784 through TURN. Peer reflexive candidates are obtained in later phases 785 of ICE, as a consequence of connectivity checks. 787 The process for gathering candidates at the responding agent is 788 identical to the process for the initiating agent. It is RECOMMENDED 789 that the responding agent begins this process immediately on receipt 790 of the candidate information, prior to alerting the user of the 791 application associated with the ICE session. 793 5.1.1.1. Host Candidates 795 Host candidates are obtained by binding to ports on an IP address 796 attached to an interface (physical or virtual, including VPN 797 interfaces) on the host. 799 For each component of each data stream the ICE agent wishes to use, 800 the agent SHOULD obtain a candidate on each IP address that the host 801 has, with the exceptions listed below. The agent obtains each 802 candidate by binding to a UDP port on the specific IP address. A 803 host candidate (and indeed every candidate) is always associated with 804 a specific component for which it is a candidate. 806 Each component has an ID assigned to it, called the component ID. 807 For RTP/RTCP data streams, unless both RTP and RTCP are multiplexed 808 in the same UDP port (RTP/RTCP multiplexing), the RTP itself has a 809 component ID of 1, and RTCP a component ID of 2. In case of RTP/RTCP 810 multiplexing, a component ID of 1 is used for both RTP and RTCP. 812 When candidates are obtained, unless the agent knows for sure that 813 RTP/RTCP multiplexing will be used (i.e., the agent knows that the 814 other agent also supports, and is willing to use, RTP/RTCP 815 multiplexing), or unless the agent only supports RTP/RTCP 816 multiplexing, the agent MUST obtain a separate candidate for RTCP. 817 If an agent has obtained a candidate for RTCP, and ends up using RTP/ 818 RTCP multiplexing, the agent does not need to perform connectivity 819 checks on the RTCP candidate. Absence of a component ID 2 as such 820 does not imply use of RTCP/RTP multiplexing, as it could also mean 821 that RTCP is not used. 823 If an agent is using separate candidates for RTP and RTCP, it will 824 end up with 2*K host candidates if an agent has K IP addresses. 826 Note that the responding agent, when obtaining its candidates, will 827 typically know if the other agent supports RTP/RTCP multiplexing, in 828 which case it will not need to obtain a separate candidate for RTCP. 829 However, absence of a component ID 2 as such does not imply use of 830 RTCP/RTP multiplexing, as it could also mean that RTCP is not used. 832 For uses other than RTP/RTCP streams, use of multiple components is 833 discouraged, since using them increases the complexity of ICE 834 processing. If multiple components are needed, the component IDs 835 SHOULD start with 1 and increase by 1 for each component. 837 The base for each host candidate is set to the candidate itself. 839 The host candidates are gathered from all IP addresses with the 840 following exceptions: 842 o Addresses from a loopback interface MUST NOT be included in the 843 candidate addresses. 845 o Deprecated IPv4-compatible IPv6 addresses [RFC4291] and IPv6 site- 846 local unicast addresses [RFC3879] MUST NOT be included in the 847 address candidates. 849 o IPv4-mapped IPv6 addresses SHOULD NOT be included in the address 850 candidates unless the application using ICE does not support IPv4 851 (i.e., is an IPv6-only application [RFC4038]). 853 o If one or more host candidates corresponding to an IPv6 address 854 generated using a mechanism that prevents location tracking 855 [RFC7721] are gathered, host candidates corresponding to IPv6 856 addresses that do allow location tracking that are configured on 857 the same interface and are part of the same network prefix MUST 858 NOT be gathered. Similarly, when host candidates corresponding to 859 an IPv6 address generated using a mechanism that prevents location 860 tracking are gathered, then host candidates corresponding to IPv6 861 link-local addresses [RFC4291] MUST NOT be gathered. 863 The IPv6 default address selection specification [RFC6724] specifies 864 that temporary addresses [RFC4941] are to be preferred over permanent 865 addresses. 867 5.1.1.2. Server Reflexive and Relayed Candidates 869 An ICE agent SHOULD gather server reflexive and relayed candidates. 870 However, use of STUN and TURN servers may be unnecessary in certain 871 networks and use of TURN servers may be expensive, so some 872 deployments may elect not to use them. If an agent does not gather 873 server reflexive or relayed candidates, it is RECOMMENDED that the 874 functionality be implemented and just disabled through configuration, 875 so that it can be re-enabled through configuration if conditions 876 change in the future. 878 The agent pairs each host candidate with the STUN or TURN servers 879 with which it is configured or has discovered by some means. It is 880 RECOMMENDED that a domain name be configured, and the DNS procedures 881 in [RFC5389] (using SRV records with the "stun" service) be used to 882 discover the STUN server, and the DNS procedures in [RFC5766] (using 883 SRV records with the "turn" service) be used to discover the TURN 884 server. 886 When multiple STUN or TURN servers are available (or when they are 887 learned through DNS records and multiple results are returned), the 888 agent MAY gather candidates for all of them and SHOULD gather 889 candidates for at least one of them (one STUN server and one TURN 890 server). It does so by pairing host candidates with STUN or TURN 891 servers and, for each pair, the agent sends a Binding or Allocate 892 request to the server from the host candidate. Binding requests to a 893 STUN server are not authenticated, and any ALTERNATE-SERVER attribute 894 in a response is ignored. Agents MUST support the backwards 895 compatibility mode for the Binding request defined in [RFC5389]. 896 Allocate requests SHOULD be authenticated using a long-term 897 credential obtained by the client through some other means. 899 The gathering process is controlled using a timer, Ta. Every time Ta 900 expires the agent can generate another new STUN or TURN transaction. 901 This transaction can either be a retry of a previous transaction that 902 failed with a recoverable error (such as authentication failure), or 903 a transaction for a new host candidate and STUN or TURN server pair. 904 The agent SHOULD NOT generate transactions more frequently than one 905 every time Ta expires. See Section 14 for guidance on how to set Ta 906 and the STUN retransmit timer, RTO. 908 The agent will receive a Binding or Allocate response. A successful 909 Allocate response will provide the agent with a server reflexive 910 candidate (obtained from the mapped address) and a relayed candidate 911 in the XOR-RELAYED-ADDRESS attribute. If the Allocate request is 912 rejected because the server lacks resources to fulfill it, the agent 913 SHOULD instead send a Binding request to obtain a server reflexive 914 candidate. A Binding response will provide the agent with only a 915 server reflexive candidate (also obtained from the mapped address). 916 The base of the server reflexive candidate is the host candidate from 917 which the Allocate or Binding request was sent. The base of a 918 relayed candidate is that candidate itself. If a relayed candidate 919 is identical to a host candidate (which can happen in rare cases), 920 the relayed candidate MUST be discarded. 922 If an IPv6-only agent is in a network that utilizes NAT64 [RFC6146] 923 and DNS64 [RFC6147] technologies, it may also gather IPv4 server 924 reflexive and/or relayed candidates from IPv4-only STUN or TURN 925 servers. IPv6-only agents SHOULD also utilize IPv6 prefix discovery 926 [RFC7050] to discover the IPv6 prefix used by NAT64 (if any) and 927 generate server reflexive candidates for each IPv6-only interface 928 accordingly. The NAT64 server reflexive candidates are prioritized 929 like IPv4 server reflexive candidates. 931 5.1.1.3. Computing Foundations 933 The ICE agent assigns each candidate a foundation. Two candidates 934 have the same foundation when all of the following are true: 936 o They have the same type (host, relayed, server reflexive, or peer 937 reflexive). 939 o Their bases have the same IP address (the ports can be different). 941 o For reflexive and relayed candidates, the STUN or TURN servers 942 used to obtain them have the same IP address (the IP address used 943 by the agent to contact the STUN or TURN server). 945 o They were obtained using the same transport protocol (TCP, UDP). 947 Similarly, two candidates have different foundations if their types 948 are different, their bases have different IP addresses, the STUN or 949 TURN servers used to obtain them have different IP addresses (the IP 950 addresses used by the agent to contact the STUN or TURN server), or 951 their transport protocols are different. 953 5.1.1.4. Keeping Candidates Alive 955 Once server reflexive and relayed candidates are allocated, they MUST 956 be kept alive until ICE processing has completed, as described in 957 Section 8.3. For server reflexive candidates learned through a 958 Binding request, the bindings MUST be kept alive by additional 959 Binding requests to the server. Refreshes for allocations are done 960 using the Refresh transaction, as described in [RFC5766]. The 961 Refresh requests will also refresh the server reflexive candidate. 963 Host candidates do not time out, but the candidate addresses may 964 change or disappear for a number of reasons. An ICE agent SHOULD 965 monitor the interfaces it uses, invalidate candidates whose base has 966 gone away, and acquire new candidates as appropriate when new IP 967 addresses (on new or currently used interfaces) appear. 969 5.1.2. Prioritizing Candidates 971 The prioritization process results in the assignment of a priority to 972 each candidate. Each candidate for a data stream MUST have a unique 973 priority that MUST be a positive integer between 1 and (2**31 - 1). 974 This priority will be used by ICE to determine the order of the 975 connectivity checks and the relative preference for candidates. 976 Higher priority values give more priority over lower values. 978 An ICE agent SHOULD compute this priority using the formula in 979 Section 5.1.2.1 and choose its parameters using the guidelines in 980 Section 5.1.2.2. If an agent elects to use a different formula, ICE 981 may take longer to converge since the agents will not be coordinated 982 in their checks. 984 The process for prioritizing candidates is common across the 985 initiating and the responding agent. 987 5.1.2.1. Recommended Formula 989 The recommended formula combines a preference for the candidate type 990 (server reflexive, peer reflexive, relayed, and host), a preference 991 for the IP address for which the candidate was obtained, and 992 component ID using the following formula: 994 priority = (2^24)*(type preference) + 995 (2^8)*(local preference) + 996 (2^0)*(256 - component ID) 998 The type preference MUST be an integer from 0 (lowest preference) to 999 126 (highest preference) inclusive and MUST be identical for all 1000 candidates of the same type and MUST be different for candidates of 1001 different types. The type preference for peer reflexive candidates 1002 MUST be higher than that of server reflexive candidates. Setting the 1003 value to 0 means that candidates of this type will only be used as a 1004 last resort. Note that candidates gathered based on the procedures 1005 of Section 5.1.1 will never be peer reflexive candidates; candidates 1006 of these type are learned from the connectivity checks performed by 1007 ICE. 1009 The local preference MUST be an integer from 0 (lowest preference) to 1010 65535 (highest preference) inclusive. When there is only a single IP 1011 address, this value SHOULD be set to 65535. If there are multiple 1012 candidates for a particular component for a particular data stream 1013 that have the same type, the local preference MUST be unique for each 1014 one. If an ICE agent is dual-stack, the local preference SHOULD be 1015 set according to the current best practice described in 1016 [I-D.ietf-ice-dualstack-fairness]. 1018 The component ID MUST be an integer between 1 and 256 inclusive. 1020 5.1.2.2. Guidelines for Choosing Type and Local Preferences 1022 The RECOMMENDED values for type preferences are 126 for host 1023 candidates, 110 for peer reflexive candidates, 100 for server 1024 reflexive candidates, and 0 for relayed candidates. 1026 If an ICE agent is multihomed and has multiple IP addresses, the 1027 recommendations in [I-D.ietf-ice-dualstack-fairness] SHOULD be 1028 followed. If multiple TURN servers are used, local priorities for 1029 the candidates obtained from the TURN servers are chosen in a similar 1030 fashion as for multihomed local candidates: the local preference 1031 value is used to indicate a preference among different servers but 1032 the preference MUST be unique for each one. 1034 When choosing type preferences, agents may take into account factors 1035 such as latency, packet loss, cost, network topology, security, 1036 privacy, and others. 1038 5.1.3. Eliminating Redundant Candidates 1040 Next, the ICE agents (initiating and responding) eliminate redundant 1041 candidates. Two candidates can have the same transport address yet 1042 have different bases, and these would not be considered redundant. 1043 Frequently, a server reflexive candidate and a host candidate will be 1044 redundant when the agent is not behind a NAT. A candidate is 1045 redundant if and only if its transport address and base equal those 1046 of another candidate. The agent SHOULD eliminate the redundant 1047 candidate with the lower priority. 1049 5.2. Lite Implementation Procedures 1051 Lite implementations only utilize host candidates. For each IP 1052 address, independent of IP address family, there MUST be zero or one 1053 candidate. With the lite implementation, ICE cannot be used to 1054 dynamically choose amongst candidates. Therefore, including more 1055 than one candidate from a particular IP address family is NOT 1056 RECOMMENDED, since only a connectivity check can truly determine 1057 whether to use one address or the other. Instead agents that have 1058 multiple public IP addresses are RECOMMENDED to run full ICE 1059 implementations to ensure the best usage of its addresses. 1061 Each component has an ID assigned to it, called the component ID. 1062 For RTP/RTCP data streams, unless RTCP is multiplexed in the same 1063 port with RTP, the RTP itself has a component ID of 1, and RTCP a 1064 component ID of 2. If an agent is using RTCP without multiplexing, 1065 it MUST obtain candidates for it. However, absence of a component ID 1066 2 as such does not imply use of RTCP/RTP multiplexing, as it could 1067 also mean that RTCP is not used. 1069 Each candidate is assigned a foundation. The foundation MUST be 1070 different for two candidates allocated from different IP addresses, 1071 and MUST be the same otherwise. A simple integer that increments for 1072 each IP address will suffice. In addition, each candidate MUST be 1073 assigned a unique priority amongst all candidates for the same data 1074 stream. If the formula in Section 5.1.2.1 is used to calculate the 1075 priority, the type preference value SHOULD be set to 126. If a host 1076 is v4-only, the local preference value SHOULD be set to 65535. If a 1077 host is v6 or dual-stack, the local preference value SHOULD be set to 1078 the precedence value for IP addresses described in RFC 6724 1079 [RFC6724]. 1081 Next, an agent chooses a default candidate for each component of each 1082 data stream. If a host is IPv4-only, there would only be one 1083 candidate for each component of each data stream, and therefore that 1084 candidate is the default. If a host is IPv6-only, the default 1085 candidate would typically be a globally scoped IPv6 address. Dual- 1086 stack hosts SHOULD allow configuration of whether IPv4 or IPv6 is 1087 used for the default candidate, and the configuration needs to be 1088 based on which one its administrator believes has a higher chance of 1089 success in the current network environment. 1091 The procedures in this section are common across the initiating and 1092 responding agents. 1094 5.3. Exchanging Candidate Information 1096 ICE agents (initiating and responding) need the following information 1097 about candidates to be exchanged. Each ICE usage MUST define how the 1098 information is exchanged with the using protocol. This section 1099 describes the information that needs to be exchanged. 1101 Candidates: One or more candidates. For each candidate: 1103 Address: The IP address and transport protocol port of the 1104 candidate. 1106 Transport: The transport protocol of the candidate. This MAY be 1107 omitted if the using protocol only runs over a single transport 1108 protocol. 1110 Foundation: A sequence of up to 32 characters. 1112 Component ID: The component ID of the candidate. This MAY be 1113 omitted if the using protocol does not use the concept of 1114 components. 1116 Priority: The 32-bit priority of the candidate. 1118 Type: The type of the candidate. 1120 Related Address and Port: The related IP address and port of the 1121 candidate. These MAY be omitted or set to invalid values if 1122 the agent does not want to reveal them, e.g., for privacy 1123 reasons. 1125 Extensibility Parameters: The using protocol might define means 1126 for adding new per-candidate ICE parameters in the future. 1128 Lite or Full: Whether the agent is a lite agent or full agent. 1130 Connectivity check pacing value: The pacing value for connectivity 1131 checks that the agent wishes to use. This MAY be omitted if the 1132 agent wishes to use a defined default value. 1134 Username Fragment and Password: Values used to perform connectivity 1135 checks. The values MUST be unguessable, with at least 128 bits of 1136 random number generator output used to generate the password, and 1137 at least 24 bits output to generate the username fragment. 1139 Extensions: New media-stream or session-level attributes (ice- 1140 options). 1142 If the using protocol is vulnerable to, and able to detect, ICE 1143 mismatch (Section 5.4), a way is needed for the detecting agent to 1144 convey this information to its peer. It is a boolean flag. 1146 The using protocol may (or may not) need to deal with backwards 1147 compatibility with older implementations that do not support ICE. If 1148 a fallback mechanism to non-ICE is supported is being used, then 1149 presumably the using protocol provides a way of conveying the default 1150 candidate (its IP address and port) in addition to the ICE 1151 parameters. 1153 Once an agent has sent its candidate information, it MUST be prepared 1154 to receive both STUN and data packets on each candidate. As 1155 discussed in Section 12.1, data packets can be sent to a candidate 1156 prior to its appearance as the default destination for data. 1158 5.4. ICE Mismatch 1160 Certain middleboxes, such as ALGs, can alter signaling information in 1161 ways that break ICE (e.g., by rewriting IP addresses in SDP). This 1162 is referred to as ICE mismatch. If the using protocol is vulnerable 1163 to ICE mismatch, the responding agent needs to be able to detect it 1164 and inform the peer ICE agent about the ICE mismatch. 1166 Each using protocol needs to define whether the using protocol is 1167 vulnerable to ICE mismatch, how ICE mismatch is detected, and whether 1168 specific actions need to be taken when ICE mismatch is detected. 1170 6. ICE Candidate Processing 1172 Once an ICE agent has gathered its candidates and exchanged 1173 candidates with its peer (Section 5), it will determine its own role. 1174 In addition, full implementations will form check lists, and begin 1175 performing connectivity checks with the peer. 1177 6.1. Procedures for Full Implementation 1179 6.1.1. Determining Role 1181 For each session, each ICE agent (Initiating and Responding) takes on 1182 a role. There are two roles -- controlling and controlled. The 1183 controlling agent is responsible for the choice of the final 1184 candidate pairs used for communications. The sections below describe 1185 in detail the actual procedures followed by controlling and 1186 controlled agents. 1188 The rules for determining the role and the impact on behavior are as 1189 follows: 1191 Both agents are full: The initiating agent that started the ICE 1192 processing MUST take the controlling role, and the other MUST take 1193 the controlled role. Both agents will form check lists, run the 1194 ICE state machines, and generate connectivity checks. The 1195 controlling agent will execute the logic in Section 8.1 to 1196 nominate pairs that will become (if the connectivity checks 1197 associated with the nominations succeed) the selected pairs, and 1198 then both agents end ICE as described in Section 8.1.2. 1200 One agent full, one lite: The full agent MUST take the controlling 1201 role, and the lite agent MUST take the controlled role. The full 1202 agent will form check lists, run the ICE state machines, and 1203 generate connectivity checks. That agent will execute the logic 1204 in Section 8.1 to nominate pairs that will become (if the 1205 connectivity checks associated with the nominations succeed) the 1206 selected pairs, and use the logic in Section 8.1.2 to end ICE. 1207 The lite implementation will just listen for connectivity checks, 1208 receive them and respond to them, and then conclude ICE as 1209 described in Section 8.2. For the lite implementation, the state 1210 of ICE processing for each data stream is considered to be 1211 Running, and the state of ICE overall is Running. 1213 Both lite: The initiating agent that started the ICE processing MUST 1214 take the controlling role, and the other MUST take the controlled 1215 role. In this case, no connectivity checks are ever sent. 1216 Rather, once the candidates are exchanged, each agent performs the 1217 processing described in Section 8 without connectivity checks. It 1218 is possible that both agents will believe they are controlled or 1219 controlling. In the latter case, the conflict is resolved through 1220 glare detection capabilities in the signaling protocol enabling 1221 the candidate exchange. The state of ICE processing for each data 1222 stream is considered to be Running, and the state of ICE overall 1223 is Running. 1225 Once the roles are determined for a session, they persist throughout 1226 the lifetime of the session. The roles can be re-determined as part 1227 of an ICE restart (Section 9), but an ICE agent MUST NOT re-determine 1228 the role as part of an ICE restart unless one or more of the 1229 following criteria is fulfilled: 1231 Full becomes lite: If the controlling agent is full, and switches to 1232 lite, the roles MUST be re-determined if the peer agent is also 1233 full. 1235 Role conflict: If the ICE restart causes a role conflict, the roles 1236 might be re-determined due to the role conflict procedures in 1237 Section 7.3.1.1. 1239 NOTE: There are certain 3PCC (third party call control) [RFC3725] 1240 scenarios where an ICE restart might cause a role conflict. 1242 NOTE: The agents needs to inform each other whether they are full or 1243 lite before the roles are determined. The mechanism for that is 1244 signalling protocol specific, and outside the scope of the document. 1246 An agent MUST accept if the peer initiates a re-determination of the 1247 roles even if the criteria for doing so are not fulfilled. This can 1248 happen if the peer is compliant with RFC 5245. 1250 6.1.2. Forming the Check Lists 1252 There is one check list for each data stream. To form a check list, 1253 initiating and responding ICE agents form candidate pairs, compute 1254 pair priorities, order pairs by priority, prune pairs, remove lower- 1255 priority pairs, and set check list states. If candidates are added 1256 to a check list (e.g., due to detection of peer reflexive 1257 candidates), the agent will re-perform these steps for the updated 1258 check list. 1260 6.1.2.1. Check List State 1262 Each check list has a state, which captures the state of ICE checks 1263 for the data stream associated with the check list. The states are: 1265 Running: The check list is neither Completed nor Failed yet. Check 1266 lists are initially set to the Running state. 1268 Completed: The check list contains a nominated pair for each 1269 component of the data stream. 1271 Failed: The check list does not have a valid pair for each component 1272 of the data stream and all of the candidate pairs in the check 1273 list are in either the Failed or Succeeded state. In other words, 1274 at least one component of the check list has candidate pairs that 1275 are all in the Failed state, which means the component has failed, 1276 which means the check list has failed. 1278 6.1.2.2. Forming Candidate Pairs 1280 The ICE agent pairs each local candidate with each remote candidate 1281 for the same component of the same data stream with the same IP 1282 address family. It is possible that some of the local candidates 1283 won't get paired with remote candidates, and some of the remote 1284 candidates won't get paired with local candidates. This can happen 1285 if one agent doesn't include candidates for the all of the components 1286 for a data stream. If this happens, the number of components for 1287 that data stream is effectively reduced, and considered to be equal 1288 to the minimum across both agents of the maximum component ID 1289 provided by each agent across all components for the data stream. 1291 In the case of RTP, this would happen when one agent provides 1292 candidates for RTCP, and the other does not. As another example, the 1293 initiating agent can multiplex RTP and RTCP on the same port 1294 [RFC5761]. However, since the initiating agent doesn't know if the 1295 peer agent can perform such multiplexing, it includes candidates for 1296 RTP and RTCP on separate ports. If the peer agent can perform such 1297 multiplexing, it would include just a single component for each 1298 candidate -- for the combined RTP/RTCP mux. ICE would end up acting 1299 as if there was just a single component for this candidate. 1301 With IPv6 it is common for a host to have multiple host candidates 1302 for each interface. To keep the amount of resulting candidate pairs 1303 reasonable and to avoid candidate pairs that are highly unlikely to 1304 work, IPv6 link-local addresses MUST NOT be paired with other than 1305 link-local addresses. 1307 The candidate pairs whose local and remote candidates are both the 1308 default candidates for a particular component is called the default 1309 candidate pair for that component. This is the pair that would be 1310 used to transmit data if both agents had not been ICE aware. 1312 Figure 5 shows the properties of and relationships between transport 1313 addresses, candidates, candidate pairs, and check lists. 1315 +--------------------------------------------+ 1316 | | 1317 | +---------------------+ | 1318 | |+----+ +----+ +----+ | +Type | 1319 | || IP | |Port| |Tran| | +Priority | 1320 | ||Addr| | | | | | +Foundation | 1321 | |+----+ +----+ +----+ | +Component ID | 1322 | | Transport | +Related Address | 1323 | | Addr | | 1324 | +---------------------+ +Base | 1325 | Candidate | 1326 +--------------------------------------------+ 1327 * * 1328 * ************************************* 1329 * * 1330 +-------------------------------+ 1331 .| | 1332 | Local Remote | 1333 | +----+ +----+ +default? | 1334 | |Cand| |Cand| +valid? | 1335 | +----+ +----+ +nominated?| 1336 | +State | 1337 | | 1338 | | 1339 | Candidate Pair | 1340 +-------------------------------+ 1341 * * 1342 * ************ 1343 * * 1344 +------------------+ 1345 | Candidate Pair | 1346 +------------------+ 1347 +------------------+ 1348 | Candidate Pair | 1349 +------------------+ 1350 +------------------+ 1351 | Candidate Pair | 1352 +------------------+ 1354 Check 1355 List 1357 Figure 5: Conceptual Diagram of a Check List 1359 6.1.2.3. Computing Pair Priority and Ordering Pairs 1361 The ICE agent computes a priority for each candidate pair. Let G be 1362 the priority for the candidate provided by the controlling agent. 1363 Let D be the priority for the candidate provided by the controlled 1364 agent. The priority for a pair is computed as follows: 1366 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 1368 The agent sorts each check list in decreasing order of candidate pair 1369 priority. If two pairs have identical priority, the ordering amongst 1370 them is arbitrary. 1372 6.1.2.4. Pruning the Pairs 1374 This sorted list of candidate pairs is used to determine a sequence 1375 of connectivity checks that will be performed. Each check involves 1376 sending a request from a local candidate to a remote candidate. 1377 Since an ICE agent cannot send requests directly from a reflexive 1378 candidate (server reflexive or peer reflexive), but only from its 1379 base, the agent next goes through the sorted list of candidate pairs. 1380 For each pair where the local candidate is reflexive, the candidate 1381 MUST be replaced by its base. 1383 The agent prunes each check list. This is done by removing a 1384 candidate pair if it is redundant with a higher priority candidate 1385 pair in the same check list. Two candidate pairs are redundant if 1386 their local candidates have the same base and their remote candidates 1387 are identical. The result is a sequence of ordered candidate pairs, 1388 called the check list for that data stream. 1390 6.1.2.5. Removing lower-priority Pairs 1392 In order to limit the attacks described in Section 19.5.1, an ICE 1393 agent MUST limit the total number of connectivity checks the agent 1394 performs across all check lists in the check list set. This is done 1395 by limiting the total number of candidate pairs in the check list 1396 set. The default limit of candidate pairs for the check list set is 1397 100, but the value MUST be configurable. The limit is enforced by, 1398 within in each check list, discarding lower-priority candidate pairs 1399 until the total number of candidate pairs in the check list set is 1400 smaller than the limit value. The discarding SHOULD be done evenly 1401 so that the number of candidate pairs in each check list is reduced 1402 the same amount. 1404 It is RECOMMENDED that a lower limit value than the default is picked 1405 when possible, and that the value is set to the maximum number of 1406 plausible candidate pairs that might be created in an actual 1407 deployment configuration. The requirement for configuration is meant 1408 to provide a tool for fixing this value in the field if, once 1409 deployed, it is found to be problematic. 1411 6.1.2.6. Computing Candidate Pair States 1413 Each candidate pair in the check list has a foundation (the 1414 combination of the foundations of the local and remote candidates in 1415 the pair) and one of the following states: 1417 Waiting: A check has not been sent for this pair, but the pair is 1418 not Frozen. 1420 In-Progress: A check has been sent for this pair, but the 1421 transaction is in progress. 1423 Succeeded: A check has been sent for this pair, and produced a 1424 successful result. 1426 Failed: A check has been sent for this pair, and failed (a response 1427 to the check was never received, or a failure response was 1428 received). 1430 Frozen: A check for this pair has not been sent, and it can not be 1431 sent until the pair is unfrozen and moved into the Waiting state. 1433 Pairs move between states as shown in Figure 6. 1435 +-----------+ 1436 | | 1437 | | 1438 | Frozen | 1439 | | 1440 | | 1441 +-----------+ 1442 | 1443 |unfreeze 1444 | 1445 V 1446 +-----------+ +-----------+ 1447 | | | | 1448 | | perform | | 1449 | Waiting |-------->|In-Progress| 1450 | | | | 1451 | | | | 1452 +-----------+ +-----------+ 1453 / | 1454 // | 1455 // | 1456 // | 1457 / | 1458 // | 1459 failure // |success 1460 // | 1461 / | 1462 // | 1463 // | 1464 // | 1465 V V 1466 +-----------+ +-----------+ 1467 | | | | 1468 | | | | 1469 | Failed | | Succeeded | 1470 | | | | 1471 | | | | 1472 +-----------+ +-----------+ 1474 Figure 6: Pair State FSM 1476 1. The initial states for each pair in a check list are computed by 1477 performing the following sequence of steps: 1479 2. The check lists are placed in an ordered list (the order is 1480 determined by each ICE usage), called the check list set. 1482 3. The ICE agent initially places all candidate pairs in the Frozen 1483 state. 1485 4. The agent sets all of the check lists in the check list set to 1486 the Running state. 1488 5. For each foundation, the agent sets the state of exactly one 1489 candidate pair to the Waiting state (unfreezing it). The 1490 candidate pair to unfreeze is chosen by finding the first 1491 candidate pair (ordered by lowest component ID and then highest 1492 priority if component IDs are equal) in the first check list 1493 (according to the usage-defined check list set order) that has 1494 that foundation. 1496 NOTE: The procedures above are different from RFC 5245, where only 1497 candidate pairs in the first check list of were initially placed in 1498 the Waiting state. Now it applies to candidate pairs in the the 1499 first check list which have that foundation, even if the first check 1500 list to have that foundation is not the first check list in the check 1501 list set. 1503 The table below illustrates an example. 1505 Table legend: 1507 Each row (m1, m2,...) represents a check list associated with a data 1508 stream. m1 represents the first check list in the check list set. 1510 Each column (f1, f2,...) represents a foundation. Every candidate pair 1511 within a given column share the same foundation. 1513 f-cp represents a candidate pair in the Frozen state. 1515 w-cp represents a candidate pair in the Waiting state. 1517 1. The agent sets all of the pairs in the check list set to the Frozen 1518 state. 1520 f1 f2 f3 f4 f5 1521 ----------------------------- 1522 m1 | f-cp f-cp f-cp 1523 | 1524 m2 | f-cp f-cp f-cp f-cp 1525 | 1526 m3 | f-cp f-cp 1527 2. For each foundation, the candidate pair with the lowest component ID 1528 is placed in the Waiting state, unless a candidate pair associated with 1529 the same foundation has already been put in the Waiting state in one of 1530 the other examined check lists in the check list set. 1532 f1 f2 f3 f4 f5 1533 ----------------------------- 1534 m1 | w-cp w-cp w-cp 1535 | 1536 m2 | f-cp f-cp f-cp w-cp 1537 | 1538 m3 | f-cp w-cp 1540 In the first check list (m1) the candidate pair for each foundation is 1541 placed in the Waiting state, as no pairs for the same foundations have 1542 yet been placed in the Waiting state. 1544 In the second check list (m2) the candidate pair for foundation f4 is 1545 placed in the Waiting state. The candidate pair for foundations f1, f2 1546 and f3 are kept in the Frozen state, as candidate pairs for those 1547 foundations have already been placed in the Waiting state (within check 1548 list m1). 1550 In the third check list (m3) the candidate pair for foundation f5 is 1551 placed in the Waiting state. The candidate pair for foundation f1 is 1552 kept in the Frozen state, as a candidate pair for that foundation have 1553 already been placed in the Waiting state (within check list m1). 1555 Once each check list have been processed, one candidate pair for each 1556 foundation in the check list set has been placed in the Waiting state. 1558 6.1.3. ICE State 1560 The ICE agent has a state determined by the state of the check lists. 1561 The state is Completed if all check lists are Completed, Failed if 1562 all check lists are Failed, and Running otherwise. 1564 6.1.4. Scheduling Checks 1566 6.1.4.1. Triggered Check Queue 1568 Once the ICE agent has computed the check lists and created the check 1569 list set, as described in Section 6.1.2, the agent will begin 1570 performing connectivity checks (ordinary and triggered). For 1571 triggered connectivity checks, the agent maintains a FIFO queue for 1572 each check list, referred to as the triggered check queue, which 1573 contains candidate pairs for which checks are to be sent at the next 1574 available opportunity. The triggered check queue is initially empty. 1576 6.1.4.2. Performing Connectivity Checks 1578 The generation of ordinary and triggered connectivity checks is 1579 governed by timer Ta. As soon as the initial states for the 1580 candidate pairs in the check list set have been set, a check is 1581 performed for a candidate pair within the first check list in the 1582 Running state, following the procedures in Section 7. After that, 1583 whenever Ta fires the next check list in the Running state in the 1584 check list set is picked, and a check is performed for a candidate 1585 within that check list. After the last check list in the Running 1586 state in the check list set has been processed, the first check list 1587 is picked again, etc. 1589 Whenever Ta fires, the ICE agent will perform a check for a candidate 1590 pair within the picked check list by performing the following steps: 1592 1. If the triggered check queue associated with the check list 1593 contains one or more candidate pairs, the agent removes the top 1594 pair from the queue, performs a connectivity check on that pair, 1595 puts the candidate pair state to In-Progress, and aborts the 1596 subsequent steps. 1598 2. If there is no candidate pair in the Waiting state, and if there 1599 are one or more pairs in the Frozen state, for each pair in the 1600 Frozen state the agent checks the foundation associated with the 1601 pair. For a given foundation, if there is no pair (in any check 1602 list in the check list set) in the Waiting or In-Progress state, 1603 the agent puts the candidate pair state to Waiting and continues 1604 with the next step. 1606 3. If there are one or more candidate pairs in the Waiting state, 1607 the agent picks the highest-priority candidate pair (if there are 1608 multiple pairs with the same priority, the pair with the lowest 1609 component ID is picked) in the Waiting state, performs a 1610 connectivity check on that pair, puts the candidate pair par 1611 state to In-Progress, and abort the subsequent steps. 1613 4. If this step is reached, no check could be performed for the 1614 picked check list. So, without waiting for timer Ta to expire 1615 again, select the next check list in the Running state and return 1616 to step #1. If this happens for every single check list in the 1617 Running state, meaning there are no remaining candidate pairs to 1618 perform connectivity checks for, abort these steps. 1620 Once the agent has picked a candidate pair for which a connectivity 1621 check is to be performed, the agent starts a check and sends the 1622 Binding request from the base associated with the local candidate of 1623 the pair to the remote candidate of the pair, as described in 1624 Section 7.2.4. 1626 Based on local policy, an agent MAY choose to terminate performing 1627 the connectivity checks for one or more checks lists in the check 1628 list set at any time. However, only the controlling agent is allowed 1629 to conclude ICE (Section 8). 1631 To compute the message integrity for the check, the agent uses the 1632 remote username fragment and password learned from the candidate 1633 information obtained from its peer. The local username fragment is 1634 known directly by the agent for its own candidate. 1636 6.2. Lite Implementation Procedures 1638 Lite implementations skip most of the steps in Section 6 except for 1639 verifying the peer's ICE support and determining its role in the ICE 1640 processing. 1642 If the lite implementation is the controlling agent (which will only 1643 happen if the peer ICE agent is also a lite implementation), it 1644 selects a candidate pair based on the ones in the candidate exchange 1645 (for IPv4, there is only ever one pair), and then updating the peer 1646 with the new candidate information reflecting that selection, if 1647 needed (it is never needed for an IPv4-only host). 1649 7. Performing Connectivity Checks 1651 This section describes how connectivity checks are performed. 1653 An ICE agent MUST be compliant to [RFC5389]. A full implementation 1654 acts both as a STUN client and a STUN server, while a lite 1655 implementation only acts as a STUN server (as it does not generate 1656 connectivity checks). 1658 7.1. STUN Extensions 1660 ICE extends STUN by defining new attributes: PRIORITY, USE-CANDIDATE, 1661 ICE-CONTROLLED, and ICE-CONTROLLING. The new attributes are formally 1662 defined in Section 16.1. This section describes the usage of the new 1663 attributes. 1665 The new attributes are only applicable to ICE connectivity checks. 1667 7.1.1. PRIORITY 1669 The priority attribute MUST be included in a Binding request and be 1670 set to the value computed by the algorithm in Section 5.1.2 for the 1671 local candidate, but with the candidate type preference of peer 1672 reflexive candidates. 1674 7.1.2. USE-CANDIDATE 1676 The controlling agent MUST include the USE-CANDIDATE attribute in 1677 order to nominate a candidate pair (Section 8.1.1). The controlled 1678 agent MUST NOT include the USE-CANDIDATE attribute in a Binding 1679 request. 1681 7.1.3. ICE-CONTROLLED and ICE-CONTROLLING 1683 The controlling agent MUST include the ICE-CONTROLLING attribute in a 1684 Binding request. The controlled agent MUST include the ICE- 1685 CONTROLLED attribute in a Binding request. 1687 The content of either attribute are used as tie-breaker values when 1688 an ICE role conflict occurs (Section 7.3.1.1). 1690 7.2. STUN Client Procedures 1692 7.2.1. Creating Permissions for Relayed Candidates 1694 If the connectivity check is being sent using a relayed local 1695 candidate, the client MUST create a permission first if it has not 1696 already created one previously. It would have created one previously 1697 if it had told the TURN server to create a permission for the given 1698 relayed candidate towards the IP address of the remote candidate. To 1699 create the permission, the ICE agent follows the procedures defined 1700 in [RFC5766]. The permission MUST be created towards the IP address 1701 of the remote candidate. It is RECOMMENDED that the agent defer 1702 creation of a TURN channel until ICE completes, in which case 1703 permissions for connectivity checks are normally created using a 1704 CreatePermission request. Once established, the agent MUST keep the 1705 permission active until ICE concludes. 1707 7.2.2. Forming Credentials 1709 A connectivity check Binding request MUST utilize the STUN short-term 1710 credential mechanism. 1712 The username for the credential is formed by concatenating the 1713 username fragment provided by the peer with the username fragment of 1714 the ICE agent sending the request, separated by a colon (":"). 1716 The password is equal to the password provided by the peer. 1718 For example, consider the case where ICE agent L is the Initiating 1719 agent and ICE agent R is the Responding agent. Agent L included a 1720 username fragment of LFRAG for its candidates and a password of 1721 LPASS. Agent R provided a username fragment of RFRAG and a password 1722 of RPASS. A connectivity check from L to R utilizes the username 1723 RFRAG:LFRAG and a password of RPASS. A connectivity check from R to 1724 L utilizes the username LFRAG:RFRAG and a password of LPASS. The 1725 responses utilize the same usernames and passwords as the requests 1726 (note that the USERNAME attribute is not present in the response). 1728 7.2.3. DiffServ Treatment 1730 If the agent is using Diffserv Codepoint markings [RFC2475] in data 1731 packets that it will send, the agent SHOULD apply the same markings 1732 to Binding requests and responses that it will send. 1734 If multiple DSCP markings are used on the data packets, the agent 1735 SHOULD choose one of them for use with the connectivity check. 1737 7.2.4. Sending the Request 1739 A connectivity check is generated by sending a Binding request from 1740 the base associated with a local candidate to a remote candidate. 1741 [RFC5389] describes how Binding requests are constructed and 1742 generated. 1744 Support for backwards compatibility with RFC 3489 MUST NOT be assumed 1745 when performing connectivity checks. The FINGERPRINT mechanism MUST 1746 be used for connectivity checks. 1748 7.2.5. Processing the Response 1750 This section defines additional procedures for processing Binding 1751 responses specific to ICE connectivity checks. 1753 When a Binding response is received, it is correlated to the 1754 corresponding Binding request using the transaction ID [RFC5389], 1755 which then associates the response with the candidate pair for which 1756 the Binding request was sent. After that, the response is processed 1757 according to the procedures for a role conflict, a failure, or a 1758 success, according to the procedures below. 1760 7.2.5.1. Role Conflict 1762 If the Binding request generates a 487 (Role Conflict) error response 1763 (Section 7.3.1.1), and if the ICE agent included an ICE-CONTROLLED 1764 attribute in the request, the agent MUST switch to the controlling 1765 role. If the agent included an ICE-CONTROLLING attribute in the 1766 request, the agent MUST switch to the controlled role. 1768 Once the agent has switched its role, the agent MUST add the 1769 candidate pair whose check generated the 487 error response to the 1770 triggered check queue associated with the check list to which the 1771 pair belongs, and set the candidate pair state to Waiting. When the 1772 triggered connectivity check is later performed, the ICE-CONTROLLING/ 1773 ICE-CONTROLLED attribute of the Binding request will indicate the 1774 agent's new role. The agent MUST change the tie-breaker value. 1776 NOTE: A role switch requires an agent to recompute pair priorities 1777 (Section 6.1.2.3), since the priority values depend on the role. 1779 NOTE: A role switch will also impact whether the agent is responsible 1780 for nominating candidate pairs, and whether the agent is responsible 1781 for initiating the exchange of the updated candidate information with 1782 the peer once ICE is concluded. 1784 7.2.5.2. Failure 1786 This section describes cases when the candidate pair state is set to 1787 Failed. 1789 NOTE: When the ICE agent sets the candidate pair state to Failed as a 1790 result of a connectivity check error, the agent does not change the 1791 states of other candidate pairs with the same foundation. 1793 7.2.5.2.1. Non-Symmetric Transport Addresses 1795 The ICE agent MUST check that the source and destination transport 1796 addresses in the Binding request and response are symmetric. I.e., 1797 the source IP address and port of the response MUST be equal to the 1798 destination IP address and port to which the Binding request was 1799 sent, and that the destination IP address and port of the response 1800 MUST be equal to the source IP address and port from which the 1801 Binding request was sent. If the addresses are not symmetric, the 1802 agent MUST set the candidate pair state to Failed. 1804 7.2.5.2.2. ICMP Error 1806 An ICE agent MAY support processing of ICMP errors for connectivity 1807 checks. If the agent supports processing of ICMP errors, and if a 1808 Binding request generates a hard ICMP error, the agent SHOULD set the 1809 state of the candidate pair to Failed. Implementers need to be aware 1810 that ICMP errors can be used as a method for denial of service 1811 attacks when making a decision on how and if to process ICMP errors. 1813 7.2.5.2.3. Timeout 1815 If the Binding request transaction times out, the ICE agent MUST set 1816 the candidate pair state to Failed. 1818 7.2.5.2.4. Unrecoverable STUN Response 1820 If the Binding request generates a STUN error response that is 1821 unrecoverable [RFC5389] the ICE agent SHOULD set the candidate pair 1822 state to Failed. 1824 7.2.5.3. Success 1826 A connectivity check is considered a success if each of the following 1827 criteria is true: 1829 o The Binding request generated a success response; and 1831 o The source and destination transport addresses in the Binding 1832 request and response are symmetric. 1834 If a check is considered a success, the ICE agent performs (in order) 1835 the actions described in the following sections. 1837 7.2.5.3.1. Discovering Peer Reflexive Candidates 1839 The ICE agent MUST check the mapped address from the STUN response. 1840 If the transport address does not match any of the local candidates 1841 that the agent knows about, the mapped address represents a new 1842 candidate: a peer reflexive candidate. Like other candidates, a peer 1843 reflexive candidate has a type, base, priority, and foundation. They 1844 are computed as follows: 1846 o The type is peer reflexive. 1848 o The base is the local candidate of the candidate pair from which 1849 the Binding request was sent. 1851 o The priority is the value of the PRIORITY attribute in the Binding 1852 request. 1854 o The foundation is described in Section 5.1.1.3. 1856 The peer reflexive candidate is then added to the list of local 1857 candidates for the data stream. The username fragment and password 1858 are the same as for all other local candidates for that data stream. 1860 The ICE agent does not need to pair the peer reflexive candidate with 1861 remote candidates, as a valid pair will be created due to the 1862 procedures in Section 7.2.5.3.2. If an agent wishes to pair the peer 1863 reflexive candidate with remote candidates other than the one in the 1864 valid pair that will be generated, the agent MAY provide updated 1865 candidate information to the peer that includes the peer reflexive 1866 candidate. This will cause the peer reflexive candidate to be paired 1867 with all other remote candidates. 1869 7.2.5.3.2. Constructing a Valid Pair 1871 The ICE agent constructs a candidate pair whose local candidate 1872 equals the mapped address of the response, and whose remote candidate 1873 equals the destination address to which the request was sent. This 1874 is called a valid pair. 1876 The valid pair might equal the pair that generated the connectivity 1877 check, a different pair in the check list, or a pair currently not in 1878 the check list. 1880 The agent maintains a separate list, referred to as the valid list. 1881 There is a valid list for each check list in the check list set. The 1882 valid list will contain valid pairs. Initially each valid list is 1883 empty. 1885 Each valid pair within the valid list has a flag, called the 1886 nominated flag. When a valid pair is added to a valid list, the flag 1887 value is set to 'false'. 1889 The valid pair will be added to a valid list as follows: 1891 1. If the valid pair equals the pair that generated the check, the 1892 pair is added to the valid list associated with the check list to 1893 which the pair belongs; or 1895 2. If the valid pair equals another pair in a check list, that pair 1896 is added to the valid list associated with the check list of that 1897 pair. The pair that generated the check is not added to a valid 1898 list; or 1900 3. If the valid pair is not in any check list, the agent computes 1901 the priority for the pair based on the priority of each 1902 candidate, using the algorithm in Section 6.1.2. The priority of 1903 the local candidate depends on its type. Unless the type is peer 1904 reflexive, the priority is equal to the priority signaled for 1905 that candidate in the candidate exchange. If the type is peer 1906 reflexive, it is equal to the PRIORITY attribute the agent placed 1907 in the Binding request that just completed. The priority of the 1908 remote candidate is taken from the candidate information of the 1909 peer. If the candidate does not appear there, then the check has 1910 been a triggered check to a new remote candidate. In that case, 1911 the priority is taken as the value of the PRIORITY attribute in 1912 the Binding request that triggered the check that just completed. 1913 The pair is then added to the valid list. 1915 NOTE: It will be very common that the valid pair will not be in any 1916 check list. Recall that the check list has pairs whose local 1917 candidates are never reflexive; those pairs had their local 1918 candidates converted to the base of the reflexive candidates, and 1919 then pruned if they were redundant. When the response to the Binding 1920 request arrives, the mapped address will be reflexive if there is a 1921 NAT between the two. In that case, the valid pair will have a local 1922 candidate that doesn't match any of the pairs in the check list. 1924 7.2.5.3.3. Updating Candidate Pair States 1926 The ICE agent sets the states of both the candidate pair that 1927 generated the check and the constructed valid pair (which may be 1928 different) to Succeeded. 1930 The agent MUST set the states for all other Frozen candidate pairs in 1931 all check lists with the same foundation to Waiting. 1933 NOTE: Within a given check list, candidate pairs with the same 1934 foundations will typically have different component ID values. 1936 7.2.5.3.4. Updating the Nominated Flag 1938 If the controlling agent sends a Binding request with the USE- 1939 CANDIDATE attribute set, and if the ICE agent receives a successful 1940 response to the request, the agent sets the nominated flag of the 1941 pair to true. If the request fails (Section 7.2.5.2), the agent MUST 1942 remove the candidate pair from the valid list, set the candidate pair 1943 state to Failed and set the check list state to Failed. 1945 If the controlled agent receives a successful response to a Binding 1946 request sent by the agent, and that Binding request was triggered by 1947 a received Binding request with the USE-CANDIDATE attribute set 1948 (Section 7.3.1.4), the agent sets the nominated flag of the pair to 1949 true. If the triggered request fails, the agent MUST remove the 1950 candidate pair from the valid list, set the candidate pair state to 1951 Failed and set the check list state to Failed. 1953 Once the nominated flag is set for a component of a data stream, it 1954 concludes the ICE processing for that component (Section 8). 1956 7.2.5.4. Check List State Updates 1958 Regardless of whether a connectivity check was successful or failed, 1959 the completion of the check may require updating of check list 1960 states. For each check list in the check list set, if all of the 1961 candidate pairs are in either Failed or Succeeded state, and if there 1962 is not a valid pair in the valid list for each component of the data 1963 stream associated with the check list, the state of the check list is 1964 set to Failed. If there is a valid pair for each component in the 1965 valid list, the state of the check list is set to Succeeded. 1967 7.3. STUN Server Procedures 1969 An ICE agent (lite or full) MUST be prepared to receive Binding 1970 requests on the base of each candidate it included in its most recent 1971 candidate exchange. 1973 The agent MUST use the short-term credential mechanism (i.e., the 1974 MESSAGE-INTEGRITY attribute) to authenticate the request and perform 1975 a message integrity check. Likewise, the short-term credential 1976 mechanism MUST be used for the response. The agent MUST consider the 1977 username to be valid if it consists of two values separated by a 1978 colon, where the first value is equal to the username fragment 1979 generated by the agent in a candidate exchange for a session in- 1980 progress. It is possible (and in fact very likely) that the 1981 initiating agent will receive a Binding request prior to receiving 1982 the candidates from its peer. If this happens, the agent MUST 1983 immediately generate a response (including computation of the mapped 1984 address as described in Section 7.3.1.2). The agent has sufficient 1985 information at this point to generate the response; the password from 1986 the peer is not required. Once the answer is received, it MUST 1987 proceed with the remaining steps required, namely, Section 7.3.1.3, 1988 Section 7.3.1.4, and Section 7.3.1.5 for full implementations. In 1989 cases where multiple STUN requests are received before the answer, 1990 this may cause several pairs to be queued up in the triggered check 1991 queue. 1993 An agent MUST NOT utilize the ALTERNATE-SERVER mechanism, and MUST 1994 NOT support the backwards-compatibility mechanisms to RFC 3489. It 1995 MUST utilize the FINGERPRINT mechanism. 1997 If the agent is using Diffserv Codepoint markings [RFC2475] in its 1998 data packets, it SHOULD apply the same markings to Binding responses. 1999 The same would apply to any layer 2 markings the endpoint might be 2000 applying to data packets. 2002 7.3.1. Additional Procedures for Full Implementations 2004 This subsection defines the additional server procedures applicable 2005 to full implementations, when the full implementation accepts the 2006 Binding request. 2008 7.3.1.1. Detecting and Repairing Role Conflicts 2010 In certain usages of ICE (such as 3PCC), both ICE agents may end up 2011 choosing the same role, resulting in a role conflict. The section 2012 describes a mechanism for detecting and repairing role conflicts. 2013 The usage document MUST specify whether this mechanism is needed. 2015 An agent MUST examine the Binding request for either the ICE- 2016 CONTROLLING or ICE-CONTROLLED attribute. It MUST follow these 2017 procedures: 2019 o If the agent is in the controlling role, and the ICE-CONTROLLING 2020 attribute is present in the request: 2022 * If the agent's tie-breaker value is larger than or equal to the 2023 contents of the ICE-CONTROLLING attribute, the agent generates 2024 a Binding error response and includes an ERROR-CODE attribute 2025 with a value of 487 (Role Conflict) but retains its role. 2027 * If the agent's tie-breaker value is less than the contents of 2028 the ICE-CONTROLLING attribute, the agent switches to the 2029 controlled role. 2031 o If the agent is in the controlled role, and the ICE-CONTROLLED 2032 attribute is present in the request: 2034 * If the agent's tie-breaker value is larger than or equal to the 2035 contents of the ICE-CONTROLLED attribute, the agent switches to 2036 the controlling role. 2038 * If the agent's tie-breaker value is less than the contents of 2039 the ICE-CONTROLLED attribute, the agent generates a Binding 2040 error response and includes an ERROR-CODE attribute with a 2041 value of 487 (Role Conflict) but retains its role. 2043 o If the agent is in the controlled role and the ICE-CONTROLLING 2044 attribute was present in the request, or the agent was in the 2045 controlling role and the ICE-CONTROLLED attribute was present in 2046 the request, there is no conflict. 2048 A change in roles will require an agent to recompute pair priorities 2049 (Section 6.1.2.3), since those priorities are a function of role. 2050 The change in role will also impact whether the agent is responsible 2051 for selecting nominated pairs and initiating exchange with updated 2052 candidate information upon conclusion of ICE. 2054 The remaining sections in Section 7.3.1 are followed if the agent 2055 generated a successful response to the Binding request, even if the 2056 agent changed roles. 2058 7.3.1.2. Computing Mapped Address 2060 For requests received on a relayed candidate, the source transport 2061 address used for STUN processing (namely, generation of the XOR- 2062 MAPPED-ADDRESS attribute) is the transport address as seen by the 2063 TURN server. That source transport address will be present in the 2064 XOR-PEER-ADDRESS attribute of a Data Indication message, if the 2065 Binding request was delivered through a Data Indication. If the 2066 Binding request was delivered through a ChannelData message, the 2067 source transport address is the one that was bound to the channel. 2069 7.3.1.3. Learning Peer Reflexive Candidates 2071 If the source transport address of the request does not match any 2072 existing remote candidates, it represents a new peer reflexive remote 2073 candidate. This candidate is constructed as follows: 2075 o The type is peer reflexive. 2077 o The priority is the value of the PRIORITY attribute in the Binding 2078 request. 2080 o The foundation is an arbitrary value, different from the 2081 foundations of all other remote candidates. If any subsequent 2082 candidate exchanges contain this peer reflexive candidate, it will 2083 signal the actual foundation for the candidate. 2085 o The component ID is the component ID of the local candidate to 2086 which the request was sent. 2088 This candidate is added to the list of remote candidates. However, 2089 the ICE agent does not pair this candidate with any local candidates. 2091 7.3.1.4. Triggered Checks 2093 Next, the agent constructs a pair whose local candidate has the 2094 transport address (as seen by the agent) on which the STUN request 2095 was received, and a remote candidate equal to the source transport 2096 address where the request came from (which may be the peer reflexive 2097 remote candidate that was just learned). The local candidate will 2098 either be a host candidate (for cases where the request was not 2099 received through a relay) or a relayed candidate (for cases where it 2100 is received through a relay). The local candidate can never be a 2101 server reflexive candidate. Since both candidates are known to the 2102 agent, it can obtain their priorities and compute the candidate pair 2103 priority. This pair is then looked up in the check list. There can 2104 be one of several outcomes: 2106 o If the pair is already on the check list: 2108 * If the state of that pair is Succeeded, nothing further is 2109 done. 2111 * If the state of that pair is In-Progress, the agent cancels the 2112 In-Progress transaction. Cancellation means that the agent 2113 will not retransmit the Binding requests associated with the 2114 connectivity check transaction, will not treat the lack of 2115 response to be a failure, but will wait the duration of the 2116 transaction timeout for a response. In addition, the agent 2117 MUST add enqueue the pair in the triggered check list 2118 associated with the check list, and set the state of the pair 2119 to Waiting, in order to trigger a new connectivity check of the 2120 pair. Creating a new connectivity check enables validating In- 2121 Progress pairs as soon as possible, without having to wait for 2122 retransmissions of the Binding requests associated with the 2123 original connectivity check transaction. 2125 * If the state of that pair is Waiting, Frozen or Failed, the 2126 agent MUST enqueue the pair in the triggered check list 2127 associated with the check list (if not already present), and 2128 set the state of the pair to Waiting, in order to trigger a new 2129 connectivity check of the pair. Note that a state change of 2130 the pair from Failed to Waiting might also trigger a state 2131 change of the associated check list. 2133 These steps are done to facilitate rapid completion of ICE when both 2134 agents are behind NAT. 2136 o If the pair is not already on the check list: 2138 * The pair is inserted into the check list based on its priority. 2140 * Its state is set to Waiting. 2142 * The pair is enqueued into the triggered check queue. 2144 When a triggered check is to be sent, it is constructed and processed 2145 as described in Section 7.2.4. These procedures require the agent to 2146 know the transport address, username fragment, and password for the 2147 peer. The username fragment for the remote candidate is equal to the 2148 part after the colon of the USERNAME in the Binding request that was 2149 just received. Using that username fragment, the agent can check the 2150 candidates received from its peer (there may be more than one in 2151 cases of forking), and find this username fragment. The 2152 corresponding password is then picked. 2154 7.3.1.5. Updating the Nominated Flag 2156 If the controlled agent receives a Binding request with the USE- 2157 CANDIDATE attribute set, and if the ICE agent accepts the request, 2158 the following action is based on the state of the pair computed in 2159 Section 7.3.1.4: 2161 o If the state of this pair is Succeeded, it means that the check 2162 previously sent by this pair produced a successful response, and 2163 generated a valid pair (Section 7.2.5.3.2). The agent sets the 2164 nominated flag value of the valid pair to true. 2166 o If the received Binding request triggered a new check to be enqued 2167 in the triggered check queue (Section 7.3.1.4), once the check is 2168 sent and if it generates a successful response, and generates a 2169 valid pair, the agent sets the nominated flag of the pair to true. 2170 If the request fails (Section 7.2.5.2), the agent MUST remove the 2171 candidate pair from the valid list, set the candidate pair state 2172 to Failed and set the check list state to Failed. 2174 If the controlled agent does not accept the request from the 2175 controlling agent, the controlled agent MUST reject the nomination 2176 request with an appropriate error code response (e.g., 400) 2177 [RFC5389]. 2179 Once the nominated flag is set for a component of a data stream, it 2180 concludes the ICE processing for that component. See Section 8. 2182 7.3.2. Additional Procedures for Lite Implementations 2184 If the controlled agent receives a Binding request with the USE- 2185 CANDIDATE attribute set, and if the ICE agent accepts the request, 2186 the agent constructs a candidate pair whose local candidate has the 2187 transport address on which the request was received, and whose remote 2188 candidate is equal to the source transport address of the request 2189 that was received. This candidate pair is assigned an arbitrary 2190 priority, and placed into the valid list of the associated check 2191 list. The agent sets the nominated flag for that pair to true. 2193 Once the nominated flag is set for a component of a data stream, it 2194 concludes the ICE processing for that component. See Section 8. 2196 8. Concluding ICE Processing 2198 This section describes how an ICE agent completes ICE. 2200 8.1. Procedures for Full Implementations 2202 Concluding ICE involves nominating pairs by the controlling agent and 2203 updating of state machinery. 2205 8.1.1. Nominating Pairs 2207 Prior to nominating, the controlling agent let connectivity checks 2208 continue until some stopping criterion is met. After that, based on 2209 an evaluation criterion, the controlling agent picks a pair among the 2210 valid pairs in the valid list for nomination. 2212 Once the controlling agent has picked a valid pair for nomination, it 2213 repeats the connectivity check that produced this valid pair (by 2214 enqueueing the pair that generated the check into the triggered check 2215 queue), this time with the USE-CANDIDATE attribute Section 7.3.1.5. 2217 Eventually, if the nominations succeed, both the controlling and 2218 controlled agents will have a single nominated pair in the valid list 2219 for each component of the data stream. Once an ICE agent sets the 2220 state of the check list to Completed (when there is a nominated pair 2221 for each component of the data stream), that pair becomes the 2222 selected pair for that agent, and is used for sending and receiving 2223 data for that component of the data stream. 2225 If an agent is not able to produce selected pairs for a data stream, 2226 the agent MUST take proper actions for informing the other agent, and 2227 e.g., removing the stream. The exact actions are outside the scope 2228 of this specification. 2230 The criteria for stopping the connectivity checks and for selecting a 2231 pair for nomination, are outside the scope of this specification. 2232 They are a matter of local optimization. The only requirement is 2233 that the agent MUST eventually pick one and only one candidate pair 2234 and generate a check for that pair with the USE-CANDIDATE attribute 2235 set. 2237 Once the controlling agent has successfully nominated a candidate 2238 pair (i.e., the agent has set the nominated flag of the pair to 2239 true), the agent MUST NOT nominate another pair for same same 2240 component of the data stream within the ICE session. Doing so 2241 requires an ICE restart. 2243 A controlling agent that does not support this specification (i.e., 2244 it is implemented according to RFC 5245) might nominate more than one 2245 candidate pair. This was referred to as "aggressive nomination" in 2246 RFC 5245. If more than one candidate pair is nominated by the 2247 controlling agent, and if the controlled agent accepts multiple 2248 nominations requests, the agents MUST produce the selected pairs 2249 using the pairs with the highest priority. 2251 The usage of the 'ice2' ice option (Section 10) by endpoints 2252 supporting this specification is supposed to prevent controlling 2253 agents implemented according to RFC 5245 from using aggressive 2254 nomination. 2256 NOTE: In RFC 5245, usage of "aggressive nomination" allowed agents to 2257 continuously nominate pairs, before a pair was eventually selected, 2258 in order to allow sending of data on those pairs. In this 2259 specification, data can always be sent on any valid pair, without 2260 nomination. Hence, there is no longer a need for aggressive 2261 nomination. 2263 8.1.2. Updating States 2265 For both controlling and controlled agents, the state of ICE 2266 processing depends on the presence of nominated candidate pairs in 2267 the valid list and on the state of the check list. Note that, at any 2268 time, more than one of the following cases can apply: 2270 o If there are no nominated pairs in the valid list for a data 2271 stream and the state of the check list is Running, ICE processing 2272 continues. 2274 o If there is at least one nominated pair in the valid list for a 2275 data stream and the state of the check list is Running: 2277 * The ICE agent MUST remove all Waiting and Frozen pairs in the 2278 CHECK LIST and triggered check queue for the same component as 2279 the nominated pairs for that data stream. 2281 * If an In-Progress pair in the check list is for the same 2282 component as a nominated pair, the agent SHOULD cease 2283 retransmissions for its check if its pair priority is lower 2284 than the lowest-priority nominated pair for that component. 2286 o Once there is at least one nominated pair in the valid list for 2287 every component of at least one data stream and the state of the 2288 check list is Running: 2290 * The agent MUST change the state of processing for its check 2291 list for that data stream to Completed. 2293 * The agent MUST continue to respond to any checks it may still 2294 receive for that data stream, and MUST perform triggered checks 2295 if required by the processing of Section 7.3. 2297 * The agent MUST continue retransmitting any In-Progress checks 2298 for that check list. 2300 o Once the state of each check list is Completed: 2302 * The agent sets the state of ICE processing overall to 2303 Completed. 2305 o If the state of the check list is Failed, ICE has not been able to 2306 complete for this data stream. The correct behavior depends on 2307 the state of the check lists for other data streams: 2309 * If all check lists are Failed, ICE processing overall is 2310 considered to be in the Failed state, and the agent SHOULD 2311 consider the session a failure, SHOULD NOT restart ICE, and the 2312 controlling agent SHOULD terminate the entire session. 2314 * If at least one of the check lists for other data streams is 2315 Completed, the controlling agent SHOULD remove the failed data 2316 stream from the session while sending updated candidate list to 2317 its peer. 2319 * If none of the check lists for other data streams are 2320 Completed, but at least one is Running, the agent SHOULD let 2321 ICE continue. 2323 8.2. Procedures for Lite Implementations 2325 When ICE concludes, a lite ICE agent can free host candidates that 2326 were not used by ICE, as described in Section 8.3. 2328 If the peer is a full agent, once the lite agent accepts a nomination 2329 request for a candidate pair, the lite agent considers the pair 2330 nominated. Once there are nominated pairs for each component of a 2331 data stream, the pairs become the selected pairs for the components 2332 of the data stream. Once the lite agent has produced selected pairs 2333 for all components of all data streams, the ICE session state is set 2334 to Completed. 2336 If the peer is a lite agent, the agent pairs local candidates with 2337 remote candidates that are for the same data stream and have the same 2338 component, transport protocol, and IP address family. For each 2339 component of each data stream, if there is only one candidate pair, 2340 that pair is added to the valid list. If there is more than one 2341 pair, it is RECOMMENDED that an agent follow the procedures of RFC 2342 6724 [RFC6724] to select a pair and add it to the valid list. 2344 If all of the components for all data streams had one pair, the state 2345 of ICE processing is Completed. Otherwise, the controlling agent 2346 MUST send an updated candidate list to reconcile different agents 2347 selecting different candidate pairs. ICE processing is complete 2348 after and only after the updated candidate exchange is complete. 2350 8.3. Freeing Candidates 2352 8.3.1. Full Implementation Procedures 2354 The rules in this section describe when it is safe for an agent to 2355 cease sending or receiving checks on a candidate that did not become 2356 a selected candidate (is not associated with a selected pair), and 2357 then free the candidate. 2359 Once a check list has reached the Completed state, the agent SHOULD 2360 wait an additional three seconds, and then it can cease responding to 2361 checks or generating triggered checks on all local candidates other 2362 than the ones that became selected candidates. Once all ICE sessions 2363 have ceased using a given local candidate (a candidate may be used by 2364 multiple ICE sessions, e.g., in forking scenarios), the agent can 2365 free that candidate. The three-second delay handles cases when 2366 aggressive nomination is used, and the selected pairs can quickly 2367 change after ICE has completed. 2369 Freeing of server reflexive candidates is never explicit; it happens 2370 by lack of a keepalive. 2372 8.3.2. Lite Implementation Procedures 2374 A lite implementation can free candidates that did not become 2375 selected candidates as soon as ICE processing has reached the 2376 Completed state for all ICE sessions using those candidates. 2378 9. ICE Restarts 2380 An ICE agent MAY restart ICE for existing data streams. An ICE 2381 restart causes all previous state of the data streams, excluding the 2382 roles of the agents, to be flushed. The only difference between an 2383 ICE restart and a brand new data session is that during the restart, 2384 data can continue to be sent using existing data sessions, and that a 2385 new data session always requires the roles to be determined. 2387 The following actions can be accomplished only using an ICE restart 2388 (the agent MUST use ICE restarts to do so): 2390 o Change the destinations of data streams. 2392 o Change from a lite implementation to a full implementation. 2394 o Change from a full implementation to a lite implementation. 2396 To restart ICE, an agent MUST change both the password and the 2397 username fragment for the data stream(s) being restarted. 2399 When the ICE is restarted, the candidate set for the new ICE session 2400 might include some, none, or all of the candidates used in the 2401 current ICE session. 2403 As described in Section 6.1.1, agents MUST NOT re-determine the roles 2404 as part as an ICE restart, unless certain criteria that require the 2405 roles to be re-determined are fulfilled. 2407 10. ICE Option 2409 This section defines a new ICE option, 'ice2'. The ICE option 2410 indicates that the ICE agent that includes it in a candidate exchange 2411 is compliant to this specification. For example, the agent will not 2412 use the aggressive nomination procedure defined in RFC 5245. In 2413 addition, it will ensure that an RFC 5245-compliant peer does not use 2414 aggressive nomination either, as required by Section 14 of RFC 5245 2415 for peers which receive unknown ICE options. 2417 An agent compliant to this specification MUST inform the peer about 2418 the compliance using the 'ice2' option. 2420 NOTE: The encoding of the 'ice2' ICE option, and the message(s) used 2421 to carry it to the peer, are protocol specific. The encoding for the 2422 Session Description Protocol (SDP) [RFC4566] is defined in 2423 [I-D.ietf-mmusic-ice-sip-sdp]. 2425 11. Keepalives 2427 All endpoints MUST send keepalives for each data session. These 2428 keepalives serve the purpose of keeping NAT bindings alive for the 2429 data session. The keepalives SHOULD be sent using a format that is 2430 supported by its peer. ICE endpoints allow for STUN-based keepalives 2431 for UDP streams, and as such, STUN keepalives MUST be used when an 2432 ICE agent is a full ICE implementation and is communicating with a 2433 peer that supports ICE (lite or full). 2435 For each candidate pair that an agent is using to send data, if no 2436 packet has been sent on that pair in the last Tr seconds, an agent 2437 MUST send a keepalive on that pair. Agents SHOULD use a Tr value of 2438 15 seconds. Agents MAY use a bigger value, but MUST NOT use a value 2439 smaller than 15 seconds. 2441 Once selected pairs have been produced for a data stream, keepalives 2442 are only sent on those pairs. 2444 An agent MUST stop sending keepalives on a data stream if the data 2445 stream is removed. If the ICE session is terminated, an agent MUST 2446 stop sending keepalives on all data streams. 2448 An agent MAY use another value for Tr, e.g. based on configuration or 2449 network/NAT characteristics. For example, if an agent has a dynamic 2450 way to discover the binding lifetimes of the intervening NATs, it can 2451 use that value to determine Tr. Administrators deploying ICE in more 2452 controlled networking environments SHOULD set Tr to the longest 2453 duration possible in their environment. 2455 When STUN is being used for keepalives, a STUN Binding Indication is 2456 used [RFC5389]. The Indication MUST NOT utilize any authentication 2457 mechanism. It SHOULD contain the FINGERPRINT attribute to aid in 2458 demultiplexing, but SHOULD NOT contain any other attributes. It is 2459 used solely to keep the NAT bindings alive. The Binding Indication 2460 is sent using the same local and remote candidates that are being 2461 used for data. Though Binding Indications are used for keepalives, 2462 an agent MUST be prepared to receive a connectivity check as well. 2463 If a connectivity check is received, a response is generated as 2464 discussed in [RFC5389], but there is no impact on ICE processing 2465 otherwise. 2467 Agents MUST by default use STUN keepalives. Individual ICE usages 2468 and ICE extensions MAY specify usage/extension-specific keepalives. 2470 12. Data Handling 2472 12.1. Sending Data 2474 An ICE agent MAY send data on any valid pair before selected pairs 2475 have been produced for the data stream. 2477 Once selected pairs have been produced for a data stream, an agent 2478 MUST send data on those pairs only. 2480 An agent sends data from the base of the local candidate to the 2481 remote candidate. In the case of a local relayed candidate, data is 2482 forwarded through the base (located in the TURN server), using the 2483 procedures defined in [RFC5766]. 2485 If the local candidate is a relayed candidate, it is RECOMMENDED that 2486 an agent creates a channel on the TURN server towards the remote 2487 candidate. This is done using the procedures for channel creation as 2488 defined in Section 11 of [RFC5766]. 2490 The selected pair for a component of a data stream is: 2492 o empty if the state of the check list for that data stream is 2493 Running, and there is no previous selected pair for that component 2494 due to an ICE restart 2496 o equal to the previous selected pair for a component of a data 2497 stream if the state of the check list for that data stream is 2498 Running, and there was a previous selected pair for that component 2499 due to an ICE restart 2501 Unless an agent is able to produce a selected pair for each component 2502 associated with a data stream, the agent MUST NOT continue sending 2503 data for any component associated with that data stream. 2505 12.1.1. Procedures for Lite Implementations 2507 A lite implementation MUST NOT send data until it has a valid list 2508 that contains a candidate pair for each component of that data 2509 stream. Once that happens, the ICE agent MAY begin sending data 2510 packets. To do that, it sends data to the remote candidate in the 2511 pair (setting the destination address and port of the packet equal to 2512 that remote candidate), and will send it from the base associated 2513 with the candidate pair used for sending data. In case of a relayed 2514 candidate, data is sent from the agent and forwarded through the base 2515 (located in the TURN server), using the procedures defined in 2516 [RFC5766]. 2518 12.2. Receiving Data 2520 Even though ICE agents are only allowed to send data using valid 2521 candidate pairs (and, once selected pairs have been produced, only on 2522 the selected pairs) ICE implementations SHOULD by default be prepared 2523 to receive data on any of the candidates provided in the most recent 2524 candidate exchange with the peer. ICE usages MAY define rules that 2525 differ from this, e.g., by defining that data will not be sent until 2526 selected pairs have been produced for a data stream. 2528 It is RECOMMENDED that, when an agent receives an RTP packet with a 2529 new source or destination IP address for a particular RTP/RTCP data 2530 stream, that the agent re-adjust its jitter buffers. 2532 RFC 3550 [RFC3550] describes an algorithm in Section 8.2 for 2533 detecting synchronization source (SSRC) collisions and loops. These 2534 algorithms are based, in part, on seeing different source transport 2535 addresses with the same SSRC. However, when ICE is used, such 2536 changes will sometimes occur as the data streams switch between 2537 candidates. An agent will be able to determine that a data stream is 2538 from the same peer as a consequence of the STUN exchange that 2539 proceeds media data transmission. Thus, if there is a change in 2540 source transport address, but the media data packets come from the 2541 same peer agent, this MUST NOT be treated as an SSRC collision. 2543 13. Extensibility Considerations 2545 This specification makes very specific choices about how both ICE 2546 agents in a session coordinate to arrive at the set of candidate 2547 pairs that are selected for data. It is anticipated that future 2548 specifications will want to alter these algorithms, whether they are 2549 simple changes like timer tweaks or larger changes like a revamp of 2550 the priority algorithm. When such a change is made, providing 2551 interoperability between the two agents in a session is critical. 2553 First, ICE provides the ICE option concept. Each extension or change 2554 to ICE is associated with an ICE option. When an agent supports such 2555 an extension or change, it provides the ICE option to the peer agent 2556 as part of the candidate exchange. 2558 One of the complications in achieving interoperability is that ICE 2559 relies on a distributed algorithm running on both agents to converge 2560 on an agreed set of candidate pairs. If the two agents run different 2561 algorithms, it can be difficult to guarantee convergence on the same 2562 candidate pairs. The nomination procedure described in Section 8 2563 eliminates some of the need for tight coordination by delegating the 2564 selection algorithm completely to the controlling agent, and ICE will 2565 converge perfectly even when both agents use different pair 2566 prioritization algorithms. One of the keys to such convergence is 2567 triggered checks, which ensure that the nominated pair is validated 2568 by both agents. 2570 ICE is also extensible to other data streams beyond RTP, and for 2571 transport protocols beyond UDP. Extensions to ICE for non-RTP data 2572 streams need to specify how many components they utilize, and assign 2573 component IDs to them, starting at 1 for the most important component 2574 ID. Specifications for new transport protocols MUST define how, if 2575 at all, various steps in the ICE processing differ from UDP. 2577 14. Setting Ta and RTO 2579 14.1. General 2581 During the ICE gathering phase (Section 5.1.1) and while ICE is 2582 performing connectivity checks (Section 7), an ICE agent triggers 2583 STUN and TURN transactions. These transactions are paced at a rate 2584 indicated by Ta, and the retransmission interval for each transaction 2585 is calculated based on the the retransmission timer for the STUN 2586 transactions (RTO) [RFC5389]. 2588 This section describes how the Ta and RTO values are computed during 2589 the ICE gathering phase and while ICE is performing connectivity 2590 checks. 2592 NOTE: Previously, in RFC 5245, different formulas were defined for 2593 computing Ta and RTO, depending on whether ICE was used for a real- 2594 time data stream (e.g., RTP) or not. 2596 The formulas below result in a behavior whereby an agent will send 2597 its first packet for every single connectivity check before 2598 performing a retransmit. This can be seen in the formulas for the 2599 RTO (which represents the retransmit interval). Those formulas scale 2600 with N, the number of checks to be performed. As a result of this, 2601 ICE maintains a nicely constant rate, but becomes more sensitive to 2602 packet loss. The loss of the first single packet for any 2603 connectivity check is likely to cause that pair to take a long time 2604 to be validated, and instead, a lower-priority check (but one for 2605 which there was no packet loss) is much more likely to complete 2606 first. This results in ICE performing sub-optimally, choosing lower- 2607 priority pairs over higher-priority pairs. 2609 14.2. Ta 2611 ICE agents SHOULD use a default Ta value, 50 ms, but MAY use another 2612 value based on the characteristics of the associated data. 2614 If an agent wants to use another Ta value than the default value, the 2615 agent MUST indicate the proposed value to its peer during the 2616 establishment of the ICE session. Both agents MUST use the higher 2617 value of the proposed values. If an agent does not propose a value, 2618 the default value is used for that agent when comparing which value 2619 is higher. 2621 Regardless of the Ta value chosen for each agent, the combination of 2622 all transactions from all agents (if a given implementation runs 2623 several concurrent agents) MUST NOT be sent more often than once 2624 every 5ms (as though there were one global Ta value for pacing all 2625 agents). See Appendix B.1 for the background of using a value of 5ms 2626 with ICE. 2628 NOTE: Appendix C shows examples of required bandwidth, using 2629 different Ta values. 2631 14.3. RTO 2633 During the ICE gathering phase, ICE agents SHOULD calculate the RTO 2634 value using the following formula: 2636 RTO = MAX (500ms, Ta * (Num-Of-Cands)) 2638 Num-Of-Cands: the number of server-reflexive and relay candidates 2640 For connectivity checks, agents SHOULD calculate the RTO value using 2641 the following formula: 2643 RTO = MAX (500ms, Ta * N * (Num-Waiting + Num-In-Progress)) 2645 N: the total number of connectivity checks to be performed. 2647 Num-Waiting: the number of checks in the check list set in the 2648 Waiting state. 2650 Num-In-Progress: the number of checks in the check list set in the 2651 In-Progress state. 2653 Note that the RTO will be different for each transaction as the 2654 number of checks in the Waiting and In-Progress states change. 2656 Agents MAY calculate the RTO value using other mechanisms than those 2657 described above. Agents MUST NOT use a RTO value smaller than 500 2658 ms. 2660 15. Examples 2662 This section shows two ICE examples: one using IPv4 addresses, and 2663 one using IPv6 addresses. 2665 To facilitate understanding, transport addresses are listed using 2666 variables that have mnemonic names. The format of the name is 2667 entity-type-seqno, where entity refers to the entity whose IP address 2668 the transport address is on, and is one of "L", "R", "STUN", or 2669 "NAT". The type is either "PUB" for transport addresses that are 2670 public, and "PRIV" for transport addresses that are private 2671 [RFC1918]. Finally, seq-no is a sequence number that is different 2672 for each transport address of the same type on a particular entity. 2673 Each variable has an IP address and port, denoted by varname.IP and 2674 varname.PORT, respectively, where varname is the name of the 2675 variable. 2677 In the call flow itself, STUN messages are annotated with several 2678 attributes. The "S=" attribute indicates the source transport 2679 address of the message. The "D=" attribute indicates the destination 2680 transport address of the message. The "MA=" attribute is used in 2681 STUN Binding response messages and refers to the mapped address. 2682 "USE-CAND" implies the presence of the USE-CANDIDATE attribute. 2684 The call flow examples omit STUN authentication operations, and focus 2685 on a single data stream between two full implementations. 2687 15.1. Example with IPv4 Addresses 2689 The example is using the topology shown in Figure 7. 2691 +-------+ 2692 |STUN | 2693 |Server | 2694 +-------+ 2695 | 2696 +---------------------+ 2697 | | 2698 | Internet | 2699 | | 2700 +---------------------+ 2701 | | 2702 | | 2703 +---------+ | 2704 | NAT | | 2705 +---------+ | 2706 | | 2707 | | 2708 +-----+ +-----+ 2709 | L | | R | 2710 +-----+ +-----+ 2712 Figure 7: Example Topology 2714 In the example, ICE agents L and R are full ICE implementations. 2715 Both agents have a single IPv4 address. Both are configured with the 2716 same STUN server. The NAT has an endpoint independent mapping 2717 property and an address dependent filtering property. The IP 2718 addresses of the ICE agents, the STUN server and the NAT are shown 2719 below; 2721 ENTITY IP Address mnemonic name 2722 -------------------------------------------------- 2723 ICE Agent L: 10.0.1.1 L-PRIV-1 2724 ICE Agent R: 192.0.2.1 R-PUB-1 2725 STUN Server: 192.0.2.2 STUN-PUB-1 2726 NAT (Public): 192.0.2.3 NAT-PUB-1 2728 L NAT STUN R 2729 |STUN alloc. | | | 2730 |(1) STUN Req | | | 2731 |S=$L-PRIV-1 | | | 2732 |D=$STUN-PUB-1 | | | 2733 |------------->| | | 2734 | |(2) STUN Req | | 2735 | |S=$NAT-PUB-1 | | 2736 | |D=$STUN-PUB-1 | | 2737 | |------------->| | 2738 | |(3) STUN Res | | 2739 | |S=$STUN-PUB-1 | | 2740 | |D=$NAT-PUB-1 | | 2741 | |MA=$NAT-PUB-1 | | 2742 | |<-------------| | 2743 |(4) STUN Res | | | 2744 |S=$STUN-PUB-1 | | | 2745 |D=$L-PRIV-1 | | | 2746 |MA=$NAT-PUB-1 | | | 2747 |<-------------| | | 2748 |(5) L's Candidate Information| | 2749 |------------------------------------------->| 2750 | | | | STUN 2751 | | | | alloc. 2752 | | |(6) STUN Req | 2753 | | |S=$R-PUB-1 | 2754 | | |D=$STUN-PUB-1 | 2755 | | |<-------------| 2756 | | |(7) STUN Res | 2757 | | |S=$STUN-PUB-1 | 2758 | | |D=$R-PUB-1 | 2759 | | |MA=$R-PUB-1 | 2760 | | |------------->| 2761 |(8) R's Candidate Information| | 2762 |<-------------------------------------------| 2763 | | (9) Bind Req |Begin 2764 | | S=$R-PUB-1 |Connectivity 2765 | | D=$L-PRIV-1 |Checks 2766 | | <-------------------| 2767 | | Dropped | 2768 |(10) Bind Req | | | 2769 |S=$L-PRIV-1 | | | 2770 |D=$R-PUB-1 | | | 2771 |------------->| | | 2772 | |(11) Bind Req | | 2773 | |S=$NAT-PUB-1 | | 2774 | |D=$R-PUB-1 | | 2775 | |---------------------------->| 2776 | |(12) Bind Res | | 2777 | |S=$R-PUB-1 | | 2778 | |D=$NAT-PUB-1 | | 2779 | |MA=$NAT-PUB-1 | | 2780 | |<----------------------------| 2781 |(13) Bind Res | | | 2782 |S=$R-PUB-1 | | | 2783 |D=$L-PRIV-1 | | | 2784 |MA=$NAT-PUB-1 | | | 2785 |<-------------| | | 2786 |Data | | | 2787 |===========================================>| 2788 | | | | 2789 | |(14) Bind Req | | 2790 | |S=$R-PUB-1 | | 2791 | |D=$NAT-PUB-1 | | 2792 | |<----------------------------| 2793 |(15) Bind Req | | | 2794 |S=$R-PUB-1 | | | 2795 |D=$L-PRIV-1 | | | 2796 |<-------------| | | 2797 |(16) Bind Res | | | 2798 |S=$L-PRIV-1 | | | 2799 |D=$R-PUB-1 | | | 2800 |MA=$R-PUB-1 | | | 2801 |------------->| | | 2802 | |(17) Bind Res | | 2803 | |S=$NAT-PUB-1 | | 2804 | |D=$R-PUB-1 | | 2805 | |MA=$R-PUB-1 | | 2806 | |---------------------------->| 2807 |Data | | | 2808 |<===========================================| 2809 | | | | 2810 ....... 2811 | | | | 2812 |(18) Bind Req | | | 2813 |S=$L-PRIV-1 | | | 2814 |D=$R-PUB-1 | | | 2815 |USE-CAND | | | 2816 |------------->| | | 2817 | |(19) Bind Req | | 2818 | |S=$NAT-PUB-1 | | 2819 | |D=$R-PUB-1 | | 2820 | |USE-CAND | | 2821 | |---------------------------->| 2822 | |(20) Bind Res | | 2823 | |S=$R-PUB-1 | | 2824 | |D=$NAT-PUB-1 | | 2825 | |MA=$NAT-PUB-1 | | 2826 | |<----------------------------| 2827 |(21) Bind Res | | | 2828 |S=$R-PUB-1 | | | 2829 |D=$L-PRIV-1 | | | 2830 |MA=$NAT-PUB-1 | | | 2831 |<-------------| | | 2832 | | | | 2834 Figure 8: Example Flow 2836 Messages 1-4: Agent L gathers a host candidate from its local IP 2837 address, and from that sends a STUN Binding request to the STUN 2838 Server. The request creates a NAT binding. The NAT public IP 2839 address of the binding becomes agent L's server reflexive candidate. 2841 Message 5: Agent L sends its local candidate information to agent R, 2842 using the signalling protocol associated with the ICE usage. 2844 Messages 6-7: Agent R gathers a host candidate from its local IP 2845 address, and from that sends a STUN Binding request to the STUN 2846 Server. Since agent R is not behind a NAT, R's server reflexive 2847 candidate will be identical to the host candidate. 2849 Message 8: Agent R sends its local candidate information to agent L, 2850 using the signalling protocol associated with the ICE usage. 2852 Since both agents are full ICE implementations, the initiating agent 2853 (agent L) becomes the controlling agent. 2855 Agents L and R both pair up the candidates. Both agents initially 2856 have two pairs. However, agent L will prune the pair containing its 2857 server reflexive candidate, resulting in just one (L1). At agent L, 2858 this pair has a local candidate of $L_PRIV_1 and remote candidate of 2859 $R_PUB_1. At agent R, there are two pairs. The highest priority 2860 pair (R1) has a local candidate of $R_PUB_1 and remote candidate of 2861 $L_PRIV_1, and the second pair (R2) has a local candidate of $R_PUB_1 2862 and remote candidate of $NAT_PUB_1. The pairs are shown below (the 2863 pair numbers are for reference purpose only): 2865 Pairs 2866 ENTITY Local Remote Pair # Valid 2867 ------------------------------------------------------------------ 2868 ICE Agent L: L_PRIV_1 R_PUB_1 L1 2870 ICE Agent R: R_PUB_1 L_PRIV_1 R1 2871 R_PUB_1 NAT_PUB_1 R2 2873 Message 9: Agent R initiates a connectivity check for pair #2. As 2874 the remote candidate of the pair is the private address of agent L, 2875 the check will not be successful, as the request cannot be routed 2876 from R to L, and will be dropped by the network. 2878 Messages 10-13: Agent L initiates a connectivity check for pair L1. 2879 The check succeeds, and L creates a new pair (L2). The local 2880 candidate of the new pair is $NAT_PUB_1 and the remote candidate is 2881 $R_PUB_1. The pair (L2) is added to the valid list of agent L. 2882 Agent L can now send and receive data on the pair (L2) if it wishes. 2884 Pairs 2885 ENTITY Local Remote Pair # Valid 2886 ------------------------------------------------------------------ 2887 ICE Agent L: L_PRIV_1 R_PUB_1 L1 2888 NAT_PUB_1 R_PUB_1 L2 X 2890 ICE Agent R: R_PUB_1 L_PRIV_1 R1 2891 R_PUB_1 NAT_PUB_1 R2 2893 Messages 14-17: When agent R receives the Binding request from agent 2894 L (message 11) it will initiate a triggered connectivity check. The 2895 pair matches one of agent R's existing pairs (R2). The check 2896 succeeds, and the pair (R2) is added to the valid list of agent R. 2897 Agent R can now send and receive data on the pair (R2) if it wishes. 2899 Pairs 2900 ENTITY Local Remote Pair # Valid 2901 ------------------------------------------------------------------ 2902 ICE Agent L: L_PRIV_1 R_PUB_1 L1 2903 NAT_PUB_1 R_PUB_1 L2 X 2905 ICE Agent R: R_PUB_1 L_PRIV_1 R1 2906 R_PUB_1 NAT_PUB_1 R2 X 2908 Messages 18-21: At some point, the controlling agent (agent L) 2909 decides to nominate a pair (L2) in the valid list. It performs a 2910 connectivity check on the pair (L2), and includes the USE-CANDIDATE 2911 attribute in the Binding request. As the check succeeds, agent L 2912 sets the nominated flag value of the pair (L2) to 'true'. Agent R 2913 sets the nominated flag value of the matching pair (R2) to 'true'. 2914 As there are no more components associated with the stream, the 2915 nominated pairs become the selected pairs. Consequently, processing 2916 for this stream moves into the Completed state. The ICE process also 2917 moves into the Completed state. 2919 15.2. Example with IPv6 Addresses 2921 The example is using the topology shown in Figure 9. 2923 +-------+ 2924 |STUN | 2925 |Server | 2926 +-------+ 2927 | 2928 +---------------------+ 2929 | | 2930 | Internet | 2931 | | 2932 +---------------------+ 2933 | | 2934 | | 2935 | | 2936 | | 2937 | | 2938 | | 2939 | | 2940 +-----+ +-----+ 2941 | L | | R | 2942 +-----+ +-----+ 2944 Figure 9: Example Topology 2946 In the example, ICE agents L and R are full ICE implementations. 2947 Both agents have a single IPv6 address. Both are configured with the 2948 same STUN server. The IP addresses of the ICE agents and the STUN 2949 server are shown below; 2951 ENTITY IP Address mnemonic name 2952 -------------------------------------------------- 2953 ICE Agent L: 2001:db8::3 L-PUB-1 2954 ICE Agent R: 2001:db8::5 R-PUB-1 2955 STUN Server: 2001:db8::9 STUN-PUB-1 2957 L STUN R 2958 |STUN alloc. | | 2959 |(1) STUN Req | | 2960 |S=$L-PUB-1 | | 2961 |D=$STUN-PUB-1 | | 2962 |---------------------------->| | 2963 |(2) STUN Res | | 2964 | S=$STUN-PUB-1 | | 2965 | D=$L-PUB-1 | | 2966 | MA=$L-PUB-1 | | 2967 |<----------------------------| | 2968 |(3) L's Candidate Information| | 2969 |------------------------------------------->| 2970 | | | STUN 2971 | | | alloc. 2972 | |(4) STUN Req | 2973 | |S=$R-PUB-1 | 2974 | |D=$STUN-PUB-1 | 2975 | |<-------------| 2976 | |(5) STUN Res | 2977 | |S=$STUN-PUB-1 | 2978 | |D=$R-PUB-1 | 2979 | |MA=$R-PUB-1 | 2980 | |------------->| 2981 |(6) R's Candidate Information| | 2982 |<-------------------------------------------| 2983 |(7) Bind Req | | 2984 |S=$L-PUB-1 | | 2985 |D=$R-PUB-1 | | 2986 |------------------------------------------->| 2987 |(8) Bind Res | | 2988 |S=$R-PUB-1 | | 2989 |D=$L-PUB-1 | | 2990 |MA=$L-PUB-1 | | 2991 |<-------------------------------------------| 2992 |Data | | 2993 |===========================================>| 2994 | | | 2995 |(9) Bind Req | | 2996 |S=$R-PUB-1 | | 2997 |D=$L-PUB-1 | | 2998 |<-------------------------------------------| 2999 |(10) Bind Res | | 3000 |S=$L-PUB-1 | | 3001 |D=$R-PUB-1 | | 3002 |MA=$R-PUB-1 | | 3003 |------------------------------------------->| 3004 |Data | | 3005 |<===========================================| 3006 | | | 3007 ....... 3008 | | | 3009 |(11) Bind Req | | 3010 |S=$L-PUB-1 | | 3011 |D=$R-PUB-1 | | 3012 |USE-CAND | | 3013 |------------------------------------------->| 3014 |(12) Bind Res | | 3015 |S=$R-PUB-1 | | 3016 |D=$L-PUB-1 | | 3017 |MA=$L-PUB-1 | | 3018 |<-------------------------------------------| 3019 | | | | 3021 Figure 10: Example Flow 3023 Messages 1-2: Agent L gathers a host candidate from its local IP 3024 address, and from that sends a STUN Binding request to the STUN 3025 Server. Since agent L is not behind a NAT, L's server reflexive 3026 candidate will be identical to the host candidate. 3028 Message 3: Agent L sends its local candidate information to agent R, 3029 using the signalling protocol associated with the ICE usage. 3031 Messages 4-5: Agent R gathers a host candidate from its local IP 3032 address, and from that sends a STUN Binding request to the STUN 3033 Server. Since agent R is not behind a NAT, R's server reflexive 3034 candidate will be identical to the host candidate. 3036 Message 6: Agent R sends its local candidate information to agent L, 3037 using the signalling protocol associated with the ICE usage. 3039 Since both agents are full ICE implementations, the initiating agent 3040 (agent L) becomes the controlling agent. 3042 Agents L and R both pair up the candidates. Both agents initially 3043 have one pair each. At agent L, the pair (L1) has a local candidate 3044 of $L_PUB_1 and remote candidate of $R_PUB_1. At agent R, the pair 3045 (R1) has a local candidate of $R_PUB_1 and remote candidate of 3046 $L_PUB_1. The pairs are shown below (the pair numbers are for 3047 reference purpose only): 3049 Pairs 3050 ENTITY Local Remote Pair # Valid 3051 ------------------------------------------------------------------ 3052 ICE Agent L: L_PUB_1 R_PUB_1 L1 3054 ICE Agent R: R_PUB_1 L_PUB_1 R1 3056 Messages 7-8: Agent L initiates a connectivity check for pair L1. 3057 The check succeeds, and the pair (L1) is added to the valid list of 3058 agent L. Agent L can now send and receive data on the pair (L1) if 3059 it wishes. 3061 Pairs 3062 ENTITY Local Remote Pair # Valid 3063 ------------------------------------------------------------------ 3064 ICE Agent L: L_PUB_1 R_PUB_1 L1 X 3066 ICE Agent R: R_PUB_1 L_PUB_1 R1 3068 Messages 9-10: When agent R receives the Binding request from agent L 3069 (message 7) it will initiate a triggered connectivity check. The 3070 pair matches agent R's existing pair (R1). The check succeeds, and 3071 the pair (R1) is added to the valid list of agent R. Agent R can now 3072 send and receive data on the pair (R1) if it wishes. 3074 Pairs 3075 ENTITY Local Remote Pair # Valid 3076 ------------------------------------------------------------------ 3077 ICE Agent L: L_PUB_1 R_PUB_1 L1 X 3079 ICE Agent R: R_PUB_1 L_PUB_1 R1 X 3081 Messages 11-12: At some point, the controlling agent (agent L) 3082 decides to nominate a pair (L1) in the valid list. It performs a 3083 connectivity check on the pair (L1), and includes the USE-CANDIDATE 3084 attribute in the Binding request. As the check succeeds, agent L 3085 sets the nominated flag value of the pair (L1) to 'true'. Agent R 3086 sets the nominated flag value of the matching pair (R1) to 'true'. 3087 As there are no more components associated with the stream, the 3088 nominated pairs become the selected pairs. Consequently, processing 3089 for this stream moves into the Completed state. The ICE process also 3090 moves into the Completed state. 3092 16. STUN Extensions 3094 16.1. New Attributes 3096 This specification defines four STUN attributes: PRIORITY, USE- 3097 CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. 3099 The PRIORITY attribute indicates the priority that is to be 3100 associated with a peer reflexive candidate, if one will be discovered 3101 by this check. It is a 32-bit unsigned integer, and has an attribute 3102 value of 0x0024. 3104 The USE-CANDIDATE attribute indicates that the candidate pair 3105 resulting from this check will be used for transmission of data. The 3106 attribute has no content (the Length field of the attribute is zero); 3107 it serves as a flag. It has an attribute value of 0x0025. 3109 The ICE-CONTROLLED attribute is present in a Binding request. The 3110 attribute indicates that the client believes it is currently in the 3111 controlled role. The content of the attribute is a 64-bit unsigned 3112 integer in network byte order, which contains a random number. The 3113 number is used for solving role conflicts, when it is referred to as 3114 the tie-breaker value. An ICE agent MUST use the same number for all 3115 Binding requests, for all streams, within an ICE session, unless it 3116 has received a 487 response, in which case it MUST change the number 3117 (Section 7.2.5.1). The agent MAY change the number when an ICE 3118 restart occurs. 3120 The ICE-CONTROLLING attribute is present in a Binding request. The 3121 attribute indicates that the client believes it is currently in the 3122 controlling role. The content of the attribute is a 64-bit unsigned 3123 integer in network byte order, which contains a random number. As 3124 for the ICE-CONTROLLED attribute, the number is used for solving role 3125 conflicts. An agent MUST use the same number for all Binding 3126 requests, for all streams, within an ICE session, unless it has 3127 received a 487 response, in which case it MUST change the number 3128 (Section 7.2.5.1). The agent MAY change the number when an ICE 3129 restart occurs. 3131 16.2. New Error Response Codes 3133 This specification defines a single error response code: 3135 487 (Role Conflict): The Binding request contained either the ICE- 3136 CONTROLLING or ICE-CONTROLLED attribute, indicating an ICE role 3137 that conflicted with the server. The remote server compared the 3138 tie-breaker values of the client and the server and determined 3139 that the client needs to switch roles. 3141 17. Operational Considerations 3143 This section discusses issues relevant to operators operating 3144 networks where ICE will be used by endpoints. 3146 17.1. NAT and Firewall Types 3148 ICE was designed to work with existing NAT and firewall equipment. 3149 Consequently, it is not necessary to replace or reconfigure existing 3150 firewall and NAT equipment in order to facilitate deployment of ICE. 3151 Indeed, ICE was developed to be deployed in environments where the 3152 Voice over IP (VoIP) operator has no control over the IP network 3153 infrastructure, including firewalls and NATs. 3155 That said, ICE works best in environments where the NAT devices are 3156 "behave" compliant, meeting the recommendations defined in [RFC4787] 3157 and [RFC5382]. In networks with behave-compliant NAT, ICE will work 3158 without the need for a TURN server, thus improving voice quality, 3159 decreasing call setup times, and reducing the bandwidth demands on 3160 the network operator. 3162 17.2. Bandwidth Requirements 3164 Deployment of ICE can have several interactions with available 3165 network capacity that operators need to take into consideration. 3167 17.2.1. STUN and TURN Server Capacity Planning 3169 First and foremost, ICE makes use of TURN and STUN servers, which 3170 would typically be located in data centers. The STUN servers require 3171 relatively little bandwidth. For each component of each data stream, 3172 there will be one or more STUN transactions from each client to the 3173 STUN server. In a basic voice-only IPv4 VoIP deployment, there will 3174 be four transactions per call (one for RTP and one for RTCP, for both 3175 caller and callee). Each transaction is a single request and a 3176 single response, the former being 20 bytes long, and the latter, 28. 3177 Consequently, if a system has N users, and each makes four calls in a 3178 busy hour, this would require N*1.7bps. For one million users, this 3179 is 1.7 Mbps, a very small number (relatively speaking). 3181 TURN traffic is more substantial. The TURN server will see traffic 3182 volume equal to the STUN volume (indeed, if TURN servers are 3183 deployed, there is no need for a separate STUN server), in addition 3184 to the traffic for the actual data. The amount of calls requiring 3185 TURN for data relay is highly dependent on network topologies, and 3186 can and will vary over time. In a network with 100% behave-compliant 3187 NATs, it is exactly zero. 3189 The planning considerations above become more significant in multi- 3190 media scenarios (e.g., audio and video conferences), and when the 3191 numbers of participants in a session grow. 3193 17.2.2. Gathering and Connectivity Checks 3195 The process of gathering of candidates and performing of connectivity 3196 checks can be bandwidth intensive. ICE has been designed to pace 3197 both of these processes. The gathering phase and the connectivity 3198 check phase are meant to generate traffic at roughly the same 3199 bandwidth as the data traffic itself will consume once the ICE 3200 process conclude. This was done to ensure that, if a network is 3201 designed to support communication traffic of a certain type (voice, 3202 video, or just text), it will have sufficient capacity to support the 3203 ICE checks for that data. Once ICE has concluded, the subsequent ICE 3204 keepalives will later cause a marginal increase in the total 3205 bandwidth utilization; however, this will typically be an extremely 3206 small increase. 3208 Congestion due to the gathering and check phases has proven to be a 3209 problem in deployments that did not utilize pacing. Typically, 3210 access links became congested as the endpoints flooded the network 3211 with checks as fast as they can send them. Consequently, network 3212 operators need to ensure that their ICE implementations support the 3213 pacing feature. Though this pacing does increase call setup times, 3214 it makes ICE network friendly and easier to deploy. 3216 17.2.3. Keepalives 3218 STUN keepalives (in the form of STUN Binding Indications) are sent in 3219 the middle of a data session. However, they are sent only in the 3220 absence of actual data traffic. In deployments with continuous media 3221 and without utilizing Voice Activity Detection (VAD), or deployments 3222 where VAD is utilized together with short interval (max 1 second) 3223 comfort noise, the keepalives are never used and there is no increase 3224 in bandwidth usage. When VAD is being used without comfort noise, 3225 keepalives will be sent during silence periods. This involves a 3226 single packet every 15-20 seconds, far less than the packet every 3227 20-30 ms that is sent when there is voice. Therefore, keepalives do 3228 not have any real impact on capacity planning. 3230 17.3. ICE and ICE-lite 3232 Deployments utilizing a mix of ICE and ICE-lite interoperate with 3233 each other. They have been explicitly designed to do so. 3235 However, ICE-lite can only be deployed in limited use cases. Those 3236 cases, and the caveats involved in doing so, are documented in 3237 Appendix A. 3239 17.4. Troubleshooting and Performance Management 3241 ICE utilizes end-to-end connectivity checks, and places much of the 3242 processing in the endpoints. This introduces a challenge to the 3243 network operator -- how can they troubleshoot ICE deployments? How 3244 can they know how ICE is performing? 3246 ICE has built-in features to help deal with these problems. 3247 Signaling servers, typically deployed in data centers of the network 3248 operator, will see the contents of the candidate exchanges that 3249 convey the ICE parameters. These parameters include the type of each 3250 candidate (host, server reflexive, or relayed), along with their 3251 related addresses. Once ICE processing has completed, an updated 3252 candidate exchange takes place, signaling the selected address (and 3253 its type). This updated signaling is performed exactly for the 3254 purposes of educating network equipment (such as a diagnostic tool 3255 attached to a signaling) about the results of ICE processing. 3257 As a consequence, through the logs generated by a signaling server, a 3258 network operator can observe what types of candidates are being used 3259 for each call, and what address were selected by ICE. This is the 3260 primary information that helps evaluate how ICE is performing. 3262 17.5. Endpoint Configuration 3264 ICE relies on several pieces of data being configured into the 3265 endpoints. This configuration data includes timers, credentials for 3266 TURN servers, and hostnames for STUN and TURN servers. ICE itself 3267 does not provide a mechanism for this configuration. Instead, it is 3268 assumed that this information is attached to whatever mechanism is 3269 used to configure all of the other parameters in the endpoint. For 3270 SIP phones, standard solutions such as the configuration framework 3271 [RFC6080] have been defined. 3273 18. IAB Considerations 3275 The IAB has studied the problem of "Unilateral Self-Address Fixing" 3276 (UNSAF), which is the general process by which an ICE agent attempts 3277 to determine its address in another realm on the other side of a NAT 3278 through a collaborative protocol reflection mechanism [RFC3424]. ICE 3279 is an example of a protocol that performs this type of function. 3280 Interestingly, the process for ICE is not unilateral, but bilateral, 3281 and the difference has a significant impact on the issues raised by 3282 the IAB. Indeed, ICE can be considered a B-SAF (Bilateral Self- 3283 Address Fixing) protocol, rather than an UNSAF protocol. Regardless, 3284 the IAB has mandated that any protocols developed for this purpose 3285 document a specific set of considerations. This section meets those 3286 requirements. 3288 18.1. Problem Definition 3290 From RFC 3424, any UNSAF proposal needs to provide: 3292 Precise definition of a specific, limited-scope problem that is to 3293 be solved with the UNSAF proposal. A short-term fix will not be 3294 generalized in order to solve other problems; this is why "short- 3295 term fixes usually aren't". 3297 The specific problems being solved by ICE are: 3299 Provide a means for two peers to determine the set of transport 3300 addresses that can be used for communication. 3302 Provide a means for a agent to determine an address that is 3303 reachable by another peer with which it wishes to communicate. 3305 18.2. Exit Strategy 3307 From RFC 3424, any UNSAF proposal needs to provide: 3309 Description of an exit strategy/transition plan. The better 3310 short-term fixes are the ones that will naturally see less and 3311 less use as the appropriate technology is deployed. 3313 ICE itself doesn't easily get phased out. However, it is useful even 3314 in a globally connected Internet, to serve as a means for detecting 3315 whether a router failure has temporarily disrupted connectivity, for 3316 example. ICE also helps prevent certain security attacks that have 3317 nothing to do with NAT. However, what ICE does is help phase out 3318 other UNSAF mechanisms. ICE effectively picks amongst those 3319 mechanisms, prioritizing ones that are better, and deprioritizing 3320 ones that are worse. As NATs begin to dissipate as IPv6 is 3321 introduced, server reflexive and relayed candidates (both forms of 3322 UNSAF addresses) simply never get used, because higher-priority 3323 connectivity exists to the native host candidates. Therefore, the 3324 servers get used less and less, and can eventually be removed when 3325 their usage goes to zero. 3327 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 3328 be used to determine whether to use IPv6 or IPv4 when two dual-stack 3329 hosts communicate with SIP (IPv6 gets used). It can also allow a 3330 network with both 6to4 and native v6 connectivity to determine which 3331 address to use when communicating with a peer. 3333 18.3. Brittleness Introduced by ICE 3335 From RFC 3424, any UNSAF proposal needs to provide: 3337 Discussion of specific issues that may render systems more 3338 "brittle". For example, approaches that involve using data at 3339 multiple network layers create more dependencies, increase 3340 debugging challenges, and make it harder to transition. 3342 ICE actually removes brittleness from existing UNSAF mechanisms. In 3343 particular, classic STUN (as described in RFC 3489 [RFC3489]) has 3344 several points of brittleness. One of them is the discovery process 3345 that requires an ICE agent to try to classify the type of NAT it is 3346 behind. This process is error-prone. With ICE, that discovery 3347 process is simply not used. Rather than unilaterally assessing the 3348 validity of the address, its validity is dynamically determined by 3349 measuring connectivity to a peer. The process of determining 3350 connectivity is very robust. 3352 Another point of brittleness in classic STUN and any other unilateral 3353 mechanism is its absolute reliance on an additional server. ICE 3354 makes use of a server for allocating unilateral addresses, but allows 3355 agents to directly connect if possible. Therefore, in some cases, 3356 the failure of a STUN server would still allow for a call to progress 3357 when ICE is used. 3359 Another point of brittleness in classic STUN is that it assumes that 3360 the STUN server is on the public Internet. Interestingly, with ICE, 3361 that is not necessary. There can be a multitude of STUN servers in a 3362 variety of address realms. ICE will discover the one that has 3363 provided a usable address. 3365 The most troubling point of brittleness in classic STUN is that it 3366 doesn't work in all network topologies. In cases where there is a 3367 shared NAT between each agent and the STUN server, traditional STUN 3368 may not work. With ICE, that restriction is removed. 3370 Classic STUN also introduces some security considerations. 3371 Fortunately, those security considerations are also mitigated by ICE. 3373 Consequently, ICE serves to repair the brittleness introduced in 3374 classic STUN, and does not introduce any additional brittleness into 3375 the system. 3377 The penalty of these improvements is that ICE increases session 3378 establishment times. 3380 18.4. Requirements for a Long-Term Solution 3382 From RFC 3424, any UNSAF proposal needs to provide: 3384 ... requirements for longer term, sound technical solutions -- 3385 contribute to the process of finding the right longer term 3386 solution. 3388 Our conclusions from RFC 3489 remain unchanged. However, we feel ICE 3389 actually helps because we believe it can be part of the long-term 3390 solution. 3392 18.5. Issues with Existing NAPT Boxes 3394 From RFC 3424, any UNSAF proposal needs to provide: 3396 Discussion of the impact of the noted practical issues with 3397 existing, deployed NA[P]Ts and experience reports. 3399 A number of NAT boxes are now being deployed into the market that try 3400 to provide "generic" ALG functionality. These generic ALGs hunt for 3401 IP addresses, either in text or binary form within a packet, and 3402 rewrite them if they match a binding. This interferes with classic 3403 STUN. However, the update to STUN [RFC5389] uses an encoding that 3404 hides these binary addresses from generic ALGs. 3406 Existing NAPT boxes have non-deterministic and typically short 3407 expiration times for UDP-based bindings. This requires 3408 implementations to send periodic keepalives to maintain those 3409 bindings. ICE uses a default of 15 s, which is a very conservative 3410 estimate. Eventually, over time, as NAT boxes become compliant to 3411 behave [RFC4787], this minimum keepalive will become deterministic 3412 and well-known, and the ICE timers can be adjusted. Having a way to 3413 discover and control the minimum keepalive interval would be far 3414 better still. 3416 19. Security Considerations 3417 19.1. IP Address Privacy 3419 The process of probing for candidates reveals the source addresses of 3420 the client and its peer to any on-network listening attacker, and the 3421 process of exchanging candidates reveals the addresses to any 3422 attacker that is able to see the negotiation. Some addresses, such 3423 as the server reflexive addresses gathered through the local 3424 interface of VPN users, may be sensitive information. If these 3425 potential attacks can not be mitigated, ICE usages can define 3426 mechanisms for controlling which addresses are revealed to the 3427 negotiation and/or probing process. Individual implementations may 3428 also have implementation-specific rules for controlling which 3429 addresses are revealed. For example, [I-D.ietf-rtcweb-ip-handling] 3430 provides additional information about the privacy aspects of 3431 revealing IP addresses via ICE for WebRTC applications. ICE 3432 implementations where such issues can arise are RECOMMENDED to 3433 provide a programmatic or user interface that provides control over 3434 which network interfaces are used to generate candidates. 3436 Based on the types of candidates provided by the peer, and the 3437 results of the connectivity tests performed against those candidates, 3438 the peer might be able to determine characteristics of the local 3439 network, e.g. if different timings are apparent to the peer. In the 3440 limit the peer might be able to probe the local network. 3442 There are several types of attacks possible in an ICE system. The 3443 subsections consider these attacks and their countermeasures. 3445 19.2. Attacks on Connectivity Checks 3447 An attacker might attempt to disrupt the STUN connectivity checks. 3448 Ultimately, all of these attacks fool an ICE agent into thinking 3449 something incorrect about the results of the connectivity checks. 3450 Depending on the type of attack, the attacker needs to have different 3451 capabilities. In some cases the attacker needs to be on the path of 3452 the connectivity checks. In other cases the attacker does not need 3453 to be on the path, as long as it is able to generate STUN 3454 connectivity checks. While attacks on connectivity checks are 3455 typically performed by network entities, if an attacker is able to 3456 control an endpoint it might be able to trigger connectivity check 3457 attacks. The possible false conclusions an attacker can try and 3458 cause are: 3460 False Invalid: An attacker can fool a pair of agents into thinking a 3461 candidate pair is invalid, when it isn't. This can be used to 3462 cause an agent to prefer a different candidate (such as one 3463 injected by the attacker) or to disrupt a call by forcing all 3464 candidates to fail. 3466 False Valid: An attacker can fool a pair of agents into thinking a 3467 candidate pair is valid, when it isn't. This can cause an agent 3468 to proceed with a session, but then not be able to receive any 3469 data. 3471 False Peer Reflexive Candidate: An attacker can cause an agent to 3472 discover a new peer reflexive candidate when it is not expected 3473 to. This can be used to redirect data streams to a Denial-of- 3474 Service (DoS) target or to the attacker, for eavesdropping or 3475 other purposes. 3477 False Valid on False Candidate: An attacker has already convinced an 3478 agent that there is a candidate with an address that does not 3479 actually route to that agent (e.g., by injecting a false peer 3480 reflexive candidate or false server reflexive candidate). The 3481 attacker then launches an attack that forces the agents to believe 3482 that this candidate is valid. 3484 If an attacker can cause a false peer reflexive candidate or false 3485 valid on a false candidate, it can launch any of the attacks 3486 described in [RFC5389]. 3488 To force the false invalid result, the attacker has to wait for the 3489 connectivity check from one of the agents to be sent. When it is, 3490 the attacker needs to inject a fake response with an unrecoverable 3491 error response (such as a 400), or drop the response so that it never 3492 reaches the agent. However, since the candidate is, in fact, valid, 3493 the original request may reach the peer agent, and result in a 3494 success response. The attacker needs to force this packet or its 3495 response to be dropped, through a DoS attack, layer 2 network 3496 disruption, or other technique. If it doesn't do this, the success 3497 response will also reach the originator, alerting it to a possible 3498 attack. The ability for the attacker to generate a fake response is 3499 mitigated through the STUN short-term credential mechanism. In order 3500 for this response to be processed, the attacker needs the password. 3501 If the candidate exchange signaling is secured, the attacker will not 3502 have the password and its response will be discarded. 3504 Spoofed ICMP Hard Errors (Type 3, codes 2-4) can also be used to 3505 create false invalid results. If an ICE agent implements a response 3506 to these ICMP errors, and the attacker is capable of generating an 3507 ICMP message that is delivered to the agent sending the connectivity 3508 check. The validation of the ICMP error message by the agent is its 3509 only defence. For Type 3 code=4 the outer IP header provides no 3510 validation, unless the connectivity check was sent with DF=0. For 3511 code 2 or 3, which are originated by the host, the address is 3512 expected to be any of the remote agents host, reflexive, or relay 3513 candidates IP addresses. The ICMP message include the IP header and 3514 UDP header of the message triggering the error. These fields also 3515 need to be validated. The IP destination and UDP destination port 3516 need to match either the targeted candidate address and port, or the 3517 candidate's base address. The source IP address and port can be any 3518 candidate for the same base address of the agent sending the 3519 connectivity check. Thus any attacker having access to the exchange 3520 of the candidates will have the necessary information. Thus the 3521 validation is a weak defence, and the sending of spoofed ICMP attacks 3522 is possible also for off-path attackers from a node in a network 3523 without source address validation. 3525 Forcing the fake valid result works in a similar way. The attacker 3526 needs to wait for the Binding request from each agent, and inject a 3527 fake success response. Again, due to the STUN short-term credential 3528 mechanism, in order for the attacker to inject a valid success 3529 response, the attacker needs the password. Alternatively, the 3530 attacker can route (e.g., using a tunnelling mechanism) a valid 3531 success response, that normally would be dropped or rejected by the 3532 network, to the agent. 3534 Forcing the false peer reflexive candidate result can be done either 3535 with fake requests or responses, or with replays. We consider the 3536 fake requests and responses case first. It requires the attacker to 3537 send a Binding request to one agent with a source IP address and port 3538 for the false candidate. In addition, the attacker needs to wait for 3539 a Binding request from the other agent, and generate a fake response 3540 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 3541 Like the other attacks described here, this attack is mitigated by 3542 the STUN message integrity mechanisms and secure candidate exchanges. 3544 Forcing the false peer reflexive candidate result with packet replays 3545 is different. The attacker waits until one of the agents sends a 3546 check. It intercepts this request, and replays it towards the other 3547 agent with a faked source IP address. It also needs to prevent the 3548 original request from reaching the remote agent, either by launching 3549 a DoS attack to cause the packet to be dropped, or forcing it to be 3550 dropped using layer 2 mechanisms. The replayed packet is received at 3551 the other agent, and accepted, since the integrity check passes (the 3552 integrity check cannot and does not cover the source IP address and 3553 port). It is then responded to. This response will contain a XOR- 3554 MAPPED-ADDRESS with the false candidate, and will be sent to that 3555 false candidate. The attacker then needs to receive it and relay it 3556 towards the originator. 3558 The other agent will then initiate a connectivity check towards that 3559 false candidate. This validation needs to succeed. This requires 3560 the attacker to force a false valid on a false candidate. Injecting 3561 of fake requests or responses to achieve this goal is prevented using 3562 the integrity mechanisms of STUN and the candidate exchange. Thus, 3563 this attack can only be launched through replays. To do that, the 3564 attacker needs to intercept the check towards this false candidate, 3565 and replay it towards the other agent. Then, it needs to intercept 3566 the response and replay that back as well. 3568 This attack is very hard to launch unless the attacker is identified 3569 by the fake candidate. This is because it requires the attacker to 3570 intercept and replay packets sent by two different hosts. If both 3571 agents are on different networks (e.g., across the public Internet), 3572 this attack can be hard to coordinate, since it needs to occur 3573 against two different endpoints on different parts of the network at 3574 the same time. 3576 If the attacker itself is identified by the fake candidate, the 3577 attack is easier to coordinate. However, if the data path is secured 3578 (e.g., using SRTP [RFC3711]), the attacker will not be able to 3579 process the data packets, but will only be able to discard them, 3580 effectively disabling the data stream. However, this attack requires 3581 the agent to disrupt packets in order to block the connectivity check 3582 from reaching the target. In that case, if the goal is to disrupt 3583 the data stream, it's much easier to just disrupt it with the same 3584 mechanism, rather than attack ICE. 3586 19.3. Attacks on Server Reflexive Address Gathering 3588 ICE endpoints make use of STUN Binding requests for gathering server 3589 reflexive candidates from a STUN server. These requests are not 3590 authenticated in any way. As a consequence, there are numerous 3591 techniques an attacker can employ to provide the client with a false 3592 server reflexive candidate: 3594 o An attacker can compromise the DNS, causing DNS queries to return 3595 a rogue STUN server address. That server can provide the client 3596 with fake server reflexive candidates. This attack is mitigated 3597 by DNS security, though DNSSEC is not required to address it. 3599 o An attacker that can observe STUN messages (such as an attacker on 3600 a shared network segment, like WiFi) can inject a fake response 3601 that is valid and will be accepted by the client. 3603 o An attacker can compromise a STUN server, and cause it to send 3604 responses with incorrect mapped addresses. 3606 A false mapped address learned by these attacks will be used as a 3607 server reflexive candidate in the establishment of the ICE session. 3608 For this candidate to actually be used for data, the attacker also 3609 needs to attack the connectivity checks, and in particular, force a 3610 false valid on a false candidate. This attack is very hard to launch 3611 if the false address identifies a fourth party (neither the 3612 initiator, responder, nor attacker), since it requires attacking the 3613 checks generated by each ICE agent in the session, and is prevented 3614 by SRTP if it identifies the attacker itself. 3616 If the attacker elects not to attack the connectivity checks, the 3617 worst it can do is prevent the server reflexive candidate from being 3618 used. However, if the peer agent has at least one candidate that is 3619 reachable by the agent under attack, the STUN connectivity checks 3620 themselves will provide a peer reflexive candidate that can be used 3621 for the exchange of data. Peer reflexive candidates are generally 3622 preferred over server reflexive candidates. As such, an attack 3623 solely on the STUN address gathering will normally have no impact on 3624 a session at all. 3626 19.4. Attacks on Relayed Candidate Gathering 3628 An attacker might attempt to disrupt the gathering of relayed 3629 candidates, forcing the client to believe it has a false relayed 3630 candidate. Exchanges with the TURN server are authenticated using a 3631 long-term credential. Consequently, injection of fake responses or 3632 requests will not work. In addition, unlike Binding requests, 3633 Allocate requests are not susceptible to replay attacks with modified 3634 source IP addresses and ports, since the source IP address and port 3635 are not utilized to provide the client with its relayed candidate. 3637 Even if an attacker has caused the client to believe in a false 3638 relayed candidate, the connectivity checks cause such a candidate to 3639 be used only if they succeed. Thus, an attacker needs to launch a 3640 false valid on a false candidate, per above, which is a very 3641 difficult attack to coordinate. 3643 19.5. Insider Attacks 3645 In addition to attacks where the attacker is a third party trying to 3646 insert fake candidate information or STUN messages, there are attacks 3647 possible with ICE when the attacker is an authenticated and valid 3648 participant in the ICE exchange. 3650 19.5.1. STUN Amplification Attack 3652 The STUN amplification attack is similar to a "voice hammer" attack, 3653 where the attacker causes other agents to direct voice packets to the 3654 attack target. However, instead of voice packets being directed to 3655 the target, STUN connectivity checks are directed to the target. The 3656 attacker sends an a large number of candidates, say, 50. The 3657 responding agent receives the candidate information, and starts its 3658 checks, which are directed at the target, and consequently, never 3659 generate a response. In the case of WebRTC the user might not even 3660 be aware that this attack is ongoing, since it might be triggered in 3661 the background by malicious JavaScript code that the user has 3662 fetched. The answerer will start a new connectivity check every Ta 3663 ms (say, Ta=50ms). However, the retransmission timers are set to a 3664 large number due to the large number of candidates. As a 3665 consequence, packets will be sent at an interval of one every Ta 3666 milliseconds, and then with increasing intervals after that. Thus, 3667 STUN will not send packets at a rate faster than data would be sent, 3668 and the STUN packets persist only briefly, until ICE fails for the 3669 session. Nonetheless, this is an amplification mechanism. 3671 It is impossible to eliminate the amplification, but the volume can 3672 be reduced through a variety of heuristics. ICE agents SHOULD limit 3673 the total number of connectivity checks they perform to 100. 3674 Additionally, agents MAY limit the number of candidates they will 3675 accept. 3677 Frequently, protocols that wish to avoid these kinds of attacks force 3678 the initiator to wait for a response prior to sending the next 3679 message. However, in the case of ICE, this is not possible. It is 3680 not possible to differentiate the following two cases: 3682 o There was no response because the initiator is being used to 3683 launch a DoS attack against an unsuspecting target that will not 3684 respond. 3686 o There was no response because the IP address and port are not 3687 reachable by the initiator. 3689 In the second case, another check will be sent at the next 3690 opportunity, while in the former case, no further checks will be 3691 sent. 3693 20. IANA Considerations 3695 The original ICE specification registered four STUN attributes, and 3696 one new STUN error response. The STUN attributes and error response 3697 are reproduced here. In addition, this specification registers a new 3698 ICE option. 3700 20.1. STUN Attributes 3702 IANA has registered four STUN attributes: 3704 0x0024 PRIORITY 3705 0x0025 USE-CANDIDATE 3706 0x8029 ICE-CONTROLLED 3707 0x802A ICE-CONTROLLING 3709 NOTE TO IANA: Please replace the reference to RFC 5245 in the 3710 registry with a reference to this specification. 3712 20.2. STUN Error Responses 3714 IANA has registered following STUN error response code: 3716 487 Role Conflict: The client asserted an ICE role (controlling or 3717 controlled) that is in conflict with the role of the server. 3719 NOTE TO IANA: Please replace the reference to RFC 5245 in the 3720 registry with a reference to this specification. 3722 20.3. ICE Options 3724 IANA is requested to register the following ICE option in the "ICE 3725 Options" sub-registry of the "Interactive Connectivity Establishment 3726 (ICE) registry", following the procedures defined in [RFC6336]. 3728 ICE Option name: 3730 ice2 3732 Contact: 3734 Name: IESG 3735 E-mail: iesg@ietf.org 3737 Change control: 3739 IESG 3741 Description: 3743 The ICE option indicates that the ICE agent using the ICE option 3744 is implemented according to RFC XXXX. 3746 Reference: 3748 RFC XXXX 3750 21. Changes from RFC 5245 3752 The purpose of this updated ICE specification is to: 3754 o Clarify procedures in RFC 5245. 3756 o Make technical changes, due to discovered flaws in RFC 5245 and 3757 based on feedback from the community that has implemented and 3758 deployed ICE applications based on RFC 5245. 3760 o Make the procedures signaling protocol independent, by removing 3761 the SIP and SDP procedures. Procedures specific to a signaling 3762 protocol will be defined in separate usage documents. 3763 [I-D.ietf-mmusic-ice-sip-sdp] defines the ICE usage with SIP and 3764 SDP. 3766 The following technical changes have been done: 3768 o Aggressive nomination removed. 3770 o The procedures for calculating candidate pair states and 3771 scheduling connectivity checks modified. 3773 o Procedures for calculation of Ta and RTO modified. 3775 o Active check list and frozen check list definitions removed. 3777 o 'ice2' ice option added. 3779 o IPv6 considerations modified. 3781 o Usage with no-op for keepalives, and keepalives with non-ICE 3782 peers, removed. 3784 22. Acknowledgements 3786 Most of the text in this document comes from the original ICE 3787 specification, RFC 5245. The authors would like to thank everyone 3788 who has contributed to that document. For additional contributions 3789 to this revision of the specification we would like to thank Emil 3790 Ivov, Paul Kyzivat, Pal-Erik Martinsen, Simon Perrault, Eric 3791 Rescorla, Thomas Stach, Peter Thatcher, Martin Thomson, Justin 3792 Uberti, Suhas Nandakumar, Taylor Brandstetter, Peter Saint-Andre, 3793 Harald Alvestrand and Roman Shpount. Ben Campbell did the AD review. 3794 Stephen Farrell did the sec-dir review. Stewart Bryant did the gen- 3795 art review. Qin We did the ops-dir review. Magnus Westerlund did 3796 the tsv-art review. 3798 23. References 3800 23.1. Normative References 3802 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3803 Requirement Levels", BCP 14, RFC 2119, 3804 DOI 10.17487/RFC2119, March 1997, . 3807 [RFC4941] Narten, T., Draves, R., and S. Krishnan, "Privacy 3808 Extensions for Stateless Address Autoconfiguration in 3809 IPv6", RFC 4941, DOI 10.17487/RFC4941, September 2007, 3810 . 3812 [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, 3813 "Session Traversal Utilities for NAT (STUN)", RFC 5389, 3814 DOI 10.17487/RFC5389, October 2008, . 3817 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3818 Relays around NAT (TURN): Relay Extensions to Session 3819 Traversal Utilities for NAT (STUN)", RFC 5766, 3820 DOI 10.17487/RFC5766, April 2010, . 3823 [RFC6336] Westerlund, M. and C. Perkins, "IANA Registry for 3824 Interactive Connectivity Establishment (ICE) Options", 3825 RFC 6336, DOI 10.17487/RFC6336, July 2011, 3826 . 3828 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3829 "Default Address Selection for Internet Protocol Version 6 3830 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3831 . 3833 23.2. Informative References 3835 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3836 and E. Lear, "Address Allocation for Private Internets", 3837 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3838 . 3840 [RFC3605] Huitema, C., "Real Time Control Protocol (RTCP) attribute 3841 in Session Description Protocol (SDP)", RFC 3605, 3842 DOI 10.17487/RFC3605, October 2003, . 3845 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3846 A., Peterson, J., Sparks, R., Handley, M., and E. 3847 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3848 DOI 10.17487/RFC3261, June 2002, . 3851 [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model 3852 with Session Description Protocol (SDP)", RFC 3264, 3853 DOI 10.17487/RFC3264, June 2002, . 3856 [RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, 3857 "STUN - Simple Traversal of User Datagram Protocol (UDP) 3858 Through Network Address Translators (NATs)", RFC 3489, 3859 DOI 10.17487/RFC3489, March 2003, . 3862 [RFC3235] Senie, D., "Network Address Translator (NAT)-Friendly 3863 Application Design Guidelines", RFC 3235, 3864 DOI 10.17487/RFC3235, January 2002, . 3867 [RFC3303] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and 3868 A. Rayhan, "Middlebox communication architecture and 3869 framework", RFC 3303, DOI 10.17487/RFC3303, August 2002, 3870 . 3872 [RFC3102] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, 3873 "Realm Specific IP: Framework", RFC 3102, 3874 DOI 10.17487/RFC3102, October 2001, . 3877 [RFC3103] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, 3878 "Realm Specific IP: Protocol Specification", RFC 3103, 3879 DOI 10.17487/RFC3103, October 2001, . 3882 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3883 UNilateral Self-Address Fixing (UNSAF) Across Network 3884 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3885 November 2002, . 3887 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3888 Jacobson, "RTP: A Transport Protocol for Real-Time 3889 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3890 July 2003, . 3892 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3893 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3894 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3895 . 3897 [RFC3725] Rosenberg, J., Peterson, J., Schulzrinne, H., and G. 3898 Camarillo, "Best Current Practices for Third Party Call 3899 Control (3pcc) in the Session Initiation Protocol (SIP)", 3900 BCP 85, RFC 3725, DOI 10.17487/RFC3725, April 2004, 3901 . 3903 [RFC3879] Huitema, C. and B. Carpenter, "Deprecating Site Local 3904 Addresses", RFC 3879, DOI 10.17487/RFC3879, September 3905 2004, . 3907 [RFC4038] Shin, M-K., Ed., Hong, Y-G., Hagino, J., Savola, P., and 3908 E. Castro, "Application Aspects of IPv6 Transition", 3909 RFC 4038, DOI 10.17487/RFC4038, March 2005, 3910 . 3912 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 3913 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 3914 2006, . 3916 [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 3917 Description Protocol", RFC 4566, DOI 10.17487/RFC4566, 3918 July 2006, . 3920 [RFC2475] Blake, S., Black, D., Carlson, M., Davies, E., Wang, Z., 3921 and W. Weiss, "An Architecture for Differentiated 3922 Services", RFC 2475, DOI 10.17487/RFC2475, December 1998, 3923 . 3925 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3926 Translation (NAT) Behavioral Requirements for Unicast 3927 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3928 2007, . 3930 [RFC5761] Perkins, C. and M. Westerlund, "Multiplexing RTP Data and 3931 Control Packets on a Single Port", RFC 5761, 3932 DOI 10.17487/RFC5761, April 2010, . 3935 [RFC4103] Hellstrom, G. and P. Jones, "RTP Payload for Text 3936 Conversation", RFC 4103, DOI 10.17487/RFC4103, June 2005, 3937 . 3939 [RFC4091] Camarillo, G. and J. Rosenberg, "The Alternative Network 3940 Address Types (ANAT) Semantics for the Session Description 3941 Protocol (SDP) Grouping Framework", RFC 4091, 3942 DOI 10.17487/RFC4091, June 2005, . 3945 [RFC4092] Camarillo, G. and J. Rosenberg, "Usage of the Session 3946 Description Protocol (SDP) Alternative Network Address 3947 Types (ANAT) Semantics in the Session Initiation Protocol 3948 (SIP)", RFC 4092, DOI 10.17487/RFC4092, June 2005, 3949 . 3951 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3952 (ICE): A Protocol for Network Address Translator (NAT) 3953 Traversal for Offer/Answer Protocols", RFC 5245, 3954 DOI 10.17487/RFC5245, April 2010, . 3957 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 3958 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 3959 RFC 5382, DOI 10.17487/RFC5382, October 2008, 3960 . 3962 [RFC6080] Petrie, D. and S. Channabasappa, Ed., "A Framework for 3963 Session Initiation Protocol User Agent Profile Delivery", 3964 RFC 6080, DOI 10.17487/RFC6080, March 2011, 3965 . 3967 [RFC6146] Bagnulo, M., Matthews, P., and I. van Beijnum, "Stateful 3968 NAT64: Network Address and Protocol Translation from IPv6 3969 Clients to IPv4 Servers", RFC 6146, DOI 10.17487/RFC6146, 3970 April 2011, . 3972 [RFC6147] Bagnulo, M., Sullivan, A., Matthews, P., and I. van 3973 Beijnum, "DNS64: DNS Extensions for Network Address 3974 Translation from IPv6 Clients to IPv4 Servers", RFC 6147, 3975 DOI 10.17487/RFC6147, April 2011, . 3978 [RFC6298] Paxson, V., Allman, M., Chu, J., and M. Sargent, 3979 "Computing TCP's Retransmission Timer", RFC 6298, 3980 DOI 10.17487/RFC6298, June 2011, . 3983 [RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, 3984 "TCP Candidates with Interactive Connectivity 3985 Establishment (ICE)", RFC 6544, DOI 10.17487/RFC6544, 3986 March 2012, . 3988 [RFC6928] Chu, J., Dukkipati, N., Cheng, Y., and M. Mathis, 3989 "Increasing TCP's Initial Window", RFC 6928, 3990 DOI 10.17487/RFC6928, April 2013, . 3993 [RFC7050] Savolainen, T., Korhonen, J., and D. Wing, "Discovery of 3994 the IPv6 Prefix Used for IPv6 Address Synthesis", 3995 RFC 7050, DOI 10.17487/RFC7050, November 2013, 3996 . 3998 [RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy 3999 Considerations for IPv6 Address Generation Mechanisms", 4000 RFC 7721, DOI 10.17487/RFC7721, March 2016, 4001 . 4003 [RFC7825] Goldberg, J., Westerlund, M., and T. Zeng, "A Network 4004 Address Translator (NAT) Traversal Mechanism for Media 4005 Controlled by the Real-Time Streaming Protocol (RTSP)", 4006 RFC 7825, DOI 10.17487/RFC7825, December 2016, 4007 . 4009 [I-D.ietf-mmusic-ice-sip-sdp] 4010 Petit-Huguenin, M., Keranen, A., and S. Nandakumar, 4011 "Session Description Protocol (SDP) Offer/Answer 4012 procedures for Interactive Connectivity Establishment 4013 (ICE)", draft-ietf-mmusic-ice-sip-sdp-16 (work in 4014 progress), November 2017. 4016 [I-D.ietf-ice-dualstack-fairness] 4017 Martinsen, P., Reddy, T., and P. Patil, "ICE Multihomed 4018 and IPv4/IPv6 Dual Stack Guidelines", draft-ietf-ice- 4019 dualstack-fairness-07 (work in progress), November 2016. 4021 [I-D.ietf-rtcweb-ip-handling] 4022 Uberti, J. and G. Shieh, "WebRTC IP Address Handling 4023 Requirements", draft-ietf-rtcweb-ip-handling-06 (work in 4024 progress), March 2018. 4026 Appendix A. Lite and Full Implementations 4028 ICE allows for two types of implementations. A full implementation 4029 supports the controlling and controlled roles in a session, and can 4030 also perform address gathering. In contrast, a lite implementation 4031 is a minimalist implementation that does little but respond to STUN 4032 checks, and only supports the controlled role in a session. 4034 Because ICE requires both endpoints to support it in order to bring 4035 benefits to either endpoint, incremental deployment of ICE in a 4036 network is more complicated. Many sessions involve an endpoint that 4037 is, by itself, not behind a NAT and not one that would worry about 4038 NAT traversal. A very common case is to have one endpoint that 4039 requires NAT traversal (such as a VoIP hard phone or soft phone) make 4040 a call to one of these devices. Even if the phone supports a full 4041 ICE implementation, ICE won't be used at all if the other device 4042 doesn't support it. The lite implementation allows for a low-cost 4043 entry point for these devices. Once they support the lite 4044 implementation, full implementations can connect to them and get the 4045 full benefits of ICE. 4047 Consequently, a lite implementation is only appropriate for devices 4048 that will *always* be connected to the public Internet and have a 4049 public IP address at which it can receive packets from any 4050 correspondent. ICE will not function when a lite implementation is 4051 placed behind a NAT. 4053 ICE allows a lite implementation to have a single IPv4 host candidate 4054 and several IPv6 addresses. In that case, candidate pairs are 4055 selected by the controlling agent using a static algorithm, such as 4056 the one in RFC 6724, which is recommended by this specification. 4057 However, static mechanisms for address selection are always prone to 4058 error, since they cannot ever reflect the actual topology and can 4059 never provide actual guarantees on connectivity. They are always 4060 heuristics. Consequently, if an ICE agent is implementing ICE just 4061 to select between its IPv4 and IPv6 addresses, and none of its IP 4062 addresses are behind NAT, usage of full ICE is still RECOMMENDED in 4063 order to provide the most robust form of address selection possible. 4065 It is important to note that the lite implementation was added to 4066 this specification to provide a stepping stone to full 4067 implementation. Even for devices that are always connected to the 4068 public Internet with just a single IPv4 address, a full 4069 implementation is preferable if achievable. Full implementations 4070 also obtain the security benefits of ICE unrelated to NAT traversal. 4071 Finally, it is often the case that a device that finds itself with a 4072 public address today will be placed in a network tomorrow where it 4073 will be behind a NAT. It is difficult to definitively know, over the 4074 lifetime of a device or product, that it will always be used on the 4075 public Internet. Full implementation provides assurance that 4076 communications will always work. 4078 Appendix B. Design Motivations 4080 ICE contains a number of normative behaviors that may themselves be 4081 simple, but derive from complicated or non-obvious thinking or use 4082 cases that merit further discussion. Since these design motivations 4083 are not necessary to understand for purposes of implementation, they 4084 are discussed here in an appendix to the specification. This section 4085 is non-normative. 4087 B.1. Pacing of STUN Transactions 4089 STUN transactions used to gather candidates and to verify 4090 connectivity are paced out at an approximate rate of one new 4091 transaction every Ta milliseconds. Each transaction, in turn, has a 4092 retransmission timer RTO that is a function of Ta as well. Why are 4093 these transactions paced, and why are these formulas used? 4095 Sending of these STUN requests will often have the effect of creating 4096 bindings on NAT devices between the client and the STUN servers. 4097 Experience has shown that many NAT devices have upper limits on the 4098 rate at which they will create new bindings. Discussions in the IETF 4099 ICE WG during the work on this specification concluded that, that 4100 once every 5 ms is will supported. This is why Ta has a lover bound 4101 of 5 ms. This is why Ta has a lower bound of 5 ms. Furthermore, 4102 transmission of these packets on the network makes use of bandwidth 4103 and needs to be rate limited by the ICE agent. Deployments based on 4104 earlier draft versions of [RFC5245] tended to overload rate- 4105 constrained access links and perform poorly overall, in addition to 4106 negatively impacting the network. As a consequence, the pacing 4107 ensures that the NAT device does not get overloaded and that traffic 4108 is kept at a reasonable rate. 4110 The definition of a "reasonable" rate is that STUN MUST NOT use more 4111 bandwidth than the RTP itself will use, once data starts flowing. 4112 The formula for Ta is designed so that, if a STUN packet were sent 4113 every Ta seconds, it would consume the same amount of bandwidth as 4114 RTP packets, summed across all data streams. Of course, STUN has 4115 retransmits, and the desire is to pace those as well. For this 4116 reason, RTO is set such that the first retransmit on the first 4117 transaction happens just as the first STUN request on the last 4118 transaction occurs. Pictorially: 4120 First Packets Retransmits 4122 | | 4123 | | 4124 -------+------ -------+------ 4125 / \ / \ 4126 / \ / \ 4128 +--+ +--+ +--+ +--+ +--+ +--+ 4129 |A1| |B1| |C1| |A2| |B2| |C2| 4130 +--+ +--+ +--+ +--+ +--+ +--+ 4132 ---+-------+-------+-------+-------+-------+------------ Time 4133 0 Ta 2Ta 3Ta 4Ta 5Ta 4135 In this picture, there are three transactions that will be sent (for 4136 example, in the case of candidate gathering, there are three host 4137 candidate/STUN server pairs). These are transactions A, B, and C. 4138 The retransmit timer is set so that the first retransmission on the 4139 first transaction (packet A2) is sent at time 3Ta. 4141 Subsequent retransmits after the first will occur even less 4142 frequently than Ta milliseconds apart, since STUN uses an exponential 4143 back-off on its retransmissions. 4145 This mechanism of a global minimum pacing interval of 5ms is not 4146 generally applicable to transport protocols, but is applicable to ICE 4147 based on the following reasoning. 4149 o Start with the following rules which would be generally applicable 4150 to transport protocols: 4152 1. Let MaxBytes be the maximum number of bytes allowed to be 4153 outstanding in the network at start-up, which SHOULD be 14600, 4154 as defined in Section 2 of [RFC6928]. 4156 2. Let HTO be the transaction timeout, which SHOULD be 2*RTT if 4157 RTT is known and 500ms otherwise. This is based on the RTO 4158 for STUN messages from [RFC5389] and the the TCP initial RTO, 4159 which is 1 sec in [RFC6298]. 4161 3. Let MinPacing be the minimum pacing interval between 4162 transactions, which is 5ms (see above). 4164 o Observe that agents typically do not know the RTT for ICE 4165 transactions (connectivity checks in particular), meaning that HTO 4166 will almost always be 500ms. 4168 o Observe that a MinPacing of 5ms and HTO of 500ms gives at most 100 4169 packets/HTO, which for a typical ICE check of less than 120 bytes 4170 means a maximum of 12000 outstanding bytes in the network, which 4171 is less than the maximum expressed by rule 1. 4173 o Thus, for ICE, the rule set reduces down to just the MinPacing 4174 rule, which is equivalent to having a global Ta value. 4176 B.2. Candidates with Multiple Bases 4178 Section 5.1.3 talks about eliminating candidates that have the same 4179 transport address and base. However, candidates with the same 4180 transport addresses but different bases are not redundant. When can 4181 an ICE agent have two candidates that have the same IP address and 4182 port, but different bases? Consider the topology of Figure 11: 4184 +----------+ 4185 | STUN Srvr| 4186 +----------+ 4187 | 4188 | 4189 ----- 4190 // \\ 4191 | | 4192 | B:net10 | 4193 | | 4194 \\ // 4195 ----- 4196 | 4197 | 4198 +----------+ 4199 | NAT | 4200 +----------+ 4201 | 4202 | 4203 ----- 4204 // \\ 4205 | A | 4206 |192.168/16 | 4207 | | 4208 \\ // 4209 ----- 4210 | 4211 | 4212 |192.168.1.100 ----- 4213 +----------+ // \\ +----------+ 4214 | | | | | | 4215 | Initiator|---------| C:net10 |-----------| Responder| 4216 | |10.0.1.100| | 10.0.1.101 | | 4217 +----------+ \\ // +----------+ 4218 ----- 4220 Figure 11: Identical Candidates with Different Bases 4222 In this case, the initiating agent is multihomed. It has one IP 4223 address, 10.0.1.100, on network C, which is a net 10 private network. 4224 The responding agent is on this same network. The initiating agent 4225 is also connected to network A, which is 192.168/16 and has an IP 4226 address of 192.168.1.100 on this network. There is a NAT on this 4227 network, natting into network B, which is another net 10 private 4228 network, but not connected to network C. There is a STUN server on 4229 network B. 4231 The initiating agent obtains a host candidate on its IP address on 4232 network C (10.0.1.100:2498) and a host candidate on its IP address on 4233 network A (192.168.1.100:3344). It performs a STUN query to its 4234 configured STUN server from 192.168.1.100:3344. This query passes 4235 through the NAT, which happens to assign the binding 10.0.1.100:2498. 4236 The STUN server reflects this in the STUN Binding response. Now, the 4237 initiating agent has obtained a server reflexive candidate with a 4238 transport address that is identical to a host candidate 4239 (10.0.1.100:2498). However, the server reflexive candidate has a 4240 base of 192.168.1.100:3344, and the host candidate has a base of 4241 10.0.1.100:2498. 4243 B.3. Purpose of the Related Address and Related Port Attributes 4245 The candidate attribute contains two values that are not used at all 4246 by ICE itself -- related address and related port. Why are they 4247 present? 4249 There are two motivations for its inclusion. The first is 4250 diagnostic. It is very useful to know the relationship between the 4251 different types of candidates. By including it, an ICE agent can 4252 know which relayed candidate is associated with which reflexive 4253 candidate, which in turn is associated with a specific host 4254 candidate. When checks for one candidate succeed and not for others, 4255 this provides useful diagnostics on what is going on in the network. 4257 The second reason has to do with off-path Quality of Service (QoS) 4258 mechanisms. When ICE is used in environments such as PacketCable 4259 2.0, proxies will, in addition to performing normal SIP operations, 4260 inspect the SDP in SIP messages, and extract the IP address and port 4261 for data traffic. They can then interact, through policy servers, 4262 with access routers in the network, to establish guaranteed QoS for 4263 the data flows. This QoS is provided by classifying the RTP traffic 4264 based on 5-tuple, and then providing it a guaranteed rate, or marking 4265 its Diffserv codepoints appropriately. When a residential NAT is 4266 present, and a relayed candidate gets selected for data, this relayed 4267 candidate will be a transport address on an actual TURN server. That 4268 address says nothing about the actual transport address in the access 4269 router that would be used to classify packets for QoS treatment. 4270 Rather, the server reflexive candidate towards the TURN server is 4271 needed. By carrying the translation in the SDP, the proxy can use 4272 that transport address to request QoS from the access router. 4274 B.4. Importance of the STUN Username 4276 ICE requires the usage of message integrity with STUN using its 4277 short-term credential functionality. The actual short-term 4278 credential is formed by exchanging username fragments in the 4279 candidate exchange. The need for this mechanism goes beyond just 4280 security; it is actually required for correct operation of ICE in the 4281 first place. 4283 Consider ICE agents L, R, and Z. L and R are within private 4284 enterprise 1, which is using 10.0.0.0/8. Z is within private 4285 enterprise 2, which is also using 10.0.0.0/8. As it turns out, R and 4286 Z both have IP address 10.0.1.1. L sends candidates to Z. Z, in 4287 responds L with its host candidates. In this case, those candidates 4288 are 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, R is in a 4289 session at that same time, and is also using 10.0.1.1:8866 and 4290 10.0.1.1:8877 as host candidates. This means that R is prepared to 4291 accept STUN messages on those ports, just as Z is. L will send a 4292 STUN request to 10.0.1.1:8866 and another to 10.0.1.1:8877. However, 4293 these do not go to Z as expected. Instead, they go to R! If R just 4294 replied to them, L would believe it has connectivity to Z, when in 4295 fact it has connectivity to a completely different user, R. To fix 4296 this, the STUN short-term credential mechanisms are used. The 4297 username fragments are sufficiently random that it is highly unlikely 4298 that R would be using the same values as Z. Consequently, R would 4299 reject the STUN request since the credentials were invalid. In 4300 essence, the STUN username fragments provide a form of transient host 4301 identifiers, bound to a particular session established as part of the 4302 candidate exchange. 4304 An unfortunate consequence of the non-uniqueness of IP addresses is 4305 that, in the above example, R might not even be an ICE agent. It 4306 could be any host, and the port to which the STUN packet is directed 4307 could be any ephemeral port on that host. If there is an application 4308 listening on this socket for packets, and it is not prepared to 4309 handle malformed packets for whatever protocol is in use, the 4310 operation of that application could be affected. Fortunately, since 4311 the ports exchanged are ephemeral and usually drawn from the dynamic 4312 or registered range, the odds are good that the port is not used to 4313 run a server on host R, but rather is the agent side of some 4314 protocol. This decreases the probability of hitting an allocated 4315 port, due to the transient nature of port usage in this range. 4316 However, the possibility of a problem does exist, and network 4317 deployers need to be prepared for it. Note that this is not a 4318 problem specific to ICE; stray packets can arrive at a port at any 4319 time for any type of protocol, especially ones on the public 4320 Internet. As such, this requirement is just restating a general 4321 design guideline for Internet applications -- be prepared for unknown 4322 packets on any port. 4324 B.5. The Candidate Pair Priority Formula 4326 The priority for a candidate pair has an odd form. It is: 4328 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 4330 Why is this? When the candidate pairs are sorted based on this 4331 value, the resulting sorting has the MAX/MIN property. This means 4332 that the pairs are first sorted based on decreasing value of the 4333 minimum of the two priorities. For pairs that have the same value of 4334 the minimum priority, the maximum priority is used to sort amongst 4335 them. If the max and the min priorities are the same, the 4336 controlling agent's priority is used as the tie-breaker in the last 4337 part of the expression. The factor of 2*32 is used since the 4338 priority of a single candidate is always less than 2*32, resulting in 4339 the pair priority being a "concatenation" of the two component 4340 priorities. This creates the MAX/MIN sorting. MAX/MIN ensures that, 4341 for a particular ICE agent, a lower-priority candidate is never used 4342 until all higher-priority candidates have been tried. 4344 B.6. Why Are Keepalives Needed? 4346 Once data begins flowing on a candidate pair, it is still necessary 4347 to keep the bindings alive at intermediate NATs for the duration of 4348 the session. Normally, the data stream packets themselves (e.g., 4349 RTP) meet this objective. However, several cases merit further 4350 discussion. Firstly, in some RTP usages, such as SIP, the data 4351 streams can be "put on hold". This is accomplished by using the SDP 4352 "sendonly" or "inactive" attributes, as defined in RFC 3264 4353 [RFC3264]. RFC 3264 directs implementations to cease transmission of 4354 data in these cases. However, doing so may cause NAT bindings to 4355 timeout, and data won't be able to come off hold. 4357 Secondly, some RTP payload formats, such as the payload format for 4358 text conversation [RFC4103], may send packets so infrequently that 4359 the interval exceeds the NAT binding timeouts. 4361 Thirdly, if silence suppression is in use, long periods of silence 4362 may cause data transmission to cease sufficiently long for NAT 4363 bindings to time out. 4365 For these reasons, the data packets themselves cannot be relied upon. 4366 ICE defines a simple periodic keepalive utilizing STUN Binding 4367 indications. This makes its bandwidth requirements highly 4368 predictable, and thus amenable to QoS reservations. 4370 B.7. Why Prefer Peer Reflexive Candidates? 4372 Section 5.1.2 describes procedures for computing the priority of 4373 candidate based on its type and local preferences. That section 4374 requires that the type preference for peer reflexive candidates 4375 always be higher than server reflexive. Why is that? The reason has 4376 to do with the security considerations in Section 19. It is much 4377 easier for an attacker to cause an ICE agent to use a false server 4378 reflexive candidate than it is for an attacker to cause an agent to 4379 use a false peer reflexive candidate. Consequently, attacks against 4380 address gathering with Binding requests are thwarted by ICE by 4381 preferring the peer reflexive candidates. 4383 B.8. Why Are Binding Indications Used for Keepalives? 4385 Data keepalives are described in Section 11. These keepalives make 4386 use of STUN when both endpoints are ICE capable. However, rather 4387 than using a Binding request transaction (which generates a 4388 response), the keepalives use an Indication. Why is that? 4390 The primary reason has to do with network QoS mechanisms. Once data 4391 begins flowing, network elements will assume that the data stream has 4392 a fairly regular structure, making use of periodic packets at fixed 4393 intervals, with the possibility of jitter. If an ICE agent is 4394 sending data packets, and then receives a Binding request, it would 4395 need to generate a response packet along with its data packets. This 4396 will increase the actual bandwidth requirements for the 5-tuple 4397 carrying the data packets, and introduce jitter in the delivery of 4398 those packets. Analysis has shown that this is a concern in certain 4399 layer 2 access networks that use fairly tight packet schedulers for 4400 data. 4402 Additionally, using a Binding Indication allows integrity to be 4403 disabled, allowing for better performance. This is useful for large- 4404 scale endpoints, such as Public Switched Telephone Network (PSTN) 4405 gateways and Session Border Controllers (SBCs). 4407 B.9. Selecting Candidate Type Preference 4409 One criterion for selection of the type and local preference values 4410 is the use of a data intermediary, such as a TURN server, a tunnel 4411 service such as VPN server, or NAT. With a data intermediary, if 4412 data is sent to that candidate, it will first transit the data 4413 intermediary before being received. Relayed candidates are one type 4414 of candidate that involves a data intermediary. Another are host 4415 candidates obtained from a VPN interface. When data is transited 4416 through a data intermediary, it can have a positive or negative 4417 effect on the latency between transmission and reception. It may or 4418 may not increase the packet losses, because of the additional router 4419 hops that may be taken. It may increase the cost of providing 4420 service, since data will be routed in and right back out of a data 4421 intermediary run by a provider. If these concerns are important, the 4422 type preference for relayed candidates needs to be carefully chosen. 4424 Another criterion for selection of preferences is IP address family. 4425 ICE works with both IPv4 and IPv6. It provides a transition 4426 mechanism that allows dual-stack hosts to prefer connectivity over 4427 IPv6, but to fall back to IPv4 in case the v6 networks are 4428 disconnected. Implementation SHOULD follow the guidelines from 4429 [I-D.ietf-ice-dualstack-fairness] to avoid excessive delays in the 4430 connectivity check phase if broken paths exist. 4432 Another criterion for selecting preferences is topological awareness. 4433 This is most useful for candidates that make use of intermediaries. 4434 In those cases, if an ICE agent has preconfigured or dynamically 4435 discovered knowledge of the topological proximity of the 4436 intermediaries to itself, it can use that to assign higher local 4437 preferences to candidates obtained from closer intermediaries. 4439 Another criterion for selecting preferences might be security or 4440 privacy. If a user is a telecommuter, and therefore connected to a 4441 corporate network and a local home network, the user may prefer their 4442 voice traffic to be routed over the VPN or similar tunnel in order to 4443 keep it on the corporate network when communicating within the 4444 enterprise, but use the local network when communicating with users 4445 outside of the enterprise. In such a case, a VPN address would have 4446 a higher local preference than any other address. 4448 Appendix C. Connectivity Check Bandwidth 4450 The tables below show, for IPv4 and IPv6, the bandwidth required for 4451 performing connectivity checks, using different Ta values (given in 4452 ms) and different ufrag sizes (given in bytes). 4454 The results were provided by Jusin Uberti (Google) 11th April 2016. 4456 IP version: IPv4 4457 Packet len (bytes): 108 + ufrag 4458 | 4459 ms | 4 8 12 16 4460 -----|------------------------ 4461 500 | 1.86k 1.98k 2.11k 2.24k 4462 200 | 4.64k 4.96k 5.28k 5.6k 4463 100 | 9.28k 9.92k 10.6k 11.2k 4464 50 | 18.6k 19.8k 21.1k 22.4k 4465 20 | 46.4k 49.6k 52.8k 56.0k 4466 10 | 92.8k 99.2k 105k 112k 4467 5 | 185k 198k 211k 224k 4468 2 | 464k 496k 528k 560k 4469 1 | 928k 992k 1.06M 1.12M 4471 IP version: IPv6 4472 Packet len (bytes): 128 + ufrag 4473 | 4474 ms | 4 8 12 16 4475 -----|------------------------ 4476 500 | 2.18k 2.3k 2.43k 2.56k 4477 200 | 5.44k 5.76k 6.08k 6.4k 4478 100 | 10.9k 11.5k 12.2k 12.8k 4479 50 | 21.8k 23.0k 24.3k 25.6k 4480 20 | 54.4k 57.6k 60.8k 64.0k 4481 10 | 108k 115k 121k 128k 4482 5 | 217k 230k 243k 256k 4483 2 | 544k 576k 608k 640k 4484 1 | 1.09M 1.15M 1.22M 1.28M 4486 Figure 12: Connectivity Check Bandwidth 4488 Authors' Addresses 4490 Ari Keranen 4491 Ericsson 4492 Hirsalantie 11 4493 02420 Jorvas 4494 Finland 4496 Email: ari.keranen@ericsson.com 4497 Christer Holmberg 4498 Ericsson 4499 Hirsalantie 11 4500 02420 Jorvas 4501 Finland 4503 Email: christer.holmberg@ericsson.com 4505 Jonathan Rosenberg 4506 jdrosen.net 4507 Monmouth, NJ 4508 US 4510 Email: jdrosen@jdrosen.net 4511 URI: http://www.jdrosen.net