idnits 2.17.1 draft-ietf-ice-rfc5245bis-15.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 1538 has weird spacing: '... | f-cp f-cp ...' == Line 1540 has weird spacing: '... | f-cp f-cp ...' == Line 1550 has weird spacing: '... | w-cp w-cp ...' == Line 1552 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 (November 3, 2017) is 2358 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 7, 2018 jdrosen.net 7 November 3, 2017 9 Interactive Connectivity Establishment (ICE): A Protocol for Network 10 Address Translator (NAT) Traversal 11 draft-ietf-ice-rfc5245bis-15 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 7, 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 . . . . . . . . . . . . . . . . . . . . . . 78 191 24. References . . . . . . . . . . . . . . . . . . . . . . . . . 78 192 24.1. Normative References . . . . . . . . . . . . . . . . . . 78 193 24.2. Informative References . . . . . . . . . . . . . . . . . 79 194 Appendix A. Lite and Full Implementations . . . . . . . . . . . 82 195 Appendix B. Design Motivations . . . . . . . . . . . . . . . . . 83 196 B.1. Pacing of STUN Transactions . . . . . . . . . . . . . . . 84 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 in the check list set. This is done 1411 by limiting the total number of candidate pairs in the check list 1412 set. The default limit of candidate pairs for the check list set is 1413 100, but the value MUST be configurable. The limit is enforced by, 1414 within in each check list, discarding lower-priority candidate pairs 1415 until the total number of candidate pairs in the check list set is 1416 smaller than the limit value. The discarding SHOULD be done evenly 1417 so that the number of candidate pairs in each check list is reduced 1418 the same amount. 1420 It is RECOMMENDED that a lower limit value than the default is picked 1421 when possible, and that the value is set to the maximum number of 1422 plausible candidate pairs that might be created in an actual 1423 deployment configuration. The requirement for configuration is meant 1424 to provide a tool for fixing this value in the field if, once 1425 deployed, it is found to be problematic. 1427 6.1.2.6. Computing Candidate Pair States 1429 Each candidate pair in the check list has a foundation (the 1430 combination of the foundations of the local and remote candidates in 1431 the pair) and one of the following states: 1433 Waiting: A check has not been sent for this pair, but the pair is 1434 not Frozen. 1436 In-Progress: A check has been sent for this pair, but the 1437 transaction is in progress. 1439 Succeeded: A check has been sent for this pair, and produced a 1440 successful result. 1442 Failed: A check has been sent for this pair, and failed (a response 1443 to the check was never received, or a failure response was 1444 received). 1446 Frozen: A check for this pair has not been sent, and it can not be 1447 sent until the pair is unfrozen and moved into the Waiting state. 1449 Pairs move between states as shown in Figure 7. 1451 +-----------+ 1452 | | 1453 | | 1454 | Frozen | 1455 | | 1456 | | 1457 +-----------+ 1458 | 1459 |unfreeze 1460 | 1461 V 1462 +-----------+ +-----------+ 1463 | | | | 1464 | | perform | | 1465 | Waiting |-------->|In-Progress| 1466 | | | | 1467 | | | | 1468 +-----------+ +-----------+ 1469 / | 1470 // | 1471 // | 1472 // | 1473 / | 1474 // | 1475 failure // |success 1476 // | 1477 / | 1478 // | 1479 // | 1480 // | 1481 V V 1482 +-----------+ +-----------+ 1483 | | | | 1484 | | | | 1485 | Failed | | Succeeded | 1486 | | | | 1487 | | | | 1488 +-----------+ +-----------+ 1490 Figure 7: Pair State FSM 1492 1. The initial states for each pair in a check list are computed by 1493 performing the following sequence of steps: 1495 2. The check lists are placed in an ordered list (the order is 1496 determined by each ICE usage), called the check list set. 1498 3. The ICE agent initially places all candidate pairs in the Frozen 1499 state. 1501 4. The agent sets all of the check lists in the check list set to 1502 the Running state. 1504 5. For each foundation, the agent sets the state of exactly one 1505 candidate pair to the Waiting state (unfreezing it). The 1506 candidate pair to unfreeze is chosen by finding the first 1507 candidate pair (ordered by lowest component ID and then highest 1508 priority if component IDs are equal) in the first check list 1509 (according to the usage-defined check list set order) that has 1510 that foundation. 1512 NOTE: The procedures above are different from RFC5245, where only 1513 candidate pairs in the first check list of were initially placed in 1514 the Waiting state. Now it applies to candidate pairs in the the 1515 first check list which have that foundation, even if the first check 1516 list to have that foundation is not the first check list in the check 1517 list set. 1519 The table in Figure 8 illustrates an example. 1521 Table legend: 1523 Each row (m1, m2,...) represents a check list associated with a data 1524 stream. m1 represents the first check list in the check list set. 1526 Each column (f1, f2,...) represents a foundation. Every candidate pair 1527 within a given column share the same foundation. 1529 f-cp represents a candidate pair in the Frozen state. 1531 w-cp represents a candidate pair in the Waiting state. 1533 1. The agent sets all of the pairs in the check list set to the Frozen 1534 state. 1536 f1 f2 f3 f4 f5 1537 ----------------------------- 1538 m1 | f-cp f-cp f-cp 1539 | 1540 m2 | f-cp f-cp f-cp f-cp 1541 | 1542 m3 | f-cp f-cp 1543 2. For each foundation, the candidate pair with the lowest component ID 1544 is placed in the Waiting state, unless a candidate pair associated with 1545 the same foundation has already been put in the Waiting state in one of 1546 the other examined check lists in the check list set. 1548 f1 f2 f3 f4 f5 1549 ----------------------------- 1550 m1 | w-cp w-cp w-cp 1551 | 1552 m2 | f-cp f-cp f-cp w-cp 1553 | 1554 m3 | f-cp w-cp 1556 In the first check list (m1) the candidate pair for each foundation is 1557 placed in the Waiting state, as no pairs for the same foundations have 1558 yet been placed in the Waiting state. 1560 In the second check list (m2) the candidate pair for foundation f4 is 1561 placed in the Waiting state. The candidate pair for foundations f1, f2 1562 and f3 are kept in the Frozen state, as candidate pairs for those 1563 foundations have already been placed in the Waiting state (within check 1564 list m1). 1566 In the third check list (m3) the candidate pair for foundation f5 is 1567 placed in the Waiting state. The candidate pair for foundation f1 is 1568 kept in the Frozen state, as a candidate pair for that foundation have 1569 already been placed in the Waiting state (within check list m1). 1571 Once each check list have been processed, one candidate pair for each 1572 foundation in the check list set has been placed in the Waiting state. 1574 Figure 8: Initial Pair State 1576 6.1.3. ICE State 1578 The ICE agent has a state determined by the state of the check lists. 1579 The state is Completed if all check lists are Completed, Failed if 1580 all check lists are Failed, and Running otherwise. 1582 6.1.4. Scheduling Checks 1584 6.1.4.1. Triggered Check Queue 1586 Once the ICE agent has computed the check lists and created the check 1587 list set, as described in Section 6.1.2, the agent will begin 1588 performing connectivity checks (ordinary and triggered). For 1589 triggered connectivity checks, the agent maintains a FIFO queue for 1590 each check list, referred to as the triggered check queue, which 1591 contains candidate pairs for which checks are to be sent at the next 1592 available opportunity. The triggered check queue is initially empty. 1594 6.1.4.2. Performing Connectivity Checks 1596 The generation of ordinary and triggered connectivity checks is 1597 governed by timer Ta. As soon as the initial states for the 1598 candidate pairs in the check list set have been set, a check is 1599 performed for a candidate pair within the first check list in the 1600 Running state, following the procedures in Section 7. After that, 1601 whenever Ta fires the next check list in the Running state in the 1602 check list set is picked, and a check is performed for a candidate 1603 within that check list. After the last check list in the Running 1604 state in the check list set has been processed, the first check list 1605 is picked again. Etc. 1607 Whenever Ta fires, the ICE agent will perform a check for a candidate 1608 pair within the picked check list by performing the following steps: 1610 1. If the triggered check queue associated with the check list 1611 contains one or more candidate pairs, the agent removes the top 1612 pair from the queue, performs a connectivity check on that pair, 1613 puts the candidate pair state to In-Progress, and aborts the 1614 subsequent steps. 1616 2. If there is no candidate pair in the Waiting state, and if there 1617 are one or more pairs in the Frozen state, for each pair in the 1618 Frozen state the agent checks the foundation associated with the 1619 pair. For a given foundation, if there is no pair (in any check 1620 list in the check list set) in the Waiting or In-Progress state, 1621 the agent puts the candidate pair state to Waiting and continues 1622 with the next step. 1624 3. If there are one or more candidate pairs in the Waiting state, 1625 the agent picks the highest-priority candidate pair (if there are 1626 multiple pairs with the same priority, the pair with the lowest 1627 component ID is picked) in the Waiting state, performs a 1628 connectivity check on that pair, puts the candidate pair par 1629 state to In-Progress, and abort the subsequent steps. 1631 4. If this step is reached, no check could be performed for the 1632 picked check list. So, without waiting for timer Ta to expire 1633 again, select the next check list in the Running state and return 1634 to step #1. If this happens for every single check list in the 1635 Running state, meaning there are no remaining candidate pairs to 1636 perform connectivity checks for, abort these steps. 1638 Once the agent has picked a candidate pair, for which a connectivity 1639 check is to be performed, the agent performs the check by sending a 1640 STUN request from the base associated with the local candidate of the 1641 pair to the remote candidate of the pair, as described in 1642 Section 7.2.4. 1644 Based on local policy, an agent MAY choose to terminate performing 1645 the connectivity checks for one or more checks lists in the check 1646 list set at any time. However, only the controlling agent is allowed 1647 to conclude ICE (Section 8). 1649 To compute the message integrity for the check, the agent uses the 1650 remote username fragment and password learned from the candidate 1651 information obtained from its peer. The local username fragment is 1652 known directly by the agent for its own candidate. 1654 The Initiator performs the ordinary checks on receiving the candidate 1655 information from the Peer (responder) and having formed the check 1656 lists. On the other hand the responding agent either performs the 1657 triggered or ordinary checks as described above. 1659 6.2. Lite Implementation Procedures 1661 Lite implementations skips most of the steps in Section 6 except for 1662 verifying the peer's ICE support and determining its role in the ICE 1663 processing. 1665 If the lite implementation is the controlling agent (which will only 1666 happen if the peer ICE agent is also a lite implementation), it 1667 selects a candidate pair based on the ones in the candidate exchange 1668 (for IPv4, there is only ever one pair), and then updating the peer 1669 with the new candidate information reflecting that selection, when 1670 needed (it is never needed for an IPv4-only host). The controlled 1671 agent is told which candidate pairs to use for each data stream, and 1672 no further candidate updates are needed to signal this information. 1674 7. Performing Connectivity Checks 1676 This section describes how connectivity checks are performed. 1678 An ICE agent MUST be compliant to [RFC5389]. A full implementation 1679 acts both as a STUN client and a STUN server, while a lite 1680 implementation only acts as a STUN server (as it does not generate 1681 connectivity checks). 1683 7.1. STUN Extensions 1685 ICE extends STUN by defining new attributes: PRIORITY, USE-CANDIDATE, 1686 ICE-CONTROLLED, and ICE-CONTROLLING. The new attributes are formally 1687 defined in Section 18.1. This section describes the usage of the new 1688 attributes. 1690 The new attributes are only applicable to ICE connectivity checks. 1692 7.1.1. PRIORITY 1694 The priority attribute MUST be included in a Binding request and be 1695 set to the value computed by the algorithm in Section 5.1.2 for the 1696 local candidate, but with the candidate type preference of peer 1697 reflexive candidates. 1699 7.1.2. USE-CANDIDATE 1701 The controlling agent MUST include the USE-CANDIDATE attribute in 1702 order to nominate a candidate pair Section 8.1.1. The controlled 1703 agent MUST NOT include the USE-CANDIDATE attribute in a Binding 1704 request. 1706 7.1.3. ICE-CONTROLLED and ICE-CONTROLLING 1708 The controlling agent MUST include the ICE-CONTROLLING attribute in a 1709 Binding request. The controlled agent MUST include the ICE- 1710 CONTROLLED attribute in a Binding request. 1712 The content of either attribute are used as tie-breaker values when 1713 an ICE role conflict occurs Section 7.3.1.1. 1715 7.2. STUN Client Procedures 1717 7.2.1. Creating Permissions for Relayed Candidates 1719 If the connectivity check is being sent using a relayed local 1720 candidate, the client MUST create a permission first if it has not 1721 already created one previously. It would have created one previously 1722 if it had told the TURN server to create a permission for the given 1723 relayed candidate towards the IP address of the remote candidate. To 1724 create the permission, the ICE agent follows the procedures defined 1725 in [RFC5766]. The permission MUST be created towards the IP address 1726 of the remote candidate. It is RECOMMENDED that the agent defer 1727 creation of a TURN channel until ICE completes, in which case 1728 permissions for connectivity checks are normally created using a 1729 CreatePermission request. Once established, the agent MUST keep the 1730 permission active until ICE concludes. 1732 7.2.2. Forming Credentials 1734 A connectivity check Binding request MUST utilize the STUN short-term 1735 credential mechanism. 1737 The username for the credential is formed by concatenating the 1738 username fragment provided by the peer with the username fragment of 1739 the ICE agent sending the request, separated by a colon (":"). 1741 The password is equal to the password provided by the peer. 1743 For example, consider the case where ICE agent L is the Initiating 1744 agent and ICE agent R is the Responding agent. Agent L included a 1745 username fragment of LFRAG for its candidates and a password of 1746 LPASS. Agent R provided a username fragment of RFRAG and a password 1747 of RPASS. A connectivity check from L to R utilizes the username 1748 RFRAG:LFRAG and a password of RPASS. A connectivity check from R to 1749 L utilizes the username LFRAG:RFRAG and a password of LPASS. The 1750 responses utilize the same usernames and passwords as the requests 1751 (note that the USERNAME attribute is not present in the response). 1753 7.2.3. DiffServ Treatment 1755 If an ICE agent is using Diffserv Codepoint markings [RFC2475] in its 1756 data packets, the agent SHOULD apply those same markings to its 1757 connectivity checks. 1759 If multiple DSCP markings are used on the data packets, the agent 1760 SHOULD choose one of them for use with the connectivity check. 1762 7.2.4. Sending the Request 1764 A connectivity check is generated by sending a Binding request from 1765 the base associated with a local candidate to a remote candidate. 1766 [RFC5389] describes how Binding requests are constructed and 1767 generated. 1769 Support for backwards compatibility with RFC 3489 MUST NOT be assumed 1770 when performing connectivity checks. The FINGERPRINT mechanism MUST 1771 be used for connectivity checks. 1773 7.2.5. Processing the Response 1775 This section defines additional procedures for processing Binding 1776 responses specific to ICE connectivity checks. 1778 When a Binding response is received, it is correlated to the 1779 corresponding Binding request using the transaction ID [RFC5389], 1780 which then associates the response with the candidate pair for which 1781 the Binding request was sent. After that, the response is processed 1782 according to the procedures for a role conflict, a failure, or a 1783 success, according to the procedures below. 1785 7.2.5.1. Role Conflict 1787 If the Binding request generates a 487 (Role Conflict) error 1788 response, and if the ICE agent included an ICE-CONTROLLED attribute 1789 in the request, the agent MUST switch to the controlling role. If 1790 the agent included an ICE-CONTROLLING attribute in the request, the 1791 agent MUST switch to the controlled role. 1793 Once the agent has switched its role, the agent MUST add the 1794 candidate pair whose check generated the 487 error response to the 1795 triggered check queue associated with the check list to which the 1796 pair belongs, and set the candidate pair state to Waiting. When the 1797 triggered connectivity check is later performed, the ICE-CONTROLLING/ 1798 ICE-CONTROLLED attribute of the Binding request will indicate the 1799 agent's new role. The agent MAY change the tie-breaker value. 1801 NOTE: A role switch requires an agent to recompute pair priorities 1802 (Section 6.1.2.3), since the priority values depend on the role. 1804 NOTE: A role switch will also impact whether the agent is responsible 1805 for nominating candidate pairs, and whether the agent is responsible 1806 for initiating the exchange of the updated candidate information with 1807 the peer once ICE is concluded. 1809 7.2.5.2. Failure 1811 This section describes cases when the candidate pair state is set to 1812 Failed. 1814 NOTE: When the ICE agent sets the candidate pair state to Failed as a 1815 result of a connectivity check error, the agent does not change the 1816 states of other candidate pairs with the same foundation. 1818 7.2.5.2.1. Non-Symmetric Transport Addresses 1820 The ICE agent MUST check that the source and destination transport 1821 addresses in the Binding request and response are symmetric. I.e., 1822 the source IP address and port of the response MUST be equal the 1823 destination IP address and port to which the Binding request was 1824 sent, and that the destination IP address and port of the response 1825 MUST be equal to the source IP address and port from which the 1826 Binding request was sent. If the addresses are not symmetric, the 1827 agent MUST set the candidate pair state to Failed. 1829 7.2.5.2.2. ICMP Error 1831 An ICE agent MAY support processing of ICMP errors for connectivity 1832 checks. If the agent supports processing of ICMP errors, and if a 1833 Binging request generates an ICMP error, the agent SHOULD set the 1834 state of the candidate pair to Failed. 1836 7.2.5.2.3. Timeout 1838 If the Binding request times out, the ICE agent SHOULD set the 1839 candidate pair state to Failed. 1841 7.2.5.2.4. Unrecoverable STUN Response 1843 If the Binding request generates a STUN error response that is 1844 unrecoverable [RFC5389] the ICE agent SHOULD set the candidate pair 1845 state to Failed. 1847 7.2.5.3. Success 1849 A connectivity check is considered a success if each of the following 1850 criteria is true: 1852 o The Binding request generated a success response; and 1854 o The source and destination transport addresses in the Binding 1855 request and response are symmetric. 1857 If a check is considered a success, the ICE agent performs (in order) 1858 the actions described in the following sections. 1860 7.2.5.3.1. Discovering Peer Reflexive Candidates 1862 The ICE agent MUST check the mapped address from the STUN response. 1863 If the transport address does not match any of the local candidates 1864 that the agent knows about, the mapped address represents a new 1865 candidate: a peer reflexive candidate. Like other candidates, a peer 1866 reflexive candidate has a type, base, priority, and foundation. They 1867 are computed as follows: 1869 o The type is peer reflexive. 1871 o The base is local candidate of the candidate pair from which the 1872 Binding request was sent. 1874 o The priority is the value of the PRIORITY attribute in the Binding 1875 request. 1877 o The foundation is described in Section 5.1.1.3. 1879 The peer reflexive candidate is then added to the list of local 1880 candidates for the data stream. The username fragment and password 1881 are the same as for all other local candidates for that data stream. 1883 The ICE agent does not need to pair the peer reflexive candidate with 1884 remote candidates, as a valid candidate pair will be created due to 1885 the procedures in Section 7.2.5.3.2. If an agent wishes to pair the 1886 peer reflexive candidate with remote candidates other than the one in 1887 the valid pair that will be generated, the agent MAY provide updated 1888 candidate information to the peer that includes the peer reflexive 1889 candidate. This will cause the peer reflexive candidate to be paired 1890 with all other remote candidates. 1892 7.2.5.3.2. Constructing a Valid Pair 1894 The ICE agent constructs a candidate pair whose local candidate 1895 equals the mapped address of the response, and whose remote candidate 1896 equals the destination address to which the request was sent. This 1897 is called a valid pair. 1899 The valid pair may equal the pair that generated the connectivity 1900 check, or it may equal a different pair in a check list (sometimes in 1901 a different check list than the one to which the pair that generated 1902 the connectivity checks), or it may be a pair not currently in any 1903 check list. 1905 The agent maintains a separate list, referred to as the valid list. 1906 There is a valid list for each check list in the check list set. The 1907 valid list will contain valid pairs. Initially each valid list is 1908 empty. 1910 Each valid pair within the valid list has a flag, called the 1911 nominated flag. When a valid pair is added to a valid list, the flag 1912 value is set to 'false'. 1914 The valid pair will be added to a valid list as follows: 1916 1. If the valid pair equals the pair that generated the check, the 1917 pair is added to the valid list associated with the check list to 1918 which the pair belongs; or 1920 2. If the valid pair equals another pair in a check list, that pair 1921 is added to the valid list associated with the check list of that 1922 pair. The pair that generated the check is not added to a valid 1923 list; or 1925 3. If the valid pair is not in any check list, the agent computes 1926 the priority for the pair based on the priority of each 1927 candidate, using the algorithm in Section 6.1.2. The priority of 1928 the local candidate depends on its type. Unless the type is peer 1929 reflexive, the priority is equal to the priority signaled for 1930 that candidate in the candidate exchange. If the type is peer 1931 reflexive, it is equal to the PRIORITY attribute the agent placed 1932 in the Binding request that just completed. The priority of the 1933 remote candidate is taken from the candidate information of the 1934 peer. If the candidate does not appear there, then the check 1935 must have been a triggered check to a new remote candidate. In 1936 that case, the priority is taken as the value of the PRIORITY 1937 attribute in the Binding request that triggered the check that 1938 just completed. The pair is then added to the valid list. 1940 NOTE: It will be very common that the valid pair will not be in any 1941 check list. Recall that the check list has pairs whose local 1942 candidates are never reflexive; those pairs had their local 1943 candidates converted to the base of the reflexive candidates, and 1944 then pruned if they were redundant. When the response to the Binding 1945 request arrives, the mapped address will be reflexive if there is a 1946 NAT between the two. In that case, the valid pair will have a local 1947 candidate that doesn't match any of the pairs in the check list. 1949 7.2.5.3.3. Updating Candidate Pair States 1951 The ICE agent sets the states of both the candidate pair that 1952 generated the check and the constructed valid pair (which may be 1953 different) to Succeeded. 1955 The agent MUST set the states for all other Frozen candidate pairs in 1956 all check lists with the same foundation to Waiting. 1958 NOTE: Within a given check list, candidate pairs with the same 1959 foundations will typically have different component ID values. 1961 7.2.5.3.4. Updating the Nominated Flag 1963 If the controlling agent sends a Binding request with the USE- 1964 CANDIDATE attribute set, and if the ICE agent receives a successful 1965 response to the request, the agent sets the nominated flag of the 1966 pair to true. If the request fails Section 7.2.5.2, the agent MUST 1967 remove the candidate pair from the valid list, set the candidate pair 1968 state to Failed and set the check list state to Failed. 1970 If the controlled agent receives a successful response to a Binding 1971 request sent by the agent, and that Binding request was triggered by 1972 a received Binding request with the USE-CANDIDATE attribute set 1973 Section 7.3.1.4, the agent sets the nominated flag of the pair to 1974 true. If the triggered request fails, the agent MUST remove the 1975 candidate pair from the valid list, set the candidate pair state to 1976 Failed and set the check list state to Failed. 1978 Once the nominated flag is set for a component of a data stream, it 1979 concludes the ICE processing for that component. See Section 8. 1981 7.2.5.4. Check List State Updates 1983 Regardless of whether a connectivity check was successful or failed, 1984 the completion of the check may require updating of check list 1985 states. For each check list in the check list set, if all of the 1986 candidate pairs are in either Failed or Succeeded state, and if there 1987 is not a valid pair in the valid list for each component of the data 1988 stream associated with the check list, the state of the check list is 1989 set to Failed. If there is a valid pair for each component in the 1990 valid list, the state of the check list is set to Succeeded. 1992 7.3. STUN Server Procedures 1994 An ICE agent (lite or full) MUST be prepared to receive Binding 1995 requests on the base of each candidate it included in its most recent 1996 candidate exchange. 1998 The agent MUST use the short-term credential mechanism (i.e., the 1999 MESSAGE-INTEGRITY attribute) to authenticate the request and perform 2000 a message integrity check. Likewise, the short-term credential 2001 mechanism MUST be used for the response. The agent MUST consider the 2002 username to be valid if it consists of two values separated by a 2003 colon, where the first value is equal to the username fragment 2004 generated by the agent in an candidate exchange for a session in- 2005 progress. It is possible (and in fact very likely) that the 2006 initiating agent will receive a Binding request prior to receiving 2007 the candidates from its peer. If this happens, the agent MUST 2008 immediately generate a response (including computation of the mapped 2009 address as described in Section 7.3.1.2). The agent has sufficient 2010 information at this point to generate the response; the password from 2011 the peer is not required. Once the answer is received, it MUST 2012 proceed with the remaining steps required, namely, Section 7.3.1.3, 2013 Section 7.3.1.4, and Section 7.3.1.5 for full implementations. In 2014 cases where multiple STUN requests are received before the answer, 2015 this may cause several pairs to be queued up in the triggered check 2016 queue. 2018 An agent MUST NOT utilize the ALTERNATE-SERVER mechanism, and MUST 2019 NOT support the backwards-compatibility mechanisms to RFC 3489. It 2020 MUST utilize the FINGERPRINT mechanism. 2022 If the agent is using Diffserv Codepoint markings [RFC2475] in its 2023 data packets, it SHOULD apply the same markings to Binding responses. 2024 The same would apply to any layer 2 markings the endpoint might be 2025 applying to data packets. 2027 7.3.1. Additional Procedures for Full Implementations 2029 This subsection defines the additional server procedures applicable 2030 to full implementations, when the full implementation accepts the 2031 Binding request. 2033 7.3.1.1. Detecting and Repairing Role Conflicts 2035 In certain usages of ICE (such as third party call control), both ICE 2036 agents may end up choosing the same role, resulting in a role 2037 conflict. The section describes a mechanism for detecting and 2038 repairing role conflicts. The usage document MUST specify whether 2039 this mechanism is needed. 2041 An agent MUST examine the Binding request for either the ICE- 2042 CONTROLLING or ICE-CONTROLLED attribute. It MUST follow these 2043 procedures: 2045 o If neither ICE-CONTROLLING nor ICE-CONTROLLED is present in the 2046 request, the peer agent may have implemented a previous version of 2047 this specification. There may be a conflict, but it cannot be 2048 detected. 2050 o If the agent is in the controlling role, and the ICE-CONTROLLING 2051 attribute is present in the request: 2053 * If the agent's tie-breaker value is larger than or equal to the 2054 contents of the ICE-CONTROLLING attribute, the agent generates 2055 a Binding error response and includes an ERROR-CODE attribute 2056 with a value of 487 (Role Conflict) but retains its role. 2058 * If the agent's tie-breaker value is less than the contents of 2059 the ICE-CONTROLLING attribute, the agent switches to the 2060 controlled role. 2062 o If the agent is in the controlled role, and the ICE-CONTROLLED 2063 attribute is present in the request: 2065 * If the agent's tie-breaker value is larger than or equal to the 2066 contents of the ICE-CONTROLLED attribute, the agent switches to 2067 the controlling role. 2069 * If the agent's tie-breaker value is less than the contents of 2070 the ICE-CONTROLLED attribute, the agent generates a Binding 2071 error response and includes an ERROR-CODE attribute with a 2072 value of 487 (Role Conflict) but retains its role. 2074 o If the agent is in the controlled role and the ICE-CONTROLLING 2075 attribute was present in the request, or the agent was in the 2076 controlling role and the ICE-CONTROLLED attribute was present in 2077 the request, there is no conflict. 2079 A change in roles will require an agent to recompute pair priorities 2080 (Section 6.1.2.3), since those priorities are a function of role. 2081 The change in role will also impact whether the agent is responsible 2082 for selecting nominated pairs and initiating exchange with updated 2083 candidate information upon conclusion of ICE. 2085 The remaining sections in Section 7.3.1 are followed if the agent 2086 generated a successful response to the Binding request, even if the 2087 agent changed roles. 2089 7.3.1.2. Computing Mapped Address 2091 For requests received on a relayed candidate, the source transport 2092 address used for STUN processing (namely, generation of the XOR- 2093 MAPPED-ADDRESS attribute) is the transport address as seen by the 2094 TURN server. That source transport address will be present in the 2095 XOR-PEER-ADDRESS attribute of a Data Indication message, if the 2096 Binding request was delivered through a Data Indication. If the 2097 Binding request was delivered through a ChannelData message, the 2098 source transport address is the one that was bound to the channel. 2100 7.3.1.3. Learning Peer Reflexive Candidates 2102 If the source transport address of the request does not match any 2103 existing remote candidates, it represents a new peer reflexive remote 2104 candidate. This candidate is constructed as follows: 2106 o The type is peer reflexive. 2108 o The priority is the value of the PRIORITY attribute in the Binding 2109 request. 2111 o The foundation is an arbitrary value, different from the 2112 foundations of all other remote candidates. If any subsequent 2113 candidate exchanges contain this peer reflexive candidate, it will 2114 signal the actual foundation for the candidate. 2116 o The component ID is the component ID of the local candidate to 2117 which the request was sent. 2119 This candidate is added to the list of remote candidates. However, 2120 the ICE agent does not pair this candidate with any local candidates. 2122 7.3.1.4. Triggered Checks 2124 Next, the agent constructs a pair whose local candidate has the 2125 transport address (as seen by the agent) on which the STUN request 2126 was received, and a remote candidate equal to the source transport 2127 address where the request came from (which may be the peer reflexive 2128 remote candidate that was just learned). The local candidate will 2129 either be a host candidate (for cases where the request was not 2130 received through a relay) or a relayed candidate (for cases where it 2131 is received through a relay). The local candidate can never be a 2132 server reflexive candidate. Since both candidates are known to the 2133 agent, it can obtain their priorities and compute the candidate pair 2134 priority. This pair is then looked up in the check list. There can 2135 be one of several outcomes: 2137 o If the pair is already on the check list: 2139 * If the state of that pair is Waiting or Frozen, a check for 2140 that pair is enqueued into the triggered check queue if not 2141 already present. 2143 * If the state of that pair is In-Progress, the agent cancels the 2144 in-progress transaction. Cancellation means that the agent 2145 will not retransmit the request, will not treat the lack of 2146 response to be a failure, but will wait the duration of the 2147 transaction timeout for a response. In addition, the agent 2148 MUST create a new connectivity check for that pair 2149 (representing a new STUN Binding request transaction) by 2150 enqueueing the pair in the triggered check queue. The state of 2151 the pair is then changed to Waiting. 2153 * If the state of the pair is Failed, it is changed to Waiting 2154 and the agent MUST create a new connectivity check for that 2155 pair (representing a new STUN Binding request transaction), by 2156 enqueueing the pair in the triggered check queue. 2158 * If the state of that pair is Succeeded, nothing further is 2159 done. 2161 These steps are done to facilitate rapid completion of ICE when both 2162 agents are behind NAT. 2164 o If the pair is not already on the check list: 2166 * The pair is inserted into the check list based on its priority. 2168 * Its state is set to Waiting. 2170 * The pair is enqueued into the triggered check queue. 2172 When a triggered check is to be sent, it is constructed and processed 2173 as described in Section 7.2.4. These procedures require the agent to 2174 know the transport address, username fragment, and password for the 2175 peer. The username fragment for the remote candidate is equal to the 2176 part after the colon of the USERNAME in the Binding request that was 2177 just received. Using that username fragment, the agent can check the 2178 candidates received from its peer (there may be more than one in 2179 cases of forking), and find this username fragment. The 2180 corresponding password is then picked. 2182 7.3.1.5. Updating the Nominated Flag 2184 If the controlled agent receives a Binding request with the USE- 2185 CANDIDATE attribute set, and if the ICE agent accepts the request, 2186 the following action is based on the state of the pair computed in 2187 Section 7.3.1.4: 2189 o If the state of this pair is Succeeded, it means that the check 2190 previously sent by this pair produced a successful response, and 2191 generated a valid pair (Section 7.2.5.3.2). The agent sets the 2192 nominated flag value of the pair to true. 2194 o If the received Binding request triggered a new check to be enqued 2195 in the triggered check queue (Section 7.3.1.4), once the check is 2196 sent and if it generates a successful response, and generates a 2197 valid pair, the agent sets the nominated flag of the pair to true. 2198 If the request fails Section 7.2.5.2, the agent MUST remove the 2199 candidate pair from the valid list, set the candidate pair state 2200 to Failed and set the check list state to Failed. 2202 If the controlled agent does not accept the request from the 2203 controlling agent, the controlled agent MUST reject the nomination 2204 request with an appropriate error code response (e.g., 400) 2205 [RFC5389]. 2207 Once the nominated flag is set for a component of a data stream, it 2208 concludes the ICE processing for that component. See Section 8. 2210 7.3.2. Additional Procedures for Lite Implementations 2212 If the controlled agent receives a Binding request with the USE- 2213 CANDIDATE attribute set, and if the ICE agent accepts the request, 2214 the agent constructs a candidate pair whose local candidate has the 2215 transport address on which the request was received, and whose remote 2216 candidate is equal to the source transport address of the request 2217 that was received. This candidate pair is assigned an arbitrary 2218 priority, and placed into the valid list of the associated check 2219 list. The agent sets the nominated flag for that pair to true. 2221 Once the nominated flag is set for a component of a data stream, it 2222 concludes the ICE processing for that component. See Section 8. 2224 8. Concluding ICE Processing 2226 This section describes how an ICE agent completes ICE. 2228 8.1. Procedures for Full Implementations 2230 Concluding ICE involves nominating pairs by the controlling agent and 2231 updating of state machinery. 2233 8.1.1. Nominating Pairs 2235 Prior to nominating, the controlling agent let connectivity checks 2236 continue until some stopping criterion is met. After that, based on 2237 an evaluation criterion, the controlling agent picks a pair among the 2238 valid pairs in the valid list for nomination. 2240 Once the controlling agent has picked a valid pair for nomination, it 2241 repeats the connectivity check that produced this valid pair (by 2242 enqueueing the pair that generated the check into the triggered check 2243 queue), this time with the USE-CANDIDATE attribute Section 7.3.1.5. 2245 Eventually, if the nominations succeed, both the controlling and 2246 controlled agents will have a single nominated pair in the valid list 2247 for each component of the data stream. Once an ICE agent sets the 2248 state of the check list to Completed (when there is a nominated pair 2249 for each component of the data stream), that pair becomes the 2250 selected pair for that agent, and is used for sending and receiving 2251 data for that component of the data stream. 2253 If an agent is not able to produce selected pairs for a data stream, 2254 the agent MUST take proper actions for informing the other agent, and 2255 e.g., removing the stream. The exact actions are outside the scope 2256 of this specification. 2258 The criterion details for stopping the connectivity checks and for 2259 selecting a pair for nomination, are outside the scope of this 2260 specification. They are a matter of local optimization. The only 2261 requirement is that the agent MUST eventually pick one and only one 2262 candidate pair and generate a check for that pair with the USE- 2263 CANDIDATE attribute set. 2265 If more than one candidate pair is nominated by the controlling 2266 agent, and if the controlled agent accepts multiple nominations 2267 requests, the agents MUST produce the selected pairs using the pairs 2268 with the highest priority. 2270 NOTE: A controlling agent that does not support this specification 2271 (i.e. it is implemented according to RFC 5245) might nominate more 2272 than one candidate pair. This was referred to as aggressive 2273 nomination in RFC 5245. The usage of the 'ice2' ice option 2274 Section 10 by endpoints supporting this specification should prevent 2275 such controlling agents from using aggressive nomination. 2277 8.1.2. Updating States 2279 For both controlling and controlled agents, the state of ICE 2280 processing depends on the presence of nominated candidate pairs in 2281 the valid list and on the state of the check list. Note that, at any 2282 time, more than one of the following cases can apply: 2284 o If there are no nominated pairs in the valid list for a data 2285 stream and the state of the check list is Running, ICE processing 2286 continues. 2288 o If there is at least one nominated pair in the valid list for a 2289 data stream and the state of the check list is Running: 2291 * The ICE agent MUST remove all Waiting and Frozen pairs in the 2292 CHECK LIST and triggered check queue for the same component as 2293 the nominated pairs for that data stream. 2295 * If an In-Progress pair in the check list is for the same 2296 component as a nominated pair, the agent SHOULD cease 2297 retransmissions for its check if its pair priority is lower 2298 than the lowest-priority nominated pair for that component. 2300 o Once there is at least one nominated pair in the valid list for 2301 every component of at least one data stream and the state of the 2302 check list is Running: 2304 * The agent MUST change the state of processing for its check 2305 list for that data stream to Completed. 2307 * The agent MUST continue to respond to any checks it may still 2308 receive for that data stream, and MUST perform triggered checks 2309 if required by the processing of Section 7.3. 2311 * The agent MUST continue retransmitting any In-Progress checks 2312 for that check list. 2314 * The agent MAY begin transmitting data for this data stream as 2315 described in Section 12.1. 2317 o Once the state of each check list is Completed: 2319 * The agent sets the state of ICE processing overall to 2320 Completed. 2322 o If the state of the check list is Failed, ICE has not been able to 2323 complete for this data stream. The correct behavior depends on 2324 the state of the check lists for other data streams: 2326 * If all check lists are Failed, ICE processing overall is 2327 considered to be in the Failed state, and the agent SHOULD 2328 consider the session a failure, SHOULD NOT restart ICE, and the 2329 controlling agent SHOULD terminate the entire session. 2331 * If at least one of the check lists for other data streams is 2332 Completed, the controlling agent SHOULD remove the failed data 2333 stream from the session while sending updated candidate list to 2334 its peer. 2336 * If none of the check lists for other data streams are 2337 Completed, but at least one is Running, the agent SHOULD let 2338 ICE continue. 2340 8.2. Procedures for Lite Implementations 2342 When ICE concludes, a lite ICE agent can free host candidates that 2343 were not used by ICE, as described in Section 8.3. 2345 If the peer is a full agent, once the lite agent accepts a nomination 2346 request for a candidate pair, the lite agent considers the pair 2347 nominated. Once there are nominated pairs for each component of a 2348 data stream, the pairs become the selected pairs for the components 2349 of the data stream. Once the lite agent has produced selected pairs 2350 for all components of all data streams, the ICE session state is set 2351 to Completed. 2353 If the peer is a lite agent, the agent pairs local candidates with 2354 remote candidates that are for the same data stream and have the same 2355 component, transport protocol, and IP address family. For each 2356 component of each data stream, if there is only one candidate pair, 2357 that pair is added to the valid list. If there is more than one 2358 pair, it is RECOMMENDED that an agent follow the procedures of RFC 2359 6724 [RFC6724] to select a pair and add it to the valid list. 2361 If all of the components for all data streams had one pair, the state 2362 of ICE processing is Completed. Otherwise, the controlling agent 2363 MUST send an updated candidate list to reconcile different agents 2364 selecting different candidate pairs. ICE processing is complete 2365 after and only after the updated candidate exchange is complete. 2367 8.3. Freeing Candidates 2369 8.3.1. Full Implementation Procedures 2371 The procedures in Section 8 require that an ICE agent continue to 2372 listen for STUN requests and continue to generate triggered checks 2373 for a data stream, even once processing for that stream completes. 2374 The rules in this section describe when it is safe for an agent to 2375 cease sending or receiving checks on a candidate that did not become 2376 a selected candidate (is not associated with a selected pair), and 2377 then free the candidate. 2379 Once a check list has reached the Completed state, the agent SHOULD 2380 wait an additional three seconds, and then it can cease responding to 2381 checks or generating triggered checks on all local candidates other 2382 than the ones that became selected candidates. Once all ICE sessions 2383 have ceased using a given local candidate (a candidate may be used by 2384 multiple ICE sessions, e.g. in forking scenarios), the agent can free 2385 that candidate. The three-second delay handles cases when aggressive 2386 nomination is used, and the selected pairs can quickly change after 2387 ICE has completed. 2389 Freeing of server reflexive candidates is never explicit; it happens 2390 by lack of a keepalive. 2392 8.3.2. Lite Implementation Procedures 2394 A lite implementation can free candidates that did not become 2395 selected candidates as soon as ICE processing has reached the 2396 Completed state for all ICE sessions using those candidates. 2398 9. ICE Restarts 2400 An ICE agent MAY restart ICE for existing data streams. An ICE 2401 restart causes all previous state of the data streams, excluding the 2402 roles of the agents to be flushed. The only difference between an 2403 ICE restart and a brand new data session is that during the restart, 2404 data can continue to be sent using existing data sessions, and that a 2405 new data session always requires the roles to be determined. 2407 The following actions can be accomplished only using an ICE restart 2408 (the agent MUST use ICE restarts to do so): 2410 o Change the destinations of data streams. 2412 o Change from a lite implementation to a full implementation. 2414 o Change from a full implementation to a lite implementation. 2416 To restart ICE, an agent MUST change both the password and the 2417 username fragment for the data stream(s) being restarted. The new 2418 candidate set MAY include some, none, or all of the previous 2419 candidates. 2421 As described in Section 6.1.1, agents MUST NOT re-determine the roles 2422 as part as an ICE restart, unless certain criteria that require the 2423 roles to be re-determined are fulfilled. 2425 10. ICE Option 2427 This section defines a new ICE option, 'ice2'. The ICE option 2428 indicates that the ICE agent that includes it in a candidate exchange 2429 is compliant to this specification. For example, the agent will not 2430 use the aggressive nomination procedure defined in [RFC5245]. 2432 An agent compliant to this specification MUST inform the peer about 2433 the compliance using the 'ice2' option. 2435 NOTE: The encoding of the 'ice2' ICE option, and the message(s) used 2436 to carry it to the peer, are protocol specific. The encoding for the 2437 Session Description Protocol (SDP) [RFC4566] is defined in 2438 [I-D.ietf-mmusic-ice-sip-sdp]. 2440 11. Keepalives 2442 All endpoints MUST send keepalives for each data session. These 2443 keepalives serve the purpose of keeping NAT bindings alive for the 2444 data session. The keepalives SHOULD be sent using a format that is 2445 supported by its peer. ICE endpoints allow for STUN-based keepalives 2446 for UDP streams, and as such, STUN keepalives MUST be used when an 2447 ICE agent is a full ICE implementation and is communicating with a 2448 peer that supports ICE (lite or full). 2450 For each candidate pair that an agent is using to send data, if no 2451 packet has been sent on that pair in the last Tr seconds, an agent 2452 MUST send a keepalive on that pair. Agents SHOULD use a Tr value of 2453 15 seconds. Agents MAY use a bigger value, but MUST NOT use a value 2454 smaller than 15 seconds. 2456 Once selected pairs have been produced for a data stream, keepalives 2457 are only sent on those pairs. 2459 An agent MUST stop sending keepalives on a data stream if the data 2460 stream is removed. If the ICE session is terminated, an agent MUST 2461 stop sending keepalives on all data streams. 2463 An agent MAY use another value for Tr, e.g. based on configuration or 2464 network/NAT characteristics. For example, if an agent has a dynamic 2465 way to discover the binding lifetimes of the intervening NATs, it can 2466 use that value to determine Tr. Administrators deploying ICE in more 2467 controlled networking environments SHOULD set Tr to the longest 2468 duration possible in their environment. 2470 When STUN is being used for keepalives, a STUN Binding Indication is 2471 used [RFC5389]. The Indication MUST NOT utilize any authentication 2472 mechanism. It SHOULD contain the FINGERPRINT attribute to aid in 2473 demultiplexing, but SHOULD NOT contain any other attributes. It is 2474 used solely to keep the NAT bindings alive. The Binding Indication 2475 is sent using the same local and remote candidates that are being 2476 used for data. Though Binding Indications are used for keepalives, 2477 an agent MUST be prepared to receive a connectivity check as well. 2478 If a connectivity check is received, a response is generated as 2479 discussed in [RFC5389], but there is no impact on ICE processing 2480 otherwise. 2482 Agents MUST by default use STUN keepalives. Individual ICE usages 2483 and ICE extensions MAY specify usage/extension-specific keepalives. 2485 12. Data Handling 2487 12.1. Sending Data 2489 An ICE agent MAY send data on any valid candidate pair before 2490 selected pairs have been produced for the data stream. 2492 Once selected pairs have been produced for a data stream, an agent 2493 MUST send data on those pairs. 2495 An agent sends data from the base of the local candidate to the 2496 remote candidate. In the case of a local relayed candidate, data is 2497 forwarded through the base (located in the TURN server), using the 2498 procedures defined in [RFC5766]. 2500 If the local candidate is a relayed candidate, it is RECOMMENDED that 2501 an agent creates a channel on the TURN server towards the remote 2502 candidate. This is done using the procedures for channel creation as 2503 defined in Section 11 of [RFC5766]. 2505 The selected pair for a component of a data stream is: 2507 o empty if the state of the check list for that data stream is 2508 Running, and there is no previous selected pair for that component 2509 due to an ICE restart 2511 o equal to the previous selected pair for a component of a data 2512 stream if the state of the check list for that data stream is 2513 Running, and there was a previous selected pair for that component 2514 due to an ICE restart 2516 Unless an agent is able to produce a selected pair for each component 2517 associated with a data stream, the agent MUST NOT continue sending 2518 data for any component associated with that data stream. 2520 12.2. Procedures for Lite Implementations 2522 A lite implementation MUST NOT send data until it has a valid list 2523 that contains a candidate pair for each component of that data 2524 stream. Once that happens, the ICE agent MAY begin sending data 2525 packets. To do that, it sends data to the remote candidate in the 2526 pair (setting the destination address and port of the packet equal to 2527 that remote candidate), and will send it from the base associated 2528 with the candidate pair used for sending data. In case of a relayed 2529 candidate, data is sent from the agent and forwarded through the base 2530 (located in the TURN server), using the procedures defined in 2531 [RFC5766]. 2533 12.3. Procedures for All Implementations 2535 ICE has interactions with jitter buffer adaptation mechanisms. An 2536 RTP stream can begin using one candidate, and switch to another one, 2537 though this happens rarely with ICE. The newer candidate may result 2538 in RTP packets taking a different path through the network -- one 2539 with different delay characteristics. As discussed below, ICE agents 2540 are encouraged to re-adjust jitter buffers when there are changes in 2541 source or destination address of data packets. Furthermore, many 2542 audio codecs use the marker bit to signal the beginning of a 2543 talkspurt, for the purposes of jitter buffer adaptation. For such 2544 codecs, it is RECOMMENDED that the sender set the marker bit 2546 [RFC3550] when an agent switches transmission of data from one 2547 candidate pair to another. 2549 13. Receiving Data 2551 Even though ICE agents are only allowed to send data using valid 2552 candidate pairs (and, once selected pairs have been produced, only on 2553 the selected pairs) ICE implementations SHOULD by default be prepared 2554 to receive data on any of the candidates provided in the most recent 2555 candidate exchange with the peer. ICE usages MAY define rules that 2556 differs from this, e.g., by defining that data must not be sent until 2557 selected pairs have been produced for a data stream. 2559 It is RECOMMENDED that, when an agent receives an RTP packet with a 2560 new source or destination IP address for a particular RTP/RTCP data 2561 stream, that the agent re-adjust its jitter buffers. 2563 RFC 3550 [RFC3550] describes an algorithm in Section 8.2 for 2564 detecting synchronization source (SSRC) collisions and loops. These 2565 algorithms are based, in part, on seeing different source transport 2566 addresses with the same SSRC. However, when ICE is used, such 2567 changes will sometimes occur as the data streams switch between 2568 candidates. An agent will be able to determine that a data stream is 2569 from the same peer as a consequence of the STUN exchange that 2570 proceeds media data transmission. Thus, if there is a change in 2571 source transport address, but the media data packets come from the 2572 same peer agent, this MUST NOT be treated as an SSRC collision. 2574 14. Extensibility Considerations 2576 This specification makes very specific choices about how both ICE 2577 agents in a session coordinate to arrive at the set of candidate 2578 pairs that are selected for data. It is anticipated that future 2579 specifications will want to alter these algorithms, whether they are 2580 simple changes like timer tweaks or larger changes like a revamp of 2581 the priority algorithm. When such a change is made, providing 2582 interoperability between the two agents in a session is critical. 2584 First, ICE provides the ice-options attribute. Each extension or 2585 change to ICE is associated with a token. When an agent supporting 2586 such an extension or change triggers candidate exchange, it MUST 2587 include the token for that extension in this attribute. This allows 2588 each side to know what the other side is doing. This attribute MUST 2589 NOT be present if the agent doesn't support any ICE extensions or 2590 changes. 2592 One of the complications in achieving interoperability is that ICE 2593 relies on a distributed algorithm running on both agents to converge 2594 on an agreed set of candidate pairs. If the two agents run different 2595 algorithms, it can be difficult to guarantee convergence on the same 2596 candidate pairs. The regular nomination procedure described in 2597 Section 8 eliminates some of the tight coordination by delegating the 2598 selection algorithm completely to the controlling agent. 2599 Consequently, when a controlling agent is communicating with a peer 2600 that supports options it doesn't know about, the agent MUST run a 2601 regular nomination algorithm. When regular nomination is used, ICE 2602 will converge perfectly even when both agents use different pair 2603 prioritization algorithms. One of the keys to such convergence is 2604 triggered checks, which ensure that the nominated pair is validated 2605 by both agents. Consequently, any future ICE enhancements MUST 2606 preserve triggered checks. 2608 ICE is also extensible to other data streams beyond RTP, and for 2609 transport protocols beyond UDP. Extensions to ICE for non-RTP data 2610 streams need to specify how many components they utilize, and assign 2611 component IDs to them, starting at 1 for the most important component 2612 ID. Specifications for new transport protocols must define how, if 2613 at all, various steps in the ICE processing differ from UDP. 2615 15. Setting Ta and RTO 2617 15.1. General 2619 During the ICE gathering phase (Section 5.1.1) and while ICE is 2620 performing connectivity checks (Section 7), an ICE agent triggers 2621 STUN and TURN transactions. These transactions are paced at a rate 2622 indicated by Ta, and the retransmission interval for each transaction 2623 is calculated based on the the retransmission timer for the STUN 2624 transactions (RTO) [RFC5389]. 2626 This section describes how the Ta and RTO values are computed during 2627 the ICE gathering phase and while ICE is performing connectivity 2628 checks. 2630 NOTE: Previously, in RFC 5245, different formulas were defined for 2631 computing Ta and RTO, depending on whether ICE was used for a real- 2632 time data stream (e.g., RTP) or not. 2634 The formulas below result in a behavior whereby an agent will send 2635 its first packet for every single connectivity check before 2636 performing a retransmit. This can be seen in the formulas for the 2637 RTO (which represents the retransmit interval). Those formulas scale 2638 with N, the number of checks to be performed. As a result of this, 2639 ICE maintains a nicely constant rate, but becomes more sensitive to 2640 packet loss. The loss of the first single packet for any 2641 connectivity check is likely to cause that pair to take a long time 2642 to be validated, and instead, a lower-priority check (but one for 2643 which there was no packet loss) is much more likely to complete 2644 first. This results in ICE performing sub-optimally, choosing lower- 2645 priority pairs over higher-priority pairs. Implementors should be 2646 aware of this consequence, but still should utilize the timer values 2647 described here. 2649 15.2. Ta 2651 ICE agents SHOULD use the default Ta value, 50 ms, but MAY use 2652 another value based on the characteristics of the associated data. 2654 If an agent wants to use another Ta value than the default value, the 2655 agent MUST indicate the proposed value to its peer during the 2656 establishment of the ICE session. Both agents MUST use the higher 2657 value of the proposed values. If an agent does not propose a value, 2658 the default value is used for that agent when comparing which value 2659 is higher. 2661 Regardless of the Ta value chosen for each agent, the combination of 2662 all transactions from all agents (if a given implementation runs 2663 several concurrent agents) MUST NOT be sent more often than once 2664 every 5ms (as though there were one global Ta value for pacing all 2665 agents). 2667 This mechanism of a global minimum pacing interval of 5ms is not 2668 generally applicable to transport protocols, but is applicable to ICE 2669 based on the following reasoning. 2671 o Start with the following rules which would be generally applicable 2672 to transport protocols: 2674 1. Let MaxBytes be the maximum number of bytes allowed to be 2675 outstanding in the network at start-up, which SHOULD be 14600 2676 bytes per RFC 6928. 2678 2. Let HTO be the transaction timeout, which SHOULD be 2*RTT if 2679 RTT is known and 500ms otherwise. This is based on the RTO 2680 for STUN messages from RFC 5389 and the the TCP initial RTO, 2681 which is 1 sec in RFC 6298. 2683 3. Let MinPacing be the minimum pacing interval between 2684 transactions, which SHOULD be 5ms. 2686 o Observe that agents typically do not know the RTT for ICE 2687 transactions (connectivity checks in particular), meaning that HTO 2688 will almost always be 500ms. 2690 o Observe that a MinPacing of 5ms and HTO of 500ms gives at most 100 2691 packets/HTO, which for a typical ICE check of less than 120 bytes 2692 means a maximum of 12000 outstanding bytes in the network, which 2693 is less than the maximum expressed by rule 1. 2695 o Thus, for ICE, the rule set reduces down to just the MinPacing 2696 rule, which is equivalent to having a global Ta value. 2698 NOTE: Appendix C shows examples of required bandwidth, using 2699 different Ta values. 2701 15.3. RTO 2703 During the ICE gathering phase, ICE agents SHOULD calculate the RTO 2704 value using the following formula: 2706 RTO = MAX (500ms, Ta * (Num-Of-Pairs)) 2708 Num-Of-Pairs: the number of pairs of candidates 2709 with STUN or TURN servers. 2711 For connectivity checks, agents SHOULD calculate the RTO value using 2712 the following formula: 2714 RTO = MAX (500ms, Ta*N * (Num-Waiting + Num-In-Progress)) 2716 Num-Waiting: the number of checks in the check list in the 2717 Waiting state. 2719 Num-In-Progress: the number of checks in the In-Progress state. 2721 Note that the RTO will be different for each transaction as the 2722 number of checks in the Waiting and In-Progress states change. 2724 Agents MAY calculate the RTO value using other mechanisms than those 2725 described above. Agents MUST NOT use a RTO value smaller than 500 2726 ms. 2728 16. Example 2730 The example is based on the simplified topology of Figure 9. 2732 +-------+ 2733 |STUN | 2734 |Server | 2735 +-------+ 2736 | 2737 +---------------------+ 2738 | | 2739 | Internet | 2740 | | 2741 +---------------------+ 2742 | | 2743 | | 2744 +---------+ | 2745 | NAT | | 2746 +---------+ | 2747 | | 2748 | | 2749 +-----+ +-----+ 2750 | L | | R | 2751 +-----+ +-----+ 2753 Figure 9: Example Topology 2755 Two ICE agents, L and R, are using ICE. Both are full ICE 2756 implementations. Both agents have a single IPv4 address. For agent 2757 L, it is 10.0.1.1 in private address space [RFC1918], and for agent 2758 R, 192.0.2.1 on the public Internet. Both are configured with the 2759 same STUN server (shown in this example for simplicity, although in 2760 practice the agents do not need to use the same STUN server), which 2761 is listening for STUN Binding requests at an IP address of 192.0.2.2 2762 and port 3478. TURN servers are not used in this example. Agent L 2763 is behind a NAT, and agent R is on the public Internet. The NAT has 2764 an endpoint independent mapping property and an address dependent 2765 filtering property. The public side of the NAT has an IP address of 2766 192.0.2.3. 2768 To facilitate understanding, transport addresses are listed using 2769 variables that have mnemonic names. The format of the name is 2770 entity-type-seqno, where entity refers to the entity whose IP address 2771 the transport address is on, and is one of "L", "R", "STUN", or 2772 "NAT". The type is either "PUB" for transport addresses that are 2773 public, and "PRIV" for transport addresses that are private. 2774 Finally, seq-no is a sequence number that is different for each 2775 transport address of the same type on a particular entity. Each 2776 variable has an IP address and port, denoted by varname.IP and 2777 varname.PORT, respectively, where varname is the name of the 2778 variable. 2780 The STUN server has advertised transport address STUN-PUB-1 (which is 2781 192.0.2.2:3478). 2783 In the call flow itself, STUN messages are annotated with several 2784 attributes. The "S=" attribute indicates the source transport 2785 address of the message. The "D=" attribute indicates the destination 2786 transport address of the message. The "MA=" attribute is used in 2787 STUN Binding response messages and refers to the mapped address. 2788 "USE-CAND" implies the presence of the USE-CANDIDATE attribute. 2790 The call flow examples omit STUN authentication operations, and focus 2791 on a single data stream between two full implementations. 2793 L NAT STUN R 2794 |STUN alloc. | | | 2795 |(1) STUN Req | | | 2796 |S=$L-PRIV-1 | | | 2797 |D=$STUN-PUB-1 | | | 2798 |------------->| | | 2799 | |(2) STUN Req | | 2800 | |S=$NAT-PUB-1 | | 2801 | |D=$STUN-PUB-1 | | 2802 | |------------->| | 2803 | |(3) STUN Res | | 2804 | |S=$STUN-PUB-1 | | 2805 | |D=$NAT-PUB-1 | | 2806 | |MA=$NAT-PUB-1 | | 2807 | |<-------------| | 2808 |(4) STUN Res | | | 2809 |S=$STUN-PUB-1 | | | 2810 |D=$L-PRIV-1 | | | 2811 |MA=$NAT-PUB-1 | | | 2812 |<-------------| | | 2813 |(5) L's Candidate Information| | 2814 |------------------------------------------->| 2815 | | | | STUN 2816 | | | | alloc. 2817 | | |(6) STUN Req | 2818 | | |S=$R-PUB-1 | 2819 | | |D=$STUN-PUB-1 | 2820 | | |<-------------| 2821 | | |(7) STUN Res | 2822 | | |S=$STUN-PUB-1 | 2823 | | |D=$R-PUB-1 | 2824 | | |MA=$R-PUB-1 | 2825 | | |------------->| 2826 |(8) R's Candidate Information| | 2827 |<-------------------------------------------| 2828 | |(9) Bind Req | |Begin 2829 | |S=$R-PUB-1 | |Connectivity 2830 | |D=L-PRIV-1 | |Checks 2831 | |<----------------------------| 2832 | |Dropped | | 2833 |(10) Bind Req | | | 2834 |S=$L-PRIV-1 | | | 2835 |D=$R-PUB-1 | | | 2836 |------------->| | | 2837 | |(11) Bind Req | | 2838 | |S=$NAT-PUB-1 | | 2839 | |D=$R-PUB-1 | | 2840 | |---------------------------->| 2841 | |(12) Bind Res | | 2842 | |S=$R-PUB-1 | | 2843 | |D=$NAT-PUB-1 | | 2844 | |MA=$NAT-PUB-1 | | 2845 | |<----------------------------| 2846 |(13) Bind Res | | | 2847 |S=$R-PUB-1 | | | 2848 |D=$L-PRIV-1 | | | 2849 |MA=$NAT-PUB-1 | | | 2850 |<-------------| | | 2851 |Data flows | | | 2852 | |(14) Bind Req | | 2853 | |S=$R-PUB-1 | | 2854 | |D=$NAT-PUB-1 | | 2855 | |<----------------------------| 2856 |(15) Bind Req | | | 2857 |S=$R-PUB-1 | | | 2858 |D=$L-PRIV-1 | | | 2859 |<-------------| | | 2860 |(16) Bind Res | | | 2861 |S=$L-PRIV-1 | | | 2862 |D=$R-PUB-1 | | | 2863 |MA=$R-PUB-1 | | | 2864 |------------->| | | 2865 | |(17) Bind Res | | 2866 | |S=$NAT-PUB-1 | | 2867 | |D=$R-PUB-1 | | 2868 | |MA=$R-PUB-1 | | 2869 | |---------------------------->| 2870 | | | |Data flows 2872 Figure 10: Example Flow 2874 First, agent L obtains a host candidate from its local IP address 2875 (not shown), and from that, sends a STUN Binding request to the STUN 2876 server to get a server reflexive candidate (messages 1-4). Recall 2877 that the NAT has the address and port independent mapping property. 2878 Here, it creates a binding of NAT-PUB-1 for this UDP request, and 2879 this becomes the server reflexive candidate. 2881 Agent L sets a type preference of 126 for the host candidate and 100 2882 for the server reflexive. The local preference is 65535. Based on 2883 this, the priority of the host candidate is 2130706431 and for the 2884 server reflexive candidate is 1694498815. The host candidate is 2885 assigned a foundation of 1, and the server reflexive, a foundation of 2886 2. These are sent to the peer. 2888 This candidate information is received at agent R. Agent R will 2889 obtain a host candidate, and from it, obtain a server reflexive 2890 candidate (messages 6-7). Since R is not behind a NAT, this 2891 candidate is identical to its host candidate, and they share the same 2892 base. It therefore discards this redundant candidate and ends up 2893 with a single host candidate. With identical type and local 2894 preferences as L, the priority for this candidate is 2130706431. It 2895 chooses a foundation of 1 for its single candidate. Then R's 2896 candidates are then sent to L. 2898 Since neither side indicated that it is lite, the initiating agent 2899 that began ICE processing (agent L) becomes the controlling agent. 2901 Agents L and R both pair up the candidates. They both initially have 2902 two pairs. However, agent L will prune the pair containing its 2903 server reflexive candidate, resulting in just one. At agent L, this 2904 pair has a local candidate of $L_PRIV_1 and remote candidate of 2905 $R_PUB_1, and has a candidate pair priority of 4.57566E+18 (note that 2906 an implementation would represent this as a 64-bit integer so as not 2907 to lose precision). At agent R, there are two pairs. The highest 2908 priority has a local candidate of $R_PUB_1 and remote candidate of 2909 $L_PRIV_1 and has a priority of 4.57566E+18, and the second has a 2910 local candidate of $R_PUB_1 and remote candidate of $NAT_PUB_1 and 2911 priority 3.63891E+18. 2913 Agent R begins its connectivity check (message 9) for the first pair 2914 (between the two host candidates). Since R is the controlled agent 2915 for this session, the check omits the USE-CANDIDATE attribute. The 2916 host candidate from agent L is private and behind a NAT, and thus 2917 this check won't be successful, because the packet cannot be routed 2918 from R to L. 2920 When agent L gets the R's candidates, it performs its one and only 2921 connectivity check (messages 10-13). Since the check succeeds, agent 2922 L creates a new pair, whose local candidate is from the mapped 2923 address in the Binding response (NAT-PUB-1 from message 13) and whose 2924 remote candidate is the destination of the request (R-PUB-1 from 2925 message 10). This is added to the valid list. Agent L can now send 2926 data if it so chooses. 2928 Soon after receipt of the STUN Binding request from agent L (message 2929 11), agent R will generate its triggered check. This check happens 2930 to match the next one on its check list -- from its host candidate to 2931 agent L's server reflexive candidate. This check (messages 14-17) 2932 will succeed. Consequently, agent R constructs a new candidate pair 2933 using the mapped address from the response as the local candidate (R- 2934 PUB-1) and the destination of the request (NAT-PUB-1) as the remote 2935 candidate. This pair is added to the valid list for that data 2936 stream. Since the check was generated in the reverse direction of a 2937 check that contained the USE-CANDIDATE attribute, the candidate pair 2938 is marked as selected. Consequently, processing for this stream 2939 moves into the Completed state, and agent R can also send data. 2941 17. Security Considerations 2943 The process of probing for candidates reveals the source addresses of 2944 the client and its peer to any on-network listening attacker, and the 2945 process of exchanging candidates reveals the addresses to any 2946 attacker that is able to see the negotiation. Some addresses, such 2947 as the server reflexive addresses gathered through the local 2948 interface of VPN users, may be sensitive information. If these 2949 potential attacks can not be mitigated, the implementation may want 2950 to institute controls for which addresses are revealed to the 2951 negotiation and/or probing process. Such controls need to be 2952 specified as part of the ICE usage. 2954 There are several types of attacks possible in an ICE system. This 2955 section considers these attacks and their countermeasures. These 2956 countermeasures include: 2958 o Using ICE in conjunction with secure signaling techniques, such as 2959 SIPS. 2961 o Limiting the total number of connectivity checks to 100, and 2962 optionally limiting the number of candidates they'll accept in an 2963 candidate exchange. 2965 17.1. Attacks on Connectivity Checks 2967 An attacker might attempt to disrupt the STUN connectivity checks. 2968 Ultimately, all of these attacks fool an ICE agent into thinking 2969 something incorrect about the results of the connectivity checks. 2970 The possible false conclusions an attacker can try and cause are: 2972 False Invalid: An attacker can fool a pair of agents into thinking a 2973 candidate pair is invalid, when it isn't. This can be used to 2974 cause an agent to prefer a different candidate (such as one 2975 injected by the attacker) or to disrupt a call by forcing all 2976 candidates to fail. 2978 False Valid: An attacker can fool a pair of agents into thinking a 2979 candidate pair is valid, when it isn't. This can cause an agent 2980 to proceed with a session, but then not be able to receive any 2981 data. 2983 False Peer Reflexive Candidate: An attacker can cause an agent to 2984 discover a new peer reflexive candidate, when it shouldn't have. 2985 This can be used to redirect data streams to a Denial-of-Service 2986 (DoS) target or to the attacker, for eavesdropping or other 2987 purposes. 2989 False Valid on False Candidate: An attacker has already convinced an 2990 agent that there is a candidate with an address that doesn't 2991 actually route to that agent (for example, by injecting a false 2992 peer reflexive candidate or false server reflexive candidate). It 2993 must then launch an attack that forces the agents to believe that 2994 this candidate is valid. 2996 If an attacker can cause a false peer reflexive candidate or false 2997 valid on a false candidate, it can launch any of the attacks 2998 described in [RFC5389]. 3000 To force the false invalid result, the attacker has to wait for the 3001 connectivity check from one of the agents to be sent. When it is, 3002 the attacker needs to inject a fake response with an unrecoverable 3003 error response, such as a 400. However, since the candidate is, in 3004 fact, valid, the original request may reach the peer agent, and 3005 result in a success response. The attacker needs to force this 3006 packet or its response to be dropped, through a DoS attack, layer 2 3007 network disruption, or other technique. If it doesn't do this, the 3008 success response will also reach the originator, alerting it to a 3009 possible attack. Fortunately, this attack is mitigated completely 3010 through the STUN short-term credential mechanism. The attacker needs 3011 to inject a fake response, and in order for this response to be 3012 processed, the attacker needs the password. If the candidate 3013 exchange signaling is secured, the attacker will not have the 3014 password and its response will be discarded. 3016 Forcing the fake valid result works in a similar way. The agent 3017 needs to wait for the Binding request from each agent, and inject a 3018 fake success response. The attacker won't need to worry about 3019 disrupting the actual response since, if the candidate is not valid, 3020 it presumably wouldn't be received anyway. However, like the fake 3021 invalid attack, this attack is mitigated by the STUN short-term 3022 credential mechanism in conjunction with a secure candidate exchange. 3024 Forcing the false peer reflexive candidate result can be done either 3025 with fake requests or responses, or with replays. We consider the 3026 fake requests and responses case first. It requires the attacker to 3027 send a Binding request to one agent with a source IP address and port 3028 for the false candidate. In addition, the attacker must wait for a 3029 Binding request from the other agent, and generate a fake response 3030 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 3031 Like the other attacks described here, this attack is mitigated by 3032 the STUN message integrity mechanisms and secure candidate exchanges. 3034 Forcing the false peer reflexive candidate result with packet replays 3035 is different. The attacker waits until one of the agents sends a 3036 check. It intercepts this request, and replays it towards the other 3037 agent with a faked source IP address. It must also prevent the 3038 original request from reaching the remote agent, either by launching 3039 a DoS attack to cause the packet to be dropped, or forcing it to be 3040 dropped using layer 2 mechanisms. The replayed packet is received at 3041 the other agent, and accepted, since the integrity check passes (the 3042 integrity check cannot and does not cover the source IP address and 3043 port). It is then responded to. This response will contain a XOR- 3044 MAPPED-ADDRESS with the false candidate, and will be sent to that 3045 false candidate. The attacker must then receive it and relay it 3046 towards the originator. 3048 The other agent will then initiate a connectivity check towards that 3049 false candidate. This validation needs to succeed. This requires 3050 the attacker to force a false valid on a false candidate. Injecting 3051 of fake requests or responses to achieve this goal is prevented using 3052 the integrity mechanisms of STUN and the candidate exchange. Thus, 3053 this attack can only be launched through replays. To do that, the 3054 attacker must intercept the check towards this false candidate, and 3055 replay it towards the other agent. Then, it must intercept the 3056 response and replay that back as well. 3058 This attack is very hard to launch unless the attacker is identified 3059 by the fake candidate. This is because it requires the attacker to 3060 intercept and replay packets sent by two different hosts. If both 3061 agents are on different networks (for example, across the public 3062 Internet), this attack can be hard to coordinate, since it needs to 3063 occur against two different endpoints on different parts of the 3064 network at the same time. 3066 If the attacker itself is identified by the fake candidate, the 3067 attack is easier to coordinate. However, if the data path is secured 3068 (e.g., using SRTP [RFC3711]), the attacker will not be able to 3069 process the data packets, but will only be able to discard them, 3070 effectively disabling the data stream. However, this attack requires 3071 the agent to disrupt packets in order to block the connectivity check 3072 from reaching the target. In that case, if the goal is to disrupt 3073 the data stream, it's much easier to just disrupt it with the same 3074 mechanism, rather than attack ICE. 3076 17.2. Attacks on Server Reflexive Address Gathering 3078 ICE endpoints make use of STUN Binding requests for gathering server 3079 reflexive candidates from a STUN server. These requests are not 3080 authenticated in any way. As a consequence, there are numerous 3081 techniques an attacker can employ to provide the client with a false 3082 server reflexive candidate: 3084 o An attacker can compromise the DNS, causing DNS queries to return 3085 a rogue STUN server address. That server can provide the client 3086 with fake server reflexive candidates. This attack is mitigated 3087 by DNS security, though DNS-SEC is not required to address it. 3089 o An attacker that can observe STUN messages (such as an attacker on 3090 a shared network segment, like WiFi) can inject a fake response 3091 that is valid and will be accepted by the client. 3093 o An attacker can compromise a STUN server by means of a virus, and 3094 cause it to send responses with incorrect mapped addresses. 3096 A false mapped address learned by these attacks will be used as a 3097 server reflexive candidate in the establishment of the ICE session. 3098 For this candidate to actually be used for data, the attacker must 3099 also attack the connectivity checks, and in particular, force a false 3100 valid on a false candidate. This attack is very hard to launch if 3101 the false address identifies a fourth party (neither the initiator, 3102 responder, nor attacker), since it requires attacking the checks 3103 generated by each ICE agent in the session, and is prevented by SRTP 3104 if it identifies the attacker itself. 3106 If the attacker elects not to attack the connectivity checks, the 3107 worst it can do is prevent the server reflexive candidate from being 3108 used. However, if the peer agent has at least one candidate that is 3109 reachable by the agent under attack, the STUN connectivity checks 3110 themselves will provide a peer reflexive candidate that can be used 3111 for the exchange of data. Peer reflexive candidates are generally 3112 preferred over server reflexive candidates. As such, an attack 3113 solely on the STUN address gathering will normally have no impact on 3114 a session at all. 3116 17.3. Attacks on Relayed Candidate Gathering 3118 An attacker might attempt to disrupt the gathering of relayed 3119 candidates, forcing the client to believe it has a false relayed 3120 candidate. Exchanges with the TURN server are authenticated using a 3121 long-term credential. Consequently, injection of fake responses or 3122 requests will not work. In addition, unlike Binding requests, 3123 Allocate requests are not susceptible to replay attacks with modified 3124 source IP addresses and ports, since the source IP address and port 3125 are not utilized to provide the client with its relayed candidate. 3127 However, TURN servers are susceptible to DNS attacks, or to viruses 3128 aimed at the TURN server, for purposes of turning it into a zombie or 3129 rogue server. These attacks can be mitigated by DNS-SEC and through 3130 good box and software security on TURN servers. 3132 Even if an attacker has caused the client to believe in a false 3133 relayed candidate, the connectivity checks cause such a candidate to 3134 be used only if they succeed. Thus, an attacker must launch a false 3135 valid on a false candidate, per above, which is a very difficult 3136 attack to coordinate. 3138 17.4. Insider Attacks 3140 In addition to attacks where the attacker is a third party trying to 3141 insert fake candidate information or stun messages, there are attacks 3142 possible with ICE when the attacker is an authenticated and valid 3143 participant in the ICE exchange. 3145 17.4.1. STUN Amplification Attack 3147 The STUN amplification attack is similar to the voice hammer. 3148 However, instead of voice packets being directed to the target, STUN 3149 connectivity checks are directed to the target. The attacker sends 3150 an a large number of candidates, say, 50. The responding agent 3151 receives the candidate information, and starts its checks, which are 3152 directed at the target, and consequently, never generate a response. 3153 The answerer will start a new connectivity check every Ta ms (say, 3154 Ta=20ms). However, the retransmission timers are set to a large 3155 number due to the large number of candidates. As a consequence, 3156 packets will be sent at an interval of one every Ta milliseconds, and 3157 then with increasing intervals after that. Thus, STUN will not send 3158 packets at a rate faster than data would be sent, and the STUN 3159 packets persist only briefly, until ICE fails for the session. 3160 Nonetheless, this is an amplification mechanism. 3162 It is impossible to eliminate the amplification, but the volume can 3163 be reduced through a variety of heuristics. ICE agents SHOULD limit 3164 the total number of connectivity checks they perform to 100. 3165 Additionally, agents MAY limit the number of candidates they'll 3166 accept. 3168 Frequently, protocols that wish to avoid these kinds of attacks force 3169 the initiator to wait for a response prior to sending the next 3170 message. However, in the case of ICE, this is not possible. It is 3171 not possible to differentiate the following two cases: 3173 o There was no response because the initiator is being used to 3174 launch a DoS attack against an unsuspecting target that will not 3175 respond. 3177 o There was no response because the IP address and port are not 3178 reachable by the initiator. 3180 In the second case, another check should be sent at the next 3181 opportunity, while in the former case, no further checks should be 3182 sent. 3184 18. STUN Extensions 3186 18.1. New Attributes 3188 This specification defines four new STUN attributes, PRIORITY, USE- 3189 CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. 3191 The PRIORITY attribute indicates the priority that is to be 3192 associated with a peer reflexive candidate, should one be discovered 3193 by this check. It is a 32-bit unsigned integer, and has an attribute 3194 value of 0x0024. 3196 The USE-CANDIDATE attribute indicates that the candidate pair 3197 resulting from this check should be used for transmission of data. 3198 The attribute has no content (the Length field of the attribute is 3199 zero); it serves as a flag. It has an attribute value of 0x0025. 3201 The ICE-CONTROLLED attribute is present in a Binding request and 3202 indicates that the client believes it is currently in the controlled 3203 role. The content of the attribute is a 64-bit unsigned integer in 3204 network byte order, which contains a random number. The number is 3205 used for solving role conflicts, when it is referred to as the tie- 3206 breaker value. An ICE agent MUST use the same number for all Binding 3207 requests, for all streams, within an ICE session. The agent MAY 3208 change the number when an ICE restart occurs. 3210 The ICE-CONTROLLING attribute is present in a Binding request and 3211 indicates that the client believes it is currently in the controlling 3212 role. The content of the attribute is a 64-bit unsigned integer in 3213 network byte order, which contains a random number. The number is 3214 used for solving role conflicts, when it is referred to as the tie- 3215 breaker value. An agent MUST use the same number for all Binding 3216 requests, for all streams, within an ICE session. The agent MAY 3217 change the number when an ICE restart occurs. 3219 18.2. New Error Response Codes 3221 This specification defines a single error response code: 3223 487 (Role Conflict): The Binding request contained either the ICE- 3224 CONTROLLING or ICE-CONTROLLED attribute, indicating an ICE role 3225 that conflicted with the server. The server compared the tie- 3226 breaker values of the client and the server and determined that 3227 the client needs to switch roles. 3229 19. Operational Considerations 3231 This section discusses issues relevant to network operators looking 3232 to deploy ICE. 3234 19.1. NAT and Firewall Types 3236 ICE was designed to work with existing NAT and firewall equipment. 3237 Consequently, it is not necessary to replace or reconfigure existing 3238 firewall and NAT equipment in order to facilitate deployment of ICE. 3239 Indeed, ICE was developed to be deployed in environments where the 3240 Voice over IP (VoIP) operator has no control over the IP network 3241 infrastructure, including firewalls and NAT. 3243 That said, ICE works best in environments where the NAT devices are 3244 "behave" compliant, meeting the recommendations defined in [RFC4787] 3245 and [RFC5382]. In networks with behave-compliant NAT, ICE will work 3246 without the need for a TURN server, thus improving voice quality, 3247 decreasing call setup times, and reducing the bandwidth demands on 3248 the network operator. 3250 19.2. Bandwidth Requirements 3252 Deployment of ICE can have several interactions with available 3253 network capacity that operators should take into consideration. 3255 19.2.1. STUN and TURN Server Capacity Planning 3257 First and foremost, ICE makes use of TURN and STUN servers, which 3258 would typically be located in the network operator's data centers. 3259 The STUN servers require relatively little bandwidth. For each 3260 component of each data stream, there will be one or more STUN 3261 transactions from each client to the STUN server. In a basic voice- 3262 only IPv4 VoIP deployment, there will be four transactions per call 3263 (one for RTP and one for RTCP, for both caller and callee). Each 3264 transaction is a single request and a single response, the former 3265 being 20 bytes long, and the latter, 28. Consequently, if a system 3266 has N users, and each makes four calls in a busy hour, this would 3267 require N*1.7bps. For one million users, this is 1.7 Mbps, a very 3268 small number (relatively speaking). 3270 TURN traffic is more substantial. The TURN server will see traffic 3271 volume equal to the STUN volume (indeed, if TURN servers are 3272 deployed, there is no need for a separate STUN server), in addition 3273 to the traffic for the actual data. The amount of calls requiring 3274 TURN for data relay is highly dependent on network topologies, and 3275 can and will vary over time. In a network with 100% behave-compliant 3276 NAT, it is exactly zero. At time of writing, large-scale consumer 3277 deployments were seeing between 5 and 10 percent of calls requiring 3278 TURN servers. Considering a voice-only deployment using G.711 (so 80 3279 kbps in each direction), with .2 erlangs during the busy hour, this 3280 is N*3.2 kbps. For a population of one million users, this is 3.2 3281 Gbps, assuming a 10% usage of TURN servers. 3283 19.2.2. Gathering and Connectivity Checks 3285 The process of gathering of candidates and performing of connectivity 3286 checks can be bandwidth intensive. ICE has been designed to pace 3287 both of these processes. The gathering phase and the connectivity 3288 check phase are meant to generate traffic at roughly the same 3289 bandwidth as the data traffic itself. This was done to ensure that, 3290 if a network is designed to support communication traffic of a 3291 certain type (voice, video, or just text), it will have sufficient 3292 capacity to support the ICE checks for that data. Of course, the ICE 3293 checks will cause a marginal increase in the total utilization; 3294 however, this will typically be an extremely small increase. 3296 Congestion due to the gathering and check phases has proven to be a 3297 problem in deployments that did not utilize pacing. Typically, 3298 access links became congested as the endpoints flooded the network 3299 with checks as fast as they can send them. Consequently, network 3300 operators should make sure that their ICE implementations support the 3301 pacing feature. Though this pacing does increase call setup times, 3302 it makes ICE network friendly and easier to deploy. 3304 19.2.3. Keepalives 3306 STUN keepalives (in the form of STUN Binding Indications) are sent in 3307 the middle of a data session. However, they are sent only in the 3308 absence of actual data traffic. In deployments that are not 3309 utilizing Voice Activity Detection (VAD), the keepalives are never 3310 used and there is no increase in bandwidth usage. When VAD is being 3311 used, keepalives will be sent during silence periods. This involves 3312 a single packet every 15-20 seconds, far less than the packet every 3313 20-30 ms that is sent when there is voice. Therefore, keepalives 3314 don't have any real impact on capacity planning. 3316 19.3. ICE and ICE-lite 3318 Deployments utilizing a mix of ICE and ICE-lite interoperate 3319 perfectly. They have been explicitly designed to do so, without loss 3320 of function. 3322 However, ICE-lite can only be deployed in limited use cases. Those 3323 cases, and the caveats involved in doing so, are documented in 3324 Appendix A. 3326 19.4. Troubleshooting and Performance Management 3328 ICE utilizes end-to-end connectivity checks, and places much of the 3329 processing in the endpoints. This introduces a challenge to the 3330 network operator -- how can they troubleshoot ICE deployments? How 3331 can they know how ICE is performing? 3333 ICE has built-in features to help deal with these problems. 3334 Signaling servers, typically deployed in the data centers of the 3335 network operator, will see the contents of the candidate exchanges 3336 that convey the ICE parameters. These parameters include the type of 3337 each candidate (host, server reflexive, or relayed), along with their 3338 related addresses. Once ICE processing has completed, an updated 3339 candidate exchange takes place, signaling the selected address (and 3340 its type). This updated signaling is performed exactly for the 3341 purposes of educating network equipment (such as a diagnostic tool 3342 attached to a signaling) about the results of ICE processing. 3344 As a consequence, through the logs generated by a signaling server, a 3345 network operator can observe what types of candidates are being used 3346 for each call, and what address were selected by ICE. This is the 3347 primary information that helps evaluate how ICE is performing. 3349 19.5. Endpoint Configuration 3351 ICE relies on several pieces of data being configured into the 3352 endpoints. This configuration data includes timers, credentials for 3353 TURN servers, and hostnames for STUN and TURN servers. ICE itself 3354 does not provide a mechanism for this configuration. Instead, it is 3355 assumed that this information is attached to whatever mechanism is 3356 used to configure all of the other parameters in the endpoint. For 3357 SIP phones, standard solutions such as the configuration framework 3358 [RFC6080] have been defined. 3360 20. IANA Considerations 3362 The original ICE specification registered four new STUN attributes, 3363 and one new STUN error response. The STUN attributes and error 3364 response are reproduced here. In addition, this specification 3365 registers a new ICE option. 3367 20.1. STUN Attributes 3369 IANA has registered four STUN attributes: 3371 0x0024 PRIORITY 3372 0x0025 USE-CANDIDATE 3373 0x8029 ICE-CONTROLLED 3374 0x802A ICE-CONTROLLING 3376 20.2. STUN Error Responses 3378 IANA has registered following STUN error response code: 3380 487 Role Conflict: The client asserted an ICE role (controlling or 3381 controlled) that is in conflict with the role of the server. 3383 20.3. ICE Options 3385 IANA is requested to register the following ICE option in the "ICE 3386 Options" sub-registry of the "Interactive Connectivity Establishment 3387 (ICE) registry", following the procedures defined in [RFC6336]. 3389 ICE Option name: 3391 ice2 3393 Contact: 3395 Name: Christer Holmberg 3396 E-mail: christer.holmberg(at)ericsson(dot)com 3397 Address: Oy LM Ericsson Ab, 02420 Jorvas, FINLAND 3399 Change control: 3401 IESG 3403 Description: 3405 The ICE option indicates that the ICE agent using the ICE option 3406 is compliant and implemented according to RFC XXXX. 3408 Reference: 3410 RFC XXXX 3412 21. IAB Considerations 3414 The IAB has studied the problem of "Unilateral Self-Address Fixing", 3415 which is the general process by which an ICE agent attempts to 3416 determine its address in another realm on the other side of a NAT 3417 through a collaborative protocol reflection mechanism [RFC3424]. ICE 3418 is an example of a protocol that performs this type of function. 3419 Interestingly, the process for ICE is not unilateral, but bilateral, 3420 and the difference has a significant impact on the issues raised by 3421 IAB. Indeed, ICE can be considered a B-SAF (Bilateral Self-Address 3422 Fixing) protocol, rather than an UNSAF protocol. Regardless, the IAB 3423 has mandated that any protocols developed for this purpose document a 3424 specific set of considerations. This section meets those 3425 requirements. 3427 21.1. Problem Definition 3429 From RFC 3424, any UNSAF proposal must provide: 3431 Precise definition of a specific, limited-scope problem that is to 3432 be solved with the UNSAF proposal. A short-term fix should not be 3433 generalized to solve other problems; this is why "short-term fixes 3434 usually aren't". 3436 The specific problems being solved by ICE are: 3438 Provide a means for two peers to determine the set of transport 3439 addresses that can be used for communication. 3441 Provide a means for a agent to determine an address that is 3442 reachable by another peer with which it wishes to communicate. 3444 21.2. Exit Strategy 3446 From RFC 3424, any UNSAF proposal must provide: 3448 Description of an exit strategy/transition plan. The better 3449 short-term fixes are the ones that will naturally see less and 3450 less use as the appropriate technology is deployed. 3452 ICE itself doesn't easily get phased out. However, it is useful even 3453 in a globally connected Internet, to serve as a means for detecting 3454 whether a router failure has temporarily disrupted connectivity, for 3455 example. ICE also helps prevent certain security attacks that have 3456 nothing to do with NAT. However, what ICE does is help phase out 3457 other UNSAF mechanisms. ICE effectively picks amongst those 3458 mechanisms, prioritizing ones that are better, and deprioritizing 3459 ones that are worse. Local IPv6 addresses can be preferred. As NATs 3460 begin to dissipate as IPv6 is introduced, server reflexive and 3461 relayed candidates (both forms of UNSAF addresses) simply never get 3462 used, because higher-priority connectivity exists to the native host 3463 candidates. Therefore, the servers get used less and less, and can 3464 eventually be remove when their usage goes to zero. 3466 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 3467 be used to determine whether to use IPv6 or IPv4 when two dual-stack 3468 hosts communicate with SIP (IPv6 gets used). It can also allow a 3469 network with both 6to4 and native v6 connectivity to determine which 3470 address to use when communicating with a peer. 3472 21.3. Brittleness Introduced by ICE 3474 From RFC 3424, any UNSAF proposal must provide: 3476 Discussion of specific issues that may render systems more 3477 "brittle". For example, approaches that involve using data at 3478 multiple network layers create more dependencies, increase 3479 debugging challenges, and make it harder to transition. 3481 ICE actually removes brittleness from existing UNSAF mechanisms. In 3482 particular, classic STUN (as described in RFC 3489 [RFC3489]) has 3483 several points of brittleness. One of them is the discovery process 3484 that requires an ICE agent to try to classify the type of NAT it is 3485 behind. This process is error-prone. With ICE, that discovery 3486 process is simply not used. Rather than unilaterally assessing the 3487 validity of the address, its validity is dynamically determined by 3488 measuring connectivity to a peer. The process of determining 3489 connectivity is very robust. 3491 Another point of brittleness in classic STUN and any other unilateral 3492 mechanism is its absolute reliance on an additional server. ICE 3493 makes use of a server for allocating unilateral addresses, but allows 3494 agents to directly connect if possible. Therefore, in some cases, 3495 the failure of a STUN server would still allow for a call to progress 3496 when ICE is used. 3498 Another point of brittleness in classic STUN is that it assumes that 3499 the STUN server is on the public Internet. Interestingly, with ICE, 3500 that is not necessary. There can be a multitude of STUN servers in a 3501 variety of address realms. ICE will discover the one that has 3502 provided a usable address. 3504 The most troubling point of brittleness in classic STUN is that it 3505 doesn't work in all network topologies. In cases where there is a 3506 shared NAT between each agent and the STUN server, traditional STUN 3507 may not work. With ICE, that restriction is removed. 3509 Classic STUN also introduces some security considerations. 3510 Fortunately, those security considerations are also mitigated by ICE. 3512 Consequently, ICE serves to repair the brittleness introduced in 3513 classic STUN, and does not introduce any additional brittleness into 3514 the system. 3516 The penalty of these improvements is that ICE increases session 3517 establishment times. 3519 21.4. Requirements for a Long-Term Solution 3521 From RFC 3424, any UNSAF proposal must provide: 3523 ... requirements for longer term, sound technical solutions -- 3524 contribute to the process of finding the right longer term 3525 solution. 3527 Our conclusions from RFC 3489 remain unchanged. However, we feel ICE 3528 actually helps because we believe it can be part of the long-term 3529 solution. 3531 21.5. Issues with Existing NAPT Boxes 3533 From RFC 3424, any UNSAF proposal must provide: 3535 Discussion of the impact of the noted practical issues with 3536 existing, deployed NA[P]Ts and experience reports. 3538 A number of NAT boxes are now being deployed into the market that try 3539 to provide "generic" ALG functionality. These generic ALGs hunt for 3540 IP addresses, either in text or binary form within a packet, and 3541 rewrite them if they match a binding. This interferes with classic 3542 STUN. However, the update to STUN [RFC5389] uses an encoding that 3543 hides these binary addresses from generic ALGs. 3545 Existing NAPT boxes have non-deterministic and typically short 3546 expiration times for UDP-based bindings. This requires 3547 implementations to send periodic keepalives to maintain those 3548 bindings. ICE uses a default of 15 s, which is a very conservative 3549 estimate. Eventually, over time, as NAT boxes become compliant to 3550 behave [RFC4787], this minimum keepalive will become deterministic 3551 and well-known, and the ICE timers can be adjusted. Having a way to 3552 discover and control the minimum keepalive interval would be far 3553 better still. 3555 22. Changes from RFC 5245 3557 The purpose of this updated ICE specification is to: 3559 o Clarify procedures in RFC 5245. 3561 o Make technical changes, due to discovered flows in RFC 5245 and 3562 based on feedback from the community that has implemented and 3563 deployed ICE applications based on RFC 5245. 3565 o Make the procedures signaling protocol independent, by removing 3566 the SIP and SDP procedures. Procedures specific to a signaling 3567 protocol will be defined in separate usage documents. 3568 [I-D.ietf-mmusic-ice-sip-sdp] defines the ICE usage with SIP and 3569 SDP. 3571 The following technical changes have been done: 3573 o Aggressive nomination removed. 3575 o The procedures for calculating candidate pair states and 3576 scheduling connectivity checks modified. 3578 o Procedures for calculation of Ta and RTO modified. 3580 o Active check list and frozen check list definitions removed. 3582 o 'ice2' ice option added. 3584 o IPv6 considerations modified. 3586 o Usage with no-op for keepalives, and keepalives with non-ICE 3587 peers, removed. 3589 23. Acknowledgements 3591 Most of the text in this document comes from the original ICE 3592 specification, RFC 5245. The authors would like to thank everyone 3593 who has contributed to that document. For additional contributions 3594 to this revision of the specification we would like to thank Emil 3595 Ivov, Paul Kyzivat, Pal-Erik Martinsen, Simon Perrault, Eric 3596 Rescorla, Thomas Stach, Peter Thatcher, Martin Thomson, Justin 3597 Uberti, Suhas Nandakumar, Taylor Brandstetter, Peter Saint-Andre, 3598 Harald Alvestrand and Roman Shpount. 3600 24. References 3602 24.1. Normative References 3604 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3605 Requirement Levels", BCP 14, RFC 2119, 3606 DOI 10.17487/RFC2119, March 1997, . 3609 [RFC4941] Narten, T., Draves, R., and S. Krishnan, "Privacy 3610 Extensions for Stateless Address Autoconfiguration in 3611 IPv6", RFC 4941, DOI 10.17487/RFC4941, September 2007, 3612 . 3614 [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, 3615 "Session Traversal Utilities for NAT (STUN)", RFC 5389, 3616 DOI 10.17487/RFC5389, October 2008, . 3619 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3620 Relays around NAT (TURN): Relay Extensions to Session 3621 Traversal Utilities for NAT (STUN)", RFC 5766, 3622 DOI 10.17487/RFC5766, April 2010, . 3625 [RFC6336] Westerlund, M. and C. Perkins, "IANA Registry for 3626 Interactive Connectivity Establishment (ICE) Options", 3627 RFC 6336, DOI 10.17487/RFC6336, July 2011, 3628 . 3630 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3631 "Default Address Selection for Internet Protocol Version 6 3632 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3633 . 3635 24.2. Informative References 3637 [RFC3605] Huitema, C., "Real Time Control Protocol (RTCP) attribute 3638 in Session Description Protocol (SDP)", RFC 3605, 3639 DOI 10.17487/RFC3605, October 2003, . 3642 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3643 A., Peterson, J., Sparks, R., Handley, M., and E. 3644 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3645 DOI 10.17487/RFC3261, June 2002, . 3648 [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model 3649 with Session Description Protocol (SDP)", RFC 3264, 3650 DOI 10.17487/RFC3264, June 2002, . 3653 [RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, 3654 "STUN - Simple Traversal of User Datagram Protocol (UDP) 3655 Through Network Address Translators (NATs)", RFC 3489, 3656 DOI 10.17487/RFC3489, March 2003, . 3659 [RFC3235] Senie, D., "Network Address Translator (NAT)-Friendly 3660 Application Design Guidelines", RFC 3235, 3661 DOI 10.17487/RFC3235, January 2002, . 3664 [RFC3303] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and 3665 A. Rayhan, "Middlebox communication architecture and 3666 framework", RFC 3303, DOI 10.17487/RFC3303, August 2002, 3667 . 3669 [RFC3102] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, 3670 "Realm Specific IP: Framework", RFC 3102, 3671 DOI 10.17487/RFC3102, October 2001, . 3674 [RFC3103] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, 3675 "Realm Specific IP: Protocol Specification", RFC 3103, 3676 DOI 10.17487/RFC3103, October 2001, . 3679 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3680 UNilateral Self-Address Fixing (UNSAF) Across Network 3681 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3682 November 2002, . 3684 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3685 Jacobson, "RTP: A Transport Protocol for Real-Time 3686 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3687 July 2003, . 3689 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3690 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3691 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3692 . 3694 [RFC3879] Huitema, C. and B. Carpenter, "Deprecating Site Local 3695 Addresses", RFC 3879, DOI 10.17487/RFC3879, September 3696 2004, . 3698 [RFC4038] Shin, M-K., Ed., Hong, Y-G., Hagino, J., Savola, P., and 3699 E. Castro, "Application Aspects of IPv6 Transition", 3700 RFC 4038, DOI 10.17487/RFC4038, March 2005, 3701 . 3703 [RFC4091] Camarillo, G. and J. Rosenberg, "The Alternative Network 3704 Address Types (ANAT) Semantics for the Session Description 3705 Protocol (SDP) Grouping Framework", RFC 4091, 3706 DOI 10.17487/RFC4091, June 2005, . 3709 [RFC4092] Camarillo, G. and J. Rosenberg, "Usage of the Session 3710 Description Protocol (SDP) Alternative Network Address 3711 Types (ANAT) Semantics in the Session Initiation Protocol 3712 (SIP)", RFC 4092, DOI 10.17487/RFC4092, June 2005, 3713 . 3715 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 3716 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 3717 2006, . 3719 [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 3720 Description Protocol", RFC 4566, DOI 10.17487/RFC4566, 3721 July 2006, . 3723 [RFC2475] Blake, S., Black, D., Carlson, M., Davies, E., Wang, Z., 3724 and W. Weiss, "An Architecture for Differentiated 3725 Services", RFC 2475, DOI 10.17487/RFC2475, December 1998, 3726 . 3728 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3729 and E. Lear, "Address Allocation for Private Internets", 3730 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3731 . 3733 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3734 Translation (NAT) Behavioral Requirements for Unicast 3735 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3736 2007, . 3738 [RFC5761] Perkins, C. and M. Westerlund, "Multiplexing RTP Data and 3739 Control Packets on a Single Port", RFC 5761, 3740 DOI 10.17487/RFC5761, April 2010, . 3743 [RFC4103] Hellstrom, G. and P. Jones, "RTP Payload for Text 3744 Conversation", RFC 4103, DOI 10.17487/RFC4103, June 2005, 3745 . 3747 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3748 (ICE): A Protocol for Network Address Translator (NAT) 3749 Traversal for Offer/Answer Protocols", RFC 5245, 3750 DOI 10.17487/RFC5245, April 2010, . 3753 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 3754 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 3755 RFC 5382, DOI 10.17487/RFC5382, October 2008, 3756 . 3758 [RFC6080] Petrie, D. and S. Channabasappa, Ed., "A Framework for 3759 Session Initiation Protocol User Agent Profile Delivery", 3760 RFC 6080, DOI 10.17487/RFC6080, March 2011, 3761 . 3763 [RFC6146] Bagnulo, M., Matthews, P., and I. van Beijnum, "Stateful 3764 NAT64: Network Address and Protocol Translation from IPv6 3765 Clients to IPv4 Servers", RFC 6146, DOI 10.17487/RFC6146, 3766 April 2011, . 3768 [RFC6147] Bagnulo, M., Sullivan, A., Matthews, P., and I. van 3769 Beijnum, "DNS64: DNS Extensions for Network Address 3770 Translation from IPv6 Clients to IPv4 Servers", RFC 6147, 3771 DOI 10.17487/RFC6147, April 2011, . 3774 [RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, 3775 "TCP Candidates with Interactive Connectivity 3776 Establishment (ICE)", RFC 6544, DOI 10.17487/RFC6544, 3777 March 2012, . 3779 [RFC7050] Savolainen, T., Korhonen, J., and D. Wing, "Discovery of 3780 the IPv6 Prefix Used for IPv6 Address Synthesis", 3781 RFC 7050, DOI 10.17487/RFC7050, November 2013, 3782 . 3784 [I-D.ietf-mmusic-ice-sip-sdp] 3785 Petit-Huguenin, M., Keranen, A., and S. Nandakumar, 3786 "Session Description Protocol (SDP) Offer/Answer 3787 procedures for Interactive Connectivity Establishment 3788 (ICE)", draft-ietf-mmusic-ice-sip-sdp-14 (work in 3789 progress), October 2017. 3791 [RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy 3792 Considerations for IPv6 Address Generation Mechanisms", 3793 RFC 7721, DOI 10.17487/RFC7721, March 2016, 3794 . 3796 [I-D.ietf-ice-dualstack-fairness] 3797 Martinsen, P., Reddy, T., and P. Patil, "ICE Multihomed 3798 and IPv4/IPv6 Dual Stack Guidelines", draft-ietf-ice- 3799 dualstack-fairness-07 (work in progress), November 2016. 3801 Appendix A. Lite and Full Implementations 3803 ICE allows for two types of implementations. A full implementation 3804 supports the controlling and controlled roles in a session, and can 3805 also perform address gathering. In contrast, a lite implementation 3806 is a minimalist implementation that does little but respond to STUN 3807 checks. 3809 Because ICE requires both endpoints to support it in order to bring 3810 benefits to either endpoint, incremental deployment of ICE in a 3811 network is more complicated. Many sessions involve an endpoint that 3812 is, by itself, not behind a NAT and not one that would worry about 3813 NAT traversal. A very common case is to have one endpoint that 3814 requires NAT traversal (such as a VoIP hard phone or soft phone) make 3815 a call to one of these devices. Even if the phone supports a full 3816 ICE implementation, ICE won't be used at all if the other device 3817 doesn't support it. The lite implementation allows for a low-cost 3818 entry point for these devices. Once they support the lite 3819 implementation, full implementations can connect to them and get the 3820 full benefits of ICE. 3822 Consequently, a lite implementation is only appropriate for devices 3823 that will *always* be connected to the public Internet and have a 3824 public IP address at which it can receive packets from any 3825 correspondent. ICE will not function when a lite implementation is 3826 placed behind a NAT. 3828 ICE allows a lite implementation to have a single IPv4 host candidate 3829 and several IPv6 addresses. In that case, candidate pairs are 3830 selected by the controlling agent using a static algorithm, such as 3831 the one in RFC 6724, which is recommended by this specification. 3832 However, static mechanisms for address selection are always prone to 3833 error, since they cannot ever reflect the actual topology and can 3834 never provide actual guarantees on connectivity. They are always 3835 heuristics. Consequently, if an ICE agent is implementing ICE just 3836 to select between its IPv4 and IPv6 addresses, and none of its IP 3837 addresses are behind NAT, usage of full ICE is still RECOMMENDED in 3838 order to provide the most robust form of address selection possible. 3840 It is important to note that the lite implementation was added to 3841 this specification to provide a stepping stone to full 3842 implementation. Even for devices that are always connected to the 3843 public Internet with just a single IPv4 address, a full 3844 implementation is preferable if achievable. Full implementations 3845 also obtain the security benefits of ICE unrelated to NAT traversal; 3846 in particular, the voice hammer attack described in Section 17 is 3847 prevented only for full implementations, not lite. Finally, it is 3848 often the case that a device that finds itself with a public address 3849 today will be placed in a network tomorrow where it will be behind a 3850 NAT. It is difficult to definitively know, over the lifetime of a 3851 device or product, that it will always be used on the public 3852 Internet. Full implementation provides assurance that communications 3853 will always work. 3855 Appendix B. Design Motivations 3857 ICE contains a number of normative behaviors that may themselves be 3858 simple, but derive from complicated or non-obvious thinking or use 3859 cases that merit further discussion. Since these design motivations 3860 are not necessary to understand for purposes of implementation, they 3861 are discussed here in an appendix to the specification. This section 3862 is non-normative. 3864 B.1. Pacing of STUN Transactions 3866 STUN transactions used to gather candidates and to verify 3867 connectivity are paced out at an approximate rate of one new 3868 transaction every Ta milliseconds. Each transaction, in turn, has a 3869 retransmission timer RTO that is a function of Ta as well. Why are 3870 these transactions paced, and why are these formulas used? 3872 Sending of these STUN requests will often have the effect of creating 3873 bindings on NAT devices between the client and the STUN servers. 3874 Experience has shown that many NAT devices have upper limits on the 3875 rate at which they will create new bindings. Experiments have shown 3876 that once every 5 ms is well supported. This is why Ta has a lower 3877 bound of 5 ms. Furthermore, transmission of these packets on the 3878 network makes use of bandwidth and needs to be rate limited by the 3879 ICE agent. Deployments based on earlier draft versions of [RFC5245] 3880 tended to overload rate-constrained access links and perform poorly 3881 overall, in addition to negatively impacting the network. As a 3882 consequence, the pacing ensures that the NAT device does not get 3883 overloaded and that traffic is kept at a reasonable rate. 3885 The definition of a "reasonable" rate is that STUN should not use 3886 more bandwidth than the RTP itself will use, once data starts 3887 flowing. The formula for Ta is designed so that, if a STUN packet 3888 were sent every Ta seconds, it would consume the same amount of 3889 bandwidth as RTP packets, summed across all data streams. Of course, 3890 STUN has retransmits, and the desire is to pace those as well. For 3891 this reason, RTO is set such that the first retransmit on the first 3892 transaction happens just as the first STUN request on the last 3893 transaction occurs. Pictorially: 3895 First Packets Retransmits 3897 | | 3898 | | 3899 -------+------ -------+------ 3900 / \ / \ 3901 / \ / \ 3903 +--+ +--+ +--+ +--+ +--+ +--+ 3904 |A1| |B1| |C1| |A2| |B2| |C2| 3905 +--+ +--+ +--+ +--+ +--+ +--+ 3907 ---+-------+-------+-------+-------+-------+------------ Time 3908 0 Ta 2Ta 3Ta 4Ta 5Ta 3910 In this picture, there are three transactions that will be sent (for 3911 example, in the case of candidate gathering, there are three host 3912 candidate/STUN server pairs). These are transactions A, B, and C. 3913 The retransmit timer is set so that the first retransmission on the 3914 first transaction (packet A2) is sent at time 3Ta. 3916 Subsequent retransmits after the first will occur even less 3917 frequently than Ta milliseconds apart, since STUN uses an exponential 3918 back-off on its retransmissions. 3920 B.2. Candidates with Multiple Bases 3922 Section 5.1.3 talks about eliminating candidates that have the same 3923 transport address and base. However, candidates with the same 3924 transport addresses but different bases are not redundant. When can 3925 an ICE agent have two candidates that have the same IP address and 3926 port, but different bases? Consider the topology of Figure 11: 3928 +----------+ 3929 | STUN Srvr| 3930 +----------+ 3931 | 3932 | 3933 ----- 3934 // \\ 3935 | | 3936 | B:net10 | 3937 | | 3938 \\ // 3939 ----- 3940 | 3941 | 3942 +----------+ 3943 | NAT | 3944 +----------+ 3945 | 3946 | 3947 ----- 3948 // \\ 3949 | A | 3950 |192.168/16 | 3951 | | 3952 \\ // 3953 ----- 3954 | 3955 | 3956 |192.168.1.100 ----- 3957 +----------+ // \\ +----------+ 3958 | | | | | | 3959 | Initiator|---------| C:net10 |-----------| Responder| 3960 | |10.0.1.100| | 10.0.1.101 | | 3961 +----------+ \\ // +----------+ 3962 ----- 3964 Figure 11: Identical Candidates with Different Bases 3966 In this case, the initiating agent is multihomed. It has one IP 3967 address, 10.0.1.100, on network C, which is a net 10 private network. 3968 The responding agent is on this same network. The initiating agent 3969 is also connected to network A, which is 192.168/16 and has an IP 3970 address of 192.168.1.100 on this network. There is a NAT on this 3971 network, natting into network B, which is another net 10 private 3972 network, but not connected to network C. There is a STUN server on 3973 network B. 3975 The initiating agent obtains a host candidate on its IP address on 3976 network C (10.0.1.100:2498) and a host candidate on its IP address on 3977 network A (192.168.1.100:3344). It performs a STUN query to its 3978 configured STUN server from 192.168.1.100:3344. This query passes 3979 through the NAT, which happens to assign the binding 10.0.1.100:2498. 3980 The STUN server reflects this in the STUN Binding response. Now, the 3981 initiating agent has obtained a server reflexive candidate with a 3982 transport address that is identical to a host candidate 3983 (10.0.1.100:2498). However, the server reflexive candidate has a 3984 base of 192.168.1.100:3344, and the host candidate has a base of 3985 10.0.1.100:2498. 3987 B.3. Purpose of the Related Address and Related Port Attributes 3989 The candidate attribute contains two values that are not used at all 3990 by ICE itself -- related address and related port. Why are they 3991 present? 3993 There are two motivations for its inclusion. The first is 3994 diagnostic. It is very useful to know the relationship between the 3995 different types of candidates. By including it, an ICE agent can 3996 know which relayed candidate is associated with which reflexive 3997 candidate, which in turn is associated with a specific host 3998 candidate. When checks for one candidate succeed and not for others, 3999 this provides useful diagnostics on what is going on in the network. 4001 The second reason has to do with off-path Quality of Service (QoS) 4002 mechanisms. When ICE is used in environments such as PacketCable 4003 2.0, proxies will, in addition to performing normal SIP operations, 4004 inspect the SDP in SIP messages, and extract the IP address and port 4005 for data traffic. They can then interact, through policy servers, 4006 with access routers in the network, to establish guaranteed QoS for 4007 the data flows. This QoS is provided by classifying the RTP traffic 4008 based on 5-tuple, and then providing it a guaranteed rate, or marking 4009 its Diffserv codepoints appropriately. When a residential NAT is 4010 present, and a relayed candidate gets selected for data, this relayed 4011 candidate will be a transport address on an actual TURN server. That 4012 address says nothing about the actual transport address in the access 4013 router that would be used to classify packets for QoS treatment. 4014 Rather, the server reflexive candidate towards the TURN server is 4015 needed. By carrying the translation in the SDP, the proxy can use 4016 that transport address to request QoS from the access router. 4018 B.4. Importance of the STUN Username 4020 ICE requires the usage of message integrity with STUN using its 4021 short-term credential functionality. The actual short-term 4022 credential is formed by exchanging username fragments in the 4023 candidate exchange. The need for this mechanism goes beyond just 4024 security; it is actually required for correct operation of ICE in the 4025 first place. 4027 Consider ICE agents L, R, and Z. L and R are within private 4028 enterprise 1, which is using 10.0.0.0/8. Z is within private 4029 enterprise 2, which is also using 10.0.0.0/8. As it turns out, R and 4030 Z both have IP address 10.0.1.1. L sends candidates to Z. Z, in 4031 responds L with its host candidates. In this case, those candidates 4032 are 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, R is in a 4033 session at that same time, and is also using 10.0.1.1:8866 and 4034 10.0.1.1:8877 as host candidates. This means that R is prepared to 4035 accept STUN messages on those ports, just as Z is. L will send a 4036 STUN request to 10.0.1.1:8866 and another to 10.0.1.1:8877. However, 4037 these do not go to Z as expected. Instead, they go to R! If R just 4038 replied to them, L would believe it has connectivity to Z, when in 4039 fact it has connectivity to a completely different user, R. To fix 4040 this, the STUN short-term credential mechanisms are used. The 4041 username fragments are sufficiently random that it is highly unlikely 4042 that R would be using the same values as Z. Consequently, R would 4043 reject the STUN request since the credentials were invalid. In 4044 essence, the STUN username fragments provide a form of transient host 4045 identifiers, bound to a particular session established as part of the 4046 candidate exchange. 4048 An unfortunate consequence of the non-uniqueness of IP addresses is 4049 that, in the above example, R might not even be an ICE agent. It 4050 could be any host, and the port to which the STUN packet is directed 4051 could be any ephemeral port on that host. If there is an application 4052 listening on this socket for packets, and it is not prepared to 4053 handle malformed packets for whatever protocol is in use, the 4054 operation of that application could be affected. Fortunately, since 4055 the ports exchanged are ephemeral and usually drawn from the dynamic 4056 or registered range, the odds are good that the port is not used to 4057 run a server on host R, but rather is the agent side of some 4058 protocol. This decreases the probability of hitting an allocated 4059 port, due to the transient nature of port usage in this range. 4060 However, the possibility of a problem does exist, and network 4061 deployers should be prepared for it. Note that this is not a problem 4062 specific to ICE; stray packets can arrive at a port at any time for 4063 any type of protocol, especially ones on the public Internet. As 4064 such, this requirement is just restating a general design guideline 4065 for Internet applications -- be prepared for unknown packets on any 4066 port. 4068 B.5. The Candidate Pair Priority Formula 4070 The priority for a candidate pair has an odd form. It is: 4072 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 4074 Why is this? When the candidate pairs are sorted based on this 4075 value, the resulting sorting has the MAX/MIN property. This means 4076 that the pairs are first sorted based on decreasing value of the 4077 minimum of the two priorities. For pairs that have the same value of 4078 the minimum priority, the maximum priority is used to sort amongst 4079 them. If the max and the min priorities are the same, the 4080 controlling agent's priority is used as the tie-breaker in the last 4081 part of the expression. The factor of 2*32 is used since the 4082 priority of a single candidate is always less than 2*32, resulting in 4083 the pair priority being a "concatenation" of the two component 4084 priorities. This creates the MAX/MIN sorting. MAX/MIN ensures that, 4085 for a particular ICE agent, a lower-priority candidate is never used 4086 until all higher-priority candidates have been tried. 4088 B.6. Why Are Keepalives Needed? 4090 Once data begins flowing on a candidate pair, it is still necessary 4091 to keep the bindings alive at intermediate NATs for the duration of 4092 the session. Normally, the data stream packets themselves (e.g., 4093 RTP) meet this objective. However, several cases merit further 4094 discussion. Firstly, in some RTP usages, such as SIP, the data 4095 streams can be "put on hold". This is accomplished by using the SDP 4096 "sendonly" or "inactive" attributes, as defined in RFC 3264 4097 [RFC3264]. RFC 3264 directs implementations to cease transmission of 4098 data in these cases. However, doing so may cause NAT bindings to 4099 timeout, and data won't be able to come off hold. 4101 Secondly, some RTP payload formats, such as the payload format for 4102 text conversation [RFC4103], may send packets so infrequently that 4103 the interval exceeds the NAT binding timeouts. 4105 Thirdly, if silence suppression is in use, long periods of silence 4106 may cause data transmission to cease sufficiently long for NAT 4107 bindings to time out. 4109 For these reasons, the data packets themselves cannot be relied upon. 4110 ICE defines a simple periodic keepalive utilizing STUN Binding 4111 indications. This makes its bandwidth requirements highly 4112 predictable, and thus amenable to QoS reservations. 4114 B.7. Why Prefer Peer Reflexive Candidates? 4116 Section 5.1.2 describes procedures for computing the priority of 4117 candidate based on its type and local preferences. That section 4118 requires that the type preference for peer reflexive candidates 4119 always be higher than server reflexive. Why is that? The reason has 4120 to do with the security considerations in Section 17. It is much 4121 easier for an attacker to cause an ICE agent to use a false server 4122 reflexive candidate than it is for an attacker to cause an agent to 4123 use a false peer reflexive candidate. Consequently, attacks against 4124 address gathering with Binding requests are thwarted by ICE by 4125 preferring the peer reflexive candidates. 4127 B.8. Why Are Binding Indications Used for Keepalives? 4129 Data keepalives are described in Section 11. These keepalives make 4130 use of STUN when both endpoints are ICE capable. However, rather 4131 than using a Binding request transaction (which generates a 4132 response), the keepalives use an Indication. Why is that? 4134 The primary reason has to do with network QoS mechanisms. Once data 4135 begins flowing, network elements will assume that the data stream has 4136 a fairly regular structure, making use of periodic packets at fixed 4137 intervals, with the possibility of jitter. If an ICE agent is 4138 sending data packets, and then receives a Binding request, it would 4139 need to generate a response packet along with its data packets. This 4140 will increase the actual bandwidth requirements for the 5-tuple 4141 carrying the data packets, and introduce jitter in the delivery of 4142 those packets. Analysis has shown that this is a concern in certain 4143 layer 2 access networks that use fairly tight packet schedulers for 4144 data. 4146 Additionally, using a Binding Indication allows integrity to be 4147 disabled, allowing for better performance. This is useful for large- 4148 scale endpoints, such as PSTN gateways and SBCs. 4150 B.9. Selecting Candidate Type Preference 4152 One criterion for selection of the type and local preference values 4153 is the use of a data intermediary, such as a TURN server, a tunnel 4154 service such as VPN server, or NAT. With a data intermediary, if 4155 data is sent to that candidate, it will first transit the data 4156 intermediary before being received. Relayed candidates are one type 4157 of candidate that involves a data intermediary. Another are host 4158 candidates obtained from a VPN interface. When data is transited 4159 through a data intermediary, it can have a positive or negative 4160 effect on the latency between transmission and reception. It may or 4161 may not increase the packet losses, because of the additional router 4162 hops that may be taken. It may increase the cost of providing 4163 service, since data will be routed in and right back out of a data 4164 intermediary run by a provider. If these concerns are important, the 4165 type preference for relayed candidates must be carefully chosen. 4167 Another criterion for selection of preferences is IP address family. 4168 ICE works with both IPv4 and IPv6. It provides a transition 4169 mechanism that allows dual-stack hosts to prefer connectivity over 4170 IPv6, but to fall back to IPv4 in case the v6 networks are 4171 disconnected. Implementation should follow the guidelines from 4172 [I-D.ietf-ice-dualstack-fairness] to avoid excessive delays in the 4173 connectivity check phase if broken paths exist. 4175 Another criterion for selecting preferences is topological awareness. 4176 This is most useful for candidates that make use of intermediaries. 4177 In those cases, if an ICE agent has preconfigured or dynamically 4178 discovered knowledge of the topological proximity of the 4179 intermediaries to itself, it can use that to assign higher local 4180 preferences to candidates obtained from closer intermediaries. 4182 Another criterion for selecting preferences might be security or 4183 privacy. If a user is a telecommuter, and therefore connected to a 4184 corporate network and a local home network, the user may prefer their 4185 voice traffic to be routed over the VPN or similar tunnel in order to 4186 keep it on the corporate network when communicating within the 4187 enterprise, but use the local network when communicating with users 4188 outside of the enterprise. In such a case, a VPN address would have 4189 a higher local preference than any other address. 4191 Appendix C. Connectivity Check Bandwidth 4193 The tables below show, for IPv4 and IPv6, the bandwidth required for 4194 performing connectivity checks, using different Ta values (given in 4195 ms) and different ufrag sizes (given in bytes). 4197 The results were provided by Jusin Uberti (Google) 11th April 2016. 4199 IP version: IPv4 4200 Packet len (bytes): 108 + ufrag 4201 | 4202 ms | 4 8 12 16 4203 -----|------------------------ 4204 500 | 1.86k 1.98k 2.11k 2.24k 4205 200 | 4.64k 4.96k 5.28k 5.6k 4206 100 | 9.28k 9.92k 10.6k 11.2k 4207 50 | 18.6k 19.8k 21.1k 22.4k 4208 20 | 46.4k 49.6k 52.8k 56.0k 4209 10 | 92.8k 99.2k 105k 112k 4210 5 | 185k 198k 211k 224k 4211 2 | 464k 496k 528k 560k 4212 1 | 928k 992k 1.06M 1.12M 4214 IP version: IPv6 4215 Packet len (bytes): 128 + ufrag 4216 | 4217 ms | 4 8 12 16 4218 -----|------------------------ 4219 500 | 2.18k 2.3k 2.43k 2.56k 4220 200 | 5.44k 5.76k 6.08k 6.4k 4221 100 | 10.9k 11.5k 12.2k 12.8k 4222 50 | 21.8k 23.0k 24.3k 25.6k 4223 20 | 54.4k 57.6k 60.8k 64.0k 4224 10 | 108k 115k 121k 128k 4225 5 | 217k 230k 243k 256k 4226 2 | 544k 576k 608k 640k 4227 1 | 1.09M 1.15M 1.22M 1.28M 4229 Figure 12: Connectivity Check Bandwidth 4231 Authors' Addresses 4233 Ari Keranen 4234 Ericsson 4235 Hirsalantie 11 4236 02420 Jorvas 4237 Finland 4239 Email: ari.keranen@ericsson.com 4240 Christer Holmberg 4241 Ericsson 4242 Hirsalantie 11 4243 02420 Jorvas 4244 Finland 4246 Email: christer.holmberg@ericsson.com 4248 Jonathan Rosenberg 4249 jdrosen.net 4250 Monmouth, NJ 4251 US 4253 Email: jdrosen@jdrosen.net 4254 URI: http://www.jdrosen.net