idnits 2.17.1 draft-ietf-ice-rfc5245bis-07.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 14 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 1711 has weird spacing: '... | f-cp f-cp ...' == Line 1713 has weird spacing: '... | f-cp f-cp ...' == Line 1724 has weird spacing: '... | w-cp w-cp ...' == Line 1726 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 (December 8, 2016) is 2696 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) == Unused Reference: 'RFC3056' is defined on line 3883, but no explicit reference was found in the text ** 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-10 Summary: 3 errors (**), 0 flaws (~~), 9 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: June 11, 2017 jdrosen.net 7 December 8, 2016 9 Interactive Connectivity Establishment (ICE): A Protocol for Network 10 Address Translator (NAT) Traversal 11 draft-ietf-ice-rfc5245bis-07 13 Abstract 15 This document describes a protocol for Network Address Translator 16 (NAT) traversal for UDP-based multimedia. 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 June 11, 2017. 40 Copyright Notice 42 Copyright (c) 2016 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 Candidate Addresses . . . . . . . . . . . . . . 8 72 2.2. Connectivity Checks . . . . . . . . . . . . . . . . . . . 10 73 2.3. Sorting Candidates . . . . . . . . . . . . . . . . . . . 11 74 2.4. Frozen Candidates . . . . . . . . . . . . . . . . . . . . 12 75 2.5. Security for Checks . . . . . . . . . . . . . . . . . . . 13 76 2.6. Concluding ICE . . . . . . . . . . . . . . . . . . . . . 13 77 2.7. Lite Implementations . . . . . . . . . . . . . . . . . . 14 78 2.8. Usages of ICE . . . . . . . . . . . . . . . . . . . . . . 15 79 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 15 80 4. ICE Candidate Gathering and Exchange . . . . . . . . . . . . 18 81 4.1. Procedures for Full Implementation . . . . . . . . . . . 19 82 4.1.1. Gathering Candidates . . . . . . . . . . . . . . . . 19 83 4.1.1.1. Host Candidates . . . . . . . . . . . . . . . . . 20 84 4.1.1.2. Server Reflexive and Relayed Candidates . . . . . 21 85 4.1.1.3. Computing Foundations . . . . . . . . . . . . . . 23 86 4.1.1.4. Keeping Candidates Alive . . . . . . . . . . . . 23 87 4.1.2. Prioritizing Candidates . . . . . . . . . . . . . . . 24 88 4.1.2.1. Recommended Formula . . . . . . . . . . . . . . . 24 89 4.1.2.2. Guidelines for Choosing Type and Local 90 Preferences . . . . . . . . . . . . . . . . . . . 25 91 4.1.3. Eliminating Redundant Candidates . . . . . . . . . . 26 92 4.2. Lite Implementation Procedures . . . . . . . . . . . . . 26 93 4.3. Encoding the Candidate Information . . . . . . . . . . . 27 94 5. ICE Candidate Processing . . . . . . . . . . . . . . . . . . 29 95 5.1. Procedures for Full Implementation . . . . . . . . . . . 29 96 5.1.1. Verifying ICE Support . . . . . . . . . . . . . . . . 29 97 5.1.2. Determining Role . . . . . . . . . . . . . . . . . . 30 98 5.1.3. Forming the Check Lists . . . . . . . . . . . . . . . 31 99 5.1.3.1. Check List State . . . . . . . . . . . . . . . . 31 100 5.1.3.2. Forming Candidate Pairs . . . . . . . . . . . . . 32 101 5.1.3.3. Computing Pair Priority and Ordering Pairs . . . 35 102 5.1.3.4. Pruning the Pairs . . . . . . . . . . . . . . . . 35 103 5.1.3.5. Removing lower-priority Pairs . . . . . . . . . . 35 104 5.1.3.6. Computing Candidate Pair States . . . . . . . . . 35 105 5.1.4. ICE State . . . . . . . . . . . . . . . . . . . . . . 40 106 5.1.5. Scheduling Checks . . . . . . . . . . . . . . . . . . 40 107 5.1.5.1. Triggered Check Queue . . . . . . . . . . . . . . 40 108 5.1.5.2. Timer Tc . . . . . . . . . . . . . . . . . . . . 40 109 5.1.5.3. Performing Connectivity Checks . . . . . . . . . 40 110 5.2. Lite Implementation Procedures . . . . . . . . . . . . . 41 111 6. Performing Connectivity Checks . . . . . . . . . . . . . . . 42 112 6.1. STUN Client Procedures . . . . . . . . . . . . . . . . . 42 113 6.1.1. Creating Permissions for Relayed Candidates . . . . . 42 114 6.1.2. Sending the Request . . . . . . . . . . . . . . . . . 42 115 6.1.2.1. PRIORITY . . . . . . . . . . . . . . . . . . . . 43 116 6.1.2.2. USE-CANDIDATE . . . . . . . . . . . . . . . . . . 43 117 6.1.2.3. ICE-CONTROLLED and ICE-CONTROLLING . . . . . . . 43 118 6.1.2.3.1. Forming Credentials . . . . . . . . . . . . . 43 119 6.1.2.3.2. DiffServ Treatment . . . . . . . . . . . . . 44 120 6.1.2.4. Processing the Response . . . . . . . . . . . . . 44 121 6.1.2.4.1. Failure Cases . . . . . . . . . . . . . . . . 44 122 6.1.2.4.2. Success Cases . . . . . . . . . . . . . . . . 45 123 6.1.2.4.3. Check List and Timer State Updates . . . . . 48 124 6.1.3. STUN Server Procedures . . . . . . . . . . . . . . . 48 125 6.1.3.1. Additional Procedures for Full Implementations . 49 126 6.1.3.1.1. Detecting and Repairing Role Conflicts . . . 49 127 6.1.3.1.2. Computing Mapped Address . . . . . . . . . . 50 128 6.1.3.1.3. Learning Peer Reflexive Candidates . . . . . 51 129 6.1.3.1.4. Triggered Checks . . . . . . . . . . . . . . 51 130 6.1.3.1.5. Updating the Nominated Flag . . . . . . . . . 52 131 6.1.3.2. Additional Procedures for Lite Implementations . 53 132 6.2. Concluding ICE Processing . . . . . . . . . . . . . . . . 53 133 6.2.1. Procedures for Full Implementations . . . . . . . . . 53 134 6.2.1.1. Nominating Pairs . . . . . . . . . . . . . . . . 53 135 6.2.1.2. Updating States . . . . . . . . . . . . . . . . . 54 136 6.2.2. Procedures for Lite Implementations . . . . . . . . . 55 137 6.2.2.1. Peer Is Full . . . . . . . . . . . . . . . . . . 56 138 6.2.2.2. Peer Is Lite . . . . . . . . . . . . . . . . . . 56 139 6.2.3. Freeing Candidates . . . . . . . . . . . . . . . . . 57 140 6.2.3.1. Full Implementation Procedures . . . . . . . . . 57 141 6.2.3.2. Lite Implementation Procedures . . . . . . . . . 57 142 6.3. ICE Restarts . . . . . . . . . . . . . . . . . . . . . . 57 143 7. ICE Option . . . . . . . . . . . . . . . . . . . . . . . . . 58 144 8. Keepalives . . . . . . . . . . . . . . . . . . . . . . . . . 58 145 9. Media Handling . . . . . . . . . . . . . . . . . . . . . . . 59 146 9.1. Sending Media . . . . . . . . . . . . . . . . . . . . . . 59 147 9.1.1. Procedures for Full Implementations . . . . . . . . . 59 148 9.1.2. Procedures for Lite Implementations . . . . . . . . . 60 149 9.1.3. Procedures for All Implementations . . . . . . . . . 60 150 9.2. Receiving Media . . . . . . . . . . . . . . . . . . . . . 61 151 10. Extensibility Considerations . . . . . . . . . . . . . . . . 61 152 11. Setting Ta and RTO . . . . . . . . . . . . . . . . . . . . . 62 153 11.1. General . . . . . . . . . . . . . . . . . . . . . . . . 62 154 11.2. Ta . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 155 11.3. RTO . . . . . . . . . . . . . . . . . . . . . . . . . . 64 156 12. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 157 13. Security Considerations . . . . . . . . . . . . . . . . . . . 69 158 13.1. Attacks on Connectivity Checks . . . . . . . . . . . . . 70 159 13.2. Attacks on Server Reflexive Address Gathering . . . . . 72 160 13.3. Attacks on Relayed Candidate Gathering . . . . . . . . . 73 161 13.4. Insider Attacks . . . . . . . . . . . . . . . . . . . . 73 162 13.4.1. STUN Amplification Attack . . . . . . . . . . . . . 73 163 14. STUN Extensions . . . . . . . . . . . . . . . . . . . . . . . 74 164 14.1. New Attributes . . . . . . . . . . . . . . . . . . . . . 74 165 14.2. New Error Response Codes . . . . . . . . . . . . . . . . 75 166 15. Operational Considerations . . . . . . . . . . . . . . . . . 75 167 15.1. NAT and Firewall Types . . . . . . . . . . . . . . . . . 75 168 15.2. Bandwidth Requirements . . . . . . . . . . . . . . . . . 76 169 15.2.1. STUN and TURN Server Capacity Planning . . . . . . . 76 170 15.2.2. Gathering and Connectivity Checks . . . . . . . . . 76 171 15.2.3. Keepalives . . . . . . . . . . . . . . . . . . . . . 77 172 15.3. ICE and ICE-lite . . . . . . . . . . . . . . . . . . . . 77 173 15.4. Troubleshooting and Performance Management . . . . . . . 77 174 15.5. Endpoint Configuration . . . . . . . . . . . . . . . . . 78 175 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 78 176 16.1. STUN Attributes . . . . . . . . . . . . . . . . . . . . 78 177 16.2. STUN Error Responses . . . . . . . . . . . . . . . . . . 78 178 16.3. ICE Options . . . . . . . . . . . . . . . . . . . . . . 78 179 17. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 79 180 17.1. Problem Definition . . . . . . . . . . . . . . . . . . . 79 181 17.2. Exit Strategy . . . . . . . . . . . . . . . . . . . . . 80 182 17.3. Brittleness Introduced by ICE . . . . . . . . . . . . . 80 183 17.4. Requirements for a Long-Term Solution . . . . . . . . . 81 184 17.5. Issues with Existing NAPT Boxes . . . . . . . . . . . . 82 185 18. Changes from RFC 5245 . . . . . . . . . . . . . . . . . . . . 82 186 19. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 82 187 20. References . . . . . . . . . . . . . . . . . . . . . . . . . 83 188 20.1. Normative References . . . . . . . . . . . . . . . . . . 83 189 20.2. Informative References . . . . . . . . . . . . . . . . . 83 190 Appendix A. Lite and Full Implementations . . . . . . . . . . . 87 191 Appendix B. Design Motivations . . . . . . . . . . . . . . . . . 88 192 B.1. Pacing of STUN Transactions . . . . . . . . . . . . . . . 88 193 B.2. Candidates with Multiple Bases . . . . . . . . . . . . . 90 194 B.3. Purpose of the Related Address and Related Port 195 Attributes . . . . . . . . . . . . . . . . . . . . . . . 92 196 B.4. Importance of the STUN Username . . . . . . . . . . . . . 92 197 B.5. The Candidate Pair Priority Formula . . . . . . . . . . . 94 198 B.6. Why Are Keepalives Needed? . . . . . . . . . . . . . . . 94 199 B.7. Why Prefer Peer Reflexive Candidates? . . . . . . . . . . 95 200 B.8. Why Are Binding Indications Used for Keepalives? . . . . 95 201 Appendix C. Connectivity Check Bandwidth . . . . . . . . . . . . 95 202 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 96 204 1. Introduction 206 Protocols establishing multimedia sessions between peers typically 207 involve exchanging IP addresses and ports for the media sources and 208 sinks. However this poses challenges when operated through Network 209 Address Translators (NATs) [RFC3235]. These protocols also seek to 210 create a media flow directly between participants, so that there is 211 no application layer intermediary between them. This is done to 212 reduce media latency, decrease packet loss, and reduce the 213 operational costs of deploying the application. However, this is 214 difficult to accomplish through NAT. A full treatment of the reasons 215 for this is beyond the scope of this specification. 217 Numerous solutions have been defined for allowing these protocols to 218 operate through NAT. These include Application Layer Gateways 219 (ALGs), the Middlebox Control Protocol [RFC3303], the original Simple 220 Traversal of UDP Through NAT (STUN) [RFC3489] specification, and 221 Realm Specific IP [RFC3102] [RFC3103] along with session description 222 extensions needed to make them work, such as the Session Description 223 Protocol (SDP) [RFC4566] attribute for the Real Time Control Protocol 224 (RTCP) [RFC3605]. Unfortunately, these techniques all have pros and 225 cons which, make each one optimal in some network topologies, but a 226 poor choice in others. The result is that administrators and 227 implementors are making assumptions about the topologies of the 228 networks in which their solutions will be deployed. This introduces 229 complexity and brittleness into the system. What is needed is a 230 single solution that is flexible enough to work well in all 231 situations. 233 This specification defines Interactive Connectivity Establishment 234 (ICE) as a technique for NAT traversal for UDP-based media streams 235 (though ICE has been extended to handle other transport protocols, 236 such as TCP [RFC6544]). ICE works by exchanging a multiplicity of IP 237 addresses and ports which are then tested for connectivity by peer- 238 to-peer connectivity checks. The IP addresses and ports are 239 exchanged via mechanisms (for example, including in a offer/answer 240 exchange) and the connectivity checks are performed using Session 241 Traversal Utilities for NAT (STUN) specification [RFC5389]. ICE also 242 makes use of Traversal Using Relays around NAT (TURN) [RFC5766], an 243 extension to STUN. Because ICE exchanges a multiplicity of IP 244 addresses and ports for each media stream, it also allows for address 245 selection for multihomed and dual-stack hosts, and for this reason it 246 deprecates [RFC4091] and [RFC4092]. 248 2. Overview of ICE 250 In a typical ICE deployment, we have two endpoints (known as ICE 251 AGENTS) that want to communicate. They are able to communicate 252 indirectly via some signaling protocol (such as SIP), by which they 253 can exchange ICE candidates. Note that ICE is not intended for NAT 254 traversal for the signaling protocol, which is assumed to be provided 255 via another mechanism. At the beginning of the ICE process, the 256 agents are ignorant of their own topologies. In particular, they 257 might or might not be behind a NAT (or multiple tiers of NATs). ICE 258 allows the agents to discover enough information about their 259 topologies to potentially find one or more paths by which they can 260 communicate. 262 Figure 1 shows a typical environment for ICE deployment. The two 263 endpoints are labelled L and R (for left and right, which helps 264 visualize call flows). Both L and R are behind their own respective 265 NATs though they may not be aware of it. The type of NAT and its 266 properties are also unknown. Agents L and R are capable of engaging 267 in an candidate exchange process, whose purpose is to set up a media 268 session between L and R. Typically, this exchange will occur through 269 a signaling (e.g., SIP) server. 271 In addition to the agents, a signaling server and NATs, ICE is 272 typically used in concert with STUN or TURN servers in the network. 273 Each agent can have its own STUN or TURN server, or they can be the 274 same. 276 +---------+ 277 +--------+ |Signaling| +--------+ 278 | STUN | |Server | | STUN | 279 | Server | +---------+ | Server | 280 +--------+ / \ +--------+ 281 / \ 282 / \ 283 / <- Signaling -> \ 284 / \ 285 +--------+ +--------+ 286 | NAT | | NAT | 287 +--------+ +--------+ 288 / \ 289 / \ 290 +-------+ +-------+ 291 | Agent | | Agent | 292 | L | | R | 293 +-------+ +-------+ 295 Figure 1: ICE Deployment Scenario 297 The basic idea behind ICE is as follows: each agent has a variety of 298 candidate TRANSPORT ADDRESSES (combination of IP address and port for 299 a particular transport protocol, which is always UDP in this 300 specification) it could use to communicate with the other agent. 301 These might include: 303 o A transport address on a directly attached network interface 305 o A translated transport address on the public side of a NAT (a 306 "server reflexive" address) 308 o A transport address allocated from a TURN server (a "relayed 309 address") 311 Potentially, any of L's candidate transport addresses can be used to 312 communicate with any of R's candidate transport addresses. In 313 practice, however, many combinations will not work. For instance, if 314 L and R are both behind NATs, their directly attached interface 315 addresses are unlikely to be able to communicate directly (this is 316 why ICE is needed, after all!). The purpose of ICE is to discover 317 which pairs of addresses will work. The way that ICE does this is to 318 systematically try all possible pairs (in a carefully sorted order) 319 until it finds one or more that work. 321 2.1. Gathering Candidate Addresses 323 In order to execute ICE, an agent has to identify all of its address 324 candidates. A CANDIDATE is a transport address -- a combination of 325 IP address and port for a particular transport protocol (with only 326 UDP specified here). This document defines three types of 327 candidates, some derived from physical or logical network interfaces, 328 others discoverable via STUN and TURN. Naturally, one viable 329 candidate is a transport address obtained directly from a local 330 interface. Such a candidate is called a HOST CANDIDATE. The local 331 interface could be Ethernet or WiFi, or it could be one that is 332 obtained through a tunnel mechanism, such as a Virtual Private 333 Network (VPN) or Mobile IP (MIP). In all cases, such a network 334 interface appears to the agent as a local interface from which ports 335 (and thus candidates) can be allocated. 337 If an agent is multihomed, it obtains a candidate from each IP 338 address. Depending on the location of the PEER (the other agent in 339 the session) on the IP network relative to the agent, the agent may 340 be reachable by the peer through one or more of those IP addresses. 341 Consider, for example, an agent that has a local IP address on a 342 private net 10 network (I1), and a second connected to the public 343 Internet (I2). A candidate from I1 will be directly reachable when 344 communicating with a peer on the same private net 10 network, while a 345 candidate from I2 will be directly reachable when communicating with 346 a peer on the public Internet. Rather than trying to guess which IP 347 address will work, the initiating sends both the candidates to its 348 peer. 350 Next, the agent uses STUN or TURN to obtain additional candidates. 351 These come in two flavors: translated addresses on the public side of 352 a NAT (SERVER REFLEXIVE CANDIDATES) and addresses on TURN servers 353 (RELAYED CANDIDATES). When TURN servers are utilized, both types of 354 candidates are obtained from the TURN server. If only STUN servers 355 are utilized, only server reflexive candidates are obtained from 356 them. The relationship of these candidates to the host candidate is 357 shown in Figure 2. In this figure, both types of candidates are 358 discovered using TURN. In the figure, the notation X:x means IP 359 address X and UDP port x. 361 To Internet 363 | 364 | 365 | /------------ Relayed 366 Y:y | / Address 367 +--------+ 368 | | 369 | TURN | 370 | Server | 371 | | 372 +--------+ 373 | 374 | 375 | /------------ Server 376 X1':x1'|/ Reflexive 377 +------------+ Address 378 | NAT | 379 +------------+ 380 | 381 | /------------ Local 382 X:x |/ Address 383 +--------+ 384 | | 385 | Agent | 386 | | 387 +--------+ 389 Figure 2: Candidate Relationships 391 When the agent sends the TURN Allocate request from IP address and 392 port X:x, the NAT (assuming there is one) will create a binding 393 X1':x1', mapping this server reflexive candidate to the host 394 candidate X:x. Outgoing packets sent from the host candidate will be 395 translated by the NAT to the server reflexive candidate. Incoming 396 packets sent to the server reflexive candidate will be translated by 397 the NAT to the host candidate and forwarded to the agent. We call 398 the host candidate associated with a given server reflexive candidate 399 the BASE. 401 Note: "Base" refers to the address an agent sends from for a 402 particular candidate. Thus, as a degenerate case host candidates 403 also have a base, but it's the same as the host candidate. 405 When there are multiple NATs between the agent and the TURN server, 406 the TURN request will create a binding on each NAT, but only the 407 outermost server reflexive candidate (the one nearest the TURN 408 server) will be discovered by the agent. If the agent is not behind 409 a NAT, then the base candidate will be the same as the server 410 reflexive candidate and the server reflexive candidate is redundant 411 and will be eliminated. 413 The Allocate request then arrives at the TURN server. The TURN 414 server allocates a port y from its local IP address Y, and generates 415 an Allocate response, informing the agent of this relayed candidate. 416 The TURN server also informs the agent of the server reflexive 417 candidate, X1':x1' by copying the source transport address of the 418 Allocate request into the Allocate response. The TURN server acts as 419 a packet relay, forwarding traffic between L and R. In order to send 420 traffic to L, R sends traffic to the TURN server at Y:y, and the TURN 421 server forwards that to X1':x1', which passes through the NAT where 422 it is mapped to X:x and delivered to L. 424 When only STUN servers are utilized, the agent sends a STUN Binding 425 request [RFC5389] to its STUN server. The STUN server will inform 426 the agent of the server reflexive candidate X1':x1' by copying the 427 source transport address of the Binding request into the Binding 428 response. 430 2.2. Connectivity Checks 432 Once L has gathered all of its candidates, it orders them in highest 433 to lowest-priority and sends them to R over the signaling channel. 434 When R receives the candidates from L, it performs the same gathering 435 process and responds with its own list of candidates. At the end of 436 this process, each agent has a complete list of both its candidates 437 and its peer's candidates. It pairs them up, resulting in CANDIDATE 438 PAIRS. To see which pairs work, each agent schedules a series of 439 CHECKS. Each check is a STUN request/response transaction that the 440 client will perform on a particular candidate pair by sending a STUN 441 request from the local candidate to the remote candidate. 443 The basic principle of the connectivity checks is simple: 445 1. Sort the candidate pairs in priority order. 447 2. Send checks on each candidate pair in priority order. 449 3. Acknowledge checks received from the other agent. 451 With both agents performing a check on a candidate pair, the result 452 is a 4-way handshake: 454 L R 455 - - 456 STUN request -> \ L's 457 <- STUN response / check 459 <- STUN request \ R's 460 STUN response -> / check 462 Figure 3: Basic Connectivity Check 464 It is important to note that the STUN requests are sent to and from 465 the exact same IP addresses and ports that will be used for media 466 (e.g., RTP and RTCP). Consequently, agents demultiplex STUN and RTP/ 467 RTCP using contents of the packets, rather than the port on which 468 they are received. Fortunately, this demultiplexing is easy to do, 469 especially for RTP and RTCP. 471 Because a STUN Binding request is used for the connectivity check, 472 the STUN Binding response will contain the agent's translated 473 transport address on the public side of any NATs between the agent 474 and its peer. If this transport address is different from other 475 candidates the agent already learned, it represents a new candidate, 476 called a PEER REFLEXIVE CANDIDATE, which then gets tested by ICE just 477 the same as any other candidate. 479 As an optimization, as soon as R gets L's check message, R schedules 480 a connectivity check message to be sent to L on the same candidate 481 pair. This accelerates the process of finding a valid candidate, and 482 is called a TRIGGERED CHECK. 484 At the end of this handshake, both L and R know that they can send 485 (and receive) messages end-to-end in both directions. 487 2.3. Sorting Candidates 489 Because the algorithm above searches all candidate pairs, if a 490 working pair exists it will eventually find it no matter what order 491 the candidates are tried in. In order to produce faster (and better) 492 results, the candidates are sorted in a specified order. The 493 resulting list of sorted candidate pairs is called the CHECK LIST. 494 The algorithm is described in Section 4.1.2 but follows two general 495 principles: 497 o Each agent gives its candidates a numeric priority, which is sent 498 along with the candidate to the peer. 500 o The local and remote priorities are combined so that each agent 501 has the same ordering for the candidate pairs. 503 The second property is important for getting ICE to work when there 504 are NATs in front of L and R. Frequently, NATs will not allow 505 packets in from a host until the agent behind the NAT has sent a 506 packet towards that host. Consequently, ICE checks in each direction 507 will not succeed until both sides have sent a check through their 508 respective NATs. 510 The agent works through this check list by sending a STUN request for 511 the next candidate pair on the list periodically. These are called 512 ORDINARY CHECKS. 514 In general, the priority algorithm is designed so that candidates of 515 similar type get similar priorities and so that more direct routes 516 (that is, through fewer media relays and through fewer NATs) are 517 preferred over indirect ones (ones with more media relays and more 518 NATs). Within those guidelines, however, agents have a fair amount 519 of discretion about how to tune their algorithms. 521 2.4. Frozen Candidates 523 The previous description only addresses the case where the agents 524 wish to establish a media session with one COMPONENT (a piece of a 525 media stream requiring a single transport address; a media stream may 526 require multiple components, each of which has to work for the media 527 stream as a whole to be work). Sometimes (e.g., with RTP and RTCP in 528 separate components), the agents actually need to establish 529 connectivity for more than one flow. 531 The network properties are likely to be very similar for each 532 component (especially because RTP and RTCP are sent and received from 533 the same IP address). It is usually possible to leverage information 534 from one media component in order to determine the best candidates 535 for another. ICE does this with a mechanism called "frozen 536 candidates". 538 Each candidate is associated with a property called its FOUNDATION. 539 Two candidates have the same foundation when they are "similar" -- of 540 the same type and obtained from the same host candidate and STUN/TURN 541 server using the same protocol. Otherwise, their foundation is 542 different. A candidate pair has a foundation too, which is just the 543 concatenation of the foundations of its two candidates. Initially, 544 only the candidate pairs with unique foundations are tested. The 545 other candidate pairs are marked "frozen". When the connectivity 546 checks for a candidate pair succeed, the other candidate pairs with 547 the same foundation are unfrozen. This avoids repeated checking of 548 components that are superficially more attractive but in fact are 549 likely to fail. 551 While we've described "frozen" here as a separate mechanism for 552 expository purposes, in fact it is an integral part of ICE and the 553 ICE prioritization algorithm automatically ensures that the right 554 candidates are unfrozen and checked in the right order. However, if 555 the ICE usage does not utilize multiple components or media streams, 556 it does not need to implement this algorithm. 558 2.5. Security for Checks 560 Because ICE is used to discover which addresses can be used to send 561 media between two agents, it is important to ensure that the process 562 cannot be hijacked to send media to the wrong location. Each STUN 563 connectivity check is covered by a message authentication code (MAC) 564 computed using a key exchanged in the signaling channel. This MAC 565 provides message integrity and data origin authentication, thus 566 stopping an attacker from forging or modifying connectivity check 567 messages. Furthermore, if for example a SIP [RFC3261] caller is 568 using ICE, and their call forks, the ICE exchanges happen 569 independently with each forked recipient. In such a case, the keys 570 exchanged in the signaling help associate each ICE exchange with each 571 forked recipient. 573 2.6. Concluding ICE 575 ICE checks are performed in a specific sequence, so that high- 576 priority candidate pairs are checked first, followed by lower- 577 priority ones. One way to conclude ICE is to declare victory as soon 578 as a check for each component of each media stream completes 579 successfully. Indeed, this is a reasonable algorithm, and details 580 for it are provided below. However, it is possible that a packet 581 loss will cause a higher-priority check to take longer to complete. 582 In that case, allowing ICE to run a little longer might produce 583 better results. More fundamentally, however, the prioritization 584 defined by this specification may not yield "optimal" results. As an 585 example, if the aim is to select low-latency media paths, usage of a 586 relay is a hint that latencies may be higher, but it is nothing more 587 than a hint. An actual round-trip time (RTT) measurement could be 588 made, and it might demonstrate that a pair with lower priority is 589 actually better than one with higher priority. 591 Consequently, ICE assigns one of the agents in the role of the 592 CONTROLLING AGENT, and the other of the CONTROLLED AGENT. The 593 controlling agent gets to nominate which candidate pairs will get 594 used for media amongst the ones that are valid. 596 When nominating, the controlling agent lets the checks continue until 597 at least one valid candidate pair for each media stream is found. 598 Then, it picks amongst those that are valid, and sends a second STUN 599 request on its NOMINATED candidate pair, but this time with a flag 600 set to tell the peer that this pair has been nominated for use. This 601 is shown in Figure 4. 603 L R 604 - - 605 STUN request -> \ L's 606 <- STUN response / check 608 <- STUN request \ R's 609 STUN response -> / check 611 STUN request + flag -> \ L's 612 <- STUN response / check 614 Figure 4: Nomination 616 Once the STUN transaction with the flag completes, both sides cancel 617 any future checks for that media stream. ICE will now send media 618 using this pair. The pair an ICE agent is using for media is called 619 the SELECTED PAIR. 621 Once ICE is concluded, it can be restarted at any time for one or all 622 of the media streams by either agent. This is done by sending an 623 updated candidate information indicating a restart. 625 2.7. Lite Implementations 627 In order for ICE to be used in a call, both agents need to support 628 it. However, certain agents will always be connected to the public 629 Internet and have a public IP address at which it can receive packets 630 from any correspondent. To make it easier for these devices to 631 support ICE, ICE defines a special type of implementation called LITE 632 (in contrast to the normal FULL implementation). A lite 633 implementation doesn't gather candidates; it includes only host 634 candidates for any media stream. Lite agents do not generate 635 connectivity checks or run the state machines, though they need to be 636 able to respond to connectivity checks. When a lite implementation 637 connects with a full implementation, the full agent takes the role of 638 the controlling agent, and the lite agent takes on the controlled 639 role. When two lite implementations connect, no checks are sent. 641 For guidance on when a lite implementation is appropriate, see the 642 discussion in Appendix A. 644 It is important to note that the lite implementation was added to 645 this specification to provide a stepping stone to full 646 implementation. Even for devices that are always connected to the 647 public Internet, a full implementation is preferable if achievable. 649 2.8. Usages of ICE 651 This document specifies generic use of ICE with protocols that 652 provide means to exchange candidate information between the ICE 653 Peers. The specific details of (i.e how to encode candidate 654 information and the actual candidate exchange process) for different 655 protocols using ICE are described in separate usage documents. One 656 possible way the agents can exchange the candidate information is to 657 use [RFC3264] based Offer/Answer semantics as part of the SIP 658 [RFC3261] protocol [I-D.ietf-mmusic-ice-sip-sdp]. 660 3. Terminology 662 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 663 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 664 "OPTIONAL" in this document are to be interpreted as described in RFC 665 2119 [RFC2119]. 667 Readers should be familiar with the terminology defined in the STUN 668 [RFC5389], and NAT Behavioral requirements for UDP [RFC4787]. 670 This specification makes use of the following additional terminology: 672 ICE Agent: An agent is the protocol implementation involved in the 673 ICE candidate exchange. There are two agents involved in a 674 typical candidate exchange. 676 Initiating Peer, Initiating Agent, Initiator: An initiating agent is 677 the protocol implementation involved in the ICE candidate exchange 678 that initiates the ICE candidate exchange process. 680 Responding Peer, Responding Agent, Responder: A receiving agent is 681 the protocol implementation involved in the ICE candidate exchange 682 that receives and responds to the candidate exchange process 683 initiated by the Initiator. 685 ICE Candidate Exchange, Candidate Exchange: The process where the 686 ICE agents exchange information (e.g., candidates and passwords) 687 that is needed to perform ICE. [RFC3264] Offer/Answer with SDP 688 encoding is one example of a protocol that can be used for 689 exchanging the candidate information. 691 Peer: From the perspective of one of the agents in a session, its 692 peer is the other agent. Specifically, from the perspective of 693 the initiating agent, the peer is the responding agent. From the 694 perspective of the responding agent, the peer is the initiating 695 agent. 697 Transport Address: The combination of an IP address and transport 698 protocol (such as UDP or TCP) port. 700 Media, Media Stream, Media Session: When ICE is used to setup 701 multimedia sessions, the media is usually transported over RTP, 702 and a media stream composes of a stream of RTP packets. When ICE 703 is used with other than multimedia sessions, the terms "media", 704 "media stream", and "media session" are still used in this 705 specification to refer to the IP data packets that are exchanged 706 between the peers on the path created and tested with ICE. 708 Candidate, Candidate Information: A transport address that is a 709 potential point of contact for receipt of media. Candidates also 710 have properties -- their type (server reflexive, relayed, or 711 host), priority,foundation, and base. 713 Component: A component is a piece of a media stream requiring a 714 single transport address; a media stream may require multiple 715 components, each of which has to work for the media stream as a 716 whole to work. For media streams based on RTP, unless RTP and 717 RTCP are multiplexed in the same port, there are two components 718 per media stream -- one for RTP, and one for RTCP. 720 Host Candidate: A candidate obtained by binding to a specific port 721 from an IP address on the host. This includes IP addresses on 722 physical interfaces and logical ones, such as ones obtained 723 through Virtual Private Networks (VPNs) and Realm Specific IP 724 (RSIP) [RFC3102] (which lives at the operating system level). 726 Server Reflexive Candidate: A candidate whose IP address and port 727 are a binding allocated by a NAT for an agent when it sent a 728 packet through the NAT to a server. Server reflexive candidates 729 can be learned by STUN servers using the Binding request, or TURN 730 servers, which provides both a relayed and server reflexive 731 candidate. 733 Peer Reflexive Candidate: A candidate whose IP address and port are 734 a binding allocated by a NAT for an agent when it sent a STUN 735 Binding request through the NAT to its peer. 737 Relayed Candidate: A candidate obtained by sending a TURN Allocate 738 request from a host candidate to a TURN server. The relayed 739 candidate is resident on the TURN server, and the TURN server 740 relays packets back towards the agent. 742 Base: The transport address that an agent sends from for a 743 particular candidate. For host-, server reflexive- and peer 744 reflexive candidates the base is the same as the host candidate. 745 For relayed candidates the base is the same as the relayed 746 candidate (i.e., the transport address used by the TURN server to 747 send from). 749 Foundation: An arbitrary string that is the same for two candidates 750 that have the same type, base IP address, protocol (UDP, TCP, 751 etc.), and STUN or TURN server. If any of these are different, 752 then the foundation will be different. Two candidate pairs with 753 the same foundation pairs are likely to have similar network 754 characteristics. Foundations are used in the frozen algorithm. 756 Local Candidate: A candidate that an agent has obtained and shared 757 with the peer. 759 Remote Candidate: A candidate that an agent received from its peer. 761 Default Destination/Candidate: The default destination for a 762 component of a media stream is the transport address that would be 763 used by an agent that is not ICE aware. A default candidate for a 764 component is one whose transport address matches the default 765 destination for that component. 767 Candidate Pair: A pairing containing a local candidate and a remote 768 candidate. 770 Check, Connectivity Check, STUN Check: A STUN Binding request 771 transaction for the purposes of verifying connectivity. A check 772 is sent from the local candidate to the remote candidate of a 773 candidate pair. 775 Check List: An ordered set of candidate pairs that an agent will use 776 to generate checks. 778 Ordinary Check: A connectivity check generated by an agent as a 779 consequence of a timer that fires periodically, instructing it to 780 send a check. 782 Triggered Check: A connectivity check generated as a consequence of 783 the receipt of a connectivity check from the peer. 785 Valid List: An ordered set of candidate pairs for a media stream 786 that have been validated by a successful STUN transaction. 788 Full: An ICE implementation that performs the complete set of 789 functionality defined by this specification. 791 Lite: An ICE implementation that omits certain functions, 792 implementing only as much as is necessary for a peer 793 implementation that is full to gain the benefits of ICE. Lite 794 implementations do not maintain any of the state machines and do 795 not generate connectivity checks. 797 Controlling Agent: The ICE agent that is responsible for selecting 798 the final choice of candidate pairs and signaling them through 799 STUN. In any session, one agent is always controlling. The other 800 is the controlled agent. 802 Controlled Agent: An ICE agent that waits for the controlling agent 803 to select the final choice of candidate pairs. 805 Nomination, Regular Nomination: The process of picking a valid 806 candidate pair for media traffic by validating the pair with one 807 STUN request, and then picking it by sending a second STUN request 808 with a flag indicating its nomination. 810 Nominated: If a valid candidate pair has its nominated flag set, it 811 means that it may be selected by ICE for sending and receiving 812 media. 814 Selected Pair, Selected Candidate: The candidate pair selected by 815 ICE for sending and receiving media is called the selected pair, 816 and each of its candidates is called the selected candidate. 817 Before a candidiate pair has been selected, any valid candidiate 818 pair can be used for sending and receiving media (only one 819 candidiate pair at any given time). 821 Using Protocol, ICE Usage: The protocol that uses ICE for NAT 822 traversal. A usage specification defines the protocol specific 823 details on how the procedures defined here are applied to that 824 protocol. 826 4. ICE Candidate Gathering and Exchange 828 As part of ICE processing, both the initiating and responding agents 829 exchange encoded candidate information as defined by the Usage 830 Protocol (ICE Usage). Specifics of encoding mechanism and the 831 semantics of candidate information exchange is out of scope of this 832 specification. 834 However at a higher level, the below diagram captures ICE processing 835 sequence in the agents (initiator and responder) for exchange of 836 their respective candidate(s) information. 838 Initiating Responding 839 Agent Agent 840 (I) (R) 841 Gather, | | 842 prioritize, | | 843 eliminate | | 844 redundant | | 845 candidates, | | 846 Encode | | 847 candidates | | 848 | I's Candidate Information | 849 |------------------------------>| 850 | | Gather, 851 | | prioritize, 852 | | eliminate 853 | | redundant 854 | | candidates, 855 | | Encode 856 | | candidates 857 | R's Candidate Information | 858 |<------------------------------| 859 | | 861 Figure 5: Candidate Gathering and Exchange Sequence 863 As shown, the agents involved in the candidate exchange perform (1) 864 candidate gathering, (2) candidate prioritization, (3) eliminating 865 redundant candidates, (4) (possibly) choose default candidates, and 866 then (5) formulate and send the candidates to the Peer ICE agent. 867 All but the last of these five steps differ for full and lite 868 implementations. 870 4.1. Procedures for Full Implementation 872 4.1.1. Gathering Candidates 874 An agent gathers candidates when it believes that communication is 875 imminent. An initiating agent can do this based on a user interface 876 cue, or based on an explicit request to initiate a session. Every 877 candidate is a transport address. It also has a type and a base. 878 Four types are defined and gathered by this specification -- host 879 candidates, server reflexive candidates, peer reflexive candidates, 880 and relayed candidates. The server reflexive candidates are gathered 881 using STUN or TURN, and relayed candidates are obtained through TURN. 882 Peer reflexive candidates are obtained in later phases of ICE, as a 883 consequence of connectivity checks. 885 The process for gathering candidates at the responding agent is 886 identical to the process for the initiating agent. It is RECOMMENDED 887 that the responding agent begins this process immediately on receipt 888 of the candidate information, prior to alerting the user. Such 889 gathering MAY begin when an agent starts. 891 4.1.1.1. Host Candidates 893 The first step is to gather host candidates. Host candidates are 894 obtained by binding to ports (typically ephemeral) on a IP address 895 attached to an interface (physical or virtual, including VPN 896 interfaces) on the host. 898 For each UDP media stream the agent wishes to use, the agent SHOULD 899 obtain a candidate for each component of the media stream on each IP 900 address that the host has, with the exceptions listed below. The 901 agent obtains each candidate by binding to a UDP port on the specific 902 IP address. A host candidate (and indeed every candidate) is always 903 associated with a specific component for which it is a candidate. 905 Each component has an ID assigned to it, called the component ID. 906 For RTP-based media streams, unless both RTP and RTCP are multiplexed 907 in the same UDP port (RTP/RTCP multiplexing), the RTP itself has a 908 component ID of 1, and RTCP a component ID of 2. In case of RTP/RTCP 909 multiplexing, a component ID of 1 is used for both RTP and RTCP. 911 When candidates are obtained, unless the agent knows for sure that 912 RTP/RTCP multiplexing will be used (i.e. the agent knows that the 913 other agent also supports, and is willing to use, RTP/RTCP 914 multiplexing), or unless the agent only supports RTP/RTCP 915 multiplexing, the agent MUST obtain a separate candidate for RTCP. 916 If an agent has obtained a candidate for RTCP, and ends up using RTP/ 917 RTCP multiplexing, the agent does not need to perform connectivity 918 checks on the RTCP candidate. 920 If an agent is using separate candidates for RTP and RTCP, it will 921 end up with 2*K host candidates if an agent has K IP addresses. 923 Note that the responding agent, when obtaining its candidates, will 924 typically know if the other agent supports RTP/RTCP multiplexing, in 925 which case it will not need to obtain a separate candidate for RTCP. 926 However, absence of a component ID 2 as such does not imply use of 927 RTCP/RTP multiplexing, as it could also mean that RTCP is not used. 929 For other than RTP-based streams, use of multiple components is 930 discouraged since using them increases the complexity of ICE 931 processing. If multiple components are needed, the component IDs 932 SHOULD start with 1 and increase by 1 for each component. 934 The base for each host candidate is set to the candidate itself. 936 The host candidates are gathered from all IP addresses with the 937 following exceptions: 939 o Addresses from a loopback interface MUST NOT be included in the 940 candidate addresses. 942 o Deprecated IPv4-compatible IPv6 addresses [RFC4291] and IPv6 site- 943 local unicast addresses [RFC3879] MUST NOT be included in the 944 address candidates. 946 o IPv4-mapped IPv6 addresses SHOULD NOT be included in the offered 947 candidates unless the application using ICE does not support IPv4 948 (i.e., is an IPv6-only application [RFC4038]). 950 o If one or more host candidates corresponding to an IPv6 address 951 generated using a mechanism that prevents location tracking 952 [RFC7721] are gathered, host candidates corresponding to IPv6 953 addresses that do allow location tracking, that are configured on 954 the same interface, and are part of the same network prefix MUST 955 NOT be gathered; and host candidates corresponding to IPv6 link- 956 local addresses MUST NOT be gathered. 958 4.1.1.2. Server Reflexive and Relayed Candidates 960 Agents SHOULD obtain relayed candidates and SHOULD obtain server 961 reflexive candidates. These requirements are at SHOULD strength to 962 allow for provider variation. Use of STUN and TURN servers may be 963 unnecessary in closed networks where agents are never connected to 964 the public Internet or to endpoints outside of the closed network. 965 In such cases, a full implementation would be used for agents that 966 are dual-stack or multihomed, to select a host candidate. Use of 967 TURN servers is expensive, and when ICE is being used, they will only 968 be utilized when both endpoints are behind NATs that perform address 969 and port dependent mapping. Consequently, some deployments might 970 consider this use case to be marginal, and elect not to use TURN 971 servers. If an agent does not gather server reflexive or relayed 972 candidates, it is RECOMMENDED that the functionality be implemented 973 and just disabled through configuration, so that it can be re-enabled 974 through configuration if conditions change in the future. 976 If an agent is gathering both relayed and server reflexive 977 candidates, it uses a TURN server. If it is gathering just server 978 reflexive candidates, it uses a STUN server. 980 The agent next pairs each host candidate with the STUN or TURN server 981 with which it is configured or has discovered by some means. If a 982 STUN or TURN server is configured, it is RECOMMENDED that a domain 983 name be configured, and the DNS procedures in [RFC5389] (using SRV 984 records with the "stun" service) be used to discover the STUN server, 985 and the DNS procedures in [RFC5766] (using SRV records with the 986 "turn" service) be used to discover the TURN server. 988 This specification only considers usage of a single STUN or TURN 989 server. When there are multiple choices for that single STUN or TURN 990 server (when, for example, they are learned through DNS records and 991 multiple results are returned), an agent SHOULD use a single STUN or 992 TURN server (based on its IP address) for all candidates for a 993 particular session. This improves the performance of ICE. The 994 result is a set of pairs of host candidates with STUN or TURN 995 servers. The agent then chooses one pair, and sends a Binding or 996 Allocate request to the server from that host candidate. Binding 997 requests to a STUN server are not authenticated, and any ALTERNATE- 998 SERVER attribute in a response is ignored. Agents MUST support the 999 backwards compatibility mode for the Binding request defined in 1000 [RFC5389]. Allocate requests SHOULD be authenticated using a long- 1001 term credential obtained by the client through some other means. 1003 Every Ta milliseconds thereafter, the agent can generate another new 1004 STUN or TURN transaction. This transaction can either be a retry of 1005 a previous transaction that failed with a recoverable error (such as 1006 authentication failure), or a transaction for a new host candidate 1007 and STUN or TURN server pair. The agent SHOULD NOT generate 1008 transactions more frequently than one every Ta milliseconds. See 1009 Section 11 for guidance on how to set Ta and the STUN retransmit 1010 timer, RTO. 1012 The agent will receive a Binding or Allocate response. A successful 1013 Allocate response will provide the agent with a server reflexive 1014 candidate (obtained from the mapped address) and a relayed candidate 1015 in the XOR-RELAYED-ADDRESS attribute. If the Allocate request is 1016 rejected because the server lacks resources to fulfill it, the agent 1017 SHOULD instead send a Binding request to obtain a server reflexive 1018 candidate. A Binding response will provide the agent with only a 1019 server reflexive candidate (also obtained from the mapped address). 1020 The base of the server reflexive candidate is the host candidate from 1021 which the Allocate or Binding request was sent. The base of a 1022 relayed candidate is that candidate itself. If a relayed candidate 1023 is identical to a host candidate (which can happen in rare cases), 1024 the relayed candidate MUST be discarded. 1026 If an IPv6-only agent is in a network that utilizes NAT64 [RFC6146] 1027 and DNS64 [RFC6147] technologies, it may gather also IPv4 server 1028 reflexive and/or relayed candidates from IPv4-only STUN or TURN 1029 servers. IPv6-only agents SHOULD also utilize IPv6 prefix discovery 1030 [RFC7050] to discover the IPv6 prefix used by NAT64 (if any) and 1031 generate server reflexive candidates for each IPv6-only interface 1032 accordingly. The NAT64 server reflexive candidates are prioritized 1033 like IPv4 server reflexive candidates. 1035 4.1.1.3. Computing Foundations 1037 Finally, the agent assigns each candidate a foundation. The 1038 foundation is an identifier, scoped within a session. Two candidates 1039 MUST have the same foundation ID when all of the following are true: 1041 o they are of the same type (host, relayed, server reflexive, or 1042 peer reflexive) 1044 o their bases have the same IP address (the ports can be different) 1046 o for reflexive and relayed candidates, the STUN or TURN servers 1047 used to obtain them have the same IP address 1049 o they were obtained using the same transport protocol (TCP, UDP, 1050 etc.) 1052 Similarly, two candidates MUST have different foundations if their 1053 types are different, their bases have different IP addresses, the 1054 STUN or TURN servers used to obtain them have different IP addresses, 1055 or their transport protocols are different. 1057 4.1.1.4. Keeping Candidates Alive 1059 Once server reflexive and relayed candidates are allocated, they MUST 1060 be kept alive until ICE processing has completed, as described in 1061 Section 6.2.3. For server reflexive candidates learned through a 1062 Binding request, the bindings MUST be kept alive by additional 1063 Binding requests to the server. Refreshes for allocations are done 1064 using the Refresh transaction, as described in [RFC5766]. The 1065 Refresh requests will also refresh the server reflexive candidate. 1067 4.1.2. Prioritizing Candidates 1069 The prioritization process results in the assignment of a priority to 1070 each candidate. Each candidate for a media stream MUST have a unique 1071 priority that MUST be a positive integer between 1 and (2**31 - 1). 1072 This priority will be used by ICE to determine the order of the 1073 connectivity checks and the relative preference for candidates. 1075 An agent SHOULD compute this priority using the formula in 1076 Section 4.1.2.1 and choose its parameters using the guidelines in 1077 Section 4.1.2.2. If an agent elects to use a different formula, ICE 1078 will take longer to converge since both agents will not be 1079 coordinated in their checks. 1081 The process for prioritizing candidates is common across the 1082 initiating and the responding agent. 1084 4.1.2.1. Recommended Formula 1086 When using the formula, an agent computes the priority by determining 1087 a preference for each type of candidate (server reflexive, peer 1088 reflexive, relayed, and host), and, when the agent is multihomed, 1089 choosing a preference for its IP addresses. These two preferences 1090 are then combined to compute the priority for a candidate. That 1091 priority is computed using the following formula: 1093 priority = (2^24)*(type preference) + 1094 (2^8)*(local preference) + 1095 (2^0)*(256 - component ID) 1097 The type preference MUST be an integer from 0 to 126 inclusive, and 1098 represents the preference for the type of the candidate (where the 1099 types are local, server reflexive, peer reflexive, and relayed). A 1100 126 is the highest preference, and a 0 is the lowest. Setting the 1101 value to a 0 means that candidates of this type will only be used as 1102 a last resort. The type preference MUST be identical for all 1103 candidates of the same type and MUST be different for candidates of 1104 different types. The type preference for peer reflexive candidates 1105 MUST be higher than that of server reflexive candidates. Note that 1106 candidates gathered based on the procedures of Section 4.1.1 will 1107 never be peer reflexive candidates; candidates of these type are 1108 learned from the connectivity checks performed by ICE. 1110 The local preference MUST be an integer from 0 to 65535 inclusive. 1111 It represents a preference for the particular IP address from which 1112 the candidate was obtained. 65535 represents the highest preference, 1113 and a zero, the lowest. When there is only a single IP address, this 1114 value SHOULD be set to 65535. More generally, if there are multiple 1115 candidates for a particular component for a particular media stream 1116 that have the same type, the local preference MUST be unique for each 1117 one. In this specification, this only happens for multihomed hosts 1118 or if an agent is using multiple TURN servers. If a host is 1119 multihomed because it is dual-stack, the local preference should be 1120 set according to the current best practice described in 1121 [I-D.ietf-ice-dualstack-fairness]. 1123 The component ID is the component ID for the candidate, and MUST be 1124 between 1 and 256 inclusive. 1126 4.1.2.2. Guidelines for Choosing Type and Local Preferences 1128 One criterion for selection of the type and local preference values 1129 is the use of a media intermediary, such as a TURN server, a tunnel 1130 service such as VPN server, or NAT. With a media intermediary, if 1131 media is sent to that candidate, it will first transit the media 1132 intermediary before being received. Relayed candidates are one type 1133 of candidate that involves a media intermediary. Another are host 1134 candidates obtained from a VPN interface. When media is transited 1135 through a media intermediary, it can have a positive or negative 1136 effect on the latency between transmission and reception. It may or 1137 may not increase the packet losses, because of the additional router 1138 hops that may be taken. It may increase the cost of providing 1139 service, since media will be routed in and right back out of a media 1140 intermediary run by a provider. If these concerns are important, the 1141 type preference for relayed candidates must be carefully chosen. The 1142 RECOMMENDED values are 126 for host candidates, 100 for server 1143 reflexive candidates, 110 for peer reflexive candidates, and 0 for 1144 relayed candidates. 1146 Furthermore, if an agent is multihomed and has multiple IP addresses, 1147 the recommendation in [I-D.ietf-ice-dualstack-fairness] should be 1148 followed. If multiple TURN servers are used, local priorities for 1149 the candidates obtained from the TURN servers are chosen in a similar 1150 fashion as for multihomed local candidates: the local preference 1151 value is used to indicate a preference among different servers but 1152 the preference MUST be unique for each one. 1154 Another criterion for selection of preferences is IP address family. 1155 ICE works with both IPv4 and IPv6. It provides a transition 1156 mechanism that allows dual-stack hosts to prefer connectivity over 1157 IPv6, but to fall back to IPv4 in case the v6 networks are 1158 disconnected. Implementation should follow the guidelines from 1159 [I-D.ietf-ice-dualstack-fairness] to avoid excessively delays in the 1160 connectivity check phase if broken paths exist. 1162 Another criterion for selecting preferences is topological awareness. 1163 This is most useful for candidates that make use of intermediaries. 1164 In those cases, if an agent has preconfigured or dynamically 1165 discovered knowledge of the topological proximity of the 1166 intermediaries to itself, it can use that to assign higher local 1167 preferences to candidates obtained from closer intermediaries. 1169 Another criterion for selecting preferences might be security or 1170 privacy. If a user is a telecommuter, and therefore connected to a 1171 corporate network and a local home network, the user may prefer their 1172 voice traffic to be routed over the VPN or similar tunnel in order to 1173 keep it on the corporate network when communicating within the 1174 enterprise, but use the local network when communicating with users 1175 outside of the enterprise. In such a case, a VPN address would have 1176 a higher local preference than any other address. 1178 4.1.3. Eliminating Redundant Candidates 1180 Next, the agent eliminates redundant candidates. A candidate is 1181 redundant if its transport address equals another candidate, and its 1182 base equals the base of that other candidate. Note that two 1183 candidates can have the same transport address yet have different 1184 bases, and these would not be considered redundant. Frequently, a 1185 server reflexive candidate and a host candidate will be redundant 1186 when the agent is not behind a NAT. The agent SHOULD eliminate the 1187 redundant candidate with the lower priority. 1189 This process is common across the initiating and responding agents. 1191 4.2. Lite Implementation Procedures 1193 Lite implementations only utilize host candidates. A lite 1194 implementation MUST, for each component of each media stream, 1195 allocate zero or one IPv4 candidates. It MAY allocate zero or more 1196 IPv6 candidates, but no more than one per each IPv6 address utilized 1197 by the host. Since there can be no more than one IPv4 candidate per 1198 component of each media stream, if an agent has multiple IPv4 1199 addresses, it MUST choose one for allocating the candidate. If a 1200 host is dual-stack, it is RECOMMENDED that it allocate one IPv4 1201 candidate and one global IPv6 address. With the lite implementation, 1202 ICE cannot be used to dynamically choose amongst candidates. 1203 Therefore, including more than one candidate from a particular scope 1204 is NOT RECOMMENDED, since only a connectivity check can truly 1205 determine whether to use one address or the other. 1207 Each component has an ID assigned to it, called the component ID. 1208 For RTP-based media streams, unless RTCP is multiplexed in the same 1209 port with RTP, the RTP itself has a component ID of 1, and RTCP a 1210 component ID of 2. If an agent is using RTCP without multiplexing, 1211 it MUST obtain candidates for it. However, absence of a component ID 1212 2 as such does not imply use of RTCP/RTP multiplexing, as it could 1213 also mean that RTCP is not used. 1215 Each candidate is assigned a foundation. The foundation MUST be 1216 different for two candidates allocated from different IP addresses, 1217 and MUST be the same otherwise. A simple integer that increments for 1218 each IP address will suffice. In addition, each candidate MUST be 1219 assigned a unique priority amongst all candidates for the same media 1220 stream. This priority SHOULD be equal to: 1222 priority = (2^24)*(126) + 1223 (2^8)*(IP precedence) + 1224 (2^0)*(256 - component ID) 1226 If a host is v4-only, it SHOULD set the IP precedence to 65535. If a 1227 host is v6 or dual-stack, the IP precedence SHOULD be the precedence 1228 value for IP addresses described in RFC 6724 [RFC6724]. 1230 Next, an agent chooses a default candidate for each component of each 1231 media stream. If a host is IPv4-only, there would only be one 1232 candidate for each component of each media stream, and therefore that 1233 candidate is the default. If a host is IPv6 or dual-stack, the 1234 selection of default is a matter of local policy. This default 1235 SHOULD be chosen such that it is the candidate most likely to be used 1236 with a peer. For IPv6-only hosts, this would typically be a globally 1237 scoped IPv6 address. For dual-stack hosts, the IPv4 address is 1238 RECOMMENDED. 1240 The procedures in this section is common across the initiating and 1241 responding agents. 1243 4.3. Encoding the Candidate Information 1245 Regardless of the agent being an Initiator or Responder Agent, the 1246 following parameters and their data types needs to be conveyed as 1247 part of the candidate exchange process. The specifics of syntax for 1248 encoding the candidate information is out of scope of this 1249 specification. 1251 Candidate attribute There will be one or more of these for each 1252 "media stream". Each candidate is composed of: 1254 Connection Address: The IP address and transport protocol port of 1255 the candidate. 1257 Transport: An indicator of the transport protocol for this 1258 candidate. This need not be present if the using protocol will 1259 only ever run over a single transport protocol. If it runs 1260 over more than one, or if others are anticipated to be used in 1261 the future, this should be present. 1263 Foundation: A sequence of up to 32 characters. 1265 Component-ID: This would be present only if the using protocol 1266 were utilizing the concept of components. If it is, it would 1267 be a positive integer that indicates the component ID for which 1268 this is a candidate. 1270 Priority: An encoding of the 32-bit priority value. 1272 Candidate Type: The candidate type, as defined in ICE. 1274 Related Address and Port: The related IP address and port for 1275 this candidate, as defined by ICE. These MAY be omitted or set 1276 to invalid values if the agent does not want to reveal them, 1277 e.g., for privacy reasons. 1279 Extensibility Parameters: The using protocol should define some 1280 means for adding new per-candidate ICE parameters in the 1281 future. 1283 Lite Flag: If ICE lite is used by the using protocol, it needs to 1284 convey a boolean parameter which indicates whether the 1285 implementation is lite or not. 1287 Connectivity check pacing value: If an agent wants to use other than 1288 the default pacing values for the connectivity checks, it MUST 1289 indicate this in the ICE exchange. 1291 Username Fragment and Password: The using protocol has to convey a 1292 username fragment and password. The username fragment MUST 1293 contain at least 24 bits of randomness, and the password MUST 1294 contain at least 128 bits of randomness. 1296 ICE extensions: In addition to the per-candidate extensions above, 1297 the using protocol should allow for new media-stream or session- 1298 level attributes (ice-options). 1300 If the using protocol is using the ICE mismatch feature, a way is 1301 needed to convey this parameter in answers. It is a boolean flag. 1303 The exchange of parameters is symmetric; both agents need to send the 1304 same set of attributes as defined above. 1306 The using protocol may (or may not) need to deal with backwards 1307 compatibility with older implementations that do not support ICE. If 1308 the fallback mechanism is being used, then presumably the using 1309 protocol provides a way of conveying the default candidate (its IP 1310 address and port) in addition to the ICE parameters. 1312 STUN connectivity checks between agents are authenticated using the 1313 short-term credential mechanism defined for STUN [RFC5389]. This 1314 mechanism relies on a username and password that are exchanged 1315 through protocol machinery between the client and server. The 1316 username part of this credential is formed by concatenating a 1317 username fragment from each agent, separated by a colon. Each agent 1318 also provides a password, used to compute the message integrity for 1319 requests it receives. The username fragment and password are 1320 exchanged between the peers. In addition to providing security, the 1321 username provides disambiguation and correlation of checks to media 1322 streams. See Appendix B.4 for motivation. 1324 If the initiating agent is a lite implementation, it MUST indicate 1325 this when sending its candidates . 1327 ICE provides for extensibility by allowing an agent to include a 1328 series of tokens that identify ICE extensions as part of the 1329 candidate exchange process. 1331 Once an agent has sent its candidate information, that agent MUST be 1332 prepared to receive both STUN and media packets on each candidate. 1333 As discussed in Section 9.1, media packets can be sent to a candidate 1334 prior to its appearance as the default destination for media. 1336 5. ICE Candidate Processing 1338 Once an agent has candidates from it's peer, it will check if the 1339 peer supports ICE, determine its own role, exchanges candidates 1340 (Section 4) and for full implementations, forms the check lists and 1341 begins connectivity checks as explained in this section. 1343 5.1. Procedures for Full Implementation 1345 5.1.1. Verifying ICE Support 1347 Certain middleboxes, such as ALGs, may alter the ICE candidate 1348 information that breaks ICE. If the using protocol is vulnerable to 1349 this kind of changes, called ICE mismatch, the responding agent needs 1350 to detect this and signal this back to the initiating agent. The 1351 details on whether this is needed and how it is done is defined by 1352 the usage specifications. One exception to the above is that an 1353 initiating agent would never indicate ICE mismatch. 1355 5.1.2. Determining Role 1357 For each session, each agent (Initiating and Responding) takes on a 1358 role. There are two roles -- controlling and controlled. The 1359 controlling agent is responsible for the choice of the final 1360 candidate pairs used for communications. For a full agent, this 1361 means nominating the candidate pairs that can be used by ICE for each 1362 media stream, and for updating the peer with the ICE's selection, 1363 when needed. The controlled agent is told which candidate pairs to 1364 use for each media stream, and does not require updating the peer to 1365 signal this information. The sections below describe in detail the 1366 actual procedures followed by controlling and controlled nodes. 1368 The rules for determining the role and the impact on behavior are as 1369 follows: 1371 Both agents are full: The Initiating Agent which started the ICE 1372 processing MUST take the controlling role, and the other MUST take 1373 the controlled role. Both agents will form check lists, run the 1374 ICE state machines, and generate connectivity checks. The 1375 controlling agent will execute the logic in Section 6.2.1 to 1376 nominate pairs that will be selected by ICE, and then both agents 1377 end ICE as described in Section 6.2.1.2. 1379 One agent full, one lite: The full agent MUST take the controlling 1380 role, and the lite agent MUST take the controlled role. The full 1381 agent will form check lists, run the ICE state machines, and 1382 generate connectivity checks. That agent will execute the logic 1383 in Section 6.2.1 to nominate pairs that will be selected by ICE, 1384 and use the logic in Section 6.2.1.2 to end ICE. The lite 1385 implementation will just listen for connectivity checks, receive 1386 them and respond to them, and then conclude ICE as described in 1387 Section 6.2.2. For the lite implementation, the state of ICE 1388 processing for each media stream is considered to be Running, and 1389 the state of ICE overall is Running. 1391 Both lite: The Initiating Agent which started the ICE processing 1392 MUST take the controlling role, and the other MUST take the 1393 controlled role. In this case, no connectivity checks are ever 1394 sent. Rather, once the candidates are exchanged, each agent 1395 performs the processing described in Section 6.2 without 1396 connectivity checks. It is possible that both agents will believe 1397 they are controlled or controlling. In the latter case, the 1398 conflict is resolved through glare detection capabilities in the 1399 signaling protocol enabling the candidate exchange. The state of 1400 ICE processing for each media stream is considered to be Running, 1401 and the state of ICE overall is Running. 1403 Once the roles are determined for a session, they persist througout 1404 the lifetime of the session. The roles can be re-determined as part 1405 of an ICE restart (Section 6.3), but an ICE agent MUST NOT re- 1406 determine the role as part of an ICE restart unless one or more of 1407 the following criteria is fulfilled: 1409 Full becomes lite: If the controlling agent is full, and switches to 1410 lite, the roles MUST be re-determined if the peer agent is also 1411 full. 1413 Role conflict: If the ICE restart causes a role conflict, the roles 1414 might be re-determined due to the role conflict procedures in 1415 Section 6.1.3.1.1. 1417 NOTE: There are certain 3PCC scenarios where an ICE restart might 1418 cause a role conflict. 1420 NOTE: The ICE agents needs to inform each other whether they are full 1421 or lite before the roles are determined. The mechanism for that is 1422 signalling protocol specific, and outside the scope of the document. 1424 An ICE agent MUST be prepared that the peer might re-determine the 1425 roles as part of any ICE restart, even if the criteria for doing so 1426 are not fulfilled. This can happen if the peer is compliant with an 1427 older version of this specification. 1429 5.1.3. Forming the Check Lists 1431 There is one check list per in-use media stream resulting from the 1432 candidate exchange. To form the check list for a media stream, the 1433 agent forms candidate pairs, computes a candidate pair priority, 1434 orders the pairs by priority, prunes them, removes lower-priority 1435 candidates and sets their states. These steps are described in this 1436 section. If a check list is updated (e.g, due to detection of peer 1437 reflexive candidates), the agent will re-perform the steps for the 1438 updated check list. 1440 5.1.3.1. Check List State 1442 Each check list has a state, which captures the state of ICE checks 1443 for the media stream associated with the check list. The states are: 1445 Running: In this state, ICE checks are still in progress for this 1446 media stream. Check lists are initially set to the Running state. 1448 Completed: In this state, ICE checks have produced selected pairs 1449 for each component of the media stream. 1451 Failed: In this state, the ICE checks have not completed 1452 successfully for this media stream. 1454 A check list with at least one pair that is Waiting is called an 1455 active check list, and a check list with all pairs Frozen is called a 1456 frozen check list. 1458 5.1.3.2. Forming Candidate Pairs 1460 First, the agent takes each of its candidates for a media stream 1461 (called LOCAL CANDIDATES) and pairs them with the candidates it 1462 received from its peer (called REMOTE CANDIDATES) for that media 1463 stream. A local candidate is paired with a remote candidate if and 1464 only if the two candidates have the same component ID and have the 1465 same IP address version. It is possible that some of the local 1466 candidates won't get paired with remote candidates, and some of the 1467 remote candidates won't get paired with local candidates. This can 1468 happen if one agent doesn't include candidates for the all of the 1469 components for a media stream. If this happens, the number of 1470 components for that media stream is effectively reduced, and 1471 considered to be equal to the minimum across both agents of the 1472 maximum component ID provided by each agent across all components for 1473 the media stream. 1475 In the case of RTP, this would happen when one agent provides 1476 candidates for RTCP, and the other does not. As another example, the 1477 initiating agent can multiplex RTP and RTCP on the same port 1478 [RFC5761]. However, since the initiating agent doesn't know if the 1479 peer agent can perform such multiplexing, it includes candidates for 1480 RTP and RTCP on separate ports. If the peer agent can perform such 1481 multiplexing, it would include just a single component for each 1482 candidate -- for the combined RTP/RTCP mux. ICE would end up acting 1483 as if there was just a single component for this candidate. 1485 With IPv6 it is common for a host to have multiple host candidates 1486 for each interface. To keep the amount of resulting candidate pairs 1487 reasonable and to avoid candidate pairs that are highly unlikely to 1488 work, IPv6 link-local addresses [RFC4291] MUST NOT be paired with 1489 other than link-local addresses. 1491 The candidate pairs whose local and remote candidates are both the 1492 default candidates for a particular component is called the default 1493 candidate pair for that component. This is the pair that would be 1494 used to transmit media if both agents had not been ICE aware. 1496 In order to aid understanding, Figure 6 shows the relationships 1497 between several key concepts -- transport addresses, candidates, 1498 candidate pairs, and check lists, in addition to indicating the main 1499 properties of candidates and candidate pairs. 1501 +--------------------------------------------+ 1502 | | 1503 | +---------------------+ | 1504 | |+----+ +----+ +----+ | +Type | 1505 | || IP | |Port| |Tran| | +Priority | 1506 | ||Addr| | | | | | +Foundation | 1507 | |+----+ +----+ +----+ | +Component ID | 1508 | | Transport | +Related Address | 1509 | | Addr | | 1510 | +---------------------+ +Base | 1511 | Candidate | 1512 +--------------------------------------------+ 1513 * * 1514 * ************************************* 1515 * * 1516 +-------------------------------+ 1517 .| | 1518 | Local Remote | 1519 | +----+ +----+ +default? | 1520 | |Cand| |Cand| +valid? | 1521 | +----+ +----+ +nominated?| 1522 | +State | 1523 | | 1524 | | 1525 | Candidate Pair | 1526 +-------------------------------+ 1527 * * 1528 * ************ 1529 * * 1530 +------------------+ 1531 | Candidate Pair | 1532 +------------------+ 1533 +------------------+ 1534 | Candidate Pair | 1535 +------------------+ 1536 +------------------+ 1537 | Candidate Pair | 1538 +------------------+ 1540 Check 1541 List 1543 Figure 6: Conceptual Diagram of a Check List 1545 5.1.3.3. Computing Pair Priority and Ordering Pairs 1547 Once the pairs are formed, a candidate pair priority is computed. 1548 Let G be the priority for the candidate provided by the controlling 1549 agent. Let D be the priority for the candidate provided by the 1550 controlled agent. The priority for a pair is computed as: 1552 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 1554 Where G>D?1:0 is an expression whose value is 1 if G is greater than 1555 D, and 0 otherwise. Once the priority is assigned, the agent sorts 1556 the candidate pairs in decreasing order of priority. If two pairs 1557 have identical priority, the ordering amongst them is arbitrary. 1559 5.1.3.4. Pruning the Pairs 1561 This sorted list of candidate pairs is used to determine a sequence 1562 of connectivity checks that will be performed. Each check involves 1563 sending a request from a local candidate to a remote candidate. 1564 Since an agent cannot send requests directly from a reflexive 1565 candidate (server reflexive or peer reflexive), but only from its 1566 base, the agent next goes through the sorted list of candidate pairs. 1567 For each pair where the local candidate is reflexive, the candidate 1568 MUST be replaced by its base. Once this has been done, the agent 1569 MUST prune the list. This is done by removing a pair if its local 1570 and remote candidates are identical to the local and remote 1571 candidates of a pair higher up on the priority list. The result is a 1572 sequence of ordered candidate pairs, called the check list for that 1573 media stream. 1575 5.1.3.5. Removing lower-priority Pairs 1577 In order to limit the attacks described in Section 13.4.1, an agent 1578 MUST limit the total number of connectivity checks the agent performs 1579 across all check lists to a specific value, and this value MUST be 1580 configurable. A default of 100 is RECOMMENDED. This limit is 1581 enforced by discarding the lower-priority candidate pairs until there 1582 are less than 100. It is RECOMMENDED that a lower value be utilized 1583 when possible, set to the maximum number of plausible checks that 1584 might be seen in an actual deployment configuration. The requirement 1585 for configuration is meant to provide a tool for fixing this value in 1586 the field if, once deployed, it is found to be problematic. 1588 5.1.3.6. Computing Candidate Pair States 1590 Each candidate pair in the check list has a foundation and a state. 1591 The foundation is the combination of the foundations of the local and 1592 remote candidates in the pair. The state is assigned once the check 1593 list for each media stream has been computed. There are five 1594 potential values that the state can have: 1596 Waiting: A check has not been sent for this pair, but can be sent as 1597 soon as the pair is chosen based on the criteria for selecting for 1598 which candidate pair a check is to be sent. 1600 In-Progress: A check has been sent for this pair, but the 1601 transaction is in progress. 1603 Succeeded: A check has been sent for this pair, and produced a 1604 successful result. 1606 Failed: A check has been sent for this pair, and failed (a response 1607 to the check was never received, or a failure response was 1608 received). 1610 Frozen: A check for this pair has not been sent, and it can not be 1611 sent until the pair is unfrozen and moved into the Waiting state. 1613 As ICE runs, the pairs will move between states as shown in Figure 7. 1615 +-----------+ 1616 | | 1617 | | 1618 | Frozen | 1619 | | 1620 | | 1621 +-----------+ 1622 | 1623 |unfreeze 1624 | 1625 V 1626 +-----------+ +-----------+ 1627 | | | | 1628 | | perform | | 1629 | Waiting |-------->|In-Progress| 1630 | | | | 1631 | | | | 1632 +-----------+ +-----------+ 1633 / | 1634 // | 1635 // | 1636 // | 1637 / | 1638 // | 1639 failure // |success 1640 // | 1641 / | 1642 // | 1643 // | 1644 // | 1645 V V 1646 +-----------+ +-----------+ 1647 | | | | 1648 | | | | 1649 | Failed | | Succeeded | 1650 | | | | 1651 | | | | 1652 +-----------+ +-----------+ 1654 Figure 7: Pair State FSM 1656 The initial states for each pair in a check list are computed by 1657 performing the following sequence of steps: 1659 1. The check lists are placed in an ordered list (the order is 1660 determined by each ICE usage). 1662 2. The agent sets all of the pairs in each check list to the Frozen 1663 state. 1665 3. The agent sets all of the check lists to the Running state. 1667 4. The agent examines each check list, starting from the first check 1668 lists in the ordered list, in the following way: 1670 * For each foundation, the candidate pair with the lowest 1671 component ID (in case of multiple such pairs, the pair with 1672 the highest priority) is placed in the Waiting state, unless a 1673 candidate pair associated with the same foundation has already 1674 been put in the Waiting state in one of the other examined 1675 check lists. This will ensure that, within the ordered list, 1676 only one pair with a given foundation is initially placed in 1677 the Waiting state, while other pairs with the same foundation 1678 remain in the Frozen state. 1680 * When one or more candidate pairs within a given check list are 1681 placed in the Waiting state. A check list with at least one 1682 pair that is Waiting is called an active check list, and a 1683 check list with all pairs Frozen is called a frozen check 1684 list. 1686 NOTE: The procedures above are different from RFC5245, where only 1687 candidate pairs in the first check list of the ordered list were 1688 initially placed in the Waiting state. 1690 The table in Figure 8 illustrates how the initial states of the 1691 candidiate pairs in the ordered list of check lists are set. 1693 Table legend: 1695 Each row (m1, m2,...) represents a check list associated with a media 1696 stream. m1 represents the first check list in the ordered list of check 1697 lists. 1699 Each column (f1, f2,...) represents a foundation. Every candidiate pair 1700 within a given column share the same foundation. 1702 f-cp represents a candidate pair in the Frozen state. 1704 w-cp represents a candidate pair in the Waiting state. 1706 1. The agent sets all of the pairs in each check list to the Frozen 1707 state. 1709 f1 f2 f3 f4 f5 1710 ----------------------------- 1711 m1 | f-cp f-cp f-cp 1712 | 1713 m2 | f-cp f-cp f-cp f-cp 1714 | 1715 m3 | f-cp f-cp 1717 2. For each foundation, the candidate pair with the lowest component ID 1718 is placed in the Waiting state, unless a candidate pair associated with 1719 the same foundation has already been put in the Waiting state in one of 1720 the other examined check lists. 1722 f1 f2 f3 f4 f5 1723 ----------------------------- 1724 m1 | w-cp w-cp w-cp 1725 | 1726 m2 | f-cp f-cp f-cp w-cp 1727 | 1728 m3 | f-cp w-cp 1730 In the first check list (m1) the candidate pair for each foundation is 1731 placed in the Waiting state, as no pairs for the same foundations have 1732 yet been placed in the Waiting state. 1734 In the second check list (m2) the candidate pair for foundation f4 is 1735 placed in the Waiting state. The candidate pair for foundations f1, f2 1736 and f3 are kept in the Frozen state, as candidate pairs for those 1737 foundations have already been placed in the Waiting state (within check 1738 list m1). 1740 In the third check list (m3) the candidate pair for foundation f5 is 1741 placed in the Waiting state. The candidate pair for foundation f1 is 1742 kept in the Frozen state, as a candidate pair for that foundation have 1743 already been placed in the Waiting state (within check list m1). 1745 Once each check list have been processed, one candidate pair for each 1746 foundation has been placed in the Waiting state. 1748 Figure 8: Initial Pair State 1750 5.1.4. ICE State 1752 ICE processing across all check lists has a state associated with it. 1753 This state is set to Running while ICE processing is under way. The 1754 state is set to Completed when ICE processing is complete and set to 1755 Failed if it failed without success. 1757 5.1.5. Scheduling Checks 1759 5.1.5.1. Triggered Check Queue 1761 Once the agent has computed the check lists as described in 1762 Section 5.1.3, the agent will begin performing ordinary checks and 1763 triggered checks. For triggered checks, the agent maintains a FIFO 1764 queue, triggered check queue, which contains candidate pairs for 1765 which checks are to be sent at the next available opportunity. 1767 5.1.5.2. Timer Tc 1769 The generation of ordinary and triggered checks is govererned by a 1770 timer, Tc. Each active check list is associated with an instance of 1771 Tc, and whenever Tc for a given check list fires a check is performed 1772 for a candidate pair within that check list. 1774 The value of Tc is Ta*N seconds, where N is the number of active 1775 check lists. Whenver the number of active check lists change, the 1776 agent SHOULD re-calculate the Tc value. Multiplying by N allows this 1777 aggregate check throughput to be split between all active check 1778 lists. Tc associated with the first check list fires immediately, 1779 causing the agent to start performing connectivity checks as soon as 1780 the intitial states of the candidate pairs in each check list have 1781 been calculated. 1783 Implementations SHOULD spread out the starting of the Tc timers 1784 associated with each check list, so that Tc for each check list do 1785 not fire at the same time. 1787 Based on local policy, an agent MAY set the Tc value to a number 1788 bigger than described above, in order for Tc to fire less frequently. 1790 5.1.5.3. Performing Connectivity Checks 1792 When Tc for a given check list fires, the agent will perform a check 1793 for a candidate pair within that check list as follows: 1795 o If the triggered check queue contains one or more candidate pairs, 1796 the agent removes the top pair from the queue, performs a 1797 connectivity check on that pair and puts the candidate pair state 1798 to In-Progress; or 1800 o If the triggered check queue is empty, and if there are one or 1801 more candidate pairs in the Waiting state, the agent selects the 1802 highest- priority candidate pair in the Waiting state, performs a 1803 connectivity check on that pair and puts the candidate pair par 1804 state to In-Progress; or 1806 o If there is no candidate pair in the Waiting state, in any of the 1807 check lists, and if there are one or more candidate pairs in the 1808 Frozen state, the agent selects the highest-priority candidate 1809 pair in the Frozen state, performs a connectivity check on that 1810 pair and puts the candidate pair par state to In-Progress; or 1812 o If there is no candidate in the Waiting or Frozen state, the agent 1813 MUST terminate timer Tc for that check list and re-calculate Tc 1814 for the remaining active check lists. 1816 Once a candidate pair has been selected, the agent performs the check 1817 by sending a STUN request from the base associated with the local 1818 candiditate of the pair to the remote candidiate of the pair, as 1819 described in Section 6.1.2. 1821 Based on local policy, an agent MAY choose to terminate perfoming the 1822 connectivity checks for one or more active checks lists (and 1823 terminate the Tc associated with those check lists) at any time. 1825 To compute the message integrity for the check, the agent uses the 1826 remote username fragment and password learned from the candidate 1827 information obtained from its peer. The local username fragment is 1828 known directly by the agent for its own candidate. 1830 The Initiator performs the ordinary checks on receiving the candidate 1831 information from the Peer (responder) and having formed the 1832 checklists. On the other hand the responding agent either performs 1833 the triggered or ordinary checks as described above. 1835 5.2. Lite Implementation Procedures 1837 Lite implementations skips most of the steps in Section 5 except for 1838 verifying the peer's ICE support and determining its role in the ICE 1839 processing. 1841 On determining the role for a lite implementation being the 1842 controlling agent means selecting a candidate pair based on the ones 1843 in the candidate exchange (for IPv4, there is only ever one pair), 1844 and then updating the peer with the new candidate information 1845 reflecting that selection, when needed (it is never needed for an 1846 IPv4-only host). The controlled agent is told which candidate pairs 1847 to use for each media stream, and no further candidate updates are 1848 needed to signal this information. 1850 6. Performing Connectivity Checks 1852 This section describes how connectivity checks are performed. All 1853 ICE implementations are required to be compliant to [RFC5389], as 1854 opposed to the older [RFC3489]. However, whereas a full 1855 implementation will both generate checks (acting as a STUN client) 1856 and receive them (acting as a STUN server), a lite implementation 1857 will only receive checks, and thus will only act as a STUN server. 1859 6.1. STUN Client Procedures 1861 These procedures define how an agent sends a connectivity check, 1862 whether it is an ordinary or a triggered check. These procedures are 1863 only applicable to full implementations. 1865 6.1.1. Creating Permissions for Relayed Candidates 1867 If the connectivity check is being sent using a relayed local 1868 candidate, the client MUST create a permission first if it has not 1869 already created one previously. It would have created one previously 1870 if it had told the TURN server to create a permission for the given 1871 relayed candidate towards the IP address of the remote candidate. To 1872 create the permission, the agent follows the procedures defined in 1873 [RFC5766]. The permission MUST be created towards the IP address of 1874 the remote candidate. It is RECOMMENDED that the agent defer 1875 creation of a TURN channel until ICE completes, in which case 1876 permissions for connectivity checks are normally created using a 1877 CreatePermission request. Once established, the agent MUST keep the 1878 permission active until ICE concludes. 1880 6.1.2. Sending the Request 1882 A connectivity check is generated by sending a Binding request from a 1883 local candidate to a remote candidate. [RFC5389] describes how 1884 Binding requests are constructed and generated. A connectivity check 1885 MUST utilize the STUN short-term credential mechanism. Support for 1886 backwards compatibility with RFC 3489 MUST NOT be used or assumed 1887 with connectivity checks. The FINGERPRINT mechanism MUST be used for 1888 connectivity checks. 1890 ICE extends STUN by defining several new attributes, including 1891 PRIORITY, USE-CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. These 1892 new attributes are formally defined in Section 14.1, and their usage 1893 is described in the subsections below. These STUN extensions are 1894 applicable only to connectivity checks used for ICE. 1896 6.1.2.1. PRIORITY 1898 An agent MUST include the PRIORITY attribute in its Binding request. 1899 The attribute MUST be set equal to the priority that would be 1900 assigned, based on the algorithm in Section 4.1.2, to a peer 1901 reflexive candidate, should one be learned as a consequence of this 1902 check (see Section 6.1.2.4.2.1 for how peer reflexive candidates are 1903 learned). This priority value will be computed identically to how 1904 the priority for the local candidate of the pair was computed, except 1905 that the type preference is set to the value for peer reflexive 1906 candidate types. 1908 6.1.2.2. USE-CANDIDATE 1910 The controlling agent includes the USE-CANDIDATE attribute in order 1911 to nominate a candidate pair Section 6.2.1.1. The controlled agent 1912 MUST NOT include the USE-CANDIDATE attribute in its Binding request. 1914 6.1.2.3. ICE-CONTROLLED and ICE-CONTROLLING 1916 The agent MUST include the ICE-CONTROLLED attribute in the request if 1917 it is in the controlled role, and MUST include the ICE-CONTROLLING 1918 attribute in the request if it is in the controlling role. 1920 The content of either attribute are used as tie-breaker values when 1921 an ICE role conflict occurs Section 6.1.3.1.1. 1923 The ICE-CONTROLLED and ICE-CONTROLLING attributes are defined in 1924 Section 14.1. 1926 6.1.2.3.1. Forming Credentials 1928 A Binding request serving as a connectivity check MUST utilize the 1929 STUN short-term credential mechanism. The username for the 1930 credential is formed by concatenating the username fragment provided 1931 by the peer with the username fragment of the agent sending the 1932 request, separated by a colon (":"). The password is equal to the 1933 password provided by the peer. For example, consider the case where 1934 agent L is the initiating , agent and agent R is the responding 1935 agent. Agent L included a username fragment of LFRAG for its 1936 candidates and a password of LPASS. Agent R provided a username 1937 fragment of RFRAG and a password of RPASS. A connectivity check from 1938 L to R utilizes the username RFRAG:LFRAG and a password of RPASS. A 1939 connectivity check from R to L utilizes the username LFRAG:RFRAG and 1940 a password of LPASS. The responses utilize the same usernames and 1941 passwords as the requests (note that the USERNAME attribute is not 1942 present in the response). 1944 6.1.2.3.2. DiffServ Treatment 1946 If the agent is using Diffserv Codepoint markings [RFC2475] in its 1947 media packets, it SHOULD apply those same markings to its 1948 connectivity checks. 1950 6.1.2.4. Processing the Response 1952 When a Binding response is received, it is correlated to its Binding 1953 request using the transaction ID, as defined in [RFC5389], which then 1954 ties it to the candidate pair for which the Binding request was sent. 1955 This section defines additional procedures for processing Binding 1956 responses specific to this usage of STUN. 1958 6.1.2.4.1. Failure Cases 1960 If the STUN transaction generates a 487 (Role Conflict) error 1961 response, the agent checks whether it included an ICE-CONTROLLED or 1962 ICE-CONTROLLING attribute in the associated Binding request. If the 1963 request contained an ICE-CONTROLLED attribute, the agent MUST switch 1964 to the controlling role. If the request contained an ICE-CONTROLLING 1965 attribute, the agent MUST switch to the controlled role. 1967 Once the agent has switched its role, the agent MUST enqueue the 1968 candidate pair whose check generated the 487 into the triggered check 1969 queue. The state of that pair is set to Waiting. When the triggered 1970 check is sent, it will contain an ICE-CONTROLLING or ICE-CONTROLLED 1971 attribute reflecting its new role. The agent MUST NOT change the 1972 tie-breaker value. 1974 A change in roles will require an agent to recompute pair priorities 1975 (Section 5.1.3.3), since those priorities are a function of 1976 controlling and controlled roles. The change in role will also 1977 impact whether the agent is responsible for selecting nominated pairs 1978 and generating updated candidate information for sharing upon 1979 conclusion of ICE. 1981 Agents MAY support receipt of ICMP errors for connectivity checks. 1982 If the STUN transaction generates an ICMP error, the agent sets the 1983 state of the pair to Failed. If the STUN transaction generates a 1984 STUN error response that is unrecoverable (as defined in [RFC5389]) 1985 or times out, the agent sets the state of the pair to Failed. 1987 The agent MUST check that the source IP address and port of the 1988 response equal the destination IP address and port to which the 1989 Binding request was sent, and that the destination IP address and 1990 port of the response match the source IP address and port from which 1991 the Binding request was sent. In other words, the source and 1992 destination transport addresses in the request and responses are 1993 symmetric. If they are not symmetric, the agent sets the state of 1994 the pair to Failed. 1996 6.1.2.4.2. Success Cases 1998 A check is considered to be a success if all of the following are 1999 true: 2001 o The STUN transaction generated a success response. 2003 o The source IP address and port of the response equals the 2004 destination IP address and port to which the Binding request was 2005 sent. 2007 o The destination IP address and port of the response match the 2008 source IP address and port from which the Binding request was 2009 sent. 2011 6.1.2.4.2.1. Discovering Peer Reflexive Candidates 2013 The agent checks the mapped address from the STUN response. If the 2014 transport address does not match any of the local candidates that the 2015 agent knows about, the mapped address represents a new candidate -- a 2016 peer reflexive candidate. Like other candidates, it has a type, 2017 base, priority, and foundation. They are computed as follows: 2019 o Its type is equal to peer reflexive. 2021 o Its base is set equal to the local candidate of the candidate pair 2022 from which the STUN check was sent. 2024 o Its priority is set equal to the value of the PRIORITY attribute 2025 in the Binding request. 2027 o Its foundation is selected as described in Section 4.1.1.3. 2029 This peer reflexive candidate is then added to the list of local 2030 candidates for the media stream. Its username fragment and password 2031 are the same as all other local candidates for that media stream. 2032 However, the peer reflexive candidate is not paired with other remote 2033 candidates. This is not necessary; a valid pair will be generated 2034 from it momentarily based on the procedures in Section 6.1.2.4.2.2. 2035 If an agent wishes to pair the peer reflexive candidate with other 2036 remote candidates besides the one in the valid pair that will be 2037 generated, the agent MAY generate an update the peer with the 2038 candidate information that includes the peer reflexive candidate. 2039 This will cause it to be paired with all other remote candidates. 2041 6.1.2.4.2.2. Constructing a Valid Pair 2043 The agent constructs a candidate pair whose local candidate equals 2044 the mapped address of the response, and whose remote candidate equals 2045 the destination address to which the request was sent. This is 2046 called a valid pair, since it has been validated by a STUN 2047 connectivity check. The valid pair may equal the pair that generated 2048 the check, may equal a different pair in the check list, or may be a 2049 pair not currently on any check list. If the pair equals the pair 2050 that generated the check or is on a check list currently, it is also 2051 added to the VALID LIST, which is maintained by the agent for each 2052 media stream. This list is empty at the start of ICE processing, and 2053 fills as checks are performed, resulting in valid candidate pairs. 2055 It will be very common that the pair will not be on any check list. 2056 Recall that the check list has pairs whose local candidates are never 2057 reflexive; those pairs had their local candidates converted to the 2058 base of the reflexive candidates, and then pruned if they were 2059 redundant. When the response to the STUN check arrives, the mapped 2060 address will be reflexive if there is a NAT between the two. In that 2061 case, the valid pair will have a local candidate that doesn't match 2062 any of the pairs in the check list. 2064 If the pair is not on any check list, the agent computes the priority 2065 for the pair based on the priority of each candidate, using the 2066 algorithm in Section 5.1.3. The priority of the local candidate 2067 depends on its type. If it is not peer reflexive, it is equal to the 2068 priority signaled for that candidate in the candidate exchange. If 2069 it is peer reflexive, it is equal to the PRIORITY attribute the agent 2070 placed in the Binding request that just completed. The priority of 2071 the remote candidate is taken from the candidate information of the 2072 peer. If the candidate does not appear there, then the check must 2073 have been a triggered check to a new remote candidate. In that case, 2074 the priority is taken as the value of the PRIORITY attribute in the 2075 Binding request that triggered the check that just completed. The 2076 pair is then added to the VALID LIST. 2078 6.1.2.4.2.3. Updating Pair States 2080 The agent sets the state of the pair that *generated* the check to 2081 Succeeded. Note that, the pair which *generated* the check may be 2082 different than the valid pair constructed in Section 6.1.2.4.2.2 as a 2083 consequence of the response. The success of this check might also 2084 cause the state of other checks to change as well. The agent MUST 2085 perform the following two steps: 2087 1. The agent changes the states for all other Frozen pairs for the 2088 same media stream and same foundation to Waiting. Typically, but 2089 not always, these other pairs will have different component IDs. 2091 2. If there is a pair in the valid list for every component of this 2092 media stream (where this is the actual number of components being 2093 used, in cases where the number of components signaled in the 2094 candidate exchange differs from initiating to responding agent), 2095 the success of this check may unfreeze checks for other media 2096 streams. Note that this step is followed not just the first time 2097 the valid list under consideration has a pair for every 2098 component, but every subsequent time a check succeeds and adds 2099 yet another pair to that valid list. The agent examines the 2100 check list for each other media stream in turn: 2102 * If the check list is active, the agent changes the state of 2103 all Frozen pairs in that check list whose foundation matches a 2104 pair in the valid list under consideration to Waiting. 2106 * If the check list is frozen, and there is at least one pair in 2107 the check list whose foundation matches a pair in the valid 2108 list under consideration, the state of all pairs in the check 2109 list whose foundation matches a pair in the valid list under 2110 consideration is set to Waiting. This will cause the check 2111 list to become active, and ordinary checks will begin for it, 2112 as described in Section 5.1.5. 2114 * If the check list is frozen, and there are no pairs in the 2115 check list whose foundation matches a pair in the valid list 2116 under consideration, the agent 2118 + groups together all of the pairs with the same foundation, 2119 and 2121 + for each group, sets the state of the pair with the lowest 2122 component ID to Waiting. If there is more than one such 2123 pair, the one with the highest-priority is used. 2125 6.1.2.4.2.4. Updating the Nominated Flag 2127 If the agent was a controlling agent, and it had included a USE- 2128 CANDIDATE attribute in the Binding request, the valid pair generated 2129 from that check has its nominated flag set to true. This flag 2130 indicates that this valid pair SHOULD be used for media, unless the 2131 sending agent detects that the candidiate pair does not work. This 2132 concludes the ICE processing for this media stream or all media 2133 streams; see Section 6.2. 2135 If the agent is the controlled agent, the response may be the result 2136 of a triggered check that was sent in response to a request that 2137 itself had the USE-CANDIDATE attribute. This case is described in 2138 Section 6.1.3.1.5, and may now result in setting the nominated flag 2139 for the pair learned from the original request. 2141 An agent MUST NOT select a candidate pair until it has sent a Binding 2142 request, and received the corresponding Binding response, associated 2143 with the candidiate pair. 2145 6.1.2.4.3. Check List and Timer State Updates 2147 Regardless of whether the check was successful or failed, the 2148 completion of the transaction may require updating of check list and 2149 timer states. 2151 If all of the pairs in the check list are now either in the Failed or 2152 Succeeded state: 2154 o If there is not a pair in the valid list for each component of the 2155 media stream, the state of the check list is set to Failed. 2157 o For each frozen check list, the agent 2159 * groups together all of the pairs with the same foundation, and 2161 * for each group, sets the state of the pair with the lowest 2162 component ID to Waiting. If there is more than one such pair, 2163 the one with the highest-priority is used. 2165 If none of the pairs in the check list are in the Waiting or Frozen 2166 state, the check list is no longer considered active, and will not 2167 count towards the value of N in the computation of timers for 2168 ordinary checks as described in Section 5.1.5. 2170 6.1.3. STUN Server Procedures 2172 An agent MUST be prepared to receive a Binding request on the base of 2173 each candidate it included in its most recent candidate exchange. 2174 This requirement holds even if the peer is a lite implementation. 2176 The agent MUST use the short-term credential mechanism (i.e., the 2177 MESSAGE-INTEGRITY attribute) to authenticate the request and perform 2178 a message integrity check. Likewise, the short-term credential 2179 mechanism MUST be used for the response. The agent MUST consider the 2180 username to be valid if it consists of two values separated by a 2181 colon, where the first value is equal to the username fragment 2182 generated by the agent in an candidate exchange for a session in- 2183 progress. It is possible (and in fact very likely) that the 2184 initiating agent will receive a Binding request prior to receiving 2185 the candidates from its peer. If this happens, the agent MUST 2186 immediately generate a response (including computation of the mapped 2187 address as described in Section 6.1.3.1.2). The agent has sufficient 2188 information at this point to generate the response; the password from 2189 the peer is not required. Once the answer is received, it MUST 2190 proceed with the remaining steps required, namely, Section 6.1.3.1.3, 2191 Section 6.1.3.1.4, and Section 6.1.3.1.5 for full implementations. 2192 In cases where multiple STUN requests are received before the answer, 2193 this may cause several pairs to be queued up in the triggered check 2194 queue. 2196 An agent MUST NOT utilize the ALTERNATE-SERVER mechanism, and MUST 2197 NOT support the backwards-compatibility mechanisms to RFC 3489. It 2198 MUST utilize the FINGERPRINT mechanism. 2200 If the agent is using Diffserv Codepoint markings [RFC2475] in its 2201 media packets, it SHOULD apply those same markings to its responses 2202 to Binding requests. The same would apply to any layer 2 markings 2203 the endpoint might be applying to media packets. 2205 6.1.3.1. Additional Procedures for Full Implementations 2207 This subsection defines the additional server procedures applicable 2208 to full implementations. 2210 6.1.3.1.1. Detecting and Repairing Role Conflicts 2212 Normally, the rules for selection of a role in Section 5.1.2 will 2213 result in each agent selecting a different role -- one controlling 2214 and one controlled. However, in unusual call flows, typically 2215 utilizing third party call control, it is possible for both agents to 2216 select the same role. This section describes procedures for checking 2217 for this case and repairing it. These procedures apply only to 2218 usages of ICE that require conflict resolution. The usage document 2219 MUST specify whether this mechanism is needed. 2221 An agent MUST examine the Binding request for either the ICE- 2222 CONTROLLING or ICE-CONTROLLED attribute. It MUST follow these 2223 procedures: 2225 o If neither ICE-CONTROLLING nor ICE-CONTROLLED is present in the 2226 request, the peer agent may have implemented a previous version of 2227 this specification. There may be a conflict, but it cannot be 2228 detected. 2230 o If the agent is in the controlling role, and the ICE-CONTROLLING 2231 attribute is present in the request: 2233 * If the agent's tie-breaker value is larger than or equal to the 2234 contents of the ICE-CONTROLLING attribute, the agent generates 2235 a Binding error response and includes an ERROR-CODE attribute 2236 with a value of 487 (Role Conflict) but retains its role. 2238 * If the agent's tie-breaker value is less than the contents of 2239 the ICE-CONTROLLING attribute, the agent switches to the 2240 controlled role. 2242 o If the agent is in the controlled role, and the ICE-CONTROLLED 2243 attribute is present in the request: 2245 * If the agent's tie-breaker value is larger than or equal to the 2246 contents of the ICE-CONTROLLED attribute, the agent switches to 2247 the controlling role. 2249 * If the agent's tie-breaker value is less than the contents of 2250 the ICE-CONTROLLED attribute, the agent generates a Binding 2251 error response and includes an ERROR-CODE attribute with a 2252 value of 487 (Role Conflict) but retains its role. 2254 o If the agent is in the controlled role and the ICE-CONTROLLING 2255 attribute was present in the request, or the agent was in the 2256 controlling role and the ICE-CONTROLLED attribute was present in 2257 the request, there is no conflict. 2259 A change in roles will require an agent to recompute pair priorities 2260 (Section 5.1.3.3), since those priorities are a function of 2261 controlling and controlled roles. The change in role will also 2262 impact whether the agent is responsible for selecting nominated pairs 2263 and initiating exchange with updated candidate information upon 2264 conclusion of ICE. 2266 The remaining sections in Section 6.1.3.1 are followed if the server 2267 generated a successful response to the Binding request, even if the 2268 agent changed roles. 2270 6.1.3.1.2. Computing Mapped Address 2272 For requests being received on a relayed candidate, the source 2273 transport address used for STUN processing (namely, generation of the 2274 XOR-MAPPED-ADDRESS attribute) is the transport address as seen by the 2275 TURN server. That source transport address will be present in the 2276 XOR-PEER-ADDRESS attribute of a Data Indication message, if the 2277 Binding request was delivered through a Data Indication. If the 2278 Binding request was delivered through a ChannelData message, the 2279 source transport address is the one that was bound to the channel. 2281 6.1.3.1.3. Learning Peer Reflexive Candidates 2283 If the source transport address of the request does not match any 2284 existing remote candidates, it represents a new peer reflexive remote 2285 candidate. This candidate is constructed as follows: 2287 o The priority of the candidate is set to the PRIORITY attribute 2288 from the request. 2290 o The type of the candidate is set to peer reflexive. 2292 o The foundation of the candidate is set to an arbitrary value, 2293 different from the foundation for all other remote candidates. If 2294 any subsequent candidate exchanges contain this peer reflexive 2295 candidate, it will signal the actual foundation for the candidate. 2297 o The component ID of this candidate is set to the component ID for 2298 the local candidate to which the request was sent. 2300 This candidate is added to the list of remote candidates. However, 2301 the agent does not pair this candidate with any local candidates. 2303 6.1.3.1.4. Triggered Checks 2305 Next, the agent constructs a pair whose local candidate is equal to 2306 the transport address on which the STUN request was received, and a 2307 remote candidate equal to the source transport address where the 2308 request came from (which may be the peer reflexive remote candidate 2309 that was just learned). The local candidate will either be a host 2310 candidate (for cases where the request was not received through a 2311 relay) or a relayed candidate (for cases where it is received through 2312 a relay). The local candidate can never be a server reflexive 2313 candidate. Since both candidates are known to the agent, it can 2314 obtain their priorities and compute the candidate pair priority. 2315 This pair is then looked up in the check list. There can be one of 2316 several outcomes: 2318 o If the pair is already on the check list: 2320 * If the state of that pair is Waiting or Frozen, a check for 2321 that pair is enqueued into the triggered check queue if not 2322 already present. 2324 * If the state of that pair is In-Progress, the agent cancels the 2325 in-progress transaction. Cancellation means that the agent 2326 will not retransmit the request, will not treat the lack of 2327 response to be a failure, but will wait the duration of the 2328 transaction timeout for a response. In addition, the agent 2329 MUST create a new connectivity check for that pair 2330 (representing a new STUN Binding request transaction) by 2331 enqueueing the pair in the triggered check queue. The state of 2332 the pair is then changed to Waiting. 2334 * If the state of the pair is Failed, it is changed to Waiting 2335 and the agent MUST create a new connectivity check for that 2336 pair (representing a new STUN Binding request transaction), by 2337 enqueueing the pair in the triggered check queue. 2339 * If the state of that pair is Succeeded, nothing further is 2340 done. 2342 These steps are done to facilitate rapid completion of ICE when both 2343 agents are behind NAT. 2345 o If the pair is not already on the check list: 2347 * The pair is inserted into the check list based on its priority. 2349 * Its state is set to Waiting. 2351 * The pair is enqueued into the triggered check queue. 2353 When a triggered check is to be sent, it is constructed and processed 2354 as described in Section 6.1.2. These procedures require the agent to 2355 know the transport address, username fragment, and password for the 2356 peer. The username fragment for the remote candidate is equal to the 2357 part after the colon of the USERNAME in the Binding request that was 2358 just received. Using that username fragment, the agent can check the 2359 candidates received from its peer (there may be more than one in 2360 cases of forking), and find this username fragment. The 2361 corresponding password is then selected. 2363 6.1.3.1.5. Updating the Nominated Flag 2365 If the Binding request received by the agent had the USE-CANDIDATE 2366 attribute set, and the agent is in the controlled role, the agent 2367 looks at the state of the pair computed in Section 6.1.3.1.4: 2369 o If the state of this pair is Succeeded, it means that the check 2370 generated by this pair produced a successful response. This would 2371 have caused the agent to construct a valid pair when that success 2372 response was received (see Section 6.1.2.4.2.2). The agent now 2373 sets the nominated flag in the valid pair to true. This may end 2374 ICE processing for this media stream; see Section 6.2. 2376 o If the state of this pair is In-Progress, if its check produces a 2377 successful result, the resulting valid pair has its nominated flag 2378 set when the response arrives. This may end ICE processing for 2379 this media stream when it arrives; see Section 6.2. 2381 6.1.3.2. Additional Procedures for Lite Implementations 2383 If the check that was just received contained a USE-CANDIDATE 2384 attribute, the agent constructs a candidate pair whose local 2385 candidate is equal to the transport address on which the request was 2386 received, and whose remote candidate is equal to the source transport 2387 address of the request that was received. This candidate pair is 2388 assigned an arbitrary priority, and placed into a list of valid 2389 candidates called the valid list. The agent sets the nominated flag 2390 for that pair to true. ICE processing is considered complete for a 2391 media stream if the valid list contains a candidate pair for each 2392 component. 2394 6.2. Concluding ICE Processing 2396 This section describes how an agent completes ICE. 2398 6.2.1. Procedures for Full Implementations 2400 Concluding ICE involves nominating pairs by the controlling agent and 2401 updating of state machinery. 2403 6.2.1.1. Nominating Pairs 2405 When nominating, the controlling agent lets some number of checks 2406 complete, each of which omit the USE-CANDIDATE attribute. Once one 2407 or more checks complete successfully for a component of a media 2408 stream, valid pairs are generated and added to the valid list. The 2409 agent lets the checks continue until some stopping criterion is met, 2410 and then picks amongst the valid pairs based on an evaluation 2411 criterion. The criteria for stopping the checks and for evaluating 2412 the valid pairs is entirely a matter of local optimization. 2414 When the controlling agent selects the valid pair, it repeats the 2415 check that produced this valid pair (by enqueueing the pair that 2416 generated the check into the triggered check queue), this time with 2417 the USE-CANDIDATE attribute. This check should succeed (since the 2418 previous did), causing the nominated flag of that and only that pair 2419 to be set. Consequently, there will be only a single nominated pair 2420 in the valid list for each component, and when the state of the check 2421 list moves to completed, that exact pair is selected by ICE for 2422 sending and receiving media for that component. 2424 The controlling agent has control over the stopping and selection 2425 criteria for checks. The only requirement is that the agent MUST 2426 eventually pick one and only one candidate pair and generate a check 2427 for that pair with the USE-CANDIDATE attribute present. 2429 The controlled agent SHOULD select the nominated candidate pair if 2430 the agent is receiving Binding responses associated with that 2431 candidiate pair. Before the agent has received Binding responses 2432 associated with the candidiate pair, the agent can send media on any 2433 candidiate for which it has received Binding responses. If more than 2434 one candidate pair is nominated by the controlling agent, the 2435 controlled agent SHOULD select the candidate pair with the highest 2436 priority. 2438 NOTE: A controlling agent that does not support this speification 2439 (i.e. it is implemented according to RFC 5245) might nominate more 2440 than one candidiate pair. This was referred to as aggressive 2441 nomination in RFC 5245. The usage of the 'ice2' ice option by 2442 endpoints supporting this specifcation should prevent such 2443 controlling agents from using aggressive nomination. 2445 6.2.1.2. Updating States 2447 For both controlling and controlled agents, the state of ICE 2448 processing depends on the presence of nominated candidate pairs in 2449 the valid list and on the state of the check list. Note that, at any 2450 time, more than one of the following cases can apply: 2452 o If there are no nominated pairs in the valid list for a media 2453 stream and the state of the check list is Running, ICE processing 2454 continues. 2456 o If there is at least one nominated pair in the valid list for a 2457 media stream and the state of the check list is Running: 2459 * The agent MUST remove all Waiting and Frozen pairs in the check 2460 list and triggered check queue for the same component as the 2461 nominated pairs for that media stream. 2463 * If an In-Progress pair in the check list is for the same 2464 component as a nominated pair, the agent SHOULD cease 2465 retransmissions for its check if its pair priority is lower 2466 than the lowest-priority nominated pair for that component. 2468 o Once there is at least one nominated pair in the valid list for 2469 every component of at least one media stream and the state of the 2470 check list is Running: 2472 * The agent MUST change the state of processing for its check 2473 list for that media stream to Completed. 2475 * The agent MUST continue to respond to any checks it may still 2476 receive for that media stream, and MUST perform triggered 2477 checks if required by the processing of Section 6.1.3. 2479 * The agent MUST continue retransmitting any In-Progress checks 2480 for that check list. 2482 * The agent MAY begin transmitting media for this media stream as 2483 described in Section 9.1. 2485 o Once the state of each check list is Completed: 2487 * The agent sets the state of ICE processing overall to 2488 Completed. 2490 o If the state of the check list is Failed, ICE has not been able to 2491 complete for this media stream. The correct behavior depends on 2492 the state of the check lists for other media streams: 2494 * If all check lists are Failed, ICE processing overall is 2495 considered to be in the Failed state, and the agent SHOULD 2496 consider the session a failure, SHOULD NOT restart ICE, and the 2497 controlling agent SHOULD terminate the entire session. 2499 * If at least one of the check lists for other media streams is 2500 Completed, the controlling agent SHOULD remove the failed media 2501 stream from the session while sending updated candidate list to 2502 its peer. 2504 * If none of the check lists for other media streams are 2505 Completed, but at least one is Running, the agent SHOULD let 2506 ICE continue. 2508 6.2.2. Procedures for Lite Implementations 2510 Concluding ICE for a lite implementation is relatively 2511 straightforward. There are two cases to consider: 2513 The implementation is lite, and its peer is full. 2515 The implementation is lite, and its peer is lite. 2517 The effect of ICE concluding is that the agent can free any allocated 2518 host candidates that were not utilized by ICE, as described in 2519 Section 6.2.3. 2521 6.2.2.1. Peer Is Full 2523 In this case, the agent will receive connectivity checks from its 2524 peer. When an agent has received a connectivity check that includes 2525 the USE-CANDIDATE attribute for each component of a media stream, the 2526 state of ICE processing for that media stream moves from Running to 2527 Completed. When the state of ICE processing for all media streams is 2528 Completed, the state of ICE processing overall is Completed. 2530 The lite implementation will never itself determine that ICE 2531 processing has failed for a media stream; rather, the full peer will 2532 make that determination and then remove or restart the failed media 2533 stream as part of subsequent candidate exchange process. 2535 6.2.2.2. Peer Is Lite 2537 Once the candidate exchange has completed, both agents examine their 2538 candidates and those of its peer. For each media stream, each agent 2539 pairs up its own candidates with the candidates of its peer for that 2540 media stream. Two candidates are paired up when they are for the 2541 same component, utilize the same transport protocol (UDP in this 2542 specification), and are from the same IP address family (IPv4 or 2543 IPv6). 2545 o If there is a single pair per component, that pair is added to the 2546 Valid list. If all of the components for a media stream had one 2547 pair, the state of ICE processing for that media stream is set to 2548 Completed. If all media streams are Completed, the state of ICE 2549 processing is set to Completed overall. This will always be the 2550 case for implementations that are IPv4-only. 2552 o If there is more than one pair per component: 2554 * The agent MUST select a pair based on local policy. Since this 2555 case only arises for IPv6, it is RECOMMENDED that an agent 2556 follow the procedures of RFC 6724 [RFC6724] to select a single 2557 pair. 2559 * The agent adds the selected pair for each component to the 2560 valid list. As described in Section 9.1, this will permit 2561 media to begin flowing. However, it is possible (and in fact 2562 likely) that both agents have chosen different pairs. 2564 * To reconcile this, the controlling agent MUST send updated 2565 candidate list which will include the remote-candidates 2566 attribute. 2568 * The agent MUST NOT update the state of ICE processing until 2569 after the candidate exchange completes. Then the controlling 2570 agent MUST change the state of ICE processing to Completed for 2571 all media streams, and the state of ICE processing overall to 2572 Completed. 2574 6.2.3. Freeing Candidates 2576 6.2.3.1. Full Implementation Procedures 2578 The procedures in Section 6.2 require that an agent continue to 2579 listen for STUN requests and continue to generate triggered checks 2580 for a media stream, even once processing for that stream completes. 2581 The rules in this section describe when it is safe for an agent to 2582 cease sending or receiving checks on a candidate that was not 2583 selected by ICE, and then free the candidate. 2585 Once ICE processing has reached the Completed state for all peers for 2586 media streams using those candidates, the agent SHOULD wait an 2587 additional three seconds, and then it MAY cease responding to checks 2588 or generating triggered checks on that candidate. It MAY free the 2589 candidate at that time. Freeing of server reflexive candidates is 2590 never explicit; it happens by lack of a keepalive. The three-second 2591 delay handles cases when aggressive nomination is used, and the 2592 selected pairs can quickly change after ICE has completed. 2594 6.2.3.2. Lite Implementation Procedures 2596 A lite implementation MAY free candidates not selected by ICE as soon 2597 as ICE processing has reached the Completed state for all peers for 2598 all media streams using those candidates. 2600 6.3. ICE Restarts 2602 An agent MAY restart ICE processing for an existing media stream. An 2603 ICE restart will cause all previous states, excluding the roles of 2604 the agents, of ICE processing to be flushed and checks to start anew. 2605 The only difference between an ICE restart and a brand new media 2606 session is that during the restart media can continue to be sent to 2607 the previously validated pair, and that a new media session always 2608 requires the roles to be determined. 2610 An agent MUST restart ICE for a media stream if: 2612 o The candidate(s) is being generated for the purposes of changing 2613 the target of the media stream. In other words, if an agent wants 2614 to generate an updated candidate information that, had ICE not 2615 been in use, would result in a new value for the destination of a 2616 media component. 2618 o An agent is changing its implementation level. This typically 2619 only happens in third party call control use cases, where the 2620 entity performing the signaling is not the entity receiving the 2621 media, and it has changed the target of media mid-session to 2622 another entity that has a different ICE implementation. 2624 To restart ICE, an agent MUST change both the password and the user 2625 name fragment for the media stream when exchanging the candidates. 2626 The new candidate set MAY include some, none, or all of the previous 2627 candidates for that stream and MAY include a totally new set of 2628 candidates. 2630 As described in Section 5.1.2, ICE agents MUST NOT re-determine the 2631 roles as part as an ICE restart, unless certain criteria that require 2632 the roles to be re-determined is fulfilled. 2634 7. ICE Option 2636 This section defines a new ICE option, 'ice2'. The ICE option 2637 indicates that the ICE agent that includes it (in an ice-options 2638 attribute) is compliant to this specification. For example, the ICE 2639 agent will not use the aggressive nomination procedure defined in 2640 [RFC5245]. 2642 An ICE agent compliant to this specification MUST inform the peer 2643 about the compliance using the 'ice2' ICE option. 2645 NOTE: The encoding of the 'ice2' ICE option, and the message(s) used 2646 to carry it to the peer, are protocol specific. The encoding for the 2647 Session Description Protocol (SDP) [RFC4566] is defined in 2648 [I-D.ietf-mmusic-ice-sip-sdp]. 2650 8. Keepalives 2652 All endpoints MUST send keepalives for each media session. These 2653 keepalives serve the purpose of keeping NAT bindings alive for the 2654 media session. The keepalives SHOULD be sent using a format that is 2655 supported by its peer. ICE endpoints allow for STUN-based keepalives 2656 for UDP streams, and as such, STUN keepalives MUST be used when an 2657 agent is a full ICE implementation and is communicating with a peer 2658 that supports ICE (lite or full). 2660 If there has been no packet sent on the candidate pair ICE is using 2661 for a media component for Tr seconds (where packets include those 2662 defined for the component (RTP or RTCP) and previous keepalives), an 2663 agent MUST generate a keepalive on that pair. ICE endpoints SHOULD 2664 use a Tr value of 15 seconds, but MAY use another value, e.g. based 2665 on configuration or network/NAT characteristics. For example, if an 2666 agent has a dynamic way to discover the binding lifetimes of the 2667 intervening NATs, it can use that value to determine Tr. 2668 Administrators deploying ICE in more controlled networking 2669 environments SHOULD set Tr to the longest duration possible in their 2670 environment. ICE endpoints MUST NOT use a Tr value smaller than 15 2671 seconds. 2673 When STUN is being used for keepalives, a STUN Binding Indication is 2674 used [RFC5389]. The Indication MUST NOT utilize any authentication 2675 mechanism. It SHOULD contain the FINGERPRINT attribute to aid in 2676 demultiplexing, but SHOULD NOT contain any other attributes. It is 2677 used solely to keep the NAT bindings alive. The Binding Indication 2678 is sent using the same local and remote candidates that are being 2679 used for media. Though Binding Indications are used for keepalives, 2680 an agent MUST be prepared to receive a connectivity check as well. 2681 If a connectivity check is received, a response is generated as 2682 discussed in [RFC5389], but there is no impact on ICE processing 2683 otherwise. 2685 An agent MUST begin the keepalive processing once ICE has selected 2686 candidates for usage with media, or media begins to flow, whichever 2687 happens first. Keepalives end once the session terminates or the 2688 media stream is removed. 2690 9. Media Handling 2692 9.1. Sending Media 2694 Procedures for sending media differ for full and lite 2695 implementations. 2697 9.1.1. Procedures for Full Implementations 2699 Agents always send media using a candidate pair, using candidate 2700 pairs in the Valid list. Once a candidiate pair has been selected 2701 only that candidiate pair (referred to as selected pair) is used for 2702 sending media. An agent will send media to the remote candidate 2703 (i.e., setting the destination address and port of the packet equal 2704 to that remote candidate), and will send it from the base associated 2705 with the candidiate pair used for sending media. In case of a 2706 relayed candidate, media is sent from the agent and forwarded through 2707 the base (located in the TURN server), using the procedures defined 2708 in [RFC5766]. 2710 If the local candidate is a relayed candidate, it is RECOMMENDED that 2711 an agent creates a channel on the TURN server towards the remote 2712 candidate. This is done using the procedures for channel creation as 2713 defined in Section 11 of [RFC5766]. 2715 The selected pair for a component of a media stream is: 2717 o empty if the state of the check list for that media stream is 2718 Running, and there is no previous selected pair for that component 2719 due to an ICE restart 2721 o equal to the previous selected pair for a component of a media 2722 stream if the state of the check list for that media stream is 2723 Running, and there was a previous selected pair for that component 2724 due to an ICE restart 2726 Unless an agent is able to produce a selected pair for all components 2727 associated with a media stream, the agent MUST NOT continue sending 2728 media for any component associated with that media stream. 2730 9.1.2. Procedures for Lite Implementations 2732 A lite implementation MUST NOT send media until it has a Valid list 2733 that contains a candidate pair for each component of that media 2734 stream. Once that happens, the agent MAY begin sending media 2735 packets. To do that, it sends media to the remote candidate in the 2736 pair (setting the destination address and port of the packet equal to 2737 that remote candidate), and will send it from the base associated 2738 with the candidiate pair used for sending media. In case of a 2739 relayed candidate, media is sent from the agent and forwarded through 2740 the base (located in the TURN server), using the procedures defined 2741 in [RFC5766]. 2743 9.1.3. Procedures for All Implementations 2745 ICE has interactions with jitter buffer adaptation mechanisms. An 2746 RTP stream can begin using one candidate, and switch to another one, 2747 though this happens rarely with ICE. The newer candidate may result 2748 in RTP packets taking a different path through the network -- one 2749 with different delay characteristics. As discussed below, agents are 2750 encouraged to re-adjust jitter buffers when there are changes in 2751 source or destination address of media packets. Furthermore, many 2752 audio codecs use the marker bit to signal the beginning of a 2753 talkspurt, for the purposes of jitter buffer adaptation. For such 2754 codecs, it is RECOMMENDED that the sender set the marker bit 2756 [RFC3550] when an agent switches transmission of media from one 2757 candidate pair to another. 2759 9.2. Receiving Media 2761 Even though ICE agents are only allowed to send media using valid 2762 candidiate pairs (and, once a candidiate pair has been selected, only 2763 on the selected pair) ICE implementations SHOULD by default be 2764 prepared to receive media on any of the candidiates provided in the 2765 most recent candidiate exchange with the peer. Specific ICE usages 2766 MAY define rules that differs from this, e.g., by defining that media 2767 must not be sent until selected pairs have been procduced for each 2768 component associated with that media. 2770 It is RECOMMENDED that, when an agent receives an RTP packet with a 2771 new source or destination IP address for a particular media stream, 2772 that the agent re-adjust its jitter buffers. 2774 RFC 3550 [RFC3550] describes an algorithm in Section 8.2 for 2775 detecting synchronization source (SSRC) collisions and loops. These 2776 algorithms are based, in part, on seeing different source transport 2777 addresses with the same SSRC. However, when ICE is used, such 2778 changes will sometimes occur as the media streams switch between 2779 candidates. An agent will be able to determine that a media stream 2780 is from the same peer as a consequence of the STUN exchange that 2781 proceeds media transmission. Thus, if there is a change in source 2782 transport address, but the media packets come from the same peer 2783 agent, this SHOULD NOT be treated as an SSRC collision. 2785 10. Extensibility Considerations 2787 This specification makes very specific choices about how both agents 2788 in a session coordinate to arrive at the set of candidate pairs that 2789 are selected for media. It is anticipated that future specifications 2790 will want to alter these algorithms, whether they are simple changes 2791 like timer tweaks or larger changes like a revamp of the priority 2792 algorithm. When such a change is made, providing interoperability 2793 between the two agents in a session is critical. 2795 First, ICE provides the ice-options attribute. Each extension or 2796 change to ICE is associated with a token. When an agent supporting 2797 such an extension or change triggers candidate exchange, it MUST 2798 include the token for that extension in this attribute. This allows 2799 each side to know what the other side is doing. This attribute MUST 2800 NOT be present if the agent doesn't support any ICE extensions or 2801 changes. 2803 One of the complications in achieving interoperability is that ICE 2804 relies on a distributed algorithm running on both agents to converge 2805 on an agreed set of candidate pairs. If the two agents run different 2806 algorithms, it can be difficult to guarantee convergence on the same 2807 candidate pairs. The regular nomination procedure described in 2808 Section 6.2 eliminates some of the tight coordination by delegating 2809 the selection algorithm completely to the controlling agent. 2810 Consequently, when a controlling agent is communicating with a peer 2811 that supports options it doesn't know about, the agent MUST run a 2812 regular nomination algorithm. When regular nomination is used, ICE 2813 will converge perfectly even when both agents use different pair 2814 prioritization algorithms. One of the keys to such convergence is 2815 triggered checks, which ensure that the nominated pair is validated 2816 by both agents. Consequently, any future ICE enhancements MUST 2817 preserve triggered checks. 2819 ICE is also extensible to other media streams beyond RTP, and for 2820 transport protocols beyond UDP. Extensions to ICE for non-RTP media 2821 streams need to specify how many components they utilize, and assign 2822 component IDs to them, starting at 1 for the most important component 2823 ID. Specifications for new transport protocols must define how, if 2824 at all, various steps in the ICE processing differ from UDP. 2826 11. Setting Ta and RTO 2828 11.1. General 2830 During the ICE gathering phase (Section 4.1.1) and while ICE is 2831 performing connectivity checks (Section 6), an agent triggers STUN 2832 and TURN transactions. These transactions are paced at a rate 2833 indicated by Ta, and the retransmission interval for each transaction 2834 is calculated based on the the retransmission timer for the STUN 2835 transactions (RTO) [RFC5389]. 2837 This section describes how the Ta and RTO values are computed during 2838 the ICE gathering phase and while ICE is performing connectivity 2839 checks. 2841 NOTE: Previously, in RFC 5245, different formulas were defined for 2842 computing Ta and RTO, depending on whether ICE was used for a real- 2843 time media stream (e.g. RTP) or not. 2845 The formulas below result in a behavior whereby an agent will send 2846 its first packet for every single connectivity check before 2847 performing a retransmit. This can be seen in the formulas for the 2848 RTO (which represents the retransmit interval). Those formulas scale 2849 with N, the number of checks to be performed. As a result of this, 2850 ICE maintains a nicely constant rate, but becomes more sensitive to 2851 packet loss. The loss of the first single packet for any 2852 connectivity check is likely to cause that pair to take a long time 2853 to be validated, and instead, a lower-priority check (but one for 2854 which there was no packet loss) is much more likely to complete 2855 first. This results in ICE performing sub-optimally, choosing lower- 2856 priority pairs over higher-priority pairs. Implementors should be 2857 aware of this consequence, but still should utilize the timer values 2858 described here. 2860 11.2. Ta 2862 ICE agents SHOULD use the default Ta value, 50 ms, but MAY use 2863 another value based on the characteristics of the associated media. 2865 If an ICE agent wants to use another Ta value than the default value, 2866 the agent MUST indicate the proposed value to its peer during the ICE 2867 exchange. Both agents MUST use the higher value of the proposed 2868 values. If an agent does not propose a value, the default value is 2869 used for that agent when comparing which value is higher. 2871 Regardless of the Ta value chosen for each ICE agent, the combination 2872 of all transactions from all ICE agents (if a given implementation 2873 runs several concurrent ICE agents) MUST NOT be sent more often than 2874 once every 5ms (as though there were one global Ta value for pacing 2875 all ICE agents). 2877 This mechanism of a global minimum pacing interval of 5ms is not 2878 generally applicable to transport protocols, but is applicable to ICE 2879 based on the following reasoning. 2881 o Start with the following rules which would be generally applicable 2882 to transport protocols: 2884 1. Let MaxBytes be the maximum number of bytes allowed to be 2885 outstanding in the network at start-up, which SHOULD be 14600 2886 bytes per RFC 6928. 2888 2. Let HTO be the transaction timeout, which SHOULD be 2*RTT if 2889 RTT is known and 500ms otherwise. This is based on the RTO 2890 for STUN messages from RFC 5389 and the the TCP initial RTO, 2891 which is 1 sec in RFC 6298. 2893 3. Let MinPacing be the minimum pacing interval between 2894 transactions, which SHOULD be 5ms. 2896 o Observe that ICE agents typically do not know the RTT for ICE 2897 transactions (connectivity checks in particular), meaning that HTO 2898 will almost always be 500ms. 2900 o Observe that a MinPacing of 5ms and HTO of 500ms gives at most 100 2901 packets/HTO, which for a typical ICE check of less than 120 bytes 2902 means a maximum of 12000 outstanding bytes in the network, which 2903 is less than the maximum expressed by rule 1. 2905 o Thus, for ICE, the rule set reduces down to just the MinPacing 2906 rule, which is equivalant to having a global Ta value. 2908 NOTE: Appendix C shows examples of required bandwidth, using 2909 different Ta values. 2911 11.3. RTO 2913 During the ICE gathering phase, ICE agents SHOULD calculate the RTO 2914 value using the following formula: 2916 RTO = MAX (500ms, Ta * (Num-Of-Pairs)) 2918 Num-Of-Pairs: the number of pairs of candidates 2919 with STUN or TURN servers. 2921 For connectivity checks, ICE agents SHOULD calculate the RTO value 2922 using the following formula: 2924 RTO = MAX (500ms, Ta*N * (Num-Waiting + Num-In-Progress)) 2926 Num-Waiting: the number of checks in the check list in the 2927 Waiting state. 2929 Num-In-Progress: the number of checks in the In-Progress state. 2931 Note that the RTO will be different for each transaction as the 2932 number of checks in the Waiting and In-Progress states change. 2934 ICE agents MAY calculate the RTO value using other mechanisms than 2935 those described above. ICE agents MUST NOT use a RTO value smaller 2936 than 500 ms. 2938 12. Example 2940 The example is based on the simplified topology of Figure 9. 2942 +-------+ 2943 |STUN | 2944 |Server | 2945 +-------+ 2946 | 2947 +---------------------+ 2948 | | 2949 | Internet | 2950 | | 2951 +---------------------+ 2952 | | 2953 | | 2954 +---------+ | 2955 | NAT | | 2956 +---------+ | 2957 | | 2958 | | 2959 +-----+ +-----+ 2960 | L | | R | 2961 +-----+ +-----+ 2963 Figure 9: Example Topology 2965 Two agents, L and R, are using ICE. Both are full-mode ICE 2966 implementations and use aggressive nomination when they are 2967 controlling. Both agents have a single IPv4 address. For agent L, 2968 it is 10.0.1.1 in private address space [RFC1918], and for agent R, 2969 192.0.2.1 on the public Internet. Both are configured with the same 2970 STUN server (shown in this example for simplicity, although in 2971 practice the agents do not need to use the same STUN server), which 2972 is listening for STUN Binding requests at an IP address of 192.0.2.2 2973 and port 3478. TURN servers are not used in this example. Agent L 2974 is behind a NAT, and agent R is on the public Internet. The NAT has 2975 an endpoint independent mapping property and an address dependent 2976 filtering property. The public side of the NAT has an IP address of 2977 192.0.2.3. 2979 To facilitate understanding, transport addresses are listed using 2980 variables that have mnemonic names. The format of the name is 2981 entity-type-seqno, where entity refers to the entity whose IP address 2982 the transport address is on, and is one of "L", "R", "STUN", or 2983 "NAT". The type is either "PUB" for transport addresses that are 2984 public, and "PRIV" for transport addresses that are private. 2986 Finally, seq-no is a sequence number that is different for each 2987 transport address of the same type on a particular entity. Each 2988 variable has an IP address and port, denoted by varname.IP and 2989 varname.PORT, respectively, where varname is the name of the 2990 variable. 2992 The STUN server has advertised transport address STUN-PUB-1 (which is 2993 192.0.2.2:3478). 2995 In the call flow itself, STUN messages are annotated with several 2996 attributes. The "S=" attribute indicates the source transport 2997 address of the message. The "D=" attribute indicates the destination 2998 transport address of the message. The "MA=" attribute is used in 2999 STUN Binding response messages and refers to the mapped address. 3000 "USE-CAND" implies the presence of the USE-CANDIDATE attribute. 3002 The call flow examples omit STUN authentication operations and RTCP, 3003 and focus on RTP for a single media stream between two full 3004 implementations. 3006 L NAT STUN R 3007 |RTP STUN alloc. | | 3008 |(1) STUN Req | | | 3009 |S=$L-PRIV-1 | | | 3010 |D=$STUN-PUB-1 | | | 3011 |------------->| | | 3012 | |(2) STUN Req | | 3013 | |S=$NAT-PUB-1 | | 3014 | |D=$STUN-PUB-1 | | 3015 | |------------->| | 3016 | |(3) STUN Res | | 3017 | |S=$STUN-PUB-1 | | 3018 | |D=$NAT-PUB-1 | | 3019 | |MA=$NAT-PUB-1 | | 3020 | |<-------------| | 3021 |(4) STUN Res | | | 3022 |S=$STUN-PUB-1 | | | 3023 |D=$L-PRIV-1 | | | 3024 |MA=$NAT-PUB-1 | | | 3025 |<-------------| | | 3026 |(5) L's Candidate Information| | 3027 |------------------------------------------->| 3028 | | | | RTP STUN 3029 | | | | alloc. 3030 | | |(6) STUN Req | 3031 | | |S=$R-PUB-1 | 3032 | | |D=$STUN-PUB-1 | 3033 | | |<-------------| 3034 | | |(7) STUN Res | 3035 | | |S=$STUN-PUB-1 | 3036 | | |D=$R-PUB-1 | 3037 | | |MA=$R-PUB-1 | 3038 | | |------------->| 3039 |(8) R's Candidate Information| | 3040 |<-------------------------------------------| 3041 | |(9) Bind Req | |Begin 3042 | |S=$R-PUB-1 | |Connectivity 3043 | |D=L-PRIV-1 | |Checks 3044 | |<----------------------------| 3045 | |Dropped | | 3046 |(10) Bind Req | | | 3047 |S=$L-PRIV-1 | | | 3048 |D=$R-PUB-1 | | | 3049 |USE-CAND | | | 3050 |------------->| | | 3051 | |(11) Bind Req | | 3052 | |S=$NAT-PUB-1 | | 3053 | |D=$R-PUB-1 | | 3054 | |USE-CAND | | 3055 | |---------------------------->| 3056 | |(12) Bind Res | | 3057 | |S=$R-PUB-1 | | 3058 | |D=$NAT-PUB-1 | | 3059 | |MA=$NAT-PUB-1 | | 3060 | |<----------------------------| 3061 |(13) Bind Res | | | 3062 |S=$R-PUB-1 | | | 3063 |D=$L-PRIV-1 | | | 3064 |MA=$NAT-PUB-1 | | | 3065 |<-------------| | | 3066 |RTP flows | | | 3067 | |(14) Bind Req | | 3068 | |S=$R-PUB-1 | | 3069 | |D=$NAT-PUB-1 | | 3070 | |<----------------------------| 3071 |(15) Bind Req | | | 3072 |S=$R-PUB-1 | | | 3073 |D=$L-PRIV-1 | | | 3074 |<-------------| | | 3075 |(16) Bind Res | | | 3076 |S=$L-PRIV-1 | | | 3077 |D=$R-PUB-1 | | | 3078 |MA=$R-PUB-1 | | | 3079 |------------->| | | 3080 | |(17) Bind Res | | 3081 | |S=$NAT-PUB-1 | | 3082 | |D=$R-PUB-1 | | 3083 | |MA=$R-PUB-1 | | 3084 | |---------------------------->| 3085 | | | |RTP flows 3087 Figure 10: Example Flow 3089 First, agent L obtains a host candidate from its local IP address 3090 (not shown), and from that, sends a STUN Binding request to the STUN 3091 server to get a server reflexive candidate (messages 1-4). Recall 3092 that the NAT has the address and port independent mapping property. 3093 Here, it creates a binding of NAT-PUB-1 for this UDP request, and 3094 this becomes the server reflexive candidate for RTP. 3096 Agent L sets a type preference of 126 for the host candidate and 100 3097 for the server reflexive. The local preference is 65535. Based on 3098 this, the priority of the host candidate is 2130706431 and for the 3099 server reflexive candidate is 1694498815. The host candidate is 3100 assigned a foundation of 1, and the server reflexive, a foundation of 3101 2. These are sent to the peer. 3103 This candidate information is received at agent R. Agent R will 3104 obtain a host candidate, and from it, obtain a server reflexive 3105 candidate (messages 6-7). Since R is not behind a NAT, this 3106 candidate is identical to its host candidate, and they share the same 3107 base. It therefore discards this redundant candidate and ends up 3108 with a single host candidate. With identical type and local 3109 preferences as L, the priority for this candidate is 2130706431. It 3110 chooses a foundation of 1 for its single candidate. Then R's 3111 candidates are then sent to L. 3113 Since neither side indicated that it is lite, the initiating agent 3114 that began ICE processing (agent L) becomes the controlling agent. 3116 Agents L and R both pair up the candidates. They both initially have 3117 two pairs. However, agent L will prune the pair containing its 3118 server reflexive candidate, resulting in just one. At agent L, this 3119 pair has a local candidate of $L_PRIV_1 and remote candidate of 3120 $R_PUB_1, and has a candidate pair priority of 4.57566E+18 (note that 3121 an implementation would represent this as a 64-bit integer so as not 3122 to lose precision). At agent R, there are two pairs. The highest 3123 priority has a local candidate of $R_PUB_1 and remote candidate of 3124 $L_PRIV_1 and has a priority of 4.57566E+18, and the second has a 3125 local candidate of $R_PUB_1 and remote candidate of $NAT_PUB_1 and 3126 priority 3.63891E+18. 3128 Agent R begins its connectivity check (message 9) for the first pair 3129 (between the two host candidates). Since R is the controlled agent 3130 for this session, the check omits the USE-CANDIDATE attribute. The 3131 host candidate from agent L is private and behind a NAT, and thus 3132 this check won't be successful, because the packet cannot be routed 3133 from R to L. 3135 When agent L gets the R's candidates, it performs its one and only 3136 connectivity check (messages 10-13). It implements the aggressive 3137 nomination algorithm, and thus includes a USE-CANDIDATE attribute in 3138 this check. Since the check succeeds, agent L creates a new pair, 3139 whose local candidate is from the mapped address in the Binding 3140 response (NAT-PUB-1 from message 13) and whose remote candidate is 3141 the destination of the request (R-PUB-1 from message 10). This is 3142 added to the valid list. In addition, it is marked as selected since 3143 the Binding request contained the USE-CANDIDATE attribute. Since 3144 there is a selected candidate in the Valid list for the one component 3145 of this media stream, ICE processing for this stream moves into the 3146 Completed state. Agent L can now send media if it so chooses. 3148 Soon after receipt of the STUN Binding request from agent L (message 3149 11), agent R will generate its triggered check. This check happens 3150 to match the next one on its check list -- from its host candidate to 3151 agent L's server reflexive candidate. This check (messages 14-17) 3152 will succeed. Consequently, agent R constructs a new candidate pair 3153 using the mapped address from the response as the local candidate (R- 3154 PUB-1) and the destination of the request (NAT-PUB-1) as the remote 3155 candidate. This pair is added to the Valid list for that media 3156 stream. Since the check was generated in the reverse direction of a 3157 check that contained the USE-CANDIDATE attribute, the candidate pair 3158 is marked as selected. Consequently, processing for this stream 3159 moves into the Completed state, and agent R can also send media. 3161 13. Security Considerations 3163 There are several types of attacks possible in an ICE system. This 3164 section considers these attacks and their countermeasures. These 3165 countermeasures include: 3167 o Using ICE in conjunction with secure signaling techniques, such as 3168 SIPS. 3170 o Limiting the total number of connectivity checks to 100, and 3171 optionally limiting the number of candidates they'll accept in an 3172 candidate exchange. 3174 13.1. Attacks on Connectivity Checks 3176 An attacker might attempt to disrupt the STUN connectivity checks. 3177 Ultimately, all of these attacks fool an agent into thinking 3178 something incorrect about the results of the connectivity checks. 3179 The possible false conclusions an attacker can try and cause are: 3181 False Invalid: An attacker can fool a pair of agents into thinking a 3182 candidate pair is invalid, when it isn't. This can be used to 3183 cause an agent to prefer a different candidate (such as one 3184 injected by the attacker) or to disrupt a call by forcing all 3185 candidates to fail. 3187 False Valid: An attacker can fool a pair of agents into thinking a 3188 candidate pair is valid, when it isn't. This can cause an agent 3189 to proceed with a session, but then not be able to receive any 3190 media. 3192 False Peer Reflexive Candidate: An attacker can cause an agent to 3193 discover a new peer reflexive candidate, when it shouldn't have. 3194 This can be used to redirect media streams to a Denial-of-Service 3195 (DoS) target or to the attacker, for eavesdropping or other 3196 purposes. 3198 False Valid on False Candidate: An attacker has already convinced an 3199 agent that there is a candidate with an address that doesn't 3200 actually route to that agent (for example, by injecting a false 3201 peer reflexive candidate or false server reflexive candidate). It 3202 must then launch an attack that forces the agents to believe that 3203 this candidate is valid. 3205 If an attacker can cause a false peer reflexive candidate or false 3206 valid on a false candidate, it can launch any of the attacks 3207 described in [RFC5389]. 3209 To force the false invalid result, the attacker has to wait for the 3210 connectivity check from one of the agents to be sent. When it is, 3211 the attacker needs to inject a fake response with an unrecoverable 3212 error response, such as a 400. However, since the candidate is, in 3213 fact, valid, the original request may reach the peer agent, and 3214 result in a success response. The attacker needs to force this 3215 packet or its response to be dropped, through a DoS attack, layer 2 3216 network disruption, or other technique. If it doesn't do this, the 3217 success response will also reach the originator, alerting it to a 3218 possible attack. Fortunately, this attack is mitigated completely 3219 through the STUN short-term credential mechanism. The attacker needs 3220 to inject a fake response, and in order for this response to be 3221 processed, the attacker needs the password. If the candidate 3222 exchange signaling is secured, the attacker will not have the 3223 password and its response will be discarded. 3225 Forcing the fake valid result works in a similar way. The agent 3226 needs to wait for the Binding request from each agent, and inject a 3227 fake success response. The attacker won't need to worry about 3228 disrupting the actual response since, if the candidate is not valid, 3229 it presumably wouldn't be received anyway. However, like the fake 3230 invalid attack, this attack is mitigated by the STUN short-term 3231 credential mechanism in conjunction with a secure candidate exchange. 3233 Forcing the false peer reflexive candidate result can be done either 3234 with fake requests or responses, or with replays. We consider the 3235 fake requests and responses case first. It requires the attacker to 3236 send a Binding request to one agent with a source IP address and port 3237 for the false candidate. In addition, the attacker must wait for a 3238 Binding request from the other agent, and generate a fake response 3239 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 3240 Like the other attacks described here, this attack is mitigated by 3241 the STUN message integrity mechanisms and secure candidate exchanges. 3243 Forcing the false peer reflexive candidate result with packet replays 3244 is different. The attacker waits until one of the agents sends a 3245 check. It intercepts this request, and replays it towards the other 3246 agent with a faked source IP address. It must also prevent the 3247 original request from reaching the remote agent, either by launching 3248 a DoS attack to cause the packet to be dropped, or forcing it to be 3249 dropped using layer 2 mechanisms. The replayed packet is received at 3250 the other agent, and accepted, since the integrity check passes (the 3251 integrity check cannot and does not cover the source IP address and 3252 port). It is then responded to. This response will contain a XOR- 3253 MAPPED-ADDRESS with the false candidate, and will be sent to that 3254 false candidate. The attacker must then receive it and relay it 3255 towards the originator. 3257 The other agent will then initiate a connectivity check towards that 3258 false candidate. This validation needs to succeed. This requires 3259 the attacker to force a false valid on a false candidate. Injecting 3260 of fake requests or responses to achieve this goal is prevented using 3261 the integrity mechanisms of STUN and the candidate exchange. Thus, 3262 this attack can only be launched through replays. To do that, the 3263 attacker must intercept the check towards this false candidate, and 3264 replay it towards the other agent. Then, it must intercept the 3265 response and replay that back as well. 3267 This attack is very hard to launch unless the attacker is identified 3268 by the fake candidate. This is because it requires the attacker to 3269 intercept and replay packets sent by two different hosts. If both 3270 agents are on different networks (for example, across the public 3271 Internet), this attack can be hard to coordinate, since it needs to 3272 occur against two different endpoints on different parts of the 3273 network at the same time. 3275 If the attacker itself is identified by the fake candidate, the 3276 attack is easier to coordinate. However, if the media path is 3277 secured (e.g., using SRTP [RFC3711]), the attacker will not be able 3278 to play the media packets, but will only be able to discard them, 3279 effectively disabling the media stream for the call. However, this 3280 attack requires the agent to disrupt packets in order to block the 3281 connectivity check from reaching the target. In that case, if the 3282 goal is to disrupt the media stream, it's much easier to just disrupt 3283 it with the same mechanism, rather than attack ICE. 3285 13.2. Attacks on Server Reflexive Address Gathering 3287 ICE endpoints make use of STUN Binding requests for gathering server 3288 reflexive candidates from a STUN server. These requests are not 3289 authenticated in any way. As a consequence, there are numerous 3290 techniques an attacker can employ to provide the client with a false 3291 server reflexive candidate: 3293 o An attacker can compromise the DNS, causing DNS queries to return 3294 a rogue STUN server address. That server can provide the client 3295 with fake server reflexive candidates. This attack is mitigated 3296 by DNS security, though DNS-SEC is not required to address it. 3298 o An attacker that can observe STUN messages (such as an attacker on 3299 a shared network segment, like WiFi) can inject a fake response 3300 that is valid and will be accepted by the client. 3302 o An attacker can compromise a STUN server by means of a virus, and 3303 cause it to send responses with incorrect mapped addresses. 3305 A false mapped address learned by these attacks will be used as a 3306 server reflexive candidate in the ICE exchange. For this candidate 3307 to actually be used for media, the attacker must also attack the 3308 connectivity checks, and in particular, force a false valid on a 3309 false candidate. This attack is very hard to launch if the false 3310 address identifies a fourth party (neither the initiator, responder, 3311 nor attacker), since it requires attacking the checks generated by 3312 each agent in the session, and is prevented by SRTP if it identifies 3313 the attacker themself. 3315 If the attacker elects not to attack the connectivity checks, the 3316 worst it can do is prevent the server reflexive candidate from being 3317 used. However, if the peer agent has at least one candidate that is 3318 reachable by the agent under attack, the STUN connectivity checks 3319 themselves will provide a peer reflexive candidate that can be used 3320 for the exchange of media. Peer reflexive candidates are generally 3321 preferred over server reflexive candidates. As such, an attack 3322 solely on the STUN address gathering will normally have no impact on 3323 a session at all. 3325 13.3. Attacks on Relayed Candidate Gathering 3327 An attacker might attempt to disrupt the gathering of relayed 3328 candidates, forcing the client to believe it has a false relayed 3329 candidate. Exchanges with the TURN server are authenticated using a 3330 long-term credential. Consequently, injection of fake responses or 3331 requests will not work. In addition, unlike Binding requests, 3332 Allocate requests are not susceptible to replay attacks with modified 3333 source IP addresses and ports, since the source IP address and port 3334 are not utilized to provide the client with its relayed candidate. 3336 However, TURN servers are susceptible to DNS attacks, or to viruses 3337 aimed at the TURN server, for purposes of turning it into a zombie or 3338 rogue server. These attacks can be mitigated by DNS-SEC and through 3339 good box and software security on TURN servers. 3341 Even if an attacker has caused the client to believe in a false 3342 relayed candidate, the connectivity checks cause such a candidate to 3343 be used only if they succeed. Thus, an attacker must launch a false 3344 valid on a false candidate, per above, which is a very difficult 3345 attack to coordinate. 3347 13.4. Insider Attacks 3349 In addition to attacks where the attacker is a third party trying to 3350 insert fake candidate information or stun messages, there are attacks 3351 possible with ICE when the attacker is an authenticated and valid 3352 participant in the ICE exchange. 3354 13.4.1. STUN Amplification Attack 3356 The STUN amplification attack is similar to the voice hammer. 3357 However, instead of voice packets being directed to the target, STUN 3358 connectivity checks are directed to the target. The attacker sends 3359 an a large number of candidates, say, 50. The responding agent 3360 receives the candidate information, and starts its checks, which are 3361 directed at the target, and consequently, never generate a response. 3362 The answerer will start a new connectivity check every Ta ms (say, 3363 Ta=20ms). However, the retransmission timers are set to a large 3364 number due to the large number of candidates. As a consequence, 3365 packets will be sent at an interval of one every Ta milliseconds, and 3366 then with increasing intervals after that. Thus, STUN will not send 3367 packets at a rate faster than media would be sent, and the STUN 3368 packets persist only briefly, until ICE fails for the session. 3369 Nonetheless, this is an amplification mechanism. 3371 It is impossible to eliminate the amplification, but the volume can 3372 be reduced through a variety of heuristics. Agents SHOULD limit the 3373 total number of connectivity checks they perform to 100. 3374 Additionally, agents MAY limit the number of candidates they'll 3375 accept. 3377 Frequently, protocols that wish to avoid these kinds of attacks force 3378 the initiator to wait for a response prior to sending the next 3379 message. However, in the case of ICE, this is not possible. It is 3380 not possible to differentiate the following two cases: 3382 o There was no response because the initiator is being used to 3383 launch a DoS attack against an unsuspecting target that will not 3384 respond. 3386 o There was no response because the IP address and port are not 3387 reachable by the initiator. 3389 In the second case, another check should be sent at the next 3390 opportunity, while in the former case, no further checks should be 3391 sent. 3393 14. STUN Extensions 3395 14.1. New Attributes 3397 This specification defines four new attributes, PRIORITY, USE- 3398 CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. 3400 The PRIORITY attribute indicates the priority that is to be 3401 associated with a peer reflexive candidate, should one be discovered 3402 by this check. It is a 32-bit unsigned integer, and has an attribute 3403 value of 0x0024. 3405 The USE-CANDIDATE attribute indicates that the candidate pair 3406 resulting from this check should be used for transmission of media. 3407 The attribute has no content (the Length field of the attribute is 3408 zero); it serves as a flag. It has an attribute value of 0x0025. 3410 The ICE-CONTROLLED attribute is present in a Binding request and 3411 indicates that the client believes it is currently in the controlled 3412 role. The content of the attribute is a 64-bit unsigned integer in 3413 network byte order, which contains a random number. The number is 3414 used for solving role conflicts, when it is referred to as the tie- 3415 breaker value. An ICE agent MUST use the same number for all Binding 3416 requests, for all streams, within an ICE session. The ICE agent MAY 3417 change the number when an ICE restart occurs. 3419 The ICE-CONTROLLING attribute is present in a Binding request and 3420 indicates that the client believes it is currently in the controlling 3421 role. The content of the attribute is a 64-bit unsigned integer in 3422 network byte order, which contains a random number. The number is 3423 used for solving role conflicts, when it is referred to as the tie- 3424 breaker value. An ICE agent MUST use the same number for all Binding 3425 requests, for all streams, within an ICE session. The ICE agent MAY 3426 change the number when an ICE restart occurs. 3428 14.2. New Error Response Codes 3430 This specification defines a single error response code: 3432 487 (Role Conflict): The Binding request contained either the ICE- 3433 CONTROLLING or ICE-CONTROLLED attribute, indicating an ICE role 3434 that conflicted with the server. The server compared the tie- 3435 breaker values of the client and the server and determined that 3436 the client needs to switch roles. 3438 15. Operational Considerations 3440 This section discusses issues relevant to network operators looking 3441 to deploy ICE. 3443 15.1. NAT and Firewall Types 3445 ICE was designed to work with existing NAT and firewall equipment. 3446 Consequently, it is not necessary to replace or reconfigure existing 3447 firewall and NAT equipment in order to facilitate deployment of ICE. 3448 Indeed, ICE was developed to be deployed in environments where the 3449 Voice over IP (VoIP) operator has no control over the IP network 3450 infrastructure, including firewalls and NAT. 3452 That said, ICE works best in environments where the NAT devices are 3453 "behave" compliant, meeting the recommendations defined in [RFC4787] 3454 and [RFC5382]. In networks with behave-compliant NAT, ICE will work 3455 without the need for a TURN server, thus improving voice quality, 3456 decreasing call setup times, and reducing the bandwidth demands on 3457 the network operator. 3459 15.2. Bandwidth Requirements 3461 Deployment of ICE can have several interactions with available 3462 network capacity that operators should take into consideration. 3464 15.2.1. STUN and TURN Server Capacity Planning 3466 First and foremost, ICE makes use of TURN and STUN servers, which 3467 would typically be located in the network operator's data centers. 3468 The STUN servers require relatively little bandwidth. For each 3469 component of each media stream, there will be one or more STUN 3470 transactions from each client to the STUN server. In a basic voice- 3471 only IPv4 VoIP deployment, there will be four transactions per call 3472 (one for RTP and one for RTCP, for both caller and callee). Each 3473 transaction is a single request and a single response, the former 3474 being 20 bytes long, and the latter, 28. Consequently, if a system 3475 has N users, and each makes four calls in a busy hour, this would 3476 require N*1.7bps. For one million users, this is 1.7 Mbps, a very 3477 small number (relatively speaking). 3479 TURN traffic is more substantial. The TURN server will see traffic 3480 volume equal to the STUN volume (indeed, if TURN servers are 3481 deployed, there is no need for a separate STUN server), in addition 3482 to the traffic for the actual media traffic. The amount of calls 3483 requiring TURN for media relay is highly dependent on network 3484 topologies, and can and will vary over time. In a network with 100% 3485 behave-compliant NAT, it is exactly zero. At time of writing, large- 3486 scale consumer deployments were seeing between 5 and 10 percent of 3487 calls requiring TURN servers. Considering a voice-only deployment 3488 using G.711 (so 80 kbps in each direction), with .2 erlangs during 3489 the busy hour, this is N*3.2 kbps. For a population of one million 3490 users, this is 3.2 Gbps, assuming a 10% usage of TURN servers. 3492 15.2.2. Gathering and Connectivity Checks 3494 The process of gathering of candidates and performing of connectivity 3495 checks can be bandwidth intensive. ICE has been designed to pace 3496 both of these processes. The gathering phase and the connectivity 3497 check phase are meant to generate traffic at roughly the same 3498 bandwidth as the media traffic itself. This was done to ensure that, 3499 if a network is designed to support multimedia traffic of a certain 3500 type (voice, video, or just text), it will have sufficient capacity 3501 to support the ICE checks for that media. Of course, the ICE checks 3502 will cause a marginal increase in the total utilization; however, 3503 this will typically be an extremely small increase. 3505 Congestion due to the gathering and check phases has proven to be a 3506 problem in deployments that did not utilize pacing. Typically, 3507 access links became congested as the endpoints flooded the network 3508 with checks as fast as they can send them. Consequently, network 3509 operators should make sure that their ICE implementations support the 3510 pacing feature. Though this pacing does increase call setup times, 3511 it makes ICE network friendly and easier to deploy. 3513 15.2.3. Keepalives 3515 STUN keepalives (in the form of STUN Binding Indications) are sent in 3516 the middle of a media session. However, they are sent only in the 3517 absence of actual media traffic. In deployments that are not 3518 utilizing Voice Activity Detection (VAD), the keepalives are never 3519 used and there is no increase in bandwidth usage. When VAD is being 3520 used, keepalives will be sent during silence periods. This involves 3521 a single packet every 15-20 seconds, far less than the packet every 3522 20-30 ms that is sent when there is voice. Therefore, keepalives 3523 don't have any real impact on capacity planning. 3525 15.3. ICE and ICE-lite 3527 Deployments utilizing a mix of ICE and ICE-lite interoperate 3528 perfectly. They have been explicitly designed to do so, without loss 3529 of function. 3531 However, ICE-lite can only be deployed in limited use cases. Those 3532 cases, and the caveats involved in doing so, are documented in 3533 Appendix A. 3535 15.4. Troubleshooting and Performance Management 3537 ICE utilizes end-to-end connectivity checks, and places much of the 3538 processing in the endpoints. This introduces a challenge to the 3539 network operator -- how can they troubleshoot ICE deployments? How 3540 can they know how ICE is performing? 3542 ICE has built-in features to help deal with these problems. SIP 3543 servers on the signaling path, typically deployed in the data centers 3544 of the network operator, will see the contents of the candidate 3545 exchanges that convey the ICE parameters. These parameters include 3546 the type of each candidate (host, server reflexive, or relayed), 3547 along with their related addresses. Once ICE processing has 3548 completed, an updated candidate exchange takes place, signaling the 3549 selected address (and its type). This updated re-INVITE is performed 3550 exactly for the purposes of educating network equipment (such as a 3551 diagnostic tool attached to a SIP server) about the results of ICE 3552 processing. 3554 As a consequence, through the logs generated by the SIP server, a 3555 network operator can observe what types of candidates are being used 3556 for each call, and what address was selected by ICE. This is the 3557 primary information that helps evaluate how ICE is performing. 3559 15.5. Endpoint Configuration 3561 ICE relies on several pieces of data being configured into the 3562 endpoints. This configuration data includes timers, credentials for 3563 TURN servers, and hostnames for STUN and TURN servers. ICE itself 3564 does not provide a mechanism for this configuration. Instead, it is 3565 assumed that this information is attached to whatever mechanism is 3566 used to configure all of the other parameters in the endpoint. For 3567 SIP phones, standard solutions such as the configuration framework 3568 [RFC6080] have been defined. 3570 16. IANA Considerations 3572 The original ICE specification registered four new STUN attributes, 3573 and one new STUN error response. The STUN attributes and error 3574 response are reproduced here. In addition, this specification 3575 registers a new ICE option. 3577 16.1. STUN Attributes 3579 IANA has registered four STUN attributes: 3581 0x0024 PRIORITY 3582 0x0025 USE-CANDIDATE 3583 0x8029 ICE-CONTROLLED 3584 0x802A ICE-CONTROLLING 3586 16.2. STUN Error Responses 3588 IANA has registered following STUN error response code: 3590 487 Role Conflict: The client asserted an ICE role (controlling or 3591 controlled) that is in conflict with the role of the server. 3593 16.3. ICE Options 3595 IANA is requested to register the following ICE option in the "ICE 3596 Options" sub-registry of the "Interactive Connectivity Establishment 3597 (ICE) registry", following the procedures defined in [RFC6336]. 3599 ICE Option name: 3601 ice2 3603 Contact: 3605 Name: Christer Holmberg 3606 E-mail: christer.holmberg(at)ericsson(dot)com 3607 Address: Oy LM Ericsson Ab, 02420 Jorvas, FINLAND 3609 Change control: 3611 IESG 3613 Description: 3615 The ICE option indicates that the ICE agent using the ICE option 3616 is compliant and implemented according to RFC XXXX. 3618 Reference: 3620 RFC XXXX 3622 17. IAB Considerations 3624 The IAB has studied the problem of "Unilateral Self-Address Fixing", 3625 which is the general process by which a agent attempts to determine 3626 its address in another realm on the other side of a NAT through a 3627 collaborative protocol reflection mechanism [RFC3424]. ICE is an 3628 example of a protocol that performs this type of function. 3629 Interestingly, the process for ICE is not unilateral, but bilateral, 3630 and the difference has a significant impact on the issues raised by 3631 IAB. Indeed, ICE can be considered a B-SAF (Bilateral Self-Address 3632 Fixing) protocol, rather than an UNSAF protocol. Regardless, the IAB 3633 has mandated that any protocols developed for this purpose document a 3634 specific set of considerations. This section meets those 3635 requirements. 3637 17.1. Problem Definition 3639 >From RFC 3424, any UNSAF proposal must provide: 3641 Precise definition of a specific, limited-scope problem that is to 3642 be solved with the UNSAF proposal. A short-term fix should not be 3643 generalized to solve other problems; this is why "short-term fixes 3644 usually aren't". 3646 The specific problems being solved by ICE are: 3648 Provide a means for two peers to determine the set of transport 3649 addresses that can be used for communication. 3651 Provide a means for a agent to determine an address that is 3652 reachable by another peer with which it wishes to communicate. 3654 17.2. Exit Strategy 3656 >From RFC 3424, any UNSAF proposal must provide: 3658 Description of an exit strategy/transition plan. The better 3659 short-term fixes are the ones that will naturally see less and 3660 less use as the appropriate technology is deployed. 3662 ICE itself doesn't easily get phased out. However, it is useful even 3663 in a globally connected Internet, to serve as a means for detecting 3664 whether a router failure has temporarily disrupted connectivity, for 3665 example. ICE also helps prevent certain security attacks that have 3666 nothing to do with NAT. However, what ICE does is help phase out 3667 other UNSAF mechanisms. ICE effectively selects amongst those 3668 mechanisms, prioritizing ones that are better, and deprioritizing 3669 ones that are worse. Local IPv6 addresses can be preferred. As NATs 3670 begin to dissipate as IPv6 is introduced, server reflexive and 3671 relayed candidates (both forms of UNSAF addresses) simply never get 3672 used, because higher-priority connectivity exists to the native host 3673 candidates. Therefore, the servers get used less and less, and can 3674 eventually be remove when their usage goes to zero. 3676 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 3677 be used to determine whether to use IPv6 or IPv4 when two dual-stack 3678 hosts communicate with SIP (IPv6 gets used). It can also allow a 3679 network with both 6to4 and native v6 connectivity to determine which 3680 address to use when communicating with a peer. 3682 17.3. Brittleness Introduced by ICE 3684 >From RFC 3424, any UNSAF proposal must provide: 3686 Discussion of specific issues that may render systems more 3687 "brittle". For example, approaches that involve using data at 3688 multiple network layers create more dependencies, increase 3689 debugging challenges, and make it harder to transition. 3691 ICE actually removes brittleness from existing UNSAF mechanisms. In 3692 particular, classic STUN (as described in RFC 3489 [RFC3489]) has 3693 several points of brittleness. One of them is the discovery process 3694 that requires an agent to try to classify the type of NAT it is 3695 behind. This process is error-prone. With ICE, that discovery 3696 process is simply not used. Rather than unilaterally assessing the 3697 validity of the address, its validity is dynamically determined by 3698 measuring connectivity to a peer. The process of determining 3699 connectivity is very robust. 3701 Another point of brittleness in classic STUN and any other unilateral 3702 mechanism is its absolute reliance on an additional server. ICE 3703 makes use of a server for allocating unilateral addresses, but allows 3704 agents to directly connect if possible. Therefore, in some cases, 3705 the failure of a STUN server would still allow for a call to progress 3706 when ICE is used. 3708 Another point of brittleness in classic STUN is that it assumes that 3709 the STUN server is on the public Internet. Interestingly, with ICE, 3710 that is not necessary. There can be a multitude of STUN servers in a 3711 variety of address realms. ICE will discover the one that has 3712 provided a usable address. 3714 The most troubling point of brittleness in classic STUN is that it 3715 doesn't work in all network topologies. In cases where there is a 3716 shared NAT between each agent and the STUN server, traditional STUN 3717 may not work. With ICE, that restriction is removed. 3719 Classic STUN also introduces some security considerations. 3720 Fortunately, those security considerations are also mitigated by ICE. 3722 Consequently, ICE serves to repair the brittleness introduced in 3723 classic STUN, and does not introduce any additional brittleness into 3724 the system. 3726 The penalty of these improvements is that ICE increases session 3727 establishment times. 3729 17.4. Requirements for a Long-Term Solution 3731 From RFC 3424, any UNSAF proposal must provide: 3733 ... requirements for longer term, sound technical solutions -- 3734 contribute to the process of finding the right longer term 3735 solution. 3737 Our conclusions from RFC 3489 remain unchanged. However, we feel ICE 3738 actually helps because we believe it can be part of the long-term 3739 solution. 3741 17.5. Issues with Existing NAPT Boxes 3743 From RFC 3424, any UNSAF proposal must provide: 3745 Discussion of the impact of the noted practical issues with 3746 existing, deployed NA[P]Ts and experience reports. 3748 A number of NAT boxes are now being deployed into the market that try 3749 to provide "generic" ALG functionality. These generic ALGs hunt for 3750 IP addresses, either in text or binary form within a packet, and 3751 rewrite them if they match a binding. This interferes with classic 3752 STUN. However, the update to STUN [RFC5389] uses an encoding that 3753 hides these binary addresses from generic ALGs. 3755 Existing NAPT boxes have non-deterministic and typically short 3756 expiration times for UDP-based bindings. This requires 3757 implementations to send periodic keepalives to maintain those 3758 bindings. ICE uses a default of 15 s, which is a very conservative 3759 estimate. Eventually, over time, as NAT boxes become compliant to 3760 behave [RFC4787], this minimum keepalive will become deterministic 3761 and well-known, and the ICE timers can be adjusted. Having a way to 3762 discover and control the minimum keepalive interval would be far 3763 better still. 3765 18. Changes from RFC 5245 3767 Following is the list of changes from RFC 5245 3769 o The specification was generalized to be more usable with any 3770 protocol and the parts that are specific to SIP and SDP were moved 3771 to a SIP/SDP usage document [I-D.ietf-mmusic-ice-sip-sdp]. 3773 o Default candidates, multiple components, ICE mismatch detection, 3774 subsequent offer/answer, and role conflict resolution were made 3775 optional since they are not needed with every protocol using ICE. 3777 o With IPv6, the precedence rules of RFC 6724 are used instead of 3778 the obsoleted RFC 3483 and using address preferences provided by 3779 the host operating system is recommended. 3781 o Candidate gathering rules regarding loopback addresses and IPv6 3782 addresses were clarified. 3784 19. Acknowledgements 3786 Most of the text in this document comes from the original ICE 3787 specification, RFC 5245. The authors would like to thank everyone 3788 who has contributed to that document. For additional contributions 3789 to this revision of the specification we would like to thank Emil 3790 Ivov, Paul Kyzivat, Pal-Erik Martinsen, Simon Perrault, Eric 3791 Rescorla, Thomas Stach, Peter Thatcher, Martin Thomson, Justin 3792 Uberti, and Suhas Nandakumar. 3794 20. References 3796 20.1. Normative References 3798 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3799 Requirement Levels", BCP 14, RFC 2119, 3800 DOI 10.17487/RFC2119, March 1997, 3801 . 3803 [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, 3804 "Session Traversal Utilities for NAT (STUN)", RFC 5389, 3805 DOI 10.17487/RFC5389, October 2008, 3806 . 3808 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3809 Relays around NAT (TURN): Relay Extensions to Session 3810 Traversal Utilities for NAT (STUN)", RFC 5766, 3811 DOI 10.17487/RFC5766, April 2010, 3812 . 3814 [RFC6336] Westerlund, M. and C. Perkins, "IANA Registry for 3815 Interactive Connectivity Establishment (ICE) Options", 3816 RFC 6336, DOI 10.17487/RFC6336, July 2011, 3817 . 3819 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3820 "Default Address Selection for Internet Protocol Version 6 3821 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3822 . 3824 20.2. Informative References 3826 [RFC3605] Huitema, C., "Real Time Control Protocol (RTCP) attribute 3827 in Session Description Protocol (SDP)", RFC 3605, 3828 DOI 10.17487/RFC3605, October 2003, 3829 . 3831 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3832 A., Peterson, J., Sparks, R., Handley, M., and E. 3833 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3834 DOI 10.17487/RFC3261, June 2002, 3835 . 3837 [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model 3838 with Session Description Protocol (SDP)", RFC 3264, 3839 DOI 10.17487/RFC3264, June 2002, 3840 . 3842 [RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, 3843 "STUN - Simple Traversal of User Datagram Protocol (UDP) 3844 Through Network Address Translators (NATs)", RFC 3489, 3845 DOI 10.17487/RFC3489, March 2003, 3846 . 3848 [RFC3235] Senie, D., "Network Address Translator (NAT)-Friendly 3849 Application Design Guidelines", RFC 3235, 3850 DOI 10.17487/RFC3235, January 2002, 3851 . 3853 [RFC3303] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and 3854 A. Rayhan, "Middlebox communication architecture and 3855 framework", RFC 3303, DOI 10.17487/RFC3303, August 2002, 3856 . 3858 [RFC3102] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, 3859 "Realm Specific IP: Framework", RFC 3102, 3860 DOI 10.17487/RFC3102, October 2001, 3861 . 3863 [RFC3103] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, 3864 "Realm Specific IP: Protocol Specification", RFC 3103, 3865 DOI 10.17487/RFC3103, October 2001, 3866 . 3868 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3869 UNilateral Self-Address Fixing (UNSAF) Across Network 3870 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3871 November 2002, . 3873 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3874 Jacobson, "RTP: A Transport Protocol for Real-Time 3875 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3876 July 2003, . 3878 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3879 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3880 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3881 . 3883 [RFC3056] Carpenter, B. and K. Moore, "Connection of IPv6 Domains 3884 via IPv4 Clouds", RFC 3056, DOI 10.17487/RFC3056, February 3885 2001, . 3887 [RFC3879] Huitema, C. and B. Carpenter, "Deprecating Site Local 3888 Addresses", RFC 3879, DOI 10.17487/RFC3879, September 3889 2004, . 3891 [RFC4038] Shin, M-K., Ed., Hong, Y-G., Hagino, J., Savola, P., and 3892 E. Castro, "Application Aspects of IPv6 Transition", 3893 RFC 4038, DOI 10.17487/RFC4038, March 2005, 3894 . 3896 [RFC4091] Camarillo, G. and J. Rosenberg, "The Alternative Network 3897 Address Types (ANAT) Semantics for the Session Description 3898 Protocol (SDP) Grouping Framework", RFC 4091, 3899 DOI 10.17487/RFC4091, June 2005, 3900 . 3902 [RFC4092] Camarillo, G. and J. Rosenberg, "Usage of the Session 3903 Description Protocol (SDP) Alternative Network Address 3904 Types (ANAT) Semantics in the Session Initiation Protocol 3905 (SIP)", RFC 4092, DOI 10.17487/RFC4092, June 2005, 3906 . 3908 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 3909 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 3910 2006, . 3912 [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 3913 Description Protocol", RFC 4566, DOI 10.17487/RFC4566, 3914 July 2006, . 3916 [RFC2475] Blake, S., Black, D., Carlson, M., Davies, E., Wang, Z., 3917 and W. Weiss, "An Architecture for Differentiated 3918 Services", RFC 2475, DOI 10.17487/RFC2475, December 1998, 3919 . 3921 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3922 and E. Lear, "Address Allocation for Private Internets", 3923 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3924 . 3926 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3927 Translation (NAT) Behavioral Requirements for Unicast 3928 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3929 2007, . 3931 [RFC5761] Perkins, C. and M. Westerlund, "Multiplexing RTP Data and 3932 Control Packets on a Single Port", RFC 5761, 3933 DOI 10.17487/RFC5761, April 2010, 3934 . 3936 [RFC4103] Hellstrom, G. and P. Jones, "RTP Payload for Text 3937 Conversation", RFC 4103, DOI 10.17487/RFC4103, June 2005, 3938 . 3940 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3941 (ICE): A Protocol for Network Address Translator (NAT) 3942 Traversal for Offer/Answer Protocols", RFC 5245, 3943 DOI 10.17487/RFC5245, April 2010, 3944 . 3946 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 3947 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 3948 RFC 5382, DOI 10.17487/RFC5382, October 2008, 3949 . 3951 [RFC6080] Petrie, D. and S. Channabasappa, Ed., "A Framework for 3952 Session Initiation Protocol User Agent Profile Delivery", 3953 RFC 6080, DOI 10.17487/RFC6080, March 2011, 3954 . 3956 [RFC6146] Bagnulo, M., Matthews, P., and I. van Beijnum, "Stateful 3957 NAT64: Network Address and Protocol Translation from IPv6 3958 Clients to IPv4 Servers", RFC 6146, DOI 10.17487/RFC6146, 3959 April 2011, . 3961 [RFC6147] Bagnulo, M., Sullivan, A., Matthews, P., and I. van 3962 Beijnum, "DNS64: DNS Extensions for Network Address 3963 Translation from IPv6 Clients to IPv4 Servers", RFC 6147, 3964 DOI 10.17487/RFC6147, April 2011, 3965 . 3967 [RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, 3968 "TCP Candidates with Interactive Connectivity 3969 Establishment (ICE)", RFC 6544, DOI 10.17487/RFC6544, 3970 March 2012, . 3972 [RFC7050] Savolainen, T., Korhonen, J., and D. Wing, "Discovery of 3973 the IPv6 Prefix Used for IPv6 Address Synthesis", 3974 RFC 7050, DOI 10.17487/RFC7050, November 2013, 3975 . 3977 [I-D.ietf-mmusic-ice-sip-sdp] 3978 Petit-Huguenin, M., Keranen, A., and S. Nandakumar, "Using 3979 Interactive Connectivity Establishment (ICE) with Session 3980 Description Protocol (SDP) offer/answer and Session 3981 Initiation Protocol (SIP)", draft-ietf-mmusic-ice-sip- 3982 sdp-10 (work in progress), July 2016. 3984 [RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy 3985 Considerations for IPv6 Address Generation Mechanisms", 3986 RFC 7721, DOI 10.17487/RFC7721, March 2016, 3987 . 3989 [I-D.ietf-ice-dualstack-fairness] 3990 Martinsen, P., Reddy, T., and P. Patil, "ICE Multihomed 3991 and IPv4/IPv6 Dual Stack Guidelines", draft-ietf-ice- 3992 dualstack-fairness-07 (work in progress), November 2016. 3994 Appendix A. Lite and Full Implementations 3996 ICE allows for two types of implementations. A full implementation 3997 supports the controlling and controlled roles in a session, and can 3998 also perform address gathering. In contrast, a lite implementation 3999 is a minimalist implementation that does little but respond to STUN 4000 checks. 4002 Because ICE requires both endpoints to support it in order to bring 4003 benefits to either endpoint, incremental deployment of ICE in a 4004 network is more complicated. Many sessions involve an endpoint that 4005 is, by itself, not behind a NAT and not one that would worry about 4006 NAT traversal. A very common case is to have one endpoint that 4007 requires NAT traversal (such as a VoIP hard phone or soft phone) make 4008 a call to one of these devices. Even if the phone supports a full 4009 ICE implementation, ICE won't be used at all if the other device 4010 doesn't support it. The lite implementation allows for a low-cost 4011 entry point for these devices. Once they support the lite 4012 implementation, full implementations can connect to them and get the 4013 full benefits of ICE. 4015 Consequently, a lite implementation is only appropriate for devices 4016 that will *always* be connected to the public Internet and have a 4017 public IP address at which it can receive packets from any 4018 correspondent. ICE will not function when a lite implementation is 4019 placed behind a NAT. 4021 ICE allows a lite implementation to have a single IPv4 host candidate 4022 and several IPv6 addresses. In that case, candidate pairs are 4023 selected by the controlling agent using a static algorithm, such as 4024 the one in RFC 6724, which is recommended by this specification. 4026 However, static mechanisms for address selection are always prone to 4027 error, since they cannot ever reflect the actual topology and can 4028 never provide actual guarantees on connectivity. They are always 4029 heuristics. Consequently, if an agent is implementing ICE just to 4030 select between its IPv4 and IPv6 addresses, and none of its IP 4031 addresses are behind NAT, usage of full ICE is still RECOMMENDED in 4032 order to provide the most robust form of address selection possible. 4034 It is important to note that the lite implementation was added to 4035 this specification to provide a stepping stone to full 4036 implementation. Even for devices that are always connected to the 4037 public Internet with just a single IPv4 address, a full 4038 implementation is preferable if achievable. Full implementations 4039 also obtain the security benefits of ICE unrelated to NAT traversal; 4040 in particular, the voice hammer attack described in Section 13 is 4041 prevented only for full implementations, not lite. Finally, it is 4042 often the case that a device that finds itself with a public address 4043 today will be placed in a network tomorrow where it will be behind a 4044 NAT. It is difficult to definitively know, over the lifetime of a 4045 device or product, that it will always be used on the public 4046 Internet. Full implementation provides assurance that communications 4047 will always work. 4049 Appendix B. Design Motivations 4051 ICE contains a number of normative behaviors that may themselves be 4052 simple, but derive from complicated or non-obvious thinking or use 4053 cases that merit further discussion. Since these design motivations 4054 are not necessary to understand for purposes of implementation, they 4055 are discussed here in an appendix to the specification. This section 4056 is non-normative. 4058 B.1. Pacing of STUN Transactions 4060 STUN transactions used to gather candidates and to verify 4061 connectivity are paced out at an approximate rate of one new 4062 transaction every Ta milliseconds. Each transaction, in turn, has a 4063 retransmission timer RTO that is a function of Ta as well. Why are 4064 these transactions paced, and why are these formulas used? 4066 Sending of these STUN requests will often have the effect of creating 4067 bindings on NAT devices between the client and the STUN servers. 4068 Experience has shown that many NAT devices have upper limits on the 4069 rate at which they will create new bindings. Experiments have shown 4070 that once every 5 ms is well supported. This is why Ta has a lower 4071 bound of 5 ms. Furthermore, transmission of these packets on the 4072 network makes use of bandwidth and needs to be rate limited by the 4073 agent. Deployments based on earlier draft versions of [RFC5245] 4074 tended to overload rate-constrained access links and perform poorly 4075 overall, in addition to negatively impacting the network. As a 4076 consequence, the pacing ensures that the NAT device does not get 4077 overloaded and that traffic is kept at a reasonable rate. 4079 The definition of a "reasonable" rate is that STUN should not use 4080 more bandwidth than the RTP itself will use, once media starts 4081 flowing. The formula for Ta is designed so that, if a STUN packet 4082 were sent every Ta seconds, it would consume the same amount of 4083 bandwidth as RTP packets, summed across all media streams. Of 4084 course, STUN has retransmits, and the desire is to pace those as 4085 well. For this reason, RTO is set such that the first retransmit on 4086 the first transaction happens just as the first STUN request on the 4087 last transaction occurs. Pictorially: 4089 First Packets Retransmits 4091 | | 4092 | | 4093 -------+------ -------+------ 4094 / \ / \ 4095 / \ / \ 4097 +--+ +--+ +--+ +--+ +--+ +--+ 4098 |A1| |B1| |C1| |A2| |B2| |C2| 4099 +--+ +--+ +--+ +--+ +--+ +--+ 4101 ---+-------+-------+-------+-------+-------+------------ Time 4102 0 Ta 2Ta 3Ta 4Ta 5Ta 4104 In this picture, there are three transactions that will be sent (for 4105 example, in the case of candidate gathering, there are three host 4106 candidate/STUN server pairs). These are transactions A, B, and C. 4107 The retransmit timer is set so that the first retransmission on the 4108 first transaction (packet A2) is sent at time 3Ta. 4110 Subsequent retransmits after the first will occur even less 4111 frequently than Ta milliseconds apart, since STUN uses an exponential 4112 back-off on its retransmissions. 4114 B.2. Candidates with Multiple Bases 4116 Section 4.1.3 talks about eliminating candidates that have the same 4117 transport address and base. However, candidates with the same 4118 transport addresses but different bases are not redundant. When can 4119 an agent have two candidates that have the same IP address and port, 4120 but different bases? Consider the topology of Figure 11: 4122 +----------+ 4123 | STUN Srvr| 4124 +----------+ 4125 | 4126 | 4127 ----- 4128 // \\ 4129 | | 4130 | B:net10 | 4131 | | 4132 \\ // 4133 ----- 4134 | 4135 | 4136 +----------+ 4137 | NAT | 4138 +----------+ 4139 | 4140 | 4141 ----- 4142 // \\ 4143 | A | 4144 |192.168/16 | 4145 | | 4146 \\ // 4147 ----- 4148 | 4149 | 4150 |192.168.1.100 ----- 4151 +----------+ // \\ +----------+ 4152 | | | | | | 4153 | Initiator|---------| C:net10 |-----------| Responder| 4154 | |10.0.1.100| | 10.0.1.101 | | 4155 +----------+ \\ // +----------+ 4156 ----- 4158 Figure 11: Identical Candidates with Different Bases 4160 In this case, the initiating agent is multihomed. It has one IP 4161 address, 10.0.1.100, on network C, which is a net 10 private network. 4162 The responding agent is on this same network. The initiating agent 4163 is also connected to network A, which is 192.168/16 and has an IP 4164 address of 192.168.1.100 on this network. There is a NAT on this 4165 network, natting into network B, which is another net 10 private 4166 network, but not connected to network C. There is a STUN server on 4167 network B. 4169 The initiating agent obtains a host candidate on its IP address on 4170 network C (10.0.1.100:2498) and a host candidate on its IP address on 4171 network A (192.168.1.100:3344). It performs a STUN query to its 4172 configured STUN server from 192.168.1.100:3344. This query passes 4173 through the NAT, which happens to assign the binding 10.0.1.100:2498. 4174 The STUN server reflects this in the STUN Binding response. Now, the 4175 initiating agent has obtained a server reflexive candidate with a 4176 transport address that is identical to a host candidate 4177 (10.0.1.100:2498). However, the server reflexive candidate has a 4178 base of 192.168.1.100:3344, and the host candidate has a base of 4179 10.0.1.100:2498. 4181 B.3. Purpose of the Related Address and Related Port Attributes 4183 The candidate attribute contains two values that are not used at all 4184 by ICE itself -- related address and related port. Why are they 4185 present? 4187 There are two motivations for its inclusion. The first is 4188 diagnostic. It is very useful to know the relationship between the 4189 different types of candidates. By including it, an agent can know 4190 which relayed candidate is associated with which reflexive candidate, 4191 which in turn is associated with a specific host candidate. When 4192 checks for one candidate succeed and not for others, this provides 4193 useful diagnostics on what is going on in the network. 4195 The second reason has to do with off-path Quality of Service (QoS) 4196 mechanisms. When ICE is used in environments such as PacketCable 4197 2.0, proxies will, in addition to performing normal SIP operations, 4198 inspect the SDP in SIP messages, and extract the IP address and port 4199 for media traffic. They can then interact, through policy servers, 4200 with access routers in the network, to establish guaranteed QoS for 4201 the media flows. This QoS is provided by classifying the RTP traffic 4202 based on 5-tuple, and then providing it a guaranteed rate, or marking 4203 its Diffserv codepoints appropriately. When a residential NAT is 4204 present, and a relayed candidate gets selected for media, this 4205 relayed candidate will be a transport address on an actual TURN 4206 server. That address says nothing about the actual transport address 4207 in the access router that would be used to classify packets for QoS 4208 treatment. Rather, the server reflexive candidate towards the TURN 4209 server is needed. By carrying the translation in the SDP, the proxy 4210 can use that transport address to request QoS from the access router. 4212 B.4. Importance of the STUN Username 4214 ICE requires the usage of message integrity with STUN using its 4215 short-term credential functionality. The actual short-term 4216 credential is formed by exchanging username fragments in the 4217 candidate exchange. The need for this mechanism goes beyond just 4218 security; it is actually required for correct operation of ICE in the 4219 first place. 4221 Consider agents L, R, and Z. L and R are within private enterprise 4222 1, which is using 10.0.0.0/8. Z is within private enterprise 2, 4223 which is also using 10.0.0.0/8. As it turns out, R and Z both have 4224 IP address 10.0.1.1. L sends candidates to Z. Z, in responds L with 4225 its host candidates. In this case, those candidates are 4226 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, R is in a session 4227 at that same time, and is also using 10.0.1.1:8866 and 10.0.1.1:8877 4228 as host candidates. This means that R is prepared to accept STUN 4229 messages on those ports, just as Z is. L will send a STUN request to 4230 10.0.1.1:8866 and another to 10.0.1.1:8877. However, these do not go 4231 to Z as expected. Instead, they go to R! If R just replied to them, 4232 L would believe it has connectivity to Z, when in fact it has 4233 connectivity to a completely different user, R. To fix this, the 4234 STUN short-term credential mechanisms are used. The username 4235 fragments are sufficiently random that it is highly unlikely that R 4236 would be using the same values as Z. Consequently, R would reject 4237 the STUN request since the credentials were invalid. In essence, the 4238 STUN username fragments provide a form of transient host identifiers, 4239 bound to a particular session established as part of the candidate 4240 exchange. 4242 An unfortunate consequence of the non-uniqueness of IP addresses is 4243 that, in the above example, R might not even be an ICE agent. It 4244 could be any host, and the port to which the STUN packet is directed 4245 could be any ephemeral port on that host. If there is an application 4246 listening on this socket for packets, and it is not prepared to 4247 handle malformed packets for whatever protocol is in use, the 4248 operation of that application could be affected. Fortunately, since 4249 the ports exchanged are ephemeral and usually drawn from the dynamic 4250 or registered range, the odds are good that the port is not used to 4251 run a server on host R, but rather is the agent side of some 4252 protocol. This decreases the probability of hitting an allocated 4253 port, due to the transient nature of port usage in this range. 4254 However, the possibility of a problem does exist, and network 4255 deployers should be prepared for it. Note that this is not a problem 4256 specific to ICE; stray packets can arrive at a port at any time for 4257 any type of protocol, especially ones on the public Internet. As 4258 such, this requirement is just restating a general design guideline 4259 for Internet applications -- be prepared for unknown packets on any 4260 port. 4262 B.5. The Candidate Pair Priority Formula 4264 The priority for a candidate pair has an odd form. It is: 4266 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 4268 Why is this? When the candidate pairs are sorted based on this 4269 value, the resulting sorting has the MAX/MIN property. This means 4270 that the pairs are first sorted based on decreasing value of the 4271 minimum of the two priorities. For pairs that have the same value of 4272 the minimum priority, the maximum priority is used to sort amongst 4273 them. If the max and the min priorities are the same, the 4274 controlling agent's priority is used as the tie-breaker in the last 4275 part of the expression. The factor of 2*32 is used since the 4276 priority of a single candidate is always less than 2*32, resulting in 4277 the pair priority being a "concatenation" of the two component 4278 priorities. This creates the MAX/MIN sorting. MAX/MIN ensures that, 4279 for a particular agent, a lower-priority candidate is never used 4280 until all higher-priority candidates have been tried. 4282 B.6. Why Are Keepalives Needed? 4284 Once media begins flowing on a candidate pair, it is still necessary 4285 to keep the bindings alive at intermediate NATs for the duration of 4286 the session. Normally, the media stream packets themselves (e.g., 4287 RTP) meet this objective. However, several cases merit further 4288 discussion. Firstly, in some RTP usages, such as SIP, the media 4289 streams can be "put on hold". This is accomplished by using the SDP 4290 "sendonly" or "inactive" attributes, as defined in RFC 3264 4291 [RFC3264]. RFC 3264 directs implementations to cease transmission of 4292 media in these cases. However, doing so may cause NAT bindings to 4293 timeout, and media won't be able to come off hold. 4295 Secondly, some RTP payload formats, such as the payload format for 4296 text conversation [RFC4103], may send packets so infrequently that 4297 the interval exceeds the NAT binding timeouts. 4299 Thirdly, if silence suppression is in use, long periods of silence 4300 may cause media transmission to cease sufficiently long for NAT 4301 bindings to time out. 4303 For these reasons, the media packets themselves cannot be relied 4304 upon. ICE defines a simple periodic keepalive utilizing STUN Binding 4305 indications. This makes its bandwidth requirements highly 4306 predictable, and thus amenable to QoS reservations. 4308 B.7. Why Prefer Peer Reflexive Candidates? 4310 Section 4.1.2 describes procedures for computing the priority of 4311 candidate based on its type and local preferences. That section 4312 requires that the type preference for peer reflexive candidates 4313 always be higher than server reflexive. Why is that? The reason has 4314 to do with the security considerations in Section 13. It is much 4315 easier for an attacker to cause an agent to use a false server 4316 reflexive candidate than it is for an attacker to cause an agent to 4317 use a false peer reflexive candidate. Consequently, attacks against 4318 address gathering with Binding requests are thwarted by ICE by 4319 preferring the peer reflexive candidates. 4321 B.8. Why Are Binding Indications Used for Keepalives? 4323 Media keepalives are described in Section 8. These keepalives make 4324 use of STUN when both endpoints are ICE capable. However, rather 4325 than using a Binding request transaction (which generates a 4326 response), the keepalives use an Indication. Why is that? 4328 The primary reason has to do with network QoS mechanisms. Once media 4329 begins flowing, network elements will assume that the media stream 4330 has a fairly regular structure, making use of periodic packets at 4331 fixed intervals, with the possibility of jitter. If an agent is 4332 sending media packets, and then receives a Binding request, it would 4333 need to generate a response packet along with its media packets. 4334 This will increase the actual bandwidth requirements for the 5-tuple 4335 carrying the media packets, and introduce jitter in the delivery of 4336 those packets. Analysis has shown that this is a concern in certain 4337 layer 2 access networks that use fairly tight packet schedulers for 4338 media. 4340 Additionally, using a Binding Indication allows integrity to be 4341 disabled, allowing for better performance. This is useful for large- 4342 scale endpoints, such as PSTN gateways and SBCs. 4344 Appendix C. Connectivity Check Bandwidth 4346 The tables below show, for IPv4 and IPv6, the bandwidth required for 4347 performing connectivity checks, using different Ta values (given in 4348 ms) and different ufrag sizes (given in bytes). 4350 The results were provided by Jusin Uberti (Google) 11th April 2016. 4352 IP version: IPv4 4353 Packet len (bytes): 108 + ufrag 4354 | 4355 ms | 4 8 12 16 4356 -----|------------------------ 4357 500 | 1.86k 1.98k 2.11k 2.24k 4358 200 | 4.64k 4.96k 5.28k 5.6k 4359 100 | 9.28k 9.92k 10.6k 11.2k 4360 50 | 18.6k 19.8k 21.1k 22.4k 4361 20 | 46.4k 49.6k 52.8k 56.0k 4362 10 | 92.8k 99.2k 105k 112k 4363 5 | 185k 198k 211k 224k 4364 2 | 464k 496k 528k 560k 4365 1 | 928k 992k 1.06M 1.12M 4367 IP version: IPv6 4368 Packet len (bytes): 128 + ufrag 4369 | 4370 ms | 4 8 12 16 4371 -----|------------------------ 4372 500 | 2.18k 2.3k 2.43k 2.56k 4373 200 | 5.44k 5.76k 6.08k 6.4k 4374 100 | 10.9k 11.5k 12.2k 12.8k 4375 50 | 21.8k 23.0k 24.3k 25.6k 4376 20 | 54.4k 57.6k 60.8k 64.0k 4377 10 | 108k 115k 121k 128k 4378 5 | 217k 230k 243k 256k 4379 2 | 544k 576k 608k 640k 4380 1 | 1.09M 1.15M 1.22M 1.28M 4382 Figure 12: Connectivity Check Bandwidth 4384 Authors' Addresses 4386 Ari Keranen 4387 Ericsson 4388 Hirsalantie 11 4389 02420 Jorvas 4390 Finland 4392 Email: ari.keranen@ericsson.com 4393 Christer Holmberg 4394 Ericsson 4395 Hirsalantie 11 4396 02420 Jorvas 4397 Finland 4399 Email: christer.holmberg@ericsson.com 4401 Jonathan Rosenberg 4402 jdrosen.net 4403 Monmouth, NJ 4404 US 4406 Email: jdrosen@jdrosen.net 4407 URI: http://www.jdrosen.net