idnits 2.17.1 draft-ietf-mmusic-ice-11.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** It looks like you're using RFC 3978 boilerplate. You should update this to the boilerplate described in the IETF Trust License Policy document (see https://trustee.ietf.org/license-info), which is required now. -- Found old boilerplate from RFC 3978, Section 5.1 on line 15. -- Found old boilerplate from RFC 3978, Section 5.5 on line 3176. -- Found old boilerplate from RFC 3979, Section 5, paragraph 1 on line 3153. -- Found old boilerplate from RFC 3979, Section 5, paragraph 2 on line 3160. -- Found old boilerplate from RFC 3979, Section 5, paragraph 3 on line 3166. ** This document has an original RFC 3978 Section 5.4 Copyright Line, instead of the newer IETF Trust Copyright according to RFC 4748. ** This document has an original RFC 3978 Section 5.5 Disclaimer, instead of the newer disclaimer which includes the IETF Trust according to RFC 4748. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- == No 'Intended status' indicated for this document; assuming Proposed Standard Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 4 instances of too long lines in the document, the longest one being 11 characters in excess of 72. == There are 19 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 RFC 3978 Section 5.4 Copyright Line does not match the current year -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (October 6, 2006) is 6410 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 4234 (ref. '8') (Obsoleted by RFC 5234) ** Obsolete normative reference: RFC 4566 (ref. '10') (Obsoleted by RFC 8866) == Outdated reference: A later version (-18) exists of draft-ietf-behave-rfc3489bis-04 == Outdated reference: A later version (-16) exists of draft-ietf-behave-turn-01 -- Obsolete informational reference (is this intentional?): RFC 3489 (ref. '13') (Obsoleted by RFC 5389) == Outdated reference: A later version (-07) exists of draft-ietf-mmusic-connectivity-precon-02 == Outdated reference: A later version (-04) exists of draft-ietf-avt-rtp-no-op-00 == Outdated reference: A later version (-08) exists of draft-ietf-behave-nat-udp-07 == Outdated reference: A later version (-20) exists of draft-ietf-sip-outbound-04 Summary: 6 errors (**), 0 flaws (~~), 9 warnings (==), 9 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 MMUSIC J. Rosenberg 3 Internet-Draft Cisco Systems 4 Expires: April 9, 2007 October 6, 2006 6 Interactive Connectivity Establishment (ICE): A Methodology for Network 7 Address Translator (NAT) Traversal for Offer/Answer Protocols 8 draft-ietf-mmusic-ice-11 10 Status of this Memo 12 By submitting this Internet-Draft, each author represents that any 13 applicable patent or other IPR claims of which he or she is aware 14 have been or will be disclosed, and any of which he or she becomes 15 aware will be disclosed, in accordance with Section 6 of BCP 79. 17 Internet-Drafts are working documents of the Internet Engineering 18 Task Force (IETF), its areas, and its working groups. Note that 19 other groups may also distribute working documents as Internet- 20 Drafts. 22 Internet-Drafts are draft documents valid for a maximum of six months 23 and may be updated, replaced, or obsoleted by other documents at any 24 time. It is inappropriate to use Internet-Drafts as reference 25 material or to cite them other than as "work in progress." 27 The list of current Internet-Drafts can be accessed at 28 http://www.ietf.org/ietf/1id-abstracts.txt. 30 The list of Internet-Draft Shadow Directories can be accessed at 31 http://www.ietf.org/shadow.html. 33 This Internet-Draft will expire on April 9, 2007. 35 Copyright Notice 37 Copyright (C) The Internet Society (2006). 39 Abstract 41 This document describes a protocol for Network Address Translator 42 (NAT) traversal for multimedia session signaling protocols based on 43 the offer/answer model, such as the Session Initiation Protocol 44 (SIP). This protocol is called Interactive Connectivity 45 Establishment (ICE). ICE makes use of the Simple Traversal 46 Underneath NAT (STUN) protocol, applying its binding discovery and 47 relay usages, in addition to defining a new usage for checking 48 connectivity between peers. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 53 2. Overview of ICE . . . . . . . . . . . . . . . . . . . . . . . 4 54 2.1. Gathering Candidate Addresses . . . . . . . . . . . . . . 6 55 2.2. Connectivity Checks . . . . . . . . . . . . . . . . . . . 8 56 2.3. Sorting Candidates . . . . . . . . . . . . . . . . . . . . 10 57 2.4. Frozen Candidates . . . . . . . . . . . . . . . . . . . . 10 58 2.5. Security for Checks . . . . . . . . . . . . . . . . . . . 11 59 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 11 60 4. Sending the Initial Offer . . . . . . . . . . . . . . . . . . 13 61 4.1. Gathering Candidates . . . . . . . . . . . . . . . . . . . 13 62 4.2. Prioritizing Candidates . . . . . . . . . . . . . . . . . 16 63 4.3. Choosing In-Use Candidates . . . . . . . . . . . . . . . . 18 64 4.4. Encoding the SDP . . . . . . . . . . . . . . . . . . . . . 18 65 5. Receiving the Initial Offer . . . . . . . . . . . . . . . . . 20 66 5.1. Verifying ICE Support . . . . . . . . . . . . . . . . . . 20 67 5.2. Gathering Candidates . . . . . . . . . . . . . . . . . . . 20 68 5.3. Prioritizing Candidates . . . . . . . . . . . . . . . . . 21 69 5.4. Choosing In Use Candidates . . . . . . . . . . . . . . . . 21 70 5.5. Encoding the SDP . . . . . . . . . . . . . . . . . . . . . 21 71 5.6. Forming the Check Lists . . . . . . . . . . . . . . . . . 21 72 5.7. Performing Periodic Checks . . . . . . . . . . . . . . . . 23 73 6. Receipt of the Initial Answer . . . . . . . . . . . . . . . . 24 74 6.1. Verifying ICE Support . . . . . . . . . . . . . . . . . . 24 75 6.2. Forming the Check List . . . . . . . . . . . . . . . . . . 24 76 6.3. Performing Periodic Checks . . . . . . . . . . . . . . . . 24 77 7. Connectivity Checks . . . . . . . . . . . . . . . . . . . . . 24 78 7.1. Applicability . . . . . . . . . . . . . . . . . . . . . . 24 79 7.2. Client Discovery of Server . . . . . . . . . . . . . . . . 25 80 7.3. Server Determination of Usage . . . . . . . . . . . . . . 25 81 7.4. New Requests or Indications . . . . . . . . . . . . . . . 25 82 7.5. New Attributes . . . . . . . . . . . . . . . . . . . . . . 25 83 7.6. New Error Response Codes . . . . . . . . . . . . . . . . . 25 84 7.7. Client Procedures . . . . . . . . . . . . . . . . . . . . 25 85 7.7.1. Sending the Request . . . . . . . . . . . . . . . . . 25 86 7.7.2. Processing the Response . . . . . . . . . . . . . . . 26 87 7.8. Server Procedures . . . . . . . . . . . . . . . . . . . . 27 88 7.9. Security Considerations for Connectivity Check . . . . . . 29 89 8. Completing the ICE Checks . . . . . . . . . . . . . . . . . . 29 90 9. Subsequent Offer/Answer Exchanges . . . . . . . . . . . . . . 30 91 9.1. Generating the Offer . . . . . . . . . . . . . . . . . . . 30 92 9.2. Receiving the Offer and Generating an Answer . . . . . . . 31 93 9.3. Updating the Check and Valid Lists . . . . . . . . . . . . 32 94 10. Keepalives . . . . . . . . . . . . . . . . . . . . . . . . . . 33 95 11. Media Handling . . . . . . . . . . . . . . . . . . . . . . . . 34 96 11.1. Sending Media . . . . . . . . . . . . . . . . . . . . . . 34 97 11.2. Receiving Media . . . . . . . . . . . . . . . . . . . . . 35 99 12. Usage with SIP . . . . . . . . . . . . . . . . . . . . . . . . 35 100 12.1. Latency Guidelines . . . . . . . . . . . . . . . . . . . . 35 101 12.2. Interactions with Forking . . . . . . . . . . . . . . . . 37 102 12.3. Interactions with Preconditions . . . . . . . . . . . . . 37 103 12.4. Interactions with Third Party Call Control . . . . . . . . 38 104 13. Grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 105 14. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 106 15. Security Considerations . . . . . . . . . . . . . . . . . . . 46 107 15.1. Attacks on Connectivity Checks . . . . . . . . . . . . . . 46 108 15.2. Attacks on Address Gathering . . . . . . . . . . . . . . . 49 109 15.3. Attacks on the Offer/Answer Exchanges . . . . . . . . . . 49 110 15.4. Insider Attacks . . . . . . . . . . . . . . . . . . . . . 50 111 15.4.1. The Voice Hammer Attack . . . . . . . . . . . . . . . 50 112 15.4.2. STUN Amplification Attack . . . . . . . . . . . . . . 50 113 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 51 114 16.1. candidate Attribute . . . . . . . . . . . . . . . . . . . 51 115 16.2. remote-candidates Attribute . . . . . . . . . . . . . . . 51 116 16.3. ice-pwd Attribute . . . . . . . . . . . . . . . . . . . . 52 117 16.4. ice-ufrag Attribute . . . . . . . . . . . . . . . . . . . 52 118 17. IAB Considerations . . . . . . . . . . . . . . . . . . . . . . 53 119 17.1. Problem Definition . . . . . . . . . . . . . . . . . . . . 53 120 17.2. Exit Strategy . . . . . . . . . . . . . . . . . . . . . . 53 121 17.3. Brittleness Introduced by ICE . . . . . . . . . . . . . . 54 122 17.4. Requirements for a Long Term Solution . . . . . . . . . . 55 123 17.5. Issues with Existing NAPT Boxes . . . . . . . . . . . . . 55 124 18. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 56 125 19. References . . . . . . . . . . . . . . . . . . . . . . . . . . 56 126 19.1. Normative References . . . . . . . . . . . . . . . . . . . 56 127 19.2. Informative References . . . . . . . . . . . . . . . . . . 57 128 Appendix A. Design Motivations . . . . . . . . . . . . . . . . . 58 129 A.1. Applicability to Gateways and Servers . . . . . . . . . . 59 130 A.2. Pacing of STUN Transactions . . . . . . . . . . . . . . . 60 131 A.3. Candidates with Multiple Bases . . . . . . . . . . . . . . 61 132 A.4. Purpose of the Translation . . . . . . . . . . . . . . . . 63 133 A.5. Importance of the STUN Username . . . . . . . . . . . . . 63 134 A.6. The Candidate Pair Sequence Number Formula . . . . . . . . 64 135 A.7. The Frozen State . . . . . . . . . . . . . . . . . . . . . 65 136 A.8. The remote-candidates attribute . . . . . . . . . . . . . 65 137 A.9. Why are Keepalives Needed? . . . . . . . . . . . . . . . . 66 138 A.10. Why Prefer Peer Reflexive Candidates? . . . . . . . . . . 67 139 A.11. Why Can't Offerers Send Media When a Pair Validates . . . 67 140 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 69 141 Intellectual Property and Copyright Statements . . . . . . . . . . 70 143 1. Introduction 145 RFC 3264 [4] defines a two-phase exchange of Session Description 146 Protocol (SDP) messages [10] for the purposes of establishment of 147 multimedia sessions. This offer/answer mechanism is used by 148 protocols such as the Session Initiation Protocol (SIP) [3]. 150 Protocols using offer/answer are difficult to operate through Network 151 Address Translators (NAT). Because their purpose is to establish a 152 flow of media packets, they tend to carry IP addresses within their 153 messages, which is known to be problematic through NAT [14]. The 154 protocols also seek to create a media flow directly between 155 participants, so that there is no application layer intermediary 156 between them. This is done to reduce media latency, decrease packet 157 loss, and reduce the operational costs of deploying the application. 158 However, this is difficult to accomplish through NAT. A full 159 treatment of the reasons for this is beyond the scope of this 160 specification. 162 Numerous solutions have been proposed for allowing these protocols to 163 operate through NAT. These include Application Layer Gateways 164 (ALGs), the Middlebox Control Protocol [15], Simple Traversal 165 Underneath NAT (STUN) [13] and its revision [11], the STUN Relay 166 Usage [12], and Realm Specific IP [17] [18] along with session 167 description extensions needed to make them work, such as the Session 168 Description Protocol (SDP) [10] attribute for the Real Time Control 169 Protocol (RTCP) [2]. Unfortunately, these techniques all have pros 170 and cons which make each one optimal in some network topologies, but 171 a poor choice in others. The result is that administrators and 172 implementors are making assumptions about the topologies of the 173 networks in which their solutions will be deployed. This introduces 174 complexity and brittleness into the system. What is needed is a 175 single solution which is flexible enough to work well in all 176 situations. 178 This specification provides that solution for media streams 179 established by signaling protocols based on the offer-answer model. 180 It is called Interactive Connectivity Establishment, or ICE. ICE 181 makes use of STUN and its relay extension, commonly called TURN, but 182 uses them in a specific methodology which avoids many of the pitfalls 183 of using any one alone. 185 2. Overview of ICE 187 In a typical ICE deployment, we have two endpoints (known as agents 188 in RFC 3264 terminology) which want to communicate. They are able to 189 communicate indirectly via some signaling system such as SIP, by 190 which they can perform an offer/answer exchange of SDP [4] messages. 191 Note that ICE is not intended for NAT traversal for SIP, which is 192 assumed to be provided via some other mechanism [31]. At the 193 beginning of the ICE process, the agents are ignorant of their own 194 topologies. In particular, they might or might not be behind a NAT 195 (or multiple tiers of NATs). ICE allows the agents to discover 196 enough information about their topologies to find a path or paths by 197 which they can communicate. 199 Figure Figure 1 shows a typical environment for ICE deployment. The 200 two endpoints are labelled L and R (for left and right, which helps 201 visualize call flows). Both L and R are behind NATs -- though as 202 mentioned before, they don't know that. The type of NAT and its 203 properties are also unknown. Agents L and R are capable of engaging 204 in an offer/answer exchange by which they can exchange SDP messages, 205 whose purpose is to set up a media session between L and R. 206 Typically, this exchange will occur through a SIP server. 208 In addition to the agents, a SIP server and NATs, ICE is typically 209 used in concert with STUN servers in the network. Each agent can 210 have its own STUN server, or they can be the same. 212 +-------+ 213 | SIP | 214 +-------+ | Srvr | +-------+ 215 | STUN | | | | STUN | 216 | Srvr | +-------+ | Srvr | 217 | | / \ | | 218 +-------+ / \ +-------+ 219 / \ 220 / \ 221 / \ 222 / \ 223 / <- Signalling -> \ 224 / \ 225 / \ 226 +--------+ +--------+ 227 | NAT | | NAT | 228 +--------+ +--------+ 229 / \ 230 / \ 231 / \ 232 +-------+ +-------+ 233 | Agent | | Agent | 234 | L | | R | 235 | | | | 236 +-------+ +-------+ 238 Figure 1 240 The basic idea behind ICE is as follows: each agent has a variety of 241 candidate transport addresses it could use to communicate with the 242 other agent. These might include: 244 o It's directly attached network interface (or interfaces in the 245 case of a multihomed machine 247 o A translated address on the public side of a NAT (a "server 248 reflexive" address) 250 o The address of a media relay the agent is using. 252 Potentially, any of L's candidate transport addresses can be used to 253 communicate with any of R's transport addresses. In practice, 254 however, many combinations will not work. For instance, if L and R 255 are both behind NATs then their directly interface addresses are 256 unlikely to be able to communicate directly (this is why ICE is 257 needed, after all!). The purpose of ICE is to discover which pairs 258 of addresses will work. The way that ICE does this is to 259 systematically try all possible pairs (in a carefully sorted order) 260 until it finds one or more that works. 262 2.1. Gathering Candidate Addresses 264 In order to execute ICE, an agent has to identify all of its address 265 candidates. Naturally, one viable candidate is one obtained directly 266 from a local interface the client has towards the network. Such a 267 candidate is called a HOST CANDIDATE. The local interface could be 268 one on a local layer 2 network technology, such as ethernet or WiFi, 269 or it could be one that is obtained through a tunnel mechanism, such 270 as a Virtual Private Network (VPN) or Mobile IP (MIP). In all cases, 271 these appear to the agent as a local interface from which ports (and 272 thus a candidate) can be allocated. 274 If an agent is multihomed, it can obtain a candidate from each 275 interface. Depending on the location of the peer on the IP network 276 relative to the agent, the agent may be reachable by the peer through 277 one of those interfaces, or through another. Consider, for example, 278 an agent which has a local interface to a private net 10 network, and 279 also to the public Internet. A candidate from the net10 interface 280 will be directly reachable when communicating with a peer on the same 281 private net 10 network, while a candidate from the public interface 282 will be directly reachable when communicating with a peer on the 283 public Internet. Rather than trying to guess which interface will 284 work prior to sending an offer, the offering agent includes both 285 candidates in its offer. 287 Once the agent has obtained host candidates, it uses STUN to obtain 288 additional candidates. These come in two flavors: translated 289 addresses on the public side of a NAT (SERVER REFLEXIVE CANDIDATES) 290 and addresses of media relays (RELAYED CANDIDATES). The relationship 291 of these candidates to the host candidate is shown in Figure 2. Both 292 types of candidates are discovered using STUN. 294 To Internet 296 | 297 | 298 | /------------ Relayed 299 | / Candidate 300 +--------+ 301 | | 302 | STUN | 303 | Server | 304 | | 305 +--------+ 306 | 307 | 308 | /------------ Server 309 |/ Reflexive 310 +------------+ Candidate 311 | NAT | 312 +------------+ 313 | 314 | /------------ Host 315 |/ Candidate 316 +--------+ 317 | | 318 | Agent | 319 | | 320 +--------+ 322 Figure 2 324 To find a server reflexive candidate, the agent sends a STUN Binding 325 Request, using the Binding Discovery Usage [11] from each host 326 candidate, to its STUN server. (It is assumed that the address of 327 the STUN server is configured, or learned in some way.) When the 328 agents sends the Binding Request, the NAT (assuming there is one) 329 will allocate a binding, mapping this server reflexive candidate to 330 the host candidate. Outgoing packets sent from the host candidate 331 will be translated by the NAT to the server reflexive candidate. 332 Incoming packets sent to the server relexive candidate will be 333 translated by the NAT to the host candidate and forwarded to the 334 agent. We call the host candidate associated with a given server 335 reflexive candidate the BASE. 337 Note 339 "Base" refers to the address you'd send from for a particular 340 candidate. Thus, as a degenerate case host candidates also have a 341 base, but it's the same as the host candidate. 343 When there are multiple NATs between the agent and the STUN server, 344 the STUN request will create a binding on each NAT, but only the 345 outermost server reflexive candidate will be discovered by the agent. 346 If the agent is not behind a NAT, then the base candidate will be the 347 same as the server reflexive candidate and the server reflexive 348 candidate can be ignored. 350 The final type of candidate is a RELAYED candidate. The STUN Relay 351 Usage [12] allows a STUN server to act as a media relay, forwarding 352 traffic between L and R. In order to send traffic to L, R sends 353 traffic to the media relay which forwards it to L and vice versa. 354 The same thing happens in the other direction. 356 Traffic from L to R has its addresses rewritten twice: first by the 357 NAT and second by the STUN relay server. Thus, the address that R 358 knows about and the one that it wants to send to is the one on the 359 STUN relay server. This address is the final kind of candidate, 360 which we call a RELAYED CANDIDATE. 362 2.2. Connectivity Checks 364 Once L has gathered all of its candidates, it orders them highest to 365 lowest priority and sends them to R over the signalling channel. The 366 candidates are carried in attributes in the SDP offer. When R 367 receives the offer, it performs the same gathering process and 368 responds with its own list of candidates. At the end of this 369 process, each agent has a complete list of both its candidates and 370 its peer's candidates and is ready to perform connectivity checks by 371 pairing up the candidates to see which pair works. 373 The basic principle of the connectivity checks is simple: 375 1. Sort the candidate pairs in priority order. 377 2. Send checks on each candidate pair in priority order. 379 3. Acknowledge checks received from the other agent. 381 A complete connectivity check for a single candidate pair is a simple 382 4-message handshake: 384 L R 385 - - 386 STUN request -> \ L's 387 <- STUN response / check 389 <- STUN request \ R's 390 STUN response -> / check 392 Figure 3 394 As an optimization, as soon as R gets L's check message he 395 immediately sends his own check message to L on the same candidate 396 pair. This accelerates the process of finding a valid candidate. 398 At the end of this handshake, both L and R know that they can send 399 (and receive) messages end-to-end in both directions. Note that as 400 soon as R receives L's STUN response it knows that the R->L path 401 works and it can start sending media on that path right away, as 402 shown below. This allows for 'early media' to flow as fast as 403 possible: 405 L R 406 - - 407 STUN request -> \ L's 408 <- STUN response / check 410 <- STUN request \ R's 411 STUN response -> / check 412 <- RTP Data 414 Figure 4 416 Once any connectivity check for a candidate for a given media 417 component succeeds, ICE uses that candidate and immediately abandons 418 all other connectivity checks for that component. Note that due to 419 race conditions and packet loss, this may mean that the "best" 420 candidate isn't selected, but it does guarantee the selection of a 421 candidate that works, and because of the sorting process it will 422 generally be one of the most preferred ones. 424 2.3. Sorting Candidates 426 Because the algorithm above searches all candidate pairs, if a 427 working pair exists it will eventually find it no matter what order 428 the candidates are tried in. In order to produce faster (and better) 429 results, the candidates are sorted in a specified order. The 430 algorithm is described in Section 4.2 but follows two general 431 principles: 433 o Each agent gives its candidates a numeric priority which is sent 434 along with the candidate to the peer 436 o The local and remote priorities are combined so that each agent 437 has the same ordering for the candidate pairs. 439 The second property is important for getting ICE to work when there 440 are NATs in front of A and B. Frequently, NATs will not allow packets 441 in from a host until the agent behind the NAT has sent a packet 442 towards that host. Consequently, ICE checks in each direction will 443 not succeed until both sides have sent a check through their 444 respective NATs. 446 In general the priority algorithm is designed so that candidates of 447 similar type get similar priorities and so that more direct routes 448 are favored over indirect ones. Within those guidelines, however, 449 agents have a fair amount of discretion about how to tune their 450 algorithms. 452 2.4. Frozen Candidates 454 The previous description only addresses the case where the agents 455 wish to establish a single media component--i.e., a single flow with 456 a single host-port quartet. However, in many cases (in particular 457 RTP and RTCP) the agents actually need to establish connectivity for 458 more than one flow. 460 The naive way to attack this problem would be to simply do 461 independent ICE exchanges for each media component. This is 462 obviously inefficient because the network properties are likely to be 463 very similar for each component (especially because RTP and RTCP are 464 typically run on adjacent ports). Thus, it should be possible to 465 leverage information from one media component in order to determine 466 the best candidates for another. ICE does this with a mechanism 467 called "frozen candidates." 469 The basic principle behind frozen candidates is that initially only 470 the candidates for a single media component are tested. The other 471 media components are marked "frozen". When the connectivity checks 472 for the first component succeed, the corresponding candidates for the 473 other components are unfrozen and checked immediately. This avoids 474 repeated checking of components which are superficially more 475 attractive but in fact are likely to fail. 477 While we've described "frozen" here as a separate mechanism for 478 expository purposes, in fact it is an integral part of ICE and the 479 the ICE prioritization algorithm automatically ensures that the right 480 candidates are unfrozen and checked in the right order. 482 2.5. Security for Checks 484 Because ICE is used to discover which addresses can be used to send 485 media between two agents, it is important to ensure that the process 486 cannot be hijacked to send media to the wrong location. Each STUN 487 connectivity check is covered by a message authentication code (MAC) 488 computed using a key exchanged in the signalling channel. This MAC 489 provides message integrity and data origin authentication, thus 490 stopping an attacker from forging or modifying connectivity check 491 messages. The MAC also aids in disambiguating ICE exchanges from 492 forked calls. 494 3. Terminology 496 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 497 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 498 document are to be interpreted as described in RFC 2119 [1]. 500 This specification makes use of the following terminology: 502 Agent: As defined in RFC 3264, an agent is the protocol 503 implementation involved in the offer/answer exchange. There are 504 two agents involved in an offer/answer exchange. 506 Peer: From the perspective of one of the agents in a session, its 507 peer is the other agent. Specifically, from the perspective of 508 the offerer, the peer is the answerer. From the perspective of 509 the answerer, the peer is the offerer. 511 Transport Address: The combination of an IP address and port. 513 Candidate: A transport address that is to be tested by ICE procedures 514 in order to determine its suitability for usage for receipt of 515 media. 517 Component: A component is a single transport address that is used to 518 support a media stream. For media streams based on RTP, there are 519 two components per media stream - one for RTP, and one for RTCP. 521 Host Candidate: A candidate obtained by binding to a specific port 522 from an interface on the host. This includes both physical 523 interfaces and logical ones, such as ones obtained through Virtual 524 Private Networks (VPNs) and Realm Specific IP (RSIP) [17] (which 525 lives at the operating system level). 527 Server Reflexive Candidate: A candidate obtained by sending a STUN 528 request from a host candidate to a STUN server, distinct from the 529 peer, whose address is configured or learned by the client prior 530 to an offer/answer exchange. 532 Peer Reflexive Candidate: A candidate obtained by sending a STUN 533 request from a host candidate to the STUN server running on a 534 peer's candidate. 536 Relayed Candidate: A candidate obtained by sending a STUN Allocate 537 request from a host candidate to a STUN server. The relayed 538 candidate is resident on the STUN server, and the STUN server 539 relays packets back towards the agent. 541 Translation: The translation of a relayed candidate is the transport 542 address that the relay will forward a packet to, when one is 543 received at the relayed candidate. For relayed candidates learned 544 through the STUN Allocate request, the translation of the relayed 545 candidate is the server reflexive candidate returned by the 546 Allocate response. 548 Base: The base of a server reflexive candidate is the host candidate 549 from which it was derived. A host candidate is also said to have 550 a base, equal to that candidate itself. Similarly, the base of a 551 relayed candidate is that candidate itself. 553 Foundation: Each candidate has a foundation, which is an identifier 554 that is distinct for two candidates that have different types, 555 different interface IP addresses for their base, and different IP 556 addresses for their STUN servers. Two candidates have the same 557 foundation when they are of the same type, their bases have the 558 same IP address, and, for server reflexive or relayed candidates, 559 they come from the same STUN server. Foundations are used to 560 correlate candidates, so that when one candidate is found to be 561 valid, candidates sharing the same foundation can be tested next, 562 as they are likely to also be valid. 564 Local Candidate: A candidate that an agent has obtained and included 565 in an offer or answer it sent. 567 Remote Candidate: A candidate that an agent received in an offer or 568 answer from its peer. 570 In-Use Candidate: A candidate is in-use when it appears in the m/c- 571 line of an active media stream. 573 Candidate Pair: A pairing containing a local candidate and a remote 574 candidate. 576 Check: A candidate pair where the local candidate is a transport 577 address from which an agent can send a STUN connectivity check. 579 Check List: An ordered set of STUN checks that an agent is to 580 generate towards a peer. 582 Periodic Check: A connectivity check generated by an agent as a 583 consequence of a timer that fires periodically, instructing it to 584 send a check. 586 Triggered Check: A connectivity check generated as a consequence of 587 the receipt of a connectivity check from the peer. 589 Valid List: An ordered set of candidate pairs that have been 590 validated by a successful STUN transaction. 592 4. Sending the Initial Offer 594 In order to send the initial offer in an offer/answer exchange, an 595 agent must gather candidates, priorize them, choose ones for 596 inclusion in the m/c-line, and then formulate and send the SDP. Each 597 of these steps is described in the subsections below. 599 4.1. Gathering Candidates 601 An agent gathers candidates when it believes that communications is 602 imminent. An offerer can do this based on a user interface cue, or 603 based on an explicit request to initiate a session. Every candidate 604 is a transport address. It also has a type and a base. Three types 605 are defined and gathered by this specification - host candidates, 606 server reflexive candidates, and relayed candidates. The base of a 607 candidate is the candidate that an agent must send from when using 608 that candidate. 610 The first step is to gather host candidates. Host candidates are 611 obtained by binding to ports (typically ephemeral) on an interface 612 (physical or virtual, including VPN interfaces) on the host. The 613 process for gathering host candidates depends on the transport 614 protocol. Procedures are specified here for UDP. 616 For each UDP media stream the agent wishes to use, the agent SHOULD 617 obtain a candidate for each component of the media stream on each 618 interface that the host has. It obtains each candidate by binding to 619 a UDP port on the specific interface. A host candidate (and indeed 620 every candidate) is always associated with a specific component for 621 which it is a candidate. Each component has an ID assigned to it, 622 called the component ID. For RTP-based media streams, the RTP itself 623 has a component ID of 1, and RTCP a component ID of 2. If an agent 624 is using RTCP it MUST obtain a candidate for it. If an agent is 625 using both RTP and RTCP, it would end up with 2*K host candidates if 626 an agent has K interfaces. 628 The base for each host candidate is set to the candidate itself. 630 Once the agent has obtained host candidates, it obtains server 631 reflexive and relayed candidates. The process for gathering server 632 reflexive and relayed candidates depends on the transport protocol. 633 Procedures are specified here for UDP. 635 Agents which serve end users directly, such softphones, hardphones, 636 terminal adapters and so on, SHOULD obtain relayed candidates and 637 MUST obtain server reflexive candidates. The requirement to obtain 638 relayed candidates is at SHOULD strength to allow for provider 639 variation. If they are not used, it is RECOMMENDED that it be 640 implemented and just disabled through configuration, so that it can 641 re-enabled through configuration if conditions change in the future. 642 Agents which represent network servers under the control of a service 643 provider, such as gateways to the telephone network, media servers, 644 or conferencing servers that are targeted at deployment only in 645 networks with public IP addresses MAY skip obtaining server reflexive 646 and relayed candidates. 648 The agent next pairs each host candidate with the STUN server with 649 which it is configured or has discovered by some means. This 650 specification only considers usage of a single STUN server. Every Ta 651 seconds, the agent chooses another such pair (the order is 652 inconsequential), and sends a STUN request to the server from that 653 host candidate. If the agent is using both relayed and server 654 reflexive candidates, this request MUST be a STUN Allocate request 655 from the relay usage [12]. If the agent is using only server 656 reflexive candidates, the request MUST be a STUN Binding request 657 using the binding discovery usage [11]. 659 The value of Ta SHOULD be configurable, and SHOULD have a default of 660 50ms. Note that this pacing applies only to starting STUN 661 transactions with source and destination transport addresses (i.e., 662 the host candidate and STUN server respectively) for which a STUN 663 transaction has not previously been sent. Consequently, 664 retransmissions of a STUN request are governed entirely by the 665 retransmission rules defined in [11]. Similarly, retries of a 666 request due to recoverable errors (such as an authentication 667 challenge) happen immediately and are not paced by timer Ta. Because 668 of this pacing, it will take a certain amount of time to obtain all 669 of the server reflexive and relayed candidates. Implementations 670 should be aware of the time required to do this, and if the 671 application requires a time budget, limit the amount of candidates 672 which are gathered. 674 An Allocate Response will provide the client with a server reflexive 675 candidate (obtained from the mapped address) and a relayed candidate 676 in the RELAY-ADDRESS attribute. A Binding Response will provide the 677 client with a only server reflexive candidate (also obtained from the 678 mapped address). The base of the server reflexive candidate is the 679 host candidate from which the Allocate or Binding request was sent. 680 The base of a relayed candidate is that candidate itself. A server 681 reflexive candidate obtained from an Allocate response is the called 682 the "translation" of the relayed candidate obtained from the same 683 response. The agent will need to remember the translation for the 684 relayed candidate, since it is placed into the SDP. If a relayed 685 candidate is identical to a host candidate (which can happen in rare 686 cases), the relayed candidate MUST be discarded. Proper operation of 687 ICE depends on each base being unique. 689 Next, redundant candidates are eliminated. A candidate is redundant 690 if its transport address equals another candidate, and its base 691 equals the base of that other candidate. Note that two candidates 692 can have the same transport address yet have different bases, and 693 these would not be considered redundant. 695 Finally, each candidate is assigned a foundation. The foundation is 696 an identifier, scoped within a session. Two candidates MUST have the 697 same foundation ID when they are of the same type (host, relayed, 698 server reflexive, peer reflexive or relayed), their bases have the 699 same IP address (the ports can be different), and, for reflexive and 700 relayed candidates, the STUN servers used to obtain them have the 701 same IP address. Similarly, two candidates MUST have different 702 foundations if their types are different, their bases have different 703 IP addresses, or the STUN servers used to obtain them have different 704 IP addresses. 706 4.2. Prioritizing Candidates 708 The prioritization process results in the assignment of a priority to 709 each candidate. An agent does this by determining a preference for 710 each type of candidate (server reflexive, peer reflexive, relayed and 711 host), and, when the agent is multihomed, choosing a preference for 712 its interfaces. These two preferences are then combined to compute 713 the priority for a candidate. That priority MUST be computed using 714 the following formula: 716 priority = (2^24)*(type preference) + 717 (2^8)*(local preference) + 718 (2^0)*(256 - component ID) 720 The type preference MUST be an integer from 0 to 126 inclusive, and 721 represents the preference for the type of the candidate (where the 722 types are local, server reflexive, peer reflexive and relayed). A 723 126 is the highest preference, and a 0 is the lowest. Setting the 724 value to a 0 means that candidates of this type will only be used as 725 a last resort. The type preference MUST be identical for all 726 candidates of the same type and MUST be different for candidates of 727 different types. The type preference for peer reflexive candidates 728 MUST be higher than that of server reflexive candidates. Note that 729 candidates gathered based on the procedures of Section 4.1 will never 730 be peer reflexive candidates; candidates of these type are learned 731 from the STUN connectivity checks performed by ICE. The component ID 732 is the component ID for the candidate, and MUST be between 1 and 256 733 inclusive. The local preference MUST be an integer from 0 to 65535 734 inclusive. It represents a preference for the particular interface 735 from which the candidate was obtained, in cases where an agent is 736 multihomed. 65535 represents the highest preference, and a zero, the 737 lowest. When there is only a single interface, this value SHOULD be 738 set to 65535. Generally speaking, if there are multiple candidates 739 for a particular component for a particular media stream which have 740 the same type, the local preference MUST be unique for each one. In 741 this specification, this only happens for multi-homed hosts. 743 These rules guarantee that there is a unique priority for each 744 candidate. This priority will be used by ICE to determine the order 745 of the connectivity checks and the relative preference for 746 candidates. Consequently, what follows are some guidelines for 747 selection of these values. 749 One criteria for selection of the type and local preference values is 750 the use of an intermediary. That is, if media is sent to that 751 candidate, will the media first transit an intermediate server before 752 being received. Relayed candidates are clearly one type of 753 candidates that involve an intermediary. Another are host candidates 754 obtained from a VPN interface. When media is transited through an 755 intermediary, it can increase the latency between transmission and 756 reception. It can increase the packet losses, because of the 757 additional router hops that may be taken. It may increase the cost 758 of providing service, since media will be routed in and right back 759 out of an intermediary run by the provider. If these concerns are 760 important, the type preference for relayed candidates can be set 761 lower than the type preference for reflexive and host candidates. 762 Indeed, it is RECOMMENDED that in this case, host candidates have a 763 type preference of 126, server reflexive candidates have a type 764 preference of 100, peer reflexive have a type prefence of 110, and 765 relayed candidates have a type preference of zero. Furthermore, if 766 an agent is multi-homed and has multiple interfaces, the local 767 preference for host candidates from a VPN interface SHOULD have a 768 priority of 0. 770 Another criteria for selection of preferences is IP address family. 771 ICE works with both IPv4 and IPv6. It therefore provides a 772 transition mechanism that allows dual-stack hosts to prefer 773 connectivity over IPv6, but to fall back to IPv4 in case the v6 774 networks are disconnected (due, for example, to a failure in a 6to4 775 relay) [22]. It can also help with hosts that have both a native 776 IPv6 address and a 6to4 address. In such a case, lower local 777 preferences could be assigned to the v6 interface, followed by the 778 6to4 interfaces, followed by the v4 interfaces. This allows a site 779 to obtain and begin using native v6 addresses immediately, yet still 780 fallback to 6to4 addresses when communicating with agents in other 781 sites that do not yet have native v6 connectivity. 783 Another criteria for selecting preferences is security. If a user is 784 a telecommuter, and therefore connected to their corporate network 785 and a local home network, they may prefer their voice traffic to be 786 routed over the VPN in order to keep it on the corporate network when 787 communicating within the enterprise, but use the local network when 788 communicating with users outside of the enterprise. In such a case, 789 a VPN interface would have a higher local preference than any other 790 interfaces. 792 Another criteria for selecting preferences is topological awareness. 793 This is most useful for candidates that make use of relays. In those 794 cases, if an agent has preconfigured or dynamically discovered 795 knowledge of the topological proximity of the relays to itself, it 796 can use that to assign higher local preferences to candidates 797 obtained from closer relays. 799 4.3. Choosing In-Use Candidates 801 A candidate is said to be "in-use" if it appears in the m/c-line of 802 an offer or answer. When communicating with an ICE peer, being in- 803 use implies that, should these candidates be selected by the ICE 804 algorithm, bidirectional media can flow and the candidates can be 805 used. If a candidate is selected by ICE but is not in-use, only 806 unidirectional media can flow and only for a brief time; the 807 candidate must be made in-use through an updated offer/answer 808 exchange. When communicating with a peer that is not ICE-aware, the 809 in-use candidates will be used exclusively for the exchange of media, 810 as defined in normal offer/answer procedures. 812 An agent MUST choose a set of candidates, one for each component of 813 each active media stream, to be in-use. A media stream is active if 814 it does not contain the a=inactive SDP attribute. 816 It is RECOMMENDED that in-use candidates be chosen based on the 817 likelihood of those candidates to work with the peer that is being 818 contacted. Unfortunately, it is difficult to ascertain which 819 candidates that might be. As an example, consider a user within an 820 enterprise. To reach non-ICE capable agents within the enterprise, 821 host candidates have to be used, since the enterprise policies may 822 prevent communication between elements using a relay on the public 823 network. However, when communicating to peers outside of the 824 enterprise, relayed candidates from a publically accessible STUN 825 server are needed. 827 Indeed, the difficulty in picking just one transport address that 828 will work is the whole problem that motivated the development of this 829 specification in the first place. As such, it is RECOMMENDED that 830 relayed candidates be selected to be in-use. Furthermore, ICE is 831 only truly effective when it is supported on both sides of the 832 session. It is therefore most prudent to deploy it to close-knit 833 communities as a whole, rather than piecemeal. In the example above, 834 this would mean that ICE would ideally be deployed completely within 835 the enterprise, rather than just to parts of it. 837 4.4. Encoding the SDP 839 The agent includes a single a=candidate media level attribute in the 840 SDP for each candidate for that media stream. The a=candidate 841 attribute contains the IP address, port and transport protocol for 842 that candidate. A Fully Qualified Domain Name (FQDN) for a host MAY 843 be used in place of a unicast address. In that case, when receiving 844 an offer or answer containing an FQDN in an a=candidate attribute, 845 the FQDN is looked up in the DNS using an A or AAAA record, and the 846 resulting IP address is used for the remainder of ICE processing. 848 The candidate attribute also includes the component ID for that 849 candidate. For media streams based on RTP, candidates for the actual 850 RTP media MUST have a component ID of 1, and candidates for RTCP MUST 851 have a component ID of 2. Other types of media streams which require 852 multiple components MUST develop specifications which define the 853 mapping of components to component IDs, and these component IDs MUST 854 be between 1 and 256. 856 The candidate attribute also includes the priority, which is the 857 value determined for the candidate as described in Section 4.2, and 858 the foundation, which is the value determined for the candidate as 859 described in Section 4.1. The agent SHOULD include a type for each 860 candidate by populating the candidate-types production with the 861 appropriate value - "host" for host candidates, "srflx" for server 862 reflexive candidates, "prflx" for peer reflexive candidates (though 863 these never appear in an initial offer/answer exchange), and "relay" 864 for relayed candidates. The related address MUST NOT be included if 865 a type was not included. If a type was included, the related address 866 SHOULD be present for server reflexive, peer reflexive and relayed 867 candidates. If a candidate is server or peer reflexive, the related 868 address is equal to the base for that server or peer reflexive 869 candidate. If the candidate is relayed, the related address is equal 870 to the translation of the relayed address. If the candidiate is a 871 host candidate, there is no related address and the rel-addr 872 production MUST be omitted. 874 STUN connectivity checks between agents make use of a short term 875 credential that is exchanged in the offer/answer process. The 876 username part of this credential is formed by concatenating a 877 username fragment from each agent, separated by a colon. Each agent 878 also provides a password, used to compute the message integrity for 879 requests it receives. As such, an SDP MUST contain the ice-ufrag and 880 ice-pwd attributes, containing the username fragment and password 881 respectively. These can be either session or media level attributes, 882 and thus common across all candidates for all media streams, or all 883 candidates for a particular media stream, respectively. However, if 884 two media streams have identical ice-ufrag's, they MUST have 885 identical ice-pwd's. The ice-ufrag and ice-pwd attributes MUST be 886 chosen randomly at the beginning of a session. The ice-ufrag 887 attribute MUST contain at least 24 bits of randomness, and the ice- 888 pwd attribute MUST contain at least 128 bits of randomness. This 889 means that the ice-ufrag attribute will be at least 4 characters 890 long, and the ice-pwd at least 22 characters long, since the grammar 891 for these attributes allows for 6 bits of randomness per character. 892 The attributes MAY be longer than 4 and 21 characters respectively, 893 of course. 895 The m/c-line is populated with the candidates that are in-use. For 896 streams based on RTP, this is done by placing the RTP candidate into 897 the m and c lines respectively. If the agent is utilizing RTCP, it 898 MUST encode the RTCP candidate into the m/c-line using the a=rtcp 899 attribute as defined in RFC 3605 [2]. If RTCP is not in use, the 900 agent MUST signal that using b=RS:0 and b=RR:0 as defined in RFC 3556 901 [5]. 903 There MUST be a candidate attribute for each component of the media 904 stream in the m/c-line. 906 Once an offer or answer are sent, an agent MUST be prepared to 907 receive both STUN and media packets on each candidate. As discussed 908 in Section 11.1, media packets can be sent to a candidate prior to 909 its appearence in the m/c-line. 911 5. Receiving the Initial Offer 913 When an agent receives an initial offer, it will check if the offeror 914 supports ICE, gather candidates, prioritize them, choose one for in- 915 use, encode and send an answer, and then form the check lists and 916 begin connectivity checks. 918 5.1. Verifying ICE Support 920 The agent will proceed with the ICE procedures defined in this 921 specification if the following are both true: 923 o There is at least one a=candidate attribute for each media stream 924 in the SDP it just received. 926 o For each media stream, at least one of the candidates is a match 927 for its respective in-use component in the m/c-line. 929 If both of these conditions are not met, the agent MUST process the 930 SDP based on normal RFC 3264 procedures, without using any of the ICE 931 mechanisms described in the remainder of this specification, with the 932 exception of Section 10, which describes keepalive procedures. 934 5.2. Gathering Candidates 936 The process for gathering candidates at the answerer is identical to 937 the process for the offerer as described in Section 4.1. It is 938 RECOMMENDED that this process begin immediately on receipt of the 939 offer, prior to user acceptance of a session. Such gathering MAY 940 even be done pre-emptively when an agent starts. 942 5.3. Prioritizing Candidates 944 The process for prioritizing candidates at the answerer is identical 945 to the process followed by the offerer, as described in Section 4.2. 947 5.4. Choosing In Use Candidates 949 The process for selecting in-use candidates at the answerer is 950 identical to the process followed by the offerer, as described in 951 Section 4.3. 953 5.5. Encoding the SDP 955 The process for encoding the SDP at the answerer is identical to the 956 process followed by the offerer, as described in Section 4.4. 958 5.6. Forming the Check Lists 960 Next, the agent forms the check lists. There is one check list per 961 in-use media stream resulting from the offer/answer exchange. A 962 media stream is in-use as long as its port is non-zero (which is used 963 in RFC 3264 to reject a media stream). Each check list is a sequence 964 of STUN connectivity checks that are performed by the agent. To form 965 the check list for a media stream, the agent forms candidate pairs, 966 computes a candidate pair priority, orders the pairs by priority, 967 prunes them, and sets their states. These steps are described in 968 this section. 970 First, the agent takes each of its candidates for a media stream 971 (called local candidates) and pairs them with the candidates it 972 received from its peer (called remote candidates) for that media 973 stream. A local candidate is paired with a remote candidate if and 974 only if the two candidates have the same component ID and have the 975 same IP address version. It is possible that some of the local 976 candidates don't get paired with a remote candidate, and some of the 977 remote candidates don't get paired with local candidates. This can 978 happen if one agent didn't include candidates for the all of the 979 components for a media stream. In the case of RTP, for example, this 980 would happen when one agent provided candidates for RTCP, and the 981 other did not. If this happens, the number of components for that 982 media stream is effectively reduced, and considered to be equal to 983 the minimum across both agents of the maximum component ID provided 984 by each agent across all components for the media stream. 986 Once the pairs are formed, a candidate pair priority is computed. 987 Let O-P be the priority for the candidate provided by the offerer. 988 Let A-P be the priority for the candidate provided by the answerer. 989 The priority for a pair is computed as: 991 pair priority = 2^32*MIN(O-P,A-P) + 2*MAX(O-P,A-P) + (O-P>A-P:1?0) 993 Where O-P>A-P:1?0 is an expression whose value is 1 if O-P is greater 994 than A-P, and 0 otherwise. This formula ensures a unique priority 995 for each pair in most cases. One the priority is assigned, the agent 996 sorts the candidate pairs in decreasing order of priority. If two 997 pairs have identical priority, the ordering amongst them is 998 arbitrary. 1000 This sorted list of candidate pairs is used to determine a sequence 1001 of connectivity checks that will be performed. Each check involves 1002 sending a request from a local candidate to a remote candidate. 1003 Since an agent cannot send requests directly from a reflexive 1004 candidate, but only from its base, the agent next goes through the 1005 sorted list of candidate pairs. For each pair where the local 1006 candidate is server reflexive, the server reflexive candidate MUST be 1007 replaced by its base. Once this has been done, the agent MUST remove 1008 redundant pairs. A pair is redundant if its local and remote 1009 candidates are identical to the local and remote candidates of a pair 1010 higher up on the priority list. The result is called the check list 1011 for that media stream, and each candidate pair on it is called a 1012 check. 1014 Each check is also said to have a foundation, which is merely the 1015 combination of the foundations of the local and remote candidates in 1016 the check. 1018 Finally, each check in the check list is associated with a state. 1019 This state is assigned once the check list for each media stream has 1020 been computed. There are five potential values that the state can 1021 have: 1023 Waiting: This check has not been performed, and can be performed as 1024 soon as it is the highest priority Waiting check on the check 1025 list. 1027 In-Progress: A request has been sent for this check, but the 1028 transaction is in progress. 1030 Succeeded: This check was already done and produced a successful 1031 result. 1033 Failed: This check was already done and failed, either never 1034 producing any response or producing an unrecoverable failure 1035 response. 1037 Frozen: This check hasn't been performed, and it can't yet be 1038 performed until some other check succeeds, allowing it to move 1039 into the Waiting state. 1041 First, the agent sets all of the checks in each check list to the 1042 Frozen state. Then, it takes the first check in the check list for 1043 the first media stream (a media stream is the first media stream when 1044 it is described by the first m-line in the SDP offer and answer), and 1045 sets its state to Waiting. It then finds all of the other checks in 1046 that check list with the same component ID, but different 1047 foundations, and sets all of their states to Waiting as well. Once 1048 this is done, one of the check lists will have some number of checks 1049 in the Waiting state, and the other check lists will have all of 1050 their checks in the Frozen state. A check list with at least one 1051 check that is not Frozen is called an active check list. 1053 5.7. Performing Periodic Checks 1055 An agent performs two types of checks. The first type are periodic 1056 checks. These checks occur periodically for each media stream, and 1057 involve choosing the highest priority check in the Waiting state from 1058 each check list, and performing it. The other type of check is 1059 called a triggered check. This is a check that is performed on 1060 receipt of a connectivity check from the peer. This section 1061 describes how periodic checks are performed. 1063 Once the agent has computed the check lists as described in 1064 Section 5.6, it sets a timer for each active check list. The timer 1065 fires every Ta/N seconds, where N is the number of active check lists 1066 (initially, there is only one active check list). Implementations 1067 MAY set the timer to fire less frequently than this. Ta is the same 1068 value used to pace the gathering of candidates, as described in 1069 Section 4.1. The first timer for each active check list fires 1070 immediately, so that the agent performs a connectivity check the 1071 moment the offer/answer exchange has been done, followed by the next 1072 periodic check Ta seconds later. 1074 When the timer fires, the agent MUST find the highest priority check 1075 in that check list that is in the Waiting state. The agent then 1076 sends a STUN check from the local candidate of that check to the 1077 remote candidate of that check. The procedures for forming the STUN 1078 request for this purpose are described in Section 7.7.1. If none of 1079 the checks in that check list are in the Waiting state, but there are 1080 checks in the Frozen state, the highest priority check in the Frozen 1081 state is moved into the Waiting state, and that check is performed. 1082 When a check is performed, its state is set to In-Progress. If there 1083 are no checks in either the Waiting or Frozen state, then the timer 1084 for that check list is stopped. 1086 Performing the connectivity check requires the agent to know the 1087 username fragment for the local and remote candidates, and the 1088 password for the remote candidate. For periodic checks, the remote 1089 username fragment and password are learned directly from the SDP 1090 received from the peer, and the local username fragment is known by 1091 the agent. 1093 6. Receipt of the Initial Answer 1095 This section describes the procedures that an agent follows when it 1096 receives the answer from the peer. It verifies that its peer 1097 supports ICE, forms the check list and begins performing periodic 1098 checks. 1100 6.1. Verifying ICE Support 1102 The offerer follows the same procedures described for the answerer in 1103 Section 5.1. 1105 6.2. Forming the Check List 1107 The offerer follows the same procedures described for the answerer in 1108 Section 5.6. 1110 6.3. Performing Periodic Checks 1112 The offerer follows the same procedures described for the answerer in 1113 Section 5.7. 1115 7. Connectivity Checks 1117 This section describes how connectivity checks are performed. 1118 Connectivity checks are a STUN usage, and the behaviors described 1119 here meet the guidelines for definitions of new usages as outlined in 1120 [11] 1122 Note that all ICE implementations are required to be compliant to 1123 [11], as opposed to the older [13]. 1125 7.1. Applicability 1127 This STUN usage provides a connectivity check between two peers 1128 participating in an offer/answer exchange. This check serves to 1129 validate a pair of candidates for usage of exchange of media. 1130 Connectivity checks also allow agents to discover reflexive 1131 candidates towards their peers, called peer reflexive candidates. 1133 Finally, connectivity checks serve to keep NAT bindings alive. 1135 It is fundamental to this STUN usage that the addresses and ports 1136 used for media are the same ones used for the Binding Requests and 1137 responses. Consequently, it will be necessary to demultiplex STUN 1138 traffic from whatever the media traffic is. This demultiplexing is 1139 done using the techniques described in [11]. 1141 7.2. Client Discovery of Server 1143 The client does not follow the DNS-based procedures defined in [11]. 1144 Rather, the remote candidate of the check to be performed is used as 1145 the transport address of the STUN server. Note that the STUN server 1146 is a logical entity, and is not a physically distinct server in this 1147 usage. 1149 7.3. Server Determination of Usage 1151 The server is aware of this usage because it signaled this port 1152 through the offer/answer exchange. Any STUN packets received on this 1153 port will be for the connectivity check usage. 1155 7.4. New Requests or Indications 1157 This usage does not define any new message types. 1159 7.5. New Attributes 1161 This usage defines a new attribute, PRIORITY. This attribute 1162 indicates the priority that is to be associated with a peer reflexive 1163 candidate, should one be discovered by this check. It is a 32 bit 1164 unsigned integer, and has an attribute type of 0x0024. 1166 7.6. New Error Response Codes 1168 This usage does not define any new error response codes. 1170 7.7. Client Procedures 1172 This section defines additional procedures for the Binding Request 1173 transaction, beyond those described in [11]. 1175 7.7.1. Sending the Request 1177 The agent acting as the client generates a connectivity check either 1178 periodically, or triggered. In either case, the check is generated 1179 by sending a Binding Request from a local candidate, to a remote 1180 candidate. The agent must know the username fragment for both 1181 candidates and the password for the remote candidate. 1183 A Binding Request serving as a connectivity check MUST utilize a STUN 1184 short term credential. Rather than being learned from a Shared 1185 Secret request, the short term credential is exchanged in the offer/ 1186 answer procedures. In particular, the username is formed by 1187 concatenating the username fragment provided by the peer with the 1188 username fragment of the agent sending the request, separated by a 1189 colon (":"). The password is equal to the password provided by the 1190 peer. For example, consider the case where agent A is the offerer, 1191 and agent B is the answerer. Agent A included a username fragment of 1192 AFRAG for its candidates, and a password of APASS. Agent B provided 1193 a username fragment of BFRAG and a password of BPASS. A connectivity 1194 check from A to B (and its response of course) utilize the username 1195 BFRAG:AFRAG and a password of BPASS. A connectivity check from B to 1196 A (and its response) utilize the username AFRAG:BFRAG and a password 1197 of APASS. 1199 All Binding Requests for the connectivity check usage MUST contain 1200 the PRIORITY attribute. This MUST be set equal to the priority that 1201 would be assigned, based on the algorithm in Section 4.2, to a peer 1202 reflexive candidate learned from this check. Such a peer reflexive 1203 candidate has a stream ID, component ID and local preference that are 1204 equal to the host candidate from which the check is being sent, but a 1205 type preference equal to the value associated with peer reflexive 1206 candidates. 1208 The Binding Request by an agent MUST include the USERNAME and 1209 MESSAGE-INTEGRITY attributes. That is, an agent MUST NOT wait to be 1210 challenged for short term credentials. Rather, it MUST provide them 1211 in the Binding Request right away. 1213 7.7.2. Processing the Response 1215 If the STUN transaction generates an unrecoverable failure response 1216 or times out, the agent sets the state of the check to Failed. The 1217 remainder of this section applies to processing of successful 1218 responses (any response from 200 to 299). 1220 The agent MUST check that the source IP address and port of the 1221 response equals the destination IP address and port that the Binding 1222 Request was sent to, and that the destination IP address and port of 1223 the response match the source IP address and port that the Binding 1224 Request was sent from. If these do not match, the agent sets the 1225 state of the check to Failed. The processing described in the 1226 remainder of this section MUST NOT be performed. 1228 If the check succeeds, processing continues and the agent changes the 1229 state for this check to Succeeded. Next, the agent sees if the 1230 success of this check can cause other checks to be unfrozen. If the 1231 check had a component ID of one, the agent MUST change the states for 1232 all other Frozen checks for the same media stream and same 1233 foundation, but different component IDs, to Waiting. If the 1234 component ID for the check was equal to the number of components for 1235 the media stream, the agent MUST change the state for all other 1236 Frozen checks for the first component of different media streams (and 1237 thus in different check lists) but the same foundation, to Waiting. 1239 Next, the agent checks the mapped address from the STUN response. If 1240 the transport address does not match any of the local candidates that 1241 the agent knows about, the mapped address representes a new peer 1242 reflexive candidate. Its type is equal to peer reflexive. Its base 1243 is set equal to the candidate from which the STUN check was sent. 1244 Its username fragment and password are identical to the candidate 1245 from which the check was sent. It is assigned the priority value 1246 that was placed in the PRIORITY attribute of the request. Its 1247 foundation is selected as described in Section 4.1. The peer 1248 reflexive candidate is then added to the list of local candidates 1249 known by the agent (though it is not paired with other remote 1250 candidates at this time). 1252 In addition, the agent creates a candidate pair whose local candidate 1253 equals the mapped address of the response, and whose remote candidate 1254 equals the destination address to which the request was sent. This 1255 is called a validated pair, since it has been validated by a STUN 1256 connectivity check. It is very important to note that this validated 1257 pair will often not be identical to the check itself; in many cases, 1258 the local candidate (learned through the mapped address in the 1259 response) will be different than the local candidate the request was 1260 sent from. However, the agent will know, either from the SDP or 1261 through the PRIORITY attribute that was present in a STUN request, 1262 the priorities of the local and remote candidates of the validated 1263 pair. Based on these priorities, a priority for the validated pair 1264 itself is computed if it was not already known, using the algorithm 1265 in Section 5.6, and the pair is added to the valid list. 1267 7.8. Server Procedures 1269 An agent MUST be prepared to receive a Binding Request on the base of 1270 each candidate it included in its most recent offer or answer. 1271 Receipt of a Binding Request on a transport address that the agent 1272 had included in a candidate attribute is an indication that the 1273 connectivity check usage applies to the request. 1275 The agent MUST use a short term credential to authenticate the 1276 request and perform a message integrity check. The agent MUST accept 1277 a credential if the username consists of two values separated by a 1278 colon, where the first value is equal to the username fragment 1279 generated by the agent in an offer or answer for a session in- 1280 progress, and the password is equal to the password for that username 1281 fragment. It is possible (and in fact very likely) that an offeror 1282 will receive a Binding Request prior to receiving the answer from its 1283 peer. However, the request can be processed without receiving this 1284 answer, and a response generated. 1286 For requests being received on a relayed candidate, the source 1287 transport address used for STUN processing (namely, generation of the 1288 XOR-MAPPED-ADDRESS attribute) is the transport address as seen by the 1289 relay. That source transport address will be present in the REMOTE- 1290 ADDRESS attribute of a STUN Data Indication message, if the Binding 1291 Request was delivered through a Data Indication. If the Binding 1292 Request was not encapsulated in a Data Indication, that source 1293 address is equal to the current active destination for the STUN relay 1294 session. 1296 When the agent receives a STUN Binding Request for which it generates 1297 a successful response, the agent checks the source transport address 1298 of the request. If this transport address does not match any 1299 existing remote candidates, it represents a new peer reflexive remote 1300 candidate. This candidate is given a priority equal to the PRIORITY 1301 attribute from the request. The type of the candidate is equal to 1302 peer reflexive. Its foundation is set to an arbitrary value, 1303 different from the foundation for all other remote candidates. The 1304 username fragment for this candidate is equal to the bottom half (the 1305 part after the colon) of the username in the Binding Request that was 1306 just received. The password for this username fragment is taken from 1307 the SDP from the peer. If agent has not yet received this SDP (a 1308 likely case for the offerer in the initial offer/answer exchange), it 1309 MUST wait for the SDP to be received, and then proceed with rest of 1310 the processing described in the remainder of this section. This 1311 candidate is then added to the list of remote candidates. However, 1312 it is not paired with any local candidates. 1314 Next, the agent MUST generate a triggered check in the reverse 1315 directon if it has not already sent such a check. The triggered 1316 check has a local candidate equal to the candidate on which the STUN 1317 request was received, and a remote candidate equal to the source 1318 transport address where the request came from (which may be a newly 1319 formed peer reflexive candidate). The agent knows the priorities for 1320 the local and remote candidates of this check, and so can compute the 1321 priority for the check itself. If there is already a check on the 1322 check list with this same local and remote candidates, and the state 1323 of that check is Waiting or Frozen, its state is changed to In- 1324 Progress and the check is performed. If there was already a check on 1325 the check list with this same local and remote candidates, and its 1326 state was In-Progress, the agent SHOULD generate an immediate 1327 retransmit of the Binding Request. This is to facilitate rapid 1328 completion of ICE when both agents are behind NAT. If there was a 1329 check in the list already and its state was Succeeded or Failed, 1330 nothing further is done. If there was no matching check on the check 1331 list, it is inserted into the check list based on its priority, its 1332 state is set to In-Progress, and the check is performed. 1334 7.9. Security Considerations for Connectivity Check 1336 Security considerations for the connectivity check are discussed in 1337 Section 15. 1339 8. Completing the ICE Checks 1341 When a pair is added to the valid list, and the agent was the offeror 1342 in the most recent offer/answer exchange, the agent MUST check to see 1343 if there is a pair on the validated list for each component of each 1344 media stream. If there is, the offeror MUST stop timer Ta, and MUST 1345 cease retransmitting any Binding Requests for transactions in 1346 progress. It MUST ignore any responses which may subsequently arrive 1347 to transactions previously in progress. The offeror MUST generate an 1348 updated offer as described in Section 9. It does this regardless of 1349 whether the highest priority pairs in the check list match the 1350 current in-use candidate pairs. 1352 When a pair is aded to the valid list, and the agent was the answerer 1353 in the most recent offer/answer exchange, the agent MAY begin sending 1354 media using that candidate pair, as described in Section 11.1. In 1355 addition, if there is a candidate pair on the valid list for each 1356 component of each media stream, the answerer MUST stop timer Ta, and 1357 MUST cease retransmitting any Binding Requests for transactions in 1358 progress. It MUST ignore any responses which may subsequently arrive 1359 to transactions previously in progress. 1361 Note that only agent that was the answerer in the most recent offer/ 1362 answer exchange gets to send media right away. The offeror must wait 1363 for a subsequent offer/answer exchange if the valid candidates don't 1364 match those in the m/c-line. 1366 OPEN ISSUE: It is possible that higher priority checks may still 1367 succeed, if we allowed things to continue. This can happen for 1368 several reasons. First, an in-progress check of higher priority 1369 had some packet loss and thus hasn't completed. Timer Tws was 1370 meant to handle this (I removed this timer from -10 to simplify). 1371 More interestingly, higher priority checks may have not been done 1372 because a triggered check of lower priority succeeded. This 1373 happens in cases where the number of checks at each agent are 1374 assymetric. It is possible to fix both of these problems by 1375 delaying the completion of the ICE procedures for a bit more time. 1376 This adds complexity and latency. The basic algorithm would be 1377 this. You take the lowest priority pair in the valid list. You 1378 keep doing checks as long as there are higher priority checks on 1379 the list in the Waiting state. If there are none, you wait a 1380 brief time (say 50ms) and then consider ICE finished. 1382 9. Subsequent Offer/Answer Exchanges 1384 An agent MAY generate a subsequent offer at any time. However, the 1385 rules in Section 7.7.2 will cause the offerer to generate an updated 1386 offer when the candidates in the valid list are not all in-use. 1388 9.1. Generating the Offer 1390 When an agent generates an updated offer, the set of candidate 1391 attributes to include depend on the state of ICE processing. If ICE 1392 is "done", which occurs when the valid list includes a candidate pair 1393 for each component of each media stream, the agent MUST include a 1394 candidate attribute for each local candidate amongst the pairs in the 1395 valid list (including peer reflexive candidates), and SHOULD NOT 1396 include any others. This will cause STUN keepalives to be sent for 1397 the in-use candidates, and thats it. 1399 If, however, the valid list does not yet include a candidate pair for 1400 each component of each media stream, the agent SHOULD include all 1401 current candidates, including any peer reflexive candidates it has 1402 learned since the last offer or answer it sent. This MAY include 1403 candidates it did not offer previously, but which it has gathered 1404 since the last offer/answer exchange. 1406 If a candidate was sent in a previous offer/answer exchange, it 1407 SHOULD have the same priority. For a peer reflexive candidate, the 1408 priority SHOULD be the same as determined by the processing in 1409 Section 7.7.2. The foundation SHOULD be the same. The username 1410 fragments and passwords for a media stream SHOULD remain the same as 1411 the previous offer or answer. 1413 Population of the m/c-lines also depends on the state of ICE 1414 processing. If, for a particular media stream, the valid list has 1415 candidate pairs for all of the components of that media stream, those 1416 pairs are used. In particular, the m/c-line would be constructed by 1417 from the local candidate from each of those candidate pairs. In 1418 addition, the agent MUST include the a=remote-candidates attribute 1419 for that media stream, and include in it the remote candidates for 1420 each of the pairs that were used. 1422 If, for a particular media stream, the valid list does not have pairs 1423 for all of the components of the stream, the agent SHOULD populate 1424 the m/c-line for that media stream based on the considerations in 1425 Section 4.3. 1427 The agent MUST use the same ice-pwd and ice-ufrag for a media stream 1428 as its previous offer or answer. Note that it is permissible to use 1429 a session-level attribute in one offer, but to provide the same 1430 password as a media-level attribute in a subsequent offer. This is 1431 not a change in password, just a change in its representation. 1433 9.2. Receiving the Offer and Generating an Answer 1435 When the answerer generates its answer, it must decide what 1436 candidates to include in the answer, and how to populate the m/c- 1437 line. 1439 For each media stream in the offer, the agent checks to see if the 1440 stream contained the remote-candidates attribute. If it did, it 1441 means that the offerer believed that ICE processing has completed for 1442 that media stream. In this case, the remote-candidates attribute 1443 contains the candidates that the answerer is supposed to use. It is 1444 possible that the agent doesn't even know of these candidates yet; 1445 they will be discovered shortly through a response to an in-progress 1446 check. The agent MUST populate the m/c-line with the candidates from 1447 the a=remote-candidates attribute. In addition, it MUST include an 1448 a=candidate attribute in its answer for each candidate in the 1449 a=remote-candidates attribute. If the agent is not aware of the 1450 candidate yet, it will need to generate a priority value for it. The 1451 type preference in the computation is peer-reflexive, and the stream 1452 ID and component ID are known from the offer. The agent chooses an 1453 arbitrary local preference value if it is multi-homed, since it won't 1454 yet know the interface associated with this candidate. 1456 If a media stream does not yet contain the a=remote-candidates 1457 attribute, it means that the offerer believes that ICE checks are 1458 still in progress for that media stream. In this case, the answerer 1459 SHOULD include an a=candidate attribute for all of the candidates for 1460 that media stream it knows about (including peer-reflexive 1461 candidates). The m/c-line is populated based on the considerations 1462 in Section 4.3. 1464 Construction of the ice-pwd and ice-ufrag are identical to the 1465 procedures followed by the offerer, as described in Section 9.1. 1467 Note that the a=remote-candidates attribute SHOULD NOT be included in 1468 the answer, and if included, will just be ignored by the offerer, 1469 since it is not used in any processing of the answer. 1471 9.3. Updating the Check and Valid Lists 1473 Once the subsequent offer/answer exchange has completed, each agent 1474 needs to compute the new check lists resulting from this exchange, 1475 and then remove any pairs from the valid list which are no longer 1476 usable. Once these adjustments are made, ICE processing continues 1477 using these new lists. 1479 Each agent recomputes the check lists using the procedures described 1480 in Section 5.6. If a check on the new check lists was also on the 1481 previous check lists, and its state was Waiting, In-Progress, 1482 Succeeded or Failed, its state is copied over. If a check on the new 1483 check lists does not have a state (because its a new check on an 1484 existing check list, or a check on a new check list, or the check was 1485 on an old check list but its state was not copied over) its state is 1486 set to Frozen. 1488 If none of the check lists are active (meaning that the checks in 1489 each check list are Frozen), the agent sets the first check in the 1490 check list for the first media stream to Waiting, and then sets the 1491 state of all other checks in that check list for the same component 1492 ID and with the same foundation to Waiting as well. 1494 Next, the agent goes through each check list, starting with the 1495 highest priority check. If a check has a state of Succeeded, and it 1496 has a component ID of 1, then all Frozen checks in the same check 1497 list with the same foundation whose component IDs are not one, have 1498 their state set to Waiting. If, for a particular check list, there 1499 are checks for each component of that media stream in the Succeeded 1500 state, the agent moves the state of all Frozen checks for the first 1501 component of all other media streams (and thus in different check 1502 lists) with the same foundation to Waiting. 1504 If a check was on the old check list, but was not on the new check 1505 list, and had a state of In-Progress, the corresponding STUN 1506 transaction is abandoned. No further retransmits will be sent for 1507 the STUN request, and any response that might be received is ignored. 1509 Next, the agent prunes the valid list. For each pair on the valid 1510 list, the agent examines each candidate in the pair. If the 1511 candidate was not peer reflexive, and was not present in the most 1512 recent offer/answer exchange, the candidate pair is removed from the 1513 valid list. 1515 OPEN ISSUE: This means that you cannot forcefully remove a peer 1516 reflexive candidate. This feature was possible, at much 1517 complexity, in previous versions of the spec. An alternative is 1518 to remove a peer reflexive candidate if it was not present in the 1519 offer/answer, and was discovered more than 500ms ago. 1521 10. Keepalives 1523 STUN connectivity checks are also used to keep NAT bindings open once 1524 a session is underway. This is accomplished by periodically re- 1525 starting the check process, as described in this section. 1527 Once the initial offer/answer exchange has taken place, the agent 1528 sets a timer to fire in Tr seconds. Tr SHOULD be configurable and 1529 SHOULD have a default of 15 seconds. When Tr fires, the agent MUST 1530 reset the states for all of the checks in the check list using the 1531 procedures defined in Section 5.6 and then begin performing periodic 1532 checks as described in Section 5.7. By the time the timer fires for 1533 the first time, the check list will include only the in-use 1534 candidates. Reperforming these checks will therefore performing a 1535 period keepalive. 1537 OPEN ISSUE: ICE isn't saying anything about what happens if these 1538 periodic keepalives should fail. It they do, something really bad 1539 has happened, like a NAT reboot or failure. I think we should 1540 keep that out of scope. 1542 When an ICE agent is communicating with an agent that is not ICE- 1543 aware, keepalives still need to be utilized. Indeed, these 1544 keepalives are essential even if neither endpoint implements ICE. As 1545 such, this specification defines keepalive behavior generally, for 1546 endpoints that support ICE, and those that do not. 1548 All endpoints MUST send keepalives for each media session. These 1549 keepalives MUST be sent regardless of whether the media stream is 1550 currently inactive, sendonly, recvonly or sendrecv. The keepalive 1551 SHOULD be sent using a format which is supported by its peer. ICE 1552 endpoints allow for STUN-based keepalives for UDP streams, and as 1553 such, STUN keepalives MUST be used when an agent is communicating 1554 with a peer that supports ICE. An agent can determine that its peer 1555 supports ICE by the presence of the a=candidate attributes for each 1556 media session. If the peer does not support ICE, the choice of a 1557 packet format for keepalives is a matter of local implementation. A 1558 format which allows packets to easily be sent in the absence of 1559 actual media content is RECOMMENDED. Examples of formats which 1560 readily meet this goal are RTP No-Op [27] and RTP comfort noise [23]. 1561 If the peer doesn't support any formats that are particularly well 1562 suited for keepalives, an agent SHOULD send RTP packets with an 1563 incorrect version number, or some other form of error which would 1564 cause them to be discarded by the peer. 1566 STUN-based keepalives will be sent periodically every Tr seconds as 1567 described above. If STUN keepalives are not in use (because the peer 1568 does not support ICE), an agent SHOULD ensure that a media packet is 1569 sent every Tr seconds. If one is not sent as a consequence of normal 1570 media communications, a keepalive packet using one of the formats 1571 discussed above SHOULD be sent. 1573 11. Media Handling 1575 11.1. Sending Media 1577 Agents always send media using a candidate pair. An agent will send 1578 media to the remote candidate in the pair (setting the destination 1579 address and port of the packet equal to that remote candidate), and 1580 will send it from the local candidate. When the local candidate is 1581 server or peer reflexive, media is originated from the base. Media 1582 sent from a relayed candidate is sent through that relay, using 1583 procedures defined in [12]. 1585 If an agent was the offerer in the most recent offer/answer exchange, 1586 when it sends media, it MUST use the candidates in the m/c-line for 1587 each media stream. However, it MUST only send media once those 1588 candidates also appear in the valid list. If the candidates in the 1589 m/c-line are not the ones that are ultimately selected by ICE, this 1590 implies that the offerer will need to wait for the subsequent offer/ 1591 answer exchange to complete before it can send media. 1593 If an agent was the answerer in the most recent offer/answer 1594 exchange, the rules are different. When the agent wishes to send 1595 media, and the candidate pairs in the m/c-lines are also the highest 1596 priority ones in the valid list for each media stream, it uses those 1597 candidate pairs. If, however, the highest priority pairs in the 1598 valid list for a media stream are not the same as the ones in the 1599 m/c-lines, the agent MUST use the highest priority pairs in the valid 1600 list. However, the agent MUST discontinue using those candidate 1601 pairs Tlo seconds after the next opportunity its peer would have to 1602 send an updated offer. In the case of an answer delivered in a 200 1603 OK to an offer in a SIP INVITE (regardless of whether that same 1604 answer appeared in an earlier unreliable provisional response), this 1605 would be Tlo seconds after receipt of the ACK. Tlo SHOULD be 1606 configurable and SHOULD have a default of 5 seconds. This time 1607 represents the amount of time it should take the offerer to perform 1608 its connectivity checks, arrive at the same conclusion about the 1609 candidate pair, and then generate an updated offer. If, after Tlo 1610 seconds, no updated offer arrives, the answerer MUST cease sending 1611 media, and will need to wait for the updated offer. 1613 OPEN ISSUE: In previous versions of ICE, once this timer fired, 1614 you just sent media to the one in the m/c-line. This causes the 1615 media streams to flip back and forth between addresses, which I am 1616 trying to avoid. Since this timer should never go off anyway, I 1617 removed this feature. 1619 ICE has interactions with jitter buffer adaptation mechanisms. An 1620 RTP stream can begin using one candidate, and switch to another one, 1621 though this happens rarely with ICE. The newer candidate may result 1622 in RTP packets taking a different path through the network - one with 1623 different delay characteristics. As discussed below, agents are 1624 encouraged to re-adjust jitter buffers when there are changes in 1625 source or destination address. Furthermore, many audio codecs use 1626 the marker bit to signal the beginning of a talkspurt, for the 1627 purposes of jitter buffer adaptation. For such codecs, it is 1628 RECOMMENDED that the sender change the marker bit when an agent 1629 switches transmission of media from one candidate pair to another. 1631 11.2. Receiving Media 1633 ICE implementations MUST be prepared to receive media on any 1634 candidates provided in the most recent offer/answer exchange. 1636 It is RECOMMENDED that, when an agent receives an RTP packet with a 1637 new source or destination IP address for a particular media stream, 1638 that the agent re-adjust its jitter buffers. 1640 RFC 3550 [20] describes an algorithm in Section 8.2 for detecting 1641 SSRC collisions and loops. These algorithms are based, in part, on 1642 seeing different source transport addresses with the same SSRC. 1643 However, when ICE is used, such changes will sometimes occur as the 1644 media streams switch between candidates. An agent will be able to 1645 determine that a media stream is from the same peer as a consequence 1646 of the STUN exchange that proceeds media transmission. Thus, if 1647 there is a change in source transport address, but the media packets 1648 come from the same peer agent, this SHOULD NOT be treated as an SSRC 1649 collision. 1651 12. Usage with SIP 1653 12.1. Latency Guidelines 1655 ICE requires a series of STUN-based connectivity checks to take place 1656 between endpoints. These checks start from the answerer on 1657 generation of its answer, and start from the offerer when it receives 1658 the answer. These checks can take time to complete, and as such, the 1659 selection of messages to use with offers and answers can effect 1660 perceived user latency. Two latency figures are of particular 1661 interest. These are the post-pickup delay and the post-dial delay. 1662 The post-pickup delay refers to the time between when a user "answers 1663 the phone" and when any speech they utter can be delivered to the 1664 caller. The post-dial delay refers to the time between when a user 1665 enters the destination address for the user, and ringback begins as a 1666 consequence of having succesfully started ringing the phone of the 1667 called party. 1669 To reduce post-dial delays, it is RECOMMENDED that the caller begin 1670 gathering candidates prior to actually sending its initial INVITE. 1671 This can be started upon user interface cues that a call is pending, 1672 such as activity on a keypad or the phone going offhook. 1674 If an offer is received in an INVITE request, the callee SHOULD 1675 immediately gather its candidates and then generate an answer in a 1676 provisional response. When reliable provisional responses are not 1677 used, the SDP in the provisional response is the answer, and that 1678 exact same answer reappears in the 200 OK. To deal with possible 1679 losses of the provisional response, it SHOULD be retransmitted until 1680 some indication of receipt. This indication can either be through 1681 PRACK [9], or through the receipt of a successful STUN Binding 1682 Request. Even if PRACK is not used, the provisional response SHOULD 1683 be retransmitted using the exponential backoff described in [9]. 1684 Furthermore, once the answer has been sent, the agent SHOULD begin 1685 its connectivity checks. Once candidate pairs for each component of 1686 a media stream enter the valid list, the callee can begin sending 1687 media on that media stream. 1689 However, prior to this point, any media that needs to be sent towards 1690 the caller (such as SIP early media [25] cannot be transmitted. For 1691 this reason, implementations SHOULD delay alerting the called party 1692 until candidates for each component of each media stream have entered 1693 the valid list. In the case of a PSTN gateway, this would mean that 1694 the setup message into the PSTN is delayed until this point. Doing 1695 this increases the post-dial delay, but has the effect of eliminating 1696 'ghost rings'. Ghost rings are cases where the called party hears 1697 the phone ring, picks up, but hears nothing and cannot be heard. 1698 This technique works without requiring support for, or usage of, 1699 preconditions [6], since its a localized decision. It also has the 1700 benefit of guaranteeing that not a single packet of media will get 1701 clipped, so that post-pickup delay is zero. If an agent chooses to 1702 delay local alerting in this way, it SHOULD generate a 180 response 1703 once alerting begins. 1705 Based on the rules in Section 11.1, the offerer will not be able to 1706 send media until the highest priority valid candidates match the m/c- 1707 line. When used with SIP, if the initial offer is sent in the 1708 INVITE, and the answer is sent in both the provisional and final 200 1709 OK response, the offerer will generally not be able to send media 1710 until it sends a re-INVITE and receives the 200 OK response to that 1711 re-INVITE. This can take several hundred milliseconds. If this 1712 latency is an issue (it is generally not considered an issue for 1713 voice systems), reliable provisional responses [9] MAY be used, in 1714 which case an UPDATE [24] can be used to send an updated offer prior 1715 to the call being answered. 1717 As discussed in Section 15, offer/answer exchanges SHOULD be secured 1718 against eavesdropping and man-in-the-middle attacks. To do that, the 1719 usage of SIPS [3] is RECOMMENDED when used in concert with ICE. 1721 12.2. Interactions with Forking 1723 ICE interacts very well with forking. Indeed, ICE fixes some of the 1724 problems associated with forking. Without ICE, when a call forks and 1725 the caller receives multiple incoming media streams, it cannot 1726 determine which media stream corresponds to which callee. 1728 With ICE, this problem is resolved. The connectivity checks which 1729 occur prior to transmission of media carry username fragments, which 1730 in turn are correlated to a specific callee. Subsequent media 1731 packets which arrive on the same 5-tuple as the connectivity check 1732 will be associated with that same callee. Thus, the caller can 1733 perform this correlation as long as it has received an answer. 1735 12.3. Interactions with Preconditions 1737 Quality of Service (QoS) preconditions, which are defined in RFC 3312 1738 [6] and RFC 4032 [7], apply only to the transport addresses listed in 1739 the m/c lines in an offer/answer. If ICE changes the transport 1740 address where media is received, this change is reflected in the m/c 1741 lines of a new offer/answer. As such, it appears like any other re- 1742 INVITE would, and is fully treated in RFC 3312 and 4032, which apply 1743 without regard to the fact that the m/c lines are changing due to ICE 1744 negotiations ocurring "in the background". 1746 Indeed, an agent SHOULD NOT indicate that Qos preconditions have been 1747 met until the ICE checks have completed and selected the candidate 1748 pairs to be used for media. 1750 ICE also has (purposeful) interactions with connectivity 1751 preconditions [26]. Those interactions are described there. Note 1752 that the procedures described in Section 12.1 describe their own type 1753 of "preconditions", albeit with less functionality than those 1754 provided by the explicit preconditions in [26]. 1756 12.4. Interactions with Third Party Call Control 1758 ICE works with Flows I and IV as described in [16]. Flow I works 1759 without the controller supporting or being aware of ICE. Flow IV 1760 will work as long as the controller passes along the ICE attributes 1761 without alteration. Flow III may disrupt ICE processing, since it 1762 will distort the stream ID values used in the computation of 1763 priorities. When there is but a single media stream, Flow III will 1764 work as long as the controller passes through the ICE attributes 1765 unmodified. Flow II is fundamentally incompatible with ICE; each 1766 agent will believe itself to be the answerer and thus never generate 1767 a re-INVITE. 1769 OPEN ISSUE: Its really too bad flow III doesn't work with 1770 multimedia; should consider ways to make it work. There are 1771 several ways. 1773 The flows for continued operation, as described in Section 7 of RFC 1774 3725, require additional behavior of ICE implementations to support. 1775 In particular, if an agent receives a mid-dialog re-INVITE that 1776 contains no offer, it MUST go through the process of gathering 1777 candidates, prioritizing them and generating an offer, as if this was 1778 an initial offer for a session. Furthermore, that list of candidates 1779 SHOULD include the ones currently in-use. 1781 13. Grammar 1783 This specification defines four new SDP attributes - the "candidate", 1784 "remote-candidates", "ice-ufrag" and "ice-pwd" attributes. 1786 The candidate attribute is a media-level attribute only. It contains 1787 a transport address for a candidate that can be used for connectivity 1788 checks. 1790 The syntax of this attribute is defined using Augmented BNF as 1791 defined in RFC 4234 [8]: 1793 candidate-attribute = "candidate" ":" foundation SP component-id SP 1794 transport SP 1795 priority SP 1796 connection-address SP ;from RFC 4566 1797 port ;port from RFC 4566 1798 [SP cand-type] 1799 [SP rel-addr] 1800 [SP rel-port] 1801 *(SP extension-att-name SP 1802 extension-att-value) 1804 foundation = 1*ice-char 1805 component-id = 1*DIGIT 1806 transport = "UDP" / transport-extension 1807 transport-extension = token ; from RFC 3261 1808 priority = 1*DIGIT 1809 cand-type = "typ" SP candidate-types 1810 candidate-types = "host" / "srflx" / "prflx" / "relay" / token 1811 rel-addr = "raddr" SP connection-address 1812 rel-port = "rport" SP port 1813 extension-att-name = byte-string ;from RFC 4566 1814 extension-att-value = byte-string 1815 ice-char = ALPHA / DIGIT / "+" / "/" 1817 The foundation is composed of one or more ice-char. The component-id 1818 is a positive integer, which identifies the specific component for 1819 which the transport address is a candidate. It MUST start at 1 and 1820 MUST increment by 1 for each component of a particular candidate. 1821 The connect-address production is taken from RFC 4566 [10], allowing 1822 for IPv4 addresses, IPv6 addresses and FQDNs. The port production is 1823 also taken from RFC 4566 [10]. The token production is taken from 1824 RFC 3261 [3]. The transport production indicates the transport 1825 protocol for the candidate. This specification only defines UDP. 1826 However, extensibility is provided to allow for future transport 1827 protocols to be used with ICE, such as TCP or the Datagram Congestion 1828 Control Protocol (DCCP) [28]. 1830 The cand-type production encodes the type of candidate. This 1831 specification defines the values "host", "srflx", "prflx" and "relay" 1832 for host, server reflexive, peer reflexive and relayed candidates, 1833 respectively. The set of candidate types is extensible for the 1834 future. Inclusion of the candidate type is optional. The rel-addr 1835 and rel-port productions convey information the related transport 1836 addresses. Rules for inclusion of these values is described in 1837 Section 4.4. 1839 The a=candidate attribute can itself be extended. The grammar allows 1840 for new name/value pairs to be added at the end of the attribute. An 1841 implementation MUST ignore any name/value pairs it doesn't 1842 understand. 1844 The syntax of the "remote-candidates" attribute is defined using 1845 Augmented BNF as defined in RFC 4234 [8]. The remote-candidates 1846 attribute is a media level attribute only. 1848 remote-candidate-att = "remote-candidates" ":" remote-candidate 1849 0*(SP remote-candidate) 1850 remote-candidate = component-ID SP connection-address SP port 1852 The attribute contains a connection-address and port for each 1853 component. The ordering of components is irrelevant. However, a 1854 value MUST be present for each component of a media stream. 1856 The syntax of the "ice-pwd" and "ice-ufrag" attributes are defined 1857 as: 1859 ice-pwd-att = "ice-pwd" ":" password 1860 ice-ufrag-att = "ice-ufrag" ":" ufrag 1861 password = 22*ice-char 1862 ufrag = 4*ice-char 1864 The "ice-pwd" and "ice-ufrag" attributes can appear at either the 1865 session-level or media-level. When present in both, the value in the 1866 media-level takes precedence. Thus, the value at the session level 1867 is effectively a default that applies to all media streams, unless 1868 overriden by a media-level value. 1870 14. Example 1872 Two agents, L and R, are using ICE. Both agents have a single IPv4 1873 interface. For agent L, it is 10.0.1.1, and for agent R, 192.0.2.1. 1874 Both are configured with a single STUN server each (indeed, the same 1875 one for each), which is listening for STUN requests at an IP address 1876 of 192.0.2.2 and port 3478. This STUN server supports both the 1877 Binding Discovery usage and the Relay usage. Agent L is behind a 1878 NAT, and agent R is on the public Internet. The NAT has an endpoint 1879 independent mapping property and an address dependent filtering 1880 property. The public side of the NAT has an IP address of 192.0.2.3. 1882 To facilitate understanding, transport addresses are listed using 1883 variables that have mnemonic names. The format of the name is 1884 entity-type-seqno, where entity refers to the entity whose interface 1885 the transport address is on, and is one of "L", "R", "STUN", or 1886 "NAT". The type is either "PUB" for transport addresses that are 1887 public, and "PRIV" for transport addresses that are private. 1888 Finally, seq-no is a sequence number that is different for each 1889 transport address of the same type on a particular entity. Each 1890 variable has an IP address and port, denoted by varname.IP and 1891 varname.PORT, respectively, where varname is the name of the 1892 variable. 1894 The STUN server has advertised transport address STUN-PUB-1 (which is 1895 192.0.2.2:3478) for both the binding discovery usage and the relay 1896 usage. However, neither agent is using the relay usage. 1898 In the call flow itself, STUN messages are annotated with several 1899 attributes. The "S=" attribute indicates the source transport 1900 address of the message. The "D=" attribute indicates the destination 1901 transport address of the message. The "MA=" attribute is used in 1902 STUN Binding Response messages and refers to the mapped address. 1904 The call flow examples omit STUN authentication operations and RTCP, 1905 and focus on RTP for a single media stream. 1907 L NAT STUN R 1908 |RTP STUN alloc. | | 1909 |(1) STUN Req | | | 1910 |S=$L-PRIV-1 | | | 1911 |D=$STUN-PUB-1 | | | 1912 |------------->| | | 1913 | |(2) STUN Req | | 1914 | |S=$NAT-PUB-1 | | 1915 | |D=$STUN-PUB-1 | | 1916 | |------------->| | 1917 | |(3) STUN Res | | 1918 | |S=$STUN-PUB-1 | | 1919 | |D=$NAT-PUB-1 | | 1920 | |MA=$NAT-PUB-1 | | 1921 | |<-------------| | 1922 |(4) STUN Res | | | 1923 |S=$STUN-PUB-1 | | | 1924 |D=$L-PRIV-1 | | | 1925 |MA=$NAT-PUB-1 | | | 1926 |<-------------| | | 1927 |(5) Offer | | | 1928 |------------------------------------------->| 1929 | | | |RTP STUN alloc. 1930 | | |(6) STUN Req | 1931 | | |S=$R-PUB-1 | 1932 | | |D=$STUN-PUB-1 | 1933 | | |<-------------| 1934 | | |(7) STUN Res | 1935 | | |S=$STUN-PUB-1 | 1936 | | |D=$R-PUB-1 | 1937 | | |MA=$R-PUB-1 | 1938 | | |------------->| 1939 |(8) answer | | | 1940 |<-------------------------------------------| 1941 | |(9) Bind Req | | 1942 | |S=$R-PUB-1 | | 1943 | |D=L-PRIV-1 | | 1944 | |<----------------------------| 1945 | |Dropped | | 1946 |(10) Bind Req | | | 1947 |S=$L-PRIV-1 | | | 1948 |D=$R-PUB-1 | | | 1949 |------------->| | | 1950 | |(11) Bind Req | | 1951 | |S=$NAT-PUB-1 | | 1952 | |D=$R-PUB-1 | | 1953 | |---------------------------->| 1954 | |(12) Bind Res | | 1955 | |S=$R-PUB-1 | | 1956 | |D=$NAT-PUB-1 | | 1957 | |MA=$NAT-PUB-1 | | 1958 | |<----------------------------| 1959 |(13) Bind Res | | | 1960 |S=$R-PUB-1 | | | 1961 |D=$L-PRIV-1 | | | 1962 |MA=$NAT-PUB-1 | | | 1963 |<-------------| | | 1964 |(14) Offer | | | 1965 |------------------------------------------->| 1966 |(15) Answer | | | 1967 |<-------------------------------------------| 1968 | |(16) Bind Req | | 1969 | |S=$R-PUB-1 | | 1970 | |D=$NAT-PUB-1 | | 1971 | |<----------------------------| 1972 |(17) Bind Req | | | 1973 |S=$R-PUB-1 | | | 1974 |D=$L-PRIV-1 | | | 1975 |<-------------| | | 1976 |(18) Bind Res | | | 1977 |S=$L-PRIV-1 | | | 1978 |D=$R-PUB-1 | | | 1979 |MA=$R-PUB-1 | | | 1980 |------------->| | | 1981 | |(19) Bind Res | | 1982 | |S=$NAT-PUB-1 | | 1983 | |D=$R-PUB-1 | | 1984 | |MA=$R-PUB-1 | | 1985 | |---------------------------->| 1986 |RTP flows | | | 1988 Figure 9 1990 First, agent L obtains a host candidate from its local interface (not 1991 shown), and from that, sends a STUN Binding Request to the STUN 1992 server to get a server reflexive candidate (messages 1-4). Recall 1993 that the NAT has the address and port independent mapping property. 1994 Here, it creates a binding of NAT-PUB-1 for this UDP request, and 1995 this becomes the server reflexive candidate for RTP. 1997 Agent L sets a type preference of 126 for the host candidate and 100 1998 for the server reflexive. The local preference is 65535. Based on 1999 this, the priority of the host candidate is 2130706178 and for the 2000 server reflexive candidate is 1694498562. The host candidate is 2001 assigned a foundation of 1, and the server reflexive, a foundation of 2002 2. It chooses its server reflexive candidate as the in-use 2003 candidate, and encodes it into the m/c-line. The resulting offer 2004 (message 5) looks like (lines folded for clarity): 2006 v=0 2007 o=jdoe 2890844526 2890842807 IN IP4 $L-PRIV-1.IP 2008 s= 2009 c=IN IP4 $NAT-PUB-1.IP 2010 t=0 0 2011 a=ice-pwd:asd88fgpdd777uzjYhagZg 2012 a=ice-ufrag:8hhY 2013 m=audio $NAT-PUB-1.PORT RTP/AVP 0 2014 a=rtpmap:0 PCMU/8000 2015 a=candidate:1 1 UDP 2130706178 $L-PRIV-1.IP $L-PRIV-1.PORT typ local 2016 a=candidate:2 1 UDP 1694498562 $NAT-PUB-1.IP $NAT-PUB-1.PORT typ srflx raddr 2017 $L-PRIV-1.IP rport $L-PRIV-1.PORT 2019 The offer, with the variables replaced with their values, will look 2020 like (lines folded for clarity): 2022 v=0 2023 o=jdoe 2890844526 2890842807 IN IP4 10.0.1.1 2024 s= 2025 c=IN IP4 192.0.2.3 2026 t=0 0 2027 a=ice-pwd:asd88fgpdd777uzjYhagZg 2028 a=ice-ufrag:8hhY 2029 m=audio 45664 RTP/AVP 0 2030 a=rtpmap:0 PCMU/8000 2031 a=candidate:1 1 UDP 2130706178 10.0.1.1 8998 typ local 2032 a=candidate:2 1 UDP 1694498562 192.0.2.3 45664 typ srflx raddr 2033 10.0.1.1 rport 8998 2035 This offer is received at agent R. Agent R will obtain a host 2036 candidate, and from it, obtain a server reflexive candidate (messages 2037 6-7). Since R is not behind a NAT, this candidate is identical to 2038 its host candidate, and they share the same base. It therefore 2039 discards this candidate and ends up with a single host candidate. 2040 With identical type and local preferences as L, the priority for this 2041 candidate is 2130706178. It chooses a foundation of 1 for its single 2042 candidate. Its resulting answer looks like: 2044 v=0 2045 o=bob 2808844564 2808844564 IN IP4 $R-PUB-1.IP 2046 s= 2047 c=IN IP4 $R-PUB-1.IP 2048 t=0 0 2049 a=ice-pwd:YH75Fviy6338Vbrhrlp8Yh 2050 a=ice-ufrag:9uB6 2051 m=audio $R-PUB-1.PORT RTP/AVP 0 2052 a=rtpmap:0 PCMU/8000 2053 a=candidate:1 1 UDP 2130706178 $R-PUB-1.IP $R-PUB-1.PORT typ local 2055 With the variables filled in: 2057 v=0 2058 o=bob 2808844564 2808844564 IN IP4 192.0.2.1 2059 s= 2060 c=IN IP4 192.0.2.1 2061 t=0 0 2062 a=ice-pwd:YH75Fviy6338Vbrhrlp8Yh 2063 a=ice-ufrag:9uB6 2064 m=audio 3478 RTP/AVP 0 2065 a=rtpmap:0 PCMU/8000 2066 a=candidate:1 1 UDP 2130706178 192.0.2.1 3478 typ local 2068 Agents L and R both pair up the candidates. They both initially have 2069 two. However, agent L will prune the pair containing its server 2070 reflexive candidate, resulting in just one. At agent L, this pair 2071 (the check) has a local candidate of $L_PRIV_1 and remote candidate 2072 of $R_PUB_1, and has a candidate pair priority of 4.57566E+18 (note 2073 that an implementation would represent this as a 64 bit integer so as 2074 not to lose precision). At agent R, there are two checks. The 2075 highest priority has a local candidate of $R_PUB_1 and remote 2076 candidate of $L_PRIV_1 and has a priority of 4.57566E+18, and the 2077 second has a local candidate of $R_PUB_1 and remote candidate of 2078 $NAT_PUB_1 and priority 3.63891E+18. 2080 Agent R begins its connectivity check (message 9) for the first pair 2081 (between the two host candidates). The host candidate from agent L 2082 is private and behind a different NAT, and thus this check is 2083 discarded. 2085 When agent L gets the answer, it performs its one and only 2086 connectivity check (messages 10-13). This will succeed. This causes 2087 agent L to create a new pair, whos local candidate is from the mapped 2088 address in the binding response (NAT-PUB-1 from message 13) and whose 2089 remote candidate is the destination of the request (R-PUB-1 from 2090 message 10). This is added to the valid list. At this point, agent 2091 L examines the valid list and sees that there is a candidate there 2092 for each component of each media stream (which is just RTP for the 2093 single audio stream). It therefore considers ICE checks complete and 2094 sends an updated offer (message 14). This offer serves only to 2095 remove the candidate that was not selected and indicate the remote 2096 candidates; the m/c-line remains unchanged. This offer looks like: 2098 v=0 2099 o=jdoe 2890844528 2890842809 IN IP4 10.0.1.1 2100 s= 2101 c=IN IP4 192.0.2.3 2102 t=0 0 2103 a=ice-pwd:asd88fgpdd777uzjYhagZg 2104 a=ice-ufrag:8hhY 2105 m=audio 45664 RTP/AVP 0 2106 a=remote-candidates 1 192.0.2.1 3478 2107 a=rtpmap:0 PCMU/8000 2108 a=candidate:2 1 UDP 1694498562 192.0.2.3 45664 typ srflx raddr 2109 10.0.1.1 rport 8998 2111 Agent R can construct the answer. Since the remote-candidates listed 2112 in the offer match the ones that agent R had already selected for the 2113 m/c-line in the previous answer, there is no change there. Its 2114 answer therefore looks like: 2116 v=0 2117 o=bob 2808844565 2808844566 IN IP4 192.0.2.1 2118 s= 2119 c=IN IP4 192.0.2.1 2120 t=0 0 2121 a=ice-pwd:YH75Fviy6338Vbrhrlp8Yh 2122 a=ice-ufrag:9uB6 2123 m=audio 3478 RTP/AVP 0 2124 a=rtpmap:0 PCMU/8000 2125 a=candidate:1 1 UDP 2130706178 192.0.2.1 3478 typ local 2127 Upon receipt of the check from agent L (message 11), agent R will 2128 generate its triggered check. This check happens to match the next 2129 one on its check list - from its host candidate to agent L's server 2130 reflexive candidate. This check (messages 16-19) will succeed. 2131 Consequently, agent R constructs a new candidate pair using the 2132 mapped address from the response as the local candidate (R-PUB-1) and 2133 the destination of the request (NAT-PUB-1) as the remote candidate. 2134 This pair is added to the valid list. Since this pair matches the 2135 pair in the m/c-lines, agent R can send media as well. 2137 15. Security Considerations 2139 There are several types of attacks possible in an ICE system. This 2140 section considers these attacks and their countermeasures. 2142 15.1. Attacks on Connectivity Checks 2144 An attacker might attempt to disrupt the STUN connectivity checks. 2145 Ultimately, all of these attacks fool an agent into thinking 2146 something incorrect about the results of the connectivity checks. 2147 The possible false conclusions an attacker can try and cause are: 2149 False Invalid: An attacker can fool a pair of agents into thinking a 2150 candidate pair is invalid, when it isn't. This can be used to 2151 cause an agent to prefer a different candidate (such as one 2152 injected by the attacker), or to disrupt a call by forcing all 2153 candidates to fail. 2155 False Valid: An attacker can fool a pair of agents into thinking a 2156 candidate pair is valid, when it isn't. This can cause an agent 2157 to proceed with a session, but then not be able to receive any 2158 media. 2160 False Peer-Reflexive Candidate: An attacker can cause an agent to 2161 discover a new peer reflexive candidate, when it shouldn't have. 2162 This can be used to redirect media streams to a DoS target or to 2163 the attacker, for eavesdropping or other purposes. 2165 False Valid on False Candidate: An attacker has already convinced an 2166 agent that there is a candidate with an address that doesn't 2167 actually route to that agent (for example, by injecting a false 2168 peer reflexive candidate or false server reflexive candidate). It 2169 must then launch an attack that forces the agents to believe that 2170 this candidate is valid. 2172 Of the various techniques for creating faked STUN messages described 2173 in [11], many are not applicable for the connectivity checks. 2174 Compromises of STUN servers are not much of a concern, since the STUN 2175 servers are embedded in endpoints and distributed throughout the 2176 network. Thus, compromising the STUN server is equivalent to 2177 comprimising the endpoint, and if that happens, far more problematic 2178 attacks are possible than those against ICE. Similarly, DNS attacks 2179 are usually irrelevant since STUN servers are not typically 2180 discovered via DNS, they are signaled via IP addresses embedded in 2181 SDP. Injection of fake responses and relaying modified requests all 2182 can be handled in ICE with the countermeasures discussed below. 2184 To force the false invalid result, the attacker has to wait for the 2185 connectivity check from one of the agents to be sent. When it is, 2186 the attacker needs to inject a fake response with an unrecoverable 2187 error response, such as a 600. However, since the candidate is, in 2188 fact, valid, the original request may reach the peer agent, and 2189 result in a success response. The attacker needs to force this 2190 packet or its response to be dropped, through a DoS attack, layer 2 2191 network disruption, or other technique. If it doesn't do this, the 2192 success response will also reach the originator, alerting it to a 2193 possible attack. Fortunately, this attack is mitigated completely 2194 through the STUN message integrity mechanism. The attacker needs to 2195 inject a fake response, and in order for this response to be 2196 processed, the attacker needs the password. If the offer/answer 2197 signaling is secured, the attacker will not have the password. 2199 Forcing the fake valid result works in a similar way. The agent 2200 needs to wait for the Binding Request from each agent, and inject a 2201 fake success response. The attacker won't need to worry about 2202 disrupting the actual response since, if the candidate is not valid, 2203 it presumably wouldn't be received anyway. However, like the fake 2204 invalid attack, this attack is mitigated completely through the STUN 2205 message integrity and offer/answer security techniques. 2207 Forcing the false peer reflexive candidate result can be done either 2208 with fake requests or responses, or with replays. We consider the 2209 fake requests and responses case first. It requires the attacker to 2210 send a Binding Request to one agent with a source IP address and port 2211 for the false candidate. In addition, the attacker must wait for a 2212 Binding Request from the other agent, and generate a fake response 2213 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 2214 Like the other attacks described here, this attack is mitigated by 2215 the STUN message integrity mechanisms and secure offer/answer 2216 exchanges. 2218 Forcing the false peer reflexive candidate result with packet replays 2219 is different. The attacker waits until one of the agents sends a 2220 check. It intercepts this request, and replays it towards the other 2221 agent with a faked source IP address. It must also prevent the 2222 original request from reaching the remote agent, either by launching 2223 a DoS attack to cause the packet to be dropped, or forcing it to be 2224 dropped using layer 2 mechanisms. The replayed packet is received at 2225 the other agent, and accepted, since the integrity check passes (the 2226 integrity check cannot and does not cover the source IP address and 2227 port). It is then responded to. This response will contain a XOR- 2228 MAPPED-ADDRESS with the false candidate, and will be sent to that 2229 false candidate. The attacker must then intercept it and relay it 2230 towards the originator. 2232 The other agent will then initiate a connectivity check towards that 2233 false candidate. This validation needs to succeed. This requires 2234 the attacker to force a false valid on a false candidate. Injecting 2235 of fake requests or responses to achieve this goal is prevented using 2236 the integrity mechanisms of STUN and the offer/answer exchange. 2237 Thus, this attack can only be launched through replays. To do that, 2238 the attacker must intercept the check towards this false candidate, 2239 and replay it towards the other agent. Then, it must intercept the 2240 response and replay that back as well. 2242 This attack is very hard to launch unless the attacker themself is 2243 identified by the fake candidate. This is because it requires the 2244 attacker to intercept and replay packets sent by two different hosts. 2245 If both agents are on different networks (for example, across the 2246 public Internet), this attack can be hard to coordinate, since it 2247 needs to occur against two different endpoints on different parts of 2248 the network at the same time. 2250 If the attacker themself is identified by the fake candidate the 2251 attack is easier to coordinate. However, if SRTP is used [21], the 2252 attacker will not be able to play the media packets, they will only 2253 be able to discard them, effectively disabling the media stream for 2254 the call. However, this attack requires the agent to disrupt packets 2255 in order to block the connectivity check from reaching the target. 2257 In that case, if the goal is to disrupt the media stream, its much 2258 easier to just disrupt it with the same mechanism, rather than attack 2259 ICE. 2261 15.2. Attacks on Address Gathering 2263 ICE endpoints make use of STUN for gathering candidates rom a STUN 2264 server in the network. This is corresponds to the Binding Discovery 2265 usage of STUN described in [11]. As a consequence, the attacks 2266 against STUN itself that are described in that specification can 2267 still be used against the binding discovery usage when utilized with 2268 ICE. 2270 However, the additional mechanisms provided by ICE actually 2271 counteract such attacks, making binding discovery with STUN more 2272 secure when combined with ICE than without ICE. 2274 Consider an attacker which is able to provide an agent with a faked 2275 mapped address in a STUN Binding Request that is used for address 2276 gathering. This is the primary attack primitive described in [11]. 2277 This address will be used as a server reflexive candidate in the ICE 2278 exchange. For this candidate to actually be used for media, the 2279 attacker must also attack the connectivity checks, and in particular, 2280 force a false valid on a false candidate. This attack is very hard 2281 to launch if the false address identifies a third party, and is 2282 prevented by SRTP if it identifies the attacker themself. 2284 If the attacker elects not to attack the connectivity checks, the 2285 worst it can do is prevent the server reflexive candidate from being 2286 used. However, if the peer agent has at least one candidate that is 2287 reachable by the agent under attack, the STUN connectivity checks 2288 themselves will provide a peer reflexive candidate that can be used 2289 for the exchange of media. Peer reflexive candidates are generally 2290 preferred over server reflexive candidates. As such, an attack 2291 solely on the STUN address gathering will normally have no impact on 2292 a session at all. 2294 15.3. Attacks on the Offer/Answer Exchanges 2296 An attacker that can modify or disrupt the offer/answer exchanges 2297 themselves can readily launch a variety of attacks with ICE. They 2298 could direct media to a target of a DoS attack, they could insert 2299 themselves into the media stream, and so on. These are similar to 2300 the general security considerations for offer/answer exchanges, and 2301 the security considerations in RFC 3264 [4] apply. These require 2302 techniques for message integrity and encryption for offers and 2303 answers, which are satisfied by the SIPS mechanism [3] when SIP is 2304 used. As such, the usage of SIPS with ICE is RECOMMENDED. 2306 15.4. Insider Attacks 2308 In addition to attacks where the attacker is a third party trying to 2309 insert fake offers, answers or stun messages, there are several 2310 attacks possible with ICE when the attacker is an authenticated and 2311 valid participant in the ICE exchange. 2313 15.4.1. The Voice Hammer Attack 2315 The voice hammer attack is an amplification attack. In this attack, 2316 the attacker initiates sessions to other agents, and includes the IP 2317 address and port of a DoS target in the m/c-line of their SDP. This 2318 causes substantial amplification; a single offer/answer exchange can 2319 create a continuing flood of media packets, possibly at high rates 2320 (consider video sources). This attack is not specific to ICE, but 2321 ICE can help provide remediation. 2323 Specifically, if ICE is used, the agent receiving the malicious SDP 2324 will first peform connectivity checks to the target of media before 2325 sending it there. If this target is a third party host, the checks 2326 will not succeed, and media is never sent. 2328 Unfortunately, ICE doesn't help if its not used, in which case an 2329 attacker could simply send the offer without the ICE parameters. 2330 However, in environments where the set of clients are known, and 2331 limited to ones that support ICE, the server can reject any offers or 2332 answers that don't indicate ICE support. 2334 15.4.2. STUN Amplification Attack 2336 The STUN amplification attack is similar to the voice hammer. 2337 However, instead of voice packets being directed to the target, STUN 2338 connectivity checks are directed to the target. This attack is 2339 accomplished by having the offerer send an offer with a large number 2340 of candidates, say 50. The answerer receives the offer, and starts 2341 its checks, which are directed at the target, and consequently, never 2342 generate a response. The answerer will start a new connectivity 2343 check every 50ms, and each check is a STUN transaction consisting of 2344 9 retransmits of a message 65 bytes in length (plus 28 bytes for the 2345 IP/UDP header) that runs for 7.9 seconds, for a total of 105 bytes/ 2346 second per transaction on average. In the worst case, there can be 2347 158 transactions in progress at once (7.9 seconds divided by 50ms), 2348 for a total of 132 kbps, just for STUN requests. 2350 It is impossible to eliminate the amplification, but the volume can 2351 be reduced through a variety of heuristics. For example, agents can 2352 limit the number of candidates they'll accept in an offer or answer, 2353 they can increase the value of Ta, or exponentially increase Ta as 2354 time goes on. All of these ultimately trade off the time for the ICE 2355 exchanges to complete, with the amount of traffic that gets sent. 2357 OPEN ISSUE: Need better remediation for this. Especially an issue 2358 if we reduce Ta to be as fast as media packets themselves, in 2359 which case this attack is as equally devastating as the voice 2360 hammer. 2362 16. IANA Considerations 2364 This specification defines four new SDP attributes per the procedures 2365 of Section 8.2.4 of [10]. The required information for the 2366 registrations are included here. 2368 16.1. candidate Attribute 2370 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2372 Attribute Name: candidate 2374 Long Form: candidate 2376 Type of Attribute: media level 2378 Charset Considerations: The attribute is not subject to the charset 2379 attribute. 2381 Purpose: This attribute is used with Interactive Connectivity 2382 Establishment (ICE), and provides one of many possible candidate 2383 addresses for communication. These addresses are validated with 2384 an end-to-end connectivity check using Simple Traversal Underneath 2385 NAT (STUN). 2387 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2388 please replace XXXX with the RFC number of this specification]. 2390 16.2. remote-candidates Attribute 2392 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2394 Attribute Name: remote-candidates 2396 Long Form: remote-candidates 2397 Type of Attribute: media level 2399 Charset Considerations: The attribute is not subject to the charset 2400 attribute. 2402 Purpose: This attribute is used with Interactive Connectivity 2403 Establishment (ICE), and provides the identity of the remote 2404 candidates that the offerer wishes the answerer to use in its 2405 answer. 2407 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2408 please replace XXXX with the RFC number of this specification]. 2410 16.3. ice-pwd Attribute 2412 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2414 Attribute Name: ice-pwd 2416 Long Form: ice-pwd 2418 Type of Attribute: session or media level 2420 Charset Considerations: The attribute is not subject to the charset 2421 attribute. 2423 Purpose: This attribute is used with Interactive Connectivity 2424 Establishment (ICE), and provides the password used to protect 2425 STUN connectivity checks. 2427 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2428 please replace XXXX with the RFC number of this specification]. 2430 16.4. ice-ufrag Attribute 2432 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2434 Attribute Name: ice-ufrag 2436 Long Form: ice-ufrag 2438 Type of Attribute: session or media level 2440 Charset Considerations: The attribute is not subject to the charset 2441 attribute. 2443 Purpose: This attribute is used with Interactive Connectivity 2444 Establishment (ICE), and provides the fragments used to construct 2445 the username in STUN connectivity checks. 2447 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2448 please replace XXXX with the RFC number of this specification]. 2450 17. IAB Considerations 2452 The IAB has studied the problem of "Unilateral Self Address Fixing", 2453 which is the general process by which a agent attempts to determine 2454 its address in another realm on the other side of a NAT through a 2455 collaborative protocol reflection mechanism [19]. ICE is an example 2456 of a protocol that performs this type of function. Interestingly, 2457 the process for ICE is not unilateral, but bilateral, and the 2458 difference has a signficant impact on the issues raised by IAB. 2459 Indeed, ICE can be considered a B-SAF (Bilateral Self-Address Fixing) 2460 protocol, rather than an UNSAF protocol. Regardless, the IAB has 2461 mandated that any protocols developed for this purpose document a 2462 specific set of considerations. This section meets those 2463 requirements. 2465 17.1. Problem Definition 2467 From RFC 3424 any UNSAF proposal must provide: 2469 Precise definition of a specific, limited-scope problem that is to 2470 be solved with the UNSAF proposal. A short term fix should not be 2471 generalized to solve other problems; this is why "short term fixes 2472 usually aren't". 2474 The specific problems being solved by ICE are: 2476 Provide a means for two peers to determine the set of transport 2477 addresses which can be used for communication. 2479 Provide a means for resolving many of the limitations of other 2480 UNSAF mechanisms by wrapping them in an additional layer of 2481 processing (the ICE methodology). 2483 Provide a means for a agent to determine an address that is 2484 reachable by another peer with which it wishes to communicate. 2486 17.2. Exit Strategy 2488 From RFC 3424, any UNSAF proposal must provide: 2490 Description of an exit strategy/transition plan. The better short 2491 term fixes are the ones that will naturally see less and less use 2492 as the appropriate technology is deployed. 2494 ICE itself doesn't easily get phased out. However, it is useful even 2495 in a globally connected Internet, to serve as a means for detecting 2496 whether a router failure has temporarily disrupted connectivity, for 2497 example. ICE also helps prevent certain security attacks which have 2498 nothing to do with NAT. However, what ICE does is help phase out 2499 other UNSAF mechanisms. ICE effectively selects amongst those 2500 mechanisms, prioritizing ones that are better, and deprioritizing 2501 ones that are worse. Local IPv6 addresses can be preferred. As NATs 2502 begin to dissipate as IPv6 is introduced, server reflexive and 2503 relayed candidates (both forms of UNSAF mechanisms) simply never get 2504 used, because higher priority connectivity exists to the native host 2505 candidates. Therefore, the servers get used less and less, and can 2506 eventually be remove when their usage goes to zero. 2508 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 2509 be used to determine whether to use IPv6 or IPv4 when two dual-stack 2510 hosts communicate with SIP (IPv6 gets used). It can also allow a 2511 network with both 6to4 and native v6 connectivity to determine which 2512 address to use when communicating with a peer. 2514 17.3. Brittleness Introduced by ICE 2516 From RFC3424, any UNSAF proposal must provide: 2518 Discussion of specific issues that may render systems more 2519 "brittle". For example, approaches that involve using data at 2520 multiple network layers create more dependencies, increase 2521 debugging challenges, and make it harder to transition. 2523 ICE actually removes brittleness from existing UNSAF mechanisms. In 2524 particular, traditional STUN (as described in RFC 3489 [13]) has 2525 several points of brittleness. One of them is the discovery process 2526 which requires a agent to try and classify the type of NAT it is 2527 behind. This process is error-prone. With ICE, that discovery 2528 process is simply not used. Rather than unilaterally assessing the 2529 validity of the address, its validity is dynamically determined by 2530 measuring connectivity to a peer. The process of determining 2531 connectivity is very robust. 2533 Another point of brittleness in traditional STUN and any other 2534 unilateral mechanism is its absolute reliance on an additional 2535 server. ICE makes use of a server for allocating unilateral 2536 addresses, but allows agents to directly connect if possible. 2537 Therefore, in some cases, the failure of a STUN server would still 2538 allow for a call to progress when ICE is used. 2540 Another point of brittleness in traditional STUN is that it assumes 2541 that the STUN server is on the public Internet. Interestingly, with 2542 ICE, that is not necessary. There can be a multitude of STUN servers 2543 in a variety of address realms. ICE will discover the one that has 2544 provided a usable address. 2546 The most troubling point of brittleness in traditional STUN is that 2547 it doesn't work in all network topologies. In cases where there is a 2548 shared NAT between each agent and the STUN server, traditional STUN 2549 may not work. With ICE, that restriction is removed. 2551 Traditional STUN also introduces some security considerations. 2552 Fortunately, those security considerations are also mitigated by ICE. 2554 Consequently, ICE serves to repair the brittleness introduced in 2555 other UNSAF mechanisms, and does not introduce any additional 2556 brittleness into the system. 2558 17.4. Requirements for a Long Term Solution 2560 From RFC 3424, any UNSAF proposal must provide: 2562 Identify requirements for longer term, sound technical solutions 2563 -- contribute to the process of finding the right longer term 2564 solution. 2566 Our conclusions from STUN remain unchanged. However, we feel ICE 2567 actually helps because we believe it can be part of the long term 2568 solution. 2570 17.5. Issues with Existing NAPT Boxes 2572 From RFC 3424, any UNSAF proposal must provide: 2574 Discussion of the impact of the noted practical issues with 2575 existing, deployed NA[P]Ts and experience reports. 2577 A number of NAT boxes are now being deployed into the market which 2578 try and provide "generic" ALG functionality. These generic ALGs hunt 2579 for IP addresses, either in text or binary form within a packet, and 2580 rewrite them if they match a binding. This interferes with 2581 traditional STUN. However, the update to STUN [11] uses an encoding 2582 which hides these binary addresses from generic ALGs. Since [11] is 2583 required for all ICE implementations, this NAPT problem does not 2584 impact ICE. 2586 Existing NAPT boxes have non-deterministic and typically short 2587 expiration times for UDP-based bindings. This requires 2588 implementations to send periodic keepalives to maintain those 2589 bindings. ICE uses a default of 15s, which is a very conservative 2590 estimate. Eventually, over time, as NAT boxes become compliant to 2591 behave [30], this minimum keepalive will become deterministic and 2592 well-known, and the ICE timers can be adjusted. Having a way to 2593 discover and control the minimum keepalive interval would be far 2594 better still. 2596 18. Acknowledgements 2598 The authors would like to thank Flemming Andreasen, Rohan Mahy, Dean 2599 Willis, Eric Cooper, Dan Wing, Douglas Otis, Tim Moore, and Francois 2600 Audet for their comments and input. A special thanks goes to Bill 2601 May, who suggested several of the concepts in this specification, 2602 Philip Matthews, who suggested many of the key performance 2603 optimizations in this specification, Eric Rescorla, who drafted the 2604 text in the introduction, and Magnus Westerlund, for doing several 2605 detailed reviews on the various revisions of this specification. 2607 19. References 2609 19.1. Normative References 2611 [1] Bradner, S., "Key words for use in RFCs to Indicate Requirement 2612 Levels", BCP 14, RFC 2119, March 1997. 2614 [2] Huitema, C., "Real Time Control Protocol (RTCP) attribute in 2615 Session Description Protocol (SDP)", RFC 3605, October 2003. 2617 [3] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, A., 2618 Peterson, J., Sparks, R., Handley, M., and E. Schooler, "SIP: 2619 Session Initiation Protocol", RFC 3261, June 2002. 2621 [4] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model with 2622 Session Description Protocol (SDP)", RFC 3264, June 2002. 2624 [5] Casner, S., "Session Description Protocol (SDP) Bandwidth 2625 Modifiers for RTP Control Protocol (RTCP) Bandwidth", RFC 3556, 2626 July 2003. 2628 [6] Camarillo, G., Marshall, W., and J. Rosenberg, "Integration of 2629 Resource Management and Session Initiation Protocol (SIP)", 2630 RFC 3312, October 2002. 2632 [7] Camarillo, G. and P. Kyzivat, "Update to the Session Initiation 2633 Protocol (SIP) Preconditions Framework", RFC 4032, March 2005. 2635 [8] Crocker, D. and P. Overell, "Augmented BNF for Syntax 2636 Specifications: ABNF", RFC 4234, October 2005. 2638 [9] Rosenberg, J. and H. Schulzrinne, "Reliability of Provisional 2639 Responses in Session Initiation Protocol (SIP)", RFC 3262, 2640 June 2002. 2642 [10] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 2643 Description Protocol", RFC 4566, July 2006. 2645 [11] Rosenberg, J., "Simple Traversal Underneath Network Address 2646 Translators (NAT) (STUN)", draft-ietf-behave-rfc3489bis-04 2647 (work in progress), July 2006. 2649 [12] Rosenberg, J., "Obtaining Relay Addresses from Simple Traversal 2650 of UDP Through NAT (STUN)", draft-ietf-behave-turn-01 (work in 2651 progress), June 2006. 2653 19.2. Informative References 2655 [13] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, "STUN 2656 - Simple Traversal of User Datagram Protocol (UDP) Through 2657 Network Address Translators (NATs)", RFC 3489, March 2003. 2659 [14] Senie, D., "Network Address Translator (NAT)-Friendly 2660 Application Design Guidelines", RFC 3235, January 2002. 2662 [15] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and A. 2663 Rayhan, "Middlebox communication architecture and framework", 2664 RFC 3303, August 2002. 2666 [16] Rosenberg, J., Peterson, J., Schulzrinne, H., and G. Camarillo, 2667 "Best Current Practices for Third Party Call Control (3pcc) in 2668 the Session Initiation Protocol (SIP)", BCP 85, RFC 3725, 2669 April 2004. 2671 [17] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, "Realm 2672 Specific IP: Framework", RFC 3102, October 2001. 2674 [18] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, "Realm 2675 Specific IP: Protocol Specification", RFC 3103, October 2001. 2677 [19] Daigle, L. and IAB, "IAB Considerations for UNilateral Self- 2678 Address Fixing (UNSAF) Across Network Address Translation", 2679 RFC 3424, November 2002. 2681 [20] Schulzrinne, H., Casner, S., Frederick, R., and V. Jacobson, 2682 "RTP: A Transport Protocol for Real-Time Applications", 2683 RFC 3550, July 2003. 2685 [21] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 2686 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 2687 RFC 3711, March 2004. 2689 [22] Carpenter, B. and K. Moore, "Connection of IPv6 Domains via 2690 IPv4 Clouds", RFC 3056, February 2001. 2692 [23] Zopf, R., "Real-time Transport Protocol (RTP) Payload for 2693 Comfort Noise (CN)", RFC 3389, September 2002. 2695 [24] Rosenberg, J., "The Session Initiation Protocol (SIP) UPDATE 2696 Method", RFC 3311, October 2002. 2698 [25] Camarillo, G. and H. Schulzrinne, "Early Media and Ringing Tone 2699 Generation in the Session Initiation Protocol (SIP)", RFC 3960, 2700 December 2004. 2702 [26] Andreasen, F., "Connectivity Preconditions for Session 2703 Description Protocol Media Streams", 2704 draft-ietf-mmusic-connectivity-precon-02 (work in progress), 2705 June 2006. 2707 [27] Andreasen, F., "A No-Op Payload Format for RTP", 2708 draft-ietf-avt-rtp-no-op-00 (work in progress), May 2005. 2710 [28] Kohler, E., Handley, M., and S. Floyd, "Datagram Congestion 2711 Control Protocol (DCCP)", RFC 4340, March 2006. 2713 [29] Hellstrom, G. and P. Jones, "RTP Payload for Text 2714 Conversation", RFC 4103, June 2005. 2716 [30] Audet, F. and C. Jennings, "NAT Behavioral Requirements for 2717 Unicast UDP", draft-ietf-behave-nat-udp-07 (work in progress), 2718 June 2006. 2720 [31] Jennings, C. and R. Mahy, "Managing Client Initiated 2721 Connections in the Session Initiation Protocol (SIP)", 2722 draft-ietf-sip-outbound-04 (work in progress), June 2006. 2724 Appendix A. Design Motivations 2726 ICE contains a number of normative behaviors which may themselves be 2727 simple, but derive from complicated or non-obvious thinking or use 2728 cases which merit further discussion. Since these design motivations 2729 are not neccesary to understand for purposes of implementation, they 2730 are discussed here in an appendix to the specification. This section 2731 is non-normative. 2733 A.1. Applicability to Gateways and Servers 2735 Section 4.1 discusses procedures for gathering candidates, including 2736 host, server reflexive and relayed. In that section, recommendations 2737 are given for when an agent should obtain each of these three types. 2738 In particular, for agents embedded in PSTN gateways, media servers, 2739 conferencing servers, and so on, ICE specifies that an agent can 2740 stick with just host candidates, since it has a public IP address. 2742 This leads to an important question - why would such an endpoint even 2743 bother with ICE? If it has a public IP address, what additional 2744 value do the ICE procedures bring? There are many, actually. 2746 First, doing so greatly facilitates NAT traversal for clients that 2747 connect to it. Consider a PC softphone behind a NAT whose mapping 2748 policy is address and port dependent. The softphone initiates a call 2749 through a gateway that implements ICE. The gateway doesn't obtain 2750 any server reflexive or relayed candidates, but it implements ICE, 2751 and consequently, is prepared to receive STUN connectivity checks on 2752 its host candidates. The softphone will send a STUN connectivity 2753 check to the gateway, which passes through the intervending NAT. 2754 This causes the NAT to allocate a new binding for the softphone. The 2755 connectivity is received by the gateway, and will cause it gateway to 2756 send a check back to the softphone, at this newly created candidate. 2757 A successful response confirms that this candidate is usable, and the 2758 gateway can send media immediately to the softphone. This allows 2759 direct media transmission between the gateway and softphone, without 2760 the need for relays, even though the softphone was behind a 'bad' 2761 NAT. 2763 Second, implementation of the STUN connectivity checks allows for NAT 2764 bindings along the way to be kept open. Keeping these bindings open 2765 is essential for continued communications between the gateway and 2766 softphone. 2768 Third, ICE prevents a fairly destructive attack in multimedia 2769 systems, called the voice hammer. The STUN connectivity check used 2770 by an ICE endpoint allows it to be certain that the target of media 2771 packets is, in fact, the same entity that requested the packets 2772 through the offer/answer exchange. See Section 15 for a more 2773 complete discussion on this attack. 2775 A.2. Pacing of STUN Transactions 2777 STUN transactions used to gather candidates and to verify 2778 connectivity are paced out at an approximate rate of one new 2779 transaction every Ta seconds, where Ta has a default of 50ms. Why 2780 are these transactions paced, and why was 50ms chosen as default? 2782 Sending of these STUN requests will often have the effect of creating 2783 bindings on NAT devices between the client and the STUN servers. 2784 Experience has shown that many NAT devices have upper limits on the 2785 rate at which they will create new bindings. Furthermore, 2786 transmission of these packets on the network makes use of bandwidth 2787 and needs to be rate limited by the agent. As a consequence, the 2788 pacing ensures that the NAT devices does not get overloaded and that 2789 traffic is kept at a reasonable rate. 2791 Another aspect of the STUN requests is their bandwidth usage. In 2792 ICE, each STUN request contains the STUN 20 byte header, in addition 2793 to the USERNAME, MESSAGE-INTEGRITY and PRIORITY attributes. The 2794 USERNAME attribute contains a 4-byte attribute overhead, plus the 2795 username value itself. This username is the concatenation of the two 2796 fragments, plus a colon. Each fragment is supposed to be at least 4 2797 bytes long, making the total length of the USERNAME attribute (4*2 + 2798 1 + 4) = 13 bytes. The MESSAGE-INTEGRITY attribute is 4 bytes of 2799 overhead plus 20 bytes value, for 24 bytes. The PRIORITY attribute 2800 is 4 bytes of overhead plus 4 bytes of value, for 8 bytes. Thus, the 2801 total length of the STUN Binding Request is (20 + 13 + 24 + 8) = 65 2802 bytes, with 28 bytes of overhead for IP and UDP for a total of 93 2803 bytes. The response contains the STUN 20 byte header, the XOR- 2804 MAPPED-ADDRESS, and MESSAGE-INTEGRITY attributes. XOR-MAPPED-ADDRESS 2805 has 4 bytes overhead plus an 8 byte value, for a total of 12 bytes. 2806 Thus, each STUN response is (20 + 12 + 24) = 56 bytes plus 28 bytes 2807 of UDP/IP overhead for a total of 84 bytes. Checks typically fall 2808 into one of two cases. If a check works, each transaction has a 2809 single request and a single response, for a total of 2 packets and 2810 177 bytes over one RTT interval. Assuming a fairly agressive RTT of 2811 70ms, this produces 20.23 kbps, but only briefly. If a check fails 2812 because the pair is invalid, there will be nine requests and no 2813 responses. This produces 837 bytes over 7.9s, for a total of 105.9 2814 bps, but over a long period of time. 2816 OPEN ISSUE: The bandwidth computations are pretty complex because 2817 ICE is not a CBR stream, and its bandwidth utilization depends on 2818 how many transactions it ends up generating before it finishes. 2819 Need to work this model more. 2821 Given that these numbers are close to, if not greater than, the 2822 bandwidths utilized by many voice codecs, this seems a reasonable 2823 value to use. 2825 OPEN ISSUE: There is some debate about whether to reduce this 2826 pacing interval smaller, say 20ms, to speed up ICE, or perhaps 2827 make it equal to the bandwidth that would be utilized by the media 2828 streams themselves. 2830 A.3. Candidates with Multiple Bases 2832 Section 4.1 talks about merging together candidates that are 2833 identical but have different bases. When can an agent have two 2834 candidates that have the same IP address and port, but different 2835 bases? Consider the topology of Figure 16: 2837 +----------+ 2838 | STUN Srvr| 2839 +----------+ 2840 | 2841 | 2842 ----- 2843 // \\ 2844 | | 2845 | B:net10 | 2846 | | 2847 \\ // 2848 ----- 2849 | 2850 | 2851 +----------+ 2852 | NAT | 2853 +----------+ 2854 | 2855 | 2856 ----- 2857 // \\ 2858 | A | 2859 |192.168/16 | 2860 | | 2861 \\ // 2862 ----- 2863 | 2864 | 2865 |192.168.1.1 ----- 2866 +----------+ // \\ +----------+ 2867 | | | | | | 2868 | Offerer |---------| C:net10 |---------| Answerer | 2869 | |10.0.1.1 | | 10.0.1.2 | | 2870 +----------+ \\ // +----------+ 2871 ----- 2873 Figure 16 2875 In this case, the offerer is multi-homed. It has one interface, 2876 10.0.1.1, on network C, which is a net 10 private network. The 2877 Answerer is on this same network. The offerer is also connected to 2878 network A, which is 192.168/16. The offerer has an interface of 2879 192.168.1.1 on this network. There is a NAT on this network, natting 2880 into network B, which is another net10 private network, but not 2881 connected to network C. There is a STUN server on network B. 2883 The offerer obtains a host candidate on its interface on network C 2884 (10.0.1.1:2498) and a host candidate on its interface on network A 2885 (192.168.1.1:3344). It performs a STUN query to its configured STUN 2886 server from 192.168.1.1:3344. This query passes through the NAT, 2887 which happens to assign the binding 10.0.1.1:2498. The STUN server 2888 reflects this in the STUN Binding Response. Now, the offerer has 2889 obtained a server reflexive candidate with a transport address that 2890 is identical to a host candidate (10.0.1.1:2498). However, the 2891 server reflexive candidate has a base of 192.168.1.1:3344, and the 2892 host candidate has a base of 10.0.1.1:2498. 2894 A.4. Purpose of the Translation 2896 When a candidate is relayed, the SDP offer or answer contain both the 2897 relayed candidate and its translation. However, the translation is 2898 never used by ICE itself. Why is it present in the message? 2900 There are two motivations for its inclusion. The first is 2901 diagnostic. It is very useful to know the relationship between the 2902 different types of candidates. By including the translation, an 2903 agent can know which relayed candidate is associated with which 2904 reflexive candidate, which in turn is associated with a specific host 2905 candidate. When checks for one candidate succeed and not the others, 2906 this provides useful diagnostics on what is going on in the network. 2908 The second reason has to do with off-path Quality of Service (QoS) 2909 mechanisms. When ICE is used in environments such as PacketCable 2.0 2910 [[TODO: need PC2.0 reference]], proxies will, in addition to 2911 performing normal SIP operations, inspect the SDP in SIP messages, 2912 and extract the IP address and port for media traffic. They can then 2913 interact, through policy servers, with access routers in the network, 2914 to establish guaranteed QoS for the media flows. This QoS is 2915 provided by classifying the RTP traffic based on 5-tuple, and then 2916 providing it a guaranteed rate, or marking its Diffserv codepoints 2917 appropriately. When a residential NAT is present, and a relayed 2918 candidate gets selected for media, this relayed candidate will be a 2919 transport address on an actual STUN relay. That address says nothing 2920 about the actual transport address in the access router that would be 2921 used to classify packets for QoS treatment. Rather, the translation 2922 of that relayed address is needed. By carrying the translation in 2923 the SDP, the proxy can use that transport address to request QoS from 2924 the access router. 2926 A.5. Importance of the STUN Username 2928 ICE requires the usage of message integrity with STUN using its short 2929 term credential functionality. The actual short term credential is 2930 formed by exchanging username fragments in the SDP offer/answer 2931 exchange. The need for this mechanism goes beyond just security; it 2932 is actual required for correct operation of ICE in the first place. 2934 Consider agents A, B, and C. A and B are within private enterprise 1, 2935 which is using 10.0.0.0/8. C is within private enterprise 2, which 2936 is also using 10.0.0.0/8. As it turns out, B and C both have IP 2937 address 10.0.1.1. A sends an offer to C. C, in its answer, provides 2938 A with its host candidates. In this case, those candidates are 2939 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, B is in a session 2940 at that same time, and is also using 10.0.1.1:8866 and 10.0.1.1:8877 2941 as host candidates. This means that B is prepared to accept STUN 2942 messages on those ports, just as C is. A will send a STUN request to 2943 10.0.1.1:8866 and and another to 10.0.1.1:8877. However, these do 2944 not go to C as expected. Instead, they go to B! If B just replied 2945 to them, A would believe it has connectivity to C, when in fact it 2946 has connectivity to a completely different user, B. To fix this, the 2947 STUN short term credential mechanisms are used. The username 2948 fragments are sufficiently random that it is highly unlikely that B 2949 would be using the same values as A. Consequently, B would reject the 2950 STUN request since the credentials were invalid. In essence, the 2951 STUN username fragments provide a form of transient host identifiers, 2952 bound to a particular offer/answer session. 2954 An unfortunate consequence of the non-uniqueness of IP addresses is 2955 that, in the above example, B might not even be an ICE agent. It 2956 could be any host, and the port to which the STUN packet is directed 2957 could be any ephemeral port on that host. If there is an application 2958 listening on this socket for packets, and it is not prepared to 2959 handle malformed packets for whatever protocol is in use, the 2960 operation of that application could be affected. Fortunately, since 2961 the ports exchanged in SDP are ephemeral and usually drawn from the 2962 dynamic or registered range, the odds are good that the port is not 2963 used to run a server on host B, but rather is the agent side of some 2964 protocol. This decreases the probability of hitting a port in-use, 2965 due to the transient nature of port usage in this range. However, 2966 the possibility of a problem does exist, and network deployers should 2967 be prepared for it. Note that this is not a problem specific to ICE; 2968 stray packets can arrive at a port at any time for any type of 2969 protocol, especially ones on the public Internet. As such, this 2970 requirement is just restating a general design guideline for Internet 2971 applications - be prepared for unknown packets on any port. 2973 A.6. The Candidate Pair Sequence Number Formula 2975 The sequence number for a candidate pair has an odd form. It is: 2977 PAIR-SN = 10000*MAX(O-SN,A-SN) + MIN(O-SN,A-SN) + O-IP/SZ 2979 Why is this? When the candidate pairs are sorted based on this 2980 value, the resulting sorting has the MAX/MIN property. This means 2981 that the pairs are first sorted based on increasing value of the 2982 maximum of the two sequence numbers. For pairs that have the same 2983 value of the maximum sequence number, the minimum sequence number is 2984 used to sort amongst them. If the max and the min sequence numbers 2985 are the same, the IP address of the offerers candidate serves as a 2986 tie breaker. The factor of 1000 is used since there will always be 2987 fewer than a 1000 candidates, and thus the largest value a sequence 2988 number (and thus the minimum sequence number) can have is always less 2989 than 1000. This creates the desired sorting property. 2991 Recall that candidate sequence numbers are assigned such that, for a 2992 particular set of candidates of the same type, the RTP components 2993 have lower sequence numbers than the corresponding RTCP component. 2994 Also recall that, if an agent prefers host candidates to server 2995 reflexive to relayed, sequence numbers for host candidates are always 2996 lower than server reflexive which are always lower than relayed. 2997 Because of this, 2999 A.7. The Frozen State 3001 The Frozen state is used for two purposes. Firstly, it allows ICE to 3002 first perform checks for the first component of a media stream. Once 3003 a successful check has completed for the first component, the other 3004 components of the same type and local preference will get performed. 3005 Secondly, when there are multiple media streams, it allows ICE to 3006 first check candidates for a single media stream, and once a set of 3007 candidates has been found, candidates of that same type for other 3008 media streams can be checked first. This effectively 'caches' the 3009 results of a check for one media stream, and applies them to another. 3010 For example, if only the relayed candidates for audio (which were the 3011 last resort candidates) succeed, ICE will check the relayed 3012 candidates for video first. 3014 A.8. The remote-candidates attribute 3016 The a=remote-candidates attribute exists to eliminate a race 3017 condition between the updated offer and the response to the STUN 3018 Binding Request that moved a candidate into the Valid list. This 3019 race condition is shown in Figure 17. On receipt of message 4, agent 3020 A adds a candidate pair to the valid list. If there was only a 3021 single media stream with a single component, agent A could now send 3022 an updated offer. However, the check from agent B has not yet 3023 generated a response, and agent B receives the updated offer (message 3024 7) before getting the response (message 10). Thus, it does not yet 3025 know that this particular pair is valid. To eliminate this 3026 condition, the actual candidates at B that were selected by the 3027 offerer (the remote candidates) are included in the offer itself. 3029 Note, however, that agent B will not send media until it has received 3030 this STUN response. 3032 Agent A Network Agent B 3033 |(1) Offer | | 3034 |------------------------------------------>| 3035 |(2) Answer | | 3036 |<------------------------------------------| 3037 |(3) STUN Req. | | 3038 |------------------------------------------>| 3039 |(4) STUN Res. | | 3040 |<------------------------------------------| 3041 |(5) STUN Req. | | 3042 |<------------------------------------------| 3043 |(6) STUN Res. | | 3044 |-------------------->| | 3045 | |Lost | 3046 |(7) Offer | | 3047 |------------------------------------------>| 3048 |(8) Answer | | 3049 |<------------------------------------------| 3050 |(9) STUN Req. | | 3051 |<------------------------------------------| 3052 |(10) STUN Res. | | 3053 |------------------------------------------>| 3055 Figure 17 3057 A.9. Why are Keepalives Needed? 3059 Once media begins flowing on a candidate pair, it is still necessary 3060 to keep the bindings alive at intermediate NATs for the duration of 3061 the session. Normally, the media stream packets themselves (e.g., 3062 RTP) meet this objective. However, several cases merit further 3063 discussion. Firstly, in some RTP usages, such as SIP, the media 3064 streams can be "put on hold". This is accomplished by using the SDP 3065 "sendonly" or "inactive" attributes, as defined in RFC 3264 [4]. RFC 3066 3264 directs implementations to cease transmission of media in these 3067 cases. However, doing so may cause NAT bindings to timeout, and 3068 media won't be able to come off hold. 3070 Secondly, some RTP payload formats, such as the payload format for 3071 text conversation [29], may send packets so infrequently that the 3072 interval exceeds the NAT binding timeouts. 3074 Thirdly, if silence suppression is in use, long periods of silence 3075 may cause media transmission to cease sufficiently long for NAT 3076 bindings to time out. 3078 For these reasons, the media packets themselves cannot be relied 3079 upon. ICE defines a simple periodic keepalive that operates 3080 indpendently of media transmission. This makes its bandwidth 3081 requirements highly predictable, and thus amenable to QoS 3082 reservations. 3084 A.10. Why Prefer Peer Reflexive Candidates? 3086 Section 4.2 describes procedures for computing the priority of 3087 candidate based on its type and local preferences. That section 3088 requires that the type preference for peer reflexive candidates 3089 always be lower than server reflexive. Why is that? The reason has 3090 to do with the security considerations in Section 15. It is much 3091 easier for an attacker to cause an agent to use a false server 3092 reflexive candidate than it is for an attacker to cause an agent to 3093 use a false peer reflexive candidate. Consequently, attacks against 3094 the STUN binding discovery usage are thwarted by ICE by preferring 3095 the peer reflexive candidates. 3097 A.11. Why Can't Offerers Send Media When a Pair Validates 3099 Section 11.1 describes rules for sending media. The rules are 3100 asymmetric, and not the same for offerers and answerers. In 3101 particular, an answerer can send media right away to a candidate pair 3102 once it validates, even if it doesnt match the pairs in the m/c-line. 3103 THe offerer cannot - it must wait for an updated offer/answer 3104 exchange. Why is that? 3106 This, in fact, relates to a bigger question - why is the updated 3107 offer/answer exchange needed at all? Indeed, in a pure offer/answer 3108 environment, it would not be. The offerer and answerer will agree on 3109 the candidates to use through ICE, and then can begin using them. As 3110 far as the agents themselves are concerned, the updated offer/answer 3111 provides no new information. However, in practice, numerous 3112 components along the signaling path look at the SDP information. 3113 These include entities performing off-path QoS reservations, NAT 3114 traversal components such as ALGs and Session Border Controllers 3115 (SBCs) and diagnostic tools that passively monitor the network. For 3116 these tools to continue to function without change, the core property 3117 of SDP - that the m/c-lines represent the addresses used for media - 3118 must be retained. For this reason, an updated offer must be sent. 3120 To ensure that an updated offerer is sent, ICE purposefully prevents 3121 the offerer from sending media until that offer is sent. It 3122 furthermore restricts the answerer in how long it can send media 3123 until an updated offer is received. This provides protocol 3124 incentives for sending the updated offer. 3126 The updated offer also helps ensure that ICE did the right thing. In 3127 very unusual cases, the offerer and answerer might not agree on the 3128 candidates selected by ICE. This would be detected in the updated 3129 offer/answer exchange, allowing them to restart ICE procedures to fix 3130 the problem. 3132 Author's Address 3134 Jonathan Rosenberg 3135 Cisco Systems 3136 600 Lanidex Plaza 3137 Parsippany, NJ 07054 3138 US 3140 Phone: +1 973 952-5000 3141 Email: jdrosen@cisco.com 3142 URI: http://www.jdrosen.net 3144 Intellectual Property Statement 3146 The IETF takes no position regarding the validity or scope of any 3147 Intellectual Property Rights or other rights that might be claimed to 3148 pertain to the implementation or use of the technology described in 3149 this document or the extent to which any license under such rights 3150 might or might not be available; nor does it represent that it has 3151 made any independent effort to identify any such rights. Information 3152 on the procedures with respect to rights in RFC documents can be 3153 found in BCP 78 and BCP 79. 3155 Copies of IPR disclosures made to the IETF Secretariat and any 3156 assurances of licenses to be made available, or the result of an 3157 attempt made to obtain a general license or permission for the use of 3158 such proprietary rights by implementers or users of this 3159 specification can be obtained from the IETF on-line IPR repository at 3160 http://www.ietf.org/ipr. 3162 The IETF invites any interested party to bring to its attention any 3163 copyrights, patents or patent applications, or other proprietary 3164 rights that may cover technology that may be required to implement 3165 this standard. Please address the information to the IETF at 3166 ietf-ipr@ietf.org. 3168 Disclaimer of Validity 3170 This document and the information contained herein are provided on an 3171 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS 3172 OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET 3173 ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, 3174 INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE 3175 INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED 3176 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 3178 Copyright Statement 3180 Copyright (C) The Internet Society (2006). This document is subject 3181 to the rights, licenses and restrictions contained in BCP 78, and 3182 except as set forth therein, the authors retain all their rights. 3184 Acknowledgment 3186 Funding for the RFC Editor function is currently provided by the 3187 Internet Society.