idnits 2.17.1 draft-ietf-ice-rfc5245bis-20.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 2713 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 8, 2018) is 2241 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 9, 2018 jdrosen.net 7 March 8, 2018 9 Interactive Connectivity Establishment (ICE): A Protocol for Network 10 Address Translator (NAT) Traversal 11 draft-ietf-ice-rfc5245bis-20 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 9, 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 Check List and ICE 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 . . . . . . . . . . . . . . . . . . . . . . . . 52 148 10. ICE Option . . . . . . . . . . . . . . . . . . . . . . . . . 53 149 11. Keepalives . . . . . . . . . . . . . . . . . . . . . . . . . 53 150 12. Data Handling . . . . . . . . . . . . . . . . . . . . . . . . 54 151 12.1. Sending Data . . . . . . . . . . . . . . . . . . . . . . 54 152 12.1.1. Procedures for Lite Implementations . . . . . . . . 55 153 12.2. Receiving Data . . . . . . . . . . . . . . . . . . . . . 55 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 . . . . . . . . . . . . . . . . . . . . . . . . . . 58 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 2216 (Section 7.2.5.3.4). The procdures for the controlled agent are 2217 described in Section 7.3.1.5. 2219 Eventually, if the nominations succeed, both the controlling and 2220 controlled agents will have a single nominated pair in the valid list 2221 for each component of the data stream. Once an ICE agent sets the 2222 state of the check list to Completed (when there is a nominated pair 2223 for each component of the data stream), that pair becomes the 2224 selected pair for that agent, and is used for sending and receiving 2225 data for that component of the data stream. 2227 If an agent is not able to produce selected pairs for each component 2228 of a data stream, the agent MUST take proper actions for informing 2229 the other agent, and e.g., removing the stream. The exact actions 2230 are outside the scope of this specification. 2232 The criteria for stopping the connectivity checks and for picking a 2233 pair for nomination, are outside the scope of this specification. 2234 They are a matter of local optimization. The only requirement is 2235 that the agent MUST eventually pick one and only one candidate pair 2236 and generate a check for that pair with the USE-CANDIDATE attribute 2237 set. 2239 Once the controlling agent has successfully nominated a candidate 2240 pair (Section 7.2.5.3.4), the agent MUST NOT nominate another pair 2241 for same same component of the data stream within the ICE session. 2242 Doing so requires an ICE restart. 2244 A controlling agent that does not support this specification (i.e., 2245 it is implemented according to RFC 5245) might nominate more than one 2246 candidate pair. This was referred to as "aggressive nomination" in 2247 RFC 5245. If more than one candidate pair is nominated by the 2248 controlling agent, and if the controlled agent accepts multiple 2249 nominations requests, the agents MUST produce the selected pairs 2250 using the pairs with the highest priority. 2252 The usage of the 'ice2' ice option (Section 10) by endpoints 2253 supporting this specification is supposed to prevent controlling 2254 agents implemented according to RFC 5245 from using aggressive 2255 nomination. 2257 NOTE: In RFC 5245, usage of "aggressive nomination" allowed agents to 2258 continuously nominate pairs, before a pair was eventually selected, 2259 in order to allow sending of data on those pairs. In this 2260 specification, data can always be sent on any valid pair, without 2261 nomination. Hence, there is no longer a need for aggressive 2262 nomination. 2264 8.1.2. Updating Check List and ICE States 2266 For both a controlling and a controlled agent, when a candidate pair 2267 for a component of a data stream gets nominated, it might impact 2268 other pairs in the check list associated with the data stream. It 2269 might also impact the state of the check list: 2271 o Once a candidate pair for a component of a data stream has been 2272 nominated, and the state of the check list associated with the 2273 data stream is Running, the ICE agent MUST remove all candidate 2274 pairs for the same component from the check list and from the 2275 triggered check queue. If the state of a pair is In-Progress 2276 pair, the agent cancels the In-Progress transaction. Cancellation 2277 means that the agent will not retransmit the Binding requests 2278 associated with the connectivity check transaction, will not treat 2279 the lack of response to be a failure, but will wait the duration 2280 of the transaction timeout for a response. 2282 o Once candidate pairs for each component of a data stream have been 2283 nominated, and the state of the check list associated with the 2284 data stream is Running, the ICE agent sets the state of the check 2285 list to Completed. 2287 o Once a candidate pair for a component of a data stream has been 2288 nominated, an agent MUST continue to respond to any Binding 2289 request it might still receive for the nominated pair, and for any 2290 remaining candidate pairs in the check list associated with the 2291 data stream. As defined in Section 7.3.1.4, as the state a pair 2292 is Succeeded, an agent will no longer generate triggered checks 2293 when receiving a Binding request for the pair. 2295 Once the state of each check list in the check list set is Completed, 2296 the agent sets the state of the ICE session to Completed. 2298 If the state of a check list is Failed, ICE has not been able to 2299 complete for the data stream associated with the check list. The 2300 correct behavior depends on the state of the check lists in the check 2301 list set. If the controlling agent wants to continue the session 2302 without the data stream associated with the Failed check list, and if 2303 there are still one or more check lists in Running or Completed mode, 2304 the agent can let the ICE processing continue. The agent MUST take 2305 proper actions for removing the failed data stream. If the 2306 controlling agent does not want to continue the session and MUST 2307 terminate the session. The state of the ICE session is set to 2308 Failed. 2310 If the state of each check list in the check list set is Failed, the 2311 state of the ICE session is set to Failed. Unless the controlling 2312 agent wants to continue the session without the data streams, it MUST 2313 terminate the session. 2315 8.2. Procedures for Lite Implementations 2317 When ICE concludes, a lite ICE agent can free host candidates that 2318 were not used by ICE, as described in Section 8.3. 2320 If the peer is a full agent, once the lite agent accepts a nomination 2321 request for a candidate pair, the lite agent considers the pair 2322 nominated. Once there are nominated pairs for each component of a 2323 data stream, the pairs become the selected pairs for the components 2324 of the data stream. Once the lite agent has produced selected pairs 2325 for all components of all data streams, the ICE session state is set 2326 to Completed. 2328 If the peer is a lite agent, the agent pairs local candidates with 2329 remote candidates that are for the same data stream and have the same 2330 component, transport protocol, and IP address family. For each 2331 component of each data stream, if there is only one candidate pair, 2332 that pair is added to the valid list. If there is more than one 2333 pair, it is RECOMMENDED that an agent follow the procedures of RFC 2334 6724 [RFC6724] to select a pair and add it to the valid list. 2336 If all of the components for all data streams had one pair, the state 2337 of ICE processing is Completed. Otherwise, the controlling agent 2338 MUST send an updated candidate list to reconcile different agents 2339 selecting different candidate pairs. ICE processing is complete 2340 after and only after the updated candidate exchange is complete. 2342 8.3. Freeing Candidates 2344 8.3.1. Full Implementation Procedures 2346 The rules in this section describe when it is safe for an agent to 2347 cease sending or receiving checks on a candidate that did not become 2348 a selected candidate (is not associated with a selected pair), and 2349 then free the candidate. 2351 Once a check list has reached the Completed state, the agent SHOULD 2352 wait an additional three seconds, and then it can cease responding to 2353 checks or generating triggered checks on all local candidates other 2354 than the ones that became selected candidates. Once all ICE sessions 2355 have ceased using a given local candidate (a candidate may be used by 2356 multiple ICE sessions, e.g., in forking scenarios), the agent can 2357 free that candidate. The three-second delay handles cases when 2358 aggressive nomination is used, and the selected pairs can quickly 2359 change after ICE has completed. 2361 Freeing of server reflexive candidates is never explicit; it happens 2362 by lack of a keepalive. 2364 8.3.2. Lite Implementation Procedures 2366 A lite implementation can free candidates that did not become 2367 selected candidates as soon as ICE processing has reached the 2368 Completed state for all ICE sessions using those candidates. 2370 9. ICE Restarts 2372 An ICE agent MAY restart ICE for existing data streams. An ICE 2373 restart causes all previous state of the data streams, excluding the 2374 roles of the agents, to be flushed. The only difference between an 2375 ICE restart and a brand new data session is that during the restart, 2376 data can continue to be sent using existing data sessions, and that a 2377 new data session always requires the roles to be determined. 2379 The following actions can be accomplished only using an ICE restart 2380 (the agent MUST use ICE restarts to do so): 2382 o Change the destinations of data streams. 2384 o Change from a lite implementation to a full implementation. 2386 o Change from a full implementation to a lite implementation. 2388 To restart ICE, an agent MUST change both the password and the 2389 username fragment for the data stream(s) being restarted. 2391 When the ICE is restarted, the candidate set for the new ICE session 2392 might include some, none, or all of the candidates used in the 2393 current ICE session. 2395 As described in Section 6.1.1, agents MUST NOT re-determine the roles 2396 as part as an ICE restart, unless certain criteria that require the 2397 roles to be re-determined are fulfilled. 2399 10. ICE Option 2401 This section defines a new ICE option, 'ice2'. The ICE option 2402 indicates that the ICE agent that includes it in a candidate exchange 2403 is compliant to this specification. For example, the agent will not 2404 use the aggressive nomination procedure defined in RFC 5245. In 2405 addition, it will ensure that an RFC 5245-compliant peer does not use 2406 aggressive nomination either, as required by Section 14 of RFC 5245 2407 for peers which receive unknown ICE options. 2409 An agent compliant to this specification MUST inform the peer about 2410 the compliance using the 'ice2' option. 2412 NOTE: The encoding of the 'ice2' ICE option, and the message(s) used 2413 to carry it to the peer, are protocol specific. The encoding for the 2414 Session Description Protocol (SDP) [RFC4566] is defined in 2415 [I-D.ietf-mmusic-ice-sip-sdp]. 2417 11. Keepalives 2419 All endpoints MUST send keepalives for each data session. These 2420 keepalives serve the purpose of keeping NAT bindings alive for the 2421 data session. The keepalives SHOULD be sent using a format that is 2422 supported by its peer. ICE endpoints allow for STUN-based keepalives 2423 for UDP streams, and as such, STUN keepalives MUST be used when an 2424 ICE agent is a full ICE implementation and is communicating with a 2425 peer that supports ICE (lite or full). 2427 For each candidate pair that an agent is using to send data, if no 2428 packet has been sent on that pair in the last Tr seconds, an agent 2429 MUST send a keepalive on that pair. Agents SHOULD use a Tr value of 2430 15 seconds. Agents MAY use a bigger value, but MUST NOT use a value 2431 smaller than 15 seconds. 2433 Once selected pairs have been produced for a data stream, keepalives 2434 are only sent on those pairs. 2436 An agent MUST stop sending keepalives on a data stream if the data 2437 stream is removed. If the ICE session is terminated, an agent MUST 2438 stop sending keepalives on all data streams. 2440 An agent MAY use another value for Tr, e.g. based on configuration or 2441 network/NAT characteristics. For example, if an agent has a dynamic 2442 way to discover the binding lifetimes of the intervening NATs, it can 2443 use that value to determine Tr. Administrators deploying ICE in more 2444 controlled networking environments SHOULD set Tr to the longest 2445 duration possible in their environment. 2447 When STUN is being used for keepalives, a STUN Binding Indication is 2448 used [RFC5389]. The Indication MUST NOT utilize any authentication 2449 mechanism. It SHOULD contain the FINGERPRINT attribute to aid in 2450 demultiplexing, but SHOULD NOT contain any other attributes. It is 2451 used solely to keep the NAT bindings alive. The Binding Indication 2452 is sent using the same local and remote candidates that are being 2453 used for data. Though Binding Indications are used for keepalives, 2454 an agent MUST be prepared to receive a connectivity check as well. 2455 If a connectivity check is received, a response is generated as 2456 discussed in [RFC5389], but there is no impact on ICE processing 2457 otherwise. 2459 Agents MUST by default use STUN keepalives. Individual ICE usages 2460 and ICE extensions MAY specify usage/extension-specific keepalives. 2462 12. Data Handling 2464 12.1. Sending Data 2466 An ICE agent MAY send data on any valid pair before selected pairs 2467 have been produced for the data stream. 2469 Once selected pairs have been produced for a data stream, an agent 2470 MUST send data on those pairs only. 2472 An agent sends data from the base of the local candidate to the 2473 remote candidate. In the case of a local relayed candidate, data is 2474 forwarded through the base (located in the TURN server), using the 2475 procedures defined in [RFC5766]. 2477 If the local candidate is a relayed candidate, it is RECOMMENDED that 2478 an agent creates a channel on the TURN server towards the remote 2479 candidate. This is done using the procedures for channel creation as 2480 defined in Section 11 of [RFC5766]. 2482 The selected pair for a component of a data stream is: 2484 o empty if the state of the check list for that data stream is 2485 Running, and there is no previous selected pair for that component 2486 due to an ICE restart 2488 o equal to the previous selected pair for a component of a data 2489 stream if the state of the check list for that data stream is 2490 Running, and there was a previous selected pair for that component 2491 due to an ICE restart 2493 Unless an agent is able to produce a selected pair for each component 2494 associated with a data stream, the agent MUST NOT continue sending 2495 data for any component associated with that data stream. 2497 12.1.1. Procedures for Lite Implementations 2499 A lite implementation MUST NOT send data until it has a valid list 2500 that contains a candidate pair for each component of that data 2501 stream. Once that happens, the ICE agent MAY begin sending data 2502 packets. To do that, it sends data to the remote candidate in the 2503 pair (setting the destination address and port of the packet equal to 2504 that remote candidate), and will send it from the base associated 2505 with the candidate pair used for sending data. In case of a relayed 2506 candidate, data is sent from the agent and forwarded through the base 2507 (located in the TURN server), using the procedures defined in 2508 [RFC5766]. 2510 12.2. Receiving Data 2512 Even though ICE agents are only allowed to send data using valid 2513 candidate pairs (and, once selected pairs have been produced, only on 2514 the selected pairs) ICE implementations SHOULD by default be prepared 2515 to receive data on any of the candidates provided in the most recent 2516 candidate exchange with the peer. ICE usages MAY define rules that 2517 differ from this, e.g., by defining that data will not be sent until 2518 selected pairs have been produced for a data stream. 2520 It is RECOMMENDED that, when an agent receives an RTP packet with a 2521 new source or destination IP address for a particular RTP/RTCP data 2522 stream, that the agent re-adjust its jitter buffers. 2524 RFC 3550 [RFC3550] describes an algorithm in Section 8.2 for 2525 detecting synchronization source (SSRC) collisions and loops. These 2526 algorithms are based, in part, on seeing different source transport 2527 addresses with the same SSRC. However, when ICE is used, such 2528 changes will sometimes occur as the data streams switch between 2529 candidates. An agent will be able to determine that a data stream is 2530 from the same peer as a consequence of the STUN exchange that 2531 proceeds media data transmission. Thus, if there is a change in 2532 source transport address, but the media data packets come from the 2533 same peer agent, this MUST NOT be treated as an SSRC collision. 2535 13. Extensibility Considerations 2537 This specification makes very specific choices about how both ICE 2538 agents in a session coordinate to arrive at the set of candidate 2539 pairs that are selected for data. It is anticipated that future 2540 specifications will want to alter these algorithms, whether they are 2541 simple changes like timer tweaks or larger changes like a revamp of 2542 the priority algorithm. When such a change is made, providing 2543 interoperability between the two agents in a session is critical. 2545 First, ICE provides the ICE option concept. Each extension or change 2546 to ICE is associated with an ICE option. When an agent supports such 2547 an extension or change, it provides the ICE option to the peer agent 2548 as part of the candidate exchange. 2550 One of the complications in achieving interoperability is that ICE 2551 relies on a distributed algorithm running on both agents to converge 2552 on an agreed set of candidate pairs. If the two agents run different 2553 algorithms, it can be difficult to guarantee convergence on the same 2554 candidate pairs. The nomination procedure described in Section 8 2555 eliminates some of the need for tight coordination by delegating the 2556 selection algorithm completely to the controlling agent, and ICE will 2557 converge perfectly even when both agents use different pair 2558 prioritization algorithms. One of the keys to such convergence is 2559 triggered checks, which ensure that the nominated pair is validated 2560 by both agents. 2562 ICE is also extensible to other data streams beyond RTP, and for 2563 transport protocols beyond UDP. Extensions to ICE for non-RTP data 2564 streams need to specify how many components they utilize, and assign 2565 component IDs to them, starting at 1 for the most important component 2566 ID. Specifications for new transport protocols MUST define how, if 2567 at all, various steps in the ICE processing differ from UDP. 2569 14. Setting Ta and RTO 2571 14.1. General 2573 During the ICE gathering phase (Section 5.1.1) and while ICE is 2574 performing connectivity checks (Section 7), an ICE agent triggers 2575 STUN and TURN transactions. These transactions are paced at a rate 2576 indicated by Ta, and the retransmission interval for each transaction 2577 is calculated based on the the retransmission timer for the STUN 2578 transactions (RTO) [RFC5389]. 2580 This section describes how the Ta and RTO values are computed during 2581 the ICE gathering phase and while ICE is performing connectivity 2582 checks. 2584 NOTE: Previously, in RFC 5245, different formulas were defined for 2585 computing Ta and RTO, depending on whether ICE was used for a real- 2586 time data stream (e.g., RTP) or not. 2588 The formulas below result in a behavior whereby an agent will send 2589 its first packet for every single connectivity check before 2590 performing a retransmit. This can be seen in the formulas for the 2591 RTO (which represents the retransmit interval). Those formulas scale 2592 with N, the number of checks to be performed. As a result of this, 2593 ICE maintains a nicely constant rate, but becomes more sensitive to 2594 packet loss. The loss of the first single packet for any 2595 connectivity check is likely to cause that pair to take a long time 2596 to be validated, and instead, a lower-priority check (but one for 2597 which there was no packet loss) is much more likely to complete 2598 first. This results in ICE performing sub-optimally, choosing lower- 2599 priority pairs over higher-priority pairs. 2601 14.2. Ta 2603 ICE agents SHOULD use a default Ta value, 50 ms, but MAY use another 2604 value based on the characteristics of the associated data. 2606 If an agent wants to use another Ta value than the default value, the 2607 agent MUST indicate the proposed value to its peer during the 2608 establishment of the ICE session. Both agents MUST use the higher 2609 value of the proposed values. If an agent does not propose a value, 2610 the default value is used for that agent when comparing which value 2611 is higher. 2613 Regardless of the Ta value chosen for each agent, the combination of 2614 all transactions from all agents (if a given implementation runs 2615 several concurrent agents) MUST NOT be sent more often than once 2616 every 5ms (as though there were one global Ta value for pacing all 2617 agents). See Appendix B.1 for the background of using a value of 5ms 2618 with ICE. 2620 NOTE: Appendix C shows examples of required bandwidth, using 2621 different Ta values. 2623 14.3. RTO 2625 During the ICE gathering phase, ICE agents SHOULD calculate the RTO 2626 value using the following formula: 2628 RTO = MAX (500ms, Ta * (Num-Of-Cands)) 2630 Num-Of-Cands: the number of server-reflexive and relay candidates 2632 For connectivity checks, agents SHOULD calculate the RTO value using 2633 the following formula: 2635 RTO = MAX (500ms, Ta * N * (Num-Waiting + Num-In-Progress)) 2637 N: the total number of connectivity checks to be performed. 2639 Num-Waiting: the number of checks in the check list set in the 2640 Waiting state. 2642 Num-In-Progress: the number of checks in the check list set in the 2643 In-Progress state. 2645 Note that the RTO will be different for each transaction as the 2646 number of checks in the Waiting and In-Progress states change. 2648 Agents MAY calculate the RTO value using other mechanisms than those 2649 described above. Agents MUST NOT use a RTO value smaller than 500 2650 ms. 2652 15. Examples 2654 This section shows two ICE examples: one using IPv4 addresses, and 2655 one using IPv6 addresses. 2657 To facilitate understanding, transport addresses are listed using 2658 variables that have mnemonic names. The format of the name is 2659 entity-type-seqno, where entity refers to the entity whose IP address 2660 the transport address is on, and is one of "L", "R", "STUN", or 2661 "NAT". The type is either "PUB" for transport addresses that are 2662 public, and "PRIV" for transport addresses that are private 2663 [RFC1918]. Finally, seq-no is a sequence number that is different 2664 for each transport address of the same type on a particular entity. 2665 Each variable has an IP address and port, denoted by varname.IP and 2666 varname.PORT, respectively, where varname is the name of the 2667 variable. 2669 In the call flow itself, STUN messages are annotated with several 2670 attributes. The "S=" attribute indicates the source transport 2671 address of the message. The "D=" attribute indicates the destination 2672 transport address of the message. The "MA=" attribute is used in 2673 STUN Binding response messages and refers to the mapped address. 2674 "USE-CAND" implies the presence of the USE-CANDIDATE attribute. 2676 The call flow examples omit STUN authentication operations, and focus 2677 on a single data stream between two full implementations. 2679 15.1. Example with IPv4 Addresses 2681 The example is using the topology shown in Figure 7. 2683 +-------+ 2684 |STUN | 2685 |Server | 2686 +-------+ 2687 | 2688 +---------------------+ 2689 | | 2690 | Internet | 2691 | | 2692 +---------------------+ 2693 | | 2694 | | 2695 +---------+ | 2696 | NAT | | 2697 +---------+ | 2698 | | 2699 | | 2700 +-----+ +-----+ 2701 | L | | R | 2702 +-----+ +-----+ 2704 Figure 7: Example Topology 2706 In the example, ICE agents L and R are full ICE implementations. 2707 Both agents have a single IPv4 address. Both are configured with the 2708 same STUN server. The NAT has an endpoint independent mapping 2709 property and an address dependent filtering property. The IP 2710 addresses of the ICE agents, the STUN server and the NAT are shown 2711 below; 2713 ENTITY IP Address mnemonic name 2714 -------------------------------------------------- 2715 ICE Agent L: 10.0.1.1 L-PRIV-1 2716 ICE Agent R: 192.0.2.1 R-PUB-1 2717 STUN Server: 192.0.2.2 STUN-PUB-1 2718 NAT (Public): 192.0.2.3 NAT-PUB-1 2720 L NAT STUN R 2721 |STUN alloc. | | | 2722 |(1) STUN Req | | | 2723 |S=$L-PRIV-1 | | | 2724 |D=$STUN-PUB-1 | | | 2725 |------------->| | | 2726 | |(2) STUN Req | | 2727 | |S=$NAT-PUB-1 | | 2728 | |D=$STUN-PUB-1 | | 2729 | |------------->| | 2730 | |(3) STUN Res | | 2731 | |S=$STUN-PUB-1 | | 2732 | |D=$NAT-PUB-1 | | 2733 | |MA=$NAT-PUB-1 | | 2734 | |<-------------| | 2735 |(4) STUN Res | | | 2736 |S=$STUN-PUB-1 | | | 2737 |D=$L-PRIV-1 | | | 2738 |MA=$NAT-PUB-1 | | | 2739 |<-------------| | | 2740 |(5) L's Candidate Information| | 2741 |------------------------------------------->| 2742 | | | | STUN 2743 | | | | alloc. 2744 | | |(6) STUN Req | 2745 | | |S=$R-PUB-1 | 2746 | | |D=$STUN-PUB-1 | 2747 | | |<-------------| 2748 | | |(7) STUN Res | 2749 | | |S=$STUN-PUB-1 | 2750 | | |D=$R-PUB-1 | 2751 | | |MA=$R-PUB-1 | 2752 | | |------------->| 2753 |(8) R's Candidate Information| | 2754 |<-------------------------------------------| 2755 | | (9) Bind Req |Begin 2756 | | S=$R-PUB-1 |Connectivity 2757 | | D=$L-PRIV-1 |Checks 2758 | | <-------------------| 2759 | | Dropped | 2760 |(10) Bind Req | | | 2761 |S=$L-PRIV-1 | | | 2762 |D=$R-PUB-1 | | | 2763 |------------->| | | 2764 | |(11) Bind Req | | 2765 | |S=$NAT-PUB-1 | | 2766 | |D=$R-PUB-1 | | 2767 | |---------------------------->| 2768 | |(12) Bind Res | | 2769 | |S=$R-PUB-1 | | 2770 | |D=$NAT-PUB-1 | | 2771 | |MA=$NAT-PUB-1 | | 2772 | |<----------------------------| 2773 |(13) Bind Res | | | 2774 |S=$R-PUB-1 | | | 2775 |D=$L-PRIV-1 | | | 2776 |MA=$NAT-PUB-1 | | | 2777 |<-------------| | | 2778 |Data | | | 2779 |===========================================>| 2780 | | | | 2781 | |(14) Bind Req | | 2782 | |S=$R-PUB-1 | | 2783 | |D=$NAT-PUB-1 | | 2784 | |<----------------------------| 2785 |(15) Bind Req | | | 2786 |S=$R-PUB-1 | | | 2787 |D=$L-PRIV-1 | | | 2788 |<-------------| | | 2789 |(16) Bind Res | | | 2790 |S=$L-PRIV-1 | | | 2791 |D=$R-PUB-1 | | | 2792 |MA=$R-PUB-1 | | | 2793 |------------->| | | 2794 | |(17) Bind Res | | 2795 | |S=$NAT-PUB-1 | | 2796 | |D=$R-PUB-1 | | 2797 | |MA=$R-PUB-1 | | 2798 | |---------------------------->| 2799 |Data | | | 2800 |<===========================================| 2801 | | | | 2802 ....... 2803 | | | | 2804 |(18) Bind Req | | | 2805 |S=$L-PRIV-1 | | | 2806 |D=$R-PUB-1 | | | 2807 |USE-CAND | | | 2808 |------------->| | | 2809 | |(19) Bind Req | | 2810 | |S=$NAT-PUB-1 | | 2811 | |D=$R-PUB-1 | | 2812 | |USE-CAND | | 2813 | |---------------------------->| 2814 | |(20) Bind Res | | 2815 | |S=$R-PUB-1 | | 2816 | |D=$NAT-PUB-1 | | 2817 | |MA=$NAT-PUB-1 | | 2818 | |<----------------------------| 2819 |(21) Bind Res | | | 2820 |S=$R-PUB-1 | | | 2821 |D=$L-PRIV-1 | | | 2822 |MA=$NAT-PUB-1 | | | 2823 |<-------------| | | 2824 | | | | 2826 Figure 8: Example Flow 2828 Messages 1-4: Agent L gathers a host candidate from its local IP 2829 address, and from that sends a STUN Binding request to the STUN 2830 Server. The request creates a NAT binding. The NAT public IP 2831 address of the binding becomes agent L's server reflexive candidate. 2833 Message 5: Agent L sends its local candidate information to agent R, 2834 using the signalling protocol associated with the ICE usage. 2836 Messages 6-7: Agent R gathers a host candidate from its local IP 2837 address, and from that sends a STUN Binding request to the STUN 2838 Server. Since agent R is not behind a NAT, R's server reflexive 2839 candidate will be identical to the host candidate. 2841 Message 8: Agent R sends its local candidate information to agent L, 2842 using the signalling protocol associated with the ICE usage. 2844 Since both agents are full ICE implementations, the initiating agent 2845 (agent L) becomes the controlling agent. 2847 Agents L and R both pair up the candidates. Both agents initially 2848 have two pairs. However, agent L will prune the pair containing its 2849 server reflexive candidate, resulting in just one (L1). At agent L, 2850 this pair has a local candidate of $L_PRIV_1 and remote candidate of 2851 $R_PUB_1. At agent R, there are two pairs. The highest priority 2852 pair (R1) has a local candidate of $R_PUB_1 and remote candidate of 2853 $L_PRIV_1, and the second pair (R2) has a local candidate of $R_PUB_1 2854 and remote candidate of $NAT_PUB_1. The pairs are shown below (the 2855 pair numbers are for reference purpose only): 2857 Pairs 2858 ENTITY Local Remote Pair # Valid 2859 ------------------------------------------------------------------ 2860 ICE Agent L: L_PRIV_1 R_PUB_1 L1 2862 ICE Agent R: R_PUB_1 L_PRIV_1 R1 2863 R_PUB_1 NAT_PUB_1 R2 2865 Message 9: Agent R initiates a connectivity check for pair #2. As 2866 the remote candidate of the pair is the private address of agent L, 2867 the check will not be successful, as the request cannot be routed 2868 from R to L, and will be dropped by the network. 2870 Messages 10-13: Agent L initiates a connectivity check for pair L1. 2871 The check succeeds, and L creates a new pair (L2). The local 2872 candidate of the new pair is $NAT_PUB_1 and the remote candidate is 2873 $R_PUB_1. The pair (L2) is added to the valid list of agent L. 2874 Agent L can now send and receive data on the pair (L2) if it wishes. 2876 Pairs 2877 ENTITY Local Remote Pair # Valid 2878 ------------------------------------------------------------------ 2879 ICE Agent L: L_PRIV_1 R_PUB_1 L1 2880 NAT_PUB_1 R_PUB_1 L2 X 2882 ICE Agent R: R_PUB_1 L_PRIV_1 R1 2883 R_PUB_1 NAT_PUB_1 R2 2885 Messages 14-17: When agent R receives the Binding request from agent 2886 L (message 11) it will initiate a triggered connectivity check. The 2887 pair matches one of agent R's existing pairs (R2). The check 2888 succeeds, and the pair (R2) is added to the valid list of agent R. 2889 Agent R can now send and receive data on the pair (R2) if it wishes. 2891 Pairs 2892 ENTITY Local Remote Pair # Valid 2893 ------------------------------------------------------------------ 2894 ICE Agent L: L_PRIV_1 R_PUB_1 L1 2895 NAT_PUB_1 R_PUB_1 L2 X 2897 ICE Agent R: R_PUB_1 L_PRIV_1 R1 2898 R_PUB_1 NAT_PUB_1 R2 X 2900 Messages 18-21: At some point, the controlling agent (agent L) 2901 decides to nominate a pair (L2) in the valid list. It performs a 2902 connectivity check on the pair (L2), and includes the USE-CANDIDATE 2903 attribute in the Binding request. As the check succeeds, agent L 2904 sets the nominated flag value of the pair (L2) to 'true'. Agent R 2905 sets the nominated flag value of the matching pair (R2) to 'true'. 2906 As there are no more components associated with the stream, the 2907 nominated pairs become the selected pairs. Consequently, processing 2908 for this stream moves into the Completed state. The ICE process also 2909 moves into the Completed state. 2911 15.2. Example with IPv6 Addresses 2913 The example is using the topology shown in Figure 9. 2915 +-------+ 2916 |STUN | 2917 |Server | 2918 +-------+ 2919 | 2920 +---------------------+ 2921 | | 2922 | Internet | 2923 | | 2924 +---------------------+ 2925 | | 2926 | | 2927 | | 2928 | | 2929 | | 2930 | | 2931 | | 2932 +-----+ +-----+ 2933 | L | | R | 2934 +-----+ +-----+ 2936 Figure 9: Example Topology 2938 In the example, ICE agents L and R are full ICE implementations. 2939 Both agents have a single IPv6 address. Both are configured with the 2940 same STUN server. The IP addresses of the ICE agents and the STUN 2941 server are shown below; 2943 ENTITY IP Address mnemonic name 2944 -------------------------------------------------- 2945 ICE Agent L: 2001:db8::3 L-PUB-1 2946 ICE Agent R: 2001:db8::5 R-PUB-1 2947 STUN Server: 2001:db8::9 STUN-PUB-1 2949 L STUN R 2950 |STUN alloc. | | 2951 |(1) STUN Req | | 2952 |S=$L-PUB-1 | | 2953 |D=$STUN-PUB-1 | | 2954 |---------------------------->| | 2955 |(2) STUN Res | | 2956 | S=$STUN-PUB-1 | | 2957 | D=$L-PUB-1 | | 2958 | MA=$L-PUB-1 | | 2959 |<----------------------------| | 2960 |(3) L's Candidate Information| | 2961 |------------------------------------------->| 2962 | | | STUN 2963 | | | alloc. 2964 | |(4) STUN Req | 2965 | |S=$R-PUB-1 | 2966 | |D=$STUN-PUB-1 | 2967 | |<-------------| 2968 | |(5) STUN Res | 2969 | |S=$STUN-PUB-1 | 2970 | |D=$R-PUB-1 | 2971 | |MA=$R-PUB-1 | 2972 | |------------->| 2973 |(6) R's Candidate Information| | 2974 |<-------------------------------------------| 2975 |(7) Bind Req | | 2976 |S=$L-PUB-1 | | 2977 |D=$R-PUB-1 | | 2978 |------------------------------------------->| 2979 |(8) Bind Res | | 2980 |S=$R-PUB-1 | | 2981 |D=$L-PUB-1 | | 2982 |MA=$L-PUB-1 | | 2983 |<-------------------------------------------| 2984 |Data | | 2985 |===========================================>| 2986 | | | 2987 |(9) Bind Req | | 2988 |S=$R-PUB-1 | | 2989 |D=$L-PUB-1 | | 2990 |<-------------------------------------------| 2991 |(10) Bind Res | | 2992 |S=$L-PUB-1 | | 2993 |D=$R-PUB-1 | | 2994 |MA=$R-PUB-1 | | 2995 |------------------------------------------->| 2996 |Data | | 2997 |<===========================================| 2998 | | | 2999 ....... 3000 | | | 3001 |(11) Bind Req | | 3002 |S=$L-PUB-1 | | 3003 |D=$R-PUB-1 | | 3004 |USE-CAND | | 3005 |------------------------------------------->| 3006 |(12) Bind Res | | 3007 |S=$R-PUB-1 | | 3008 |D=$L-PUB-1 | | 3009 |MA=$L-PUB-1 | | 3010 |<-------------------------------------------| 3011 | | | | 3013 Figure 10: Example Flow 3015 Messages 1-2: Agent L gathers a host candidate from its local IP 3016 address, and from that sends a STUN Binding request to the STUN 3017 Server. Since agent L is not behind a NAT, L's server reflexive 3018 candidate will be identical to the host candidate. 3020 Message 3: Agent L sends its local candidate information to agent R, 3021 using the signalling protocol associated with the ICE usage. 3023 Messages 4-5: Agent R 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 R is not behind a NAT, R's server reflexive 3026 candidate will be identical to the host candidate. 3028 Message 6: Agent R sends its local candidate information to agent L, 3029 using the signalling protocol associated with the ICE usage. 3031 Since both agents are full ICE implementations, the initiating agent 3032 (agent L) becomes the controlling agent. 3034 Agents L and R both pair up the candidates. Both agents initially 3035 have one pair each. At agent L, the pair (L1) has a local candidate 3036 of $L_PUB_1 and remote candidate of $R_PUB_1. At agent R, the pair 3037 (R1) has a local candidate of $R_PUB_1 and remote candidate of 3038 $L_PUB_1. The pairs are shown below (the pair numbers are for 3039 reference purpose only): 3041 Pairs 3042 ENTITY Local Remote Pair # Valid 3043 ------------------------------------------------------------------ 3044 ICE Agent L: L_PUB_1 R_PUB_1 L1 3046 ICE Agent R: R_PUB_1 L_PUB_1 R1 3048 Messages 7-8: Agent L initiates a connectivity check for pair L1. 3049 The check succeeds, and the pair (L1) is added to the valid list of 3050 agent L. Agent L can now send and receive data on the pair (L1) if 3051 it wishes. 3053 Pairs 3054 ENTITY Local Remote Pair # Valid 3055 ------------------------------------------------------------------ 3056 ICE Agent L: L_PUB_1 R_PUB_1 L1 X 3058 ICE Agent R: R_PUB_1 L_PUB_1 R1 3060 Messages 9-10: When agent R receives the Binding request from agent L 3061 (message 7) it will initiate a triggered connectivity check. The 3062 pair matches agent R's existing pair (R1). The check succeeds, and 3063 the pair (R1) is added to the valid list of agent R. Agent R can now 3064 send and receive data on the pair (R1) if it wishes. 3066 Pairs 3067 ENTITY Local Remote Pair # Valid 3068 ------------------------------------------------------------------ 3069 ICE Agent L: L_PUB_1 R_PUB_1 L1 X 3071 ICE Agent R: R_PUB_1 L_PUB_1 R1 X 3073 Messages 11-12: At some point, the controlling agent (agent L) 3074 decides to nominate a pair (L1) in the valid list. It performs a 3075 connectivity check on the pair (L1), and includes the USE-CANDIDATE 3076 attribute in the Binding request. As the check succeeds, agent L 3077 sets the nominated flag value of the pair (L1) to 'true'. Agent R 3078 sets the nominated flag value of the matching pair (R1) to 'true'. 3079 As there are no more components associated with the stream, the 3080 nominated pairs become the selected pairs. Consequently, processing 3081 for this stream moves into the Completed state. The ICE process also 3082 moves into the Completed state. 3084 16. STUN Extensions 3086 16.1. New Attributes 3088 This specification defines four STUN attributes: PRIORITY, USE- 3089 CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. 3091 The PRIORITY attribute indicates the priority that is to be 3092 associated with a peer reflexive candidate, if one will be discovered 3093 by this check. It is a 32-bit unsigned integer, and has an attribute 3094 value of 0x0024. 3096 The USE-CANDIDATE attribute indicates that the candidate pair 3097 resulting from this check will be used for transmission of data. The 3098 attribute has no content (the Length field of the attribute is zero); 3099 it serves as a flag. It has an attribute value of 0x0025. 3101 The ICE-CONTROLLED attribute is present in a Binding request. The 3102 attribute indicates that the client believes it is currently in the 3103 controlled role. The content of the attribute is a 64-bit unsigned 3104 integer in network byte order, which contains a random number. The 3105 number is used for solving role conflicts, when it is referred to as 3106 the tie-breaker value. An ICE agent MUST use the same number for all 3107 Binding requests, for all streams, within an ICE session, unless it 3108 has received a 487 response, in which case it MUST change the number 3109 (Section 7.2.5.1). The agent MAY change the number when an ICE 3110 restart occurs. 3112 The ICE-CONTROLLING attribute is present in a Binding request. The 3113 attribute indicates that the client believes it is currently in the 3114 controlling role. The content of the attribute is a 64-bit unsigned 3115 integer in network byte order, which contains a random number. As 3116 for the ICE-CONTROLLED attribute, the number is used for solving role 3117 conflicts. An agent MUST use the same number for all Binding 3118 requests, for all streams, within an ICE session, unless it has 3119 received a 487 response, in which case it MUST change the number 3120 (Section 7.2.5.1). The agent MAY change the number when an ICE 3121 restart occurs. 3123 16.2. New Error Response Codes 3125 This specification defines a single error response code: 3127 487 (Role Conflict): The Binding request contained either the ICE- 3128 CONTROLLING or ICE-CONTROLLED attribute, indicating an ICE role 3129 that conflicted with the server. The remote server compared the 3130 tie-breaker values of the client and the server and determined 3131 that the client needs to switch roles. 3133 17. Operational Considerations 3135 This section discusses issues relevant to operators operating 3136 networks where ICE will be used by endpoints. 3138 17.1. NAT and Firewall Types 3140 ICE was designed to work with existing NAT and firewall equipment. 3141 Consequently, it is not necessary to replace or reconfigure existing 3142 firewall and NAT equipment in order to facilitate deployment of ICE. 3143 Indeed, ICE was developed to be deployed in environments where the 3144 Voice over IP (VoIP) operator has no control over the IP network 3145 infrastructure, including firewalls and NATs. 3147 That said, ICE works best in environments where the NAT devices are 3148 "behave" compliant, meeting the recommendations defined in [RFC4787] 3149 and [RFC5382]. In networks with behave-compliant NAT, ICE will work 3150 without the need for a TURN server, thus improving voice quality, 3151 decreasing call setup times, and reducing the bandwidth demands on 3152 the network operator. 3154 17.2. Bandwidth Requirements 3156 Deployment of ICE can have several interactions with available 3157 network capacity that operators need to take into consideration. 3159 17.2.1. STUN and TURN Server Capacity Planning 3161 First and foremost, ICE makes use of TURN and STUN servers, which 3162 would typically be located in data centers. The STUN servers require 3163 relatively little bandwidth. For each component of each data stream, 3164 there will be one or more STUN transactions from each client to the 3165 STUN server. In a basic voice-only IPv4 VoIP deployment, there will 3166 be four transactions per call (one for RTP and one for RTCP, for both 3167 caller and callee). Each transaction is a single request and a 3168 single response, the former being 20 bytes long, and the latter, 28. 3169 Consequently, if a system has N users, and each makes four calls in a 3170 busy hour, this would require N*1.7bps. For one million users, this 3171 is 1.7 Mbps, a very small number (relatively speaking). 3173 TURN traffic is more substantial. The TURN server will see traffic 3174 volume equal to the STUN volume (indeed, if TURN servers are 3175 deployed, there is no need for a separate STUN server), in addition 3176 to the traffic for the actual data. The amount of calls requiring 3177 TURN for data relay is highly dependent on network topologies, and 3178 can and will vary over time. In a network with 100% behave-compliant 3179 NATs, it is exactly zero. 3181 The planning considerations above become more significant in multi- 3182 media scenarios (e.g., audio and video conferences), and when the 3183 numbers of participants in a session grow. 3185 17.2.2. Gathering and Connectivity Checks 3187 The process of gathering of candidates and performing of connectivity 3188 checks can be bandwidth intensive. ICE has been designed to pace 3189 both of these processes. The gathering phase and the connectivity 3190 check phase are meant to generate traffic at roughly the same 3191 bandwidth as the data traffic itself will consume once the ICE 3192 process conclude. This was done to ensure that, if a network is 3193 designed to support communication traffic of a certain type (voice, 3194 video, or just text), it will have sufficient capacity to support the 3195 ICE checks for that data. Once ICE has concluded, the subsequent ICE 3196 keepalives will later cause a marginal increase in the total 3197 bandwidth utilization; however, this will typically be an extremely 3198 small increase. 3200 Congestion due to the gathering and check phases has proven to be a 3201 problem in deployments that did not utilize pacing. Typically, 3202 access links became congested as the endpoints flooded the network 3203 with checks as fast as they can send them. Consequently, network 3204 operators need to ensure that their ICE implementations support the 3205 pacing feature. Though this pacing does increase call setup times, 3206 it makes ICE network friendly and easier to deploy. 3208 17.2.3. Keepalives 3210 STUN keepalives (in the form of STUN Binding Indications) are sent in 3211 the middle of a data session. However, they are sent only in the 3212 absence of actual data traffic. In deployments with continuous media 3213 and without utilizing Voice Activity Detection (VAD), or deployments 3214 where VAD is utilized together with short interval (max 1 second) 3215 comfort noise, the keepalives are never used and there is no increase 3216 in bandwidth usage. When VAD is being used without comfort noise, 3217 keepalives will be sent during silence periods. This involves a 3218 single packet every 15-20 seconds, far less than the packet every 3219 20-30 ms that is sent when there is voice. Therefore, keepalives do 3220 not have any real impact on capacity planning. 3222 17.3. ICE and ICE-lite 3224 Deployments utilizing a mix of ICE and ICE-lite interoperate with 3225 each other. They have been explicitly designed to do so. 3227 However, ICE-lite can only be deployed in limited use cases. Those 3228 cases, and the caveats involved in doing so, are documented in 3229 Appendix A. 3231 17.4. Troubleshooting and Performance Management 3233 ICE utilizes end-to-end connectivity checks, and places much of the 3234 processing in the endpoints. This introduces a challenge to the 3235 network operator -- how can they troubleshoot ICE deployments? How 3236 can they know how ICE is performing? 3238 ICE has built-in features to help deal with these problems. 3239 Signaling servers, typically deployed in data centers of the network 3240 operator, will see the contents of the candidate exchanges that 3241 convey the ICE parameters. These parameters include the type of each 3242 candidate (host, server reflexive, or relayed), along with their 3243 related addresses. Once ICE processing has completed, an updated 3244 candidate exchange takes place, signaling the selected address (and 3245 its type). This updated signaling is performed exactly for the 3246 purposes of educating network equipment (such as a diagnostic tool 3247 attached to a signaling) about the results of ICE processing. 3249 As a consequence, through the logs generated by a signaling server, a 3250 network operator can observe what types of candidates are being used 3251 for each call, and what address were selected by ICE. This is the 3252 primary information that helps evaluate how ICE is performing. 3254 17.5. Endpoint Configuration 3256 ICE relies on several pieces of data being configured into the 3257 endpoints. This configuration data includes timers, credentials for 3258 TURN servers, and hostnames for STUN and TURN servers. ICE itself 3259 does not provide a mechanism for this configuration. Instead, it is 3260 assumed that this information is attached to whatever mechanism is 3261 used to configure all of the other parameters in the endpoint. For 3262 SIP phones, standard solutions such as the configuration framework 3263 [RFC6080] have been defined. 3265 18. IAB Considerations 3267 The IAB has studied the problem of "Unilateral Self-Address Fixing" 3268 (UNSAF), which is the general process by which an ICE agent attempts 3269 to determine its address in another realm on the other side of a NAT 3270 through a collaborative protocol reflection mechanism [RFC3424]. ICE 3271 is an example of a protocol that performs this type of function. 3272 Interestingly, the process for ICE is not unilateral, but bilateral, 3273 and the difference has a significant impact on the issues raised by 3274 the IAB. Indeed, ICE can be considered a B-SAF (Bilateral Self- 3275 Address Fixing) protocol, rather than an UNSAF protocol. Regardless, 3276 the IAB has mandated that any protocols developed for this purpose 3277 document a specific set of considerations. This section meets those 3278 requirements. 3280 18.1. Problem Definition 3282 From RFC 3424, any UNSAF proposal needs to provide: 3284 Precise definition of a specific, limited-scope problem that is to 3285 be solved with the UNSAF proposal. A short-term fix will not be 3286 generalized in order to solve other problems; this is why "short- 3287 term fixes usually aren't". 3289 The specific problems being solved by ICE are: 3291 Provide a means for two peers to determine the set of transport 3292 addresses that can be used for communication. 3294 Provide a means for a agent to determine an address that is 3295 reachable by another peer with which it wishes to communicate. 3297 18.2. Exit Strategy 3299 From RFC 3424, any UNSAF proposal needs to provide: 3301 Description of an exit strategy/transition plan. The better 3302 short-term fixes are the ones that will naturally see less and 3303 less use as the appropriate technology is deployed. 3305 ICE itself doesn't easily get phased out. However, it is useful even 3306 in a globally connected Internet, to serve as a means for detecting 3307 whether a router failure has temporarily disrupted connectivity, for 3308 example. ICE also helps prevent certain security attacks that have 3309 nothing to do with NAT. However, what ICE does is help phase out 3310 other UNSAF mechanisms. ICE effectively picks amongst those 3311 mechanisms, prioritizing ones that are better, and deprioritizing 3312 ones that are worse. As NATs begin to dissipate as IPv6 is 3313 introduced, server reflexive and relayed candidates (both forms of 3314 UNSAF addresses) simply never get used, because higher-priority 3315 connectivity exists to the native host candidates. Therefore, the 3316 servers get used less and less, and can eventually be removed when 3317 their usage goes to zero. 3319 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 3320 be used to determine whether to use IPv6 or IPv4 when two dual-stack 3321 hosts communicate with SIP (IPv6 gets used). It can also allow a 3322 network with both 6to4 and native v6 connectivity to determine which 3323 address to use when communicating with a peer. 3325 18.3. Brittleness Introduced by ICE 3327 From RFC 3424, any UNSAF proposal needs to provide: 3329 Discussion of specific issues that may render systems more 3330 "brittle". For example, approaches that involve using data at 3331 multiple network layers create more dependencies, increase 3332 debugging challenges, and make it harder to transition. 3334 ICE actually removes brittleness from existing UNSAF mechanisms. In 3335 particular, classic STUN (as described in RFC 3489 [RFC3489]) has 3336 several points of brittleness. One of them is the discovery process 3337 that requires an ICE agent to try to classify the type of NAT it is 3338 behind. This process is error-prone. With ICE, that discovery 3339 process is simply not used. Rather than unilaterally assessing the 3340 validity of the address, its validity is dynamically determined by 3341 measuring connectivity to a peer. The process of determining 3342 connectivity is very robust. 3344 Another point of brittleness in classic STUN and any other unilateral 3345 mechanism is its absolute reliance on an additional server. ICE 3346 makes use of a server for allocating unilateral addresses, but allows 3347 agents to directly connect if possible. Therefore, in some cases, 3348 the failure of a STUN server would still allow for a call to progress 3349 when ICE is used. 3351 Another point of brittleness in classic STUN is that it assumes that 3352 the STUN server is on the public Internet. Interestingly, with ICE, 3353 that is not necessary. There can be a multitude of STUN servers in a 3354 variety of address realms. ICE will discover the one that has 3355 provided a usable address. 3357 The most troubling point of brittleness in classic STUN is that it 3358 doesn't work in all network topologies. In cases where there is a 3359 shared NAT between each agent and the STUN server, traditional STUN 3360 may not work. With ICE, that restriction is removed. 3362 Classic STUN also introduces some security considerations. 3363 Fortunately, those security considerations are also mitigated by ICE. 3365 Consequently, ICE serves to repair the brittleness introduced in 3366 classic STUN, and does not introduce any additional brittleness into 3367 the system. 3369 The penalty of these improvements is that ICE increases session 3370 establishment times. 3372 18.4. Requirements for a Long-Term Solution 3374 From RFC 3424, any UNSAF proposal needs to provide: 3376 ... requirements for longer term, sound technical solutions -- 3377 contribute to the process of finding the right longer term 3378 solution. 3380 Our conclusions from RFC 3489 remain unchanged. However, we feel ICE 3381 actually helps because we believe it can be part of the long-term 3382 solution. 3384 18.5. Issues with Existing NAPT Boxes 3386 From RFC 3424, any UNSAF proposal needs to provide: 3388 Discussion of the impact of the noted practical issues with 3389 existing, deployed NA[P]Ts and experience reports. 3391 A number of NAT boxes are now being deployed into the market that try 3392 to provide "generic" ALG functionality. These generic ALGs hunt for 3393 IP addresses, either in text or binary form within a packet, and 3394 rewrite them if they match a binding. This interferes with classic 3395 STUN. However, the update to STUN [RFC5389] uses an encoding that 3396 hides these binary addresses from generic ALGs. 3398 Existing NAPT boxes have non-deterministic and typically short 3399 expiration times for UDP-based bindings. This requires 3400 implementations to send periodic keepalives to maintain those 3401 bindings. ICE uses a default of 15 s, which is a very conservative 3402 estimate. Eventually, over time, as NAT boxes become compliant to 3403 behave [RFC4787], this minimum keepalive will become deterministic 3404 and well-known, and the ICE timers can be adjusted. Having a way to 3405 discover and control the minimum keepalive interval would be far 3406 better still. 3408 19. Security Considerations 3409 19.1. IP Address Privacy 3411 The process of probing for candidates reveals the source addresses of 3412 the client and its peer to any on-network listening attacker, and the 3413 process of exchanging candidates reveals the addresses to any 3414 attacker that is able to see the negotiation. Some addresses, such 3415 as the server reflexive addresses gathered through the local 3416 interface of VPN users, may be sensitive information. If these 3417 potential attacks can not be mitigated, ICE usages can define 3418 mechanisms for controlling which addresses are revealed to the 3419 negotiation and/or probing process. Individual implementations may 3420 also have implementation-specific rules for controlling which 3421 addresses are revealed. For example, [I-D.ietf-rtcweb-ip-handling] 3422 provides additional information about the privacy aspects of 3423 revealing IP addresses via ICE for WebRTC applications. ICE 3424 implementations where such issues can arise are RECOMMENDED to 3425 provide a programmatic or user interface that provides control over 3426 which network interfaces are used to generate candidates. 3428 Based on the types of candidates provided by the peer, and the 3429 results of the connectivity tests performed against those candidates, 3430 the peer might be able to determine characteristics of the local 3431 network, e.g. if different timings are apparent to the peer. In the 3432 limit the peer might be able to probe the local network. 3434 There are several types of attacks possible in an ICE system. The 3435 subsections consider these attacks and their countermeasures. 3437 19.2. Attacks on Connectivity Checks 3439 An attacker might attempt to disrupt the STUN connectivity checks. 3440 Ultimately, all of these attacks fool an ICE agent into thinking 3441 something incorrect about the results of the connectivity checks. 3442 Depending on the type of attack, the attacker needs to have different 3443 capabilities. In some cases the attacker needs to be on the path of 3444 the connectivity checks. In other cases the attacker does not need 3445 to be on the path, as long as it is able to generate STUN 3446 connectivity checks. While attacks on connectivity checks are 3447 typically performed by network entities, if an attacker is able to 3448 control an endpoint it might be able to trigger connectivity check 3449 attacks. The possible false conclusions an attacker can try and 3450 cause are: 3452 False Invalid: An attacker can fool a pair of agents into thinking a 3453 candidate pair is invalid, when it isn't. This can be used to 3454 cause an agent to prefer a different candidate (such as one 3455 injected by the attacker) or to disrupt a call by forcing all 3456 candidates to fail. 3458 False Valid: An attacker can fool a pair of agents into thinking a 3459 candidate pair is valid, when it isn't. This can cause an agent 3460 to proceed with a session, but then not be able to receive any 3461 data. 3463 False Peer Reflexive Candidate: An attacker can cause an agent to 3464 discover a new peer reflexive candidate when it is not expected 3465 to. This can be used to redirect data streams to a Denial-of- 3466 Service (DoS) target or to the attacker, for eavesdropping or 3467 other purposes. 3469 False Valid on False Candidate: An attacker has already convinced an 3470 agent that there is a candidate with an address that does not 3471 actually route to that agent (e.g., by injecting a false peer 3472 reflexive candidate or false server reflexive candidate). The 3473 attacker then launches an attack that forces the agents to believe 3474 that this candidate is valid. 3476 If an attacker can cause a false peer reflexive candidate or false 3477 valid on a false candidate, it can launch any of the attacks 3478 described in [RFC5389]. 3480 To force the false invalid result, the attacker has to wait for the 3481 connectivity check from one of the agents to be sent. When it is, 3482 the attacker needs to inject a fake response with an unrecoverable 3483 error response (such as a 400), or drop the response so that it never 3484 reaches the agent. However, since the candidate is, in fact, valid, 3485 the original request may reach the peer agent, and result in a 3486 success response. The attacker needs to force this packet or its 3487 response to be dropped, through a DoS attack, layer 2 network 3488 disruption, or other technique. If it doesn't do this, the success 3489 response will also reach the originator, alerting it to a possible 3490 attack. The ability for the attacker to generate a fake response is 3491 mitigated through the STUN short-term credential mechanism. In order 3492 for this response to be processed, the attacker needs the password. 3493 If the candidate exchange signaling is secured, the attacker will not 3494 have the password and its response will be discarded. 3496 Spoofed ICMP Hard Errors (Type 3, codes 2-4) can also be used to 3497 create false invalid results. If an ICE agent implements a response 3498 to these ICMP errors, and the attacker is capable of generating an 3499 ICMP message that is delivered to the agent sending the connectivity 3500 check. The validation of the ICMP error message by the agent is its 3501 only defence. For Type 3 code=4 the outer IP header provides no 3502 validation, unless the connectivity check was sent with DF=0. For 3503 code 2 or 3, which are originated by the host, the address is 3504 expected to be any of the remote agents host, reflexive, or relay 3505 candidates IP addresses. The ICMP message include the IP header and 3506 UDP header of the message triggering the error. These fields also 3507 need to be validated. The IP destination and UDP destination port 3508 need to match either the targeted candidate address and port, or the 3509 candidate's base address. The source IP address and port can be any 3510 candidate for the same base address of the agent sending the 3511 connectivity check. Thus any attacker having access to the exchange 3512 of the candidates will have the necessary information. Thus the 3513 validation is a weak defence, and the sending of spoofed ICMP attacks 3514 is possible also for off-path attackers from a node in a network 3515 without source address validation. 3517 Forcing the fake valid result works in a similar way. The attacker 3518 needs to wait for the Binding request from each agent, and inject a 3519 fake success response. Again, due to the STUN short-term credential 3520 mechanism, in order for the attacker to inject a valid success 3521 response, the attacker needs the password. Alternatively, the 3522 attacker can route (e.g., using a tunnelling mechanism) a valid 3523 success response, that normally would be dropped or rejected by the 3524 network, to the agent. 3526 Forcing the false peer reflexive candidate result can be done either 3527 with fake requests or responses, or with replays. We consider the 3528 fake requests and responses case first. It requires the attacker to 3529 send a Binding request to one agent with a source IP address and port 3530 for the false candidate. In addition, the attacker needs to wait for 3531 a Binding request from the other agent, and generate a fake response 3532 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 3533 Like the other attacks described here, this attack is mitigated by 3534 the STUN message integrity mechanisms and secure candidate exchanges. 3536 Forcing the false peer reflexive candidate result with packet replays 3537 is different. The attacker waits until one of the agents sends a 3538 check. It intercepts this request, and replays it towards the other 3539 agent with a faked source IP address. It also needs to prevent the 3540 original request from reaching the remote agent, either by launching 3541 a DoS attack to cause the packet to be dropped, or forcing it to be 3542 dropped using layer 2 mechanisms. The replayed packet is received at 3543 the other agent, and accepted, since the integrity check passes (the 3544 integrity check cannot and does not cover the source IP address and 3545 port). It is then responded to. This response will contain a XOR- 3546 MAPPED-ADDRESS with the false candidate, and will be sent to that 3547 false candidate. The attacker then needs to receive it and relay it 3548 towards the originator. 3550 The other agent will then initiate a connectivity check towards that 3551 false candidate. This validation needs to succeed. This requires 3552 the attacker to force a false valid on a false candidate. Injecting 3553 of fake requests or responses to achieve this goal is prevented using 3554 the integrity mechanisms of STUN and the candidate exchange. Thus, 3555 this attack can only be launched through replays. To do that, the 3556 attacker needs to intercept the check towards this false candidate, 3557 and replay it towards the other agent. Then, it needs to intercept 3558 the response and replay that back as well. 3560 This attack is very hard to launch unless the attacker is identified 3561 by the fake candidate. This is because it requires the attacker to 3562 intercept and replay packets sent by two different hosts. If both 3563 agents are on different networks (e.g., across the public Internet), 3564 this attack can be hard to coordinate, since it needs to occur 3565 against two different endpoints on different parts of the network at 3566 the same time. 3568 If the attacker itself is identified by the fake candidate, the 3569 attack is easier to coordinate. However, if the data path is secured 3570 (e.g., using SRTP [RFC3711]), the attacker will not be able to 3571 process the data packets, but will only be able to discard them, 3572 effectively disabling the data stream. However, this attack requires 3573 the agent to disrupt packets in order to block the connectivity check 3574 from reaching the target. In that case, if the goal is to disrupt 3575 the data stream, it's much easier to just disrupt it with the same 3576 mechanism, rather than attack ICE. 3578 19.3. Attacks on Server Reflexive Address Gathering 3580 ICE endpoints make use of STUN Binding requests for gathering server 3581 reflexive candidates from a STUN server. These requests are not 3582 authenticated in any way. As a consequence, there are numerous 3583 techniques an attacker can employ to provide the client with a false 3584 server reflexive candidate: 3586 o An attacker can compromise the DNS, causing DNS queries to return 3587 a rogue STUN server address. That server can provide the client 3588 with fake server reflexive candidates. This attack is mitigated 3589 by DNS security, though DNSSEC is not required to address it. 3591 o An attacker that can observe STUN messages (such as an attacker on 3592 a shared network segment, like WiFi) can inject a fake response 3593 that is valid and will be accepted by the client. 3595 o An attacker can compromise a STUN server, and cause it to send 3596 responses with incorrect mapped addresses. 3598 A false mapped address learned by these attacks will be used as a 3599 server reflexive candidate in the establishment of the ICE session. 3600 For this candidate to actually be used for data, the attacker also 3601 needs to attack the connectivity checks, and in particular, force a 3602 false valid on a false candidate. This attack is very hard to launch 3603 if the false address identifies a fourth party (neither the 3604 initiator, responder, nor attacker), since it requires attacking the 3605 checks generated by each ICE agent in the session, and is prevented 3606 by SRTP if it identifies the attacker itself. 3608 If the attacker elects not to attack the connectivity checks, the 3609 worst it can do is prevent the server reflexive candidate from being 3610 used. However, if the peer agent has at least one candidate that is 3611 reachable by the agent under attack, the STUN connectivity checks 3612 themselves will provide a peer reflexive candidate that can be used 3613 for the exchange of data. Peer reflexive candidates are generally 3614 preferred over server reflexive candidates. As such, an attack 3615 solely on the STUN address gathering will normally have no impact on 3616 a session at all. 3618 19.4. Attacks on Relayed Candidate Gathering 3620 An attacker might attempt to disrupt the gathering of relayed 3621 candidates, forcing the client to believe it has a false relayed 3622 candidate. Exchanges with the TURN server are authenticated using a 3623 long-term credential. Consequently, injection of fake responses or 3624 requests will not work. In addition, unlike Binding requests, 3625 Allocate requests are not susceptible to replay attacks with modified 3626 source IP addresses and ports, since the source IP address and port 3627 are not utilized to provide the client with its relayed candidate. 3629 Even if an attacker has caused the client to believe in a false 3630 relayed candidate, the connectivity checks cause such a candidate to 3631 be used only if they succeed. Thus, an attacker needs to launch a 3632 false valid on a false candidate, per above, which is a very 3633 difficult attack to coordinate. 3635 19.5. Insider Attacks 3637 In addition to attacks where the attacker is a third party trying to 3638 insert fake candidate information or STUN messages, there are attacks 3639 possible with ICE when the attacker is an authenticated and valid 3640 participant in the ICE exchange. 3642 19.5.1. STUN Amplification Attack 3644 The STUN amplification attack is similar to a "voice hammer" attack, 3645 where the attacker causes other agents to direct voice packets to the 3646 attack target. However, instead of voice packets being directed to 3647 the target, STUN connectivity checks are directed to the target. The 3648 attacker sends an a large number of candidates, say, 50. The 3649 responding agent receives the candidate information, and starts its 3650 checks, which are directed at the target, and consequently, never 3651 generate a response. In the case of WebRTC the user might not even 3652 be aware that this attack is ongoing, since it might be triggered in 3653 the background by malicious JavaScript code that the user has 3654 fetched. The answerer will start a new connectivity check every Ta 3655 ms (say, Ta=50ms). However, the retransmission timers are set to a 3656 large number due to the large number of candidates. As a 3657 consequence, packets will be sent at an interval of one every Ta 3658 milliseconds, and then with increasing intervals after that. Thus, 3659 STUN will not send packets at a rate faster than data would be sent, 3660 and the STUN packets persist only briefly, until ICE fails for the 3661 session. Nonetheless, this is an amplification mechanism. 3663 It is impossible to eliminate the amplification, but the volume can 3664 be reduced through a variety of heuristics. ICE agents SHOULD limit 3665 the total number of connectivity checks they perform to 100. 3666 Additionally, agents MAY limit the number of candidates they will 3667 accept. 3669 Frequently, protocols that wish to avoid these kinds of attacks force 3670 the initiator to wait for a response prior to sending the next 3671 message. However, in the case of ICE, this is not possible. It is 3672 not possible to differentiate the following two cases: 3674 o There was no response because the initiator is being used to 3675 launch a DoS attack against an unsuspecting target that will not 3676 respond. 3678 o There was no response because the IP address and port are not 3679 reachable by the initiator. 3681 In the second case, another check will be sent at the next 3682 opportunity, while in the former case, no further checks will be 3683 sent. 3685 20. IANA Considerations 3687 The original ICE specification registered four STUN attributes, and 3688 one new STUN error response. The STUN attributes and error response 3689 are reproduced here. In addition, this specification registers a new 3690 ICE option. 3692 20.1. STUN Attributes 3694 IANA has registered four STUN attributes: 3696 0x0024 PRIORITY 3697 0x0025 USE-CANDIDATE 3698 0x8029 ICE-CONTROLLED 3699 0x802A ICE-CONTROLLING 3701 NOTE TO IANA: Please replace the reference to RFC 5245 in the 3702 registry with a reference to this specification. 3704 20.2. STUN Error Responses 3706 IANA has registered following STUN error response code: 3708 487 Role Conflict: The client asserted an ICE role (controlling or 3709 controlled) that is in conflict with the role of the server. 3711 NOTE TO IANA: Please replace the reference to RFC 5245 in the 3712 registry with a reference to this specification. 3714 20.3. ICE Options 3716 IANA is requested to register the following ICE option in the "ICE 3717 Options" sub-registry of the "Interactive Connectivity Establishment 3718 (ICE) registry", following the procedures defined in [RFC6336]. 3720 ICE Option name: 3722 ice2 3724 Contact: 3726 Name: IESG 3727 E-mail: iesg@ietf.org 3729 Change control: 3731 IESG 3733 Description: 3735 The ICE option indicates that the ICE agent using the ICE option 3736 is implemented according to RFC XXXX. 3738 Reference: 3740 RFC XXXX 3742 21. Changes from RFC 5245 3744 The purpose of this updated ICE specification is to: 3746 o Clarify procedures in RFC 5245. 3748 o Make technical changes, due to discovered flaws in RFC 5245 and 3749 based on feedback from the community that has implemented and 3750 deployed ICE applications based on RFC 5245. 3752 o Make the procedures signaling protocol independent, by removing 3753 the SIP and SDP procedures. Procedures specific to a signaling 3754 protocol will be defined in separate usage documents. 3755 [I-D.ietf-mmusic-ice-sip-sdp] defines the ICE usage with SIP and 3756 SDP. 3758 The following technical changes have been done: 3760 o Aggressive nomination removed. 3762 o The procedures for calculating candidate pair states and 3763 scheduling connectivity checks modified. 3765 o Procedures for calculation of Ta and RTO modified. 3767 o Active check list and frozen check list definitions removed. 3769 o 'ice2' ice option added. 3771 o IPv6 considerations modified. 3773 o Usage with no-op for keepalives, and keepalives with non-ICE 3774 peers, removed. 3776 22. Acknowledgements 3778 Most of the text in this document comes from the original ICE 3779 specification, RFC 5245. The authors would like to thank everyone 3780 who has contributed to that document. For additional contributions 3781 to this revision of the specification we would like to thank Emil 3782 Ivov, Paul Kyzivat, Pal-Erik Martinsen, Simon Perrault, Eric 3783 Rescorla, Thomas Stach, Peter Thatcher, Martin Thomson, Justin 3784 Uberti, Suhas Nandakumar, Taylor Brandstetter, Peter Saint-Andre, 3785 Harald Alvestrand and Roman Shpount. Ben Campbell did the AD review. 3786 Stephen Farrell did the sec-dir review. Stewart Bryant did the gen- 3787 art review. Qin We did the ops-dir review. Magnus Westerlund did 3788 the tsv-art review. 3790 23. References 3792 23.1. Normative References 3794 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3795 Requirement Levels", BCP 14, RFC 2119, 3796 DOI 10.17487/RFC2119, March 1997, . 3799 [RFC4941] Narten, T., Draves, R., and S. Krishnan, "Privacy 3800 Extensions for Stateless Address Autoconfiguration in 3801 IPv6", RFC 4941, DOI 10.17487/RFC4941, September 2007, 3802 . 3804 [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, 3805 "Session Traversal Utilities for NAT (STUN)", RFC 5389, 3806 DOI 10.17487/RFC5389, October 2008, . 3809 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3810 Relays around NAT (TURN): Relay Extensions to Session 3811 Traversal Utilities for NAT (STUN)", RFC 5766, 3812 DOI 10.17487/RFC5766, April 2010, . 3815 [RFC6336] Westerlund, M. and C. Perkins, "IANA Registry for 3816 Interactive Connectivity Establishment (ICE) Options", 3817 RFC 6336, DOI 10.17487/RFC6336, July 2011, 3818 . 3820 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3821 "Default Address Selection for Internet Protocol Version 6 3822 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3823 . 3825 23.2. Informative References 3827 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3828 and E. Lear, "Address Allocation for Private Internets", 3829 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3830 . 3832 [RFC3605] Huitema, C., "Real Time Control Protocol (RTCP) attribute 3833 in Session Description Protocol (SDP)", RFC 3605, 3834 DOI 10.17487/RFC3605, October 2003, . 3837 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3838 A., Peterson, J., Sparks, R., Handley, M., and E. 3839 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3840 DOI 10.17487/RFC3261, June 2002, . 3843 [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model 3844 with Session Description Protocol (SDP)", RFC 3264, 3845 DOI 10.17487/RFC3264, June 2002, . 3848 [RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, 3849 "STUN - Simple Traversal of User Datagram Protocol (UDP) 3850 Through Network Address Translators (NATs)", RFC 3489, 3851 DOI 10.17487/RFC3489, March 2003, . 3854 [RFC3235] Senie, D., "Network Address Translator (NAT)-Friendly 3855 Application Design Guidelines", RFC 3235, 3856 DOI 10.17487/RFC3235, January 2002, . 3859 [RFC3303] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and 3860 A. Rayhan, "Middlebox communication architecture and 3861 framework", RFC 3303, DOI 10.17487/RFC3303, August 2002, 3862 . 3864 [RFC3102] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, 3865 "Realm Specific IP: Framework", RFC 3102, 3866 DOI 10.17487/RFC3102, October 2001, . 3869 [RFC3103] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, 3870 "Realm Specific IP: Protocol Specification", RFC 3103, 3871 DOI 10.17487/RFC3103, October 2001, . 3874 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3875 UNilateral Self-Address Fixing (UNSAF) Across Network 3876 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3877 November 2002, . 3879 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3880 Jacobson, "RTP: A Transport Protocol for Real-Time 3881 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3882 July 2003, . 3884 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3885 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3886 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3887 . 3889 [RFC3725] Rosenberg, J., Peterson, J., Schulzrinne, H., and G. 3890 Camarillo, "Best Current Practices for Third Party Call 3891 Control (3pcc) in the Session Initiation Protocol (SIP)", 3892 BCP 85, RFC 3725, DOI 10.17487/RFC3725, April 2004, 3893 . 3895 [RFC3879] Huitema, C. and B. Carpenter, "Deprecating Site Local 3896 Addresses", RFC 3879, DOI 10.17487/RFC3879, September 3897 2004, . 3899 [RFC4038] Shin, M-K., Ed., Hong, Y-G., Hagino, J., Savola, P., and 3900 E. Castro, "Application Aspects of IPv6 Transition", 3901 RFC 4038, DOI 10.17487/RFC4038, March 2005, 3902 . 3904 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 3905 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 3906 2006, . 3908 [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 3909 Description Protocol", RFC 4566, DOI 10.17487/RFC4566, 3910 July 2006, . 3912 [RFC2475] Blake, S., Black, D., Carlson, M., Davies, E., Wang, Z., 3913 and W. Weiss, "An Architecture for Differentiated 3914 Services", RFC 2475, DOI 10.17487/RFC2475, December 1998, 3915 . 3917 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3918 Translation (NAT) Behavioral Requirements for Unicast 3919 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3920 2007, . 3922 [RFC5761] Perkins, C. and M. Westerlund, "Multiplexing RTP Data and 3923 Control Packets on a Single Port", RFC 5761, 3924 DOI 10.17487/RFC5761, April 2010, . 3927 [RFC4103] Hellstrom, G. and P. Jones, "RTP Payload for Text 3928 Conversation", RFC 4103, DOI 10.17487/RFC4103, June 2005, 3929 . 3931 [RFC4091] Camarillo, G. and J. Rosenberg, "The Alternative Network 3932 Address Types (ANAT) Semantics for the Session Description 3933 Protocol (SDP) Grouping Framework", RFC 4091, 3934 DOI 10.17487/RFC4091, June 2005, . 3937 [RFC4092] Camarillo, G. and J. Rosenberg, "Usage of the Session 3938 Description Protocol (SDP) Alternative Network Address 3939 Types (ANAT) Semantics in the Session Initiation Protocol 3940 (SIP)", RFC 4092, DOI 10.17487/RFC4092, June 2005, 3941 . 3943 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3944 (ICE): A Protocol for Network Address Translator (NAT) 3945 Traversal for Offer/Answer Protocols", RFC 5245, 3946 DOI 10.17487/RFC5245, April 2010, . 3949 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 3950 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 3951 RFC 5382, DOI 10.17487/RFC5382, October 2008, 3952 . 3954 [RFC6080] Petrie, D. and S. Channabasappa, Ed., "A Framework for 3955 Session Initiation Protocol User Agent Profile Delivery", 3956 RFC 6080, DOI 10.17487/RFC6080, March 2011, 3957 . 3959 [RFC6146] Bagnulo, M., Matthews, P., and I. van Beijnum, "Stateful 3960 NAT64: Network Address and Protocol Translation from IPv6 3961 Clients to IPv4 Servers", RFC 6146, DOI 10.17487/RFC6146, 3962 April 2011, . 3964 [RFC6147] Bagnulo, M., Sullivan, A., Matthews, P., and I. van 3965 Beijnum, "DNS64: DNS Extensions for Network Address 3966 Translation from IPv6 Clients to IPv4 Servers", RFC 6147, 3967 DOI 10.17487/RFC6147, April 2011, . 3970 [RFC6298] Paxson, V., Allman, M., Chu, J., and M. Sargent, 3971 "Computing TCP's Retransmission Timer", RFC 6298, 3972 DOI 10.17487/RFC6298, June 2011, . 3975 [RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, 3976 "TCP Candidates with Interactive Connectivity 3977 Establishment (ICE)", RFC 6544, DOI 10.17487/RFC6544, 3978 March 2012, . 3980 [RFC6928] Chu, J., Dukkipati, N., Cheng, Y., and M. Mathis, 3981 "Increasing TCP's Initial Window", RFC 6928, 3982 DOI 10.17487/RFC6928, April 2013, . 3985 [RFC7050] Savolainen, T., Korhonen, J., and D. Wing, "Discovery of 3986 the IPv6 Prefix Used for IPv6 Address Synthesis", 3987 RFC 7050, DOI 10.17487/RFC7050, November 2013, 3988 . 3990 [RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy 3991 Considerations for IPv6 Address Generation Mechanisms", 3992 RFC 7721, DOI 10.17487/RFC7721, March 2016, 3993 . 3995 [RFC7825] Goldberg, J., Westerlund, M., and T. Zeng, "A Network 3996 Address Translator (NAT) Traversal Mechanism for Media 3997 Controlled by the Real-Time Streaming Protocol (RTSP)", 3998 RFC 7825, DOI 10.17487/RFC7825, December 2016, 3999 . 4001 [I-D.ietf-mmusic-ice-sip-sdp] 4002 Petit-Huguenin, M., Keranen, A., and S. Nandakumar, 4003 "Session Description Protocol (SDP) Offer/Answer 4004 procedures for Interactive Connectivity Establishment 4005 (ICE)", draft-ietf-mmusic-ice-sip-sdp-16 (work in 4006 progress), November 2017. 4008 [I-D.ietf-ice-dualstack-fairness] 4009 Martinsen, P., Reddy, T., and P. Patil, "ICE Multihomed 4010 and IPv4/IPv6 Dual Stack Guidelines", draft-ietf-ice- 4011 dualstack-fairness-07 (work in progress), November 2016. 4013 [I-D.ietf-rtcweb-ip-handling] 4014 Uberti, J. and G. Shieh, "WebRTC IP Address Handling 4015 Requirements", draft-ietf-rtcweb-ip-handling-06 (work in 4016 progress), March 2018. 4018 Appendix A. Lite and Full Implementations 4020 ICE allows for two types of implementations. A full implementation 4021 supports the controlling and controlled roles in a session, and can 4022 also perform address gathering. In contrast, a lite implementation 4023 is a minimalist implementation that does little but respond to STUN 4024 checks, and only supports the controlled role in a session. 4026 Because ICE requires both endpoints to support it in order to bring 4027 benefits to either endpoint, incremental deployment of ICE in a 4028 network is more complicated. Many sessions involve an endpoint that 4029 is, by itself, not behind a NAT and not one that would worry about 4030 NAT traversal. A very common case is to have one endpoint that 4031 requires NAT traversal (such as a VoIP hard phone or soft phone) make 4032 a call to one of these devices. Even if the phone supports a full 4033 ICE implementation, ICE won't be used at all if the other device 4034 doesn't support it. The lite implementation allows for a low-cost 4035 entry point for these devices. Once they support the lite 4036 implementation, full implementations can connect to them and get the 4037 full benefits of ICE. 4039 Consequently, a lite implementation is only appropriate for devices 4040 that will *always* be connected to the public Internet and have a 4041 public IP address at which it can receive packets from any 4042 correspondent. ICE will not function when a lite implementation is 4043 placed behind a NAT. 4045 ICE allows a lite implementation to have a single IPv4 host candidate 4046 and several IPv6 addresses. In that case, candidate pairs are 4047 selected by the controlling agent using a static algorithm, such as 4048 the one in RFC 6724, which is recommended by this specification. 4049 However, static mechanisms for address selection are always prone to 4050 error, since they cannot ever reflect the actual topology and can 4051 never provide actual guarantees on connectivity. They are always 4052 heuristics. Consequently, if an ICE agent is implementing ICE just 4053 to select between its IPv4 and IPv6 addresses, and none of its IP 4054 addresses are behind NAT, usage of full ICE is still RECOMMENDED in 4055 order to provide the most robust form of address selection possible. 4057 It is important to note that the lite implementation was added to 4058 this specification to provide a stepping stone to full 4059 implementation. Even for devices that are always connected to the 4060 public Internet with just a single IPv4 address, a full 4061 implementation is preferable if achievable. Full implementations 4062 also obtain the security benefits of ICE unrelated to NAT traversal. 4063 Finally, it is often the case that a device that finds itself with a 4064 public address today will be placed in a network tomorrow where it 4065 will be behind a NAT. It is difficult to definitively know, over the 4066 lifetime of a device or product, that it will always be used on the 4067 public Internet. Full implementation provides assurance that 4068 communications will always work. 4070 Appendix B. Design Motivations 4072 ICE contains a number of normative behaviors that may themselves be 4073 simple, but derive from complicated or non-obvious thinking or use 4074 cases that merit further discussion. Since these design motivations 4075 are not necessary to understand for purposes of implementation, they 4076 are discussed here in an appendix to the specification. This section 4077 is non-normative. 4079 B.1. Pacing of STUN Transactions 4081 STUN transactions used to gather candidates and to verify 4082 connectivity are paced out at an approximate rate of one new 4083 transaction every Ta milliseconds. Each transaction, in turn, has a 4084 retransmission timer RTO that is a function of Ta as well. Why are 4085 these transactions paced, and why are these formulas used? 4087 Sending of these STUN requests will often have the effect of creating 4088 bindings on NAT devices between the client and the STUN servers. 4089 Experience has shown that many NAT devices have upper limits on the 4090 rate at which they will create new bindings. Discussions in the IETF 4091 ICE WG during the work on this specification concluded that, that 4092 once every 5 ms is well supported. This is why Ta has a lower bound 4093 of 5 ms. Furthermore, transmission of these packets on the network 4094 makes use of bandwidth and needs to be rate limited by the ICE agent. 4095 Deployments based on earlier draft versions of [RFC5245] tended to 4096 overload rate-constrained access links and perform poorly overall, in 4097 addition to negatively impacting the network. As a consequence, the 4098 pacing ensures that the NAT device does not get overloaded and that 4099 traffic is kept at a reasonable rate. 4101 The definition of a "reasonable" rate is that STUN MUST NOT use more 4102 bandwidth than the RTP itself will use, once data starts flowing. 4103 The formula for Ta is designed so that, if a STUN packet were sent 4104 every Ta seconds, it would consume the same amount of bandwidth as 4105 RTP packets, summed across all data streams. Of course, STUN has 4106 retransmits, and the desire is to pace those as well. For this 4107 reason, RTO is set such that the first retransmit on the first 4108 transaction happens just as the first STUN request on the last 4109 transaction occurs. Pictorially: 4111 First Packets Retransmits 4113 | | 4114 | | 4115 -------+------ -------+------ 4116 / \ / \ 4117 / \ / \ 4119 +--+ +--+ +--+ +--+ +--+ +--+ 4120 |A1| |B1| |C1| |A2| |B2| |C2| 4121 +--+ +--+ +--+ +--+ +--+ +--+ 4123 ---+-------+-------+-------+-------+-------+------------ Time 4124 0 Ta 2Ta 3Ta 4Ta 5Ta 4126 In this picture, there are three transactions that will be sent (for 4127 example, in the case of candidate gathering, there are three host 4128 candidate/STUN server pairs). These are transactions A, B, and C. 4129 The retransmit timer is set so that the first retransmission on the 4130 first transaction (packet A2) is sent at time 3Ta. 4132 Subsequent retransmits after the first will occur even less 4133 frequently than Ta milliseconds apart, since STUN uses an exponential 4134 back-off on its retransmissions. 4136 This mechanism of a global minimum pacing interval of 5ms is not 4137 generally applicable to transport protocols, but is applicable to ICE 4138 based on the following reasoning. 4140 o Start with the following rules which would be generally applicable 4141 to transport protocols: 4143 1. Let MaxBytes be the maximum number of bytes allowed to be 4144 outstanding in the network at start-up, which SHOULD be 14600, 4145 as defined in Section 2 of [RFC6928]. 4147 2. Let HTO be the transaction timeout, which SHOULD be 2*RTT if 4148 RTT is known and 500ms otherwise. This is based on the RTO 4149 for STUN messages from [RFC5389] and the the TCP initial RTO, 4150 which is 1 sec in [RFC6298]. 4152 3. Let MinPacing be the minimum pacing interval between 4153 transactions, which is 5ms (see above). 4155 o Observe that agents typically do not know the RTT for ICE 4156 transactions (connectivity checks in particular), meaning that HTO 4157 will almost always be 500ms. 4159 o Observe that a MinPacing of 5ms and HTO of 500ms gives at most 100 4160 packets/HTO, which for a typical ICE check of less than 120 bytes 4161 means a maximum of 12000 outstanding bytes in the network, which 4162 is less than the maximum expressed by rule 1. 4164 o Thus, for ICE, the rule set reduces down to just the MinPacing 4165 rule, which is equivalent to having a global Ta value. 4167 B.2. Candidates with Multiple Bases 4169 Section 5.1.3 talks about eliminating candidates that have the same 4170 transport address and base. However, candidates with the same 4171 transport addresses but different bases are not redundant. When can 4172 an ICE agent have two candidates that have the same IP address and 4173 port, but different bases? Consider the topology of Figure 11: 4175 +----------+ 4176 | STUN Srvr| 4177 +----------+ 4178 | 4179 | 4180 ----- 4181 // \\ 4182 | | 4183 | B:net10 | 4184 | | 4185 \\ // 4186 ----- 4187 | 4188 | 4189 +----------+ 4190 | NAT | 4191 +----------+ 4192 | 4193 | 4194 ----- 4195 // \\ 4196 | A | 4197 |192.168/16 | 4198 | | 4199 \\ // 4200 ----- 4201 | 4202 | 4203 |192.168.1.100 ----- 4204 +----------+ // \\ +----------+ 4205 | | | | | | 4206 | Initiator|---------| C:net10 |-----------| Responder| 4207 | |10.0.1.100| | 10.0.1.101 | | 4208 +----------+ \\ // +----------+ 4209 ----- 4211 Figure 11: Identical Candidates with Different Bases 4213 In this case, the initiating agent is multihomed. It has one IP 4214 address, 10.0.1.100, on network C, which is a net 10 private network. 4215 The responding agent is on this same network. The initiating agent 4216 is also connected to network A, which is 192.168/16 and has an IP 4217 address of 192.168.1.100 on this network. There is a NAT on this 4218 network, natting into network B, which is another net 10 private 4219 network, but not connected to network C. There is a STUN server on 4220 network B. 4222 The initiating agent obtains a host candidate on its IP address on 4223 network C (10.0.1.100:2498) and a host candidate on its IP address on 4224 network A (192.168.1.100:3344). It performs a STUN query to its 4225 configured STUN server from 192.168.1.100:3344. This query passes 4226 through the NAT, which happens to assign the binding 10.0.1.100:2498. 4227 The STUN server reflects this in the STUN Binding response. Now, the 4228 initiating agent has obtained a server reflexive candidate with a 4229 transport address that is identical to a host candidate 4230 (10.0.1.100:2498). However, the server reflexive candidate has a 4231 base of 192.168.1.100:3344, and the host candidate has a base of 4232 10.0.1.100:2498. 4234 B.3. Purpose of the Related Address and Related Port Attributes 4236 The candidate attribute contains two values that are not used at all 4237 by ICE itself -- related address and related port. Why are they 4238 present? 4240 There are two motivations for its inclusion. The first is 4241 diagnostic. It is very useful to know the relationship between the 4242 different types of candidates. By including it, an ICE agent can 4243 know which relayed candidate is associated with which reflexive 4244 candidate, which in turn is associated with a specific host 4245 candidate. When checks for one candidate succeed and not for others, 4246 this provides useful diagnostics on what is going on in the network. 4248 The second reason has to do with off-path Quality of Service (QoS) 4249 mechanisms. When ICE is used in environments such as PacketCable 4250 2.0, proxies will, in addition to performing normal SIP operations, 4251 inspect the SDP in SIP messages, and extract the IP address and port 4252 for data traffic. They can then interact, through policy servers, 4253 with access routers in the network, to establish guaranteed QoS for 4254 the data flows. This QoS is provided by classifying the RTP traffic 4255 based on 5-tuple, and then providing it a guaranteed rate, or marking 4256 its Diffserv codepoints appropriately. When a residential NAT is 4257 present, and a relayed candidate gets selected for data, this relayed 4258 candidate will be a transport address on an actual TURN server. That 4259 address says nothing about the actual transport address in the access 4260 router that would be used to classify packets for QoS treatment. 4261 Rather, the server reflexive candidate towards the TURN server is 4262 needed. By carrying the translation in the SDP, the proxy can use 4263 that transport address to request QoS from the access router. 4265 B.4. Importance of the STUN Username 4267 ICE requires the usage of message integrity with STUN using its 4268 short-term credential functionality. The actual short-term 4269 credential is formed by exchanging username fragments in the 4270 candidate exchange. The need for this mechanism goes beyond just 4271 security; it is actually required for correct operation of ICE in the 4272 first place. 4274 Consider ICE agents L, R, and Z. L and R are within private 4275 enterprise 1, which is using 10.0.0.0/8. Z is within private 4276 enterprise 2, which is also using 10.0.0.0/8. As it turns out, R and 4277 Z both have IP address 10.0.1.1. L sends candidates to Z. Z, in 4278 responds L with its host candidates. In this case, those candidates 4279 are 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, R is in a 4280 session at that same time, and is also using 10.0.1.1:8866 and 4281 10.0.1.1:8877 as host candidates. This means that R is prepared to 4282 accept STUN messages on those ports, just as Z is. L will send a 4283 STUN request to 10.0.1.1:8866 and another to 10.0.1.1:8877. However, 4284 these do not go to Z as expected. Instead, they go to R! If R just 4285 replied to them, L would believe it has connectivity to Z, when in 4286 fact it has connectivity to a completely different user, R. To fix 4287 this, the STUN short-term credential mechanisms are used. The 4288 username fragments are sufficiently random that it is highly unlikely 4289 that R would be using the same values as Z. Consequently, R would 4290 reject the STUN request since the credentials were invalid. In 4291 essence, the STUN username fragments provide a form of transient host 4292 identifiers, bound to a particular session established as part of the 4293 candidate exchange. 4295 An unfortunate consequence of the non-uniqueness of IP addresses is 4296 that, in the above example, R might not even be an ICE agent. It 4297 could be any host, and the port to which the STUN packet is directed 4298 could be any ephemeral port on that host. If there is an application 4299 listening on this socket for packets, and it is not prepared to 4300 handle malformed packets for whatever protocol is in use, the 4301 operation of that application could be affected. Fortunately, since 4302 the ports exchanged are ephemeral and usually drawn from the dynamic 4303 or registered range, the odds are good that the port is not used to 4304 run a server on host R, but rather is the agent side of some 4305 protocol. This decreases the probability of hitting an allocated 4306 port, due to the transient nature of port usage in this range. 4307 However, the possibility of a problem does exist, and network 4308 deployers need to be prepared for it. Note that this is not a 4309 problem specific to ICE; stray packets can arrive at a port at any 4310 time for any type of protocol, especially ones on the public 4311 Internet. As such, this requirement is just restating a general 4312 design guideline for Internet applications -- be prepared for unknown 4313 packets on any port. 4315 B.5. The Candidate Pair Priority Formula 4317 The priority for a candidate pair has an odd form. It is: 4319 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 4321 Why is this? When the candidate pairs are sorted based on this 4322 value, the resulting sorting has the MAX/MIN property. This means 4323 that the pairs are first sorted based on decreasing value of the 4324 minimum of the two priorities. For pairs that have the same value of 4325 the minimum priority, the maximum priority is used to sort amongst 4326 them. If the max and the min priorities are the same, the 4327 controlling agent's priority is used as the tie-breaker in the last 4328 part of the expression. The factor of 2*32 is used since the 4329 priority of a single candidate is always less than 2*32, resulting in 4330 the pair priority being a "concatenation" of the two component 4331 priorities. This creates the MAX/MIN sorting. MAX/MIN ensures that, 4332 for a particular ICE agent, a lower-priority candidate is never used 4333 until all higher-priority candidates have been tried. 4335 B.6. Why Are Keepalives Needed? 4337 Once data begins flowing on a candidate pair, it is still necessary 4338 to keep the bindings alive at intermediate NATs for the duration of 4339 the session. Normally, the data stream packets themselves (e.g., 4340 RTP) meet this objective. However, several cases merit further 4341 discussion. Firstly, in some RTP usages, such as SIP, the data 4342 streams can be "put on hold". This is accomplished by using the SDP 4343 "sendonly" or "inactive" attributes, as defined in RFC 3264 4344 [RFC3264]. RFC 3264 directs implementations to cease transmission of 4345 data in these cases. However, doing so may cause NAT bindings to 4346 timeout, and data won't be able to come off hold. 4348 Secondly, some RTP payload formats, such as the payload format for 4349 text conversation [RFC4103], may send packets so infrequently that 4350 the interval exceeds the NAT binding timeouts. 4352 Thirdly, if silence suppression is in use, long periods of silence 4353 may cause data transmission to cease sufficiently long for NAT 4354 bindings to time out. 4356 For these reasons, the data packets themselves cannot be relied upon. 4357 ICE defines a simple periodic keepalive utilizing STUN Binding 4358 indications. This makes its bandwidth requirements highly 4359 predictable, and thus amenable to QoS reservations. 4361 B.7. Why Prefer Peer Reflexive Candidates? 4363 Section 5.1.2 describes procedures for computing the priority of 4364 candidate based on its type and local preferences. That section 4365 requires that the type preference for peer reflexive candidates 4366 always be higher than server reflexive. Why is that? The reason has 4367 to do with the security considerations in Section 19. It is much 4368 easier for an attacker to cause an ICE agent to use a false server 4369 reflexive candidate than it is for an attacker to cause an agent to 4370 use a false peer reflexive candidate. Consequently, attacks against 4371 address gathering with Binding requests are thwarted by ICE by 4372 preferring the peer reflexive candidates. 4374 B.8. Why Are Binding Indications Used for Keepalives? 4376 Data keepalives are described in Section 11. These keepalives make 4377 use of STUN when both endpoints are ICE capable. However, rather 4378 than using a Binding request transaction (which generates a 4379 response), the keepalives use an Indication. Why is that? 4381 The primary reason has to do with network QoS mechanisms. Once data 4382 begins flowing, network elements will assume that the data stream has 4383 a fairly regular structure, making use of periodic packets at fixed 4384 intervals, with the possibility of jitter. If an ICE agent is 4385 sending data packets, and then receives a Binding request, it would 4386 need to generate a response packet along with its data packets. This 4387 will increase the actual bandwidth requirements for the 5-tuple 4388 carrying the data packets, and introduce jitter in the delivery of 4389 those packets. Analysis has shown that this is a concern in certain 4390 layer 2 access networks that use fairly tight packet schedulers for 4391 data. 4393 Additionally, using a Binding Indication allows integrity to be 4394 disabled, allowing for better performance. This is useful for large- 4395 scale endpoints, such as Public Switched Telephone Network (PSTN) 4396 gateways and Session Border Controllers (SBCs). 4398 B.9. Selecting Candidate Type Preference 4400 One criterion for selection of the type and local preference values 4401 is the use of a data intermediary, such as a TURN server, a tunnel 4402 service such as VPN server, or NAT. With a data intermediary, if 4403 data is sent to that candidate, it will first transit the data 4404 intermediary before being received. Relayed candidates are one type 4405 of candidate that involves a data intermediary. Another are host 4406 candidates obtained from a VPN interface. When data is transited 4407 through a data intermediary, it can have a positive or negative 4408 effect on the latency between transmission and reception. It may or 4409 may not increase the packet losses, because of the additional router 4410 hops that may be taken. It may increase the cost of providing 4411 service, since data will be routed in and right back out of a data 4412 intermediary run by a provider. If these concerns are important, the 4413 type preference for relayed candidates needs to be carefully chosen. 4415 Another criterion for selection of preferences is IP address family. 4416 ICE works with both IPv4 and IPv6. It provides a transition 4417 mechanism that allows dual-stack hosts to prefer connectivity over 4418 IPv6, but to fall back to IPv4 in case the v6 networks are 4419 disconnected. Implementation SHOULD follow the guidelines from 4420 [I-D.ietf-ice-dualstack-fairness] to avoid excessive delays in the 4421 connectivity check phase if broken paths exist. 4423 Another criterion for selecting preferences is topological awareness. 4424 This is most useful for candidates that make use of intermediaries. 4425 In those cases, if an ICE agent has preconfigured or dynamically 4426 discovered knowledge of the topological proximity of the 4427 intermediaries to itself, it can use that to assign higher local 4428 preferences to candidates obtained from closer intermediaries. 4430 Another criterion for selecting preferences might be security or 4431 privacy. If a user is a telecommuter, and therefore connected to a 4432 corporate network and a local home network, the user may prefer their 4433 voice traffic to be routed over the VPN or similar tunnel in order to 4434 keep it on the corporate network when communicating within the 4435 enterprise, but use the local network when communicating with users 4436 outside of the enterprise. In such a case, a VPN address would have 4437 a higher local preference than any other address. 4439 Appendix C. Connectivity Check Bandwidth 4441 The tables below show, for IPv4 and IPv6, the bandwidth required for 4442 performing connectivity checks, using different Ta values (given in 4443 ms) and different ufrag sizes (given in bytes). 4445 The results were provided by Jusin Uberti (Google) 11th April 2016. 4447 IP version: IPv4 4448 Packet len (bytes): 108 + ufrag 4449 | 4450 ms | 4 8 12 16 4451 -----|------------------------ 4452 500 | 1.86k 1.98k 2.11k 2.24k 4453 200 | 4.64k 4.96k 5.28k 5.6k 4454 100 | 9.28k 9.92k 10.6k 11.2k 4455 50 | 18.6k 19.8k 21.1k 22.4k 4456 20 | 46.4k 49.6k 52.8k 56.0k 4457 10 | 92.8k 99.2k 105k 112k 4458 5 | 185k 198k 211k 224k 4459 2 | 464k 496k 528k 560k 4460 1 | 928k 992k 1.06M 1.12M 4462 IP version: IPv6 4463 Packet len (bytes): 128 + ufrag 4464 | 4465 ms | 4 8 12 16 4466 -----|------------------------ 4467 500 | 2.18k 2.3k 2.43k 2.56k 4468 200 | 5.44k 5.76k 6.08k 6.4k 4469 100 | 10.9k 11.5k 12.2k 12.8k 4470 50 | 21.8k 23.0k 24.3k 25.6k 4471 20 | 54.4k 57.6k 60.8k 64.0k 4472 10 | 108k 115k 121k 128k 4473 5 | 217k 230k 243k 256k 4474 2 | 544k 576k 608k 640k 4475 1 | 1.09M 1.15M 1.22M 1.28M 4477 Figure 12: Connectivity Check Bandwidth 4479 Authors' Addresses 4481 Ari Keranen 4482 Ericsson 4483 Hirsalantie 11 4484 02420 Jorvas 4485 Finland 4487 Email: ari.keranen@ericsson.com 4488 Christer Holmberg 4489 Ericsson 4490 Hirsalantie 11 4491 02420 Jorvas 4492 Finland 4494 Email: christer.holmberg@ericsson.com 4496 Jonathan Rosenberg 4497 jdrosen.net 4498 Monmouth, NJ 4499 US 4501 Email: jdrosen@jdrosen.net 4502 URI: http://www.jdrosen.net