idnits 2.17.1 draft-ietf-ice-rfc5245bis-14.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. -- The document has examples using IPv4 documentation addresses according to RFC6890, but does not use any IPv6 documentation addresses. Maybe there should be IPv6 examples, too? Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 1531 has weird spacing: '... | f-cp f-cp ...' == Line 1533 has weird spacing: '... | f-cp f-cp ...' == Line 1543 has weird spacing: '... | w-cp w-cp ...' == Line 1545 has weird spacing: '... | f-cp f-cp ...' == 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 (October 30, 2017) is 2370 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 4091 (Obsoleted by RFC 5245) -- Obsolete informational reference (is this intentional?): RFC 4092 (Obsoleted by RFC 5245) -- Obsolete informational reference (is this intentional?): RFC 4566 (Obsoleted by RFC 8866) -- 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-14 Summary: 4 errors (**), 0 flaws (~~), 8 warnings (==), 7 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: May 3, 2018 jdrosen.net 7 October 30, 2017 9 Interactive Connectivity Establishment (ICE): A Protocol for Network 10 Address Translator (NAT) Traversal 11 draft-ietf-ice-rfc5245bis-14 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 May 3, 2018. 40 Copyright Notice 42 Copyright (c) 2017 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 . . . . . . . . . . . . . . . . . . . . . . . 12 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 . . . . . . . . . . . . . . . . . . . 18 80 5.1.1. Gathering Candidates . . . . . . . . . . . . . . . . 18 81 5.1.1.1. Host Candidates . . . . . . . . . . . . . . . . . 18 82 5.1.1.2. Server Reflexive and Relayed Candidates . . . . . 20 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 . . . . . . . . . . . . 25 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 . . . . . . . . . . . . . 29 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 . . . . . . . . . . . . . . . . . . . . . 38 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 . . . . . . . . . . . . . . . . . 39 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 . . . 49 139 8. Concluding ICE Processing . . . . . . . . . . . . . . . . . . 49 140 8.1. Procedures for Full Implementations . . . . . . . . . . . 49 141 8.1.1. Nominating Pairs . . . . . . . . . . . . . . . . . . 49 142 8.1.2. Updating States . . . . . . . . . . . . . . . . . . . 50 143 8.2. Procedures for Lite Implementations . . . . . . . . . . . 51 144 8.3. Freeing Candidates . . . . . . . . . . . . . . . . . . . 52 145 8.3.1. Full Implementation Procedures . . . . . . . . . . . 52 146 8.3.2. Lite Implementation Procedures . . . . . . . . . . . 52 147 9. ICE Restarts . . . . . . . . . . . . . . . . . . . . . . . . 52 148 10. ICE Option . . . . . . . . . . . . . . . . . . . . . . . . . 53 149 11. Keepalives . . . . . . . . . . . . . . . . . . . . . . . . . 53 150 12. Data Handling . . . . . . . . . . . . . . . . . . . . . . . . 54 151 12.1. Sending Data . . . . . . . . . . . . . . . . . . . . . . 54 152 12.2. Procedures for Lite Implementations . . . . . . . . . . 55 153 12.3. Procedures for All Implementations . . . . . . . . . . . 55 154 13. Receiving Data . . . . . . . . . . . . . . . . . . . . . . . 56 155 14. Extensibility Considerations . . . . . . . . . . . . . . . . 56 156 15. Setting Ta and RTO . . . . . . . . . . . . . . . . . . . . . 57 157 15.1. General . . . . . . . . . . . . . . . . . . . . . . . . 57 158 15.2. Ta . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 159 15.3. RTO . . . . . . . . . . . . . . . . . . . . . . . . . . 59 160 16. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 161 17. Security Considerations . . . . . . . . . . . . . . . . . . . 64 162 17.1. Attacks on Connectivity Checks . . . . . . . . . . . . . 65 163 17.2. Attacks on Server Reflexive Address Gathering . . . . . 67 164 17.3. Attacks on Relayed Candidate Gathering . . . . . . . . . 68 165 17.4. Insider Attacks . . . . . . . . . . . . . . . . . . . . 68 166 17.4.1. STUN Amplification Attack . . . . . . . . . . . . . 68 167 18. STUN Extensions . . . . . . . . . . . . . . . . . . . . . . . 69 168 18.1. New Attributes . . . . . . . . . . . . . . . . . . . . . 69 169 18.2. New Error Response Codes . . . . . . . . . . . . . . . . 70 170 19. Operational Considerations . . . . . . . . . . . . . . . . . 70 171 19.1. NAT and Firewall Types . . . . . . . . . . . . . . . . . 70 172 19.2. Bandwidth Requirements . . . . . . . . . . . . . . . . . 71 173 19.2.1. STUN and TURN Server Capacity Planning . . . . . . . 71 174 19.2.2. Gathering and Connectivity Checks . . . . . . . . . 71 175 19.2.3. Keepalives . . . . . . . . . . . . . . . . . . . . . 72 176 19.3. ICE and ICE-lite . . . . . . . . . . . . . . . . . . . . 72 177 19.4. Troubleshooting and Performance Management . . . . . . . 72 178 19.5. Endpoint Configuration . . . . . . . . . . . . . . . . . 73 179 20. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 73 180 20.1. STUN Attributes . . . . . . . . . . . . . . . . . . . . 73 181 20.2. STUN Error Responses . . . . . . . . . . . . . . . . . . 73 182 20.3. ICE Options . . . . . . . . . . . . . . . . . . . . . . 73 183 21. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 74 184 21.1. Problem Definition . . . . . . . . . . . . . . . . . . . 74 185 21.2. Exit Strategy . . . . . . . . . . . . . . . . . . . . . 75 186 21.3. Brittleness Introduced by ICE . . . . . . . . . . . . . 75 187 21.4. Requirements for a Long-Term Solution . . . . . . . . . 76 188 21.5. Issues with Existing NAPT Boxes . . . . . . . . . . . . 77 189 22. Changes from RFC 5245 . . . . . . . . . . . . . . . . . . . . 77 190 23. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 77 191 24. References . . . . . . . . . . . . . . . . . . . . . . . . . 78 192 24.1. Normative References . . . . . . . . . . . . . . . . . . 78 193 24.2. Informative References . . . . . . . . . . . . . . . . . 78 194 Appendix A. Lite and Full Implementations . . . . . . . . . . . 82 195 Appendix B. Design Motivations . . . . . . . . . . . . . . . . . 83 196 B.1. Pacing of STUN Transactions . . . . . . . . . . . . . . . 83 197 B.2. Candidates with Multiple Bases . . . . . . . . . . . . . 85 198 B.3. Purpose of the Related Address and Related Port 199 Attributes . . . . . . . . . . . . . . . . . . . . . . . 87 200 B.4. Importance of the STUN Username . . . . . . . . . . . . . 87 201 B.5. The Candidate Pair Priority Formula . . . . . . . . . . . 89 202 B.6. Why Are Keepalives Needed? . . . . . . . . . . . . . . . 89 203 B.7. Why Prefer Peer Reflexive Candidates? . . . . . . . . . . 90 204 B.8. Why Are Binding Indications Used for Keepalives? . . . . 90 205 B.9. Selecting Candidate Type Preference . . . . . . . . . . . 90 206 Appendix C. Connectivity Check Bandwidth . . . . . . . . . . . . 91 207 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 92 209 1. Introduction 211 Protocols establishing communication sessions between peers typically 212 involve exchanging IP addresses and ports for the data sources and 213 sinks. However this poses challenges when operated through Network 214 Address Translators (NATs) [RFC3235]. These protocols also seek to 215 create a data flow directly between participants, so that there is no 216 application layer intermediary between them. This is done to reduce 217 data latency, decrease packet loss, and reduce the operational costs 218 of deploying the application. However, this is difficult to 219 accomplish through NATs. A full treatment of the reasons for this is 220 beyond the scope of this specification. 222 Numerous solutions have been defined for allowing these protocols to 223 operate through NATs. These include Application Layer Gateways 224 (ALGs), the Middlebox Control Protocol [RFC3303], the original Simple 225 Traversal of UDP Through NAT (STUN) [RFC3489] specification, and 226 Realm Specific IP [RFC3102] [RFC3103] along with session description 227 extensions needed to make them work, such as the Session Description 228 Protocol (SDP) [RFC4566] attribute for the Real Time Control Protocol 229 (RTCP) [RFC3605]. Unfortunately, these techniques all have pros and 230 cons which, make each one optimal in some network topologies, but a 231 poor choice in others. The result is that administrators and 232 implementors are making assumptions about the topologies of the 233 networks in which their solutions will be deployed. This introduces 234 complexity and brittleness into the system. What is needed is a 235 single solution that is flexible enough to work well in all 236 situations. 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 via mechanisms (for example, including in a offer/answer 245 exchange) and the connectivity checks are performed using Session 246 Traversal Utilities for NAT (STUN) specification [RFC5389]. ICE also 247 makes use of Traversal Using Relays around NAT (TURN) [RFC5766], an 248 extension to STUN. Because ICE exchanges a multiplicity of IP 249 addresses and ports for each data stream, it also allows for address 250 selection for multihomed and dual-stack hosts, and for this reason it 251 deprecates [RFC4091] and [RFC4092]. 253 2. Overview of ICE 255 In a typical ICE deployment, there are two endpoints (ICE agents) 256 that want to communicate. Note that ICE is not intended for NAT 257 traversal for the signaling protocol, which is assumed to be provided 258 via another mechanism. ICE assumes that the agents are able to 259 establish a signaling connection between each other. 261 Initially, the agents are ignorant of their own topologies. In 262 particular, the agents may or may not be behind NATs (or multiple 263 tiers of NATs). ICE allows the agents to discover enough information 264 about their topologies to potentially find one or more paths by which 265 they can establish a data session. 267 Figure 1 shows a typical ICE deployment. The agents are labelled L 268 and R. Both L and R are behind their own respective NATs though they 269 may not be aware of it. The type of NAT and its properties are also 270 unknown. L and R are capable of engaging in an candidate exchange 271 process, whose purpose is to set up a data session between L and R. 272 Typically, this exchange will occur through a signaling server (e.g., 273 SIP proxy). 275 In addition to the agents, a signaling server and NATs, ICE is 276 typically used in concert with STUN or TURN servers in the network. 277 Each agent can have its own STUN or TURN server, or they can be the 278 same. 280 +---------+ 281 +--------+ |Signaling| +--------+ 282 | STUN | |Server | | STUN | 283 | Server | +---------+ | Server | 284 +--------+ / \ +--------+ 285 / \ 286 / \ 287 / <- Signaling -> \ 288 / \ 289 +--------+ +--------+ 290 | NAT | | NAT | 291 +--------+ +--------+ 292 / \ 293 / \ 294 +-------+ +-------+ 295 | Agent | | Agent | 296 | L | | R | 297 +-------+ +-------+ 299 Figure 1: ICE Deployment Scenario 301 The basic idea behind ICE is as follows: each agent has a variety of 302 candidate transport addresses (combination of IP address and port for 303 a particular transport protocol, which is always UDP in this 304 specification) it could use to communicate with the other agent. 305 These might include: 307 o A transport address on a directly attached network interface 309 o A translated transport address on the public side of a NAT (a 310 "server reflexive" address) 312 o A transport address allocated from a TURN server (a "relayed 313 address") 315 Potentially, any of L's candidate transport addresses can be used to 316 communicate with any of R's candidate transport addresses. In 317 practice, however, many combinations will not work. For instance, if 318 L and R are both behind NATs, their directly attached interface 319 addresses are unlikely to be able to communicate directly (this is 320 why ICE is needed, after all!). The purpose of ICE is to discover 321 which pairs of addresses will work. The way that ICE does this is to 322 systematically try all possible pairs (in a carefully sorted order) 323 until it finds one or more that work. 325 2.1. Gathering Candidates 327 In order to execute ICE, an ICE agent has to identify all of its 328 address candidates. A candidate has a transport address -- a 329 combination of IP address and port for a particular transport 330 protocol (with only UDP specified here). There are different types 331 of candidates, some derived from physical or logical network 332 interfaces, others discoverable via STUN and TURN. Naturally, one 333 viable candidate has a transport address obtained directly from a 334 local interface. Such a candidate is called a host candidate. The 335 local interface could be Ethernet or WiFi, or it could be one that is 336 obtained through a tunnel mechanism, such as a Virtual Private 337 Network (VPN) or Mobile IP (MIP). In all cases, such a network 338 interface appears to the agent as a local interface from which ports 339 (and thus candidates) can be allocated. 341 Next, the agent uses STUN or TURN to obtain additional candidates. 342 These come in two flavors: translated addresses on the public side of 343 a NAT (server reflexive candidates) and addresses on TURN servers 344 (relayed candidates). When TURN servers are utilized, both types of 345 candidates are obtained from the TURN server. If only STUN servers 346 are utilized, only server reflexive candidates are obtained from 347 them. The relationship of these candidates to the host candidate is 348 shown in Figure 2. In this figure, both types of candidates are 349 discovered using TURN. In the figure, the notation X:x means IP 350 address X and UDP port x. 352 To Internet 354 | 355 | 356 | /------------ Relayed 357 Y:y | / Address 358 +--------+ 359 | | 360 | TURN | 361 | Server | 362 | | 363 +--------+ 364 | 365 | 366 | /------------ Server 367 X1':x1'|/ Reflexive 368 +------------+ Address 369 | NAT | 370 +------------+ 371 | 372 | /------------ Local 373 X:x |/ Address 374 +--------+ 375 | | 376 | Agent | 377 | | 378 +--------+ 380 Figure 2: Candidate Relationships 382 When the agent sends the TURN Allocate request from IP address and 383 port X:x, the NAT (assuming there is one) will create a binding 384 X1':x1', mapping this server reflexive candidate to the host 385 candidate X:x. Outgoing packets sent from the host candidate will be 386 translated by the NAT to the server reflexive candidate. Incoming 387 packets sent to the server reflexive candidate will be translated by 388 the NAT to the host candidate and forwarded to the agent. The host 389 candidate associated with a given server reflexive candidate is the 390 BASE. 392 Note: "Base" refers to the address an agent sends from for a 393 particular candidate. Thus, as a degenerate case, host candidates 394 also have a base, but it's the same as the host candidate. 396 When there are multiple NATs between the agent and the TURN server, 397 the TURN request will create a binding on each NAT, but only the 398 outermost server reflexive candidate (the one nearest the TURN 399 server) will be discovered by the agent. If the agent is not behind 400 a NAT, then the base candidate will be the same as the server 401 reflexive candidate and the server reflexive candidate is redundant 402 and will be eliminated. 404 The Allocate request then arrives at the TURN server. The TURN 405 server allocates a port y from its local IP address Y, and generates 406 an Allocate response, informing the agent of this relayed candidate. 407 The TURN server also informs the agent of the server reflexive 408 candidate, X1':x1' by copying the source transport address of the 409 Allocate request into the Allocate response. The TURN server acts as 410 a packet relay, forwarding traffic between L and R. In order to send 411 traffic to L, R sends traffic to the TURN server at Y:y, and the TURN 412 server forwards that to X1':x1', which passes through the NAT where 413 it is mapped to X:x and delivered to L. 415 When only STUN servers are utilized, the agent sends a STUN Binding 416 request [RFC5389] to its STUN server. The STUN server will inform 417 the agent of the server reflexive candidate X1':x1' by copying the 418 source transport address of the Binding request into the Binding 419 response. 421 2.2. Connectivity Checks 423 Once L has gathered all of its candidates, it orders them in highest 424 to lowest-priority and sends them to R over the signaling channel. 425 When R receives the candidates from L, it performs the same gathering 426 process and responds with its own list of candidates. At the end of 427 this process, each ICE agent has a complete list of both its 428 candidates and its peer's candidates. It pairs them up, resulting in 429 candidate pairs. To see which pairs work, each agent schedules a 430 series of connectivity checks. Each check is a STUN request/response 431 transaction that the client will perform on a particular candidate 432 pair by sending a STUN request from the local candidate to the remote 433 candidate. 435 The basic principle of the connectivity checks is simple: 437 1. Sort the candidate pairs in priority order. 439 2. Send checks on each candidate pair in priority order. 441 3. Acknowledge checks received from the other agent. 443 With both agents performing a check on a candidate pair, the result 444 is a 4-way handshake: 446 L R 447 - - 448 STUN request -> \ L's 449 <- STUN response / check 451 <- STUN request \ R's 452 STUN response -> / check 454 Figure 3: Basic Connectivity Check 456 It is important to note that the STUN requests are sent to and from 457 the exact same IP addresses and ports that will be used for data 458 (e.g., RTP, RTCP, or other protocols). Consequently, agents 459 demultiplex STUN and data using the contents of the packets, rather 460 than the port on which they are received. 462 Because a STUN Binding request is used for the connectivity check, 463 the STUN Binding response will contain the agent's translated 464 transport address on the public side of any NATs between the agent 465 and its peer. If this transport address is different from that of 466 other candidates the agent already learned, it represents a new 467 candidate (peer reflexive candidate), which then gets tested by ICE 468 just the same as any other candidate. 470 Because the algorithm above searches all candidate pairs, if a 471 working pair exists it will eventually find it no matter what order 472 the candidates are tried in. In order to produce faster (and better) 473 results, the candidates are sorted in a specified order. The 474 resulting list of sorted candidate pairs is called the check list. 476 The agent works through the check list by sending a STUN request for 477 the next candidate pair on the list periodically. These are called 478 ordinary checks. 480 As an optimization, as soon as R gets L's check message, R schedules 481 a connectivity check message to be sent to L on the same candidate 482 pair. This accelerates the process of finding a valid candidate, and 483 is called a triggered check. 485 At the end of this handshake, both L and R know that they can send 486 (and receive) messages end-to-end in both directions. 488 In general, the priority algorithm is designed so that candidates of 489 similar type get similar priorities and so that more direct routes 490 (that is, through fewer data relays and through fewer NATs) are 491 preferred over indirect ones (ones with more data relays and more 492 NATs). Within those guidelines, however, agents have a fair amount 493 of discretion about how to tune their algorithms. 495 A data stream might consist of multiple components (pieces of a data 496 stream that require their own set of candidates, e.g., RTP and RTCP). 498 2.3. Nominating Candidate Pairs And Concluding ICE 500 ICE assigns one of the ICE agents in the role of the controlling 501 agent, and the other of the controlled agent. For each component of 502 a data stream, the controlling agent nominates a candidate pair from 503 the valid candidate pairs to be used for data. The exact timing of 504 the nomination is based on local policy. 506 When nominating, the controlling agent lets the checks continue until 507 at least one valid candidate pair for each component of a data stream 508 is found and then picks a candidate pair from the valid candidate 509 pairs and sends a STUN request on the pair, using an attribute to 510 indicate to the controlled peer that it has nominated the pair. This 511 is shown in Figure 4. 513 L R 514 - - 515 STUN request -> \ L's 516 <- STUN response / check 518 <- STUN request \ R's 519 STUN response -> / check 521 STUN request + flag -> \ L's 522 <- STUN response / check 524 Figure 4: Nomination 526 Once the controlled agent receives the STUN request with the 527 attribute, it will check (unless the check has already been done) the 528 same pair. If the transactions above succeed, the agents will set 529 the nominated flag for the pairs, and will cancel any future checks 530 for that component of the data stream. Once an agent has set the 531 nominated flag for each component of a data stream, the pairs become 532 the selected pairs. After that, only the selected pairs will be used 533 for sending and receiving data associated with that data stream. 535 2.4. ICE Restart 537 Once ICE is concluded, it can be restarted at any time for one or all 538 of the data streams by either ICE agent. This is done by sending an 539 updated candidate information indicating a restart. 541 2.5. Lite Implementations 543 Certain ICE agents will always be connected to the public Internet 544 and have a public IP address at which it can receive packets from any 545 correspondent. To make it easier for these devices to support ICE, 546 ICE defines a special type of implementation called lite (in contrast 547 to the normal full implementation). Lite agents only use host 548 candidates and do not generate connectivity checks or run the state 549 machines, though they need to be able to respond to connectivity 550 checks. 552 3. ICE Usage 554 This document specifies generic use of ICE with protocols that 555 provide means to exchange candidate information between the ICE 556 agents. The specific details of (i.e how to encode candidate 557 information and the actual candidate exchange process) for different 558 protocols using ICE (referred to as using protocol) are described in 559 separate usage documents. 561 One mechanism for agents to exchange the candidate information by 562 using [RFC3264] based Offer/Answer semantics as part of the SIP 563 [RFC3261] protocol [I-D.ietf-mmusic-ice-sip-sdp]. 565 4. Terminology 567 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 568 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 569 "OPTIONAL" in this document are to be interpreted as described in RFC 570 2119 [RFC2119]. 572 Readers should be familiar with the terminology defined in the STUN 573 [RFC5389], and NAT Behavioral requirements for UDP [RFC4787]. 575 This specification makes use of the following additional terminology: 577 ICE Session: An ICE session consists of all ICE-related actions 578 starting with the candidate gathering, followed by the 579 interactions (candidate exchange, connectivity checks, nominations 580 and keep-alives) between the ICE agents until all the candidates 581 are released or ICE-restart is triggered. 583 ICE Agent, Agent: An ICE agent (sometimes simply referred to as an 584 agent) is the protocol implementation involved in the ICE 585 candidate exchange. There are two agents involved in a typical 586 candidate exchange. 588 Initiating Peer, Initiating Agent, Initiator: An initiating agent is 589 an ICE agent that initiates the ICE candidate exchange process. 591 Responding Peer, Responding Agent, Responder: A receiving agent is 592 an ICE agent that receives and responds to the candidate exchange 593 process initiated by the initiating agent. 595 ICE Candidate Exchange, Candidate Exchange: The process where the 596 ICE agents exchange information (e.g., candidates and passwords) 597 that is needed to perform ICE. [RFC3264] Offer/Answer with SDP 598 encoding is one example of a protocol that can be used for 599 exchanging the candidate information. 601 Peer: From the perspective of one of the ICE agents in a session, 602 its peer is the other agent. Specifically, from the perspective 603 of the initiating agent, the peer is the responding agent. From 604 the perspective of the responding agent, the peer is the 605 initiating agent. 607 Transport Address: The combination of an IP address and transport 608 protocol (such as UDP or TCP) port. 610 Data, Data Stream, Data Session: When ICE is used to setup data 611 sessions, the data is transported using some protocol. Media is 612 usually transported over RTP, composed of a stream of RTP packets. 613 Data session refers to data packets that are exchanged between the 614 peer on the path created and tested with ICE. 616 Candidate, Candidate Information: A transport address that is a 617 potential point of contact for receipt of data. Candidates also 618 have properties -- their type (server reflexive, relayed, or 619 host), priority, foundation, and base. 621 Component: A component is a piece of a data stream. A data stream 622 may require multiple components, each of which has to work in 623 order for the data stream as a whole to work. For RTP/RTCP data 624 streams, unless RTP and RTCP are multiplexed in the same port, 625 there are two components per data stream -- one for RTP, and one 626 for RTCP. A component has a candidate pair, which cannot be used 627 by other components 629 Host Candidate: A candidate obtained by binding to a specific port 630 from an IP address on the host. This includes IP addresses on 631 physical interfaces and logical ones, such as ones obtained 632 through Virtual Private Networks (VPNs). 634 Server Reflexive Candidate: A candidate whose IP address and port 635 are a binding allocated by a NAT for an ICE agent when it sent a 636 packet through the NAT to a server, such as a STUN server. 638 Peer Reflexive Candidate: A candidate whose IP address and port are 639 a binding allocated by a NAT for an ICE agent when it sent a 640 packet through the NAT to its peer. 642 Relayed Candidate: A candidate obtained from a relay server, such as 643 a TURN server. 645 Base: The transport address that an ICE agent sends from for a 646 particular candidate. For host, server reflexive and peer 647 reflexive candidates the base is the same as the host candidate. 648 For relayed candidates the base is the same as the relayed 649 candidate (i.e., the transport address used by the TURN server to 650 send from). 652 Foundation: An arbitrary string used in the freezing algorithm to 653 group similar candidates. Is the same for two candidates that 654 have the same type, base IP address, protocol (UDP, TCP, etc.), 655 and STUN or TURN server. If any of these are different, then the 656 foundation will be different. 658 Local Candidate: A candidate that an ICE agent has obtained and may 659 send to its peer. 661 Remote Candidate: A candidate that an ICE agent received from its 662 peer. 664 Default Destination/Candidate: The default destination for a 665 component of a data stream is the transport address that would be 666 used by an ICE agent that is not ICE-aware. A default candidate 667 for a component is one whose transport address matches the default 668 destination for that component. 670 Candidate Pair: A pair of a local candidate and a remote candidate. 672 Check, Connectivity Check, STUN Check: A STUN Binding request for 673 the purposes of verifying connectivity. A check is sent from the 674 base of the local candidate to the remote candidate of a candidate 675 pair. 677 Check List: An ordered set of candidate pairs that an ICE agent will 678 use to generate checks. 680 Ordinary Check: A connectivity check generated by an ICE agent as a 681 consequence of a timer that fires periodically, instructing it to 682 send a check. 684 Triggered Check: A connectivity check generated as a consequence of 685 the receipt of a connectivity check from the peer. 687 Valid List: An ordered set of candidate pairs for a data stream that 688 have been validated by a successful STUN transaction. 690 Check List Set: The ordered list of all check lists. The order is 691 determined by each ICE usage. 693 Full Implementation: An ICE implementation that performs the 694 complete set of functionality defined by this specification. 696 Lite Implementation: An ICE implementation that omits certain 697 functions, implementing only as much as is necessary for a peer 698 implementation that is full to gain the benefits of ICE. Lite 699 implementations do not maintain any of the state machines and do 700 not generate connectivity checks. 702 Controlling Agent: The ICE agent that nominates a candidate pair. 703 In any session, one agent is always controlling. The other is the 704 controlled agent. 706 Controlled Agent: The ICE agent that waits for the controlling agent 707 to nominate a candidate pair. 709 Nomination, Regular Nomination: The process of the controlling agent 710 indicating to the controlled agent which candidate pair the ICE 711 agents should use for sending and receiving data. 713 Nominated, Nominated Flag: Once the nomination of a candidate pair 714 has succeeded, the candidate pair has become nominated, and the 715 value of its nominated flag is set to true. 717 Selected Pair, Selected Candidate Pair: The candidate pair used for 718 sending and receiving data for a component of a data stream is 719 referred to as the selected pair. Before selected pairs have been 720 produced for a data stream, any valid candidate pair associated 721 with a component of a data stream can be used for sending and 722 receiving data for the component. Once there are nominated pairs 723 for each component of a data stream, the nominated pairs become 724 the selected pairs for the data stream. The candidates associated 725 with the selected pairs are referred to as selected candidates. 727 Using Protocol, ICE Usage: The protocol that uses ICE for NAT 728 traversal. A usage specification defines the protocol-specific 729 details on how the procedures defined here are applied to that 730 protocol. 732 5. ICE Candidate Gathering and Exchange 734 As part of ICE processing, both the initiating and responding agents 735 exchange encoded candidate information as defined by the Usage 736 Protocol (ICE Usage). Specifics of the encoding mechanism and the 737 semantics of candidate information exchange is out of scope of this 738 specification. 740 However at a higher level, the diagram below shows how the ICE agents 741 (initiator and responder) exchange their respective candidate(s) 742 information. 744 Initiating Responding 745 Agent Agent 746 (I) (R) 747 Gather, | | 748 prioritize, | | 749 eliminate | | 750 redundant | | 751 candidates, | | 752 Encode | | 753 candidates | | 754 | I's Candidate Information | 755 |------------------------------>| 756 | | Gather, 757 | | prioritize, 758 | | eliminate 759 | | redundant 760 | | candidates, 761 | | Encode 762 | | candidates 763 | R's Candidate Information | 764 |<------------------------------| 765 | | 767 Figure 5: Candidate Gathering and Exchange Sequence 769 As shown, the agents involved in the candidate exchange perform (1) 770 candidate gathering, (2) candidate prioritization, (3) redundant 771 candidate elimination, (4) (possibly) default candidate selection, 772 and (5) sending of the candidates to the peer. All but the last of 773 these five steps differ for full and lite implementations. 775 5.1. Full Implementation 777 5.1.1. Gathering Candidates 779 An ICE agent gathers candidates when it believes that communication 780 is imminent. An initiating agent can do this based on a user 781 interface cue, or based on an explicit request to initiate a session. 782 Every candidate has a transport address. It also has a type and a 783 base. Four types are defined and gathered by this specification -- 784 host candidates, server reflexive candidates, peer reflexive 785 candidates, and relayed candidates. The server reflexive candidates 786 are gathered using STUN or TURN, and relayed candidates are obtained 787 through TURN. Peer reflexive candidates are obtained in later phases 788 of ICE, as a consequence of connectivity checks. 790 The process for gathering candidates at the responding agent is 791 identical to the process for the initiating agent. It is RECOMMENDED 792 that the responding agent begins this process immediately on receipt 793 of the candidate information, prior to alerting the user of the 794 application associated with the ICE session. Such gathering MAY 795 begin when an agent starts. 797 5.1.1.1. Host Candidates 799 Host candidates are obtained by binding to ports on an IP address 800 attached to an interface (physical or virtual, including VPN 801 interfaces) on the host. 803 For each component of each data stream the ICE agent wishes to use, 804 the agent SHOULD obtain a candidate on each IP address that the host 805 has, with the exceptions listed below. The agent obtains each 806 candidate by binding to a UDP port on the specific IP address. A 807 host candidate (and indeed every candidate) is always associated with 808 a specific component for which it is a candidate. 810 Each component has an ID assigned to it, called the component ID. 811 For RTP/RTCP data streams, unless both RTP and RTCP are multiplexed 812 in the same UDP port (RTP/RTCP multiplexing), the RTP itself has a 813 component ID of 1, and RTCP a component ID of 2. In case of RTP/RTCP 814 multiplexing, a component ID of 1 is used for both RTP and RTCP. 816 When candidates are obtained, unless the agent knows for sure that 817 RTP/RTCP multiplexing will be used (i.e. the agent knows that the 818 other agent also supports, and is willing to use, RTP/RTCP 819 multiplexing), or unless the agent only supports RTP/RTCP 820 multiplexing, the agent MUST obtain a separate candidate for RTCP. 821 If an agent has obtained a candidate for RTCP, and ends up using RTP/ 822 RTCP multiplexing, the agent does not need to perform connectivity 823 checks on the RTCP candidate. Absence of a component ID 2 as such 824 does not imply use of RTCP/RTP multiplexing, as it could also mean 825 that RTCP is not used. 827 If an agent is using separate candidates for RTP and RTCP, it will 828 end up with 2*K host candidates if an agent has K IP addresses. 830 Note that the responding agent, when obtaining its candidates, will 831 typically know if the other agent supports RTP/RTCP multiplexing, in 832 which case it will not need to obtain a separate candidate for RTCP. 833 However, absence of a component ID 2 as such does not imply use of 834 RTCP/RTP multiplexing, as it could also mean that RTCP is not used. 836 For other than RTP/RTCP streams, use of multiple components is 837 discouraged since using them increases the complexity of ICE 838 processing. If multiple components are needed, the component IDs 839 SHOULD start with 1 and increase by 1 for each component. 841 The base for each host candidate is set to the candidate itself. 843 The host candidates are gathered from all IP addresses with the 844 following exceptions: 846 o Addresses from a loopback interface MUST NOT be included in the 847 candidate addresses. 849 o Deprecated IPv4-compatible IPv6 addresses [RFC4291] and IPv6 site- 850 local unicast addresses [RFC3879] MUST NOT be included in the 851 address candidates. 853 o IPv4-mapped IPv6 addresses SHOULD NOT be included in the address 854 candidates unless the application using ICE does not support IPv4 855 (i.e., is an IPv6-only application [RFC4038]). 857 o If one or more host candidates corresponding to an IPv6 address 858 generated using a mechanism that prevents location tracking 859 [RFC7721] are gathered, host candidates corresponding to IPv6 860 addresses that do allow location tracking, that are configured on 861 the same interface, and are part of the same network prefix MUST 862 NOT be gathered. 864 o Host candidates corresponding to IPv6 link-local addresses MUST 865 NOT be gathered. 867 The IPv6 default address selection specification [RFC6724] specifies 868 that temporary addresses [RFC4941] are to be preferred over permanent 869 addresses. 871 5.1.1.2. Server Reflexive and Relayed Candidates 873 An ICE agent SHOULD gather server reflexive and relayed candidates. 874 These requirements are at SHOULD strength to allow for provider 875 variation. Use of STUN and TURN servers may be unnecessary in 876 certain networks and use of TURN servers may be expensive, so some 877 deployments may elect not to use them. If an agent does not gather 878 server reflexive or relayed candidates, it is RECOMMENDED that the 879 functionality be implemented and just disabled through configuration, 880 so that it can be re-enabled through configuration if conditions 881 change in the future. 883 The agent pairs each host candidate with the STUN or TURN servers 884 with which it is configured or has discovered by some means. It is 885 RECOMMENDED that a domain name be configured, and the DNS procedures 886 in [RFC5389] (using SRV records with the "stun" service) be used to 887 discover the STUN server, and the DNS procedures in [RFC5766] (using 888 SRV records with the "turn" service) be used to discover the TURN 889 server. 891 When multiple STUN or TURN servers are available (or when they are 892 learned through DNS records and multiple results are returned), the 893 agent MAY gather candidates for all of them and SHOULD gather 894 candidates for at least one of them (one STUN server and one TURN 895 server). It does so by pairing host candidates with STUN or TURN 896 servers and, for each pair, the agent sends a Binding or Allocate 897 request to the server from the host candidate. Binding requests to a 898 STUN server are not authenticated, and any ALTERNATE-SERVER attribute 899 in a response is ignored. Agents MUST support the backwards 900 compatibility mode for the Binding request defined in [RFC5389]. 901 Allocate requests SHOULD be authenticated using a long-term 902 credential obtained by the client through some other means. 904 The gathering process is controlled using a timer, Ta. Every time Ta 905 expires, the agent can generate another new STUN or TURN transaction. 906 This transaction can either be a retry of a previous transaction that 907 failed with a recoverable error (such as authentication failure), or 908 a transaction for a new host candidate and STUN or TURN server pair. 909 The agent SHOULD NOT generate transactions more frequently than one 910 every time Ta expires. See Section 15 for guidance on how to set Ta 911 and the STUN retransmit timer, RTO. 913 The agent will receive a Binding or Allocate response. A successful 914 Allocate response will provide the agent with a server reflexive 915 candidate (obtained from the mapped address) and a relayed candidate 916 in the XOR-RELAYED-ADDRESS attribute. If the Allocate request is 917 rejected because the server lacks resources to fulfill it, the agent 918 SHOULD instead send a Binding request to obtain a server reflexive 919 candidate. A Binding response will provide the agent with only a 920 server reflexive candidate (also obtained from the mapped address). 921 The base of the server reflexive candidate is the host candidate from 922 which the Allocate or Binding request was sent. The base of a 923 relayed candidate is that candidate itself. If a relayed candidate 924 is identical to a host candidate (which can happen in rare cases), 925 the relayed candidate MUST be discarded. 927 If an IPv6-only agent is in a network that utilizes NAT64 [RFC6146] 928 and DNS64 [RFC6147] technologies, it may also gather IPv4 server 929 reflexive and/or relayed candidates from IPv4-only STUN or TURN 930 servers. IPv6-only agents SHOULD also utilize IPv6 prefix discovery 931 [RFC7050] to discover the IPv6 prefix used by NAT64 (if any) and 932 generate server reflexive candidates for each IPv6-only interface 933 accordingly. The NAT64 server reflexive candidates are prioritized 934 like IPv4 server reflexive candidates. 936 5.1.1.3. Computing Foundations 938 The ICE agent assigns each candidate a foundation. Two candidates 939 MUST have the same foundation when all of the following are true: 941 o They have the same type (host, relayed, server reflexive, or peer 942 reflexive). 944 o Their bases have the same IP address (the ports can be different). 946 o For reflexive and relayed candidates, the STUN or TURN servers 947 used to obtain them have the same IP address. 949 o They were obtained using the same transport protocol (TCP, UDP). 951 Similarly, two candidates MUST have different foundations if their 952 types are different, their bases have different IP addresses, the 953 STUN or TURN servers used to obtain them have different IP addresses, 954 or their transport protocols are different. 956 5.1.1.4. Keeping Candidates Alive 958 Once server reflexive and relayed candidates are allocated, they MUST 959 be kept alive until ICE processing has completed, as described in 960 Section 8.3. For server reflexive candidates learned through a 961 Binding request, the bindings MUST be kept alive by additional 962 Binding requests to the server. Refreshes for allocations are done 963 using the Refresh transaction, as described in [RFC5766]. The 964 Refresh requests will also refresh the server reflexive candidate. 966 Host candidates do not time out, but the candidate addresses may 967 change or disappear for a number of reasons. An ICE agent SHOULD 968 monitor the interfaces it uses, invalidate candidates whose base has 969 gone away, and acquire new candidates as appropriate when new 970 interfaces appear. 972 5.1.2. Prioritizing Candidates 974 The prioritization process results in the assignment of a priority to 975 each candidate. Each candidate for a data stream MUST have a unique 976 priority that MUST be a positive integer between 1 and (2**31 - 1). 977 This priority will be used by ICE to determine the order of the 978 connectivity checks and the relative preference for candidates. 980 An ICE agent SHOULD compute this priority using the formula in 981 Section 5.1.2.1 and choose its parameters using the guidelines in 982 Section 5.1.2.2. If an agent elects to use a different formula, ICE 983 may take longer to converge since the agents will not be coordinated 984 in their checks. 986 The process for prioritizing candidates is common across the 987 initiating and the responding agent. 989 5.1.2.1. Recommended Formula 991 The recommended formula combines a preference for the candidate type 992 (server reflexive, peer reflexive, relayed, and host), a preference 993 for IP address for which the candidate was obtained, and component ID 994 using the following formula: 996 priority = (2^24)*(type preference) + 997 (2^8)*(local preference) + 998 (2^0)*(256 - component ID) 1000 The type preference MUST be an integer from 0 (lowest preference) to 1001 126 (highest preference) inclusive and MUST be identical for all 1002 candidates of the same type and MUST be different for candidates of 1003 different types. The type preference for peer reflexive candidates 1004 MUST be higher than that of server reflexive candidates. Setting the 1005 value to 0 means that candidates of this type will only be used as a 1006 last resort. Note that candidates gathered based on the procedures 1007 of Section 5.1.1 will never be peer reflexive candidates; candidates 1008 of these type are learned from the connectivity checks performed by 1009 ICE. 1011 The local preference MUST be an integer from 0 (lowest preference) to 1012 65535 (highest preference) inclusive. When there is only a single IP 1013 address, this value SHOULD be set to 65535. If there are multiple 1014 candidates for a particular component for a particular data stream 1015 that have the same type, the local preference MUST be unique for each 1016 one. If an ICE agent is dual-stack, the local preference should be 1017 set according to the current best practice described in 1018 [I-D.ietf-ice-dualstack-fairness]. 1020 The component ID MUST be an integer between 1 and 256 inclusive. 1022 5.1.2.2. Guidelines for Choosing Type and Local Preferences 1024 The RECOMMENDED values for type preferences are 126 for host 1025 candidates, 110 for peer reflexive candidates, 100 for server 1026 reflexive candidates, and 0 for relayed candidates. 1028 If an ICE agent is multihomed and has multiple IP addresses, the 1029 recommendations in [I-D.ietf-ice-dualstack-fairness] SHOULD be 1030 followed. If multiple TURN servers are used, local priorities for 1031 the candidates obtained from the TURN servers are chosen in a similar 1032 fashion as for multihomed local candidates: the local preference 1033 value is used to indicate a preference among different servers but 1034 the preference MUST be unique for each one. 1036 When choosing type preferences, agents may take into account factors 1037 such as latency, packet loss, cost, network topology, security, 1038 privacy, and others. 1040 5.1.3. Eliminating Redundant Candidates 1042 Next, the ICE agents (initiating and responding) eliminate redundant 1043 candidates. Two candidates can have the same transport address yet 1044 have different bases, and these would not be considered redundant. 1045 Frequently, a server reflexive candidate and a host candidate will be 1046 redundant when the agent is not behind a NAT. A candidate is 1047 redundant if and only if its transport address and base equal those 1048 of another candidate. The agent SHOULD eliminate the redundant 1049 candidate with the lower priority. 1051 5.2. Lite Implementation Procedures 1053 Lite implementations only utilize host candidates. A lite 1054 implementation MUST, for each component of each data stream, allocate 1055 zero or one IPv4 candidates. It MAY allocate zero or more IPv6 1056 candidates, but no more than one per each IPv6 address utilized by 1057 the host. Since there can be no more than one IPv4 candidate per 1058 component of each data stream, if an ICE agent has multiple IPv4 1059 addresses, it MUST choose one for allocating the candidate. If a 1060 host is dual-stack, it is RECOMMENDED that it allocate one IPv4 1061 candidate and one global IPv6 address. With the lite implementation, 1062 ICE cannot be used to dynamically choose amongst candidates. 1063 Therefore, including more than one candidate from a particular scope 1064 is NOT RECOMMENDED, since only a connectivity check can truly 1065 determine whether to use one address or the other. 1067 Each component has an ID assigned to it, called the component ID. 1068 For RTP/RTCP data streams, unless RTCP is multiplexed in the same 1069 port with RTP, the RTP itself has a component ID of 1, and RTCP a 1070 component ID of 2. If an agent is using RTCP without multiplexing, 1071 it MUST obtain candidates for it. However, absence of a component ID 1072 2 as such does not imply use of RTCP/RTP multiplexing, as it could 1073 also mean that RTCP is not used. 1075 Each candidate is assigned a foundation. The foundation MUST be 1076 different for two candidates allocated from different IP addresses, 1077 and MUST be the same otherwise. A simple integer that increments for 1078 each IP address will suffice. In addition, each candidate MUST be 1079 assigned a unique priority amongst all candidates for the same data 1080 stream. This priority SHOULD be equal to: 1082 priority = (2^24)*(126) + 1083 (2^8)*(IP precedence) + 1084 (2^0)*(256 - component ID) 1086 If a host is v4-only, it SHOULD set the IP precedence to 65535. If a 1087 host is v6 or dual-stack, the IP precedence SHOULD be the precedence 1088 value for IP addresses described in RFC 6724 [RFC6724]. 1090 Next, an agent chooses a default candidate for each component of each 1091 data stream. If a host is IPv4-only, there would only be one 1092 candidate for each component of each data stream, and therefore that 1093 candidate is the default. If a host is IPv6 or dual-stack, the 1094 selection of default is a matter of local policy. This default 1095 SHOULD be chosen such that it is the candidate most likely to be used 1096 with a peer. For IPv6-only hosts, this would typically be a globally 1097 scoped IPv6 address. For dual-stack hosts, the IPv4 address is 1098 RECOMMENDED. 1100 The procedures in this section is common across the initiating and 1101 responding agents. 1103 5.3. Exchanging Candidate Information 1105 ICE agents (initiating and responding) need the following information 1106 about candidates to be exchanged. Each ICE usage MUST define how the 1107 information is exchanged with the using protocol. This section 1108 describes the information that needs to be exchanged. 1110 Candidates: One or more candidates. For each candidate: 1112 Address: The IP address and transport protocol port of the 1113 candidate. 1115 Transport: The transport protocol of the candidate. This MAY be 1116 omitted if the using protocol only runs over a single transport 1117 protocol. 1119 Foundation: A sequence of up to 32 characters. 1121 Component ID: The component ID of the candidate. This MAY be 1122 omitted if the using protocol does not use the concept of 1123 components. 1125 Priority: The 32-bit priority of the candidate. 1127 Type: The type of the candidate. 1129 Related Address and Port: The related IP address and port of the 1130 candidate. These MAY be omitted or set to invalid values if 1131 the agent does not want to reveal them, e.g., for privacy 1132 reasons. 1134 Extensibility Parameters: The using protocol should define some 1135 means for adding new per-candidate ICE parameters in the 1136 future. 1138 Lite or Full: Whether the agent is a lite agent or full agent. 1140 Connectivity check pacing value: The pacing value for connectivity 1141 checks that the agent wishes to use. This MAY be omitted if the 1142 agent wishes to use a defined default value. 1144 Username Fragment and Password: Values used to perform connectivity 1145 checks. The username fragment MUST contain at least 24 bits of 1146 randomness, and the password MUST contain at least 128 bits of 1147 randomness. 1149 Extensions: New media-stream or session-level attributes (ice- 1150 options). 1152 If the using protocol is vulnerable to, and able to detect, ICE 1153 mismatch (Section 5.4), a way is needed for the detecting agent to 1154 convey this information to its peer. It is a boolean flag. 1156 The using protocol may (or may not) need to deal with backwards 1157 compatibility with older implementations that do not support ICE. If 1158 the fallback mechanism is being used, then presumably the using 1159 protocol provides a way of conveying the default candidate (its IP 1160 address and port) in addition to the ICE parameters. 1162 Once an agent has sent its candidate information, it MUST be prepared 1163 to receive both STUN and data packets on each candidate. As 1164 discussed in Section 12.1, data packets can be sent to a candidate 1165 prior to its appearance as the default destination for data. 1167 5.4. ICE Mismatch 1169 Certain middleboxes, such as ALGs, can alter signaling information in 1170 ways that break ICE. This is referred to as ICE mismatch. If the 1171 using protocol is vulnerable to ICE mismatch, the responding agent 1172 needs to be able to detect it and inform the peer ICE agent about the 1173 ICE mismatch. 1175 Each using protocol needs to define whether the using protocol is 1176 vulnerable to ICE mismatch, how ICE mismatch is detected, and whether 1177 specific actions need to be taken when ICE mismatch is detected. 1179 6. ICE Candidate Processing 1181 Once an ICE agent has gathered its candidates and exchanged 1182 candidates with its peer (Section 5), it will determine its own role. 1183 In addition, full implementations will form check lists, and begin 1184 performing connectivity checks with the peer. 1186 6.1. Procedures for Full Implementation 1188 6.1.1. Determining Role 1190 For each session, each ICE agent (Initiating and Responding) takes on 1191 a role. There are two roles -- controlling and controlled. The 1192 controlling agent is responsible for the choice of the final 1193 candidate pairs used for communications. For a full agent, this 1194 means nominating the candidate pairs that can be used by ICE for each 1195 data stream, and for updating the peer with the ICE's selection, when 1196 needed. The controlled agent is told which candidate pairs to use 1197 for each data stream, and does not require updating the peer to 1198 signal this information. The sections below describe in detail the 1199 actual procedures followed by controlling and controlled nodes. 1201 The rules for determining the role and the impact on behavior are as 1202 follows: 1204 Both agents are full: The initiating agent which started the ICE 1205 processing MUST take the controlling role, and the other MUST take 1206 the controlled role. Both agents will form check lists, run the 1207 ICE state machines, and generate connectivity checks. The 1208 controlling agent will execute the logic in Section 8.1 to 1209 nominate pairs that will become (if the connectivity checks 1210 associated with the nominations succeed) the selected pairs, and 1211 then both agents end ICE as described in Section 8.1.2. 1213 One agent full, one lite: The full agent MUST take the controlling 1214 role, and the lite agent MUST take the controlled role. The full 1215 agent will form check lists, run the ICE state machines, and 1216 generate connectivity checks. That agent will execute the logic 1217 in Section 8.1 to nominate pairs that will become (if the 1218 connectivity checks associated with the nominations succeed) the 1219 selected pairs, and use the logic in Section 8.1.2 to end ICE. 1220 The lite implementation will just listen for connectivity checks, 1221 receive them and respond to them, and then conclude ICE as 1222 described in Section 8.2. For the lite implementation, the state 1223 of ICE processing for each data stream is considered to be 1224 Running, and the state of ICE overall is Running. 1226 Both lite: The initiating agent which started the ICE processing 1227 MUST take the controlling role, and the other MUST take the 1228 controlled role. In this case, no connectivity checks are ever 1229 sent. Rather, once the candidates are exchanged, each agent 1230 performs the processing described in Section 8 without 1231 connectivity checks. It is possible that both agents will believe 1232 they are controlled or controlling. In the latter case, the 1233 conflict is resolved through glare detection capabilities in the 1234 signaling protocol enabling the candidate exchange. The state of 1235 ICE processing for each data stream is considered to be Running, 1236 and the state of ICE overall is Running. 1238 Once the roles are determined for a session, they persist throughout 1239 the lifetime of the session. The roles can be re-determined as part 1240 of an ICE restart (Section 9), but an ICE agent MUST NOT re-determine 1241 the role as part of an ICE restart unless one or more of the 1242 following criteria is fulfilled: 1244 Full becomes lite: If the controlling agent is full, and switches to 1245 lite, the roles MUST be re-determined if the peer agent is also 1246 full. 1248 Role conflict: If the ICE restart causes a role conflict, the roles 1249 might be re-determined due to the role conflict procedures in 1250 Section 7.3.1.1. 1252 NOTE: There are certain 3PCC scenarios where an ICE restart might 1253 cause a role conflict. 1255 NOTE: The agents needs to inform each other whether they are full or 1256 lite before the roles are determined. The mechanism for that is 1257 signalling protocol specific, and outside the scope of the document. 1259 An agent MUST be prepared that the peer might re-determine the roles 1260 as part of any ICE restart, even if the criteria for doing so are not 1261 fulfilled. This can happen if the peer is compliant with an older 1262 version of this specification. 1264 6.1.2. Forming the Check Lists 1266 There is one check list for each data stream. To form a check list, 1267 an ICE agent (initiating and responding) forms candidate pairs, 1268 computes pair priorities, orders pairs by priority, prunes pairs, 1269 removes lower-priority pairs, and sets check list states. If 1270 candidates are added to a check list (e.g, due to detection of peer 1271 reflexive candidates), the agent will re-perform these steps for the 1272 updated check list. 1274 6.1.2.1. Check List State 1276 Each check list has a state, which captures the state of ICE checks 1277 for the data stream associated with the check list. The states are: 1279 Running: The check list is neither Completed nor Failed yet. Check 1280 lists are initially set to the Running state. 1282 Completed: The check list contains a nominated pair for each 1283 component of the data stream. 1285 Failed: The check list does not have a valid candidate pair for each 1286 component of the data stream and all of the candidate pairs in the 1287 check list are in either the Failed or Succeeded state. In other 1288 words, at least one component of the check list has candidate 1289 pairs that are all in the Failed state, which means the component 1290 has failed, which means the check list has failed. 1292 6.1.2.2. Forming Candidate Pairs 1294 The ICE agent pairs each local candidate with each remote candidate 1295 for the same component of the same data stream with the same IP 1296 address family. It is possible that some of the local candidates 1297 won't get paired with remote candidates, and some of the remote 1298 candidates won't get paired with local candidates. This can happen 1299 if one agent doesn't include candidates for the all of the components 1300 for a data stream. If this happens, the number of components for 1301 that data stream is effectively reduced, and considered to be equal 1302 to the minimum across both agents of the maximum component ID 1303 provided by each agent across all components for the data stream. 1305 In the case of RTP, this would happen when one agent provides 1306 candidates for RTCP, and the other does not. As another example, the 1307 initiating agent can multiplex RTP and RTCP on the same port 1308 [RFC5761]. However, since the initiating agent doesn't know if the 1309 peer agent can perform such multiplexing, it includes candidates for 1310 RTP and RTCP on separate ports. If the peer agent can perform such 1311 multiplexing, it would include just a single component for each 1312 candidate -- for the combined RTP/RTCP mux. ICE would end up acting 1313 as if there was just a single component for this candidate. 1315 With IPv6 it is common for a host to have multiple host candidates 1316 for each interface. To keep the amount of resulting candidate pairs 1317 reasonable and to avoid candidate pairs that are highly unlikely to 1318 work, IPv6 link-local addresses [RFC4291] MUST NOT be paired with 1319 other than link-local addresses. 1321 The candidate pairs whose local and remote candidates are both the 1322 default candidates for a particular component is called the default 1323 candidate pair for that component. This is the pair that would be 1324 used to transmit data if both agents had not been ICE aware. 1326 Figure 6 shows the properties of and relationships between transport 1327 addresses, candidates, candidate pairs, and check lists. 1329 +--------------------------------------------+ 1330 | | 1331 | +---------------------+ | 1332 | |+----+ +----+ +----+ | +Type | 1333 | || IP | |Port| |Tran| | +Priority | 1334 | ||Addr| | | | | | +Foundation | 1335 | |+----+ +----+ +----+ | +Component ID | 1336 | | Transport | +Related Address | 1337 | | Addr | | 1338 | +---------------------+ +Base | 1339 | Candidate | 1340 +--------------------------------------------+ 1341 * * 1342 * ************************************* 1343 * * 1344 +-------------------------------+ 1345 .| | 1346 | Local Remote | 1347 | +----+ +----+ +default? | 1348 | |Cand| |Cand| +valid? | 1349 | +----+ +----+ +nominated?| 1350 | +State | 1351 | | 1352 | | 1353 | Candidate Pair | 1354 +-------------------------------+ 1355 * * 1356 * ************ 1357 * * 1358 +------------------+ 1359 | Candidate Pair | 1360 +------------------+ 1361 +------------------+ 1362 | Candidate Pair | 1363 +------------------+ 1364 +------------------+ 1365 | Candidate Pair | 1366 +------------------+ 1368 Check 1369 List 1371 Figure 6: Conceptual Diagram of a Check List 1373 6.1.2.3. Computing Pair Priority and Ordering Pairs 1375 The ICE agent computes a priority for each candidate pair. Let G be 1376 the priority for the candidate provided by the controlling agent. 1377 Let D be the priority for the candidate provided by the controlled 1378 agent. The priority for a pair is computed as follows, where G>D?1:0 1379 is an expression whose value is 1 if G is greater than D, and 0 1380 otherwise. 1382 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 1384 The agent sorts each check list in decreasing order of candidate pair 1385 priority. If two pairs have identical priority, the ordering amongst 1386 them is arbitrary. 1388 6.1.2.4. Pruning the Pairs 1390 This sorted list of candidate pairs is used to determine a sequence 1391 of connectivity checks that will be performed. Each check involves 1392 sending a request from a local candidate to a remote candidate. 1393 Since an ICE agent cannot send requests directly from a reflexive 1394 candidate (server reflexive or peer reflexive), but only from its 1395 base, the agent next goes through the sorted list of candidate pairs. 1396 For each pair where the local candidate is reflexive, the candidate 1397 MUST be replaced by its base. 1399 The agent prunes each check list. This is done by removing a 1400 candidate pair if it is redundant with a higher priority candidate 1401 pair in the same check list. Two candidate pairs are redundant if 1402 their local candidates have the same base and their remote candidates 1403 are identical. The result is a sequence of ordered candidate pairs, 1404 called the check list for that data stream. 1406 6.1.2.5. Removing lower-priority Pairs 1408 In order to limit the attacks described in Section 17.4.1, an ICE 1409 agent MUST limit the total number of connectivity checks the agent 1410 performs across all check lists to a specific value, and this value 1411 MUST be configurable. A default of 100 is RECOMMENDED. This limit 1412 is enforced by discarding the lower-priority candidate pairs until 1413 there are less than 100. It is RECOMMENDED that a lower value be 1414 utilized when possible, set to the maximum number of plausible checks 1415 that might be seen in an actual deployment configuration. The 1416 requirement for configuration is meant to provide a tool for fixing 1417 this value in the field if, once deployed, it is found to be 1418 problematic. 1420 6.1.2.6. Computing Candidate Pair States 1422 Each candidate pair in the check list has a foundation (the 1423 combination of the foundations of the local and remote candidates in 1424 the pair) and one of the following states: 1426 Waiting: A check has not been sent for this pair, but the pair is 1427 not Frozen. 1429 In-Progress: A check has been sent for this pair, but the 1430 transaction is in progress. 1432 Succeeded: A check has been sent for this pair, and produced a 1433 successful result. 1435 Failed: A check has been sent for this pair, and failed (a response 1436 to the check was never received, or a failure response was 1437 received). 1439 Frozen: A check for this pair has not been sent, and it can not be 1440 sent until the pair is unfrozen and moved into the Waiting state. 1442 Pairs move between states as shown in Figure 7. 1444 +-----------+ 1445 | | 1446 | | 1447 | Frozen | 1448 | | 1449 | | 1450 +-----------+ 1451 | 1452 |unfreeze 1453 | 1454 V 1455 +-----------+ +-----------+ 1456 | | | | 1457 | | perform | | 1458 | Waiting |-------->|In-Progress| 1459 | | | | 1460 | | | | 1461 +-----------+ +-----------+ 1462 / | 1463 // | 1464 // | 1465 // | 1466 / | 1467 // | 1468 failure // |success 1469 // | 1470 / | 1471 // | 1472 // | 1473 // | 1474 V V 1475 +-----------+ +-----------+ 1476 | | | | 1477 | | | | 1478 | Failed | | Succeeded | 1479 | | | | 1480 | | | | 1481 +-----------+ +-----------+ 1483 Figure 7: Pair State FSM 1485 1. The initial states for each pair in a check list are computed by 1486 performing the following sequence of steps: 1488 2. The check lists are placed in an ordered list (the order is 1489 determined by each ICE usage), called the check list set. 1491 3. The ICE agent initially places all candidate pairs in the Frozen 1492 state. 1494 4. The agent sets all of the check lists in the check list set to 1495 the Running state. 1497 5. For each foundation, the agent sets the state of exactly one 1498 candidate pair to the Waiting state (unfreezing it). The 1499 candidate pair to unfreeze is chosen by finding the first 1500 candidate pair (ordered by lowest component ID and then highest 1501 priority if component IDs are equal) in the first check list 1502 (according to the usage-defined check list set order) that has 1503 that foundation. 1505 NOTE: The procedures above are different from RFC5245, where only 1506 candidate pairs in the first check list of were initially placed in 1507 the Waiting state. Now it applies to candidate pairs in the the 1508 first check list which have that foundation, even if the first check 1509 list to have that foundation is not the first check list in the check 1510 list set. 1512 The table in Figure 8 illustrates an example. 1514 Table legend: 1516 Each row (m1, m2,...) represents a check list associated with a data 1517 stream. m1 represents the first check list in the check list set. 1519 Each column (f1, f2,...) represents a foundation. Every candidate pair 1520 within a given column share the same foundation. 1522 f-cp represents a candidate pair in the Frozen state. 1524 w-cp represents a candidate pair in the Waiting state. 1526 1. The agent sets all of the pairs in the check list set to the Frozen 1527 state. 1529 f1 f2 f3 f4 f5 1530 ----------------------------- 1531 m1 | f-cp f-cp f-cp 1532 | 1533 m2 | f-cp f-cp f-cp f-cp 1534 | 1535 m3 | f-cp f-cp 1536 2. For each foundation, the candidate pair with the lowest component ID 1537 is placed in the Waiting state, unless a candidate pair associated with 1538 the same foundation has already been put in the Waiting state in one of 1539 the other examined check lists in the check list set. 1541 f1 f2 f3 f4 f5 1542 ----------------------------- 1543 m1 | w-cp w-cp w-cp 1544 | 1545 m2 | f-cp f-cp f-cp w-cp 1546 | 1547 m3 | f-cp w-cp 1549 In the first check list (m1) the candidate pair for each foundation is 1550 placed in the Waiting state, as no pairs for the same foundations have 1551 yet been placed in the Waiting state. 1553 In the second check list (m2) the candidate pair for foundation f4 is 1554 placed in the Waiting state. The candidate pair for foundations f1, f2 1555 and f3 are kept in the Frozen state, as candidate pairs for those 1556 foundations have already been placed in the Waiting state (within check 1557 list m1). 1559 In the third check list (m3) the candidate pair for foundation f5 is 1560 placed in the Waiting state. The candidate pair for foundation f1 is 1561 kept in the Frozen state, as a candidate pair for that foundation have 1562 already been placed in the Waiting state (within check list m1). 1564 Once each check list have been processed, one candidate pair for each 1565 foundation in the check list set has been placed in the Waiting state. 1567 Figure 8: Initial Pair State 1569 6.1.3. ICE State 1571 The ICE agent has a state determined by the state of the check lists. 1572 The state is Completed if all check lists are Completed, Failed if 1573 all check lists are Failed, and Running otherwise. 1575 6.1.4. Scheduling Checks 1577 6.1.4.1. Triggered Check Queue 1579 Once the ICE agent has computed the check lists and created the check 1580 list set, as described in Section 6.1.2, the agent will begin 1581 performing connectivity checks (ordinary and triggered). For 1582 triggered connectivity checks, the agent maintains a FIFO queue for 1583 each check list, referred to as the triggered check queue, which 1584 contains candidate pairs for which checks are to be sent at the next 1585 available opportunity. The triggered check queue is initially empty. 1587 6.1.4.2. Performing Connectivity Checks 1589 The generation of ordinary and triggered connectivity checks is 1590 governed by timer Ta. As soon as the initial states for the 1591 candidate pairs in the check list set have been set, a check is 1592 performed for a candidate pair within the first check list in the 1593 Running state, following the procedures in Section 7. After that, 1594 whenever Ta fires the next check list in the Running state in the 1595 check list set is picked, and a check is performed for a candidate 1596 within that check list. After the last check list in the Running 1597 state in the check list set has been processed, the first check list 1598 is picked again. Etc. 1600 Whenever Ta fires, the ICE agent will perform a check for a candidate 1601 pair within the picked check list by performing the following steps: 1603 1. If the triggered check queue associated with the check list 1604 contains one or more candidate pairs, the agent removes the top 1605 pair from the queue, performs a connectivity check on that pair, 1606 puts the candidate pair state to In-Progress, and aborts the 1607 subsequent steps. 1609 2. If there is no candidate pair in the Waiting state, and if there 1610 are one or more pairs in the Frozen state, for each pair in the 1611 Frozen state the agent checks the foundation associated with the 1612 pair. For a given foundation, if there is no pair (in any check 1613 list in the check list set) in the Waiting or In-Progress state, 1614 the agent puts the candidate pair state to Waiting and continues 1615 with the next step. 1617 3. If there are one or more candidate pairs in the Waiting state, 1618 the agent picks the highest-priority candidate pair (if there are 1619 multiple pairs with the same priority, the pair with the lowest 1620 component ID is picked) in the Waiting state, performs a 1621 connectivity check on that pair, puts the candidate pair par 1622 state to In-Progress, and abort the subsequent steps. 1624 4. If this step is reached, no check could be performed for the 1625 picked check list. So, without waiting for timer Ta to expire 1626 again, select the next check list in the Running state and return 1627 to step #1. If this happens for every single check list in the 1628 Running state, meaning there are no remaining candidate pairs to 1629 perform connectivity checks for, abort these steps. 1631 Once the agent has picked a candidate pair, for which a connectivity 1632 check is to be performed, the agent performs the check by sending a 1633 STUN request from the base associated with the local candidate of the 1634 pair to the remote candidate of the pair, as described in 1635 Section 7.2.4. 1637 Based on local policy, an agent MAY choose to terminate performing 1638 the connectivity checks for one or more checks lists in the check 1639 list set at any time. However, only the controlling agent is allowed 1640 to conclude ICE (Section 8). 1642 To compute the message integrity for the check, the agent uses the 1643 remote username fragment and password learned from the candidate 1644 information obtained from its peer. The local username fragment is 1645 known directly by the agent for its own candidate. 1647 The Initiator performs the ordinary checks on receiving the candidate 1648 information from the Peer (responder) and having formed the check 1649 lists. On the other hand the responding agent either performs the 1650 triggered or ordinary checks as described above. 1652 6.2. Lite Implementation Procedures 1654 Lite implementations skips most of the steps in Section 6 except for 1655 verifying the peer's ICE support and determining its role in the ICE 1656 processing. 1658 If the lite implementation is the controlling agent (which will only 1659 happen if the peer ICE agent is also a lite implementation), it 1660 selects a candidate pair based on the ones in the candidate exchange 1661 (for IPv4, there is only ever one pair), and then updating the peer 1662 with the new candidate information reflecting that selection, when 1663 needed (it is never needed for an IPv4-only host). The controlled 1664 agent is told which candidate pairs to use for each data stream, and 1665 no further candidate updates are needed to signal this information. 1667 7. Performing Connectivity Checks 1669 This section describes how connectivity checks are performed. 1671 An ICE agent MUST be compliant to [RFC5389]. A full implementation 1672 acts both as a STUN client and a STUN server, while a lite 1673 implementation only acts as a STUN server (as it does not generate 1674 connectivity checks). 1676 7.1. STUN Extensions 1678 ICE extends STUN by defining new attributes: PRIORITY, USE-CANDIDATE, 1679 ICE-CONTROLLED, and ICE-CONTROLLING. The new attributes are formally 1680 defined in Section 18.1. This section describes the usage of the new 1681 attributes. 1683 The new attributes are only applicable to ICE connectivity checks. 1685 7.1.1. PRIORITY 1687 The priority attribute MUST be included in a Binding request and be 1688 set to the value computed by the algorithm in Section 5.1.2 for the 1689 local candidate, but with the candidate type preference of peer 1690 reflexive candidates. 1692 7.1.2. USE-CANDIDATE 1694 The controlling agent MUST include the USE-CANDIDATE attribute in 1695 order to nominate a candidate pair Section 8.1.1. The controlled 1696 agent MUST NOT include the USE-CANDIDATE attribute in a Binding 1697 request. 1699 7.1.3. ICE-CONTROLLED and ICE-CONTROLLING 1701 The controlling agent MUST include the ICE-CONTROLLING attribute in a 1702 Binding request. The controlled agent MUST include the ICE- 1703 CONTROLLED attribute in a Binding request. 1705 The content of either attribute are used as tie-breaker values when 1706 an ICE role conflict occurs Section 7.3.1.1. 1708 7.2. STUN Client Procedures 1710 7.2.1. Creating Permissions for Relayed Candidates 1712 If the connectivity check is being sent using a relayed local 1713 candidate, the client MUST create a permission first if it has not 1714 already created one previously. It would have created one previously 1715 if it had told the TURN server to create a permission for the given 1716 relayed candidate towards the IP address of the remote candidate. To 1717 create the permission, the ICE agent follows the procedures defined 1718 in [RFC5766]. The permission MUST be created towards the IP address 1719 of the remote candidate. It is RECOMMENDED that the agent defer 1720 creation of a TURN channel until ICE completes, in which case 1721 permissions for connectivity checks are normally created using a 1722 CreatePermission request. Once established, the agent MUST keep the 1723 permission active until ICE concludes. 1725 7.2.2. Forming Credentials 1727 A connectivity check Binding request MUST utilize the STUN short-term 1728 credential mechanism. 1730 The username for the credential is formed by concatenating the 1731 username fragment provided by the peer with the username fragment of 1732 the ICE agent sending the request, separated by a colon (":"). 1734 The password is equal to the password provided by the peer. 1736 For example, consider the case where ICE agent L is the Initiating 1737 agent and ICE agent R is the Responding agent. Agent L included a 1738 username fragment of LFRAG for its candidates and a password of 1739 LPASS. Agent R provided a username fragment of RFRAG and a password 1740 of RPASS. A connectivity check from L to R utilizes the username 1741 RFRAG:LFRAG and a password of RPASS. A connectivity check from R to 1742 L utilizes the username LFRAG:RFRAG and a password of LPASS. The 1743 responses utilize the same usernames and passwords as the requests 1744 (note that the USERNAME attribute is not present in the response). 1746 7.2.3. DiffServ Treatment 1748 If an ICE agent is using Diffserv Codepoint markings [RFC2475] in its 1749 data packets, the agent SHOULD apply those same markings to its 1750 connectivity checks. 1752 If multiple DSCP markings are used on the data packets, the agent 1753 SHOULD choose one of them for use with the connectivity check. 1755 7.2.4. Sending the Request 1757 A connectivity check is generated by sending a Binding request from 1758 the base associated with a local candidate to a remote candidate. 1759 [RFC5389] describes how Binding requests are constructed and 1760 generated. 1762 Support for backwards compatibility with RFC 3489 MUST NOT be assumed 1763 when performing connectivity checks. The FINGERPRINT mechanism MUST 1764 be used for connectivity checks. 1766 7.2.5. Processing the Response 1768 This section defines additional procedures for processing Binding 1769 responses specific to ICE connectivity checks. 1771 When a Binding response is received, it is correlated to the 1772 corresponding Binding request using the transaction ID [RFC5389], 1773 which then associates the response with the candidate pair for which 1774 the Binding request was sent. After that, the response is processed 1775 according to the procedures for a role conflict, a failure, or a 1776 success, according to the procedures below. 1778 7.2.5.1. Role Conflict 1780 If the Binding request generates a 487 (Role Conflict) error 1781 response, and if the ICE agent included an ICE-CONTROLLED attribute 1782 in the request, the agent MUST switch to the controlling role. If 1783 the agent included an ICE-CONTROLLING attribute in the request, the 1784 agent MUST switch to the controlled role. 1786 Once the agent has switched its role, the agent MUST add the 1787 candidate pair whose check generated the 487 error response to the 1788 triggered check queue associated with the check list to which the 1789 pair belongs, and set the candidate pair state to Waiting. When the 1790 triggered connectivity check is later performed, the ICE-CONTROLLING/ 1791 ICE-CONTROLLED attribute of the Binding request will indicate the 1792 agent's new role. The agent MAY change the tie-breaker value. 1794 NOTE: A role switch requires an agent to recompute pair priorities 1795 (Section 6.1.2.3), since the priority values depend on the role. 1797 NOTE: A role switch will also impact whether the agent is responsible 1798 for nominating candidate pairs, and whether the agent is responsible 1799 for initiating the exchange of the updated candidate information with 1800 the peer once ICE is concluded. 1802 7.2.5.2. Failure 1804 This section describes cases when the candidate pair state is set to 1805 Failed. 1807 NOTE: When the ICE agent sets the candidate pair state to Failed as a 1808 result of a connectivity check error, the agent does not change the 1809 states of other candidate pairs with the same foundation. 1811 7.2.5.2.1. Non-Symmetric Transport Addresses 1813 The ICE agent MUST check that the source and destination transport 1814 addresses in the Binding request and response are symmetric. I.e., 1815 the source IP address and port of the response MUST be equal the 1816 destination IP address and port to which the Binding request was 1817 sent, and that the destination IP address and port of the response 1818 MUST be equal to the source IP address and port from which the 1819 Binding request was sent. If the addresses are not symmetric, the 1820 agent MUST set the candidate pair state to Failed. 1822 7.2.5.2.2. ICMP Error 1824 An ICE agent MAY support processing of ICMP errors for connectivity 1825 checks. If the agent supports processing of ICMP errors, and if a 1826 Binging request generates an ICMP error, the agent SHOULD set the 1827 state of the candidate pair to Failed. 1829 7.2.5.2.3. Timeout 1831 If the Binding request times out, the ICE agent SHOULD set the 1832 candidate pair state to Failed. 1834 7.2.5.2.4. Unrecoverable STUN Response 1836 If the Binding request generates a STUN error response that is 1837 unrecoverable [RFC5389] the ICE agent SHOULD set the candidate pair 1838 state to Failed. 1840 7.2.5.3. Success 1842 A connectivity check is considered a success if each of the following 1843 criteria is true: 1845 o The Binding request generated a success response; and 1847 o The source and destination transport addresses in the Binding 1848 request and response are symmetric. 1850 If a check is considered a success, the ICE agent performs (in order) 1851 the actions described in the following sections. 1853 7.2.5.3.1. Discovering Peer Reflexive Candidates 1855 The ICE agent MUST check the mapped address from the STUN response. 1856 If the transport address does not match any of the local candidates 1857 that the agent knows about, the mapped address represents a new 1858 candidate: a peer reflexive candidate. Like other candidates, a peer 1859 reflexive candidate has a type, base, priority, and foundation. They 1860 are computed as follows: 1862 o The type is peer reflexive. 1864 o The base is local candidate of the candidate pair from which the 1865 Binding request was sent. 1867 o The priority is the value of the PRIORITY attribute in the Binding 1868 request. 1870 o The foundation is described in Section 5.1.1.3. 1872 The peer reflexive candidate is then added to the list of local 1873 candidates for the data stream. The username fragment and password 1874 are the same as for all other local candidates for that data stream. 1876 The ICE agent does not need to pair the peer reflexive candidate with 1877 remote candidates, as a valid candidate pair will be created due to 1878 the procedures in Section 7.2.5.3.2. If an agent wishes to pair the 1879 peer reflexive candidate with remote candidates other than the one in 1880 the valid pair that will be generated, the agent MAY provide updated 1881 candidate information to the peer that includes the peer reflexive 1882 candidate. This will cause the peer reflexive candidate to be paired 1883 with all other remote candidates. 1885 7.2.5.3.2. Constructing a Valid Pair 1887 The ICE agent constructs a candidate pair whose local candidate 1888 equals the mapped address of the response, and whose remote candidate 1889 equals the destination address to which the request was sent. This 1890 is called a valid pair. 1892 The valid pair may equal the pair that generated the connectivity 1893 check, or it may equal a different pair in a check list (sometimes in 1894 a different check list than the one to which the pair that generated 1895 the connectivity checks), or it may be a pair not currently in any 1896 check list. 1898 The agent maintains a separate list, referred to as the valid list. 1899 There is a valid list for each check list in the check list set. The 1900 valid list will contain valid pairs. Initially each valid list is 1901 empty. 1903 Each valid pair within the valid list has a flag, called the 1904 nominated flag. When a valid pair is added to a valid list, the flag 1905 value is set to 'false'. 1907 The valid pair will be added to a valid list as follows: 1909 1. If the valid pair equals the pair that generated the check, the 1910 pair is added to the valid list associated with the check list to 1911 which the pair belongs; or 1913 2. If the valid pair equals another pair in a check list, that pair 1914 is added to the valid list associated with the check list of that 1915 pair. The pair that generated the check is not added to a valid 1916 list; or 1918 3. If the valid pair is not in any check list, the agent computes 1919 the priority for the pair based on the priority of each 1920 candidate, using the algorithm in Section 6.1.2. The priority of 1921 the local candidate depends on its type. Unless the type is peer 1922 reflexive, the priority is equal to the priority signaled for 1923 that candidate in the candidate exchange. If the type is peer 1924 reflexive, it is equal to the PRIORITY attribute the agent placed 1925 in the Binding request that just completed. The priority of the 1926 remote candidate is taken from the candidate information of the 1927 peer. If the candidate does not appear there, then the check 1928 must have been a triggered check to a new remote candidate. In 1929 that case, the priority is taken as the value of the PRIORITY 1930 attribute in the Binding request that triggered the check that 1931 just completed. The pair is then added to the valid list. 1933 NOTE: It will be very common that the valid pair will not be in any 1934 check list. Recall that the check list has pairs whose local 1935 candidates are never reflexive; those pairs had their local 1936 candidates converted to the base of the reflexive candidates, and 1937 then pruned if they were redundant. When the response to the Binding 1938 request arrives, the mapped address will be reflexive if there is a 1939 NAT between the two. In that case, the valid pair will have a local 1940 candidate that doesn't match any of the pairs in the check list. 1942 7.2.5.3.3. Updating Candidate Pair States 1944 The ICE agent sets the states of both the candidate pair that 1945 generated the check and the constructed valid pair (which may be 1946 different) to Succeeded. 1948 The agent MUST set the states for all other Frozen candidate pairs in 1949 all check lists with the same foundation to Waiting. 1951 NOTE: Within a given check list, candidate pairs with the same 1952 foundations will typically have different component ID values. 1954 7.2.5.3.4. Updating the Nominated Flag 1956 If the controlling agent sends a Binding request with the USE- 1957 CANDIDATE attribute set, and if the ICE agent receives a successful 1958 response to the request, the agent sets the nominated flag of the 1959 pair to true. If the request fails Section 7.2.5.2, the agent MUST 1960 remove the candidate pair from the valid list, set the candidate pair 1961 state to Failed and set the check list state to Failed. 1963 If the controlled agent receives a successful response to a Binding 1964 request sent by the agent, and that Binding request was triggered by 1965 a received Binding request with the USE-CANDIDATE attribute set 1966 Section 7.3.1.4, the agent sets the nominated flag of the pair to 1967 true. If the triggered request fails, the agent MUST remove the 1968 candidate pair from the valid list, set the candidate pair state to 1969 Failed and set the check list state to Failed. 1971 Once the nominated flag is set for a component of a data stream, it 1972 concludes the ICE processing for that component. See Section 8. 1974 7.2.5.4. Check List State Updates 1976 Regardless of whether a connectivity check was successful or failed, 1977 the completion of the check may require updating of check list 1978 states. For each check list in the check list set, if all of the 1979 candidate pairs are in either Failed or Succeeded state, and if there 1980 is not a valid pair in the valid list for each component of the data 1981 stream associated with the check list, the state of the check list is 1982 set to Failed. If there is a valid pair for each component in the 1983 valid list, the state of the check list is set to Succeeded. 1985 7.3. STUN Server Procedures 1987 An ICE agent (lite or full) MUST be prepared to receive Binding 1988 requests on the base of each candidate it included in its most recent 1989 candidate exchange. 1991 The agent MUST use the short-term credential mechanism (i.e., the 1992 MESSAGE-INTEGRITY attribute) to authenticate the request and perform 1993 a message integrity check. Likewise, the short-term credential 1994 mechanism MUST be used for the response. The agent MUST consider the 1995 username to be valid if it consists of two values separated by a 1996 colon, where the first value is equal to the username fragment 1997 generated by the agent in an candidate exchange for a session in- 1998 progress. It is possible (and in fact very likely) that the 1999 initiating agent will receive a Binding request prior to receiving 2000 the candidates from its peer. If this happens, the agent MUST 2001 immediately generate a response (including computation of the mapped 2002 address as described in Section 7.3.1.2). The agent has sufficient 2003 information at this point to generate the response; the password from 2004 the peer is not required. Once the answer is received, it MUST 2005 proceed with the remaining steps required, namely, Section 7.3.1.3, 2006 Section 7.3.1.4, and Section 7.3.1.5 for full implementations. In 2007 cases where multiple STUN requests are received before the answer, 2008 this may cause several pairs to be queued up in the triggered check 2009 queue. 2011 An agent MUST NOT utilize the ALTERNATE-SERVER mechanism, and MUST 2012 NOT support the backwards-compatibility mechanisms to RFC 3489. It 2013 MUST utilize the FINGERPRINT mechanism. 2015 If the agent is using Diffserv Codepoint markings [RFC2475] in its 2016 data packets, it SHOULD apply the same markings to Binding responses. 2017 The same would apply to any layer 2 markings the endpoint might be 2018 applying to data packets. 2020 7.3.1. Additional Procedures for Full Implementations 2022 This subsection defines the additional server procedures applicable 2023 to full implementations, when the full implementation accepts the 2024 Binding request. 2026 7.3.1.1. Detecting and Repairing Role Conflicts 2028 In certain usages of ICE (such as third party call control), both ICE 2029 agents may end up choosing the same role, resulting in a role 2030 conflict. The section describes a mechanism for detecting and 2031 repairing role conflicts. The usage document MUST specify whether 2032 this mechanism is needed. 2034 An agent MUST examine the Binding request for either the ICE- 2035 CONTROLLING or ICE-CONTROLLED attribute. It MUST follow these 2036 procedures: 2038 o If neither ICE-CONTROLLING nor ICE-CONTROLLED is present in the 2039 request, the peer agent may have implemented a previous version of 2040 this specification. There may be a conflict, but it cannot be 2041 detected. 2043 o If the agent is in the controlling role, and the ICE-CONTROLLING 2044 attribute is present in the request: 2046 * If the agent's tie-breaker value is larger than or equal to the 2047 contents of the ICE-CONTROLLING attribute, the agent generates 2048 a Binding error response and includes an ERROR-CODE attribute 2049 with a value of 487 (Role Conflict) but retains its role. 2051 * If the agent's tie-breaker value is less than the contents of 2052 the ICE-CONTROLLING attribute, the agent switches to the 2053 controlled role. 2055 o If the agent is in the controlled role, and the ICE-CONTROLLED 2056 attribute is present in the request: 2058 * If the agent's tie-breaker value is larger than or equal to the 2059 contents of the ICE-CONTROLLED attribute, the agent switches to 2060 the controlling role. 2062 * If the agent's tie-breaker value is less than the contents of 2063 the ICE-CONTROLLED attribute, the agent generates a Binding 2064 error response and includes an ERROR-CODE attribute with a 2065 value of 487 (Role Conflict) but retains its role. 2067 o If the agent is in the controlled role and the ICE-CONTROLLING 2068 attribute was present in the request, or the agent was in the 2069 controlling role and the ICE-CONTROLLED attribute was present in 2070 the request, there is no conflict. 2072 A change in roles will require an agent to recompute pair priorities 2073 (Section 6.1.2.3), since those priorities are a function of role. 2074 The change in role will also impact whether the agent is responsible 2075 for selecting nominated pairs and initiating exchange with updated 2076 candidate information upon conclusion of ICE. 2078 The remaining sections in Section 7.3.1 are followed if the agent 2079 generated a successful response to the Binding request, even if the 2080 agent changed roles. 2082 7.3.1.2. Computing Mapped Address 2084 For requests received on a relayed candidate, the source transport 2085 address used for STUN processing (namely, generation of the XOR- 2086 MAPPED-ADDRESS attribute) is the transport address as seen by the 2087 TURN server. That source transport address will be present in the 2088 XOR-PEER-ADDRESS attribute of a Data Indication message, if the 2089 Binding request was delivered through a Data Indication. If the 2090 Binding request was delivered through a ChannelData message, the 2091 source transport address is the one that was bound to the channel. 2093 7.3.1.3. Learning Peer Reflexive Candidates 2095 If the source transport address of the request does not match any 2096 existing remote candidates, it represents a new peer reflexive remote 2097 candidate. This candidate is constructed as follows: 2099 o The type is peer reflexive. 2101 o The priority is the value of the PRIORITY attribute in the Binding 2102 request. 2104 o The foundation is an arbitrary value, different from the 2105 foundations of all other remote candidates. If any subsequent 2106 candidate exchanges contain this peer reflexive candidate, it will 2107 signal the actual foundation for the candidate. 2109 o The component ID is the component ID of the local candidate to 2110 which the request was sent. 2112 This candidate is added to the list of remote candidates. However, 2113 the ICE agent does not pair this candidate with any local candidates. 2115 7.3.1.4. Triggered Checks 2117 Next, the agent constructs a pair whose local candidate has the 2118 transport address (as seen by the agent) on which the STUN request 2119 was received, and a remote candidate equal to the source transport 2120 address where the request came from (which may be the peer reflexive 2121 remote candidate that was just learned). The local candidate will 2122 either be a host candidate (for cases where the request was not 2123 received through a relay) or a relayed candidate (for cases where it 2124 is received through a relay). The local candidate can never be a 2125 server reflexive candidate. Since both candidates are known to the 2126 agent, it can obtain their priorities and compute the candidate pair 2127 priority. This pair is then looked up in the check list. There can 2128 be one of several outcomes: 2130 o If the pair is already on the check list: 2132 * If the state of that pair is Waiting or Frozen, a check for 2133 that pair is enqueued into the triggered check queue if not 2134 already present. 2136 * If the state of that pair is In-Progress, the agent cancels the 2137 in-progress transaction. Cancellation means that the agent 2138 will not retransmit the request, will not treat the lack of 2139 response to be a failure, but will wait the duration of the 2140 transaction timeout for a response. In addition, the agent 2141 MUST create a new connectivity check for that pair 2142 (representing a new STUN Binding request transaction) by 2143 enqueueing the pair in the triggered check queue. The state of 2144 the pair is then changed to Waiting. 2146 * If the state of the pair is Failed, it is changed to Waiting 2147 and the agent MUST create a new connectivity check for that 2148 pair (representing a new STUN Binding request transaction), by 2149 enqueueing the pair in the triggered check queue. 2151 * If the state of that pair is Succeeded, nothing further is 2152 done. 2154 These steps are done to facilitate rapid completion of ICE when both 2155 agents are behind NAT. 2157 o If the pair is not already on the check list: 2159 * The pair is inserted into the check list based on its priority. 2161 * Its state is set to Waiting. 2163 * The pair is enqueued into the triggered check queue. 2165 When a triggered check is to be sent, it is constructed and processed 2166 as described in Section 7.2.4. These procedures require the agent to 2167 know the transport address, username fragment, and password for the 2168 peer. The username fragment for the remote candidate is equal to the 2169 part after the colon of the USERNAME in the Binding request that was 2170 just received. Using that username fragment, the agent can check the 2171 candidates received from its peer (there may be more than one in 2172 cases of forking), and find this username fragment. The 2173 corresponding password is then picked. 2175 7.3.1.5. Updating the Nominated Flag 2177 If the controlled agent receives a Binding request with the USE- 2178 CANDIDATE attribute set, and if the ICE agent accepts the request, 2179 the following action is based on the state of the pair computed in 2180 Section 7.3.1.4: 2182 o If the state of this pair is Succeeded, it means that the check 2183 previously sent by this pair produced a successful response, and 2184 generated a valid pair (Section 7.2.5.3.2). The agent sets the 2185 nominated flag value of the pair to true. 2187 o If the received Binding request triggered a new check to be enqued 2188 in the triggered check queue (Section 7.3.1.4), once the check is 2189 sent and if it generates a successful response, and generates a 2190 valid pair, the agent sets the nominated flag of the pair to true. 2191 If the request fails Section 7.2.5.2, the agent MUST remove the 2192 candidate pair from the valid list, set the candidate pair state 2193 to Failed and set the check list state to Failed. 2195 If the controlled agent does not accept the request from the 2196 controlling agent, the controlled agent MUST reject the nomination 2197 request with an appropriate error code response (e.g., 400) 2198 [RFC5389]. 2200 Once the nominated flag is set for a component of a data stream, it 2201 concludes the ICE processing for that component. See Section 8. 2203 7.3.2. Additional Procedures for Lite Implementations 2205 If the controlled agent receives a Binding request with the USE- 2206 CANDIDATE attribute set, and if the ICE agent accepts the request, 2207 the agent constructs a candidate pair whose local candidate has the 2208 transport address on which the request was received, and whose remote 2209 candidate is equal to the source transport address of the request 2210 that was received. This candidate pair is assigned an arbitrary 2211 priority, and placed into the valid list of the associated check 2212 list. The agent sets the nominated flag for that pair to true. 2214 Once the nominated flag is set for a component of a data stream, it 2215 concludes the ICE processing for that component. See Section 8. 2217 8. Concluding ICE Processing 2219 This section describes how an ICE agent completes ICE. 2221 8.1. Procedures for Full Implementations 2223 Concluding ICE involves nominating pairs by the controlling agent and 2224 updating of state machinery. 2226 8.1.1. Nominating Pairs 2228 Prior to nominating, the controlling agent let connectivity checks 2229 continue until some stopping criterion is met. After that, based on 2230 an evaluation criterion, the controlling agent picks a pair among the 2231 valid pairs in the valid list for nomination. 2233 Once the controlling agent has picked a valid pair for nomination, it 2234 repeats the connectivity check that produced this valid pair (by 2235 enqueueing the pair that generated the check into the triggered check 2236 queue), this time with the USE-CANDIDATE attribute Section 7.3.1.5. 2238 Eventually, if the nominations succeed, both the controlling and 2239 controlled agents will have a single nominated pair in the valid list 2240 for each component of the data stream. Once an ICE agent sets the 2241 state of the check list to Completed (when there is a nominated pair 2242 for each component of the data stream), that pair becomes the 2243 selected pair for that agent, and is used for sending and receiving 2244 data for that component of the data stream. 2246 If an agent is not able to produce selected pairs for a data stream, 2247 the agent MUST take proper actions for informing the other agent, and 2248 e.g., removing the stream. The exact actions are outside the scope 2249 of this specification. 2251 The criterion details for stopping the connectivity checks and for 2252 selecting a pair for nomination, are outside the scope of this 2253 specification. They are a matter of local optimization. The only 2254 requirement is that the agent MUST eventually pick one and only one 2255 candidate pair and generate a check for that pair with the USE- 2256 CANDIDATE attribute set. 2258 If more than one candidate pair is nominated by the controlling 2259 agent, and if the controlled agent accepts multiple nominations 2260 requests, the agents MUST produce the selected pairs using the pairs 2261 with the highest priority. 2263 NOTE: A controlling agent that does not support this specification 2264 (i.e. it is implemented according to RFC 5245) might nominate more 2265 than one candidate pair. This was referred to as aggressive 2266 nomination in RFC 5245. The usage of the 'ice2' ice option 2267 Section 10 by endpoints supporting this specification should prevent 2268 such controlling agents from using aggressive nomination. 2270 8.1.2. Updating States 2272 For both controlling and controlled agents, the state of ICE 2273 processing depends on the presence of nominated candidate pairs in 2274 the valid list and on the state of the check list. Note that, at any 2275 time, more than one of the following cases can apply: 2277 o If there are no nominated pairs in the valid list for a data 2278 stream and the state of the check list is Running, ICE processing 2279 continues. 2281 o If there is at least one nominated pair in the valid list for a 2282 data stream and the state of the check list is Running: 2284 * The ICE agent MUST remove all Waiting and Frozen pairs in the 2285 CHECK LIST and triggered check queue for the same component as 2286 the nominated pairs for that data stream. 2288 * If an In-Progress pair in the check list is for the same 2289 component as a nominated pair, the agent SHOULD cease 2290 retransmissions for its check if its pair priority is lower 2291 than the lowest-priority nominated pair for that component. 2293 o Once there is at least one nominated pair in the valid list for 2294 every component of at least one data stream and the state of the 2295 check list is Running: 2297 * The agent MUST change the state of processing for its check 2298 list for that data stream to Completed. 2300 * The agent MUST continue to respond to any checks it may still 2301 receive for that data stream, and MUST perform triggered checks 2302 if required by the processing of Section 7.3. 2304 * The agent MUST continue retransmitting any In-Progress checks 2305 for that check list. 2307 * The agent MAY begin transmitting data for this data stream as 2308 described in Section 12.1. 2310 o Once the state of each check list is Completed: 2312 * The agent sets the state of ICE processing overall to 2313 Completed. 2315 o If the state of the check list is Failed, ICE has not been able to 2316 complete for this data stream. The correct behavior depends on 2317 the state of the check lists for other data streams: 2319 * If all check lists are Failed, ICE processing overall is 2320 considered to be in the Failed state, and the agent SHOULD 2321 consider the session a failure, SHOULD NOT restart ICE, and the 2322 controlling agent SHOULD terminate the entire session. 2324 * If at least one of the check lists for other data streams is 2325 Completed, the controlling agent SHOULD remove the failed data 2326 stream from the session while sending updated candidate list to 2327 its peer. 2329 * If none of the check lists for other data streams are 2330 Completed, but at least one is Running, the agent SHOULD let 2331 ICE continue. 2333 8.2. Procedures for Lite Implementations 2335 When ICE concludes, a lite ICE agent can free host candidates that 2336 were not used by ICE, as described in Section 8.3. 2338 If the peer is a full agent, once the lite agent accepts a nomination 2339 request for a candidate pair, the lite agent considers the pair 2340 nominated. Once there are nominated pairs for each component of a 2341 data stream, the pairs become the selected pairs for the components 2342 of the data stream. Once the lite agent has produced selected pairs 2343 for all components of all data streams, the ICE session state is set 2344 to Completed. 2346 If the peer is a lite agent, the agent pairs local candidates with 2347 remote candidates that are for the same data stream and have the same 2348 component, transport protocol, and IP address family. For each 2349 component of each data stream, if there is only one candidate pair, 2350 that pair is added to the valid list. If there is more than one 2351 pair, it is RECOMMENDED that an agent follow the procedures of RFC 2352 6724 [RFC6724] to select a pair and add it to the valid list. 2354 If all of the components for all data streams had one pair, the state 2355 of ICE processing is Completed. Otherwise, the controlling agent 2356 MUST send an updated candidate list to reconcile different agents 2357 selecting different candidate pairs. ICE processing is complete 2358 after and only after the updated candidate exchange is complete. 2360 8.3. Freeing Candidates 2362 8.3.1. Full Implementation Procedures 2364 The procedures in Section 8 require that an ICE agent continue to 2365 listen for STUN requests and continue to generate triggered checks 2366 for a data stream, even once processing for that stream completes. 2367 The rules in this section describe when it is safe for an agent to 2368 cease sending or receiving checks on a candidate that did not become 2369 a selected candidate (is not associated with a selected pair), and 2370 then free the candidate. 2372 Once a check list has reached the Completed state, the agent SHOULD 2373 wait an additional three seconds, and then it can cease responding to 2374 checks or generating triggered checks on all local candidates other 2375 than the ones that became selected candidates. Once all ICE sessions 2376 have ceased using a given local candidate (a candidate may be used by 2377 multiple ICE sessions, e.g. in forking scenarios), the agent can free 2378 that candidate. The three-second delay handles cases when aggressive 2379 nomination is used, and the selected pairs can quickly change after 2380 ICE has completed. 2382 Freeing of server reflexive candidates is never explicit; it happens 2383 by lack of a keepalive. 2385 8.3.2. Lite Implementation Procedures 2387 A lite implementation can free candidates that did not become 2388 selected candidates as soon as ICE processing has reached the 2389 Completed state for all ICE sessions using those candidates. 2391 9. ICE Restarts 2393 An ICE agent MAY restart ICE for existing data streams. An ICE 2394 restart causes all previous state of the data streams, excluding the 2395 roles of the agents to be flushed. The only difference between an 2396 ICE restart and a brand new data session is that during the restart, 2397 data can continue to be sent using existing data sessions, and that a 2398 new data session always requires the roles to be determined. 2400 The following actions can be accomplished only using an ICE restart 2401 (the agent MUST use ICE restarts to do so): 2403 o Change the destinations of data streams. 2405 o Change from a lite implementation to a full implementation. 2407 o Change from a full implementation to a lite implementation. 2409 To restart ICE, an agent MUST change both the password and the 2410 username fragment for the data stream(s) being restarted. The new 2411 candidate set MAY include some, none, or all of the previous 2412 candidates. 2414 As described in Section 6.1.1, agents MUST NOT re-determine the roles 2415 as part as an ICE restart, unless certain criteria that require the 2416 roles to be re-determined are fulfilled. 2418 10. ICE Option 2420 This section defines a new ICE option, 'ice2'. The ICE option 2421 indicates that the ICE agent that includes it in a candidate exchange 2422 is compliant to this specification. For example, the agent will not 2423 use the aggressive nomination procedure defined in [RFC5245]. 2425 An agent compliant to this specification MUST inform the peer about 2426 the compliance using the 'ice2' option. 2428 NOTE: The encoding of the 'ice2' ICE option, and the message(s) used 2429 to carry it to the peer, are protocol specific. The encoding for the 2430 Session Description Protocol (SDP) [RFC4566] is defined in 2431 [I-D.ietf-mmusic-ice-sip-sdp]. 2433 11. Keepalives 2435 All endpoints MUST send keepalives for each data session. These 2436 keepalives serve the purpose of keeping NAT bindings alive for the 2437 data session. The keepalives SHOULD be sent using a format that is 2438 supported by its peer. ICE endpoints allow for STUN-based keepalives 2439 for UDP streams, and as such, STUN keepalives MUST be used when an 2440 ICE agent is a full ICE implementation and is communicating with a 2441 peer that supports ICE (lite or full). 2443 For each candidate pair that an agent is using to send data, if no 2444 packet has been sent on that pair in the last Tr seconds, an agent 2445 MUST send a keepalive on that pair. Agents SHOULD use a Tr value of 2446 15 seconds. Agents MAY use a bigger value, but MUST NOT use a value 2447 smaller than 15 seconds. 2449 Once selected pairs have been produced for a data stream, keepalives 2450 are only sent on those pairs. 2452 An agent MUST stop sending keepalives on a data stream if the data 2453 stream is removed. If the ICE session is terminated, an agent MUST 2454 stop sending keepalives on all data streams. 2456 An agent MAY use another value for Tr, e.g. based on configuration or 2457 network/NAT characteristics. For example, if an agent has a dynamic 2458 way to discover the binding lifetimes of the intervening NATs, it can 2459 use that value to determine Tr. Administrators deploying ICE in more 2460 controlled networking environments SHOULD set Tr to the longest 2461 duration possible in their environment. 2463 When STUN is being used for keepalives, a STUN Binding Indication is 2464 used [RFC5389]. The Indication MUST NOT utilize any authentication 2465 mechanism. It SHOULD contain the FINGERPRINT attribute to aid in 2466 demultiplexing, but SHOULD NOT contain any other attributes. It is 2467 used solely to keep the NAT bindings alive. The Binding Indication 2468 is sent using the same local and remote candidates that are being 2469 used for data. Though Binding Indications are used for keepalives, 2470 an agent MUST be prepared to receive a connectivity check as well. 2471 If a connectivity check is received, a response is generated as 2472 discussed in [RFC5389], but there is no impact on ICE processing 2473 otherwise. 2475 Agents MUST by default use STUN keepalives. Individual ICE usages 2476 and ICE extensions MAY specify usage/extension-specific keepalives. 2478 12. Data Handling 2480 12.1. Sending Data 2482 An ICE agent MAY send data on any valid candidate pair before 2483 selected pairs have been produced for the data stream. 2485 Once selected pairs have been produced for a data stream, an agent 2486 MUST send data on those pairs. 2488 An agent sends data from the base of the local candidate to the 2489 remote candidate. In the case of a local relayed candidate, data is 2490 forwarded through the base (located in the TURN server), using the 2491 procedures defined in [RFC5766]. 2493 If the local candidate is a relayed candidate, it is RECOMMENDED that 2494 an agent creates a channel on the TURN server towards the remote 2495 candidate. This is done using the procedures for channel creation as 2496 defined in Section 11 of [RFC5766]. 2498 The selected pair for a component of a data stream is: 2500 o empty if the state of the check list for that data stream is 2501 Running, and there is no previous selected pair for that component 2502 due to an ICE restart 2504 o equal to the previous selected pair for a component of a data 2505 stream if the state of the check list for that data stream is 2506 Running, and there was a previous selected pair for that component 2507 due to an ICE restart 2509 Unless an agent is able to produce a selected pair for each component 2510 associated with a data stream, the agent MUST NOT continue sending 2511 data for any component associated with that data stream. 2513 12.2. Procedures for Lite Implementations 2515 A lite implementation MUST NOT send data until it has a valid list 2516 that contains a candidate pair for each component of that data 2517 stream. Once that happens, the ICE agent MAY begin sending data 2518 packets. To do that, it sends data to the remote candidate in the 2519 pair (setting the destination address and port of the packet equal to 2520 that remote candidate), and will send it from the base associated 2521 with the candidate pair used for sending data. In case of a relayed 2522 candidate, data is sent from the agent and forwarded through the base 2523 (located in the TURN server), using the procedures defined in 2524 [RFC5766]. 2526 12.3. Procedures for All Implementations 2528 ICE has interactions with jitter buffer adaptation mechanisms. An 2529 RTP stream can begin using one candidate, and switch to another one, 2530 though this happens rarely with ICE. The newer candidate may result 2531 in RTP packets taking a different path through the network -- one 2532 with different delay characteristics. As discussed below, ICE agents 2533 are encouraged to re-adjust jitter buffers when there are changes in 2534 source or destination address of data packets. Furthermore, many 2535 audio codecs use the marker bit to signal the beginning of a 2536 talkspurt, for the purposes of jitter buffer adaptation. For such 2537 codecs, it is RECOMMENDED that the sender set the marker bit 2539 [RFC3550] when an agent switches transmission of data from one 2540 candidate pair to another. 2542 13. Receiving Data 2544 Even though ICE agents are only allowed to send data using valid 2545 candidate pairs (and, once selected pairs have been produced, only on 2546 the selected pairs) ICE implementations SHOULD by default be prepared 2547 to receive data on any of the candidates provided in the most recent 2548 candidate exchange with the peer. ICE usages MAY define rules that 2549 differs from this, e.g., by defining that data must not be sent until 2550 selected pairs have been produced for a data stream. 2552 It is RECOMMENDED that, when an agent receives an RTP packet with a 2553 new source or destination IP address for a particular RTP/RTCP data 2554 stream, that the agent re-adjust its jitter buffers. 2556 RFC 3550 [RFC3550] describes an algorithm in Section 8.2 for 2557 detecting synchronization source (SSRC) collisions and loops. These 2558 algorithms are based, in part, on seeing different source transport 2559 addresses with the same SSRC. However, when ICE is used, such 2560 changes will sometimes occur as the data streams switch between 2561 candidates. An agent will be able to determine that a data stream is 2562 from the same peer as a consequence of the STUN exchange that 2563 proceeds media data transmission. Thus, if there is a change in 2564 source transport address, but the media data packets come from the 2565 same peer agent, this MUST NOT be treated as an SSRC collision. 2567 14. Extensibility Considerations 2569 This specification makes very specific choices about how both ICE 2570 agents in a session coordinate to arrive at the set of candidate 2571 pairs that are selected for data. It is anticipated that future 2572 specifications will want to alter these algorithms, whether they are 2573 simple changes like timer tweaks or larger changes like a revamp of 2574 the priority algorithm. When such a change is made, providing 2575 interoperability between the two agents in a session is critical. 2577 First, ICE provides the ice-options attribute. Each extension or 2578 change to ICE is associated with a token. When an agent supporting 2579 such an extension or change triggers candidate exchange, it MUST 2580 include the token for that extension in this attribute. This allows 2581 each side to know what the other side is doing. This attribute MUST 2582 NOT be present if the agent doesn't support any ICE extensions or 2583 changes. 2585 One of the complications in achieving interoperability is that ICE 2586 relies on a distributed algorithm running on both agents to converge 2587 on an agreed set of candidate pairs. If the two agents run different 2588 algorithms, it can be difficult to guarantee convergence on the same 2589 candidate pairs. The regular nomination procedure described in 2590 Section 8 eliminates some of the tight coordination by delegating the 2591 selection algorithm completely to the controlling agent. 2592 Consequently, when a controlling agent is communicating with a peer 2593 that supports options it doesn't know about, the agent MUST run a 2594 regular nomination algorithm. When regular nomination is used, ICE 2595 will converge perfectly even when both agents use different pair 2596 prioritization algorithms. One of the keys to such convergence is 2597 triggered checks, which ensure that the nominated pair is validated 2598 by both agents. Consequently, any future ICE enhancements MUST 2599 preserve triggered checks. 2601 ICE is also extensible to other data streams beyond RTP, and for 2602 transport protocols beyond UDP. Extensions to ICE for non-RTP data 2603 streams need to specify how many components they utilize, and assign 2604 component IDs to them, starting at 1 for the most important component 2605 ID. Specifications for new transport protocols must define how, if 2606 at all, various steps in the ICE processing differ from UDP. 2608 15. Setting Ta and RTO 2610 15.1. General 2612 During the ICE gathering phase (Section 5.1.1) and while ICE is 2613 performing connectivity checks (Section 7), an ICE agent triggers 2614 STUN and TURN transactions. These transactions are paced at a rate 2615 indicated by Ta, and the retransmission interval for each transaction 2616 is calculated based on the the retransmission timer for the STUN 2617 transactions (RTO) [RFC5389]. 2619 This section describes how the Ta and RTO values are computed during 2620 the ICE gathering phase and while ICE is performing connectivity 2621 checks. 2623 NOTE: Previously, in RFC 5245, different formulas were defined for 2624 computing Ta and RTO, depending on whether ICE was used for a real- 2625 time data stream (e.g., RTP) or not. 2627 The formulas below result in a behavior whereby an agent will send 2628 its first packet for every single connectivity check before 2629 performing a retransmit. This can be seen in the formulas for the 2630 RTO (which represents the retransmit interval). Those formulas scale 2631 with N, the number of checks to be performed. As a result of this, 2632 ICE maintains a nicely constant rate, but becomes more sensitive to 2633 packet loss. The loss of the first single packet for any 2634 connectivity check is likely to cause that pair to take a long time 2635 to be validated, and instead, a lower-priority check (but one for 2636 which there was no packet loss) is much more likely to complete 2637 first. This results in ICE performing sub-optimally, choosing lower- 2638 priority pairs over higher-priority pairs. Implementors should be 2639 aware of this consequence, but still should utilize the timer values 2640 described here. 2642 15.2. Ta 2644 ICE agents SHOULD use the default Ta value, 50 ms, but MAY use 2645 another value based on the characteristics of the associated data. 2647 If an agent wants to use another Ta value than the default value, the 2648 agent MUST indicate the proposed value to its peer during the 2649 establishment of the ICE session. Both agents MUST use the higher 2650 value of the proposed values. If an agent does not propose a value, 2651 the default value is used for that agent when comparing which value 2652 is higher. 2654 Regardless of the Ta value chosen for each agent, the combination of 2655 all transactions from all agents (if a given implementation runs 2656 several concurrent agents) MUST NOT be sent more often than once 2657 every 5ms (as though there were one global Ta value for pacing all 2658 agents). 2660 This mechanism of a global minimum pacing interval of 5ms is not 2661 generally applicable to transport protocols, but is applicable to ICE 2662 based on the following reasoning. 2664 o Start with the following rules which would be generally applicable 2665 to transport protocols: 2667 1. Let MaxBytes be the maximum number of bytes allowed to be 2668 outstanding in the network at start-up, which SHOULD be 14600 2669 bytes per RFC 6928. 2671 2. Let HTO be the transaction timeout, which SHOULD be 2*RTT if 2672 RTT is known and 500ms otherwise. This is based on the RTO 2673 for STUN messages from RFC 5389 and the the TCP initial RTO, 2674 which is 1 sec in RFC 6298. 2676 3. Let MinPacing be the minimum pacing interval between 2677 transactions, which SHOULD be 5ms. 2679 o Observe that agents typically do not know the RTT for ICE 2680 transactions (connectivity checks in particular), meaning that HTO 2681 will almost always be 500ms. 2683 o Observe that a MinPacing of 5ms and HTO of 500ms gives at most 100 2684 packets/HTO, which for a typical ICE check of less than 120 bytes 2685 means a maximum of 12000 outstanding bytes in the network, which 2686 is less than the maximum expressed by rule 1. 2688 o Thus, for ICE, the rule set reduces down to just the MinPacing 2689 rule, which is equivalent to having a global Ta value. 2691 NOTE: Appendix C shows examples of required bandwidth, using 2692 different Ta values. 2694 15.3. RTO 2696 During the ICE gathering phase, ICE agents SHOULD calculate the RTO 2697 value using the following formula: 2699 RTO = MAX (500ms, Ta * (Num-Of-Pairs)) 2701 Num-Of-Pairs: the number of pairs of candidates 2702 with STUN or TURN servers. 2704 For connectivity checks, agents SHOULD calculate the RTO value using 2705 the following formula: 2707 RTO = MAX (500ms, Ta*N * (Num-Waiting + Num-In-Progress)) 2709 Num-Waiting: the number of checks in the check list in the 2710 Waiting state. 2712 Num-In-Progress: the number of checks in the In-Progress state. 2714 Note that the RTO will be different for each transaction as the 2715 number of checks in the Waiting and In-Progress states change. 2717 Agents MAY calculate the RTO value using other mechanisms than those 2718 described above. Agents MUST NOT use a RTO value smaller than 500 2719 ms. 2721 16. Example 2723 The example is based on the simplified topology of Figure 9. 2725 +-------+ 2726 |STUN | 2727 |Server | 2728 +-------+ 2729 | 2730 +---------------------+ 2731 | | 2732 | Internet | 2733 | | 2734 +---------------------+ 2735 | | 2736 | | 2737 +---------+ | 2738 | NAT | | 2739 +---------+ | 2740 | | 2741 | | 2742 +-----+ +-----+ 2743 | L | | R | 2744 +-----+ +-----+ 2746 Figure 9: Example Topology 2748 Two ICE agents, L and R, are using ICE. Both are full ICE 2749 implementations. Both agents have a single IPv4 address. For agent 2750 L, it is 10.0.1.1 in private address space [RFC1918], and for agent 2751 R, 192.0.2.1 on the public Internet. Both are configured with the 2752 same STUN server (shown in this example for simplicity, although in 2753 practice the agents do not need to use the same STUN server), which 2754 is listening for STUN Binding requests at an IP address of 192.0.2.2 2755 and port 3478. TURN servers are not used in this example. Agent L 2756 is behind a NAT, and agent R is on the public Internet. The NAT has 2757 an endpoint independent mapping property and an address dependent 2758 filtering property. The public side of the NAT has an IP address of 2759 192.0.2.3. 2761 To facilitate understanding, transport addresses are listed using 2762 variables that have mnemonic names. The format of the name is 2763 entity-type-seqno, where entity refers to the entity whose IP address 2764 the transport address is on, and is one of "L", "R", "STUN", or 2765 "NAT". The type is either "PUB" for transport addresses that are 2766 public, and "PRIV" for transport addresses that are private. 2767 Finally, seq-no is a sequence number that is different for each 2768 transport address of the same type on a particular entity. Each 2769 variable has an IP address and port, denoted by varname.IP and 2770 varname.PORT, respectively, where varname is the name of the 2771 variable. 2773 The STUN server has advertised transport address STUN-PUB-1 (which is 2774 192.0.2.2:3478). 2776 In the call flow itself, STUN messages are annotated with several 2777 attributes. The "S=" attribute indicates the source transport 2778 address of the message. The "D=" attribute indicates the destination 2779 transport address of the message. The "MA=" attribute is used in 2780 STUN Binding response messages and refers to the mapped address. 2781 "USE-CAND" implies the presence of the USE-CANDIDATE attribute. 2783 The call flow examples omit STUN authentication operations, and focus 2784 on a single data stream between two full implementations. 2786 L NAT STUN R 2787 |STUN alloc. | | | 2788 |(1) STUN Req | | | 2789 |S=$L-PRIV-1 | | | 2790 |D=$STUN-PUB-1 | | | 2791 |------------->| | | 2792 | |(2) STUN Req | | 2793 | |S=$NAT-PUB-1 | | 2794 | |D=$STUN-PUB-1 | | 2795 | |------------->| | 2796 | |(3) STUN Res | | 2797 | |S=$STUN-PUB-1 | | 2798 | |D=$NAT-PUB-1 | | 2799 | |MA=$NAT-PUB-1 | | 2800 | |<-------------| | 2801 |(4) STUN Res | | | 2802 |S=$STUN-PUB-1 | | | 2803 |D=$L-PRIV-1 | | | 2804 |MA=$NAT-PUB-1 | | | 2805 |<-------------| | | 2806 |(5) L's Candidate Information| | 2807 |------------------------------------------->| 2808 | | | | STUN 2809 | | | | alloc. 2810 | | |(6) STUN Req | 2811 | | |S=$R-PUB-1 | 2812 | | |D=$STUN-PUB-1 | 2813 | | |<-------------| 2814 | | |(7) STUN Res | 2815 | | |S=$STUN-PUB-1 | 2816 | | |D=$R-PUB-1 | 2817 | | |MA=$R-PUB-1 | 2818 | | |------------->| 2819 |(8) R's Candidate Information| | 2820 |<-------------------------------------------| 2821 | |(9) Bind Req | |Begin 2822 | |S=$R-PUB-1 | |Connectivity 2823 | |D=L-PRIV-1 | |Checks 2824 | |<----------------------------| 2825 | |Dropped | | 2826 |(10) Bind Req | | | 2827 |S=$L-PRIV-1 | | | 2828 |D=$R-PUB-1 | | | 2829 |------------->| | | 2830 | |(11) Bind Req | | 2831 | |S=$NAT-PUB-1 | | 2832 | |D=$R-PUB-1 | | 2833 | |---------------------------->| 2834 | |(12) Bind Res | | 2835 | |S=$R-PUB-1 | | 2836 | |D=$NAT-PUB-1 | | 2837 | |MA=$NAT-PUB-1 | | 2838 | |<----------------------------| 2839 |(13) Bind Res | | | 2840 |S=$R-PUB-1 | | | 2841 |D=$L-PRIV-1 | | | 2842 |MA=$NAT-PUB-1 | | | 2843 |<-------------| | | 2844 |Data flows | | | 2845 | |(14) Bind Req | | 2846 | |S=$R-PUB-1 | | 2847 | |D=$NAT-PUB-1 | | 2848 | |<----------------------------| 2849 |(15) Bind Req | | | 2850 |S=$R-PUB-1 | | | 2851 |D=$L-PRIV-1 | | | 2852 |<-------------| | | 2853 |(16) Bind Res | | | 2854 |S=$L-PRIV-1 | | | 2855 |D=$R-PUB-1 | | | 2856 |MA=$R-PUB-1 | | | 2857 |------------->| | | 2858 | |(17) Bind Res | | 2859 | |S=$NAT-PUB-1 | | 2860 | |D=$R-PUB-1 | | 2861 | |MA=$R-PUB-1 | | 2862 | |---------------------------->| 2863 | | | |Data flows 2865 Figure 10: Example Flow 2867 First, agent L obtains a host candidate from its local IP address 2868 (not shown), and from that, sends a STUN Binding request to the STUN 2869 server to get a server reflexive candidate (messages 1-4). Recall 2870 that the NAT has the address and port independent mapping property. 2871 Here, it creates a binding of NAT-PUB-1 for this UDP request, and 2872 this becomes the server reflexive candidate. 2874 Agent L sets a type preference of 126 for the host candidate and 100 2875 for the server reflexive. The local preference is 65535. Based on 2876 this, the priority of the host candidate is 2130706431 and for the 2877 server reflexive candidate is 1694498815. The host candidate is 2878 assigned a foundation of 1, and the server reflexive, a foundation of 2879 2. These are sent to the peer. 2881 This candidate information is received at agent R. Agent R will 2882 obtain a host candidate, and from it, obtain a server reflexive 2883 candidate (messages 6-7). Since R is not behind a NAT, this 2884 candidate is identical to its host candidate, and they share the same 2885 base. It therefore discards this redundant candidate and ends up 2886 with a single host candidate. With identical type and local 2887 preferences as L, the priority for this candidate is 2130706431. It 2888 chooses a foundation of 1 for its single candidate. Then R's 2889 candidates are then sent to L. 2891 Since neither side indicated that it is lite, the initiating agent 2892 that began ICE processing (agent L) becomes the controlling agent. 2894 Agents L and R both pair up the candidates. They both initially have 2895 two pairs. However, agent L will prune the pair containing its 2896 server reflexive candidate, resulting in just one. At agent L, this 2897 pair has a local candidate of $L_PRIV_1 and remote candidate of 2898 $R_PUB_1, and has a candidate pair priority of 4.57566E+18 (note that 2899 an implementation would represent this as a 64-bit integer so as not 2900 to lose precision). At agent R, there are two pairs. The highest 2901 priority has a local candidate of $R_PUB_1 and remote candidate of 2902 $L_PRIV_1 and has a priority of 4.57566E+18, and the second has a 2903 local candidate of $R_PUB_1 and remote candidate of $NAT_PUB_1 and 2904 priority 3.63891E+18. 2906 Agent R begins its connectivity check (message 9) for the first pair 2907 (between the two host candidates). Since R is the controlled agent 2908 for this session, the check omits the USE-CANDIDATE attribute. The 2909 host candidate from agent L is private and behind a NAT, and thus 2910 this check won't be successful, because the packet cannot be routed 2911 from R to L. 2913 When agent L gets the R's candidates, it performs its one and only 2914 connectivity check (messages 10-13). Since the check succeeds, agent 2915 L creates a new pair, whose local candidate is from the mapped 2916 address in the Binding response (NAT-PUB-1 from message 13) and whose 2917 remote candidate is the destination of the request (R-PUB-1 from 2918 message 10). This is added to the valid list. Agent L can now send 2919 data if it so chooses. 2921 Soon after receipt of the STUN Binding request from agent L (message 2922 11), agent R will generate its triggered check. This check happens 2923 to match the next one on its check list -- from its host candidate to 2924 agent L's server reflexive candidate. This check (messages 14-17) 2925 will succeed. Consequently, agent R constructs a new candidate pair 2926 using the mapped address from the response as the local candidate (R- 2927 PUB-1) and the destination of the request (NAT-PUB-1) as the remote 2928 candidate. This pair is added to the valid list for that data 2929 stream. Since the check was generated in the reverse direction of a 2930 check that contained the USE-CANDIDATE attribute, the candidate pair 2931 is marked as selected. Consequently, processing for this stream 2932 moves into the Completed state, and agent R can also send data. 2934 17. Security Considerations 2936 The process of probing for candidates reveals the source addresses of 2937 the client and its peer to any on-network listening attacker, and the 2938 process of exchanging candidates reveals the addresses to any 2939 attacker that is able to see the negotiation. Some addresses, such 2940 as the server reflexive addresses gathered through the local 2941 interface of VPN users, may be sensitive information. If these 2942 potential attacks can not be mitigated, the implementation may want 2943 to institute controls for which addresses are revealed to the 2944 negotiation and/or probing process. Such controls need to be 2945 specified as part of the ICE usage. 2947 There are several types of attacks possible in an ICE system. This 2948 section considers these attacks and their countermeasures. These 2949 countermeasures include: 2951 o Using ICE in conjunction with secure signaling techniques, such as 2952 SIPS. 2954 o Limiting the total number of connectivity checks to 100, and 2955 optionally limiting the number of candidates they'll accept in an 2956 candidate exchange. 2958 17.1. Attacks on Connectivity Checks 2960 An attacker might attempt to disrupt the STUN connectivity checks. 2961 Ultimately, all of these attacks fool an ICE agent into thinking 2962 something incorrect about the results of the connectivity checks. 2963 The possible false conclusions an attacker can try and cause are: 2965 False Invalid: An attacker can fool a pair of agents into thinking a 2966 candidate pair is invalid, when it isn't. This can be used to 2967 cause an agent to prefer a different candidate (such as one 2968 injected by the attacker) or to disrupt a call by forcing all 2969 candidates to fail. 2971 False Valid: An attacker can fool a pair of agents into thinking a 2972 candidate pair is valid, when it isn't. This can cause an agent 2973 to proceed with a session, but then not be able to receive any 2974 data. 2976 False Peer Reflexive Candidate: An attacker can cause an agent to 2977 discover a new peer reflexive candidate, when it shouldn't have. 2978 This can be used to redirect data streams to a Denial-of-Service 2979 (DoS) target or to the attacker, for eavesdropping or other 2980 purposes. 2982 False Valid on False Candidate: An attacker has already convinced an 2983 agent that there is a candidate with an address that doesn't 2984 actually route to that agent (for example, by injecting a false 2985 peer reflexive candidate or false server reflexive candidate). It 2986 must then launch an attack that forces the agents to believe that 2987 this candidate is valid. 2989 If an attacker can cause a false peer reflexive candidate or false 2990 valid on a false candidate, it can launch any of the attacks 2991 described in [RFC5389]. 2993 To force the false invalid result, the attacker has to wait for the 2994 connectivity check from one of the agents to be sent. When it is, 2995 the attacker needs to inject a fake response with an unrecoverable 2996 error response, such as a 400. However, since the candidate is, in 2997 fact, valid, the original request may reach the peer agent, and 2998 result in a success response. The attacker needs to force this 2999 packet or its response to be dropped, through a DoS attack, layer 2 3000 network disruption, or other technique. If it doesn't do this, the 3001 success response will also reach the originator, alerting it to a 3002 possible attack. Fortunately, this attack is mitigated completely 3003 through the STUN short-term credential mechanism. The attacker needs 3004 to inject a fake response, and in order for this response to be 3005 processed, the attacker needs the password. If the candidate 3006 exchange signaling is secured, the attacker will not have the 3007 password and its response will be discarded. 3009 Forcing the fake valid result works in a similar way. The agent 3010 needs to wait for the Binding request from each agent, and inject a 3011 fake success response. The attacker won't need to worry about 3012 disrupting the actual response since, if the candidate is not valid, 3013 it presumably wouldn't be received anyway. However, like the fake 3014 invalid attack, this attack is mitigated by the STUN short-term 3015 credential mechanism in conjunction with a secure candidate exchange. 3017 Forcing the false peer reflexive candidate result can be done either 3018 with fake requests or responses, or with replays. We consider the 3019 fake requests and responses case first. It requires the attacker to 3020 send a Binding request to one agent with a source IP address and port 3021 for the false candidate. In addition, the attacker must wait for a 3022 Binding request from the other agent, and generate a fake response 3023 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 3024 Like the other attacks described here, this attack is mitigated by 3025 the STUN message integrity mechanisms and secure candidate exchanges. 3027 Forcing the false peer reflexive candidate result with packet replays 3028 is different. The attacker waits until one of the agents sends a 3029 check. It intercepts this request, and replays it towards the other 3030 agent with a faked source IP address. It must also prevent the 3031 original request from reaching the remote agent, either by launching 3032 a DoS attack to cause the packet to be dropped, or forcing it to be 3033 dropped using layer 2 mechanisms. The replayed packet is received at 3034 the other agent, and accepted, since the integrity check passes (the 3035 integrity check cannot and does not cover the source IP address and 3036 port). It is then responded to. This response will contain a XOR- 3037 MAPPED-ADDRESS with the false candidate, and will be sent to that 3038 false candidate. The attacker must then receive it and relay it 3039 towards the originator. 3041 The other agent will then initiate a connectivity check towards that 3042 false candidate. This validation needs to succeed. This requires 3043 the attacker to force a false valid on a false candidate. Injecting 3044 of fake requests or responses to achieve this goal is prevented using 3045 the integrity mechanisms of STUN and the candidate exchange. Thus, 3046 this attack can only be launched through replays. To do that, the 3047 attacker must intercept the check towards this false candidate, and 3048 replay it towards the other agent. Then, it must intercept the 3049 response and replay that back as well. 3051 This attack is very hard to launch unless the attacker is identified 3052 by the fake candidate. This is because it requires the attacker to 3053 intercept and replay packets sent by two different hosts. If both 3054 agents are on different networks (for example, across the public 3055 Internet), this attack can be hard to coordinate, since it needs to 3056 occur against two different endpoints on different parts of the 3057 network at the same time. 3059 If the attacker itself is identified by the fake candidate, the 3060 attack is easier to coordinate. However, if the data path is secured 3061 (e.g., using SRTP [RFC3711]), the attacker will not be able to 3062 process the data packets, but will only be able to discard them, 3063 effectively disabling the data stream. However, this attack requires 3064 the agent to disrupt packets in order to block the connectivity check 3065 from reaching the target. In that case, if the goal is to disrupt 3066 the data stream, it's much easier to just disrupt it with the same 3067 mechanism, rather than attack ICE. 3069 17.2. Attacks on Server Reflexive Address Gathering 3071 ICE endpoints make use of STUN Binding requests for gathering server 3072 reflexive candidates from a STUN server. These requests are not 3073 authenticated in any way. As a consequence, there are numerous 3074 techniques an attacker can employ to provide the client with a false 3075 server reflexive candidate: 3077 o An attacker can compromise the DNS, causing DNS queries to return 3078 a rogue STUN server address. That server can provide the client 3079 with fake server reflexive candidates. This attack is mitigated 3080 by DNS security, though DNS-SEC is not required to address it. 3082 o An attacker that can observe STUN messages (such as an attacker on 3083 a shared network segment, like WiFi) can inject a fake response 3084 that is valid and will be accepted by the client. 3086 o An attacker can compromise a STUN server by means of a virus, and 3087 cause it to send responses with incorrect mapped addresses. 3089 A false mapped address learned by these attacks will be used as a 3090 server reflexive candidate in the establishment of the ICE session. 3091 For this candidate to actually be used for data, the attacker must 3092 also attack the connectivity checks, and in particular, force a false 3093 valid on a false candidate. This attack is very hard to launch if 3094 the false address identifies a fourth party (neither the initiator, 3095 responder, nor attacker), since it requires attacking the checks 3096 generated by each ICE agent in the session, and is prevented by SRTP 3097 if it identifies the attacker itself. 3099 If the attacker elects not to attack the connectivity checks, the 3100 worst it can do is prevent the server reflexive candidate from being 3101 used. However, if the peer agent has at least one candidate that is 3102 reachable by the agent under attack, the STUN connectivity checks 3103 themselves will provide a peer reflexive candidate that can be used 3104 for the exchange of data. Peer reflexive candidates are generally 3105 preferred over server reflexive candidates. As such, an attack 3106 solely on the STUN address gathering will normally have no impact on 3107 a session at all. 3109 17.3. Attacks on Relayed Candidate Gathering 3111 An attacker might attempt to disrupt the gathering of relayed 3112 candidates, forcing the client to believe it has a false relayed 3113 candidate. Exchanges with the TURN server are authenticated using a 3114 long-term credential. Consequently, injection of fake responses or 3115 requests will not work. In addition, unlike Binding requests, 3116 Allocate requests are not susceptible to replay attacks with modified 3117 source IP addresses and ports, since the source IP address and port 3118 are not utilized to provide the client with its relayed candidate. 3120 However, TURN servers are susceptible to DNS attacks, or to viruses 3121 aimed at the TURN server, for purposes of turning it into a zombie or 3122 rogue server. These attacks can be mitigated by DNS-SEC and through 3123 good box and software security on TURN servers. 3125 Even if an attacker has caused the client to believe in a false 3126 relayed candidate, the connectivity checks cause such a candidate to 3127 be used only if they succeed. Thus, an attacker must launch a false 3128 valid on a false candidate, per above, which is a very difficult 3129 attack to coordinate. 3131 17.4. Insider Attacks 3133 In addition to attacks where the attacker is a third party trying to 3134 insert fake candidate information or stun messages, there are attacks 3135 possible with ICE when the attacker is an authenticated and valid 3136 participant in the ICE exchange. 3138 17.4.1. STUN Amplification Attack 3140 The STUN amplification attack is similar to the voice hammer. 3141 However, instead of voice packets being directed to the target, STUN 3142 connectivity checks are directed to the target. The attacker sends 3143 an a large number of candidates, say, 50. The responding agent 3144 receives the candidate information, and starts its checks, which are 3145 directed at the target, and consequently, never generate a response. 3146 The answerer will start a new connectivity check every Ta ms (say, 3147 Ta=20ms). However, the retransmission timers are set to a large 3148 number due to the large number of candidates. As a consequence, 3149 packets will be sent at an interval of one every Ta milliseconds, and 3150 then with increasing intervals after that. Thus, STUN will not send 3151 packets at a rate faster than data would be sent, and the STUN 3152 packets persist only briefly, until ICE fails for the session. 3153 Nonetheless, this is an amplification mechanism. 3155 It is impossible to eliminate the amplification, but the volume can 3156 be reduced through a variety of heuristics. ICE agents SHOULD limit 3157 the total number of connectivity checks they perform to 100. 3158 Additionally, agents MAY limit the number of candidates they'll 3159 accept. 3161 Frequently, protocols that wish to avoid these kinds of attacks force 3162 the initiator to wait for a response prior to sending the next 3163 message. However, in the case of ICE, this is not possible. It is 3164 not possible to differentiate the following two cases: 3166 o There was no response because the initiator is being used to 3167 launch a DoS attack against an unsuspecting target that will not 3168 respond. 3170 o There was no response because the IP address and port are not 3171 reachable by the initiator. 3173 In the second case, another check should be sent at the next 3174 opportunity, while in the former case, no further checks should be 3175 sent. 3177 18. STUN Extensions 3179 18.1. New Attributes 3181 This specification defines four new STUN attributes, PRIORITY, USE- 3182 CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. 3184 The PRIORITY attribute indicates the priority that is to be 3185 associated with a peer reflexive candidate, should one be discovered 3186 by this check. It is a 32-bit unsigned integer, and has an attribute 3187 value of 0x0024. 3189 The USE-CANDIDATE attribute indicates that the candidate pair 3190 resulting from this check should be used for transmission of data. 3191 The attribute has no content (the Length field of the attribute is 3192 zero); it serves as a flag. It has an attribute value of 0x0025. 3194 The ICE-CONTROLLED attribute is present in a Binding request and 3195 indicates that the client believes it is currently in the controlled 3196 role. The content of the attribute is a 64-bit unsigned integer in 3197 network byte order, which contains a random number. The number is 3198 used for solving role conflicts, when it is referred to as the tie- 3199 breaker value. An ICE agent MUST use the same number for all Binding 3200 requests, for all streams, within an ICE session. The agent MAY 3201 change the number when an ICE restart occurs. 3203 The ICE-CONTROLLING attribute is present in a Binding request and 3204 indicates that the client believes it is currently in the controlling 3205 role. The content of the attribute is a 64-bit unsigned integer in 3206 network byte order, which contains a random number. The number is 3207 used for solving role conflicts, when it is referred to as the tie- 3208 breaker value. An agent MUST use the same number for all Binding 3209 requests, for all streams, within an ICE session. The agent MAY 3210 change the number when an ICE restart occurs. 3212 18.2. New Error Response Codes 3214 This specification defines a single error response code: 3216 487 (Role Conflict): The Binding request contained either the ICE- 3217 CONTROLLING or ICE-CONTROLLED attribute, indicating an ICE role 3218 that conflicted with the server. The server compared the tie- 3219 breaker values of the client and the server and determined that 3220 the client needs to switch roles. 3222 19. Operational Considerations 3224 This section discusses issues relevant to network operators looking 3225 to deploy ICE. 3227 19.1. NAT and Firewall Types 3229 ICE was designed to work with existing NAT and firewall equipment. 3230 Consequently, it is not necessary to replace or reconfigure existing 3231 firewall and NAT equipment in order to facilitate deployment of ICE. 3232 Indeed, ICE was developed to be deployed in environments where the 3233 Voice over IP (VoIP) operator has no control over the IP network 3234 infrastructure, including firewalls and NAT. 3236 That said, ICE works best in environments where the NAT devices are 3237 "behave" compliant, meeting the recommendations defined in [RFC4787] 3238 and [RFC5382]. In networks with behave-compliant NAT, ICE will work 3239 without the need for a TURN server, thus improving voice quality, 3240 decreasing call setup times, and reducing the bandwidth demands on 3241 the network operator. 3243 19.2. Bandwidth Requirements 3245 Deployment of ICE can have several interactions with available 3246 network capacity that operators should take into consideration. 3248 19.2.1. STUN and TURN Server Capacity Planning 3250 First and foremost, ICE makes use of TURN and STUN servers, which 3251 would typically be located in the network operator's data centers. 3252 The STUN servers require relatively little bandwidth. For each 3253 component of each data stream, there will be one or more STUN 3254 transactions from each client to the STUN server. In a basic voice- 3255 only IPv4 VoIP deployment, there will be four transactions per call 3256 (one for RTP and one for RTCP, for both caller and callee). Each 3257 transaction is a single request and a single response, the former 3258 being 20 bytes long, and the latter, 28. Consequently, if a system 3259 has N users, and each makes four calls in a busy hour, this would 3260 require N*1.7bps. For one million users, this is 1.7 Mbps, a very 3261 small number (relatively speaking). 3263 TURN traffic is more substantial. The TURN server will see traffic 3264 volume equal to the STUN volume (indeed, if TURN servers are 3265 deployed, there is no need for a separate STUN server), in addition 3266 to the traffic for the actual data. The amount of calls requiring 3267 TURN for data relay is highly dependent on network topologies, and 3268 can and will vary over time. In a network with 100% behave-compliant 3269 NAT, it is exactly zero. At time of writing, large-scale consumer 3270 deployments were seeing between 5 and 10 percent of calls requiring 3271 TURN servers. Considering a voice-only deployment using G.711 (so 80 3272 kbps in each direction), with .2 erlangs during the busy hour, this 3273 is N*3.2 kbps. For a population of one million users, this is 3.2 3274 Gbps, assuming a 10% usage of TURN servers. 3276 19.2.2. Gathering and Connectivity Checks 3278 The process of gathering of candidates and performing of connectivity 3279 checks can be bandwidth intensive. ICE has been designed to pace 3280 both of these processes. The gathering phase and the connectivity 3281 check phase are meant to generate traffic at roughly the same 3282 bandwidth as the data traffic itself. This was done to ensure that, 3283 if a network is designed to support communication traffic of a 3284 certain type (voice, video, or just text), it will have sufficient 3285 capacity to support the ICE checks for that data. Of course, the ICE 3286 checks will cause a marginal increase in the total utilization; 3287 however, this will typically be an extremely small increase. 3289 Congestion due to the gathering and check phases has proven to be a 3290 problem in deployments that did not utilize pacing. Typically, 3291 access links became congested as the endpoints flooded the network 3292 with checks as fast as they can send them. Consequently, network 3293 operators should make sure that their ICE implementations support the 3294 pacing feature. Though this pacing does increase call setup times, 3295 it makes ICE network friendly and easier to deploy. 3297 19.2.3. Keepalives 3299 STUN keepalives (in the form of STUN Binding Indications) are sent in 3300 the middle of a data session. However, they are sent only in the 3301 absence of actual data traffic. In deployments that are not 3302 utilizing Voice Activity Detection (VAD), the keepalives are never 3303 used and there is no increase in bandwidth usage. When VAD is being 3304 used, keepalives will be sent during silence periods. This involves 3305 a single packet every 15-20 seconds, far less than the packet every 3306 20-30 ms that is sent when there is voice. Therefore, keepalives 3307 don't have any real impact on capacity planning. 3309 19.3. ICE and ICE-lite 3311 Deployments utilizing a mix of ICE and ICE-lite interoperate 3312 perfectly. They have been explicitly designed to do so, without loss 3313 of function. 3315 However, ICE-lite can only be deployed in limited use cases. Those 3316 cases, and the caveats involved in doing so, are documented in 3317 Appendix A. 3319 19.4. Troubleshooting and Performance Management 3321 ICE utilizes end-to-end connectivity checks, and places much of the 3322 processing in the endpoints. This introduces a challenge to the 3323 network operator -- how can they troubleshoot ICE deployments? How 3324 can they know how ICE is performing? 3326 ICE has built-in features to help deal with these problems. 3327 Signaling servers, typically deployed in the data centers of the 3328 network operator, will see the contents of the candidate exchanges 3329 that convey the ICE parameters. These parameters include the type of 3330 each candidate (host, server reflexive, or relayed), along with their 3331 related addresses. Once ICE processing has completed, an updated 3332 candidate exchange takes place, signaling the selected address (and 3333 its type). This updated signaling is performed exactly for the 3334 purposes of educating network equipment (such as a diagnostic tool 3335 attached to a signaling) about the results of ICE processing. 3337 As a consequence, through the logs generated by a signaling server, a 3338 network operator can observe what types of candidates are being used 3339 for each call, and what address were selected by ICE. This is the 3340 primary information that helps evaluate how ICE is performing. 3342 19.5. Endpoint Configuration 3344 ICE relies on several pieces of data being configured into the 3345 endpoints. This configuration data includes timers, credentials for 3346 TURN servers, and hostnames for STUN and TURN servers. ICE itself 3347 does not provide a mechanism for this configuration. Instead, it is 3348 assumed that this information is attached to whatever mechanism is 3349 used to configure all of the other parameters in the endpoint. For 3350 SIP phones, standard solutions such as the configuration framework 3351 [RFC6080] have been defined. 3353 20. IANA Considerations 3355 The original ICE specification registered four new STUN attributes, 3356 and one new STUN error response. The STUN attributes and error 3357 response are reproduced here. In addition, this specification 3358 registers a new ICE option. 3360 20.1. STUN Attributes 3362 IANA has registered four STUN attributes: 3364 0x0024 PRIORITY 3365 0x0025 USE-CANDIDATE 3366 0x8029 ICE-CONTROLLED 3367 0x802A ICE-CONTROLLING 3369 20.2. STUN Error Responses 3371 IANA has registered following STUN error response code: 3373 487 Role Conflict: The client asserted an ICE role (controlling or 3374 controlled) that is in conflict with the role of the server. 3376 20.3. ICE Options 3378 IANA is requested to register the following ICE option in the "ICE 3379 Options" sub-registry of the "Interactive Connectivity Establishment 3380 (ICE) registry", following the procedures defined in [RFC6336]. 3382 ICE Option name: 3384 ice2 3386 Contact: 3388 Name: Christer Holmberg 3389 E-mail: christer.holmberg(at)ericsson(dot)com 3390 Address: Oy LM Ericsson Ab, 02420 Jorvas, FINLAND 3392 Change control: 3394 IESG 3396 Description: 3398 The ICE option indicates that the ICE agent using the ICE option 3399 is compliant and implemented according to RFC XXXX. 3401 Reference: 3403 RFC XXXX 3405 21. IAB Considerations 3407 The IAB has studied the problem of "Unilateral Self-Address Fixing", 3408 which is the general process by which an ICE agent attempts to 3409 determine its address in another realm on the other side of a NAT 3410 through a collaborative protocol reflection mechanism [RFC3424]. ICE 3411 is an example of a protocol that performs this type of function. 3412 Interestingly, the process for ICE is not unilateral, but bilateral, 3413 and the difference has a significant impact on the issues raised by 3414 IAB. Indeed, ICE can be considered a B-SAF (Bilateral Self-Address 3415 Fixing) protocol, rather than an UNSAF protocol. Regardless, the IAB 3416 has mandated that any protocols developed for this purpose document a 3417 specific set of considerations. This section meets those 3418 requirements. 3420 21.1. Problem Definition 3422 From RFC 3424, any UNSAF proposal must provide: 3424 Precise definition of a specific, limited-scope problem that is to 3425 be solved with the UNSAF proposal. A short-term fix should not be 3426 generalized to solve other problems; this is why "short-term fixes 3427 usually aren't". 3429 The specific problems being solved by ICE are: 3431 Provide a means for two peers to determine the set of transport 3432 addresses that can be used for communication. 3434 Provide a means for a agent to determine an address that is 3435 reachable by another peer with which it wishes to communicate. 3437 21.2. Exit Strategy 3439 From RFC 3424, any UNSAF proposal must provide: 3441 Description of an exit strategy/transition plan. The better 3442 short-term fixes are the ones that will naturally see less and 3443 less use as the appropriate technology is deployed. 3445 ICE itself doesn't easily get phased out. However, it is useful even 3446 in a globally connected Internet, to serve as a means for detecting 3447 whether a router failure has temporarily disrupted connectivity, for 3448 example. ICE also helps prevent certain security attacks that have 3449 nothing to do with NAT. However, what ICE does is help phase out 3450 other UNSAF mechanisms. ICE effectively picks amongst those 3451 mechanisms, prioritizing ones that are better, and deprioritizing 3452 ones that are worse. Local IPv6 addresses can be preferred. As NATs 3453 begin to dissipate as IPv6 is introduced, server reflexive and 3454 relayed candidates (both forms of UNSAF addresses) simply never get 3455 used, because higher-priority connectivity exists to the native host 3456 candidates. Therefore, the servers get used less and less, and can 3457 eventually be remove when their usage goes to zero. 3459 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 3460 be used to determine whether to use IPv6 or IPv4 when two dual-stack 3461 hosts communicate with SIP (IPv6 gets used). It can also allow a 3462 network with both 6to4 and native v6 connectivity to determine which 3463 address to use when communicating with a peer. 3465 21.3. Brittleness Introduced by ICE 3467 From RFC 3424, any UNSAF proposal must provide: 3469 Discussion of specific issues that may render systems more 3470 "brittle". For example, approaches that involve using data at 3471 multiple network layers create more dependencies, increase 3472 debugging challenges, and make it harder to transition. 3474 ICE actually removes brittleness from existing UNSAF mechanisms. In 3475 particular, classic STUN (as described in RFC 3489 [RFC3489]) has 3476 several points of brittleness. One of them is the discovery process 3477 that requires an ICE agent to try to classify the type of NAT it is 3478 behind. This process is error-prone. With ICE, that discovery 3479 process is simply not used. Rather than unilaterally assessing the 3480 validity of the address, its validity is dynamically determined by 3481 measuring connectivity to a peer. The process of determining 3482 connectivity is very robust. 3484 Another point of brittleness in classic STUN and any other unilateral 3485 mechanism is its absolute reliance on an additional server. ICE 3486 makes use of a server for allocating unilateral addresses, but allows 3487 agents to directly connect if possible. Therefore, in some cases, 3488 the failure of a STUN server would still allow for a call to progress 3489 when ICE is used. 3491 Another point of brittleness in classic STUN is that it assumes that 3492 the STUN server is on the public Internet. Interestingly, with ICE, 3493 that is not necessary. There can be a multitude of STUN servers in a 3494 variety of address realms. ICE will discover the one that has 3495 provided a usable address. 3497 The most troubling point of brittleness in classic STUN is that it 3498 doesn't work in all network topologies. In cases where there is a 3499 shared NAT between each agent and the STUN server, traditional STUN 3500 may not work. With ICE, that restriction is removed. 3502 Classic STUN also introduces some security considerations. 3503 Fortunately, those security considerations are also mitigated by ICE. 3505 Consequently, ICE serves to repair the brittleness introduced in 3506 classic STUN, and does not introduce any additional brittleness into 3507 the system. 3509 The penalty of these improvements is that ICE increases session 3510 establishment times. 3512 21.4. Requirements for a Long-Term Solution 3514 From RFC 3424, any UNSAF proposal must provide: 3516 ... requirements for longer term, sound technical solutions -- 3517 contribute to the process of finding the right longer term 3518 solution. 3520 Our conclusions from RFC 3489 remain unchanged. However, we feel ICE 3521 actually helps because we believe it can be part of the long-term 3522 solution. 3524 21.5. Issues with Existing NAPT Boxes 3526 From RFC 3424, any UNSAF proposal must provide: 3528 Discussion of the impact of the noted practical issues with 3529 existing, deployed NA[P]Ts and experience reports. 3531 A number of NAT boxes are now being deployed into the market that try 3532 to provide "generic" ALG functionality. These generic ALGs hunt for 3533 IP addresses, either in text or binary form within a packet, and 3534 rewrite them if they match a binding. This interferes with classic 3535 STUN. However, the update to STUN [RFC5389] uses an encoding that 3536 hides these binary addresses from generic ALGs. 3538 Existing NAPT boxes have non-deterministic and typically short 3539 expiration times for UDP-based bindings. This requires 3540 implementations to send periodic keepalives to maintain those 3541 bindings. ICE uses a default of 15 s, which is a very conservative 3542 estimate. Eventually, over time, as NAT boxes become compliant to 3543 behave [RFC4787], this minimum keepalive will become deterministic 3544 and well-known, and the ICE timers can be adjusted. Having a way to 3545 discover and control the minimum keepalive interval would be far 3546 better still. 3548 22. Changes from RFC 5245 3550 Following is the list of changes from RFC 5245 3552 o The specification was generalized to be more usable with any 3553 protocol and the parts that are specific to SIP and SDP were moved 3554 to a SIP/SDP usage document [I-D.ietf-mmusic-ice-sip-sdp]. 3556 o Default candidates, multiple components, ICE mismatch detection, 3557 subsequent offer/answer, and role conflict resolution were made 3558 optional since they are not needed with every protocol using ICE. 3560 o With IPv6, the precedence rules of RFC 6724 are used instead of 3561 the obsoleted RFC 3483 and using address preferences provided by 3562 the host operating system is recommended. 3564 o Candidate gathering rules regarding loopback addresses and IPv6 3565 addresses were clarified. 3567 23. Acknowledgements 3569 Most of the text in this document comes from the original ICE 3570 specification, RFC 5245. The authors would like to thank everyone 3571 who has contributed to that document. For additional contributions 3572 to this revision of the specification we would like to thank Emil 3573 Ivov, Paul Kyzivat, Pal-Erik Martinsen, Simon Perrault, Eric 3574 Rescorla, Thomas Stach, Peter Thatcher, Martin Thomson, Justin 3575 Uberti, Suhas Nandakumar, Taylor Brandstetter, Peter Saint-Andre, 3576 Harald Alvestrand and Roman Shpount. 3578 24. References 3580 24.1. Normative References 3582 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3583 Requirement Levels", BCP 14, RFC 2119, 3584 DOI 10.17487/RFC2119, March 1997, . 3587 [RFC4941] Narten, T., Draves, R., and S. Krishnan, "Privacy 3588 Extensions for Stateless Address Autoconfiguration in 3589 IPv6", RFC 4941, DOI 10.17487/RFC4941, September 2007, 3590 . 3592 [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, 3593 "Session Traversal Utilities for NAT (STUN)", RFC 5389, 3594 DOI 10.17487/RFC5389, October 2008, . 3597 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3598 Relays around NAT (TURN): Relay Extensions to Session 3599 Traversal Utilities for NAT (STUN)", RFC 5766, 3600 DOI 10.17487/RFC5766, April 2010, . 3603 [RFC6336] Westerlund, M. and C. Perkins, "IANA Registry for 3604 Interactive Connectivity Establishment (ICE) Options", 3605 RFC 6336, DOI 10.17487/RFC6336, July 2011, 3606 . 3608 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3609 "Default Address Selection for Internet Protocol Version 6 3610 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3611 . 3613 24.2. Informative References 3615 [RFC3605] Huitema, C., "Real Time Control Protocol (RTCP) attribute 3616 in Session Description Protocol (SDP)", RFC 3605, 3617 DOI 10.17487/RFC3605, October 2003, . 3620 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3621 A., Peterson, J., Sparks, R., Handley, M., and E. 3622 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3623 DOI 10.17487/RFC3261, June 2002, . 3626 [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model 3627 with Session Description Protocol (SDP)", RFC 3264, 3628 DOI 10.17487/RFC3264, June 2002, . 3631 [RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, 3632 "STUN - Simple Traversal of User Datagram Protocol (UDP) 3633 Through Network Address Translators (NATs)", RFC 3489, 3634 DOI 10.17487/RFC3489, March 2003, . 3637 [RFC3235] Senie, D., "Network Address Translator (NAT)-Friendly 3638 Application Design Guidelines", RFC 3235, 3639 DOI 10.17487/RFC3235, January 2002, . 3642 [RFC3303] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and 3643 A. Rayhan, "Middlebox communication architecture and 3644 framework", RFC 3303, DOI 10.17487/RFC3303, August 2002, 3645 . 3647 [RFC3102] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, 3648 "Realm Specific IP: Framework", RFC 3102, 3649 DOI 10.17487/RFC3102, October 2001, . 3652 [RFC3103] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, 3653 "Realm Specific IP: Protocol Specification", RFC 3103, 3654 DOI 10.17487/RFC3103, October 2001, . 3657 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3658 UNilateral Self-Address Fixing (UNSAF) Across Network 3659 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3660 November 2002, . 3662 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3663 Jacobson, "RTP: A Transport Protocol for Real-Time 3664 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3665 July 2003, . 3667 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3668 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3669 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3670 . 3672 [RFC3879] Huitema, C. and B. Carpenter, "Deprecating Site Local 3673 Addresses", RFC 3879, DOI 10.17487/RFC3879, September 3674 2004, . 3676 [RFC4038] Shin, M-K., Ed., Hong, Y-G., Hagino, J., Savola, P., and 3677 E. Castro, "Application Aspects of IPv6 Transition", 3678 RFC 4038, DOI 10.17487/RFC4038, March 2005, 3679 . 3681 [RFC4091] Camarillo, G. and J. Rosenberg, "The Alternative Network 3682 Address Types (ANAT) Semantics for the Session Description 3683 Protocol (SDP) Grouping Framework", RFC 4091, 3684 DOI 10.17487/RFC4091, June 2005, . 3687 [RFC4092] Camarillo, G. and J. Rosenberg, "Usage of the Session 3688 Description Protocol (SDP) Alternative Network Address 3689 Types (ANAT) Semantics in the Session Initiation Protocol 3690 (SIP)", RFC 4092, DOI 10.17487/RFC4092, June 2005, 3691 . 3693 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 3694 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 3695 2006, . 3697 [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 3698 Description Protocol", RFC 4566, DOI 10.17487/RFC4566, 3699 July 2006, . 3701 [RFC2475] Blake, S., Black, D., Carlson, M., Davies, E., Wang, Z., 3702 and W. Weiss, "An Architecture for Differentiated 3703 Services", RFC 2475, DOI 10.17487/RFC2475, December 1998, 3704 . 3706 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3707 and E. Lear, "Address Allocation for Private Internets", 3708 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3709 . 3711 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3712 Translation (NAT) Behavioral Requirements for Unicast 3713 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3714 2007, . 3716 [RFC5761] Perkins, C. and M. Westerlund, "Multiplexing RTP Data and 3717 Control Packets on a Single Port", RFC 5761, 3718 DOI 10.17487/RFC5761, April 2010, . 3721 [RFC4103] Hellstrom, G. and P. Jones, "RTP Payload for Text 3722 Conversation", RFC 4103, DOI 10.17487/RFC4103, June 2005, 3723 . 3725 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3726 (ICE): A Protocol for Network Address Translator (NAT) 3727 Traversal for Offer/Answer Protocols", RFC 5245, 3728 DOI 10.17487/RFC5245, April 2010, . 3731 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 3732 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 3733 RFC 5382, DOI 10.17487/RFC5382, October 2008, 3734 . 3736 [RFC6080] Petrie, D. and S. Channabasappa, Ed., "A Framework for 3737 Session Initiation Protocol User Agent Profile Delivery", 3738 RFC 6080, DOI 10.17487/RFC6080, March 2011, 3739 . 3741 [RFC6146] Bagnulo, M., Matthews, P., and I. van Beijnum, "Stateful 3742 NAT64: Network Address and Protocol Translation from IPv6 3743 Clients to IPv4 Servers", RFC 6146, DOI 10.17487/RFC6146, 3744 April 2011, . 3746 [RFC6147] Bagnulo, M., Sullivan, A., Matthews, P., and I. van 3747 Beijnum, "DNS64: DNS Extensions for Network Address 3748 Translation from IPv6 Clients to IPv4 Servers", RFC 6147, 3749 DOI 10.17487/RFC6147, April 2011, . 3752 [RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, 3753 "TCP Candidates with Interactive Connectivity 3754 Establishment (ICE)", RFC 6544, DOI 10.17487/RFC6544, 3755 March 2012, . 3757 [RFC7050] Savolainen, T., Korhonen, J., and D. Wing, "Discovery of 3758 the IPv6 Prefix Used for IPv6 Address Synthesis", 3759 RFC 7050, DOI 10.17487/RFC7050, November 2013, 3760 . 3762 [I-D.ietf-mmusic-ice-sip-sdp] 3763 Petit-Huguenin, M., Keranen, A., and S. Nandakumar, 3764 "Session Description Protocol (SDP) Offer/Answer 3765 procedures for Interactive Connectivity Establishment 3766 (ICE)", draft-ietf-mmusic-ice-sip-sdp-14 (work in 3767 progress), October 2017. 3769 [RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy 3770 Considerations for IPv6 Address Generation Mechanisms", 3771 RFC 7721, DOI 10.17487/RFC7721, March 2016, 3772 . 3774 [I-D.ietf-ice-dualstack-fairness] 3775 Martinsen, P., Reddy, T., and P. Patil, "ICE Multihomed 3776 and IPv4/IPv6 Dual Stack Guidelines", draft-ietf-ice- 3777 dualstack-fairness-07 (work in progress), November 2016. 3779 Appendix A. Lite and Full Implementations 3781 ICE allows for two types of implementations. A full implementation 3782 supports the controlling and controlled roles in a session, and can 3783 also perform address gathering. In contrast, a lite implementation 3784 is a minimalist implementation that does little but respond to STUN 3785 checks. 3787 Because ICE requires both endpoints to support it in order to bring 3788 benefits to either endpoint, incremental deployment of ICE in a 3789 network is more complicated. Many sessions involve an endpoint that 3790 is, by itself, not behind a NAT and not one that would worry about 3791 NAT traversal. A very common case is to have one endpoint that 3792 requires NAT traversal (such as a VoIP hard phone or soft phone) make 3793 a call to one of these devices. Even if the phone supports a full 3794 ICE implementation, ICE won't be used at all if the other device 3795 doesn't support it. The lite implementation allows for a low-cost 3796 entry point for these devices. Once they support the lite 3797 implementation, full implementations can connect to them and get the 3798 full benefits of ICE. 3800 Consequently, a lite implementation is only appropriate for devices 3801 that will *always* be connected to the public Internet and have a 3802 public IP address at which it can receive packets from any 3803 correspondent. ICE will not function when a lite implementation is 3804 placed behind a NAT. 3806 ICE allows a lite implementation to have a single IPv4 host candidate 3807 and several IPv6 addresses. In that case, candidate pairs are 3808 selected by the controlling agent using a static algorithm, such as 3809 the one in RFC 6724, which is recommended by this specification. 3811 However, static mechanisms for address selection are always prone to 3812 error, since they cannot ever reflect the actual topology and can 3813 never provide actual guarantees on connectivity. They are always 3814 heuristics. Consequently, if an ICE agent is implementing ICE just 3815 to select between its IPv4 and IPv6 addresses, and none of its IP 3816 addresses are behind NAT, usage of full ICE is still RECOMMENDED in 3817 order to provide the most robust form of address selection possible. 3819 It is important to note that the lite implementation was added to 3820 this specification to provide a stepping stone to full 3821 implementation. Even for devices that are always connected to the 3822 public Internet with just a single IPv4 address, a full 3823 implementation is preferable if achievable. Full implementations 3824 also obtain the security benefits of ICE unrelated to NAT traversal; 3825 in particular, the voice hammer attack described in Section 17 is 3826 prevented only for full implementations, not lite. Finally, it is 3827 often the case that a device that finds itself with a public address 3828 today will be placed in a network tomorrow where it will be behind a 3829 NAT. It is difficult to definitively know, over the lifetime of a 3830 device or product, that it will always be used on the public 3831 Internet. Full implementation provides assurance that communications 3832 will always work. 3834 Appendix B. Design Motivations 3836 ICE contains a number of normative behaviors that may themselves be 3837 simple, but derive from complicated or non-obvious thinking or use 3838 cases that merit further discussion. Since these design motivations 3839 are not necessary to understand for purposes of implementation, they 3840 are discussed here in an appendix to the specification. This section 3841 is non-normative. 3843 B.1. Pacing of STUN Transactions 3845 STUN transactions used to gather candidates and to verify 3846 connectivity are paced out at an approximate rate of one new 3847 transaction every Ta milliseconds. Each transaction, in turn, has a 3848 retransmission timer RTO that is a function of Ta as well. Why are 3849 these transactions paced, and why are these formulas used? 3851 Sending of these STUN requests will often have the effect of creating 3852 bindings on NAT devices between the client and the STUN servers. 3853 Experience has shown that many NAT devices have upper limits on the 3854 rate at which they will create new bindings. Experiments have shown 3855 that once every 5 ms is well supported. This is why Ta has a lower 3856 bound of 5 ms. Furthermore, transmission of these packets on the 3857 network makes use of bandwidth and needs to be rate limited by the 3858 ICE agent. Deployments based on earlier draft versions of [RFC5245] 3859 tended to overload rate-constrained access links and perform poorly 3860 overall, in addition to negatively impacting the network. As a 3861 consequence, the pacing ensures that the NAT device does not get 3862 overloaded and that traffic is kept at a reasonable rate. 3864 The definition of a "reasonable" rate is that STUN should not use 3865 more bandwidth than the RTP itself will use, once data starts 3866 flowing. The formula for Ta is designed so that, if a STUN packet 3867 were sent every Ta seconds, it would consume the same amount of 3868 bandwidth as RTP packets, summed across all data streams. Of course, 3869 STUN has retransmits, and the desire is to pace those as well. For 3870 this reason, RTO is set such that the first retransmit on the first 3871 transaction happens just as the first STUN request on the last 3872 transaction occurs. Pictorially: 3874 First Packets Retransmits 3876 | | 3877 | | 3878 -------+------ -------+------ 3879 / \ / \ 3880 / \ / \ 3882 +--+ +--+ +--+ +--+ +--+ +--+ 3883 |A1| |B1| |C1| |A2| |B2| |C2| 3884 +--+ +--+ +--+ +--+ +--+ +--+ 3886 ---+-------+-------+-------+-------+-------+------------ Time 3887 0 Ta 2Ta 3Ta 4Ta 5Ta 3889 In this picture, there are three transactions that will be sent (for 3890 example, in the case of candidate gathering, there are three host 3891 candidate/STUN server pairs). These are transactions A, B, and C. 3892 The retransmit timer is set so that the first retransmission on the 3893 first transaction (packet A2) is sent at time 3Ta. 3895 Subsequent retransmits after the first will occur even less 3896 frequently than Ta milliseconds apart, since STUN uses an exponential 3897 back-off on its retransmissions. 3899 B.2. Candidates with Multiple Bases 3901 Section 5.1.3 talks about eliminating candidates that have the same 3902 transport address and base. However, candidates with the same 3903 transport addresses but different bases are not redundant. When can 3904 an ICE agent have two candidates that have the same IP address and 3905 port, but different bases? Consider the topology of Figure 11: 3907 +----------+ 3908 | STUN Srvr| 3909 +----------+ 3910 | 3911 | 3912 ----- 3913 // \\ 3914 | | 3915 | B:net10 | 3916 | | 3917 \\ // 3918 ----- 3919 | 3920 | 3921 +----------+ 3922 | NAT | 3923 +----------+ 3924 | 3925 | 3926 ----- 3927 // \\ 3928 | A | 3929 |192.168/16 | 3930 | | 3931 \\ // 3932 ----- 3933 | 3934 | 3935 |192.168.1.100 ----- 3936 +----------+ // \\ +----------+ 3937 | | | | | | 3938 | Initiator|---------| C:net10 |-----------| Responder| 3939 | |10.0.1.100| | 10.0.1.101 | | 3940 +----------+ \\ // +----------+ 3941 ----- 3943 Figure 11: Identical Candidates with Different Bases 3945 In this case, the initiating agent is multihomed. It has one IP 3946 address, 10.0.1.100, on network C, which is a net 10 private network. 3947 The responding agent is on this same network. The initiating agent 3948 is also connected to network A, which is 192.168/16 and has an IP 3949 address of 192.168.1.100 on this network. There is a NAT on this 3950 network, natting into network B, which is another net 10 private 3951 network, but not connected to network C. There is a STUN server on 3952 network B. 3954 The initiating agent obtains a host candidate on its IP address on 3955 network C (10.0.1.100:2498) and a host candidate on its IP address on 3956 network A (192.168.1.100:3344). It performs a STUN query to its 3957 configured STUN server from 192.168.1.100:3344. This query passes 3958 through the NAT, which happens to assign the binding 10.0.1.100:2498. 3959 The STUN server reflects this in the STUN Binding response. Now, the 3960 initiating agent has obtained a server reflexive candidate with a 3961 transport address that is identical to a host candidate 3962 (10.0.1.100:2498). However, the server reflexive candidate has a 3963 base of 192.168.1.100:3344, and the host candidate has a base of 3964 10.0.1.100:2498. 3966 B.3. Purpose of the Related Address and Related Port Attributes 3968 The candidate attribute contains two values that are not used at all 3969 by ICE itself -- related address and related port. Why are they 3970 present? 3972 There are two motivations for its inclusion. The first is 3973 diagnostic. It is very useful to know the relationship between the 3974 different types of candidates. By including it, an ICE agent can 3975 know which relayed candidate is associated with which reflexive 3976 candidate, which in turn is associated with a specific host 3977 candidate. When checks for one candidate succeed and not for others, 3978 this provides useful diagnostics on what is going on in the network. 3980 The second reason has to do with off-path Quality of Service (QoS) 3981 mechanisms. When ICE is used in environments such as PacketCable 3982 2.0, proxies will, in addition to performing normal SIP operations, 3983 inspect the SDP in SIP messages, and extract the IP address and port 3984 for data traffic. They can then interact, through policy servers, 3985 with access routers in the network, to establish guaranteed QoS for 3986 the data flows. This QoS is provided by classifying the RTP traffic 3987 based on 5-tuple, and then providing it a guaranteed rate, or marking 3988 its Diffserv codepoints appropriately. When a residential NAT is 3989 present, and a relayed candidate gets selected for data, this relayed 3990 candidate will be a transport address on an actual TURN server. That 3991 address says nothing about the actual transport address in the access 3992 router that would be used to classify packets for QoS treatment. 3993 Rather, the server reflexive candidate towards the TURN server is 3994 needed. By carrying the translation in the SDP, the proxy can use 3995 that transport address to request QoS from the access router. 3997 B.4. Importance of the STUN Username 3999 ICE requires the usage of message integrity with STUN using its 4000 short-term credential functionality. The actual short-term 4001 credential is formed by exchanging username fragments in the 4002 candidate exchange. The need for this mechanism goes beyond just 4003 security; it is actually required for correct operation of ICE in the 4004 first place. 4006 Consider ICE agents L, R, and Z. L and R are within private 4007 enterprise 1, which is using 10.0.0.0/8. Z is within private 4008 enterprise 2, which is also using 10.0.0.0/8. As it turns out, R and 4009 Z both have IP address 10.0.1.1. L sends candidates to Z. Z, in 4010 responds L with its host candidates. In this case, those candidates 4011 are 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, R is in a 4012 session at that same time, and is also using 10.0.1.1:8866 and 4013 10.0.1.1:8877 as host candidates. This means that R is prepared to 4014 accept STUN messages on those ports, just as Z is. L will send a 4015 STUN request to 10.0.1.1:8866 and another to 10.0.1.1:8877. However, 4016 these do not go to Z as expected. Instead, they go to R! If R just 4017 replied to them, L would believe it has connectivity to Z, when in 4018 fact it has connectivity to a completely different user, R. To fix 4019 this, the STUN short-term credential mechanisms are used. The 4020 username fragments are sufficiently random that it is highly unlikely 4021 that R would be using the same values as Z. Consequently, R would 4022 reject the STUN request since the credentials were invalid. In 4023 essence, the STUN username fragments provide a form of transient host 4024 identifiers, bound to a particular session established as part of the 4025 candidate exchange. 4027 An unfortunate consequence of the non-uniqueness of IP addresses is 4028 that, in the above example, R might not even be an ICE agent. It 4029 could be any host, and the port to which the STUN packet is directed 4030 could be any ephemeral port on that host. If there is an application 4031 listening on this socket for packets, and it is not prepared to 4032 handle malformed packets for whatever protocol is in use, the 4033 operation of that application could be affected. Fortunately, since 4034 the ports exchanged are ephemeral and usually drawn from the dynamic 4035 or registered range, the odds are good that the port is not used to 4036 run a server on host R, but rather is the agent side of some 4037 protocol. This decreases the probability of hitting an allocated 4038 port, due to the transient nature of port usage in this range. 4039 However, the possibility of a problem does exist, and network 4040 deployers should be prepared for it. Note that this is not a problem 4041 specific to ICE; stray packets can arrive at a port at any time for 4042 any type of protocol, especially ones on the public Internet. As 4043 such, this requirement is just restating a general design guideline 4044 for Internet applications -- be prepared for unknown packets on any 4045 port. 4047 B.5. The Candidate Pair Priority Formula 4049 The priority for a candidate pair has an odd form. It is: 4051 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 4053 Why is this? When the candidate pairs are sorted based on this 4054 value, the resulting sorting has the MAX/MIN property. This means 4055 that the pairs are first sorted based on decreasing value of the 4056 minimum of the two priorities. For pairs that have the same value of 4057 the minimum priority, the maximum priority is used to sort amongst 4058 them. If the max and the min priorities are the same, the 4059 controlling agent's priority is used as the tie-breaker in the last 4060 part of the expression. The factor of 2*32 is used since the 4061 priority of a single candidate is always less than 2*32, resulting in 4062 the pair priority being a "concatenation" of the two component 4063 priorities. This creates the MAX/MIN sorting. MAX/MIN ensures that, 4064 for a particular ICE agent, a lower-priority candidate is never used 4065 until all higher-priority candidates have been tried. 4067 B.6. Why Are Keepalives Needed? 4069 Once data begins flowing on a candidate pair, it is still necessary 4070 to keep the bindings alive at intermediate NATs for the duration of 4071 the session. Normally, the data stream packets themselves (e.g., 4072 RTP) meet this objective. However, several cases merit further 4073 discussion. Firstly, in some RTP usages, such as SIP, the data 4074 streams can be "put on hold". This is accomplished by using the SDP 4075 "sendonly" or "inactive" attributes, as defined in RFC 3264 4076 [RFC3264]. RFC 3264 directs implementations to cease transmission of 4077 data in these cases. However, doing so may cause NAT bindings to 4078 timeout, and data won't be able to come off hold. 4080 Secondly, some RTP payload formats, such as the payload format for 4081 text conversation [RFC4103], may send packets so infrequently that 4082 the interval exceeds the NAT binding timeouts. 4084 Thirdly, if silence suppression is in use, long periods of silence 4085 may cause data transmission to cease sufficiently long for NAT 4086 bindings to time out. 4088 For these reasons, the data packets themselves cannot be relied upon. 4089 ICE defines a simple periodic keepalive utilizing STUN Binding 4090 indications. This makes its bandwidth requirements highly 4091 predictable, and thus amenable to QoS reservations. 4093 B.7. Why Prefer Peer Reflexive Candidates? 4095 Section 5.1.2 describes procedures for computing the priority of 4096 candidate based on its type and local preferences. That section 4097 requires that the type preference for peer reflexive candidates 4098 always be higher than server reflexive. Why is that? The reason has 4099 to do with the security considerations in Section 17. It is much 4100 easier for an attacker to cause an ICE agent to use a false server 4101 reflexive candidate than it is for an attacker to cause an agent to 4102 use a false peer reflexive candidate. Consequently, attacks against 4103 address gathering with Binding requests are thwarted by ICE by 4104 preferring the peer reflexive candidates. 4106 B.8. Why Are Binding Indications Used for Keepalives? 4108 Data keepalives are described in Section 11. These keepalives make 4109 use of STUN when both endpoints are ICE capable. However, rather 4110 than using a Binding request transaction (which generates a 4111 response), the keepalives use an Indication. Why is that? 4113 The primary reason has to do with network QoS mechanisms. Once data 4114 begins flowing, network elements will assume that the data stream has 4115 a fairly regular structure, making use of periodic packets at fixed 4116 intervals, with the possibility of jitter. If an ICE agent is 4117 sending data packets, and then receives a Binding request, it would 4118 need to generate a response packet along with its data packets. This 4119 will increase the actual bandwidth requirements for the 5-tuple 4120 carrying the data packets, and introduce jitter in the delivery of 4121 those packets. Analysis has shown that this is a concern in certain 4122 layer 2 access networks that use fairly tight packet schedulers for 4123 data. 4125 Additionally, using a Binding Indication allows integrity to be 4126 disabled, allowing for better performance. This is useful for large- 4127 scale endpoints, such as PSTN gateways and SBCs. 4129 B.9. Selecting Candidate Type Preference 4131 One criterion for selection of the type and local preference values 4132 is the use of a data intermediary, such as a TURN server, a tunnel 4133 service such as VPN server, or NAT. With a data intermediary, if 4134 data is sent to that candidate, it will first transit the data 4135 intermediary before being received. Relayed candidates are one type 4136 of candidate that involves a data intermediary. Another are host 4137 candidates obtained from a VPN interface. When data is transited 4138 through a data intermediary, it can have a positive or negative 4139 effect on the latency between transmission and reception. It may or 4140 may not increase the packet losses, because of the additional router 4141 hops that may be taken. It may increase the cost of providing 4142 service, since data will be routed in and right back out of a data 4143 intermediary run by a provider. If these concerns are important, the 4144 type preference for relayed candidates must be carefully chosen. 4146 Another criterion for selection of preferences is IP address family. 4147 ICE works with both IPv4 and IPv6. It provides a transition 4148 mechanism that allows dual-stack hosts to prefer connectivity over 4149 IPv6, but to fall back to IPv4 in case the v6 networks are 4150 disconnected. Implementation should follow the guidelines from 4151 [I-D.ietf-ice-dualstack-fairness] to avoid excessive delays in the 4152 connectivity check phase if broken paths exist. 4154 Another criterion for selecting preferences is topological awareness. 4155 This is most useful for candidates that make use of intermediaries. 4156 In those cases, if an ICE agent has preconfigured or dynamically 4157 discovered knowledge of the topological proximity of the 4158 intermediaries to itself, it can use that to assign higher local 4159 preferences to candidates obtained from closer intermediaries. 4161 Another criterion for selecting preferences might be security or 4162 privacy. If a user is a telecommuter, and therefore connected to a 4163 corporate network and a local home network, the user may prefer their 4164 voice traffic to be routed over the VPN or similar tunnel in order to 4165 keep it on the corporate network when communicating within the 4166 enterprise, but use the local network when communicating with users 4167 outside of the enterprise. In such a case, a VPN address would have 4168 a higher local preference than any other address. 4170 Appendix C. Connectivity Check Bandwidth 4172 The tables below show, for IPv4 and IPv6, the bandwidth required for 4173 performing connectivity checks, using different Ta values (given in 4174 ms) and different ufrag sizes (given in bytes). 4176 The results were provided by Jusin Uberti (Google) 11th April 2016. 4178 IP version: IPv4 4179 Packet len (bytes): 108 + ufrag 4180 | 4181 ms | 4 8 12 16 4182 -----|------------------------ 4183 500 | 1.86k 1.98k 2.11k 2.24k 4184 200 | 4.64k 4.96k 5.28k 5.6k 4185 100 | 9.28k 9.92k 10.6k 11.2k 4186 50 | 18.6k 19.8k 21.1k 22.4k 4187 20 | 46.4k 49.6k 52.8k 56.0k 4188 10 | 92.8k 99.2k 105k 112k 4189 5 | 185k 198k 211k 224k 4190 2 | 464k 496k 528k 560k 4191 1 | 928k 992k 1.06M 1.12M 4193 IP version: IPv6 4194 Packet len (bytes): 128 + ufrag 4195 | 4196 ms | 4 8 12 16 4197 -----|------------------------ 4198 500 | 2.18k 2.3k 2.43k 2.56k 4199 200 | 5.44k 5.76k 6.08k 6.4k 4200 100 | 10.9k 11.5k 12.2k 12.8k 4201 50 | 21.8k 23.0k 24.3k 25.6k 4202 20 | 54.4k 57.6k 60.8k 64.0k 4203 10 | 108k 115k 121k 128k 4204 5 | 217k 230k 243k 256k 4205 2 | 544k 576k 608k 640k 4206 1 | 1.09M 1.15M 1.22M 1.28M 4208 Figure 12: Connectivity Check Bandwidth 4210 Authors' Addresses 4212 Ari Keranen 4213 Ericsson 4214 Hirsalantie 11 4215 02420 Jorvas 4216 Finland 4218 Email: ari.keranen@ericsson.com 4219 Christer Holmberg 4220 Ericsson 4221 Hirsalantie 11 4222 02420 Jorvas 4223 Finland 4225 Email: christer.holmberg@ericsson.com 4227 Jonathan Rosenberg 4228 jdrosen.net 4229 Monmouth, NJ 4230 US 4232 Email: jdrosen@jdrosen.net 4233 URI: http://www.jdrosen.net