idnits 2.17.1 draft-ietf-ice-rfc5245bis-02.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 == 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 (June 13, 2016) is 2873 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Obsolete normative reference: RFC 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-08 Summary: 3 errors (**), 0 flaws (~~), 4 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: December 15, 2016 jdrosen.net 7 June 13, 2016 9 Interactive Connectivity Establishment (ICE): A Protocol for Network 10 Address Translator (NAT) Traversal 11 draft-ietf-ice-rfc5245bis-02 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 December 15, 2016. 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 . . . . . . . . . . . . . . . 23 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. Forming Candidate Pairs . . . . . . . . . . . . . 31 100 5.1.3.2. Computing Pair Priority and Ordering Pairs . . . 34 101 5.1.3.3. Pruning the Pairs . . . . . . . . . . . . . . . . 34 102 5.1.3.4. Computing States . . . . . . . . . . . . . . . . 34 103 5.1.4. Scheduling Checks . . . . . . . . . . . . . . . . . . 37 104 5.2. Lite Implementation Procedures . . . . . . . . . . . . . 39 105 6. Performing Connectivity Checks . . . . . . . . . . . . . . . 39 106 6.1. STUN Client Procedures . . . . . . . . . . . . . . . . . 39 107 6.1.1. Creating Permissions for Relayed Candidates . . . . . 39 108 6.1.2. Sending the Request . . . . . . . . . . . . . . . . . 40 109 6.1.2.1. PRIORITY . . . . . . . . . . . . . . . . . . . . 40 110 6.1.2.2. USE-CANDIDATE . . . . . . . . . . . . . . . . . . 40 111 6.1.2.3. ICE-CONTROLLED and ICE-CONTROLLING . . . . . . . 40 112 6.1.2.4. Forming Credentials . . . . . . . . . . . . . . . 41 113 6.1.2.5. DiffServ Treatment . . . . . . . . . . . . . . . 41 114 6.1.3. Processing the Response . . . . . . . . . . . . . . . 41 115 6.1.3.1. Failure Cases . . . . . . . . . . . . . . . . . . 41 116 6.1.3.2. Success Cases . . . . . . . . . . . . . . . . . . 42 117 6.1.3.2.1. Discovering Peer Reflexive Candidates . . . . 42 118 6.1.3.2.2. Constructing a Valid Pair . . . . . . . . . . 43 119 6.1.3.2.3. Updating Pair States . . . . . . . . . . . . 44 120 6.1.3.2.4. Updating the Nominated Flag . . . . . . . . . 45 121 6.1.3.3. Check List and Timer State Updates . . . . . . . 45 122 6.2. STUN Server Procedures . . . . . . . . . . . . . . . . . 46 123 6.2.1. Additional Procedures for Full Implementations . . . 46 124 6.2.1.1. Detecting and Repairing Role Conflicts . . . . . 47 125 6.2.1.2. Computing Mapped Address . . . . . . . . . . . . 48 126 6.2.1.3. Learning Peer Reflexive Candidates . . . . . . . 48 127 6.2.1.4. Triggered Checks . . . . . . . . . . . . . . . . 49 128 6.2.1.5. Updating the Nominated Flag . . . . . . . . . . . 50 129 6.2.2. Additional Procedures for Lite Implementations . . . 50 130 7. Concluding ICE Processing . . . . . . . . . . . . . . . . . . 50 131 7.1. Procedures for Full Implementations . . . . . . . . . . . 51 132 7.1.1. Nominating Pairs . . . . . . . . . . . . . . . . . . 51 133 7.1.2. Updating States . . . . . . . . . . . . . . . . . . . 52 134 7.2. Procedures for Lite Implementations . . . . . . . . . . . 53 135 7.2.1. Peer Is Full . . . . . . . . . . . . . . . . . . . . 53 136 7.2.2. Peer Is Lite . . . . . . . . . . . . . . . . . . . . 53 137 7.3. Freeing Candidates . . . . . . . . . . . . . . . . . . . 54 138 7.3.1. Full Implementation Procedures . . . . . . . . . . . 54 139 7.3.2. Lite Implementation Procedures . . . . . . . . . . . 54 140 8. ICE Restarts . . . . . . . . . . . . . . . . . . . . . . . . 55 141 9. ICE Option . . . . . . . . . . . . . . . . . . . . . . . . . 55 142 10. Keepalives . . . . . . . . . . . . . . . . . . . . . . . . . 56 143 11. Media Handling . . . . . . . . . . . . . . . . . . . . . . . 57 144 11.1. Sending Media . . . . . . . . . . . . . . . . . . . . . 57 145 11.1.1. Procedures for Full Implementations . . . . . . . . 57 146 11.1.2. Procedures for Lite Implementations . . . . . . . . 57 147 11.1.3. Procedures for All Implementations . . . . . . . . . 58 148 11.2. Receiving Media . . . . . . . . . . . . . . . . . . . . 58 149 12. Extensibility Considerations . . . . . . . . . . . . . . . . 58 150 13. Setting Ta and RTO . . . . . . . . . . . . . . . . . . . . . 59 151 13.1. Real-time Media Streams . . . . . . . . . . . . . . . . 60 152 13.2. Non-real-time Sessions . . . . . . . . . . . . . . . . . 61 153 14. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 154 15. Security Considerations . . . . . . . . . . . . . . . . . . . 67 155 15.1. Attacks on Connectivity Checks . . . . . . . . . . . . . 67 156 15.2. Attacks on Server Reflexive Address Gathering . . . . . 69 157 15.3. Attacks on Relayed Candidate Gathering . . . . . . . . . 70 158 15.4. Insider Attacks . . . . . . . . . . . . . . . . . . . . 70 159 15.4.1. STUN Amplification Attack . . . . . . . . . . . . . 71 160 16. STUN Extensions . . . . . . . . . . . . . . . . . . . . . . . 71 161 16.1. New Attributes . . . . . . . . . . . . . . . . . . . . . 71 162 16.2. New Error Response Codes . . . . . . . . . . . . . . . . 72 163 17. Operational Considerations . . . . . . . . . . . . . . . . . 72 164 17.1. NAT and Firewall Types . . . . . . . . . . . . . . . . . 72 165 17.2. Bandwidth Requirements . . . . . . . . . . . . . . . . . 73 166 17.2.1. STUN and TURN Server Capacity Planning . . . . . . . 73 167 17.2.2. Gathering and Connectivity Checks . . . . . . . . . 73 168 17.2.3. Keepalives . . . . . . . . . . . . . . . . . . . . . 74 169 17.3. ICE and ICE-lite . . . . . . . . . . . . . . . . . . . . 74 170 17.4. Troubleshooting and Performance Management . . . . . . . 74 171 17.5. Endpoint Configuration . . . . . . . . . . . . . . . . . 75 172 18. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 75 173 18.1. STUN Attributes . . . . . . . . . . . . . . . . . . . . 75 174 18.2. STUN Error Responses . . . . . . . . . . . . . . . . . . 75 175 18.3. ICE Options . . . . . . . . . . . . . . . . . . . . . . 75 176 19. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 76 177 19.1. Problem Definition . . . . . . . . . . . . . . . . . . . 76 178 19.2. Exit Strategy . . . . . . . . . . . . . . . . . . . . . 77 179 19.3. Brittleness Introduced by ICE . . . . . . . . . . . . . 77 180 19.4. Requirements for a Long-Term Solution . . . . . . . . . 78 181 19.5. Issues with Existing NAPT Boxes . . . . . . . . . . . . 79 182 20. Changes from RFC 5245 . . . . . . . . . . . . . . . . . . . . 79 183 21. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 79 184 22. References . . . . . . . . . . . . . . . . . . . . . . . . . 80 185 22.1. Normative References . . . . . . . . . . . . . . . . . . 80 186 22.2. Informative References . . . . . . . . . . . . . . . . . 80 187 Appendix A. Lite and Full Implementations . . . . . . . . . . . 84 188 Appendix B. Design Motivations . . . . . . . . . . . . . . . . . 85 189 B.1. Pacing of STUN Transactions . . . . . . . . . . . . . . . 85 190 B.2. Candidates with Multiple Bases . . . . . . . . . . . . . 87 191 B.3. Purpose of the Related Address and Related Port 192 Attributes . . . . . . . . . . . . . . . . . . . . . . . 89 194 B.4. Importance of the STUN Username . . . . . . . . . . . . . 89 195 B.5. The Candidate Pair Priority Formula . . . . . . . . . . . 91 196 B.6. Why Are Keepalives Needed? . . . . . . . . . . . . . . . 91 197 B.7. Why Prefer Peer Reflexive Candidates? . . . . . . . . . . 92 198 B.8. Why Are Binding Indications Used for Keepalives? . . . . 92 199 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 92 201 1. Introduction 203 Protocols establishing multimedia sessions between peers typically 204 involve exchanging IP addresses and ports for the media sources and 205 sinks. However this poses challenges when operated through Network 206 Address Translators (NATs) [RFC3235]. These protocols also seek to 207 create a media flow directly between participants, so that there is 208 no application layer intermediary between them. This is done to 209 reduce media latency, decrease packet loss, and reduce the 210 operational costs of deploying the application. However, this is 211 difficult to accomplish through NAT. A full treatment of the reasons 212 for this is beyond the scope of this specification. 214 Numerous solutions have been defined for allowing these protocols to 215 operate through NAT. These include Application Layer Gateways 216 (ALGs), the Middlebox Control Protocol [RFC3303], the original Simple 217 Traversal of UDP Through NAT (STUN) [RFC3489] specification, and 218 Realm Specific IP [RFC3102] [RFC3103] along with session description 219 extensions needed to make them work, such as the Session Description 220 Protocol (SDP) [RFC4566] attribute for the Real Time Control Protocol 221 (RTCP) [RFC3605]. Unfortunately, these techniques all have pros and 222 cons which, make each one optimal in some network topologies, but a 223 poor choice in others. The result is that administrators and 224 implementors are making assumptions about the topologies of the 225 networks in which their solutions will be deployed. This introduces 226 complexity and brittleness into the system. What is needed is a 227 single solution that is flexible enough to work well in all 228 situations. 230 This specification defines Interactive Connectivity Establishment 231 (ICE) as a technique for NAT traversal for UDP-based media streams 232 (though ICE has been extended to handle other transport protocols, 233 such as TCP [RFC6544]). ICE works by exchanging a multiplicity of IP 234 addresses and ports which are then tested for connectivity by peer- 235 to-peer connectivity checks. The IP addresses and ports are 236 exchanged via mechanisms (for example, including in a offer/answer 237 exchange) and the connectivity checks are performed using Session 238 Traversal Utilities for NAT (STUN) specification [RFC5389]. ICE also 239 makes use of Traversal Using Relays around NAT (TURN) [RFC5766], an 240 extension to STUN. Because ICE exchanges a multiplicity of IP 241 addresses and ports for each media stream, it also allows for address 242 selection for multihomed and dual-stack hosts, and for this reason it 243 deprecates [RFC4091] and [RFC4092]. 245 2. Overview of ICE 247 In a typical ICE deployment, we have two endpoints (known as ICE 248 AGENTS) that want to communicate. They are able to communicate 249 indirectly via some signaling protocol (such as SIP), by which they 250 can exchange ICE candidates. Note that ICE is not intended for NAT 251 traversal for the signaling protocol, which is assumed to be provided 252 via another mechanism. At the beginning of the ICE process, the 253 agents are ignorant of their own topologies. In particular, they 254 might or might not be behind a NAT (or multiple tiers of NATs). ICE 255 allows the agents to discover enough information about their 256 topologies to potentially find one or more paths by which they can 257 communicate. 259 Figure 1 shows a typical environment for ICE deployment. The two 260 endpoints are labelled L and R (for left and right, which helps 261 visualize call flows). Both L and R are behind their own respective 262 NATs though they may not be aware of it. The type of NAT and its 263 properties are also unknown. Agents L and R are capable of engaging 264 in an candidate exchange process, whose purpose is to set up a media 265 session between L and R. Typically, this exchange will occur through 266 a signaling (e.g., SIP) server. 268 In addition to the agents, a signaling server and NATs, ICE is 269 typically used in concert with STUN or TURN servers in the network. 270 Each agent can have its own STUN or TURN server, or they can be the 271 same. 273 +---------+ 274 +--------+ |Signaling| +--------+ 275 | STUN | |Server | | STUN | 276 | Server | +---------+ | Server | 277 +--------+ / \ +--------+ 278 / \ 279 / \ 280 / <- Signaling -> \ 281 / \ 282 +--------+ +--------+ 283 | NAT | | NAT | 284 +--------+ +--------+ 285 / \ 286 / \ 287 +-------+ +-------+ 288 | Agent | | Agent | 289 | L | | R | 290 +-------+ +-------+ 292 Figure 1: ICE Deployment Scenario 294 The basic idea behind ICE is as follows: each agent has a variety of 295 candidate TRANSPORT ADDRESSES (combination of IP address and port for 296 a particular transport protocol, which is always UDP in this 297 specification) it could use to communicate with the other agent. 298 These might include: 300 o A transport address on a directly attached network interface 302 o A translated transport address on the public side of a NAT (a 303 "server reflexive" address) 305 o A transport address allocated from a TURN server (a "relayed 306 address") 308 Potentially, any of L's candidate transport addresses can be used to 309 communicate with any of R's candidate transport addresses. In 310 practice, however, many combinations will not work. For instance, if 311 L and R are both behind NATs, their directly attached interface 312 addresses are unlikely to be able to communicate directly (this is 313 why ICE is needed, after all!). The purpose of ICE is to discover 314 which pairs of addresses will work. The way that ICE does this is to 315 systematically try all possible pairs (in a carefully sorted order) 316 until it finds one or more that work. 318 2.1. Gathering Candidate Addresses 320 In order to execute ICE, an agent has to identify all of its address 321 candidates. A CANDIDATE is a transport address -- a combination of 322 IP address and port for a particular transport protocol (with only 323 UDP specified here). This document defines three types of 324 candidates, some derived from physical or logical network interfaces, 325 others discoverable via STUN and TURN. Naturally, one viable 326 candidate is a transport address obtained directly from a local 327 interface. Such a candidate is called a HOST CANDIDATE. The local 328 interface could be Ethernet or WiFi, or it could be one that is 329 obtained through a tunnel mechanism, such as a Virtual Private 330 Network (VPN) or Mobile IP (MIP). In all cases, such a network 331 interface appears to the agent as a local interface from which ports 332 (and thus candidates) can be allocated. 334 If an agent is multihomed, it obtains a candidate from each IP 335 address. Depending on the location of the PEER (the other agent in 336 the session) on the IP network relative to the agent, the agent may 337 be reachable by the peer through one or more of those IP addresses. 338 Consider, for example, an agent that has a local IP address on a 339 private net 10 network (I1), and a second connected to the public 340 Internet (I2). A candidate from I1 will be directly reachable when 341 communicating with a peer on the same private net 10 network, while a 342 candidate from I2 will be directly reachable when communicating with 343 a peer on the public Internet. Rather than trying to guess which IP 344 address will work, the initiating sends both the candidates to its 345 peer. 347 Next, the agent uses STUN or TURN to obtain additional candidates. 348 These come in two flavors: translated addresses on the public side of 349 a NAT (SERVER REFLEXIVE CANDIDATES) and addresses on TURN servers 350 (RELAYED CANDIDATES). When TURN servers are utilized, both types of 351 candidates are obtained from the TURN server. If only STUN servers 352 are utilized, only server reflexive candidates are obtained from 353 them. The relationship of these candidates to the host candidate is 354 shown in Figure 2. In this figure, both types of candidates are 355 discovered using TURN. In the figure, the notation X:x means IP 356 address X and UDP port x. 358 To Internet 360 | 361 | 362 | /------------ Relayed 363 Y:y | / Address 364 +--------+ 365 | | 366 | TURN | 367 | Server | 368 | | 369 +--------+ 370 | 371 | 372 | /------------ Server 373 X1':x1'|/ Reflexive 374 +------------+ Address 375 | NAT | 376 +------------+ 377 | 378 | /------------ Local 379 X:x |/ Address 380 +--------+ 381 | | 382 | Agent | 383 | | 384 +--------+ 386 Figure 2: Candidate Relationships 388 When the agent sends the TURN Allocate request from IP address and 389 port X:x, the NAT (assuming there is one) will create a binding 390 X1':x1', mapping this server reflexive candidate to the host 391 candidate X:x. Outgoing packets sent from the host candidate will be 392 translated by the NAT to the server reflexive candidate. Incoming 393 packets sent to the server reflexive candidate will be translated by 394 the NAT to the host candidate and forwarded to the agent. We call 395 the host candidate associated with a given server reflexive candidate 396 the BASE. 398 Note: "Base" refers to the address an agent sends from for a 399 particular candidate. Thus, as a degenerate case host candidates 400 also have a base, but it's the same as the host candidate. 402 When there are multiple NATs between the agent and the TURN server, 403 the TURN request will create a binding on each NAT, but only the 404 outermost server reflexive candidate (the one nearest the TURN 405 server) will be discovered by the agent. If the agent is not behind 406 a NAT, then the base candidate will be the same as the server 407 reflexive candidate and the server reflexive candidate is redundant 408 and will be eliminated. 410 The Allocate request then arrives at the TURN server. The TURN 411 server allocates a port y from its local IP address Y, and generates 412 an Allocate response, informing the agent of this relayed candidate. 413 The TURN server also informs the agent of the server reflexive 414 candidate, X1':x1' by copying the source transport address of the 415 Allocate request into the Allocate response. The TURN server acts as 416 a packet relay, forwarding traffic between L and R. In order to send 417 traffic to L, R sends traffic to the TURN server at Y:y, and the TURN 418 server forwards that to X1':x1', which passes through the NAT where 419 it is mapped to X:x and delivered to L. 421 When only STUN servers are utilized, the agent sends a STUN Binding 422 request [RFC5389] to its STUN server. The STUN server will inform 423 the agent of the server reflexive candidate X1':x1' by copying the 424 source transport address of the Binding request into the Binding 425 response. 427 2.2. Connectivity Checks 429 Once L has gathered all of its candidates, it orders them in highest 430 to lowest-priority and sends them to R over the signaling channel. 431 When R receives the candidates from L, it performs the same gathering 432 process and responds with its own list of candidates. At the end of 433 this process, each agent has a complete list of both its candidates 434 and its peer's candidates. It pairs them up, resulting in CANDIDATE 435 PAIRS. To see which pairs work, each agent schedules a series of 436 CHECKS. Each check is a STUN request/response transaction that the 437 client will perform on a particular candidate pair by sending a STUN 438 request from the local candidate to the remote candidate. 440 The basic principle of the connectivity checks is simple: 442 1. Sort the candidate pairs in priority order. 444 2. Send checks on each candidate pair in priority order. 446 3. Acknowledge checks received from the other agent. 448 With both agents performing a check on a candidate pair, the result 449 is a 4-way handshake: 451 L R 452 - - 453 STUN request -> \ L's 454 <- STUN response / check 456 <- STUN request \ R's 457 STUN response -> / check 459 Figure 3: Basic Connectivity Check 461 It is important to note that the STUN requests are sent to and from 462 the exact same IP addresses and ports that will be used for media 463 (e.g., RTP and RTCP). Consequently, agents demultiplex STUN and RTP/ 464 RTCP using contents of the packets, rather than the port on which 465 they are received. Fortunately, this demultiplexing is easy to do, 466 especially for RTP and RTCP. 468 Because a STUN Binding request is used for the connectivity check, 469 the STUN Binding response will contain the agent's translated 470 transport address on the public side of any NATs between the agent 471 and its peer. If this transport address is different from other 472 candidates the agent already learned, it represents a new candidate, 473 called a PEER REFLEXIVE CANDIDATE, which then gets tested by ICE just 474 the same as any other candidate. 476 As an optimization, as soon as R gets L's check message, R schedules 477 a connectivity check message to be sent to L on the same candidate 478 pair. This accelerates the process of finding a valid candidate, and 479 is called a TRIGGERED CHECK. 481 At the end of this handshake, both L and R know that they can send 482 (and receive) messages end-to-end in both directions. 484 2.3. Sorting Candidates 486 Because the algorithm above searches all candidate pairs, if a 487 working pair exists it will eventually find it no matter what order 488 the candidates are tried in. In order to produce faster (and better) 489 results, the candidates are sorted in a specified order. The 490 resulting list of sorted candidate pairs is called the CHECK LIST. 491 The algorithm is described in Section 4.1.2 but follows two general 492 principles: 494 o Each agent gives its candidates a numeric priority, which is sent 495 along with the candidate to the peer. 497 o The local and remote priorities are combined so that each agent 498 has the same ordering for the candidate pairs. 500 The second property is important for getting ICE to work when there 501 are NATs in front of L and R. Frequently, NATs will not allow 502 packets in from a host until the agent behind the NAT has sent a 503 packet towards that host. Consequently, ICE checks in each direction 504 will not succeed until both sides have sent a check through their 505 respective NATs. 507 The agent works through this check list by sending a STUN request for 508 the next candidate pair on the list periodically. These are called 509 ORDINARY CHECKS. 511 In general, the priority algorithm is designed so that candidates of 512 similar type get similar priorities and so that more direct routes 513 (that is, through fewer media relays and through fewer NATs) are 514 preferred over indirect ones (ones with more media relays and more 515 NATs). Within those guidelines, however, agents have a fair amount 516 of discretion about how to tune their algorithms. 518 2.4. Frozen Candidates 520 The previous description only addresses the case where the agents 521 wish to establish a media session with one COMPONENT (a piece of a 522 media stream requiring a single transport address; a media stream may 523 require multiple components, each of which has to work for the media 524 stream as a whole to be work). Sometimes (e.g., with RTP and RTCP in 525 separate components), the agents actually need to establish 526 connectivity for more than one flow. 528 The network properties are likely to be very similar for each 529 component (especially because RTP and RTCP are sent and received from 530 the same IP address). It is usually possible to leverage information 531 from one media component in order to determine the best candidates 532 for another. ICE does this with a mechanism called "frozen 533 candidates". 535 Each candidate is associated with a property called its FOUNDATION. 536 Two candidates have the same foundation when they are "similar" -- of 537 the same type and obtained from the same host candidate and STUN/TURN 538 server using the same protocol. Otherwise, their foundation is 539 different. A candidate pair has a foundation too, which is just the 540 concatenation of the foundations of its two candidates. Initially, 541 only the candidate pairs with unique foundations are tested. The 542 other candidate pairs are marked "frozen". When the connectivity 543 checks for a candidate pair succeed, the other candidate pairs with 544 the same foundation are unfrozen. This avoids repeated checking of 545 components that are superficially more attractive but in fact are 546 likely to fail. 548 While we've described "frozen" here as a separate mechanism for 549 expository purposes, in fact it is an integral part of ICE and the 550 ICE prioritization algorithm automatically ensures that the right 551 candidates are unfrozen and checked in the right order. However, if 552 the ICE usage does not utilize multiple components or media streams, 553 it does not need to implement this algorithm. 555 2.5. Security for Checks 557 Because ICE is used to discover which addresses can be used to send 558 media between two agents, it is important to ensure that the process 559 cannot be hijacked to send media to the wrong location. Each STUN 560 connectivity check is covered by a message authentication code (MAC) 561 computed using a key exchanged in the signaling channel. This MAC 562 provides message integrity and data origin authentication, thus 563 stopping an attacker from forging or modifying connectivity check 564 messages. Furthermore, if for example a SIP [RFC3261] caller is 565 using ICE, and their call forks, the ICE exchanges happen 566 independently with each forked recipient. In such a case, the keys 567 exchanged in the signaling help associate each ICE exchange with each 568 forked recipient. 570 2.6. Concluding ICE 572 ICE checks are performed in a specific sequence, so that high- 573 priority candidate pairs are checked first, followed by lower- 574 priority ones. One way to conclude ICE is to declare victory as soon 575 as a check for each component of each media stream completes 576 successfully. Indeed, this is a reasonable algorithm, and details 577 for it are provided below. However, it is possible that a packet 578 loss will cause a higher-priority check to take longer to complete. 579 In that case, allowing ICE to run a little longer might produce 580 better results. More fundamentally, however, the prioritization 581 defined by this specification may not yield "optimal" results. As an 582 example, if the aim is to select low-latency media paths, usage of a 583 relay is a hint that latencies may be higher, but it is nothing more 584 than a hint. An actual round-trip time (RTT) measurement could be 585 made, and it might demonstrate that a pair with lower priority is 586 actually better than one with higher priority. 588 Consequently, ICE assigns one of the agents in the role of the 589 CONTROLLING AGENT, and the other of the CONTROLLED AGENT. The 590 controlling agent gets to nominate which candidate pairs will get 591 used for media amongst the ones that are valid. 593 When nominating, the controlling agent lets the checks continue until 594 at least one valid candidate pair for each media stream is found. 595 Then, it picks amongst those that are valid, and sends a second STUN 596 request on its NOMINATED candidate pair, but this time with a flag 597 set to tell the peer that this pair has been nominated for use. This 598 is shown in Figure 4. 600 L R 601 - - 602 STUN request -> \ L's 603 <- STUN response / check 605 <- STUN request \ R's 606 STUN response -> / check 608 STUN request + flag -> \ L's 609 <- STUN response / check 611 Figure 4: Nomination 613 Once the STUN transaction with the flag completes, both sides cancel 614 any future checks for that media stream. ICE will now send media 615 using this pair. The pair an ICE agent is using for media is called 616 the SELECTED PAIR. 618 Once ICE is concluded, it can be restarted at any time for one or all 619 of the media streams by either agent. This is done by sending an 620 updated candidate information indicating a restart. 622 2.7. Lite Implementations 624 In order for ICE to be used in a call, both agents need to support 625 it. However, certain agents will always be connected to the public 626 Internet and have a public IP address at which it can receive packets 627 from any correspondent. To make it easier for these devices to 628 support ICE, ICE defines a special type of implementation called LITE 629 (in contrast to the normal FULL implementation). A lite 630 implementation doesn't gather candidates; it includes only host 631 candidates for any media stream. Lite agents do not generate 632 connectivity checks or run the state machines, though they need to be 633 able to respond to connectivity checks. When a lite implementation 634 connects with a full implementation, the full agent takes the role of 635 the controlling agent, and the lite agent takes on the controlled 636 role. When two lite implementations connect, no checks are sent. 638 For guidance on when a lite implementation is appropriate, see the 639 discussion in Appendix A. 641 It is important to note that the lite implementation was added to 642 this specification to provide a stepping stone to full 643 implementation. Even for devices that are always connected to the 644 public Internet, a full implementation is preferable if achievable. 646 2.8. Usages of ICE 648 This document specifies generic use of ICE with protocols that 649 provide means to exchange candidate information between the ICE 650 Peers. The specific details of (i.e how to encode candidate 651 information and the actual candidate exchange process) for different 652 protocols using ICE are described in separate usage documents. One 653 possible way the agents can exchange the candidate information is to 654 use [RFC3264] based Offer/Answer semantics as part of the SIP 655 [RFC3261] protocol [I-D.ietf-mmusic-ice-sip-sdp]. 657 3. Terminology 659 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 660 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 661 "OPTIONAL" in this document are to be interpreted as described in RFC 662 2119 [RFC2119]. 664 Readers should be familiar with the terminology defined in the STUN 665 [RFC5389], and NAT Behavioral requirements for UDP [RFC4787]. 667 This specification makes use of the following additional terminology: 669 ICE Agent: An agent is the protocol implementation involved in the 670 ICE candidate exchange. There are two agents involved in a 671 typical candidate exchange. 673 Initiating Peer, Initiating Agent, Initiator: An initiating agent is 674 the protocol implementation involved in the ICE candidate exchange 675 that initiates the ICE candidate exchange process. 677 Responding Peer, Responding Agent, Responder: A receiving agent is 678 the protocol implementation involved in the ICE candidate exchange 679 that receives and responds to the candidate exchange process 680 initiated by the Initiator. 682 ICE Candidate Exchange, Candidate Exchange: The process where the 683 ICE agents exchange information (e.g., candidates and passwords) 684 that is needed to perform ICE. [RFC3264] Offer/Answer with SDP 685 encoding is one example of a protocol that can be used for 686 exchanging the candidate information. 688 Peer: From the perspective of one of the agents in a session, its 689 peer is the other agent. Specifically, from the perspective of 690 the initiating agent, the peer is the responding agent. From the 691 perspective of the responding agent, the peer is the initiating 692 agent. 694 Transport Address: The combination of an IP address and transport 695 protocol (such as UDP or TCP) port. 697 Media, Media Stream, Media Session: When ICE is used to setup 698 multimedia sessions, the media is usually transported over RTP, 699 and a media stream composes of a stream of RTP packets. When ICE 700 is used with other than multimedia sessions, the terms "media", 701 "media stream", and "media session" are still used in this 702 specification to refer to the IP data packets that are exchanged 703 between the peers on the path created and tested with ICE. 705 Candidate, Candidate Information: A transport address that is a 706 potential point of contact for receipt of media. Candidates also 707 have properties -- their type (server reflexive, relayed, or 708 host), priority,foundation, and base. 710 Component: A component is a piece of a media stream requiring a 711 single transport address; a media stream may require multiple 712 components, each of which has to work for the media stream as a 713 whole to work. For media streams based on RTP, unless RTP and 714 RTCP are multiplexed in the same port, there are two components 715 per media stream -- one for RTP, and one for RTCP. 717 Host Candidate: A candidate obtained by binding to a specific port 718 from an IP address on the host. This includes IP addresses on 719 physical interfaces and logical ones, such as ones obtained 720 through Virtual Private Networks (VPNs) and Realm Specific IP 721 (RSIP) [RFC3102] (which lives at the operating system level). 723 Server Reflexive Candidate: A candidate whose IP address and port 724 are a binding allocated by a NAT for an agent when it sent a 725 packet through the NAT to a server. Server reflexive candidates 726 can be learned by STUN servers using the Binding request, or TURN 727 servers, which provides both a relayed and server reflexive 728 candidate. 730 Peer Reflexive Candidate: A candidate whose IP address and port are 731 a binding allocated by a NAT for an agent when it sent a STUN 732 Binding request through the NAT to its peer. 734 Relayed Candidate: A candidate obtained by sending a TURN Allocate 735 request from a host candidate to a TURN server. The relayed 736 candidate is resident on the TURN server, and the TURN server 737 relays packets back towards the agent. 739 Base: The base of a server reflexive candidate is the host candidate 740 from which it was derived. A host candidate is also said to have 741 a base, equal to that candidate itself. Similarly, the base of a 742 relayed candidate is that candidate itself. 744 Foundation: An arbitrary string that is the same for two candidates 745 that have the same type, base IP address, protocol (UDP, TCP, 746 etc.), and STUN or TURN server. If any of these are different, 747 then the foundation will be different. Two candidate pairs with 748 the same foundation pairs are likely to have similar network 749 characteristics. Foundations are used in the frozen algorithm. 751 Local Candidate: A candidate that an agent has obtained and shared 752 with the peer. 754 Remote Candidate: A candidate that an agent received from its peer. 756 Default Destination/Candidate: The default destination for a 757 component of a media stream is the transport address that would be 758 used by an agent that is not ICE aware. A default candidate for a 759 component is one whose transport address matches the default 760 destination for that component. 762 Candidate Pair: A pairing containing a local candidate and a remote 763 candidate. 765 Check, Connectivity Check, STUN Check: A STUN Binding request 766 transaction for the purposes of verifying connectivity. A check 767 is sent from the local candidate to the remote candidate of a 768 candidate pair. 770 Check List: An ordered set of candidate pairs that an agent will use 771 to generate checks. 773 Ordinary Check: A connectivity check generated by an agent as a 774 consequence of a timer that fires periodically, instructing it to 775 send a check. 777 Triggered Check: A connectivity check generated as a consequence of 778 the receipt of a connectivity check from the peer. 780 Valid List: An ordered set of candidate pairs for a media stream 781 that have been validated by a successful STUN transaction. 783 Full: An ICE implementation that performs the complete set of 784 functionality defined by this specification. 786 Lite: An ICE implementation that omits certain functions, 787 implementing only as much as is necessary for a peer 788 implementation that is full to gain the benefits of ICE. Lite 789 implementations do not maintain any of the state machines and do 790 not generate connectivity checks. 792 Controlling Agent: The ICE agent that is responsible for selecting 793 the final choice of candidate pairs and signaling them through 794 STUN. In any session, one agent is always controlling. The other 795 is the controlled agent. 797 Controlled Agent: An ICE agent that waits for the controlling agent 798 to select the final choice of candidate pairs. 800 Nomination, Regular Nomination: The process of picking a valid 801 candidate pair for media traffic by validating the pair with one 802 STUN request, and then picking it by sending a second STUN request 803 with a flag indicating its nomination. 805 Nominated: If a valid candidate pair has its nominated flag set, it 806 means that it may be selected by ICE for sending and receiving 807 media. 809 Selected Pair, Selected Candidate: The candidate pair selected by 810 ICE for sending and receiving media is called the selected pair, 811 and each of its candidates is called the selected candidate. 813 Using Protocol, ICE Usage: The protocol that uses ICE for NAT 814 traversal. A usage specification defines the protocol specific 815 details on how the procedures defined here are applied to that 816 protocol. 818 4. ICE Candidate Gathering and Exchange 820 As part of ICE processing, both the initiating and responding agents 821 exchange encoded candidate information as defined by the Usage 822 Protocol (ICE Usage). Specifics of encoding mechanism and the 823 semantics of candidate information exchange is out of scope of this 824 specification. 826 However at a higher level, the below diagram captures ICE processing 827 sequence in the agents (initiator and responder) for exchange of 828 their respective candidate(s) information. 830 Initiating Responding 831 Agent Agent 832 (I) (R) 833 Gather, | | 834 prioritize, | | 835 eliminate | | 836 redundant | | 837 candidates, | | 838 Encode | | 839 candidates | | 840 | I's Candidate Information | 841 |------------------------------>| 842 | | Gather, 843 | | prioritize, 844 | | eliminate 845 | | redundant 846 | | candidates, 847 | | Encode 848 | | candidates 849 | R's Candidate Information | 850 |<------------------------------| 851 | | 853 Figure 5: Candidate Gathering and Exchange Sequence 855 As shown, the agents involved in the candidate exchange perform (1) 856 candidate gathering, (2) candidate prioritization, (3) eliminating 857 redundant candidates, (4) (possibly) choose default candidates, and 858 then (5) formulate and send the candidates to the Peer ICE agent. 859 All but the last of these five steps differ for full and lite 860 implementations. 862 4.1. Procedures for Full Implementation 864 4.1.1. Gathering Candidates 866 An agent gathers candidates when it believes that communication is 867 imminent. An initiating agent can do this based on a user interface 868 cue, or based on an explicit request to initiate a session. Every 869 candidate is a transport address. It also has a type and a base. 870 Four types are defined and gathered by this specification -- host 871 candidates, server reflexive candidates, peer reflexive candidates, 872 and relayed candidates. The server reflexive candidates are gathered 873 using STUN or TURN, and relayed candidates are obtained through TURN. 874 Peer reflexive candidates are obtained in later phases of ICE, as a 875 consequence of connectivity checks. The base of a candidate is the 876 candidate that an agent must send from when using that candidate. 878 The process for gathering candidates at the responding agent is 879 identical to the process for the initiating agent. It is RECOMMENDED 880 that the responding agent begins this process immediately on receipt 881 of the candidate information, prior to alerting the user. Such 882 gathering MAY begin when an agent starts. 884 4.1.1.1. Host Candidates 886 The first step is to gather host candidates. Host candidates are 887 obtained by binding to ports (typically ephemeral) on a IP address 888 attached to an interface (physical or virtual, including VPN 889 interfaces) on the host. 891 For each UDP media stream the agent wishes to use, the agent SHOULD 892 obtain a candidate for each component of the media stream on each IP 893 address that the host has, with the exceptions listed below. The 894 agent obtains each candidate by binding to a UDP port on the specific 895 IP address. A host candidate (and indeed every candidate) is always 896 associated with a specific component for which it is a candidate. 898 Each component has an ID assigned to it, called the component ID. 899 For RTP-based media streams, unless both RTP and RTCP are multiplexed 900 in the same UDP port (RTP/RTCP multiplexing), the RTP itself has a 901 component ID of 1, and RTCP a component ID of 2. In case of RTP/RTCP 902 multiplexing, a component ID of 1 is used for both RTP and RTCP. 904 When candidates are obtained, unless the agent knows for sure that 905 RTP/RTCP multiplexing will be used (i.e. the agent knows that the 906 other agent also supports, and is willing to use, RTP/RTCP 907 multiplexing), or unless the agent only supports RTP/RTCP 908 multiplexing, the agent MUST obtain a separate candidate for RTCP. 909 If an agent has obtained a candidate for RTCP, and ends up using RTP/ 910 RTCP multiplexing, the agent does not need to perform connectivity 911 checks on the RTCP candidate. 913 If an agent is using separate candidates for RTP and RTCP, it will 914 end up with 2*K host candidates if an agent has K IP addresses. 916 Note that the responding agent, when obtaining its candidates, will 917 typically know if the other agent supports RTP/RTCP multiplexing, in 918 which case it will not need to obtain a separate candidate for RTCP. 919 However, absence of a component ID 2 as such does not imply use of 920 RTCP/RTP multiplexing, as it could also mean that RTCP is not used. 922 For other than RTP-based streams, use of multiple components is 923 discouraged since using them increases the complexity of ICE 924 processing. If multiple components are needed, the component IDs 925 SHOULD start with 1 and increase by 1 for each component. 927 The base for each host candidate is set to the candidate itself. 929 The host candidates are gathered from all IP addresses with the 930 following exceptions: 932 o Addresses from a loopback interface MUST NOT be included in the 933 candidate addresses. 935 o Deprecated IPv4-compatible IPv6 addresses [RFC4291] and IPv6 site- 936 local unicast addresses [RFC3879] MUST NOT be included in the 937 address candidates. 939 o IPv4-mapped IPv6 addresses SHOULD NOT be included in the offered 940 candidates unless the application using ICE does not support IPv4 941 (i.e., is an IPv6-only application [RFC4038]). 943 o If one or more host candidates corresponding to an IPv6 address 944 generated using a mechanism that prevents location tracking 945 [I-D.ietf-6man-ipv6-address-generation-privacy] are gathered, host 946 candidates corresponding to IPv6 addresses that do allow location 947 tracking, that are configured on the same interface, and are part 948 of the same network prefix MUST NOT be gathered; and host 949 candidates corresponding to IPv6 link-local addresses MUST NOT be 950 gathered. 952 4.1.1.2. Server Reflexive and Relayed Candidates 954 Agents SHOULD obtain relayed candidates and SHOULD obtain server 955 reflexive candidates. These requirements are at SHOULD strength to 956 allow for provider variation. Use of STUN and TURN servers may be 957 unnecessary in closed networks where agents are never connected to 958 the public Internet or to endpoints outside of the closed network. 959 In such cases, a full implementation would be used for agents that 960 are dual-stack or multihomed, to select a host candidate. Use of 961 TURN servers is expensive, and when ICE is being used, they will only 962 be utilized when both endpoints are behind NATs that perform address 963 and port dependent mapping. Consequently, some deployments might 964 consider this use case to be marginal, and elect not to use TURN 965 servers. If an agent does not gather server reflexive or relayed 966 candidates, it is RECOMMENDED that the functionality be implemented 967 and just disabled through configuration, so that it can be re-enabled 968 through configuration if conditions change in the future. 970 If an agent is gathering both relayed and server reflexive 971 candidates, it uses a TURN server. If it is gathering just server 972 reflexive candidates, it uses a STUN server. 974 The agent next pairs each host candidate with the STUN or TURN server 975 with which it is configured or has discovered by some means. If a 976 STUN or TURN server is configured, it is RECOMMENDED that a domain 977 name be configured, and the DNS procedures in [RFC5389] (using SRV 978 records with the "stun" service) be used to discover the STUN server, 979 and the DNS procedures in [RFC5766] (using SRV records with the 980 "turn" service) be used to discover the TURN server. 982 This specification only considers usage of a single STUN or TURN 983 server. When there are multiple choices for that single STUN or TURN 984 server (when, for example, they are learned through DNS records and 985 multiple results are returned), an agent SHOULD use a single STUN or 986 TURN server (based on its IP address) for all candidates for a 987 particular session. This improves the performance of ICE. The 988 result is a set of pairs of host candidates with STUN or TURN 989 servers. The agent then chooses one pair, and sends a Binding or 990 Allocate request to the server from that host candidate. Binding 991 requests to a STUN server are not authenticated, and any ALTERNATE- 992 SERVER attribute in a response is ignored. Agents MUST support the 993 backwards compatibility mode for the Binding request defined in 994 [RFC5389]. Allocate requests SHOULD be authenticated using a long- 995 term credential obtained by the client through some other means. 997 Every Ta milliseconds thereafter, the agent can generate another new 998 STUN or TURN transaction. This transaction can either be a retry of 999 a previous transaction that failed with a recoverable error (such as 1000 authentication failure), or a transaction for a new host candidate 1001 and STUN or TURN server pair. The agent SHOULD NOT generate 1002 transactions more frequently than one every Ta milliseconds. See 1003 Section 13 for guidance on how to set Ta and the STUN retransmit 1004 timer, RTO. 1006 The agent will receive a Binding or Allocate response. A successful 1007 Allocate response will provide the agent with a server reflexive 1008 candidate (obtained from the mapped address) and a relayed candidate 1009 in the XOR-RELAYED-ADDRESS attribute. If the Allocate request is 1010 rejected because the server lacks resources to fulfill it, the agent 1011 SHOULD instead send a Binding request to obtain a server reflexive 1012 candidate. A Binding response will provide the agent with only a 1013 server reflexive candidate (also obtained from the mapped address). 1014 The base of the server reflexive candidate is the host candidate from 1015 which the Allocate or Binding request was sent. The base of a 1016 relayed candidate is that candidate itself. If a relayed candidate 1017 is identical to a host candidate (which can happen in rare cases), 1018 the relayed candidate MUST be discarded. 1020 If an IPv6-only agent is in a network that utilizes NAT64 [RFC6146] 1021 and DNS64 [RFC6147] technologies, it may gather also IPv4 server 1022 reflexive and/or relayed candidates from IPv4-only STUN or TURN 1023 servers. IPv6-only agents SHOULD also utilize IPv6 prefix discovery 1024 [RFC7050] to discover the IPv6 prefix used by NAT64 (if any) and 1025 generate server reflexive candidates for each IPv6-only interface 1026 accordingly. The NAT64 server reflexive candidates are prioritized 1027 like IPv4 server reflexive candidates. 1029 4.1.1.3. Computing Foundations 1031 Finally, the agent assigns each candidate a foundation. The 1032 foundation is an identifier, scoped within a session. Two candidates 1033 MUST have the same foundation ID when all of the following are true: 1035 o they are of the same type (host, relayed, server reflexive, or 1036 peer reflexive) 1038 o their bases have the same IP address (the ports can be different) 1040 o for reflexive and relayed candidates, the STUN or TURN servers 1041 used to obtain them have the same IP address 1043 o they were obtained using the same transport protocol (TCP, UDP, 1044 etc.) 1046 Similarly, two candidates MUST have different foundations if their 1047 types are different, their bases have different IP addresses, the 1048 STUN or TURN servers used to obtain them have different IP addresses, 1049 or their transport protocols are different. 1051 4.1.1.4. Keeping Candidates Alive 1053 Once server reflexive and relayed candidates are allocated, they MUST 1054 be kept alive until ICE processing has completed, as described in 1055 Section 7.3. For server reflexive candidates learned through a 1056 Binding request, the bindings MUST be kept alive by additional 1057 Binding requests to the server. Refreshes for allocations are done 1058 using the Refresh transaction, as described in [RFC5766]. The 1059 Refresh requests will also refresh the server reflexive candidate. 1061 4.1.2. Prioritizing Candidates 1063 The prioritization process results in the assignment of a priority to 1064 each candidate. Each candidate for a media stream MUST have a unique 1065 priority that MUST be a positive integer between 1 and (2**31 - 1). 1066 This priority will be used by ICE to determine the order of the 1067 connectivity checks and the relative preference for candidates. 1069 An agent SHOULD compute this priority using the formula in 1070 Section 4.1.2.1 and choose its parameters using the guidelines in 1071 Section 4.1.2.2. If an agent elects to use a different formula, ICE 1072 will take longer to converge since both agents will not be 1073 coordinated in their checks. 1075 The process for prioritizing candidates is common across the 1076 initiating and the responding agent. 1078 4.1.2.1. Recommended Formula 1080 When using the formula, an agent computes the priority by determining 1081 a preference for each type of candidate (server reflexive, peer 1082 reflexive, relayed, and host), and, when the agent is multihomed, 1083 choosing a preference for its IP addresses. These two preferences 1084 are then combined to compute the priority for a candidate. That 1085 priority is computed using the following formula: 1087 priority = (2^24)*(type preference) + 1088 (2^8)*(local preference) + 1089 (2^0)*(256 - component ID) 1091 The type preference MUST be an integer from 0 to 126 inclusive, and 1092 represents the preference for the type of the candidate (where the 1093 types are local, server reflexive, peer reflexive, and relayed). A 1094 126 is the highest preference, and a 0 is the lowest. Setting the 1095 value to a 0 means that candidates of this type will only be used as 1096 a last resort. The type preference MUST be identical for all 1097 candidates of the same type and MUST be different for candidates of 1098 different types. The type preference for peer reflexive candidates 1099 MUST be higher than that of server reflexive candidates. Note that 1100 candidates gathered based on the procedures of Section 4.1.1 will 1101 never be peer reflexive candidates; candidates of these type are 1102 learned from the connectivity checks performed by ICE. 1104 The local preference MUST be an integer from 0 to 65535 inclusive. 1105 It represents a preference for the particular IP address from which 1106 the candidate was obtained. 65535 represents the highest preference, 1107 and a zero, the lowest. When there is only a single IP address, this 1108 value SHOULD be set to 65535. More generally, if there are multiple 1109 candidates for a particular component for a particular media stream 1110 that have the same type, the local preference MUST be unique for each 1111 one. In this specification, this only happens for multihomed hosts 1112 or if an agent is using multiple TURN servers. If a host is 1113 multihomed because it is dual-stack, the local preference SHOULD be 1114 set equal to the precedence value for IP addresses described in RFC 1115 6724 [RFC6724]. If the host operating system provides an API for 1116 discovering preference among different addresses, those preferences 1117 SHOULD be used for the local preference to prioritize addresses 1118 indicated as preferred by the operating system. 1120 The component ID is the component ID for the candidate, and MUST be 1121 between 1 and 256 inclusive. 1123 4.1.2.2. Guidelines for Choosing Type and Local Preferences 1125 One criterion for selection of the type and local preference values 1126 is the use of a media intermediary, such as a TURN server, VPN 1127 server, or NAT. With a media intermediary, if media is sent to that 1128 candidate, it will first transit the media intermediary before being 1129 received. Relayed candidates are one type of candidate that involves 1130 a media intermediary. Another are host candidates obtained from a 1131 VPN interface. When media is transited through a media intermediary, 1132 it can increase the latency between transmission and reception. It 1133 can increase the packet losses, because of the additional router hops 1134 that may be taken. It may increase the cost of providing service, 1135 since media will be routed in and right back out of a media 1136 intermediary run by a provider. If these concerns are important, the 1137 type preference for relayed candidates SHOULD be lower than host 1138 candidates. The RECOMMENDED values are 126 for host candidates, 100 1139 for server reflexive candidates, 110 for peer reflexive candidates, 1140 and 0 for relayed candidates. 1142 Furthermore, if an agent is multihomed and has multiple IP addresses, 1143 the local preference for host candidates from a VPN interface SHOULD 1144 have a priority of 0. If multiple TURN servers are used, local 1145 priorities for the candidates obtained from the TURN servers are 1146 chosen in a similar fashion as for multihomed local candidates: the 1147 local preference value is used to indicate preference among different 1148 servers but the preference MUST be unique for each one. 1150 Another criterion for selection of preferences is IP address family. 1151 ICE works with both IPv4 and IPv6. It therefore provides a 1152 transition mechanism that allows dual-stack hosts to prefer 1153 connectivity over IPv6, but to fall back to IPv4 in case the v6 1154 networks are disconnected (due, for example, to a failure in a 6to4 1155 relay) [RFC3056]. It can also help with hosts that have both a 1156 native IPv6 address and a 6to4 address. In such a case, higher local 1157 preferences could be assigned to the v6 addresses, followed by the 1158 6to4 addresses, followed by the v4 addresses. This allows a site to 1159 obtain and begin using native v6 addresses immediately, yet still 1160 fall back to 6to4 addresses when communicating with agents in other 1161 sites that do not yet have native v6 connectivity. 1163 Another criterion for selecting preferences is security. If a user 1164 is a telecommuter, and therefore connected to a corporate network and 1165 a local home network, the user may prefer their voice traffic to be 1166 routed over the VPN in order to keep it on the corporate network when 1167 communicating within the enterprise, but use the local network when 1168 communicating with users outside of the enterprise. In such a case, 1169 a VPN address would have a higher local preference than any other 1170 address. 1172 Another criterion for selecting preferences is topological awareness. 1173 This is most useful for candidates that make use of intermediaries. 1174 In those cases, if an agent has preconfigured or dynamically 1175 discovered knowledge of the topological proximity of the 1176 intermediaries to itself, it can use that to assign higher local 1177 preferences to candidates obtained from closer intermediaries. 1179 4.1.3. Eliminating Redundant Candidates 1181 Next, the agent eliminates redundant candidates. A candidate is 1182 redundant if its transport address equals another candidate, and its 1183 base equals the base of that other candidate. Note that two 1184 candidates can have the same transport address yet have different 1185 bases, and these would not be considered redundant. Frequently, a 1186 server reflexive candidate and a host candidate will be redundant 1187 when the agent is not behind a NAT. The agent SHOULD eliminate the 1188 redundant candidate with the lower priority. 1190 This process is common across the initiating and responding agents. 1192 4.2. Lite Implementation Procedures 1194 Lite implementations only utilize host candidates. A lite 1195 implementation MUST, for each component of each media stream, 1196 allocate zero or one IPv4 candidates. It MAY allocate zero or more 1197 IPv6 candidates, but no more than one per each IPv6 address utilized 1198 by the host. Since there can be no more than one IPv4 candidate per 1199 component of each media stream, if an agent has multiple IPv4 1200 addresses, it MUST choose one for allocating the candidate. If a 1201 host is dual-stack, it is RECOMMENDED that it allocate one IPv4 1202 candidate and one global IPv6 address. With the lite implementation, 1203 ICE cannot be used to dynamically choose amongst candidates. 1204 Therefore, including more than one candidate from a particular scope 1205 is NOT RECOMMENDED, since only a connectivity check can truly 1206 determine whether to use one address or the other. 1208 Each component has an ID assigned to it, called the component ID. 1209 For RTP-based media streams, unless RTCP is multiplexed in the same 1210 port with RTP, the RTP itself has a component ID of 1, and RTCP a 1211 component ID of 2. If an agent is using RTCP without multiplexing, 1212 it MUST obtain candidates for it. However, absence of a component ID 1213 2 as such does not imply use of RTCP/RTP multiplexing, as it could 1214 also mean that RTCP is not used. 1216 Each candidate is assigned a foundation. The foundation MUST be 1217 different for two candidates allocated from different IP addresses, 1218 and MUST be the same otherwise. A simple integer that increments for 1219 each IP address will suffice. In addition, each candidate MUST be 1220 assigned a unique priority amongst all candidates for the same media 1221 stream. This priority SHOULD be equal to: 1223 priority = (2^24)*(126) + 1224 (2^8)*(IP precedence) + 1225 (2^0)*(256 - component ID) 1227 If a host is v4-only, it SHOULD set the IP precedence to 65535. If a 1228 host is v6 or dual-stack, the IP precedence SHOULD be the precedence 1229 value for IP addresses described in RFC 6724 [RFC6724]. 1231 Next, an agent chooses a default candidate for each component of each 1232 media stream. If a host is IPv4-only, there would only be one 1233 candidate for each component of each media stream, and therefore that 1234 candidate is the default. If a host is IPv6 or dual-stack, the 1235 selection of default is a matter of local policy. This default 1236 SHOULD be chosen such that it is the candidate most likely to be used 1237 with a peer. For IPv6-only hosts, this would typically be a globally 1238 scoped IPv6 address. For dual-stack hosts, the IPv4 address is 1239 RECOMMENDED. 1241 The procedures in this section is common across the initiating and 1242 responding agents. 1244 4.3. Encoding the Candidate Information 1246 Regardless of the agent being an Initiator or Responder Agent, the 1247 following parameters and their data types needs to be conveyed as 1248 part of the candidate exchange process. The specifics of syntax for 1249 encoding the candidate information is out of scope of this 1250 specification. 1252 Candidate attribute There will be one or more of these for each 1253 "media stream". Each candidate is composed of: 1255 Connection Address: The IP address and transport protocol port of 1256 the candidate. 1258 Transport: An indicator of the transport protocol for this 1259 candidate. This need not be present if the using protocol will 1260 only ever run over a single transport protocol. If it runs 1261 over more than one, or if others are anticipated to be used in 1262 the future, this should be present. 1264 Foundation: A sequence of up to 32 characters. 1266 Component-ID: This would be present only if the using protocol 1267 were utilizing the concept of components. If it is, it would 1268 be a positive integer that indicates the component ID for which 1269 this is a candidate. 1271 Priority: An encoding of the 32-bit priority value. 1273 Candidate Type: The candidate type, as defined in ICE. 1275 Related Address and Port: The related IP address and port for 1276 this candidate, as defined by ICE. These MAY be omitted or set 1277 to invalid values if the agent does not want to reveal them, 1278 e.g., for privacy reasons. 1280 Extensibility Parameters: The using protocol should define some 1281 means for adding new per-candidate ICE parameters in the 1282 future. 1284 Lite Flag: If ICE lite is used by the using protocol, it needs to 1285 convey a boolean parameter which indicates whether the 1286 implementation is lite or not. 1288 Connectivity check pacing value: If an agent wants to use other than 1289 the default pacing values for the connectivity checks, it MUST 1290 indicate this in the ICE exchange. 1292 Username Fragment and Password: The using protocol has to convey a 1293 username fragment and password. The username fragment MUST 1294 contain at least 24 bits of randomness, and the password MUST 1295 contain at least 128 bits of randomness. 1297 ICE extensions: In addition to the per-candidate extensions above, 1298 the using protocol should allow for new media-stream or session- 1299 level attributes (ice-options). 1301 If the using protocol is using the ICE mismatch feature, a way is 1302 needed to convey this parameter in answers. It is a boolean flag. 1304 The exchange of parameters is symmetric; both agents need to send the 1305 same set of attributes as defined above. 1307 The using protocol may (or may not) need to deal with backwards 1308 compatibility with older implementations that do not support ICE. If 1309 the fallback mechanism is being used, then presumably the using 1310 protocol provides a way of conveying the default candidate (its IP 1311 address and port) in addition to the ICE parameters. 1313 STUN connectivity checks between agents are authenticated using the 1314 short-term credential mechanism defined for STUN [RFC5389]. This 1315 mechanism relies on a username and password that are exchanged 1316 through protocol machinery between the client and server. The 1317 username part of this credential is formed by concatenating a 1318 username fragment from each agent, separated by a colon. Each agent 1319 also provides a password, used to compute the message integrity for 1320 requests it receives. The username fragment and password are 1321 exchanged between the peers. In addition to providing security, the 1322 username provides disambiguation and correlation of checks to media 1323 streams. See Appendix B.4 for motivation. 1325 If the initiating agent is a lite implementation, it MUST indicate 1326 this when sending its candidates . 1328 ICE provides for extensibility by allowing an agent to include a 1329 series of tokens that identify ICE extensions as part of the 1330 candidate exchange process. 1332 Once an agent has sent its candidate information, that agent MUST be 1333 prepared to receive both STUN and media packets on each candidate. 1334 As discussed in Section 11.1, media packets can be sent to a 1335 candidate prior to its appearance as the default destination for 1336 media. 1338 5. ICE Candidate Processing 1340 Once an agent has candidates from it's peer, it will check if the 1341 peer supports ICE, determine its own role, exchanges candidates 1342 (Section 4) and for full implementations, forms the check lists and 1343 begins connectivity checks as explained in this section. 1345 5.1. Procedures for Full Implementation 1347 5.1.1. Verifying ICE Support 1349 Certain middleboxes, such as ALGs, may alter the ICE candidate 1350 information that breaks ICE. If the using protocol is vulnerable to 1351 this kind of changes, called ICE mismatch, the responding agent needs 1352 to detect this and signal this back to the initiating agent. The 1353 details on whether this is needed and how it is done is defined by 1354 the usage specifications. One exception to the above is that an 1355 initiating agent would never indicate ICE mismatch. 1357 5.1.2. Determining Role 1359 For each session, each agent (Initiating and Responding) takes on a 1360 role. There are two roles -- controlling and controlled. The 1361 controlling agent is responsible for the choice of the final 1362 candidate pairs used for communications. For a full agent, this 1363 means nominating the candidate pairs that can be used by ICE for each 1364 media stream, and for updating the peer with the ICE's selection, 1365 when needed. The controlled agent is told which candidate pairs to 1366 use for each media stream, and does not require updating the peer to 1367 signal this information. The sections below describe in detail the 1368 actual procedures followed by controlling and controlled nodes. 1370 The rules for determining the role and the impact on behavior are as 1371 follows: 1373 Both agents are full: The Initiating Agent which started the ICE 1374 processing MUST take the controlling role, and the other MUST take 1375 the controlled role. Both agents will form check lists, run the 1376 ICE state machines, and generate connectivity checks. The 1377 controlling agent will execute the logic in Section 7.1 to 1378 nominate pairs that will be selected by ICE, and then both agents 1379 end ICE as described in Section 7.1.2. 1381 One agent full, one lite: The full agent MUST take the controlling 1382 role, and the lite agent MUST take the controlled role. The full 1383 agent will form check lists, run the ICE state machines, and 1384 generate connectivity checks. That agent will execute the logic 1385 in Section 7.1 to nominate pairs that will be selected by ICE, and 1386 use the logic in Section 7.1.2 to end ICE. The lite 1387 implementation will just listen for connectivity checks, receive 1388 them and respond to them, and then conclude ICE as described in 1389 Section 7.2. For the lite implementation, the state of ICE 1390 processing for each media stream is considered to be Running, and 1391 the state of ICE overall is Running. 1393 Both lite: The Initiating Agent which started the ICE processing 1394 MUST take the controlling role, and the other MUST take the 1395 controlled role. In this case, no connectivity checks are ever 1396 sent. Rather, once the candidates are exchanged, each agent 1397 performs the processing described in Section 7 without 1398 connectivity checks. It is possible that both agents will believe 1399 they are controlled or controlling. In the latter case, the 1400 conflict is resolved through glare detection capabilities in the 1401 signaling protocol enabling the candidate exchange. The state of 1402 ICE processing for each media stream is considered to be Running, 1403 and the state of ICE overall is Running. 1405 Once roles are determined for a session, they persist unless ICE is 1406 restarted. An ICE restart causes a new selection of roles and tie- 1407 breakers. 1409 5.1.3. Forming the Check Lists 1411 There is one check list per in-use media stream resulting from the 1412 candidate exchange. To form the check list for a media stream, the 1413 agent forms candidate pairs, computes a candidate pair priority, 1414 orders the pairs by priority, prunes them, and sets their states. 1415 These steps are described in this section. 1417 5.1.3.1. Forming Candidate Pairs 1419 First, the agent takes each of its candidates for a media stream 1420 (called LOCAL CANDIDATES) and pairs them with the candidates it 1421 received from its peer (called REMOTE CANDIDATES) for that media 1422 stream. In order to prevent the attacks described in Section 15.4.1, 1423 agents MAY limit the number of candidates they'll accept in an 1424 candidate exchange process. A local candidate is paired with a 1425 remote candidate if and only if the two candidates have the same 1426 component ID and have the same IP address version. It is possible 1427 that some of the local candidates won't get paired with remote 1428 candidates, and some of the remote candidates won't get paired with 1429 local candidates. This can happen if one agent doesn't include 1430 candidates for the all of the components for a media stream. If this 1431 happens, the number of components for that media stream is 1432 effectively reduced, and considered to be equal to the minimum across 1433 both agents of the maximum component ID provided by each agent across 1434 all components for the media stream. 1436 In the case of RTP, this would happen when one agent provides 1437 candidates for RTCP, and the other does not. As another example, the 1438 initiating agent can multiplex RTP and RTCP on the same port 1439 [RFC5761]. However, since the initiating agent doesn't know if the 1440 peer agent can perform such multiplexing, it includes candidates for 1441 RTP and RTCP on separate ports. If the peer agent can perform such 1442 multiplexing, it would include just a single component for each 1443 candidate -- for the combined RTP/RTCP mux. ICE would end up acting 1444 as if there was just a single component for this candidate. 1446 With IPv6 it is common for a host to have multiple host candidates 1447 for each interface. To keep the amount of resulting candidate pairs 1448 reasonable and to avoid candidate pairs that are highly unlikely to 1449 work, IPv6 link-local addresses [RFC4291] MUST NOT be paired with 1450 other than link-local addresses. 1452 The candidate pairs whose local and remote candidates are both the 1453 default candidates for a particular component is called, 1454 unsurprisingly, the default candidate pair for that component. This 1455 is the pair that would be used to transmit media if both agents had 1456 not been ICE aware. 1458 In order to aid understanding, Figure 6 shows the relationships 1459 between several key concepts -- transport addresses, candidates, 1460 candidate pairs, and check lists, in addition to indicating the main 1461 properties of candidates and candidate pairs. 1463 +--------------------------------------------+ 1464 | | 1465 | +---------------------+ | 1466 | |+----+ +----+ +----+ | +Type | 1467 | || IP | |Port| |Tran| | +Priority | 1468 | ||Addr| | | | | | +Foundation | 1469 | |+----+ +----+ +----+ | +Component ID | 1470 | | Transport | +Related Address | 1471 | | Addr | | 1472 | +---------------------+ +Base | 1473 | Candidate | 1474 +--------------------------------------------+ 1475 * * 1476 * ************************************* 1477 * * 1478 +-------------------------------+ 1479 .| | 1480 | Local Remote | 1481 | +----+ +----+ +default? | 1482 | |Cand| |Cand| +valid? | 1483 | +----+ +----+ +nominated?| 1484 | +State | 1485 | | 1486 | | 1487 | Candidate Pair | 1488 +-------------------------------+ 1489 * * 1490 * ************ 1491 * * 1492 +------------------+ 1493 | Candidate Pair | 1494 +------------------+ 1495 +------------------+ 1496 | Candidate Pair | 1497 +------------------+ 1498 +------------------+ 1499 | Candidate Pair | 1500 +------------------+ 1502 Check 1503 List 1505 Figure 6: Conceptual Diagram of a Check List 1507 5.1.3.2. Computing Pair Priority and Ordering Pairs 1509 Once the pairs are formed, a candidate pair priority is computed. 1510 Let G be the priority for the candidate provided by the controlling 1511 agent. Let D be the priority for the candidate provided by the 1512 controlled agent. The priority for a pair is computed as: 1514 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 1516 Where G>D?1:0 is an expression whose value is 1 if G is greater than 1517 D, and 0 otherwise. Once the priority is assigned, the agent sorts 1518 the candidate pairs in decreasing order of priority. If two pairs 1519 have identical priority, the ordering amongst them is arbitrary. 1521 5.1.3.3. Pruning the Pairs 1523 This sorted list of candidate pairs is used to determine a sequence 1524 of connectivity checks that will be performed. Each check involves 1525 sending a request from a local candidate to a remote candidate. 1526 Since an agent cannot send requests directly from a reflexive 1527 candidate, but only from its base, the agent next goes through the 1528 sorted list of candidate pairs. For each pair where the local 1529 candidate is server reflexive, the server reflexive candidate MUST be 1530 replaced by its base. Once this has been done, the agent MUST prune 1531 the list. This is done by removing a pair if its local and remote 1532 candidates are identical to the local and remote candidates of a pair 1533 higher up on the priority list. The result is a sequence of ordered 1534 candidate pairs, called the check list for that media stream. 1536 In addition, in order to limit the attacks described in 1537 Section 15.4.1, an agent MUST limit the total number of connectivity 1538 checks the agent performs across all check lists to a specific value, 1539 and this value MUST be configurable. A default of 100 is 1540 RECOMMENDED. This limit is enforced by discarding the lower-priority 1541 candidate pairs until there are less than 100. It is RECOMMENDED 1542 that a lower value be utilized when possible, set to the maximum 1543 number of plausible checks that might be seen in an actual deployment 1544 configuration. The requirement for configuration is meant to provide 1545 a tool for fixing this value in the field if, once deployed, it is 1546 found to be problematic. 1548 5.1.3.4. Computing States 1550 Each candidate pair in the check list has a foundation and a state. 1551 The foundation is the combination of the foundations of the local and 1552 remote candidates in the pair. The state is assigned once the check 1553 list for each media stream has been computed. There are five 1554 potential values that the state can have: 1556 Waiting: A check has not been performed for this pair, and can be 1557 performed as soon as it is the highest-priority Waiting pair on 1558 the check list. 1560 In-Progress: A check has been sent for this pair, but the 1561 transaction is in progress. 1563 Succeeded: A check for this pair was already done and produced a 1564 successful result. 1566 Failed: A check for this pair was already done and failed, either 1567 never producing any response or producing an unrecoverable failure 1568 response. 1570 Frozen: A check for this pair hasn't been performed, and it can't 1571 yet be performed until some other check succeeds, allowing this 1572 pair to unfreeze and move into the Waiting state. 1574 As ICE runs, the pairs will move between states as shown in Figure 7. 1576 +-----------+ 1577 | | 1578 | | 1579 | Frozen | 1580 | | 1581 | | 1582 +-----------+ 1583 | 1584 |unfreeze 1585 | 1586 V 1587 +-----------+ +-----------+ 1588 | | | | 1589 | | perform | | 1590 | Waiting |-------->|In-Progress| 1591 | | | | 1592 | | | | 1593 +-----------+ +-----------+ 1594 / | 1595 // | 1596 // | 1597 // | 1598 / | 1599 // | 1600 failure // |success 1601 // | 1602 / | 1603 // | 1604 // | 1605 // | 1606 V V 1607 +-----------+ +-----------+ 1608 | | | | 1609 | | | | 1610 | Failed | | Succeeded | 1611 | | | | 1612 | | | | 1613 +-----------+ +-----------+ 1615 Figure 7: Pair State FSM 1617 The initial states for each pair in a check list are computed by 1618 performing the following sequence of steps: 1620 1. The agent sets all of the pairs in each check list to the Frozen 1621 state. 1623 2. The agent examines the check list for the first media stream. 1624 For that media stream: 1626 * For all pairs with the same foundation, it sets the state of 1627 the pair with the lowest component ID to Waiting. If there is 1628 more than one such pair, the one with the highest-priority is 1629 used. 1631 One of the check lists will have some number of pairs in the Waiting 1632 state, and the other check lists will have all of their pairs in the 1633 Frozen state. A check list with at least one pair that is Waiting is 1634 called an active check list, and a check list with all pairs Frozen 1635 is called a frozen check list. 1637 The check list itself is associated with a state, which captures the 1638 state of ICE checks for that media stream. There are three states: 1640 Running: In this state, ICE checks are still in progress for this 1641 media stream. 1643 Completed: In this state, ICE checks have produced nominated pairs 1644 for each component of the media stream. 1646 Failed: In this state, the ICE checks have not completed 1647 successfully for this media stream. 1649 When a check list is first constructed as the consequence of an 1650 candidate exchange, it is placed in the Running state. 1652 ICE processing across all media streams also has a state associated 1653 with it. This state is equal to Running while ICE processing is 1654 under way. The state is Completed when ICE processing is complete 1655 and Failed if it failed without success. Rules for transitioning 1656 between states are described below. 1658 5.1.4. Scheduling Checks 1660 An agent performs ordinary checks and triggered checks. The 1661 generation of both checks is governed by a timer that fires 1662 periodically for each media stream. The agent maintains a FIFO 1663 queue, called the triggered check queue, which contains candidate 1664 pairs for which checks are to be sent at the next available 1665 opportunity. When the timer fires, the agent removes the top pair 1666 from the triggered check queue, performs a connectivity check on that 1667 pair, and sets the state of the candidate pair to In-Progress. If 1668 there are no pairs in the triggered check queue, an ordinary check is 1669 sent. 1671 Once the agent has computed the check lists as described in 1672 Section 5.1.3, it sets a timer for each active check list. The timer 1673 fires every Ta*N seconds, where N is the number of active check lists 1674 (initially, there is only one active check list). Implementations 1675 MAY set the timer to fire less frequently than this. Implementations 1676 SHOULD take care to spread out these timers so that they do not fire 1677 at the same time for each media stream. Ta and the retransmit timer 1678 RTO are computed as described in Section 13. Multiplying by N allows 1679 this aggregate check throughput to be split between all active check 1680 lists. The first timer fires immediately, so that the agent performs 1681 a connectivity check the moment the candidate exchange has been done, 1682 followed by the next check Ta seconds later (since there is only one 1683 active check list). 1685 When the timer fires and there is no triggered check to be sent, the 1686 agent MUST choose an ordinary check as follows: 1688 o Find the highest-priority pair in that check list that is in the 1689 Waiting state. 1691 o If there is such a pair: 1693 * Send a STUN check from the local candidate of that pair to the 1694 remote candidate of that pair. The procedures for forming the 1695 STUN request for this purpose are described in Section 6.1.2. 1697 * Set the state of the candidate pair to In-Progress. 1699 o If there is no such pair: 1701 * Find the highest-priority pair in that check list that is in 1702 the Frozen state. 1704 * If there is such a pair: 1706 + Unfreeze the pair. 1708 + Perform a check for that pair, causing its state to 1709 transition to In-Progress. 1711 * If there is no such pair: 1713 + Terminate the timer for that check list. 1715 To compute the message integrity for the check, the agent uses the 1716 remote username fragment and password learned from the candidate 1717 information obtained from its peer. The local username fragment is 1718 known directly by the agent for its own candidate. 1720 The Initiator performs the ordinary checks on receiving the candidate 1721 information from the Peer (responder) and having formed the 1722 checklists. On the other hand the responding agent either performs 1723 the triggered or ordinary checks as described above. 1725 5.2. Lite Implementation Procedures 1727 Lite implementations skips most of the steps in Section 5 except for 1728 verifying the peer's ICE support and determining its role in the ICE 1729 processing. 1731 On determining the role for a lite implementation being the 1732 controlling agent means selecting a candidate pair based on the ones 1733 in the candidate exchange (for IPv4, there is only ever one pair), 1734 and then updating the peer with the new candidate information 1735 reflecting that selection, when needed (it is never needed for an 1736 IPv4-only host). The controlled agent is told which candidate pairs 1737 to use for each media stream, and no further candidate updates are 1738 needed to signal this information. 1740 6. Performing Connectivity Checks 1742 This section describes how connectivity checks are performed. All 1743 ICE implementations are required to be compliant to [RFC5389], as 1744 opposed to the older [RFC3489]. However, whereas a full 1745 implementation will both generate checks (acting as a STUN client) 1746 and receive them (acting as a STUN server), a lite implementation 1747 will only receive checks, and thus will only act as a STUN server. 1749 6.1. STUN Client Procedures 1751 These procedures define how an agent sends a connectivity check, 1752 whether it is an ordinary or a triggered check. These procedures are 1753 only applicable to full implementations. 1755 6.1.1. Creating Permissions for Relayed Candidates 1757 If the connectivity check is being sent using a relayed local 1758 candidate, the client MUST create a permission first if it has not 1759 already created one previously. It would have created one previously 1760 if it had told the TURN server to create a permission for the given 1761 relayed candidate towards the IP address of the remote candidate. To 1762 create the permission, the agent follows the procedures defined in 1763 [RFC5766]. The permission MUST be created towards the IP address of 1764 the remote candidate. It is RECOMMENDED that the agent defer 1765 creation of a TURN channel until ICE completes, in which case 1766 permissions for connectivity checks are normally created using a 1767 CreatePermission request. Once established, the agent MUST keep the 1768 permission active until ICE concludes. 1770 6.1.2. Sending the Request 1772 A connectivity check is generated by sending a Binding request from a 1773 local candidate to a remote candidate. [RFC5389] describes how 1774 Binding requests are constructed and generated. A connectivity check 1775 MUST utilize the STUN short-term credential mechanism. Support for 1776 backwards compatibility with RFC 3489 MUST NOT be used or assumed 1777 with connectivity checks. The FINGERPRINT mechanism MUST be used for 1778 connectivity checks. 1780 ICE extends STUN by defining several new attributes, including 1781 PRIORITY, USE-CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. These 1782 new attributes are formally defined in Section 16.1, and their usage 1783 is described in the subsections below. These STUN extensions are 1784 applicable only to connectivity checks used for ICE. 1786 6.1.2.1. PRIORITY 1788 An agent MUST include the PRIORITY attribute in its Binding request. 1789 The attribute MUST be set equal to the priority that would be 1790 assigned, based on the algorithm in Section 4.1.2, to a peer 1791 reflexive candidate, should one be learned as a consequence of this 1792 check (see Section 6.1.3.2.1 for how peer reflexive candidates are 1793 learned). This priority value will be computed identically to how 1794 the priority for the local candidate of the pair was computed, except 1795 that the type preference is set to the value for peer reflexive 1796 candidate types. 1798 6.1.2.2. USE-CANDIDATE 1800 The controlling agent includes the USE-CANDIDATE attribute in order 1801 to nominate a candidate pair Section 7.1.1. The controlled agent 1802 MUST NOT include the USE-CANDIDATE attribute in its Binding request. 1804 6.1.2.3. ICE-CONTROLLED and ICE-CONTROLLING 1806 The agent MUST include the ICE-CONTROLLED attribute in the request if 1807 it is in the controlled role, and MUST include the ICE-CONTROLLING 1808 attribute in the request if it is in the controlling role. The 1809 content of either attribute MUST be the tie-breaker that was 1810 determined in Section 5.1.2. These attributes are defined fully in 1811 Section 16.1. 1813 6.1.2.4. Forming Credentials 1815 A Binding request serving as a connectivity check MUST utilize the 1816 STUN short-term credential mechanism. The username for the 1817 credential is formed by concatenating the username fragment provided 1818 by the peer with the username fragment of the agent sending the 1819 request, separated by a colon (":"). The password is equal to the 1820 password provided by the peer. For example, consider the case where 1821 agent L is the initiating , agent and agent R is the responding 1822 agent. Agent L included a username fragment of LFRAG for its 1823 candidates and a password of LPASS. Agent R provided a username 1824 fragment of RFRAG and a password of RPASS. A connectivity check from 1825 L to R utilizes the username RFRAG:LFRAG and a password of RPASS. A 1826 connectivity check from R to L utilizes the username LFRAG:RFRAG and 1827 a password of LPASS. The responses utilize the same usernames and 1828 passwords as the requests (note that the USERNAME attribute is not 1829 present in the response). 1831 6.1.2.5. DiffServ Treatment 1833 If the agent is using Diffserv Codepoint markings [RFC2475] in its 1834 media packets, it SHOULD apply those same markings to its 1835 connectivity checks. 1837 6.1.3. Processing the Response 1839 When a Binding response is received, it is correlated to its Binding 1840 request using the transaction ID, as defined in [RFC5389], which then 1841 ties it to the candidate pair for which the Binding request was sent. 1842 This section defines additional procedures for processing Binding 1843 responses specific to this usage of STUN. 1845 6.1.3.1. Failure Cases 1847 If the STUN transaction generates a 487 (Role Conflict) error 1848 response, the agent checks whether it included the ICE-CONTROLLED or 1849 ICE-CONTROLLING attribute in the Binding request. If the request 1850 contained the ICE-CONTROLLED attribute, the agent MUST switch to the 1851 controlling role if it has not already done so. If the request 1852 contained the ICE-CONTROLLING attribute, the agent MUST switch to the 1853 controlled role if it has not already done so. Once it has switched, 1854 the agent MUST enqueue the candidate pair whose check generated the 1855 487 into the triggered check queue. The state of that pair is set to 1856 Waiting. When the triggered check is sent, it will contain an ICE- 1857 CONTROLLING or ICE-CONTROLLED attribute reflecting its new role. 1858 Note, however, that the tie-breaker value MUST NOT be reselected. 1860 A change in roles will require an agent to recompute pair priorities 1861 (Section 5.1.3.2), since those priorities are a function of 1862 controlling and controlled roles. The change in role will also 1863 impact whether the agent is responsible for selecting nominated pairs 1864 and generating updated candidate information for sharing upon 1865 conclusion of ICE. 1867 Agents MAY support receipt of ICMP errors for connectivity checks. 1868 If the STUN transaction generates an ICMP error, the agent sets the 1869 state of the pair to Failed. If the STUN transaction generates a 1870 STUN error response that is unrecoverable (as defined in [RFC5389]) 1871 or times out, the agent sets the state of the pair to Failed. 1873 The agent MUST check that the source IP address and port of the 1874 response equal the destination IP address and port to which the 1875 Binding request was sent, and that the destination IP address and 1876 port of the response match the source IP address and port from which 1877 the Binding request was sent. In other words, the source and 1878 destination transport addresses in the request and responses are 1879 symmetric. If they are not symmetric, the agent sets the state of 1880 the pair to Failed. 1882 6.1.3.2. Success Cases 1884 A check is considered to be a success if all of the following are 1885 true: 1887 o The STUN transaction generated a success response. 1889 o The source IP address and port of the response equals the 1890 destination IP address and port to which the Binding request was 1891 sent. 1893 o The destination IP address and port of the response match the 1894 source IP address and port from which the Binding request was 1895 sent. 1897 6.1.3.2.1. Discovering Peer Reflexive Candidates 1899 The agent checks the mapped address from the STUN response. If the 1900 transport address does not match any of the local candidates that the 1901 agent knows about, the mapped address represents a new candidate -- a 1902 peer reflexive candidate. Like other candidates, it has a type, 1903 base, priority, and foundation. They are computed as follows: 1905 o Its type is equal to peer reflexive. 1907 o Its base is set equal to the local candidate of the candidate pair 1908 from which the STUN check was sent. 1910 o Its priority is set equal to the value of the PRIORITY attribute 1911 in the Binding request. 1913 o Its foundation is selected as described in Section 4.1.1.3. 1915 This peer reflexive candidate is then added to the list of local 1916 candidates for the media stream. Its username fragment and password 1917 are the same as all other local candidates for that media stream. 1918 However, the peer reflexive candidate is not paired with other remote 1919 candidates. This is not necessary; a valid pair will be generated 1920 from it momentarily based on the procedures in Section 6.1.3.2.2. If 1921 an agent wishes to pair the peer reflexive candidate with other 1922 remote candidates besides the one in the valid pair that will be 1923 generated, the agent MAY generate an update the peer with the 1924 candidate information that includes the peer reflexive candidate. 1925 This will cause it to be paired with all other remote candidates. 1927 6.1.3.2.2. Constructing a Valid Pair 1929 The agent constructs a candidate pair whose local candidate equals 1930 the mapped address of the response, and whose remote candidate equals 1931 the destination address to which the request was sent. This is 1932 called a valid pair, since it has been validated by a STUN 1933 connectivity check. The valid pair may equal the pair that generated 1934 the check, may equal a different pair in the check list, or may be a 1935 pair not currently on any check list. If the pair equals the pair 1936 that generated the check or is on a check list currently, it is also 1937 added to the VALID LIST, which is maintained by the agent for each 1938 media stream. This list is empty at the start of ICE processing, and 1939 fills as checks are performed, resulting in valid candidate pairs. 1941 It will be very common that the pair will not be on any check list. 1942 Recall that the check list has pairs whose local candidates are never 1943 server reflexive; those pairs had their local candidates converted to 1944 the base of the server reflexive candidates, and then pruned if they 1945 were redundant. When the response to the STUN check arrives, the 1946 mapped address will be reflexive if there is a NAT between the two. 1947 In that case, the valid pair will have a local candidate that doesn't 1948 match any of the pairs in the check list. 1950 If the pair is not on any check list, the agent computes the priority 1951 for the pair based on the priority of each candidate, using the 1952 algorithm in Section 5.1.3. The priority of the local candidate 1953 depends on its type. If it is not peer reflexive, it is equal to the 1954 priority signaled for that candidate in the candidate exchange. If 1955 it is peer reflexive, it is equal to the PRIORITY attribute the agent 1956 placed in the Binding request that just completed. The priority of 1957 the remote candidate is taken from the candidate information of the 1958 peer. If the candidate does not appear there, then the check must 1959 have been a triggered check to a new remote candidate. In that case, 1960 the priority is taken as the value of the PRIORITY attribute in the 1961 Binding request that triggered the check that just completed. The 1962 pair is then added to the VALID LIST. 1964 6.1.3.2.3. Updating Pair States 1966 The agent sets the state of the pair that *generated* the check to 1967 Succeeded. Note that, the pair which *generated* the check may be 1968 different than the valid pair constructed in Section 6.1.3.2.2 as a 1969 consequence of the response. The success of this check might also 1970 cause the state of other checks to change as well. The agent MUST 1971 perform the following two steps: 1973 1. The agent changes the states for all other Frozen pairs for the 1974 same media stream and same foundation to Waiting. Typically, but 1975 not always, these other pairs will have different component IDs. 1977 2. If there is a pair in the valid list for every component of this 1978 media stream (where this is the actual number of components being 1979 used, in cases where the number of components signaled in the 1980 candidate exchange differs from initiating to responding agent), 1981 the success of this check may unfreeze checks for other media 1982 streams. Note that this step is followed not just the first time 1983 the valid list under consideration has a pair for every 1984 component, but every subsequent time a check succeeds and adds 1985 yet another pair to that valid list. The agent examines the 1986 check list for each other media stream in turn: 1988 * If the check list is active, the agent changes the state of 1989 all Frozen pairs in that check list whose foundation matches a 1990 pair in the valid list under consideration to Waiting. 1992 * If the check list is frozen, and there is at least one pair in 1993 the check list whose foundation matches a pair in the valid 1994 list under consideration, the state of all pairs in the check 1995 list whose foundation matches a pair in the valid list under 1996 consideration is set to Waiting. This will cause the check 1997 list to become active, and ordinary checks will begin for it, 1998 as described in Section 5.1.4. 2000 * If the check list is frozen, and there are no pairs in the 2001 check list whose foundation matches a pair in the valid list 2002 under consideration, the agent 2003 + groups together all of the pairs with the same foundation, 2004 and 2006 + for each group, sets the state of the pair with the lowest 2007 component ID to Waiting. If there is more than one such 2008 pair, the one with the highest-priority is used. 2010 6.1.3.2.4. Updating the Nominated Flag 2012 If the agent was a controlling agent, and it had included a USE- 2013 CANDIDATE attribute in the Binding request, the valid pair generated 2014 from that check has its nominated flag set to true. This flag 2015 indicates that this valid pair SHOULD be used for media, unless the 2016 sending agent detects that the candidiate pair does not work. This 2017 concludes the ICE processing for this media stream or all media 2018 streams; see Section 7. 2020 If the agent is the controlled agent, the response may be the result 2021 of a triggered check that was sent in response to a request that 2022 itself had the USE-CANDIDATE attribute. This case is described in 2023 Section 6.2.1.5, and may now result in setting the nominated flag for 2024 the pair learned from the original request. 2026 An agent MUST NOT select a candidate pair until it has sent a Binding 2027 request, and received the corresponding Binding response, associated 2028 with the candidiate pair. 2030 6.1.3.3. Check List and Timer State Updates 2032 Regardless of whether the check was successful or failed, the 2033 completion of the transaction may require updating of check list and 2034 timer states. 2036 If all of the pairs in the check list are now either in the Failed or 2037 Succeeded state: 2039 o If there is not a pair in the valid list for each component of the 2040 media stream, the state of the check list is set to Failed. 2042 o For each frozen check list, the agent 2044 * groups together all of the pairs with the same foundation, and 2046 * for each group, sets the state of the pair with the lowest 2047 component ID to Waiting. If there is more than one such pair, 2048 the one with the highest-priority is used. 2050 If none of the pairs in the check list are in the Waiting or Frozen 2051 state, the check list is no longer considered active, and will not 2052 count towards the value of N in the computation of timers for 2053 ordinary checks as described in Section 5.1.4. 2055 6.2. STUN Server Procedures 2057 An agent MUST be prepared to receive a Binding request on the base of 2058 each candidate it included in its most recent candidate exchange. 2059 This requirement holds even if the peer is a lite implementation. 2061 The agent MUST use the short-term credential mechanism (i.e., the 2062 MESSAGE-INTEGRITY attribute) to authenticate the request and perform 2063 a message integrity check. Likewise, the short-term credential 2064 mechanism MUST be used for the response. The agent MUST consider the 2065 username to be valid if it consists of two values separated by a 2066 colon, where the first value is equal to the username fragment 2067 generated by the agent in an candidate exchange for a session in- 2068 progress. It is possible (and in fact very likely) that the 2069 initiating agent will receive a Binding request prior to receiving 2070 the candidates from its peer. If this happens, the agent MUST 2071 immediately generate a response (including computation of the mapped 2072 address as described in Section 6.2.1.2). The agent has sufficient 2073 information at this point to generate the response; the password from 2074 the peer is not required. Once the answer is received, it MUST 2075 proceed with the remaining steps required, namely, Section 6.2.1.3, 2076 Section 6.2.1.4, and Section 6.2.1.5 for full implementations. In 2077 cases where multiple STUN requests are received before the answer, 2078 this may cause several pairs to be queued up in the triggered check 2079 queue. 2081 An agent MUST NOT utilize the ALTERNATE-SERVER mechanism, and MUST 2082 NOT support the backwards-compatibility mechanisms to RFC 3489. It 2083 MUST utilize the FINGERPRINT mechanism. 2085 If the agent is using Diffserv Codepoint markings [RFC2475] in its 2086 media packets, it SHOULD apply those same markings to its responses 2087 to Binding requests. The same would apply to any layer 2 markings 2088 the endpoint might be applying to media packets. 2090 6.2.1. Additional Procedures for Full Implementations 2092 This subsection defines the additional server procedures applicable 2093 to full implementations. 2095 6.2.1.1. Detecting and Repairing Role Conflicts 2097 Normally, the rules for selection of a role in Section 5.1.2 will 2098 result in each agent selecting a different role -- one controlling 2099 and one controlled. However, in unusual call flows, typically 2100 utilizing third party call control, it is possible for both agents to 2101 select the same role. This section describes procedures for checking 2102 for this case and repairing it. These procedures apply only to 2103 usages of ICE that require conflict resolution. The usage document 2104 MUST specify whether this mechanism is needed. 2106 An agent MUST examine the Binding request for either the ICE- 2107 CONTROLLING or ICE-CONTROLLED attribute. It MUST follow these 2108 procedures: 2110 o If neither ICE-CONTROLLING nor ICE-CONTROLLED is present in the 2111 request, the peer agent may have implemented a previous version of 2112 this specification. There may be a conflict, but it cannot be 2113 detected. 2115 o If the agent is in the controlling role, and the ICE-CONTROLLING 2116 attribute is present in the request: 2118 * If the agent's tie-breaker is larger than or equal to the 2119 contents of the ICE-CONTROLLING attribute, the agent generates 2120 a Binding error response and includes an ERROR-CODE attribute 2121 with a value of 487 (Role Conflict) but retains its role. 2123 * If the agent's tie-breaker is less than the contents of the 2124 ICE-CONTROLLING attribute, the agent switches to the controlled 2125 role. 2127 o If the agent is in the controlled role, and the ICE-CONTROLLED 2128 attribute is present in the request: 2130 * If the agent's tie-breaker is larger than or equal to the 2131 contents of the ICE-CONTROLLED attribute, the agent switches to 2132 the controlling role. 2134 * If the agent's tie-breaker is less than the contents of the 2135 ICE-CONTROLLED attribute, the agent generates a Binding error 2136 response and includes an ERROR-CODE attribute with a value of 2137 487 (Role Conflict) but retains its role. 2139 o If the agent is in the controlled role and the ICE-CONTROLLING 2140 attribute was present in the request, or the agent was in the 2141 controlling role and the ICE-CONTROLLED attribute was present in 2142 the request, there is no conflict. 2144 A change in roles will require an agent to recompute pair priorities 2145 (Section 5.1.3.2), since those priorities are a function of 2146 controlling and controlled roles. The change in role will also 2147 impact whether the agent is responsible for selecting nominated pairs 2148 and initiating exchange with updated candidate information upon 2149 conclusion of ICE. 2151 The remaining sections in Section 6.2.1 are followed if the server 2152 generated a successful response to the Binding request, even if the 2153 agent changed roles. 2155 6.2.1.2. Computing Mapped Address 2157 For requests being received on a relayed candidate, the source 2158 transport address used for STUN processing (namely, generation of the 2159 XOR-MAPPED-ADDRESS attribute) is the transport address as seen by the 2160 TURN server. That source transport address will be present in the 2161 XOR-PEER-ADDRESS attribute of a Data Indication message, if the 2162 Binding request was delivered through a Data Indication. If the 2163 Binding request was delivered through a ChannelData message, the 2164 source transport address is the one that was bound to the channel. 2166 6.2.1.3. Learning Peer Reflexive Candidates 2168 If the source transport address of the request does not match any 2169 existing remote candidates, it represents a new peer reflexive remote 2170 candidate. This candidate is constructed as follows: 2172 o The priority of the candidate is set to the PRIORITY attribute 2173 from the request. 2175 o The type of the candidate is set to peer reflexive. 2177 o The foundation of the candidate is set to an arbitrary value, 2178 different from the foundation for all other remote candidates. If 2179 any subsequent candidate exchanges contain this peer reflexive 2180 candidate, it will signal the actual foundation for the candidate. 2182 o The component ID of this candidate is set to the component ID for 2183 the local candidate to which the request was sent. 2185 This candidate is added to the list of remote candidates. However, 2186 the agent does not pair this candidate with any local candidates. 2188 6.2.1.4. Triggered Checks 2190 Next, the agent constructs a pair whose local candidate is equal to 2191 the transport address on which the STUN request was received, and a 2192 remote candidate equal to the source transport address where the 2193 request came from (which may be the peer reflexive remote candidate 2194 that was just learned). The local candidate will either be a host 2195 candidate (for cases where the request was not received through a 2196 relay) or a relayed candidate (for cases where it is received through 2197 a relay). The local candidate can never be a server reflexive 2198 candidate. Since both candidates are known to the agent, it can 2199 obtain their priorities and compute the candidate pair priority. 2200 This pair is then looked up in the check list. There can be one of 2201 several outcomes: 2203 o If the pair is already on the check list: 2205 * If the state of that pair is Waiting or Frozen, a check for 2206 that pair is enqueued into the triggered check queue if not 2207 already present. 2209 * If the state of that pair is In-Progress, the agent cancels the 2210 in-progress transaction. Cancellation means that the agent 2211 will not retransmit the request, will not treat the lack of 2212 response to be a failure, but will wait the duration of the 2213 transaction timeout for a response. In addition, the agent 2214 MUST create a new connectivity check for that pair 2215 (representing a new STUN Binding request transaction) by 2216 enqueueing the pair in the triggered check queue. The state of 2217 the pair is then changed to Waiting. 2219 * If the state of the pair is Failed, it is changed to Waiting 2220 and the agent MUST create a new connectivity check for that 2221 pair (representing a new STUN Binding request transaction), by 2222 enqueueing the pair in the triggered check queue. 2224 * If the state of that pair is Succeeded, nothing further is 2225 done. 2227 These steps are done to facilitate rapid completion of ICE when both 2228 agents are behind NAT. 2230 o If the pair is not already on the check list: 2232 * The pair is inserted into the check list based on its priority. 2234 * Its state is set to Waiting. 2236 * The pair is enqueued into the triggered check queue. 2238 When a triggered check is to be sent, it is constructed and processed 2239 as described in Section 6.1.2. These procedures require the agent to 2240 know the transport address, username fragment, and password for the 2241 peer. The username fragment for the remote candidate is equal to the 2242 part after the colon of the USERNAME in the Binding request that was 2243 just received. Using that username fragment, the agent can check the 2244 candidates received from its peer (there may be more than one in 2245 cases of forking), and find this username fragment. The 2246 corresponding password is then selected. 2248 6.2.1.5. Updating the Nominated Flag 2250 If the Binding request received by the agent had the USE-CANDIDATE 2251 attribute set, and the agent is in the controlled role, the agent 2252 looks at the state of the pair computed in Section 6.2.1.4: 2254 o If the state of this pair is Succeeded, it means that the check 2255 generated by this pair produced a successful response. This would 2256 have caused the agent to construct a valid pair when that success 2257 response was received (see Section 6.1.3.2.2). The agent now sets 2258 the nominated flag in the valid pair to true. This may end ICE 2259 processing for this media stream; see Section 7. 2261 o If the state of this pair is In-Progress, if its check produces a 2262 successful result, the resulting valid pair has its nominated flag 2263 set when the response arrives. This may end ICE processing for 2264 this media stream when it arrives; see Section 7. 2266 6.2.2. Additional Procedures for Lite Implementations 2268 If the check that was just received contained a USE-CANDIDATE 2269 attribute, the agent constructs a candidate pair whose local 2270 candidate is equal to the transport address on which the request was 2271 received, and whose remote candidate is equal to the source transport 2272 address of the request that was received. This candidate pair is 2273 assigned an arbitrary priority, and placed into a list of valid 2274 candidates called the valid list. The agent sets the nominated flag 2275 for that pair to true. ICE processing is considered complete for a 2276 media stream if the valid list contains a candidate pair for each 2277 component. 2279 7. Concluding ICE Processing 2281 This section describes how an agent completes ICE. 2283 7.1. Procedures for Full Implementations 2285 Concluding ICE involves nominating pairs by the controlling agent and 2286 updating of state machinery. 2288 7.1.1. Nominating Pairs 2290 When nominating, the controlling agent lets some number of checks 2291 complete, each of which omit the USE-CANDIDATE attribute. Once one 2292 or more checks complete successfully for a component of a media 2293 stream, valid pairs are generated and added to the valid list. The 2294 agent lets the checks continue until some stopping criterion is met, 2295 and then picks amongst the valid pairs based on an evaluation 2296 criterion. The criteria for stopping the checks and for evaluating 2297 the valid pairs is entirely a matter of local optimization. 2299 When the controlling agent selects the valid pair, it repeats the 2300 check that produced this valid pair (by enqueueing the pair that 2301 generated the check into the triggered check queue), this time with 2302 the USE-CANDIDATE attribute. This check should succeed (since the 2303 previous did), causing the nominated flag of that and only that pair 2304 to be set. Consequently, there will be only a single nominated pair 2305 in the valid list for each component, and when the state of the check 2306 list moves to completed, that exact pair is selected by ICE for 2307 sending and receiving media for that component. 2309 The controlling agent has control over the stopping and selection 2310 criteria for checks. The only requirement is that the agent MUST 2311 eventually pick one and only one candidate pair and generate a check 2312 for that pair with the USE-CANDIDATE attribute present. 2314 The controlled agent SHOULD select the nominated candidate pair if 2315 the agent is receiving Binding responses associated with that 2316 candidiate pair. Before the agent has received Binding responses 2317 associated with the candidiate pair, the agent can send media on any 2318 candidiate for which it has received Binding responses. If more than 2319 one candidate pair is nominated by the controlling agent, the 2320 controlled agent SHOULD select the candidate pair with the highest 2321 priority. 2323 NOTE: A controlling agent that does not support this speification 2324 (i.e. it is implemented according to RFC 5245) might nominate more 2325 than one candidiate pair. This was referred to as aggressive 2326 nomination in RFC 5245. The usage of the 'ice2' ice option by 2327 endpoints supporting this specifcation should prevent such 2328 controlling agents from using aggressive nomination. 2330 7.1.2. Updating States 2332 For both controlling and controlled agents, the state of ICE 2333 processing depends on the presence of nominated candidate pairs in 2334 the valid list and on the state of the check list. Note that, at any 2335 time, more than one of the following cases can apply: 2337 o If there are no nominated pairs in the valid list for a media 2338 stream and the state of the check list is Running, ICE processing 2339 continues. 2341 o If there is at least one nominated pair in the valid list for a 2342 media stream and the state of the check list is Running: 2344 * The agent MUST remove all Waiting and Frozen pairs in the check 2345 list and triggered check queue for the same component as the 2346 nominated pairs for that media stream. 2348 * If an In-Progress pair in the check list is for the same 2349 component as a nominated pair, the agent SHOULD cease 2350 retransmissions for its check if its pair priority is lower 2351 than the lowest-priority nominated pair for that component. 2353 o Once there is at least one nominated pair in the valid list for 2354 every component of at least one media stream and the state of the 2355 check list is Running: 2357 * The agent MUST change the state of processing for its check 2358 list for that media stream to Completed. 2360 * The agent MUST continue to respond to any checks it may still 2361 receive for that media stream, and MUST perform triggered 2362 checks if required by the processing of Section 6.2. 2364 * The agent MUST continue retransmitting any In-Progress checks 2365 for that check list. 2367 * The agent MAY begin transmitting media for this media stream as 2368 described in Section 11.1. 2370 o Once the state of each check list is Completed: 2372 * The agent sets the state of ICE processing overall to 2373 Completed. 2375 o If the state of the check list is Failed, ICE has not been able to 2376 complete for this media stream. The correct behavior depends on 2377 the state of the check lists for other media streams: 2379 * If all check lists are Failed, ICE processing overall is 2380 considered to be in the Failed state, and the agent SHOULD 2381 consider the session a failure, SHOULD NOT restart ICE, and the 2382 controlling agent SHOULD terminate the entire session. 2384 * If at least one of the check lists for other media streams is 2385 Completed, the controlling agent SHOULD remove the failed media 2386 stream from the session while sending updated candidate list to 2387 its peer. 2389 * If none of the check lists for other media streams are 2390 Completed, but at least one is Running, the agent SHOULD let 2391 ICE continue. 2393 7.2. Procedures for Lite Implementations 2395 Concluding ICE for a lite implementation is relatively 2396 straightforward. There are two cases to consider: 2398 The implementation is lite, and its peer is full. 2400 The implementation is lite, and its peer is lite. 2402 The effect of ICE concluding is that the agent can free any allocated 2403 host candidates that were not utilized by ICE, as described in 2404 Section 7.3. 2406 7.2.1. Peer Is Full 2408 In this case, the agent will receive connectivity checks from its 2409 peer. When an agent has received a connectivity check that includes 2410 the USE-CANDIDATE attribute for each component of a media stream, the 2411 state of ICE processing for that media stream moves from Running to 2412 Completed. When the state of ICE processing for all media streams is 2413 Completed, the state of ICE processing overall is Completed. 2415 The lite implementation will never itself determine that ICE 2416 processing has failed for a media stream; rather, the full peer will 2417 make that determination and then remove or restart the failed media 2418 stream as part of subsequent candidate exchange process. 2420 7.2.2. Peer Is Lite 2422 Once the candidate exchange has completed, both agents examine their 2423 candidates and those of its peer. For each media stream, each agent 2424 pairs up its own candidates with the candidates of its peer for that 2425 media stream. Two candidates are paired up when they are for the 2426 same component, utilize the same transport protocol (UDP in this 2427 specification), and are from the same IP address family (IPv4 or 2428 IPv6). 2430 o If there is a single pair per component, that pair is added to the 2431 Valid list. If all of the components for a media stream had one 2432 pair, the state of ICE processing for that media stream is set to 2433 Completed. If all media streams are Completed, the state of ICE 2434 processing is set to Completed overall. This will always be the 2435 case for implementations that are IPv4-only. 2437 o If there is more than one pair per component: 2439 * The agent MUST select a pair based on local policy. Since this 2440 case only arises for IPv6, it is RECOMMENDED that an agent 2441 follow the procedures of RFC 6724 [RFC6724] to select a single 2442 pair. 2444 * The agent adds the selected pair for each component to the 2445 valid list. As described in Section 11.1, this will permit 2446 media to begin flowing. However, it is possible (and in fact 2447 likely) that both agents have chosen different pairs. 2449 * To reconcile this, the controlling agent MUST send updated 2450 candidate list which will include the remote-candidates 2451 attribute. 2453 * The agent MUST NOT update the state of ICE processing until 2454 after the candidate exchange completes. Then the controlling 2455 agent MUST change the state of ICE processing to Completed for 2456 all media streams, and the state of ICE processing overall to 2457 Completed. 2459 7.3. Freeing Candidates 2461 7.3.1. Full Implementation Procedures 2463 The procedures in Section 7 require that an agent continue to listen 2464 for STUN requests and continue to generate triggered checks for a 2465 media stream, even once processing for that stream completes. The 2466 rules in this section describe when it is safe for an agent to cease 2467 sending or receiving checks on a candidate that was not selected by 2468 ICE, and then free the candidate. 2470 7.3.2. Lite Implementation Procedures 2472 A lite implementation MAY free candidates not selected by ICE as soon 2473 as ICE processing has reached the Completed state for all peers for 2474 all media streams using those candidates. 2476 8. ICE Restarts 2478 An agent MAY restart ICE processing for an existing media stream. An 2479 ICE restart, as the name implies, will cause all previous states of 2480 ICE processing to be flushed and checks to start anew. The only 2481 difference between an ICE restart and a brand new media session is 2482 that, during the restart, media can continue to be sent to the 2483 previously validated pair. 2485 An agent MUST restart ICE for a media stream if: 2487 o The candidate(s) is being generated for the purposes of changing 2488 the target of the media stream. In other words, if an agent wants 2489 to generate an updated candidate information that, had ICE not 2490 been in use, would result in a new value for the destination of a 2491 media component. 2493 o An agent is changing its implementation level. This typically 2494 only happens in third party call control use cases, where the 2495 entity performing the signaling is not the entity receiving the 2496 media, and it has changed the target of media mid-session to 2497 another entity that has a different ICE implementation. 2499 To restart ICE, an agent MUST change both the password and the user 2500 name fragment for the media stream when exchanging the candidates. 2501 The new candidate set MAY include some, none, or all of the previous 2502 candidates for that stream and MAY include a totally new set of 2503 candidates. 2505 9. ICE Option 2507 This section defines a new ICE option, 'ice2'. The ICE option 2508 indicates that the ICE agent that includes it (in an ice-options 2509 attribute) is compliant to this specification. For example, the ICE 2510 agent will not use the aggressive nomination procedure defined in 2511 [RFC5245]. 2513 An ICE agent compliant to this specification MUST inform the peer 2514 about the compliance using the 'ice2' ICE option. 2516 NOTE: The encoding of the 'ice2' ICE option, and the message(s) used 2517 to carry it to the peer, are protocol specific. The encoding for the 2518 Session Description Protocol (SDP) [RFC4566] is defined in 2519 [I-D.ietf-mmusic-ice-sip-sdp]. 2521 10. Keepalives 2523 All endpoints MUST send keepalives for each media session. These 2524 keepalives serve the purpose of keeping NAT bindings alive for the 2525 media session. These keepalives MUST be sent even if ICE is not 2526 being utilized for the session at all. The keepalive SHOULD be sent 2527 using a format that is supported by its peer. ICE endpoints allow 2528 for STUN-based keepalives for UDP streams, and as such, STUN 2529 keepalives MUST be used when an agent is a full ICE implementation 2530 and is communicating with a peer that supports ICE (lite or full). 2531 If the peer does not support ICE, the choice of a packet format for 2532 keepalives is a matter of local implementation. A format that allows 2533 packets to easily be sent in the absence of actual media content is 2534 RECOMMENDED. Examples of formats that readily meet this goal are RTP 2535 No-Op [I-D.ietf-avt-rtp-no-op], and in cases where both sides support 2536 it, RTP comfort noise [RFC3389]. If the peer doesn't support any 2537 formats that are particularly well suited for keepalives, an agent 2538 SHOULD send RTP packets with an incorrect version number, or some 2539 other form of error that would cause them to be discarded by the 2540 peer. 2542 If there has been no packet sent on the candidate pair ICE is using 2543 for a media component for Tr seconds (where packets include those 2544 defined for the component (RTP or RTCP) and previous keepalives), an 2545 agent MUST generate a keepalive on that pair. Tr SHOULD be 2546 configurable and SHOULD have a default of 15 seconds. Tr MUST NOT be 2547 configured to less than 15 seconds. Alternatively, if an agent has a 2548 dynamic way to discover the binding lifetimes of the intervening 2549 NATs, it can use that value to determine Tr. Administrators 2550 deploying ICE in more controlled networking environments SHOULD set 2551 Tr to the longest duration possible in their environment. 2553 If STUN is being used for keepalives, a STUN Binding Indication is 2554 used [RFC5389]. The Indication MUST NOT utilize any authentication 2555 mechanism. It SHOULD contain the FINGERPRINT attribute to aid in 2556 demultiplexing, but SHOULD NOT contain any other attributes. It is 2557 used solely to keep the NAT bindings alive. The Binding Indication 2558 is sent using the same local and remote candidates that are being 2559 used for media. Though Binding Indications are used for keepalives, 2560 an agent MUST be prepared to receive a connectivity check as well. 2561 If a connectivity check is received, a response is generated as 2562 discussed in [RFC5389], but there is no impact on ICE processing 2563 otherwise. 2565 An agent MUST begin the keepalive processing once ICE has selected 2566 candidates for usage with media, or media begins to flow, whichever 2567 happens first. Keepalives end once the session terminates or the 2568 media stream is removed. 2570 11. Media Handling 2572 11.1. Sending Media 2574 Procedures for sending media differ for full and lite 2575 implementations. 2577 11.1.1. Procedures for Full Implementations 2579 Agents always send media using a candidate pair, called the selected 2580 candidate pair. An agent will send media to the remote candidate in 2581 the selected pair (setting the destination address and port of the 2582 packet equal to that remote candidate), and will send it from the 2583 local candidate of the selected pair. When the local candidate is 2584 server or peer reflexive, media is originated from the base. Media 2585 sent from a relayed candidate is sent from the base through that TURN 2586 server, using procedures defined in [RFC5766]. 2588 If the local candidate is a relayed candidate, it is RECOMMENDED that 2589 an agent create a channel on the TURN server towards the remote 2590 candidate. This is done using the procedures for channel creation as 2591 defined in Section 11 of [RFC5766]. 2593 The selected pair for a component of a media stream is: 2595 o empty if the state of the check list for that media stream is 2596 Running, and there is no previous selected pair for that component 2597 due to an ICE restart 2599 o equal to the previous selected pair for a component of a media 2600 stream if the state of the check list for that media stream is 2601 Running, and there was a previous selected pair for that component 2602 due to an ICE restart 2604 o equal to the highest-priority nominated pair for that component in 2605 the valid list if the state of the check list is Completed 2607 If the selected pair for at least one component of a media stream is 2608 empty, an agent MUST NOT send media for any component of that media 2609 stream. If the selected pair for each component of a media stream 2610 has a value, an agent MAY send media for all components of that media 2611 stream. 2613 11.1.2. Procedures for Lite Implementations 2615 A lite implementation MUST NOT send media until it has a Valid list 2616 that contains a candidate pair for each component of that media 2617 stream. Once that happens, the agent MAY begin sending media 2618 packets. To do that, it sends media to the remote candidate in the 2619 pair (setting the destination address and port of the packet equal to 2620 that remote candidate), and will send it from the local candidate. 2622 11.1.3. Procedures for All Implementations 2624 ICE has interactions with jitter buffer adaptation mechanisms. An 2625 RTP stream can begin using one candidate, and switch to another one, 2626 though this happens rarely with ICE. The newer candidate may result 2627 in RTP packets taking a different path through the network -- one 2628 with different delay characteristics. As discussed below, agents are 2629 encouraged to re-adjust jitter buffers when there are changes in 2630 source or destination address of media packets. Furthermore, many 2631 audio codecs use the marker bit to signal the beginning of a 2632 talkspurt, for the purposes of jitter buffer adaptation. For such 2633 codecs, it is RECOMMENDED that the sender set the marker bit 2634 [RFC3550] when an agent switches transmission of media from one 2635 candidate pair to another. 2637 11.2. Receiving Media 2639 ICE implementations MUST be prepared to receive media on each 2640 component on any candidates provided for that component in the most 2641 recent candidate exchange (in the case of RTP, this would include 2642 both RTP and RTCP if candidates were provided for both). 2644 It is RECOMMENDED that, when an agent receives an RTP packet with a 2645 new source or destination IP address for a particular media stream, 2646 that the agent re-adjust its jitter buffers. 2648 RFC 3550 [RFC3550] describes an algorithm in Section 8.2 for 2649 detecting synchronization source (SSRC) collisions and loops. These 2650 algorithms are based, in part, on seeing different source transport 2651 addresses with the same SSRC. However, when ICE is used, such 2652 changes will sometimes occur as the media streams switch between 2653 candidates. An agent will be able to determine that a media stream 2654 is from the same peer as a consequence of the STUN exchange that 2655 proceeds media transmission. Thus, if there is a change in source 2656 transport address, but the media packets come from the same peer 2657 agent, this SHOULD NOT be treated as an SSRC collision. 2659 12. Extensibility Considerations 2661 This specification makes very specific choices about how both agents 2662 in a session coordinate to arrive at the set of candidate pairs that 2663 are selected for media. It is anticipated that future specifications 2664 will want to alter these algorithms, whether they are simple changes 2665 like timer tweaks or larger changes like a revamp of the priority 2666 algorithm. When such a change is made, providing interoperability 2667 between the two agents in a session is critical. 2669 First, ICE provides the ice-options attribute. Each extension or 2670 change to ICE is associated with a token. When an agent supporting 2671 such an extension or change triggers candidate exchange, it MUST 2672 include the token for that extension in this attribute. This allows 2673 each side to know what the other side is doing. This attribute MUST 2674 NOT be present if the agent doesn't support any ICE extensions or 2675 changes. 2677 One of the complications in achieving interoperability is that ICE 2678 relies on a distributed algorithm running on both agents to converge 2679 on an agreed set of candidate pairs. If the two agents run different 2680 algorithms, it can be difficult to guarantee convergence on the same 2681 candidate pairs. The regular nomination procedure described in 2682 Section 7 eliminates some of the tight coordination by delegating the 2683 selection algorithm completely to the controlling agent. 2684 Consequently, when a controlling agent is communicating with a peer 2685 that supports options it doesn't know about, the agent MUST run a 2686 regular nomination algorithm. When regular nomination is used, ICE 2687 will converge perfectly even when both agents use different pair 2688 prioritization algorithms. One of the keys to such convergence is 2689 triggered checks, which ensure that the nominated pair is validated 2690 by both agents. Consequently, any future ICE enhancements MUST 2691 preserve triggered checks. 2693 ICE is also extensible to other media streams beyond RTP, and for 2694 transport protocols beyond UDP. Extensions to ICE for non-RTP media 2695 streams need to specify how many components they utilize, and assign 2696 component IDs to them, starting at 1 for the most important component 2697 ID. Specifications for new transport protocols must define how, if 2698 at all, various steps in the ICE processing differ from UDP. 2700 13. Setting Ta and RTO 2702 During the gathering phase of ICE (Section 4.1.1) and while ICE is 2703 performing connectivity checks (Section 6), an agent sends STUN and 2704 TURN transactions. These transactions are paced at a rate of one 2705 every Ta milliseconds, and utilize a specific RTO. This section 2706 describes how the values of Ta and RTO are computed. This 2707 computation depends on whether ICE is being used with a real-time 2708 media stream (such as RTP) or something else. When ICE is used for a 2709 stream with a known maximum bandwidth, the computation in 2710 Section 13.1 MAY be followed to rate-control the ICE exchanges. For 2711 all other streams, the computation in Section 13.2 MUST be followed. 2713 13.1. Real-time Media Streams 2715 The values of RTO and Ta change during the lifetime of ICE 2716 processing. One set of values applies during the gathering phase, 2717 and the other, for connectivity checks. 2719 The value of Ta SHOULD be configurable, and SHOULD have a default of: 2721 For each media stream i: 2722 Ta_i = (stun_packet_size / rtp_packet_size) * rtp_ptime 2724 1 2725 Ta = MAX (20ms, ------------------- ) 2726 k 2727 ---- 2728 \ 1 2729 > ------ 2730 / Ta_i 2731 ---- 2732 i=1 2734 where k is the number of media streams. During the gathering phase, 2735 Ta is computed based on the number of media streams the agent has 2736 indicated in the candidate information, and the RTP packet size and 2737 RTP ptime are those of the most preferred codec for each media 2738 stream. Once the candidate exchange is completed, the agent 2739 recomputes Ta to pace the connectivity checks. In that case, the 2740 value of Ta is based on the number of media streams that will 2741 actually be used in the session, and the RTP packet size and RTP 2742 ptime are those of the most preferred codec with which the agent will 2743 send. 2745 In addition, the retransmission timer for the STUN transactions, RTO, 2746 defined in [RFC5389], SHOULD be configurable and during the gathering 2747 phase, SHOULD have a default of: 2749 RTO = MAX (100ms, Ta * (number of pairs)) 2751 where the number of pairs refers to the number of pairs of candidates 2752 with STUN or TURN servers. 2754 For connectivity checks, RTO SHOULD be configurable and SHOULD have a 2755 default of: 2757 RTO = MAX (100ms, Ta*N * (Num-Waiting + Num-In-Progress)) 2759 where Num-Waiting is the number of checks in the check list in the 2760 Waiting state, and Num-In-Progress is the number of checks in the In- 2761 Progress state. Note that the RTO will be different for each 2762 transaction as the number of checks in the Waiting and In-Progress 2763 states change. 2765 These formulas are aimed at causing STUN transactions to be paced at 2766 the same rate as media. This ensures that ICE will work properly 2767 under the same network conditions needed to support the media as 2768 well. See Appendix B.1 for additional discussion and motivations. 2769 Because of this pacing, it will take a certain amount of time to 2770 obtain all of the server reflexive and relayed candidates. 2771 Implementations should be aware of the time required to do this, and 2772 if the application requires a time budget, limit the number of 2773 candidates that are gathered. 2775 The formulas result in a behavior whereby an agent will send its 2776 first packet for every single connectivity check before performing a 2777 retransmit. This can be seen in the formulas for the RTO (which 2778 represents the retransmit interval). Those formulas scale with N, 2779 the number of checks to be performed. As a result of this, ICE 2780 maintains a nicely constant rate, but becomes more sensitive to 2781 packet loss. The loss of the first single packet for any 2782 connectivity check is likely to cause that pair to take a long time 2783 to be validated, and instead, a lower-priority check (but one for 2784 which there was no packet loss) is much more likely to complete 2785 first. This results in ICE performing sub-optimally, choosing lower- 2786 priority pairs over higher-priority pairs. Implementors should be 2787 aware of this consequence, but still should utilize the timer values 2788 described here. 2790 13.2. Non-real-time Sessions 2792 In cases where ICE is used to establish some kind of session that is 2793 not real time, and has no fixed rate associated with it that is known 2794 to work on the network in which ICE is deployed, Ta and RTO revert to 2795 more conservative values. Ta SHOULD be configurable, SHOULD have a 2796 default of 500 ms, and MUST NOT be configurable to be less than 500 2797 ms. 2799 If other Ta value than the default is used, the agent MUST indicate 2800 the value it prefers to use in the ICE exchange. Both agents MUST 2801 use the higher out of the two proposed values. 2803 In addition, the retransmission timer for the STUN transactions, RTO, 2804 SHOULD be configurable and during the gathering phase, SHOULD have a 2805 default of: 2807 RTO = MAX (500ms, Ta * (number of pairs)) 2809 where the number of pairs refers to the number of pairs of candidates 2810 with STUN or TURN servers. 2812 For connectivity checks, RTO SHOULD be configurable and SHOULD have a 2813 default of: 2815 RTO = MAX (500ms, Ta*N * (Num-Waiting + Num-In-Progress)) 2817 14. Example 2819 The example is based on the simplified topology of Figure 8. 2821 +-------+ 2822 |STUN | 2823 |Server | 2824 +-------+ 2825 | 2826 +---------------------+ 2827 | | 2828 | Internet | 2829 | | 2830 +---------------------+ 2831 | | 2832 | | 2833 +---------+ | 2834 | NAT | | 2835 +---------+ | 2836 | | 2837 | | 2838 +-----+ +-----+ 2839 | L | | R | 2840 +-----+ +-----+ 2842 Figure 8: Example Topology 2844 Two agents, L and R, are using ICE. Both are full-mode ICE 2845 implementations and use aggressive nomination when they are 2846 controlling. Both agents have a single IPv4 address. For agent L, 2847 it is 10.0.1.1 in private address space [RFC1918], and for agent R, 2848 192.0.2.1 on the public Internet. Both are configured with the same 2849 STUN server (shown in this example for simplicity, although in 2850 practice the agents do not need to use the same STUN server), which 2851 is listening for STUN Binding requests at an IP address of 192.0.2.2 2852 and port 3478. TURN servers are not used in this example. Agent L 2853 is behind a NAT, and agent R is on the public Internet. The NAT has 2854 an endpoint independent mapping property and an address dependent 2855 filtering property. The public side of the NAT has an IP address of 2856 192.0.2.3. 2858 To facilitate understanding, transport addresses are listed using 2859 variables that have mnemonic names. The format of the name is 2860 entity-type-seqno, where entity refers to the entity whose IP address 2861 the transport address is on, and is one of "L", "R", "STUN", or 2862 "NAT". The type is either "PUB" for transport addresses that are 2863 public, and "PRIV" for transport addresses that are private. 2864 Finally, seq-no is a sequence number that is different for each 2865 transport address of the same type on a particular entity. Each 2866 variable has an IP address and port, denoted by varname.IP and 2867 varname.PORT, respectively, where varname is the name of the 2868 variable. 2870 The STUN server has advertised transport address STUN-PUB-1 (which is 2871 192.0.2.2:3478). 2873 In the call flow itself, STUN messages are annotated with several 2874 attributes. The "S=" attribute indicates the source transport 2875 address of the message. The "D=" attribute indicates the destination 2876 transport address of the message. The "MA=" attribute is used in 2877 STUN Binding response messages and refers to the mapped address. 2878 "USE-CAND" implies the presence of the USE-CANDIDATE attribute. 2880 The call flow examples omit STUN authentication operations and RTCP, 2881 and focus on RTP for a single media stream between two full 2882 implementations. 2884 L NAT STUN R 2885 |RTP STUN alloc. | | 2886 |(1) STUN Req | | | 2887 |S=$L-PRIV-1 | | | 2888 |D=$STUN-PUB-1 | | | 2889 |------------->| | | 2890 | |(2) STUN Req | | 2891 | |S=$NAT-PUB-1 | | 2892 | |D=$STUN-PUB-1 | | 2893 | |------------->| | 2894 | |(3) STUN Res | | 2895 | |S=$STUN-PUB-1 | | 2896 | |D=$NAT-PUB-1 | | 2897 | |MA=$NAT-PUB-1 | | 2898 | |<-------------| | 2899 |(4) STUN Res | | | 2900 |S=$STUN-PUB-1 | | | 2901 |D=$L-PRIV-1 | | | 2902 |MA=$NAT-PUB-1 | | | 2903 |<-------------| | | 2904 |(5) L's Candidate Information| | 2905 |------------------------------------------->| 2906 | | | | RTP STUN 2907 | | | | alloc. 2908 | | |(6) STUN Req | 2909 | | |S=$R-PUB-1 | 2910 | | |D=$STUN-PUB-1 | 2911 | | |<-------------| 2912 | | |(7) STUN Res | 2913 | | |S=$STUN-PUB-1 | 2914 | | |D=$R-PUB-1 | 2915 | | |MA=$R-PUB-1 | 2916 | | |------------->| 2917 |(8) R's Candidate Information| | 2918 |<-------------------------------------------| 2919 | |(9) Bind Req | |Begin 2920 | |S=$R-PUB-1 | |Connectivity 2921 | |D=L-PRIV-1 | |Checks 2922 | |<----------------------------| 2923 | |Dropped | | 2924 |(10) Bind Req | | | 2925 |S=$L-PRIV-1 | | | 2926 |D=$R-PUB-1 | | | 2927 |USE-CAND | | | 2928 |------------->| | | 2929 | |(11) Bind Req | | 2930 | |S=$NAT-PUB-1 | | 2931 | |D=$R-PUB-1 | | 2932 | |USE-CAND | | 2933 | |---------------------------->| 2934 | |(12) Bind Res | | 2935 | |S=$R-PUB-1 | | 2936 | |D=$NAT-PUB-1 | | 2937 | |MA=$NAT-PUB-1 | | 2938 | |<----------------------------| 2939 |(13) Bind Res | | | 2940 |S=$R-PUB-1 | | | 2941 |D=$L-PRIV-1 | | | 2942 |MA=$NAT-PUB-1 | | | 2943 |<-------------| | | 2944 |RTP flows | | | 2945 | |(14) Bind Req | | 2946 | |S=$R-PUB-1 | | 2947 | |D=$NAT-PUB-1 | | 2948 | |<----------------------------| 2949 |(15) Bind Req | | | 2950 |S=$R-PUB-1 | | | 2951 |D=$L-PRIV-1 | | | 2952 |<-------------| | | 2953 |(16) Bind Res | | | 2954 |S=$L-PRIV-1 | | | 2955 |D=$R-PUB-1 | | | 2956 |MA=$R-PUB-1 | | | 2957 |------------->| | | 2958 | |(17) Bind Res | | 2959 | |S=$NAT-PUB-1 | | 2960 | |D=$R-PUB-1 | | 2961 | |MA=$R-PUB-1 | | 2962 | |---------------------------->| 2963 | | | |RTP flows 2965 Figure 9: Example Flow 2967 First, agent L obtains a host candidate from its local IP address 2968 (not shown), and from that, sends a STUN Binding request to the STUN 2969 server to get a server reflexive candidate (messages 1-4). Recall 2970 that the NAT has the address and port independent mapping property. 2971 Here, it creates a binding of NAT-PUB-1 for this UDP request, and 2972 this becomes the server reflexive candidate for RTP. 2974 Agent L sets a type preference of 126 for the host candidate and 100 2975 for the server reflexive. The local preference is 65535. Based on 2976 this, the priority of the host candidate is 2130706431 and for the 2977 server reflexive candidate is 1694498815. The host candidate is 2978 assigned a foundation of 1, and the server reflexive, a foundation of 2979 2. These are sent to the peer. 2981 This candidate information is received at agent R. Agent R will 2982 obtain a host candidate, and from it, obtain a server reflexive 2983 candidate (messages 6-7). Since R is not behind a NAT, this 2984 candidate is identical to its host candidate, and they share the same 2985 base. It therefore discards this redundant candidate and ends up 2986 with a single host candidate. With identical type and local 2987 preferences as L, the priority for this candidate is 2130706431. It 2988 chooses a foundation of 1 for its single candidate. Then R's 2989 candidates are then sent to L. 2991 Since neither side indicated that it is lite, the initiating agent 2992 that began ICE processing (agent L) becomes the controlling agent. 2994 Agents L and R both pair up the candidates. They both initially have 2995 two pairs. However, agent L will prune the pair containing its 2996 server reflexive candidate, resulting in just one. At agent L, this 2997 pair has a local candidate of $L_PRIV_1 and remote candidate of 2998 $R_PUB_1, and has a candidate pair priority of 4.57566E+18 (note that 2999 an implementation would represent this as a 64-bit integer so as not 3000 to lose precision). At agent R, there are two pairs. The highest 3001 priority has a local candidate of $R_PUB_1 and remote candidate of 3002 $L_PRIV_1 and has a priority of 4.57566E+18, and the second has a 3003 local candidate of $R_PUB_1 and remote candidate of $NAT_PUB_1 and 3004 priority 3.63891E+18. 3006 Agent R begins its connectivity check (message 9) for the first pair 3007 (between the two host candidates). Since R is the controlled agent 3008 for this session, the check omits the USE-CANDIDATE attribute. The 3009 host candidate from agent L is private and behind a NAT, and thus 3010 this check won't be successful, because the packet cannot be routed 3011 from R to L. 3013 When agent L gets the R's candidates, it performs its one and only 3014 connectivity check (messages 10-13). It implements the aggressive 3015 nomination algorithm, and thus includes a USE-CANDIDATE attribute in 3016 this check. Since the check succeeds, agent L creates a new pair, 3017 whose local candidate is from the mapped address in the Binding 3018 response (NAT-PUB-1 from message 13) and whose remote candidate is 3019 the destination of the request (R-PUB-1 from message 10). This is 3020 added to the valid list. In addition, it is marked as selected since 3021 the Binding request contained the USE-CANDIDATE attribute. Since 3022 there is a selected candidate in the Valid list for the one component 3023 of this media stream, ICE processing for this stream moves into the 3024 Completed state. Agent L can now send media if it so chooses. 3026 Soon after receipt of the STUN Binding request from agent L (message 3027 11), agent R will generate its triggered check. This check happens 3028 to match the next one on its check list -- from its host candidate to 3029 agent L's server reflexive candidate. This check (messages 14-17) 3030 will succeed. Consequently, agent R constructs a new candidate pair 3031 using the mapped address from the response as the local candidate (R- 3032 PUB-1) and the destination of the request (NAT-PUB-1) as the remote 3033 candidate. This pair is added to the Valid list for that media 3034 stream. Since the check was generated in the reverse direction of a 3035 check that contained the USE-CANDIDATE attribute, the candidate pair 3036 is marked as selected. Consequently, processing for this stream 3037 moves into the Completed state, and agent R can also send media. 3039 15. Security Considerations 3041 There are several types of attacks possible in an ICE system. This 3042 section considers these attacks and their countermeasures. These 3043 countermeasures include: 3045 o Using ICE in conjunction with secure signaling techniques, such as 3046 SIPS. 3048 o Limiting the total number of connectivity checks to 100, and 3049 optionally limiting the number of candidates they'll accept in an 3050 candidate exchange. 3052 15.1. Attacks on Connectivity Checks 3054 An attacker might attempt to disrupt the STUN connectivity checks. 3055 Ultimately, all of these attacks fool an agent into thinking 3056 something incorrect about the results of the connectivity checks. 3057 The possible false conclusions an attacker can try and cause are: 3059 False Invalid: An attacker can fool a pair of agents into thinking a 3060 candidate pair is invalid, when it isn't. This can be used to 3061 cause an agent to prefer a different candidate (such as one 3062 injected by the attacker) or to disrupt a call by forcing all 3063 candidates to fail. 3065 False Valid: An attacker can fool a pair of agents into thinking a 3066 candidate pair is valid, when it isn't. This can cause an agent 3067 to proceed with a session, but then not be able to receive any 3068 media. 3070 False Peer Reflexive Candidate: An attacker can cause an agent to 3071 discover a new peer reflexive candidate, when it shouldn't have. 3072 This can be used to redirect media streams to a Denial-of-Service 3073 (DoS) target or to the attacker, for eavesdropping or other 3074 purposes. 3076 False Valid on False Candidate: An attacker has already convinced an 3077 agent that there is a candidate with an address that doesn't 3078 actually route to that agent (for example, by injecting a false 3079 peer reflexive candidate or false server reflexive candidate). It 3080 must then launch an attack that forces the agents to believe that 3081 this candidate is valid. 3083 If an attacker can cause a false peer reflexive candidate or false 3084 valid on a false candidate, it can launch any of the attacks 3085 described in [RFC5389]. 3087 To force the false invalid result, the attacker has to wait for the 3088 connectivity check from one of the agents to be sent. When it is, 3089 the attacker needs to inject a fake response with an unrecoverable 3090 error response, such as a 400. However, since the candidate is, in 3091 fact, valid, the original request may reach the peer agent, and 3092 result in a success response. The attacker needs to force this 3093 packet or its response to be dropped, through a DoS attack, layer 2 3094 network disruption, or other technique. If it doesn't do this, the 3095 success response will also reach the originator, alerting it to a 3096 possible attack. Fortunately, this attack is mitigated completely 3097 through the STUN short-term credential mechanism. The attacker needs 3098 to inject a fake response, and in order for this response to be 3099 processed, the attacker needs the password. If the candidate 3100 exchange signaling is secured, the attacker will not have the 3101 password and its response will be discarded. 3103 Forcing the fake valid result works in a similar way. The agent 3104 needs to wait for the Binding request from each agent, and inject a 3105 fake success response. The attacker won't need to worry about 3106 disrupting the actual response since, if the candidate is not valid, 3107 it presumably wouldn't be received anyway. However, like the fake 3108 invalid attack, this attack is mitigated by the STUN short-term 3109 credential mechanism in conjunction with a secure candidate exchange. 3111 Forcing the false peer reflexive candidate result can be done either 3112 with fake requests or responses, or with replays. We consider the 3113 fake requests and responses case first. It requires the attacker to 3114 send a Binding request to one agent with a source IP address and port 3115 for the false candidate. In addition, the attacker must wait for a 3116 Binding request from the other agent, and generate a fake response 3117 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 3118 Like the other attacks described here, this attack is mitigated by 3119 the STUN message integrity mechanisms and secure candidate exchanges. 3121 Forcing the false peer reflexive candidate result with packet replays 3122 is different. The attacker waits until one of the agents sends a 3123 check. It intercepts this request, and replays it towards the other 3124 agent with a faked source IP address. It must also prevent the 3125 original request from reaching the remote agent, either by launching 3126 a DoS attack to cause the packet to be dropped, or forcing it to be 3127 dropped using layer 2 mechanisms. The replayed packet is received at 3128 the other agent, and accepted, since the integrity check passes (the 3129 integrity check cannot and does not cover the source IP address and 3130 port). It is then responded to. This response will contain a XOR- 3131 MAPPED-ADDRESS with the false candidate, and will be sent to that 3132 false candidate. The attacker must then receive it and relay it 3133 towards the originator. 3135 The other agent will then initiate a connectivity check towards that 3136 false candidate. This validation needs to succeed. This requires 3137 the attacker to force a false valid on a false candidate. Injecting 3138 of fake requests or responses to achieve this goal is prevented using 3139 the integrity mechanisms of STUN and the candidate exchange. Thus, 3140 this attack can only be launched through replays. To do that, the 3141 attacker must intercept the check towards this false candidate, and 3142 replay it towards the other agent. Then, it must intercept the 3143 response and replay that back as well. 3145 This attack is very hard to launch unless the attacker is identified 3146 by the fake candidate. This is because it requires the attacker to 3147 intercept and replay packets sent by two different hosts. If both 3148 agents are on different networks (for example, across the public 3149 Internet), this attack can be hard to coordinate, since it needs to 3150 occur against two different endpoints on different parts of the 3151 network at the same time. 3153 If the attacker itself is identified by the fake candidate, the 3154 attack is easier to coordinate. However, if the media path is 3155 secured (e.g., using SRTP [RFC3711]), the attacker will not be able 3156 to play the media packets, but will only be able to discard them, 3157 effectively disabling the media stream for the call. However, this 3158 attack requires the agent to disrupt packets in order to block the 3159 connectivity check from reaching the target. In that case, if the 3160 goal is to disrupt the media stream, it's much easier to just disrupt 3161 it with the same mechanism, rather than attack ICE. 3163 15.2. Attacks on Server Reflexive Address Gathering 3165 ICE endpoints make use of STUN Binding requests for gathering server 3166 reflexive candidates from a STUN server. These requests are not 3167 authenticated in any way. As a consequence, there are numerous 3168 techniques an attacker can employ to provide the client with a false 3169 server reflexive candidate: 3171 o An attacker can compromise the DNS, causing DNS queries to return 3172 a rogue STUN server address. That server can provide the client 3173 with fake server reflexive candidates. This attack is mitigated 3174 by DNS security, though DNS-SEC is not required to address it. 3176 o An attacker that can observe STUN messages (such as an attacker on 3177 a shared network segment, like WiFi) can inject a fake response 3178 that is valid and will be accepted by the client. 3180 o An attacker can compromise a STUN server by means of a virus, and 3181 cause it to send responses with incorrect mapped addresses. 3183 A false mapped address learned by these attacks will be used as a 3184 server reflexive candidate in the ICE exchange. For this candidate 3185 to actually be used for media, the attacker must also attack the 3186 connectivity checks, and in particular, force a false valid on a 3187 false candidate. This attack is very hard to launch if the false 3188 address identifies a fourth party (neither the initiator, responder, 3189 nor attacker), since it requires attacking the checks generated by 3190 each agent in the session, and is prevented by SRTP if it identifies 3191 the attacker themself. 3193 If the attacker elects not to attack the connectivity checks, the 3194 worst it can do is prevent the server reflexive candidate from being 3195 used. However, if the peer agent has at least one candidate that is 3196 reachable by the agent under attack, the STUN connectivity checks 3197 themselves will provide a peer reflexive candidate that can be used 3198 for the exchange of media. Peer reflexive candidates are generally 3199 preferred over server reflexive candidates. As such, an attack 3200 solely on the STUN address gathering will normally have no impact on 3201 a session at all. 3203 15.3. Attacks on Relayed Candidate Gathering 3205 An attacker might attempt to disrupt the gathering of relayed 3206 candidates, forcing the client to believe it has a false relayed 3207 candidate. Exchanges with the TURN server are authenticated using a 3208 long-term credential. Consequently, injection of fake responses or 3209 requests will not work. In addition, unlike Binding requests, 3210 Allocate requests are not susceptible to replay attacks with modified 3211 source IP addresses and ports, since the source IP address and port 3212 are not utilized to provide the client with its relayed candidate. 3214 However, TURN servers are susceptible to DNS attacks, or to viruses 3215 aimed at the TURN server, for purposes of turning it into a zombie or 3216 rogue server. These attacks can be mitigated by DNS-SEC and through 3217 good box and software security on TURN servers. 3219 Even if an attacker has caused the client to believe in a false 3220 relayed candidate, the connectivity checks cause such a candidate to 3221 be used only if they succeed. Thus, an attacker must launch a false 3222 valid on a false candidate, per above, which is a very difficult 3223 attack to coordinate. 3225 15.4. Insider Attacks 3227 In addition to attacks where the attacker is a third party trying to 3228 insert fake candidate information or stun messages, there are attacks 3229 possible with ICE when the attacker is an authenticated and valid 3230 participant in the ICE exchange. 3232 15.4.1. STUN Amplification Attack 3234 The STUN amplification attack is similar to the voice hammer. 3235 However, instead of voice packets being directed to the target, STUN 3236 connectivity checks are directed to the target. The attacker sends 3237 an a large number of candidates, say, 50. The responding agent 3238 receives the candidate information, and starts its checks, which are 3239 directed at the target, and consequently, never generate a response. 3240 The answerer will start a new connectivity check every Ta ms (say, 3241 Ta=20ms). However, the retransmission timers are set to a large 3242 number due to the large number of candidates. As a consequence, 3243 packets will be sent at an interval of one every Ta milliseconds, and 3244 then with increasing intervals after that. Thus, STUN will not send 3245 packets at a rate faster than media would be sent, and the STUN 3246 packets persist only briefly, until ICE fails for the session. 3247 Nonetheless, this is an amplification mechanism. 3249 It is impossible to eliminate the amplification, but the volume can 3250 be reduced through a variety of heuristics. Agents SHOULD limit the 3251 total number of connectivity checks they perform to 100. 3252 Additionally, agents MAY limit the number of candidates they'll 3253 accept. 3255 Frequently, protocols that wish to avoid these kinds of attacks force 3256 the initiator to wait for a response prior to sending the next 3257 message. However, in the case of ICE, this is not possible. It is 3258 not possible to differentiate the following two cases: 3260 o There was no response because the initiator is being used to 3261 launch a DoS attack against an unsuspecting target that will not 3262 respond. 3264 o There was no response because the IP address and port are not 3265 reachable by the initiator. 3267 In the second case, another check should be sent at the next 3268 opportunity, while in the former case, no further checks should be 3269 sent. 3271 16. STUN Extensions 3273 16.1. New Attributes 3275 This specification defines four new attributes, PRIORITY, USE- 3276 CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING. 3278 The PRIORITY attribute indicates the priority that is to be 3279 associated with a peer reflexive candidate, should one be discovered 3280 by this check. It is a 32-bit unsigned integer, and has an attribute 3281 value of 0x0024. 3283 The USE-CANDIDATE attribute indicates that the candidate pair 3284 resulting from this check should be used for transmission of media. 3285 The attribute has no content (the Length field of the attribute is 3286 zero); it serves as a flag. It has an attribute value of 0x0025. 3288 The ICE-CONTROLLED attribute is present in a Binding request and 3289 indicates that the client believes it is currently in the controlled 3290 role. The content of the attribute is a 64-bit unsigned integer in 3291 network byte order, which contains a random number used for tie- 3292 breaking of role conflicts. 3294 The ICE-CONTROLLING attribute is present in a Binding request and 3295 indicates that the client believes it is currently in the controlling 3296 role. The content of the attribute is a 64-bit unsigned integer in 3297 network byte order, which contains a random number used for tie- 3298 breaking of role conflicts. 3300 16.2. New Error Response Codes 3302 This specification defines a single error response code: 3304 487 (Role Conflict): The Binding request contained either the ICE- 3305 CONTROLLING or ICE-CONTROLLED attribute, indicating a role that 3306 conflicted with the server. The server ran a tie-breaker based on 3307 the tie-breaker value in the request and determined that the 3308 client needs to switch roles. 3310 17. Operational Considerations 3312 This section discusses issues relevant to network operators looking 3313 to deploy ICE. 3315 17.1. NAT and Firewall Types 3317 ICE was designed to work with existing NAT and firewall equipment. 3318 Consequently, it is not necessary to replace or reconfigure existing 3319 firewall and NAT equipment in order to facilitate deployment of ICE. 3320 Indeed, ICE was developed to be deployed in environments where the 3321 Voice over IP (VoIP) operator has no control over the IP network 3322 infrastructure, including firewalls and NAT. 3324 That said, ICE works best in environments where the NAT devices are 3325 "behave" compliant, meeting the recommendations defined in [RFC4787] 3326 and [RFC5382]. In networks with behave-compliant NAT, ICE will work 3327 without the need for a TURN server, thus improving voice quality, 3328 decreasing call setup times, and reducing the bandwidth demands on 3329 the network operator. 3331 17.2. Bandwidth Requirements 3333 Deployment of ICE can have several interactions with available 3334 network capacity that operators should take into consideration. 3336 17.2.1. STUN and TURN Server Capacity Planning 3338 First and foremost, ICE makes use of TURN and STUN servers, which 3339 would typically be located in the network operator's data centers. 3340 The STUN servers require relatively little bandwidth. For each 3341 component of each media stream, there will be one or more STUN 3342 transactions from each client to the STUN server. In a basic voice- 3343 only IPv4 VoIP deployment, there will be four transactions per call 3344 (one for RTP and one for RTCP, for both caller and callee). Each 3345 transaction is a single request and a single response, the former 3346 being 20 bytes long, and the latter, 28. Consequently, if a system 3347 has N users, and each makes four calls in a busy hour, this would 3348 require N*1.7bps. For one million users, this is 1.7 Mbps, a very 3349 small number (relatively speaking). 3351 TURN traffic is more substantial. The TURN server will see traffic 3352 volume equal to the STUN volume (indeed, if TURN servers are 3353 deployed, there is no need for a separate STUN server), in addition 3354 to the traffic for the actual media traffic. The amount of calls 3355 requiring TURN for media relay is highly dependent on network 3356 topologies, and can and will vary over time. In a network with 100% 3357 behave-compliant NAT, it is exactly zero. At time of writing, large- 3358 scale consumer deployments were seeing between 5 and 10 percent of 3359 calls requiring TURN servers. Considering a voice-only deployment 3360 using G.711 (so 80 kbps in each direction), with .2 erlangs during 3361 the busy hour, this is N*3.2 kbps. For a population of one million 3362 users, this is 3.2 Gbps, assuming a 10% usage of TURN servers. 3364 17.2.2. Gathering and Connectivity Checks 3366 The process of gathering of candidates and performing of connectivity 3367 checks can be bandwidth intensive. ICE has been designed to pace 3368 both of these processes. The gathering phase and the connectivity 3369 check phase are meant to generate traffic at roughly the same 3370 bandwidth as the media traffic itself. This was done to ensure that, 3371 if a network is designed to support multimedia traffic of a certain 3372 type (voice, video, or just text), it will have sufficient capacity 3373 to support the ICE checks for that media. Of course, the ICE checks 3374 will cause a marginal increase in the total utilization; however, 3375 this will typically be an extremely small increase. 3377 Congestion due to the gathering and check phases has proven to be a 3378 problem in deployments that did not utilize pacing. Typically, 3379 access links became congested as the endpoints flooded the network 3380 with checks as fast as they can send them. Consequently, network 3381 operators should make sure that their ICE implementations support the 3382 pacing feature. Though this pacing does increase call setup times, 3383 it makes ICE network friendly and easier to deploy. 3385 17.2.3. Keepalives 3387 STUN keepalives (in the form of STUN Binding Indications) are sent in 3388 the middle of a media session. However, they are sent only in the 3389 absence of actual media traffic. In deployments that are not 3390 utilizing Voice Activity Detection (VAD), the keepalives are never 3391 used and there is no increase in bandwidth usage. When VAD is being 3392 used, keepalives will be sent during silence periods. This involves 3393 a single packet every 15-20 seconds, far less than the packet every 3394 20-30 ms that is sent when there is voice. Therefore, keepalives 3395 don't have any real impact on capacity planning. 3397 17.3. ICE and ICE-lite 3399 Deployments utilizing a mix of ICE and ICE-lite interoperate 3400 perfectly. They have been explicitly designed to do so, without loss 3401 of function. 3403 However, ICE-lite can only be deployed in limited use cases. Those 3404 cases, and the caveats involved in doing so, are documented in 3405 Appendix A. 3407 17.4. Troubleshooting and Performance Management 3409 ICE utilizes end-to-end connectivity checks, and places much of the 3410 processing in the endpoints. This introduces a challenge to the 3411 network operator -- how can they troubleshoot ICE deployments? How 3412 can they know how ICE is performing? 3414 ICE has built-in features to help deal with these problems. SIP 3415 servers on the signaling path, typically deployed in the data centers 3416 of the network operator, will see the contents of the candidate 3417 exchanges that convey the ICE parameters. These parameters include 3418 the type of each candidate (host, server reflexive, or relayed), 3419 along with their related addresses. Once ICE processing has 3420 completed, an updated candidate exchange takes place, signaling the 3421 selected address (and its type). This updated re-INVITE is performed 3422 exactly for the purposes of educating network equipment (such as a 3423 diagnostic tool attached to a SIP server) about the results of ICE 3424 processing. 3426 As a consequence, through the logs generated by the SIP server, a 3427 network operator can observe what types of candidates are being used 3428 for each call, and what address was selected by ICE. This is the 3429 primary information that helps evaluate how ICE is performing. 3431 17.5. Endpoint Configuration 3433 ICE relies on several pieces of data being configured into the 3434 endpoints. This configuration data includes timers, credentials for 3435 TURN servers, and hostnames for STUN and TURN servers. ICE itself 3436 does not provide a mechanism for this configuration. Instead, it is 3437 assumed that this information is attached to whatever mechanism is 3438 used to configure all of the other parameters in the endpoint. For 3439 SIP phones, standard solutions such as the configuration framework 3440 [RFC6080] have been defined. 3442 18. IANA Considerations 3444 The original ICE specification registered four new STUN attributes, 3445 and one new STUN error response. The STUN attributes and error 3446 response are reproduced here. In addition, this specification 3447 registers a new ICE option. 3449 18.1. STUN Attributes 3451 IANA has registered four STUN attributes: 3453 0x0024 PRIORITY 3454 0x0025 USE-CANDIDATE 3455 0x8029 ICE-CONTROLLED 3456 0x802A ICE-CONTROLLING 3458 18.2. STUN Error Responses 3460 IANA has registered following STUN error response code: 3462 487 Role Conflict: The client asserted an ICE role (controlling or 3463 controlled) that is in conflict with the role of the server. 3465 18.3. ICE Options 3467 IANA is requested to register the following ICE option in the "ICE 3468 Options" sub-registry of the "Interactive Connectivity Establishment 3469 (ICE) registry", following the procedures defined in [RFC6336]. 3471 ICE Option name: 3473 ice2 3475 Contact: 3477 Name: Christer Holmberg 3478 E-mail: christer.holmberg(at)ericsson(dot)com 3479 Address: Oy LM Ericsson Ab, 02420 Jorvas, FINLAND 3481 Change control: 3483 IESG 3485 Description: 3487 The ICE option indicates that the ICE agent using the ICE option 3488 is compliant and implemented according to RFC XXXX. 3490 Reference: 3492 RFC XXXX 3494 19. IAB Considerations 3496 The IAB has studied the problem of "Unilateral Self-Address Fixing", 3497 which is the general process by which a agent attempts to determine 3498 its address in another realm on the other side of a NAT through a 3499 collaborative protocol reflection mechanism [RFC3424]. ICE is an 3500 example of a protocol that performs this type of function. 3501 Interestingly, the process for ICE is not unilateral, but bilateral, 3502 and the difference has a significant impact on the issues raised by 3503 IAB. Indeed, ICE can be considered a B-SAF (Bilateral Self-Address 3504 Fixing) protocol, rather than an UNSAF protocol. Regardless, the IAB 3505 has mandated that any protocols developed for this purpose document a 3506 specific set of considerations. This section meets those 3507 requirements. 3509 19.1. Problem Definition 3511 >From RFC 3424, any UNSAF proposal must provide: 3513 Precise definition of a specific, limited-scope problem that is to 3514 be solved with the UNSAF proposal. A short-term fix should not be 3515 generalized to solve other problems; this is why "short-term fixes 3516 usually aren't". 3518 The specific problems being solved by ICE are: 3520 Provide a means for two peers to determine the set of transport 3521 addresses that can be used for communication. 3523 Provide a means for a agent to determine an address that is 3524 reachable by another peer with which it wishes to communicate. 3526 19.2. Exit Strategy 3528 >From RFC 3424, any UNSAF proposal must provide: 3530 Description of an exit strategy/transition plan. The better 3531 short-term fixes are the ones that will naturally see less and 3532 less use as the appropriate technology is deployed. 3534 ICE itself doesn't easily get phased out. However, it is useful even 3535 in a globally connected Internet, to serve as a means for detecting 3536 whether a router failure has temporarily disrupted connectivity, for 3537 example. ICE also helps prevent certain security attacks that have 3538 nothing to do with NAT. However, what ICE does is help phase out 3539 other UNSAF mechanisms. ICE effectively selects amongst those 3540 mechanisms, prioritizing ones that are better, and deprioritizing 3541 ones that are worse. Local IPv6 addresses can be preferred. As NATs 3542 begin to dissipate as IPv6 is introduced, server reflexive and 3543 relayed candidates (both forms of UNSAF addresses) simply never get 3544 used, because higher-priority connectivity exists to the native host 3545 candidates. Therefore, the servers get used less and less, and can 3546 eventually be remove when their usage goes to zero. 3548 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 3549 be used to determine whether to use IPv6 or IPv4 when two dual-stack 3550 hosts communicate with SIP (IPv6 gets used). It can also allow a 3551 network with both 6to4 and native v6 connectivity to determine which 3552 address to use when communicating with a peer. 3554 19.3. Brittleness Introduced by ICE 3556 >From RFC 3424, any UNSAF proposal must provide: 3558 Discussion of specific issues that may render systems more 3559 "brittle". For example, approaches that involve using data at 3560 multiple network layers create more dependencies, increase 3561 debugging challenges, and make it harder to transition. 3563 ICE actually removes brittleness from existing UNSAF mechanisms. In 3564 particular, classic STUN (as described in RFC 3489 [RFC3489]) has 3565 several points of brittleness. One of them is the discovery process 3566 that requires an agent to try to classify the type of NAT it is 3567 behind. This process is error-prone. With ICE, that discovery 3568 process is simply not used. Rather than unilaterally assessing the 3569 validity of the address, its validity is dynamically determined by 3570 measuring connectivity to a peer. The process of determining 3571 connectivity is very robust. 3573 Another point of brittleness in classic STUN and any other unilateral 3574 mechanism is its absolute reliance on an additional server. ICE 3575 makes use of a server for allocating unilateral addresses, but allows 3576 agents to directly connect if possible. Therefore, in some cases, 3577 the failure of a STUN server would still allow for a call to progress 3578 when ICE is used. 3580 Another point of brittleness in classic STUN is that it assumes that 3581 the STUN server is on the public Internet. Interestingly, with ICE, 3582 that is not necessary. There can be a multitude of STUN servers in a 3583 variety of address realms. ICE will discover the one that has 3584 provided a usable address. 3586 The most troubling point of brittleness in classic STUN is that it 3587 doesn't work in all network topologies. In cases where there is a 3588 shared NAT between each agent and the STUN server, traditional STUN 3589 may not work. With ICE, that restriction is removed. 3591 Classic STUN also introduces some security considerations. 3592 Fortunately, those security considerations are also mitigated by ICE. 3594 Consequently, ICE serves to repair the brittleness introduced in 3595 classic STUN, and does not introduce any additional brittleness into 3596 the system. 3598 The penalty of these improvements is that ICE increases session 3599 establishment times. 3601 19.4. Requirements for a Long-Term Solution 3603 From RFC 3424, any UNSAF proposal must provide: 3605 ... requirements for longer term, sound technical solutions -- 3606 contribute to the process of finding the right longer term 3607 solution. 3609 Our conclusions from RFC 3489 remain unchanged. However, we feel ICE 3610 actually helps because we believe it can be part of the long-term 3611 solution. 3613 19.5. Issues with Existing NAPT Boxes 3615 From RFC 3424, any UNSAF proposal must provide: 3617 Discussion of the impact of the noted practical issues with 3618 existing, deployed NA[P]Ts and experience reports. 3620 A number of NAT boxes are now being deployed into the market that try 3621 to provide "generic" ALG functionality. These generic ALGs hunt for 3622 IP addresses, either in text or binary form within a packet, and 3623 rewrite them if they match a binding. This interferes with classic 3624 STUN. However, the update to STUN [RFC5389] uses an encoding that 3625 hides these binary addresses from generic ALGs. 3627 Existing NAPT boxes have non-deterministic and typically short 3628 expiration times for UDP-based bindings. This requires 3629 implementations to send periodic keepalives to maintain those 3630 bindings. ICE uses a default of 15 s, which is a very conservative 3631 estimate. Eventually, over time, as NAT boxes become compliant to 3632 behave [RFC4787], this minimum keepalive will become deterministic 3633 and well-known, and the ICE timers can be adjusted. Having a way to 3634 discover and control the minimum keepalive interval would be far 3635 better still. 3637 20. Changes from RFC 5245 3639 Following is the list of changes from RFC 5245 3641 o The specification was generalized to be more usable with any 3642 protocol and the parts that are specific to SIP and SDP were moved 3643 to a SIP/SDP usage document [I-D.ietf-mmusic-ice-sip-sdp]. 3645 o Default candidates, multiple components, ICE mismatch detection, 3646 subsequent offer/answer, and role conflict resolution were made 3647 optional since they are not needed with every protocol using ICE. 3649 o With IPv6, the precedence rules of RFC 6724 are used instead of 3650 the obsoleted RFC 3483 and using address preferences provided by 3651 the host operating system is recommended. 3653 o Candidate gathering rules regarding loopback addresses and IPv6 3654 addresses were clarified. 3656 21. Acknowledgements 3658 Most of the text in this document comes from the original ICE 3659 specification, RFC 5245. The authors would like to thank everyone 3660 who has contributed to that document. For additional contributions 3661 to this revision of the specification we would like to thank Emil 3662 Ivov, Paul Kyzivat, Pal-Erik Martinsen, Simon Perrault, Eric 3663 Rescorla, Thomas Stach, Peter Thatcher, Martin Thomson, Justin 3664 Uberti, and Suhas Nandakumar. 3666 22. References 3668 22.1. Normative References 3670 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3671 Requirement Levels", BCP 14, RFC 2119, 3672 DOI 10.17487/RFC2119, March 1997, 3673 . 3675 [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, 3676 "Session Traversal Utilities for NAT (STUN)", RFC 5389, 3677 DOI 10.17487/RFC5389, October 2008, 3678 . 3680 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3681 Relays around NAT (TURN): Relay Extensions to Session 3682 Traversal Utilities for NAT (STUN)", RFC 5766, 3683 DOI 10.17487/RFC5766, April 2010, 3684 . 3686 [RFC6336] Westerlund, M. and C. Perkins, "IANA Registry for 3687 Interactive Connectivity Establishment (ICE) Options", 3688 RFC 6336, DOI 10.17487/RFC6336, July 2011, 3689 . 3691 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3692 "Default Address Selection for Internet Protocol Version 6 3693 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3694 . 3696 22.2. Informative References 3698 [RFC3605] Huitema, C., "Real Time Control Protocol (RTCP) attribute 3699 in Session Description Protocol (SDP)", RFC 3605, 3700 DOI 10.17487/RFC3605, October 2003, 3701 . 3703 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3704 A., Peterson, J., Sparks, R., Handley, M., and E. 3705 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3706 DOI 10.17487/RFC3261, June 2002, 3707 . 3709 [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model 3710 with Session Description Protocol (SDP)", RFC 3264, 3711 DOI 10.17487/RFC3264, June 2002, 3712 . 3714 [RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, 3715 "STUN - Simple Traversal of User Datagram Protocol (UDP) 3716 Through Network Address Translators (NATs)", RFC 3489, 3717 DOI 10.17487/RFC3489, March 2003, 3718 . 3720 [RFC3235] Senie, D., "Network Address Translator (NAT)-Friendly 3721 Application Design Guidelines", RFC 3235, 3722 DOI 10.17487/RFC3235, January 2002, 3723 . 3725 [RFC3303] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and 3726 A. Rayhan, "Middlebox communication architecture and 3727 framework", RFC 3303, DOI 10.17487/RFC3303, August 2002, 3728 . 3730 [RFC3102] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, 3731 "Realm Specific IP: Framework", RFC 3102, 3732 DOI 10.17487/RFC3102, October 2001, 3733 . 3735 [RFC3103] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, 3736 "Realm Specific IP: Protocol Specification", RFC 3103, 3737 DOI 10.17487/RFC3103, October 2001, 3738 . 3740 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3741 UNilateral Self-Address Fixing (UNSAF) Across Network 3742 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3743 November 2002, . 3745 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3746 Jacobson, "RTP: A Transport Protocol for Real-Time 3747 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3748 July 2003, . 3750 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3751 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3752 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3753 . 3755 [RFC3056] Carpenter, B. and K. Moore, "Connection of IPv6 Domains 3756 via IPv4 Clouds", RFC 3056, DOI 10.17487/RFC3056, February 3757 2001, . 3759 [RFC3389] Zopf, R., "Real-time Transport Protocol (RTP) Payload for 3760 Comfort Noise (CN)", RFC 3389, DOI 10.17487/RFC3389, 3761 September 2002, . 3763 [RFC3879] Huitema, C. and B. Carpenter, "Deprecating Site Local 3764 Addresses", RFC 3879, DOI 10.17487/RFC3879, September 3765 2004, . 3767 [RFC4038] Shin, M-K., Ed., Hong, Y-G., Hagino, J., Savola, P., and 3768 E. Castro, "Application Aspects of IPv6 Transition", 3769 RFC 4038, DOI 10.17487/RFC4038, March 2005, 3770 . 3772 [RFC4091] Camarillo, G. and J. Rosenberg, "The Alternative Network 3773 Address Types (ANAT) Semantics for the Session Description 3774 Protocol (SDP) Grouping Framework", RFC 4091, 3775 DOI 10.17487/RFC4091, June 2005, 3776 . 3778 [RFC4092] Camarillo, G. and J. Rosenberg, "Usage of the Session 3779 Description Protocol (SDP) Alternative Network Address 3780 Types (ANAT) Semantics in the Session Initiation Protocol 3781 (SIP)", RFC 4092, DOI 10.17487/RFC4092, June 2005, 3782 . 3784 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 3785 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 3786 2006, . 3788 [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 3789 Description Protocol", RFC 4566, DOI 10.17487/RFC4566, 3790 July 2006, . 3792 [RFC2475] Blake, S., Black, D., Carlson, M., Davies, E., Wang, Z., 3793 and W. Weiss, "An Architecture for Differentiated 3794 Services", RFC 2475, DOI 10.17487/RFC2475, December 1998, 3795 . 3797 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3798 and E. Lear, "Address Allocation for Private Internets", 3799 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3800 . 3802 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3803 Translation (NAT) Behavioral Requirements for Unicast 3804 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3805 2007, . 3807 [I-D.ietf-avt-rtp-no-op] 3808 Andreasen, F., "A No-Op Payload Format for RTP", draft- 3809 ietf-avt-rtp-no-op-04 (work in progress), May 2007. 3811 [RFC5761] Perkins, C. and M. Westerlund, "Multiplexing RTP Data and 3812 Control Packets on a Single Port", RFC 5761, 3813 DOI 10.17487/RFC5761, April 2010, 3814 . 3816 [RFC4103] Hellstrom, G. and P. Jones, "RTP Payload for Text 3817 Conversation", RFC 4103, DOI 10.17487/RFC4103, June 2005, 3818 . 3820 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3821 (ICE): A Protocol for Network Address Translator (NAT) 3822 Traversal for Offer/Answer Protocols", RFC 5245, 3823 DOI 10.17487/RFC5245, April 2010, 3824 . 3826 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 3827 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 3828 RFC 5382, DOI 10.17487/RFC5382, October 2008, 3829 . 3831 [RFC6080] Petrie, D. and S. Channabasappa, Ed., "A Framework for 3832 Session Initiation Protocol User Agent Profile Delivery", 3833 RFC 6080, DOI 10.17487/RFC6080, March 2011, 3834 . 3836 [RFC6146] Bagnulo, M., Matthews, P., and I. van Beijnum, "Stateful 3837 NAT64: Network Address and Protocol Translation from IPv6 3838 Clients to IPv4 Servers", RFC 6146, DOI 10.17487/RFC6146, 3839 April 2011, . 3841 [RFC6147] Bagnulo, M., Sullivan, A., Matthews, P., and I. van 3842 Beijnum, "DNS64: DNS Extensions for Network Address 3843 Translation from IPv6 Clients to IPv4 Servers", RFC 6147, 3844 DOI 10.17487/RFC6147, April 2011, 3845 . 3847 [RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, 3848 "TCP Candidates with Interactive Connectivity 3849 Establishment (ICE)", RFC 6544, DOI 10.17487/RFC6544, 3850 March 2012, . 3852 [RFC7050] Savolainen, T., Korhonen, J., and D. Wing, "Discovery of 3853 the IPv6 Prefix Used for IPv6 Address Synthesis", 3854 RFC 7050, DOI 10.17487/RFC7050, November 2013, 3855 . 3857 [I-D.ietf-mmusic-ice-sip-sdp] 3858 Petit-Huguenin, M., Keranen, A., and S. Nandakumar, "Using 3859 Interactive Connectivity Establishment (ICE) with Session 3860 Description Protocol (SDP) offer/answer and Session 3861 Initiation Protocol (SIP)", draft-ietf-mmusic-ice-sip- 3862 sdp-08 (work in progress), March 2016. 3864 [I-D.ietf-6man-ipv6-address-generation-privacy] 3865 Cooper, A., Gont, F., and D. Thaler, "Privacy 3866 Considerations for IPv6 Address Generation Mechanisms", 3867 draft-ietf-6man-ipv6-address-generation-privacy-08 (work 3868 in progress), September 2015. 3870 Appendix A. Lite and Full Implementations 3872 ICE allows for two types of implementations. A full implementation 3873 supports the controlling and controlled roles in a session, and can 3874 also perform address gathering. In contrast, a lite implementation 3875 is a minimalist implementation that does little but respond to STUN 3876 checks. 3878 Because ICE requires both endpoints to support it in order to bring 3879 benefits to either endpoint, incremental deployment of ICE in a 3880 network is more complicated. Many sessions involve an endpoint that 3881 is, by itself, not behind a NAT and not one that would worry about 3882 NAT traversal. A very common case is to have one endpoint that 3883 requires NAT traversal (such as a VoIP hard phone or soft phone) make 3884 a call to one of these devices. Even if the phone supports a full 3885 ICE implementation, ICE won't be used at all if the other device 3886 doesn't support it. The lite implementation allows for a low-cost 3887 entry point for these devices. Once they support the lite 3888 implementation, full implementations can connect to them and get the 3889 full benefits of ICE. 3891 Consequently, a lite implementation is only appropriate for devices 3892 that will *always* be connected to the public Internet and have a 3893 public IP address at which it can receive packets from any 3894 correspondent. ICE will not function when a lite implementation is 3895 placed behind a NAT. 3897 ICE allows a lite implementation to have a single IPv4 host candidate 3898 and several IPv6 addresses. In that case, candidate pairs are 3899 selected by the controlling agent using a static algorithm, such as 3900 the one in RFC 6724, which is recommended by this specification. 3901 However, static mechanisms for address selection are always prone to 3902 error, since they cannot ever reflect the actual topology and can 3903 never provide actual guarantees on connectivity. They are always 3904 heuristics. Consequently, if an agent is implementing ICE just to 3905 select between its IPv4 and IPv6 addresses, and none of its IP 3906 addresses are behind NAT, usage of full ICE is still RECOMMENDED in 3907 order to provide the most robust form of address selection possible. 3909 It is important to note that the lite implementation was added to 3910 this specification to provide a stepping stone to full 3911 implementation. Even for devices that are always connected to the 3912 public Internet with just a single IPv4 address, a full 3913 implementation is preferable if achievable. Full implementations 3914 also obtain the security benefits of ICE unrelated to NAT traversal; 3915 in particular, the voice hammer attack described in Section 15 is 3916 prevented only for full implementations, not lite. Finally, it is 3917 often the case that a device that finds itself with a public address 3918 today will be placed in a network tomorrow where it will be behind a 3919 NAT. It is difficult to definitively know, over the lifetime of a 3920 device or product, that it will always be used on the public 3921 Internet. Full implementation provides assurance that communications 3922 will always work. 3924 Appendix B. Design Motivations 3926 ICE contains a number of normative behaviors that may themselves be 3927 simple, but derive from complicated or non-obvious thinking or use 3928 cases that merit further discussion. Since these design motivations 3929 are not necessary to understand for purposes of implementation, they 3930 are discussed here in an appendix to the specification. This section 3931 is non-normative. 3933 B.1. Pacing of STUN Transactions 3935 STUN transactions used to gather candidates and to verify 3936 connectivity are paced out at an approximate rate of one new 3937 transaction every Ta milliseconds. Each transaction, in turn, has a 3938 retransmission timer RTO that is a function of Ta as well. Why are 3939 these transactions paced, and why are these formulas used? 3940 Sending of these STUN requests will often have the effect of creating 3941 bindings on NAT devices between the client and the STUN servers. 3942 Experience has shown that many NAT devices have upper limits on the 3943 rate at which they will create new bindings. Experiments have shown 3944 that once every 20 ms is well supported, but not much lower than 3945 that. This is why Ta has a lower bound of 20 ms. Furthermore, 3946 transmission of these packets on the network makes use of bandwidth 3947 and needs to be rate limited by the agent. Deployments based on 3948 earlier draft versions of [RFC5245] tended to overload rate- 3949 constrained access links and perform poorly overall, in addition to 3950 negatively impacting the network. As a consequence, the pacing 3951 ensures that the NAT device does not get overloaded and that traffic 3952 is kept at a reasonable rate. 3954 The definition of a "reasonable" rate is that STUN should not use 3955 more bandwidth than the RTP itself will use, once media starts 3956 flowing. The formula for Ta is designed so that, if a STUN packet 3957 were sent every Ta seconds, it would consume the same amount of 3958 bandwidth as RTP packets, summed across all media streams. Of 3959 course, STUN has retransmits, and the desire is to pace those as 3960 well. For this reason, RTO is set such that the first retransmit on 3961 the first transaction happens just as the first STUN request on the 3962 last transaction occurs. Pictorially: 3964 First Packets Retransmits 3966 | | 3967 | | 3968 -------+------ -------+------ 3969 / \ / \ 3970 / \ / \ 3972 +--+ +--+ +--+ +--+ +--+ +--+ 3973 |A1| |B1| |C1| |A2| |B2| |C2| 3974 +--+ +--+ +--+ +--+ +--+ +--+ 3976 ---+-------+-------+-------+-------+-------+------------ Time 3977 0 Ta 2Ta 3Ta 4Ta 5Ta 3979 In this picture, there are three transactions that will be sent (for 3980 example, in the case of candidate gathering, there are three host 3981 candidate/STUN server pairs). These are transactions A, B, and C. 3982 The retransmit timer is set so that the first retransmission on the 3983 first transaction (packet A2) is sent at time 3Ta. 3985 Subsequent retransmits after the first will occur even less 3986 frequently than Ta milliseconds apart, since STUN uses an exponential 3987 back-off on its retransmissions. 3989 B.2. Candidates with Multiple Bases 3991 Section 4.1.3 talks about eliminating candidates that have the same 3992 transport address and base. However, candidates with the same 3993 transport addresses but different bases are not redundant. When can 3994 an agent have two candidates that have the same IP address and port, 3995 but different bases? Consider the topology of Figure 10: 3997 +----------+ 3998 | STUN Srvr| 3999 +----------+ 4000 | 4001 | 4002 ----- 4003 // \\ 4004 | | 4005 | B:net10 | 4006 | | 4007 \\ // 4008 ----- 4009 | 4010 | 4011 +----------+ 4012 | NAT | 4013 +----------+ 4014 | 4015 | 4016 ----- 4017 // \\ 4018 | A | 4019 |192.168/16 | 4020 | | 4021 \\ // 4022 ----- 4023 | 4024 | 4025 |192.168.1.100 ----- 4026 +----------+ // \\ +----------+ 4027 | | | | | | 4028 | Initiator|---------| C:net10 |-----------| Responder| 4029 | |10.0.1.100| | 10.0.1.101 | | 4030 +----------+ \\ // +----------+ 4031 ----- 4033 Figure 10: Identical Candidates with Different Bases 4035 In this case, the initiating agent is multihomed. It has one IP 4036 address, 10.0.1.100, on network C, which is a net 10 private network. 4037 The responding agent is on this same network. The initiating agent 4038 is also connected to network A, which is 192.168/16 and has an IP 4039 address of 192.168.1.100 on this network. There is a NAT on this 4040 network, natting into network B, which is another net 10 private 4041 network, but not connected to network C. There is a STUN server on 4042 network B. 4044 The initiating agent obtains a host candidate on its IP address on 4045 network C (10.0.1.100:2498) and a host candidate on its IP address on 4046 network A (192.168.1.100:3344). It performs a STUN query to its 4047 configured STUN server from 192.168.1.100:3344. This query passes 4048 through the NAT, which happens to assign the binding 10.0.1.100:2498. 4049 The STUN server reflects this in the STUN Binding response. Now, the 4050 initiating agent has obtained a server reflexive candidate with a 4051 transport address that is identical to a host candidate 4052 (10.0.1.100:2498). However, the server reflexive candidate has a 4053 base of 192.168.1.100:3344, and the host candidate has a base of 4054 10.0.1.100:2498. 4056 B.3. Purpose of the Related Address and Related Port Attributes 4058 The candidate attribute contains two values that are not used at all 4059 by ICE itself -- related address and related port. Why are they 4060 present? 4062 There are two motivations for its inclusion. The first is 4063 diagnostic. It is very useful to know the relationship between the 4064 different types of candidates. By including it, an agent can know 4065 which relayed candidate is associated with which reflexive candidate, 4066 which in turn is associated with a specific host candidate. When 4067 checks for one candidate succeed and not for others, this provides 4068 useful diagnostics on what is going on in the network. 4070 The second reason has to do with off-path Quality of Service (QoS) 4071 mechanisms. When ICE is used in environments such as PacketCable 4072 2.0, proxies will, in addition to performing normal SIP operations, 4073 inspect the SDP in SIP messages, and extract the IP address and port 4074 for media traffic. They can then interact, through policy servers, 4075 with access routers in the network, to establish guaranteed QoS for 4076 the media flows. This QoS is provided by classifying the RTP traffic 4077 based on 5-tuple, and then providing it a guaranteed rate, or marking 4078 its Diffserv codepoints appropriately. When a residential NAT is 4079 present, and a relayed candidate gets selected for media, this 4080 relayed candidate will be a transport address on an actual TURN 4081 server. That address says nothing about the actual transport address 4082 in the access router that would be used to classify packets for QoS 4083 treatment. Rather, the server reflexive candidate towards the TURN 4084 server is needed. By carrying the translation in the SDP, the proxy 4085 can use that transport address to request QoS from the access router. 4087 B.4. Importance of the STUN Username 4089 ICE requires the usage of message integrity with STUN using its 4090 short-term credential functionality. The actual short-term 4091 credential is formed by exchanging username fragments in the 4092 candidate exchange. The need for this mechanism goes beyond just 4093 security; it is actually required for correct operation of ICE in the 4094 first place. 4096 Consider agents L, R, and Z. L and R are within private enterprise 4097 1, which is using 10.0.0.0/8. Z is within private enterprise 2, 4098 which is also using 10.0.0.0/8. As it turns out, R and Z both have 4099 IP address 10.0.1.1. L sends candidates to Z. Z, in responds L with 4100 its host candidates. In this case, those candidates are 4101 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, R is in a session 4102 at that same time, and is also using 10.0.1.1:8866 and 10.0.1.1:8877 4103 as host candidates. This means that R is prepared to accept STUN 4104 messages on those ports, just as Z is. L will send a STUN request to 4105 10.0.1.1:8866 and another to 10.0.1.1:8877. However, these do not go 4106 to Z as expected. Instead, they go to R! If R just replied to them, 4107 L would believe it has connectivity to Z, when in fact it has 4108 connectivity to a completely different user, R. To fix this, the 4109 STUN short-term credential mechanisms are used. The username 4110 fragments are sufficiently random that it is highly unlikely that R 4111 would be using the same values as Z. Consequently, R would reject 4112 the STUN request since the credentials were invalid. In essence, the 4113 STUN username fragments provide a form of transient host identifiers, 4114 bound to a particular session established as part of the candidate 4115 exchange. 4117 An unfortunate consequence of the non-uniqueness of IP addresses is 4118 that, in the above example, R might not even be an ICE agent. It 4119 could be any host, and the port to which the STUN packet is directed 4120 could be any ephemeral port on that host. If there is an application 4121 listening on this socket for packets, and it is not prepared to 4122 handle malformed packets for whatever protocol is in use, the 4123 operation of that application could be affected. Fortunately, since 4124 the ports exchanged are ephemeral and usually drawn from the dynamic 4125 or registered range, the odds are good that the port is not used to 4126 run a server on host R, but rather is the agent side of some 4127 protocol. This decreases the probability of hitting an allocated 4128 port, due to the transient nature of port usage in this range. 4129 However, the possibility of a problem does exist, and network 4130 deployers should be prepared for it. Note that this is not a problem 4131 specific to ICE; stray packets can arrive at a port at any time for 4132 any type of protocol, especially ones on the public Internet. As 4133 such, this requirement is just restating a general design guideline 4134 for Internet applications -- be prepared for unknown packets on any 4135 port. 4137 B.5. The Candidate Pair Priority Formula 4139 The priority for a candidate pair has an odd form. It is: 4141 pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) 4143 Why is this? When the candidate pairs are sorted based on this 4144 value, the resulting sorting has the MAX/MIN property. This means 4145 that the pairs are first sorted based on decreasing value of the 4146 minimum of the two priorities. For pairs that have the same value of 4147 the minimum priority, the maximum priority is used to sort amongst 4148 them. If the max and the min priorities are the same, the 4149 controlling agent's priority is used as the tie-breaker in the last 4150 part of the expression. The factor of 2*32 is used since the 4151 priority of a single candidate is always less than 2*32, resulting in 4152 the pair priority being a "concatenation" of the two component 4153 priorities. This creates the MAX/MIN sorting. MAX/MIN ensures that, 4154 for a particular agent, a lower-priority candidate is never used 4155 until all higher-priority candidates have been tried. 4157 B.6. Why Are Keepalives Needed? 4159 Once media begins flowing on a candidate pair, it is still necessary 4160 to keep the bindings alive at intermediate NATs for the duration of 4161 the session. Normally, the media stream packets themselves (e.g., 4162 RTP) meet this objective. However, several cases merit further 4163 discussion. Firstly, in some RTP usages, such as SIP, the media 4164 streams can be "put on hold". This is accomplished by using the SDP 4165 "sendonly" or "inactive" attributes, as defined in RFC 3264 4166 [RFC3264]. RFC 3264 directs implementations to cease transmission of 4167 media in these cases. However, doing so may cause NAT bindings to 4168 timeout, and media won't be able to come off hold. 4170 Secondly, some RTP payload formats, such as the payload format for 4171 text conversation [RFC4103], may send packets so infrequently that 4172 the interval exceeds the NAT binding timeouts. 4174 Thirdly, if silence suppression is in use, long periods of silence 4175 may cause media transmission to cease sufficiently long for NAT 4176 bindings to time out. 4178 For these reasons, the media packets themselves cannot be relied 4179 upon. ICE defines a simple periodic keepalive utilizing STUN Binding 4180 indications. This makes its bandwidth requirements highly 4181 predictable, and thus amenable to QoS reservations. 4183 B.7. Why Prefer Peer Reflexive Candidates? 4185 Section 4.1.2 describes procedures for computing the priority of 4186 candidate based on its type and local preferences. That section 4187 requires that the type preference for peer reflexive candidates 4188 always be higher than server reflexive. Why is that? The reason has 4189 to do with the security considerations in Section 15. It is much 4190 easier for an attacker to cause an agent to use a false server 4191 reflexive candidate than it is for an attacker to cause an agent to 4192 use a false peer reflexive candidate. Consequently, attacks against 4193 address gathering with Binding requests are thwarted by ICE by 4194 preferring the peer reflexive candidates. 4196 B.8. Why Are Binding Indications Used for Keepalives? 4198 Media keepalives are described in Section 10. These keepalives make 4199 use of STUN when both endpoints are ICE capable. However, rather 4200 than using a Binding request transaction (which generates a 4201 response), the keepalives use an Indication. Why is that? 4203 The primary reason has to do with network QoS mechanisms. Once media 4204 begins flowing, network elements will assume that the media stream 4205 has a fairly regular structure, making use of periodic packets at 4206 fixed intervals, with the possibility of jitter. If an agent is 4207 sending media packets, and then receives a Binding request, it would 4208 need to generate a response packet along with its media packets. 4209 This will increase the actual bandwidth requirements for the 5-tuple 4210 carrying the media packets, and introduce jitter in the delivery of 4211 those packets. Analysis has shown that this is a concern in certain 4212 layer 2 access networks that use fairly tight packet schedulers for 4213 media. 4215 Additionally, using a Binding Indication allows integrity to be 4216 disabled, allowing for better performance. This is useful for large- 4217 scale endpoints, such as PSTN gateways and SBCs. 4219 Authors' Addresses 4221 Ari Keranen 4222 Ericsson 4223 Hirsalantie 11 4224 02420 Jorvas 4225 Finland 4227 Email: ari.keranen@ericsson.com 4228 Christer Holmberg 4229 Ericsson 4230 Hirsalantie 11 4231 02420 Jorvas 4232 Finland 4234 Email: christer.holmberg@ericsson.com 4236 Jonathan Rosenberg 4237 jdrosen.net 4238 Monmouth, NJ 4239 US 4241 Email: jdrosen@jdrosen.net 4242 URI: http://www.jdrosen.net