idnits 2.17.1 draft-ietf-mmusic-ice-10.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 3181. -- Found old boilerplate from RFC 3979, Section 5, paragraph 1 on line 3158. -- Found old boilerplate from RFC 3979, Section 5, paragraph 2 on line 3165. -- Found old boilerplate from RFC 3979, Section 5, paragraph 3 on line 3171. ** 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 2 instances of too long lines in the document, the longest one being 5 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 (August 31, 2006) is 6447 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: March 4, 2007 August 31, 2006 6 Interactive Connectivity Establishment (ICE): A Methodology for Network 7 Address Translator (NAT) Traversal for Offer/Answer Protocols 8 draft-ietf-mmusic-ice-10 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 March 4, 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 . . . . . . . . . . . . . . . . . 15 63 4.3. Choosing In-Use Candidates . . . . . . . . . . . . . . . . 18 64 4.4. Encoding the SDP . . . . . . . . . . . . . . . . . . . . . 19 65 5. Receiving the Initial Offer . . . . . . . . . . . . . . . . . 20 66 5.1. Verifying ICE Support . . . . . . . . . . . . . . . . . . 20 67 5.2. Gathering Candidates . . . . . . . . . . . . . . . . . . . 21 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 List . . . . . . . . . . . . . . . . . . 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 A and B 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 A and B. 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 A B 385 - - 386 STUN request -> \ A's 387 <- STUN response / check 389 <- STUN request \ B's 390 STUN response -> / check 392 Figure 3 394 As an optimization, as soon as B gets A's check message he 395 immediately sends his own check message to A on the same candidate 396 pair. This accelerates the process of finding a valid candidate. 398 At the end of this handshake, both A and B know that they can send 399 (and receive) messages end-to-end in both directions. Note that as 400 soon as B receives A's STUN response it knows that the B->A 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 A B 406 - - 407 STUN request -> \ A's 408 <- STUN response / check 410 <- STUN request \ B'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 Host Candidate: A candidate obtained by binding to a specific port 518 from an interface on the host. This includes both physical 519 interfaces and logical ones, such as ones obtained through Virtual 520 Private Networks (VPNs) and Realm Specific IP (RSIP) [17] (which 521 lives at the operating system level). 523 Server Reflexive Candidate: A candidate obtained by sending a STUN 524 request from a host candidate to a STUN server, distinct from the 525 peer, whose address is configured or learned by the client prior 526 to an offer/answer exchange. 528 Peer Reflexive Candidate: A candidate obtained by sending a STUN 529 request from a host candidate to the STUN server running on a 530 peer's candidate. 532 Relayed Candidate: A candidate obtained by sending a STUN Allocate 533 request from a host candidate to a STUN server. The relayed 534 candidate is resident on the STUN server, and the STUN server 535 relays packets back towards the agent. 537 Translation: The translation of a relayed candidate is the transport 538 address that the relay will forward a packet to, when one is 539 received at the relayed candidate. For relayed candidates learned 540 through the STUN Allocate request, the translation of the relayed 541 candidate is the server reflexive candidate returned by the 542 Allocate response. 544 Base: The base of a server reflexive candidate is the host candidate 545 from which it was derived. A host candidate is also said to have 546 a base, equal to that candidate itself. Similarly, the base of a 547 relayed candidate is that candidate itself. 549 Foundation: Each candidate has a foundation, which is an identifier 550 that is distinct for two candidates that have different types, 551 different interface IP addresses for their base, and different IP 552 addresses for their STUN servers. Two candidates have the same 553 foundation when they are of the same type, their bases have the 554 same IP address, and, for server reflexive or relayed candidates, 555 they come from the same STUN server. Foundations are used to 556 correlate candidates, so that when one candidate is found to be 557 valid, candidates sharing the same foundation can be tested next, 558 as they are likely to also be valid. 560 Local Candidate: A candidate that an agent has obtained and included 561 in an offer or answer it sent. 563 Remote Candidate: A candidate that an agent received in an offer or 564 answer from its peer. 566 In-Use Candidate: A candidate is in-use when it appears in the m/c- 567 line of an active media stream. 569 Candidate Pair: A pairing containing a local candidate and a remote 570 candidate. 572 Check: A candidate pair where the local candidate is a transport 573 address from which an agent can send a STUN connectivity check. 575 Check List: An ordered set of STUN checks that an agent is to 576 generate towards a peer. 578 Periodic Check: A connectivity check generated by an agent as a 579 consequence of a timer that fires periodically, instructing it to 580 send a check. 582 Triggered Check: A connectivity check generated as a consequence of 583 the receipt of a connectivity check from the peer. 585 Valid List: An ordered set of candidate pairs that have been 586 validated by a successful STUN transaction. 588 4. Sending the Initial Offer 590 In order to send the initial offer in an offer/answer exchange, an 591 agent must gather candidates, priorize them, choose ones for 592 inclusion in the m/c-line, and then formulate and send the SDP. Each 593 of these steps is described in the subsections below. 595 4.1. Gathering Candidates 597 An agent gathers candidates when it believes that communications is 598 imminent. An offerer can do this based on a user interface cue, or 599 based on an explicit request to initiate a session. Every candidate 600 is an IP address and port (also known as a transport address). It 601 also has a type and a base. Three types are defined and gathered by 602 this specification - host candidates, server reflexive candidates, 603 and relayed candidates. The base of a candidate is candidate that an 604 agent must send from when using that candidate. 606 The first step is to gather host candidates. Host candidates are 607 obtained by binding to ports (typically ephemeral) on an interface 608 (physical or virtual, including VPN interfaces) on the host. The 609 process for gathering host candidates depends on the transport 610 protocol. Procedures are specified here for UDP. 612 For each UDP media stream the agent wishes to use, the agent SHOULD 613 obtain a candidate for each component of the media stream on each 614 interface that the host has. It obtains each candidate by binding to 615 a UDP port on the specific interface. A host candidate (and indeed 616 every candidate) is always associated with a specific component for 617 which it is a candidate. Each component has an ID assigned to it, 618 called the component ID. For RTP-based media streams, the RTP itself 619 has a component ID of 1, and RTCP a component ID of 2. If an agent 620 is using RTCP it MUST obtain a candidate for it. If an agent is 621 using both RTP and RTCP, it would end up with 2*K host candidates if 622 an agent has K interfaces. 624 The base for each host candidate is set to the candidate itself. 626 Once the agent has obtained host candidates, it obtains server 627 reflexive and relayed candidates. The process for gathering server 628 reflexive and relayed candidates depends on the transport protocol. 629 Procedures are specified here for UDP. 631 Agents which serve end users directly, such softphones, hardphones, 632 terminal adapters and so on, SHOULD obtain relayed candidates and 633 MUST obtain server reflexive candidates. The requirement to obtain 634 relayed candidates is at SHOULD strength to allow for provider 635 variation. If they are not used, it is RECOMMENDED that it be 636 implemented and just disabled through configuration, so that it can 637 re-enabled through configuration if conditions change in the future. 638 Agents which represent network servers under the control of a service 639 provider, such as gateways to the telephone network, media servers, 640 or conferencing servers that are targeted at deployment only in 641 networks with public IP addresses MAY skip obtaining server reflexive 642 and relayed candidates. 644 The agent next pairs each host candidate with the STUN server with 645 which it is configured or has discovered by some means. This 646 specification only considers usage of a single STUN server. Every Ta 647 seconds, the agent chooses another such pair (the order is 648 inconsequential), and sends a STUN request to the server from that 649 host candidate. If the agent is using both relayed and server 650 reflexive candidates, this request MUST be a STUN Allocate request 651 from the relay usage [12]. If the agent is using only server 652 reflexive candidates, the request MUST be a STUN Binding request 653 using the binding discovery usage [11]. 655 The value of Ta SHOULD be configurable, and SHOULD have a default of 656 50ms. Note that this pacing applies only to starting STUN 657 transactions with source and destination transport addresses (i.e., 658 the host candidate and STUN server respectively) for which a STUN 659 transaction has not previously been sent. Consequently, 660 retransmissions of a STUN request are governed entirely by the 661 retransmission rules defined in [11]. Similarly, retries of a 662 request due to recoverable errors (such as an authentication 663 challenge) happen immediately and are not paced by timer Ta. Because 664 of this pacing, it will take a certain amount of time to obtain all 665 of the server reflexive and relayed candidates. Implementations 666 should be aware of the time required to do this, and if the 667 application requires a time budget, limit the amount of candidates 668 which are gathered. 670 An Allocate Response will provide the client with a server reflexive 671 candidate (obtained from the mapped address) and a relayed candidate 672 in the RELAY-ADDRESS attribute. A Binding Response will provide the 673 client with a only server reflexive candidate (also obtained from the 674 mapped address). The base of the server reflexive candidate is the 675 host candidate from which the Allocate or Binding request was sent. 676 The base of a relayed candidate is that candidate itself. A server 677 reflexive candidate obtained from an Allocate response is the called 678 the "translation" of the relayed candidate obtained from the same 679 response. The agent will need to remember the translation for the 680 relayed candidate, since it is placed into the SDP. If a relayed 681 candidate is identical to a host candidate (which can happen in rare 682 cases), the relayed candidate MUST be discarded. Proper operation of 683 ICE depends on each base being unique. 685 Next, redundant candidates are eliminated. A candidate is redundant 686 if its transport address equals another candidate, and its base 687 equals the base of that other candidate. Note that two candidates 688 can have the same transport address yet have different bases, and 689 these would not be considered redundant. 691 Finally, each candidate is assigned a foundation. The foundation is 692 an identifier, scoped within a session. Two candidates MUST have the 693 same foundation ID when they are of the same type (host, relayed, 694 server reflexive, peer reflexive or relayed), their bases have the 695 same IP address (the ports can be different), and, for reflexive and 696 relayed candidates, the STUN servers used to obtain them have the 697 same IP address. Similarly, two candidates MUST have different 698 foundations if their types are different, their bases have different 699 IP addresses, or the STUN servers used to obtain them have different 700 IP addresses. 702 4.2. Prioritizing Candidates 704 The prioritization process results in the assignment of a priority to 705 each candidate. An agent does this by determining a preference for 706 each type of candidate (server reflexive, per reflexive, relayed and 707 host), and, when the agent is multihomed, choosing a preference for 708 its interfaces. These two preferences are then combined to compute 709 the priority for a candidate. That priority MUST be computed using 710 the following formula: 712 priority = 1000*(type preference) + 713 100*(local preference) + 714 10*(stream ID) + 715 1*(10 - component ID) 717 The type preference MUST be an integer from 0 to 9 inclusive, and 718 represents the preference for the type of the candidate (where the 719 types are local, server reflexive, peer reflexive and relayed). A 9 720 is the highest preference, and a 0 is the lowest. Setting the value 721 to a 0 means that candidates of this type will only be used as a last 722 resort. The type preference MUST be identical for all candidates of 723 the same type and MUST be different for candidates of different 724 types. The type preference for peer reflexive candidates MUST be 725 lower than that of server reflexive candidates. Note that candidates 726 gathered based on the procedures of Section 4.1 will never be peer 727 reflexive candidates; candidates of these type are learned from the 728 STUN connectivity checks performed by ICE. The component ID is the 729 component ID for the candidate, and MUST be between 1 and 10 730 inclusive. The stream ID is an integer, starting at 9, that 731 decrements by one for each media stream in the session. When 732 signaled in the SDP, the first m-line is the one with stream ID 9, 733 the next with stream ID 8, the next with stream ID 7, and so on. In 734 essence, the stream ID indicates the position of that media stream in 735 the SDP itself. The stream ID MUST be less than or equal to 9, and 736 therefore ICE only works with multimedia sessions with 10 or fewer 737 media streams. The local preference MUST be an integer from 0 to 9 738 inclusive. It represents a preference for the particular interface 739 from which the candidate was obtained, in cases where an agent is 740 multihomed. A nine represents the highest preference, and a zero, 741 the lowest. When there is only a single interface, this value SHOULD 742 be set to nine. Generally speaking, if there are multiple candidates 743 for a particular component for a particular media stream which have 744 the same type, the local preference MUST be unique for each one. In 745 this specification, this only happens for multi-homed hosts. 747 These rules guarantee that there is a unique priority for each 748 candidate. This priority will be used by ICE to determine the order 749 of the connectivity checks and the relative preference for 750 candidates. Consequently, what follows are some guidelines for 751 selection of these values. 753 One criteria for selection of the type and local preference values is 754 the use of an intermediary. That is, if media is sent to that 755 candidate, will the media first transit an intermediate server before 756 being received. Relayed candidates are clearly one type of 757 candidates that involve an intermediary. Another are host candidates 758 obtained from a VPN interface. When media is transited through an 759 intermediary, it can increase the latency between transmission and 760 reception. It can increase the packet losses, because of the 761 additional router hops that may be taken. It may increase the cost 762 of providing service, since media will be routed in and right back 763 out of an intermediary run by the provider. If these concerns are 764 important, the type preference for relayed candidates can be set 765 lower than the type preference for reflexive and host candidates. 766 Indeed, it is RECOMMENDED that in this case, host candidates have a 767 type preference of nine, server reflexive candidates have a type 768 preference of 5, peer reflexive have a type prefence of 6, and 769 relayed candidates have a type preference of zero. Furthermore, if 770 an agent is multi-homed and has multiple interfaces, the local 771 preference for host candidates from a VPN interface SHOULD have a 772 priority of 0. 774 Another criteria for selection of preferences is IP address family. 775 ICE works with both IPv4 and IPv6. It therefore provides a 776 transition mechanism that allows dual-stack hosts to prefer 777 connectivity over IPv6, but to fall back to IPv4 in case the v6 778 networks are disconnected (due, for example, to a failure in a 6to4 779 relay) [22]. It can also help with hosts that have both a native 780 IPv6 address and a 6to4 address. In such a case, lower local 781 preferences could be assigned to the v6 interface, followed by the 782 6to4 interfaces, followed by the v4 interfaces. This allows a site 783 to obtain and begin using native v6 addresses immediately, yet still 784 fallback to 6to4 addresses when communicating with agents in other 785 sites that do not yet have native v6 connectivity. 787 Another criteria for selecting preferences is security. If a user is 788 a telecommuter, and therefore connected to their corporate network 789 and a local home network, they may prefer their voice traffic to be 790 routed over the VPN in order to keep it on the corporate network when 791 communicating within the enterprise, but use the local network when 792 communicating with users outside of the enterprise. In such a case, 793 a VPN interface would have a higher local preference than any other 794 interfaces. 796 Another criteria for selecting preferences is topological awareness. 797 This is most useful for candidates that make use of relays. In those 798 cases, if an agent has preconfigured or dynamically discovered 799 knowledge of the topological proximity of the relays to itself, it 800 can use that to assign higher local preferences to candidates 801 obtained from closer relays. 803 There may be transport-specific reasons for assigning preferences to 804 candidates. In such a case, specifications defining usage of ICE 805 with other transport protocols SHOULD document such considerations. 807 4.3. Choosing In-Use Candidates 809 A candidate is said to be "in-use" if it appears in the m/c-line of 810 an offer or answer. When communicating with an ICE peer, being in- 811 use implies that, should these candidates be selected by the ICE 812 algorithm, bidirectional media can flow and the candidates can be 813 used. If a candidate is selected by ICE but is not in-use, only 814 unidirectional media can flow and only for a brief time; the 815 candidate must be made in-use through an updated offer/answer 816 exchange. When communicating with a peer that is not ICE-aware, the 817 in-use candidates will be used exclusively for the exchange of media, 818 as defined in normal offer/answer procedures. 820 An agent MUST choose a set of candidates, one for each component of 821 each active media stream, to be in-use. A media stream is active if 822 it does not contain the a=inactive SDP attribute. 824 It is RECOMMENDED that in-use candidates be chosen based on the 825 likelihood of those candidates to work with the peer that is being 826 contacted. Unfortunately, it is difficult to ascertain which 827 candidates that might be. As an example, consider a user within an 828 enterprise. To reach non-ICE capable agents within the enterprise, 829 host candidates have to be used, since the enterprise policies may 830 prevent communication between elements using a relay on the public 831 network. However, when communicating to peers outside of the 832 enterprise, relayed candidates from a publically accessible STUN 833 server are needed. 835 Indeed, the difficulty in picking just one transport address that 836 will work is the whole problem that motivated the development of this 837 specification in the first place. As such, it is RECOMMENDED that 838 relayed candidates be selected to be in-use. Furthermore, ICE is 839 only truly effective when it is supported on both sides of the 840 session. It is therefore most prudent to deploy it to close-knit 841 communities as a whole, rather than piecemeal. In the example above, 842 this would mean that ICE would ideally be deployed completely within 843 the enterprise, rather than just to parts of it. 845 There may be transport-specific reasons for selection of an in-use 846 candidate. In such a case, specifications defining usage of ICE with 847 other transport protocols SHOULD document such considerations. 849 4.4. Encoding the SDP 851 The agent includes a single a=candidate media level attribute in the 852 SDP for each candidate for that media stream. The a=candidate 853 attribute contains the IP address, port and transport protocol for 854 that candidate. A Fully Qualified Domain Name (FQDN) for a host MAY 855 be used in place of a unicast address. In that case, when receiving 856 an offer or answer containing an FQDN in an a=candidate attribute, 857 the FQDN is looked up in the DNS using an A or AAAA record, and the 858 resulting IP address is used for the remainder of ICE processing. 859 The candidate attribute also includes the component ID for that 860 candidate. For media streams based on RTP, candidates for the actual 861 RTP media MUST have a component ID of 1, and candidates for RTCP MUST 862 have a component ID of 2. Other types of media streams which require 863 multiple components MUST develop specifications which define the 864 mapping of components to component IDs. 866 The candidate attribute also includes the priority, which is the 867 value determined for the candidate as described in Section 4.2, and 868 the foundation, which is the value determined for the candidate as 869 described in Section 4.1. The agent SHOULD include a type for each 870 candidate by populating the candidate-types production with the 871 appropriate value - "host" for host candidates, "srflx" for server 872 reflexive candidates, "prflx" for peer reflexive candidates (though 873 these never appear in an initial offer/answer exchange), and "relay" 874 for relayed candidates. The related address MUST NOT be included if 875 a type was not included. If a type was included, the related address 876 SHOULD be present for server reflexive, peer reflexive and relayed 877 candidates. If a candidate is server or peer reflexive, the related 878 address is equal to the base for that server or peer reflexive 879 candidate. If the candidate is relayed, the related address is equal 880 to the translation of the relayed address. If the candidiate is a 881 host candidate, there is no related address and the rel-addr 882 production MUST be omitted. 884 STUN connectivity checks between agents make use of a short term 885 credential that is exchanged in the offer/answer process. The 886 username part of this credential is formed by concatenating a 887 username fragment from each agent, separated by a colon. Each agent 888 also provides a password, used to compute the message integrity for 889 requests it receives. As such, an SDP MUST contain the ice-ufrag and 890 ice-pwd attributes, containing the username fragment and password 891 respectively. These can be either session or media level attributes, 892 and thus common across all candidates for all media streams, or all 893 candidates for a particular media stream, respectively. However, if 894 two media streams have identical ice-ufrag's, they MUST have 895 identical ice-pwd's. The ice-ufrag and ice-pwd attributes MUST be 896 chosen randomly at the beginning of a session. The ice-ufrag 897 attribute MUST contain at least 24 bits of randomness, and the ice- 898 pwd attribute MUST contain at least 128 bits of randomness. This 899 means that the ice-ufrag attribute will be at least 4 characters 900 long, and the ice-pwd at least 22 characters long, since the grammar 901 for these attributes allows for 6 bits of randomness per character. 902 The attributes MAY be longer than 4 and 21 characters respectively, 903 of course. 905 The m/c-line is populated with the candidates that are in-use. For 906 streams based on RTP, this is done by placing the RTP candidate into 907 the m and c lines respectively. If the agent is utilizing RTCP, it 908 MUST encode the RTCP candidate into the m/c-line using the a=rtcp 909 attribute as defined in RFC 3605 [2]. If RTCP is not in use, the 910 agent MUST signal that using b=RS:0 and b=RR:0 as defined in RFC 3556 911 [5]. 913 There MUST be a candidate attribute for each component of the media 914 stream in the m/c-line. 916 Once an offer or answer are sent, an agent MUST be prepared to 917 receive both STUN and media packets on each candidate. As discussed 918 in Section 11.1, media packets can be sent to a candidate prior to 919 its appearence in the m/c-line. 921 5. Receiving the Initial Offer 923 When an agent receives an initial offer, it will check if the offeror 924 supports ICE, gather candidates, prioritize them, choose one for in- 925 use, encode and send an answer, and then form a check list and begin 926 connectivity checks. 928 5.1. Verifying ICE Support 930 The agent will proceed with the ICE procedures defined in this 931 specification if the following are both true: 933 o There is at least one a=candidate attribute for each media stream 934 in the SDP it just received. 936 o For each media stream, at least one of the candidates is a match 937 for its respective in-use component in the m/c-line. 939 If both of these conditions are not met, the agent MUST process the 940 SDP based on normal RFC 3264 procedures, without using any of the ICE 941 mechanisms described in the remainder of this specification, with the 942 exception of Section 10, which describes keepalive procedures. 944 5.2. Gathering Candidates 946 The process for gathering candidates at the answerer is identical to 947 the process for the offerer as described in Section 4.1. It is 948 RECOMMENDED that this process begin immediately on receipt of the 949 offer, prior to user acceptance of a session. Such gathering MAY 950 even be done pre-emptively when an agent starts. 952 5.3. Prioritizing Candidates 954 The process for prioritizing candidates at the answerer is identical 955 to the process followed by the offerer, as described in Section 4.2. 957 5.4. Choosing In Use Candidates 959 The process for selecting in-use candidates at the answerer is 960 identical to the process followed by the offerer, as described in 961 Section 4.3. 963 5.5. Encoding the SDP 965 The process for encoding the SDP at the answerer is identical to the 966 process followed by the offerer, as described in Section 4.4. 968 5.6. Forming the Check List 970 Next, the agent forms the check list. The check list is a sequence 971 of STUN connectivity checks that are performed by the agent. To form 972 the check list, the agent forms candidate pairs, computes a candidate 973 pair priority, orders the pairs by priority, prunes them, and sets 974 their states. These steps are described in this section. 976 First, the agent takes each of its candidates (called local 977 candidates) and pairs them with the candidates it received from its 978 peer (called remote candidates). A local candidate is paired with a 979 remote candidate if and only if the two candidates are for the same 980 media stream, have the same component ID, and have the same IP 981 address version. It is possible that some of the local candidates 982 don't get paired with a remote candidate, and some of the remote 983 candidates don't get paired with local candidates. This can happen 984 if one agent didn't include candidates for the all of the components 985 for a media stream. In the case of RTP, for example, this would 986 happen when one agent provided candidates for RTCP, and the other did 987 not. If this happens, the number of components for that media stream 988 is effectively reduced, and considered to be equal to the minimum 989 across both agents of the maximum component ID provided by each agent 990 across all components for the media stream. 992 Once the pairs are formed, a candidate pair priority is computed. 993 Let O-P be the priority for the candidate provided by the offerer. 994 Let A-P be the priority for the candidate provided by the answerer. 995 Let O-IP be the IP address (without the port) of the candidate 996 provided by the offerer. Let SZ be two to the power of 32 for IPv4 997 candidates, and two to the power of 128 for IPv6 candidates. The 998 priority for a pair is computed as: 1000 pair priority = 10000*MIN(O-P,A-P) + MAX(O-P,A-P) + O-IP/SZ 1002 OPEN ISSUE: This can be larger than 32 bits. Should consider ways 1003 of reducing that. 1005 This formula ensures a unique priority for each pair in most cases. 1006 One the priority is assigned, the agent sorts the candidate pairs in 1007 decreasing order of priority. If two pairs have identical priority, 1008 the ordering amongst them is arbitrary. 1010 This sorted list of candidate pairs is used to determine a sequence 1011 of connectivity checks that will be performed. Each check involves 1012 sending a request from a local candidate to a remote candidate. 1013 Since an agent cannot send requests directly from a reflexive 1014 candidate, but only from its base, the agent next goes through the 1015 sorted list of candidate pairs. For each pair where the local 1016 candidate is server reflexive, the server reflexive candidate MUST be 1017 replaced by its base. Once this has been done, the agent MUST remove 1018 redundant pairs. A pair is redundant if its local and remote 1019 candidates are identical to the local and remote candidates of a pair 1020 higher up on the priority list. The result is called the check list, 1021 and each candidate pair on it is called a check. 1023 Each check is also said to have a foundation, which is merely the 1024 combination of the foundations of the local and remote candidates in 1025 the check. 1027 Finally, each check in the check list is associated with a state. 1028 There are five potential values that the state can have: 1030 Waiting: This check has not been performed, and can be performed as 1031 soon as it is the highest priority Waiting check on the check 1032 list. 1034 In-Progress: A request has been sent for this check, but the 1035 transaction is in progress. 1037 Succeeded: This check was already done and produced a successful 1038 result. 1040 Failed: This check was already done and failed, either never 1041 producing any response or producing an unrecoverable failure 1042 response. 1044 Frozen: This check hasn't been performed, and it can't yet be 1045 performed until some other check succeeds, allowing it to move 1046 into the Waiting state. 1048 First, the agent sets all of the checks to the Frozen state. Then, 1049 it sets the first check in the check list to Waiting. It then finds 1050 all of the other checks for the same media stream and with the same 1051 component ID, but different foundations, and sets all of their states 1052 to Waiting. 1054 5.7. Performing Periodic Checks 1056 An agent performs two types of checks. The first type are periodic 1057 checks. These checks occur periodically, and involve choosing the 1058 highest priority check in the Waiting state from the check list, and 1059 performing it. The other type of check is called a triggered check. 1060 This is a check that is performed on receipt of a connectivity check 1061 from the peer. This section describes how periodic checks are 1062 performed. 1064 Once the agent has computed the check list as described in 1065 Section 5.6, it sets a timer that fires every Ta seconds. This is 1066 the same value used to pace the gathering of candidates, as described 1067 in Section 4.1. The first timer fires immediately, so that the agent 1068 performs a connectivity check the moment the offer/answer exchange 1069 has been done, followed by the next periodic check Ta seconds later. 1071 When the timer fires, the agent MUST find the highest priority check 1072 in the check list that is in the Waiting state. The agent then sends 1073 a STUN check from the local candidate of that check to the remote 1074 candidate of that check. The procedures for forming the STUN request 1075 for this purpose are described in Section 7.7.1. If none of the 1076 checks in the check list are in the Waiting state, but there are 1077 checks in the Frozen state, the highest priority check in the Frozen 1078 state is moved into the Waiting state, and that check is performed. 1079 When a check is performed, its state is set to In-Progress. If there 1080 are no checks in either the Waiting or Frozen state, then timer Ta is 1081 stopped. 1083 Performing the connectivity check requires the agent to know the 1084 username fragment for the local and remote candidates, and the 1085 password for the remote candidate. For periodic checks, the remote 1086 username fragment and password are learned directly from the SDP 1087 received from the peer, and the local username fragment is known by 1088 the agent. 1090 6. Receipt of the Initial Answer 1092 This section describes the procedures that an agent follows when it 1093 receives the answer from the peer. It verifies that its peer 1094 supports ICE, forms the check list and begins performing periodic 1095 checks. 1097 6.1. Verifying ICE Support 1099 The offerer follows the same procedures described for the answerer in 1100 Section 5.1. 1102 6.2. Forming the Check List 1104 The offerer follows the same procedures described for the answerer in 1105 Section 5.6. 1107 6.3. Performing Periodic Checks 1109 The offerer follows the same procedures described for the answerer in 1110 Section 5.7. 1112 7. Connectivity Checks 1114 This section describes how connectivity checks are performed. 1115 Connectivity checks are a STUN usage, and the behaviors described 1116 here meet the guidelines for definitions of new usages as outlined in 1117 [11] 1119 Note that all ICE implementations are required to be compliant to 1120 [11], as opposed to the older [13]. 1122 7.1. Applicability 1124 This STUN usage provides a connectivity check between two peers 1125 participating in an offer/answer exchange. This check serves to 1126 validate a pair of candidates for usage of exchange of media. 1127 Connectivity checks also allow agents to discover reflexive 1128 candidates towards their peers, called peer reflexive candidates. 1129 Finally, connectivity checks serve to keep NAT bindings alive. 1131 It is fundamental to this STUN usage that the addresses and ports 1132 used for media are the same ones used for the Binding Requests and 1133 responses. Consequently, it will be necessary to demultiplex STUN 1134 traffic from whatever the media traffic is. This demultiplexing is 1135 done using the techniques described in [11]. 1137 7.2. Client Discovery of Server 1139 The client does not follow the DNS-based procedures defined in [11]. 1140 Rather, the remote candidate of the check to be performed is used as 1141 the IP address and port of the STUN server. Note that the STUN 1142 server is a logical entity, and is not a physically distinct server 1143 in this usage. 1145 7.3. Server Determination of Usage 1147 The server is aware of this usage because it signaled this port 1148 through the offer/answer exchange. Any STUN packets received on this 1149 port will be for the connectivity check usage. 1151 7.4. New Requests or Indications 1153 This usage does not define any new message types. 1155 7.5. New Attributes 1157 This usage defines a new attribute, PRIORITY. This attribute 1158 indicates the priority that is to be associated with a peer reflexive 1159 candidate, should one be discovered by this check. It is a 32 bit 1160 unsigned integer, and has an attribute type of 0x0024. 1162 7.6. New Error Response Codes 1164 This usage does not define any new error response codes. 1166 7.7. Client Procedures 1168 This section defines additional procedures for the Binding Request 1169 transaction, beyond those described in [11]. 1171 7.7.1. Sending the Request 1173 The agent acting as the client generates a connectivity check either 1174 periodically, or triggered. In either case, the check is generated 1175 by sending a Binding Request from a local candidate, to a remote 1176 candidate. The agent must know the username fragment for both 1177 candidates and the password for the remote candidate. 1179 A Binding Request serving as a connectivity check MUST utilize a STUN 1180 short term credential. Rather than being learned from a Shared 1181 Secret request, the short term credential is exchanged in the offer/ 1182 answer procedures. In particular, the username is formed by 1183 concatenating the username fragment provided by the peer with the 1184 username fragment of the agent sending the request, separated by a 1185 colon (":"). The password is equal to the password provided by the 1186 peer. For example, consider the case where agent A is the offerer, 1187 and agent B is the answerer. Agent A included a username fragment of 1188 AFRAG for its candidates, and a password of APASS. Agent B provided 1189 a username fragment of BFRAG and a password of BPASS. A connectivity 1190 check from A to B (and its response of course) utilize the username 1191 BFRAG:AFRAG and a password of BPASS. A connectivity check from B to 1192 A (and its response) utilize the username AFRAG:BFRAG and a password 1193 of APASS. 1195 All Binding Requests for the connectivity check usage MUST contain 1196 the PRIORITY attribute. This MUST be set equal to the priority that 1197 would be assigned, based on the algorithm in Section 4.2, to a peer 1198 reflexive candidate learned from this check. Such a peer reflexive 1199 candidate has a stream ID, component ID and local preference that are 1200 equal to the host candidate from which the check is being sent, but a 1201 type preference equal to the value associated with peer reflexive 1202 candidates. 1204 The Binding Request by an agent MUST include the USERNAME and 1205 MESSAGE-INTEGRITY attributes. That is, an agent MUST NOT wait to be 1206 challenged for short term credentials. Rather, it MUST provide them 1207 in the Binding Request right away. 1209 7.7.2. Processing the Response 1211 If the STUN transaction generates an unrecoverable failure response 1212 or times out, the agent sets the state of the check to Failed. The 1213 remainder of this section applies to processing of successful 1214 responses (any response from 200 to 299). 1216 The agent MUST check that the source IP address and port of the 1217 response equals the destination IP address and port that the Binding 1218 Request was sent to, and that the source IP address and port of the 1219 request match the destination IP address and port that the Binding 1220 Response was received on. If these do not match, the agent sets the 1221 state of the check to Failed. The processing described in the 1222 remainder of this section MUST NOT be performed. 1224 Otherwise, the source transport address of the response matched the 1225 destination transport address of the request. The agent changes the 1226 state for this check to Succeeded. Next, the agent sees if the 1227 success of this check can cause other checks to be unfrozen. If the 1228 check had a component ID of one, the agent MUST change the states for 1229 all other Frozen checks for the same media stream and same 1230 foundation, but different component IDs, to Waiting. If the 1231 component ID for the check was equal to the number of components for 1232 the media stream, the agent MUST change the state for all other 1233 Frozen checks for the first component of different media streams but 1234 the same foundation, to Waiting. 1236 Next, the agent checks the mapped address from the STUN response. If 1237 the transport address does not match any of the local candidates that 1238 the agent knows about, the mapped address representes a new peer 1239 reflexive candidate. Its type is equal to peer reflexive. Its base 1240 is set equal to the candidate from which the STUN check was sent. 1241 Its username fragment and password are identical to the candidate 1242 from which the check was sent. It is assigned the priority value 1243 that was placed in the PRIORITY attribute of the request. Its 1244 foundation is selected as described in Section 4.1. The peer 1245 reflexive candidate is then added to the list of local candidates 1246 known by the agent (though it is not paired with other remote 1247 candidates at this time). 1249 In addition, the agent creates a candidate pair whose local candidate 1250 equals the mapped address of the response, and whose remote candidate 1251 equals the destination address to which the request was sent. This 1252 is called a validated pair, since it has been validated by a STUN 1253 connectivity check. The agent will know, either from the SDP or 1254 through the PRIORITY attribute that was present in a STUN request, 1255 the priorities of the local and remote candidates of the validated 1256 pair. Based on these priorities, a priority for the validated pair 1257 itself is computed if it was not already known, using the algorithm 1258 in Section 5.6, and the pair is added to the valid list. 1260 7.8. Server Procedures 1262 An agent MUST be prepared to receive a Binding Request on the base of 1263 each candidate it included in its most recent offer or answer. 1264 Receipt of a Binding Request on an IP address and port that the agent 1265 had included in a candidate attribute is an indication that the 1266 connectivity check usage applies to the request. 1268 The agent MUST use a short term credential to authenticate the 1269 request and perform a message integrity check. The agent MUST accept 1270 a credential if the username consists of two values separated by a 1271 colon, where the first value is equal to the username fragment 1272 generated by the agent in an offer or answer for a session in- 1273 progress, and the password is equal to the password for that username 1274 fragment. It is possible (and in fact very likely) that an offeror 1275 will receive a Binding Request prior to receiving the answer from its 1276 peer. However, the request can be processed without receiving this 1277 answer, and a response generated. 1279 For requests being received on a relayed candidate, the source IP 1280 address and port used for STUN processing (namely, generation of the 1281 XOR-MAPPED-ADDRESS attribute) is the IP address and port as seen by 1282 the relay. That source transport address will be present in the 1283 REMOTE-ADDRESS attribute of a STUN Data Indication message, if the 1284 Binding Request was delivered through a Data Indication. If the 1285 Binding Request was not encapsulated in a Data Indication, that 1286 source address is equal to the current active destination for the 1287 STUN relay session. 1289 When the agent receives a STUN Binding Request for which it generates 1290 a successful response, the agent checks the source transport address 1291 of the request. If this transport address does not match any 1292 existing remote candidates, it represents a new peer reflexive remote 1293 candidate. This candidate is given a priority equal to the PRIORITY 1294 attribute from the request. The type of the candidate is equal to 1295 peer reflexive. Its foundation is set to an arbitrary value, 1296 different from the foundation for all other remote candidates. The 1297 username fragment for this candidate is equal to the bottom half (the 1298 part after the colon) of the username in the Binding Request that was 1299 just received. The password for this username fragment is taken from 1300 the SDP from the peer. If agent has not yet received this SDP (a 1301 likely case for the offerer in the initial offer/answer exchange), it 1302 MUST wait for the SDP to be received, and then proceed with rest of 1303 the processing described in the remainder of this section. This 1304 candidate is then added to the list of remote candidates. However, 1305 it is not paired with any local candidates. 1307 Next, the agent MUST generate a triggered check in the reverse 1308 directon if it has not already sent such a check. The triggered 1309 check has a local candidate equal to the candidate on which the STUN 1310 request was received, and a remote candidate equal to the source 1311 transport address where the request came from (which may be a newly 1312 formed peer reflexive candidate). The agent knows the priorities for 1313 the local and remote candidates of this check, and so can compute the 1314 priority for the check itself. If there is already a check on the 1315 check list with this same local and remote candidates, and the state 1316 of that check is Waiting or Frozen, its state is changed to In- 1317 Progress and the check is performed. If there was already a check on 1318 the check list with this same local and remote candidates, and its 1319 state was In-Progress, the agent SHOULD generate an immediate 1320 retransmit of the Binding Request. This is to facilitate rapid 1321 completion of ICE when both agents are behind NAT. If there was a 1322 check in the list already and its state was Succeeded or Failed, 1323 nothing further is done. If there was no matching check on the check 1324 list, it is inserted into the check list based on its priority, its 1325 state is set to In-Progress, and the check is performed. 1327 7.9. Security Considerations for Connectivity Check 1329 Security considerations for the connectivity check are discussed in 1330 Section 15. 1332 8. Completing the ICE Checks 1334 When a pair is added to the valid list, and the agent was the offeror 1335 in the most recent offer/answer exchange, the agent MUST check to see 1336 if there is a pair on the validated list for each component of each 1337 media stream. If there is, the offeror MUST stop timer Ta, and MUST 1338 cease retransmitting any Binding Requests for transactions in 1339 progress. It MUST ignore any responses which may subsequently arrive 1340 to transactions previously in progress. The offeror MUST generate an 1341 updated offer as described in Section 9. It does this regardless of 1342 whether the highest priority pairs in the check list match the 1343 current in-use candidate pairs. 1345 When a pair is aded to the valid list, and the agent was the answerer 1346 in the most recent offer/answer exchange, the agent MAY begin sending 1347 media using that candidate pair, as described in Section 11.1. In 1348 addition, if there is a candidate pair on the valid list for each 1349 component of each media stream, the answerer MUST stop timer Ta, and 1350 MUST cease retransmitting any Binding Requests for transactions in 1351 progress. It MUST ignore any responses which may subsequently arrive 1352 to transactions previously in progress. 1354 Note that only agent that was the answerer in the most recent offer/ 1355 answer exchange gets to send media right away. The offeror must wait 1356 for a subsequent offer/answer exchange if the valid candidates don't 1357 match those in the m/c-line. 1359 OPEN ISSUE: It is possible that higher priority checks may still 1360 succeed, if we allowed things to continue. This can happen for 1361 several reasons. First, an in-progress check of higher priority 1362 had some packet loss and thus hasn't completed. Timer Tws was 1363 meant to handle this (I removed this timer from -10 to simplify). 1364 More interestingly, higher priority checks may have not been done 1365 because a triggered check of lower priority succeeded. This 1366 happens in cases where the number of checks at each agent are 1367 assymetric. It is possible to fix both of these problems by 1368 delaying the completion of the ICE procedures for a bit more time. 1369 This adds complexity and latency. The basic algorithm would be 1370 this. You take the lowest priority pair in the valid list. You 1371 keep doing checks as long as there are higher priority checks on 1372 the list in the Waiting state. If there are none, you wait a 1373 brief time (say 50ms) and then consider ICE finished. 1375 9. Subsequent Offer/Answer Exchanges 1377 An agent MAY generate a subsequent offer at any time. However, the 1378 rules in Section 7.7.2 will cause the offerer to generate an updated 1379 offer when the candidates in the valid list are not all in-use. 1381 9.1. Generating the Offer 1383 When an agent generates an updated offer, the set of candidate 1384 attributes to include depend on the state of ICE processing. If ICE 1385 is "done", which occurs when the valid list includes a candidate pair 1386 for each component of each media stream, the agent MUST include a 1387 candidate attribute for each local candidate amongst the pairs in the 1388 valid list (including peer reflexive candidates), and SHOULD NOT 1389 include any others. This will cause STUN keepalives to be sent for 1390 the in-use candidates, and thats it. 1392 If, however, the valid list does not yet include a candidate pair for 1393 each component of each media stream, the agent SHOULD include all 1394 current candidates, including any peer reflexive candidates it has 1395 learned since the last offer or answer it sent. This MAY include 1396 candidates it did not offer previously, but which it has gathered 1397 since the last offer/answer exchange. 1399 If a candidate was sent in a previous offer/answer exchange, it 1400 SHOULD have the same priority. For a peer reflexive candidate, the 1401 priority SHOULD be the same as determined by the processing in 1402 Section 7.7.2. The foundation SHOULD be the same. The username 1403 fragments and passwords for a media stream SHOULD remain the same as 1404 the previous offer or answer. 1406 Population of the m/c-lines also depends on the state of ICE 1407 processing. If, for a particular media stream, the valid list has 1408 candidate pairs for all of the components of that media stream, those 1409 pairs are used. In particular, the m/c-line would be constructed by 1410 from the local candidate from each of those candidate pairs. In 1411 addition, the agent MUST include the a=remote-candidates attribute 1412 for that media stream, and include in it the remote candidates for 1413 each of the pairs that were used. 1415 If, for a particular media stream, the valid list does not have pairs 1416 for all of the components of the stream, the agent SHOULD populate 1417 the m/c-line for that media stream based on the considerations in 1418 Section 4.3. 1420 The agent MUST use the same ice-pwd and ice-ufrag for a media stream 1421 as its previous offer or answer. Note that it is permissible to use 1422 a session-level attribute in one offer, but to provide the same 1423 password as a media-level attribute in a subsequent offer. This is 1424 not a change in password, just a change in its representation. 1426 9.2. Receiving the Offer and Generating an Answer 1428 When the answerer generates its answer, it must decide what 1429 candidates to include in the answer, and how to populate the m/c- 1430 line. 1432 For each media stream in the offer, the agent checks to see if the 1433 stream contained the remote-candidates attribute. If it did, it 1434 means that the offerer believed that ICE processing has completed for 1435 that media stream. In this case, the remote-candidates attribute 1436 contains the candidates that the answerer is supposed to use. It is 1437 possible that the agent doesn't even know of these candidates yet; 1438 they will be discovered shortly through a response to an in-progress 1439 check. The agent MUST populate the m/c-line with the candidates from 1440 the a=remote-candidates attribute. In addition, it MUST include an 1441 a=candidate attribute in its answer for each candidate in the 1442 a=remote-candidates attribute. If the agent is not aware of the 1443 candidate yet, it will need to generate a priority value for it. The 1444 type preference in the computation is peer-reflexive, and the stream 1445 ID and component ID are known from the offer. The agent chooses an 1446 arbitrary local preference value if it is multi-homed, since it won't 1447 yet know the interface associated with this candidate. 1449 If a media stream does not yet contain the a=remote-candidates 1450 attribute, it means that the offerer believes that ICE checks are 1451 still in progress for that media stream. In this case, the answerer 1452 SHOULD include an a=candidate attribute for all of the candidates for 1453 that media stream it knows about (including peer-reflexive 1454 candidates). The m/c-line is populated based on the considerations 1455 in Section 4.3. 1457 Construction of the ice-pwd and ice-ufrag are identical to the 1458 procedures followed by the offerer, as described in Section 9.1. 1460 Note that the a=remote-candidates attribute SHOULD NOT be included in 1461 the answer, and if included, will just be ignored by the offerer, 1462 since it is not used in any processing of the answer. 1464 9.3. Updating the Check and Valid Lists 1466 Once the subsequent offer/answer exchange has completed, each agent 1467 needs to compute the new check list resulting from this exchange, and 1468 then remove any pairs from the valid list which are no longer usable. 1469 Once these adjustments are made, ICE processing continues using these 1470 new lists. 1472 Each agent recomputes the check list using the procedures described 1473 in Section 5.6. If a check on this new check list was also on the 1474 previous check list, and its state was Waiting, In-Progress, 1475 Succeeded or Failed, its state is copied over. If a check on the new 1476 check list does not have a state (because its a new check or its 1477 state was not copied over), and it is for the component with 1478 component ID 1 and for the media stream with stream ID 9, its state 1479 is set to Waiting. All other pairs without a state have their state 1480 set to Frozen. 1482 Next, the agent goes through the check list, starting with the 1483 highest priority check. If a check has a state of Succeeded, and it 1484 has a component ID of 1, then all Frozen checks for the same media 1485 stream and same foundation whose component IDs are not one, have 1486 their state set to Waiting. If, for a particular media stream, there 1487 are checks for each component of that media stream in the Succeeded 1488 state, the agent moves the state of all Frozen checks for the first 1489 component of all other media streams with the same foundation to 1490 Waiting. 1492 If a check was on the old check list, but was not on the new check 1493 list, and had a state of In-Progress, the corresponding STUN 1494 transaction is abandoned. No further retransmits will be sent for 1495 the STUN request, and any response that might be received is ignored. 1497 Next, the agent prunes the valid list. For each pair on the valid 1498 list, the agent examines each candidate in the pair. If the 1499 candidate was not peer reflexive, and was not present in the most 1500 recent offer/answer exchange, the candidate pair is removed from the 1501 valid list. 1503 OPEN ISSUE: This means that you cannot forcefully remove a peer 1504 reflexive candidate. This feature was possible, at much 1505 complexity, in previous versions of the spec. An alternative is 1506 to remove a peer reflexive candidate if it was not present in the 1507 offer/answer, and was discovered more than 500ms ago. 1509 10. Keepalives 1511 STUN connectivity checks are also used to keep NAT bindings open once 1512 a session is underway. This is accomplished by periodically re- 1513 starting the check process, as described in this section. 1515 Once the initial offer/answer exchange has taken place, the agent 1516 sets a timer to fire in Tr seconds. Tr SHOULD be configurable and 1517 SHOULD have a default of 15 seconds. When Tr fires, the agent MUST 1518 reset the states for all of the checks in the check list using the 1519 procedures defined in Section 5.6 and then begin performing periodic 1520 checks as described in Section 5.7. By the time the timer fires for 1521 the first time, the check list will include only the in-use 1522 candidates. Reperforming these checks will therefore performing a 1523 period keepalive. 1525 OPEN ISSUE: ICE isn't saying anything about what happens if these 1526 periodic keepalives should fail. It they do, something really bad 1527 has happened, like a NAT reboot or failure. I think we should 1528 keep that out of scope. 1530 When an ICE agent is communicating with an agent that is not ICE- 1531 aware, keepalives still need to be utilized. Indeed, these 1532 keepalives are essential even if neither endpoint implements ICE. As 1533 such, this specification defines keepalive behavior generally, for 1534 endpoints that support ICE, and those that do not. 1536 All endpoints MUST send keepalives for each media session. These 1537 keepalives MUST be sent regardless of whether the media stream is 1538 currently inactive, sendonly, recvonly or sendrecv. The keepalive 1539 SHOULD be sent using a format which is supported by its peer. ICE 1540 endpoints allow for STUN-based keepalives for UDP streams, and as 1541 such, STUN keepalives MUST be used when an agent is communicating 1542 with a peer that supports ICE. An agent can determine that its peer 1543 supports ICE by the presence of the a=candidate attributes for each 1544 media session. If the peer does not support ICE, the choice of a 1545 packet format for keepalives is a matter of local implementation. A 1546 format which allows packets to easily be sent in the absence of 1547 actual media content is RECOMMENDED. Examples of formats which 1548 readily meet this goal are RTP No-Op [27] and RTP comfort noise [23]. 1549 If the peer doesn't support any formats that are particularly well 1550 suited for keepalives, an agent SHOULD send RTP packets with an 1551 incorrect version number, or some other form of error which would 1552 cause them to be discarded by the peer. 1554 STUN-based keepalives will be sent periodically every Tr seconds as 1555 described above. If STUN keepalives are not in use (because the peer 1556 does not support ICE), an agent SHOULD ensure that a media packet is 1557 sent every Tr seconds. If one is not sent as a consequence of normal 1558 media communications, a keepalive packet using one of the formats 1559 discussed above SHOULD be sent. 1561 11. Media Handling 1563 11.1. Sending Media 1565 Agents always send media using a candidate pair. An agent will send 1566 media to the remote candidate in the pair (setting the destination 1567 address and port of the packet equal to that remote candidate), and 1568 will send it from the local candidate. When the local candidate is 1569 server or peer reflexive, media is originated from the base. Media 1570 sent from a relayed candidate is sent through that relay, using 1571 procedures defined in [12]. 1573 If an agent was the offerer in the most recent offer/answer exchange, 1574 when it sends media, it MUST use the candidates in the m/c-line for 1575 each media stream. However, it MUST only send media once those 1576 candidates also appear in the valid list. If the candidates in the 1577 m/c-line are not the ones that are ultimately selected by ICE, this 1578 implies that the offerer will need to wait for the subsequent offer/ 1579 answer exchange to complete before it can send media. 1581 If an agent was the answerer in the most recent offer/answer 1582 exchange, the rules are different. When the agent wishes to send 1583 media, and the candidate pairs in the m/c-lines are also the highest 1584 priority ones in the valid list for each media stream, it uses those 1585 candidate pairs. If, however, the highest priority pairs in the 1586 valid list for a media stream are not the same as the ones in the 1587 m/c-lines, the agent MUST use the highest priority pairs in the valid 1588 list. However, the agent MUST discontinue using those candidate 1589 pairs Tlo seconds after the next opportunity its peer would have to 1590 send an updated offer. In the case of an answer delivered in a 200 1591 OK to an offer in a SIP INVITE (regardless of whether that same 1592 answer appeared in an earlier unreliable provisional response), this 1593 would be Tlo seconds after receipt of the ACK. Tlo SHOULD be 1594 configurable and SHOULD have a default of 5 seconds. This time 1595 represents the amount of time it should take the offerer to perform 1596 its connectivity checks, arrive at the same conclusion about the 1597 candidate pair, and then generate an updated offer. If, after Tlo 1598 seconds, no updated offer arrives, the answerer MUST cease sending 1599 media, and will need to wait for the updated offer. 1601 OPEN ISSUE: In previous versions of ICE, once this timer fired, 1602 you just sent media to the one in the m/c-line. This causes the 1603 media streams to flip back and forth between addresses, which I am 1604 trying to avoid. Since this timer should never go off anyway, I 1605 removed this feature. 1607 ICE has interactions with jitter buffer adaptation mechanisms. An 1608 RTP stream can begin using one candidate, and switch to another one, 1609 though this happens rarely with ICE. The newer candidate may result 1610 in RTP packets taking a different path through the network - one with 1611 different delay characteristics. As discussed below, agents are 1612 encouraged to re-adjust jitter buffers when there are changes in 1613 source or destination address. Furthermore, many audio codecs use 1614 the marker bit to signal the beginning of a talkspurt, for the 1615 purposes of jitter buffer adaptation. For such codecs, it is 1616 RECOMMENDED that the sender change the marker bit when an agent 1617 switches transmission of media from one candidate pair to another. 1619 11.2. Receiving Media 1621 ICE implementations MUST be prepared to receive media on any 1622 candidates provided in the most recent offer/answer exchange. In 1623 order to avoid attacks described in Section 15, when an agent 1624 receives a media packet, and it knows its peer supports ICE, it MUST 1625 verify that it has received a check (for which a successful response 1626 was generated) on the same 5-tuple as the received media packet (that 1627 is, the source and destination transport addresses of the media 1628 packet match those of the check). If no such check has succeeded, 1629 the agent MUST silently discard the media packet. 1631 It is RECOMMENDED that, when an agent receives an RTP packet with a 1632 new source or destination IP address for a particular media stream, 1633 that the agent re-adjust its jitter buffers. 1635 RFC 3550 [20] describes an algorithm in Section 8.2 for detecting 1636 SSRC collisions and loops. These algorithms are based, in part, on 1637 seeing different source IP addresses and ports with the same SSRC. 1638 However, when ICE is used, such changes will sometimes occur as the 1639 media streams switch between candidates. An agent will be able to 1640 determine that a media stream is from the same peer as a consequence 1641 of the STUN exchange that proceeds media transmission. Thus, if 1642 there is a change in source IP address and port, but the media 1643 packets come from the same peer agent, this SHOULD NOT be treated as 1644 an SSRC collision. 1646 12. Usage with SIP 1648 12.1. Latency Guidelines 1650 ICE requires a series of STUN-based connectivity checks to take place 1651 between endpoints. These checks start from the answerer on 1652 generation of its answer, and start from the offerer when it receives 1653 the answer. These checks can take time to complete, and as such, the 1654 selection of messages to use with offers and answers can effect 1655 perceived user latency. Two latency figures are of particular 1656 interest. These are the post-pickup delay and the post-dial delay. 1657 The post-pickup delay refers to the time between when a user "answers 1658 the phone" and when any speech they utter can be delivered to the 1659 caller. The post-dial delay refers to the time between when a user 1660 enters the destination address for the user, and ringback begins as a 1661 consequence of having succesfully started ringing the phone of the 1662 called party. 1664 To reduce post-dial delays, it is RECOMMENDED that the caller begin 1665 gathering candidates prior to actually sending its initial INVITE. 1666 This can be started upon user interface cues that a call is pending, 1667 such as activity on a keypad or the phone going offhook. 1669 If an offer is received in an INVITE request, the callee SHOULD 1670 immediately gather its candidates and then generate an answer in a 1671 provisional response. When reliable provisional responses are not 1672 used, the SDP in the provisional response is the answer, and that 1673 exact same answer reappears in the 200 OK. To deal with possible 1674 losses of the provisional response, it SHOULD be retransmitted until 1675 some indication of receipt. This indication can either be through 1676 PRACK [9], or through the receipt of a successful STUN Binding 1677 Request. Even if PRACK is not used, the provisional response SHOULD 1678 be retransmitted using the exponential backoff described in [9]. 1679 Furthermore, once the answer has been sent, the agent SHOULD begin 1680 its connectivity checks. Once candidate pairs for each component of 1681 a media stream enter the valid list, the callee can begin sending 1682 media on that media stream. 1684 However, prior to this point, any media that needs to be sent towards 1685 the caller (such as SIP early media [25] cannot be transmitted. For 1686 this reason, implementations SHOULD delay alerting the called party 1687 until candidates for each component of each media stream have entered 1688 the valid list. In the case of a PSTN gateway, this would mean that 1689 the setup message into the PSTN is delayed until this point. Doing 1690 this increases the post-dial delay, but has the effect of eliminating 1691 'ghost rings'. Ghost rings are cases where the called party hears 1692 the phone ring, picks up, but hears nothing and cannot be heard. 1693 This technique works without requiring support for, or usage of, 1694 preconditions [6], since its a localized decision. It also has the 1695 benefit of guaranteeing that not a single packet of media will get 1696 clipped, so that post-pickup delay is zero. If an agent chooses to 1697 delay local alerting in this way, it SHOULD generate a 180 response 1698 once alerting begins. 1700 Based on the rules in Section 11.1, the offerer will not be able to 1701 send media until the highest priority valid candidates match the m/c- 1702 line. When used with SIP, if the initial offer is sent in the 1703 INVITE, and the answer is sent in both the provisional and final 200 1704 OK response, the offerer will generally not be able to send media 1705 until it sends a re-INVITE and receives the 200 OK response to that 1706 re-INVITE. This can take several hundred milliseconds. If this 1707 latency is an issue (it is generally not considered an issue for 1708 voice systems), reliable provisional responses [9] MAY be used, in 1709 which case an UPDATE [24] can be used to send an updated offer prior 1710 to the call being answered. 1712 As discussed in Section 15, offer/answer exchanges SHOULD be secured 1713 against eavesdropping and man-in-the-middle attacks. To do that, the 1714 usage of SIPS [3] is RECOMMENDED when used in concert with ICE. 1716 12.2. Interactions with Forking 1718 ICE interacts very well with forking. Indeed, ICE fixes some of the 1719 problems associated with forking. Without ICE, when a call forks and 1720 the caller receives multiple incoming media streams, it cannot 1721 determine which media stream corresponds to which callee. 1723 With ICE, this problem is resolved. The connectivity checks which 1724 occur prior to transmission of media carry username fragments, which 1725 in turn are correlated to a specific callee. Subsequent media 1726 packets which arrive on the same 5-tuple as the connectivity check 1727 will be associated with that same callee. Thus, the caller can 1728 perform this correlation as long as it has received an answer. 1730 Section 11.2 introduces a requirement for agents receiving media; 1731 namely, that media should be discarded until a check has been 1732 received from that peer. Unfortunately, this mechanism doesn't work 1733 well in forking situations where a subset of the recipients are not 1734 ICE-aware. Those recipients will not send checks, and media from 1735 them will be discarded. 1737 OPEN ISSUE: Obviously this is an issue. Need to either remove 1738 this feature of ICE or find a way to make it work better in 1739 forking situations. 1741 12.3. Interactions with Preconditions 1743 Quality of Service (QoS) preconditions, which are defined in RFC 3312 1744 [6] and RFC 4032 [7], apply only to the IP addresses and ports listed 1745 in the m/c lines in an offer/answer. If ICE changes the address and 1746 port where media is received, this change is reflected in the m/c 1747 lines of a new offer/answer. As such, it appears like any other re- 1748 INVITE would, and is fully treated in RFC 3312 and 4032, which apply 1749 without regard to the fact that the m/c lines are changing due to ICE 1750 negotiations ocurring "in the background". 1752 Indeed, an agent SHOULD NOT indicate that Qos preconditions have been 1753 met until the ICE checks have completed and selected the candidate 1754 pairs to be used for media. 1756 ICE also has (purposeful) interactions with connectivity 1757 preconditions [26]. Those interactions are described there. 1759 OPEN ISSUE: Are these preconditions really needed with ICE? ICE 1760 provides a connectivity precondition on its own using the 1761 mechanisms described above. 1763 12.4. Interactions with Third Party Call Control 1765 ICE works with Flows I and IV as described in [16]. Flow I works 1766 without the controller supporting or being aware of ICE. Flow IV 1767 will work as long as the controller passes along the ICE attributes 1768 without alteration. Flow III may disrupt ICE processing, since it 1769 will distort the stream ID values used in the computation of 1770 priorities. When there is but a single media stream, Flow III will 1771 work as long as the controller passes through the ICE attributes 1772 unmodified. Flow II is fundamentally incompatible with ICE; each 1773 agent will believe itself to be the answerer and thus never generate 1774 a re-INVITE. 1776 OPEN ISSUE: Its really too bad flow III doesn't work with 1777 multimedia; should consider ways to make it work. There are 1778 several ways. 1780 The flows for continued operation, as described in Section 7 of RFC 1781 3725, require additional behavior of ICE implementations to support. 1782 In particular, if an agent receives a mid-dialog re-INVITE that 1783 contains no offer, it MUST go through the process of gathering 1784 candidates, prioritizing them and generating an offer, as if this was 1785 an initial offer for a session. Furthermore, that list of candidates 1786 SHOULD include the ones currently in-use. 1788 13. Grammar 1790 This specification defines four new SDP attributes - the "candidate", 1791 "remote-candidates", "ice-ufrag" and "ice-pwd" attributes. 1793 The candidate attribute is a media-level attribute only. It contains 1794 a transport address for a candidate that can be used for connectivity 1795 checks. 1797 The syntax of this attribute is defined using Augmented BNF as 1798 defined in RFC 4234 [8]: 1800 candidate-attribute = "candidate" ":" foundation SP component-id SP 1801 transport SP 1802 priority SP 1803 connection-address SP ;from RFC 4566 1804 port ;port from RFC 4566 1805 [SP cand-type] 1806 [SP rel-addr] 1807 [SP rel-port] 1808 *(SP extension-att-name SP 1809 extension-att-value) 1811 foundation = 1*ice-char 1812 component-id = 1*DIGIT 1813 transport = "UDP" / transport-extension 1814 transport-extension = token ; from RFC 3261 1815 priority = 1*DIGIT 1816 cand-type = "typ" SP candidate-types 1817 candidate-types = "host" / "srflx" / "prflx" / "relay" / token 1818 rel-addr = "raddr" SP connection-address 1819 rel-port = "rport" SP port 1820 extension-att-name = byte-string ;from RFC 4566 1821 extension-att-value = byte-string 1822 ice-char = ALPHA / DIGIT / "+" / "/" 1824 The foundation is composed of one or more ice-char. The component-id 1825 is a positive integer, which identifies the specific component for 1826 which the transport address is a candidate. It MUST start at 1 and 1827 MUST increment by 1 for each component of a particular candidate. 1828 The connect-address production is taken from RFC 4566 [10], allowing 1829 for IPv4 addresses, IPv6 addresses and FQDNs. The port production is 1830 also taken from RFC 4566 [10]. The token production is taken from 1831 RFC 3261 [3]. The transport production indicates the transport 1832 protocol for the candidate. This specification only defines UDP. 1833 However, extensibility is provided to allow for future transport 1834 protocols to be used with ICE, such as TCP or the Datagram Congestion 1835 Control Protocol (DCCP) [28]. 1837 The cand-type production encodes the type of candidate. This 1838 specification defines the values "host", "srflx", "prflx" and "relay" 1839 for host, server reflexive, peer reflexive and relayed candidates, 1840 respectively. The set of candidate types is extensible for the 1841 future. Inclusion of the candidate type is optional. The rel-addr 1842 and rel-port productions convey information the related transport 1843 addresses. Rules for inclusion of these values is described in 1844 Section 4.4. 1846 The a=candidate attribute can itself be extended. The grammar allows 1847 for new name/value pairs to be added at the end of the attribute. An 1848 implementation MUST ignore any name/value pairs it doesn't 1849 understand. 1851 The syntax of the "remote-candidates" attribute is defined using 1852 Augmented BNF as defined in RFC 4234 [8]. The remote-candidates 1853 attribute is a media level attribute only. 1855 remote-candidate-att = "remote-candidates" ":" remote-candidate 1856 0*(SP remote-candidate) 1857 remote-candidate = component-ID SP connection-address SP port 1859 The attribute contains a connection-address and port for each 1860 component. The ordering of components is irrelevant. However, a 1861 value MUST be present for each component of a media stream. 1863 The syntax of the "ice-pwd" and "ice-ufrag" attributes are defined 1864 as: 1866 ice-pwd-att = "ice-pwd" ":" password 1867 ice-ufrag-att = "ice-ufrag" ":" ufrag 1868 password = 22*ice-char 1869 ufrag = 4*ice-char 1871 The "ice-pwd" and "ice-ufrag" attributes can appear at either the 1872 session-level or media-level. When present in both, the value in the 1873 media-level takes precedence. Thus, the value at the session level 1874 is effectively a default that applies to all media streams, unless 1875 overriden by a media-level value. 1877 14. Example 1879 Two agents, L and R, are using ICE. Both agents have a single IPv4 1880 interface. For agent L, it is 10.0.1.1, and for agent R, 192.0.2.1. 1881 Both are configured with a single STUN server each (indeed, the same 1882 one for each), which is listening for STUN requests at an IP address 1883 of 192.0.2.2 and port 3478. This STUN server supports both the 1884 Binding Discovery usage and the Relay usage. Agent L is behind a 1885 NAT, and agent R is on the public Internet. The NAT has an endpoint 1886 independent mapping property and an address dependent filtering 1887 property. The public side of the NAT has an IP address of 192.0.2.3. 1889 To facilitate understanding, transport addresses are listed using 1890 variables that have mnemonic names. The format of the name is 1891 entity-type-seqno, where entity refers to the entity whose interface 1892 the transport address is on, and is one of "L", "R", "STUN", or 1893 "NAT". The type is either "PUB" for transport addresses that are 1894 public, and "PRIV" for transport addresses that are private. 1895 Finally, seq-no is a sequence number that is different for each 1896 transport address of the same type on a particular entity. Each 1897 variable has an IP address and port, denoted by varname.IP and 1898 varname.PORT, respectively, where varname is the name of the 1899 variable. 1901 The STUN server has advertised transport address STUN-PUB-1 (which is 1902 192.0.2.2:3478) for both the binding discovery usage and the relay 1903 usage. However, neither agent is using the relay usage. 1905 In the call flow itself, STUN messages are annotated with several 1906 attributes. The "S=" attribute indicates the source transport 1907 address of the message. The "D=" attribute indicates the destination 1908 transport address of the message. The "MA=" attribute is used in 1909 STUN Binding Response messages and refers to the mapped address. 1911 The call flow examples omit STUN authentication operations and RTCP, 1912 and focus on RTP for a single media stream. 1914 L NAT STUN R 1915 |RTP STUN alloc. | | 1916 |(1) STUN Req | | | 1917 |S=$L-PRIV-1 | | | 1918 |D=$STUN-PUB-1 | | | 1919 |------------->| | | 1920 | |(2) STUN Req | | 1921 | |S=$NAT-PUB-1 | | 1922 | |D=$STUN-PUB-1 | | 1923 | |------------->| | 1924 | |(3) STUN Res | | 1925 | |S=$STUN-PUB-1 | | 1926 | |D=$NAT-PUB-1 | | 1927 | |MA=$NAT-PUB-1 | | 1928 | |<-------------| | 1929 |(4) STUN Res | | | 1930 |S=$STUN-PUB-1 | | | 1931 |D=$L-PRIV-1 | | | 1932 |MA=$NAT-PUB-1 | | | 1933 |<-------------| | | 1934 |(5) Offer | | | 1935 |------------------------------------------->| 1936 | | | |RTP STUN alloc. 1937 | | |(6) STUN Req | 1938 | | |S=$R-PUB-1 | 1939 | | |D=$STUN-PUB-1 | 1940 | | |<-------------| 1941 | | |(7) STUN Res | 1942 | | |S=$STUN-PUB-1 | 1943 | | |D=$R-PUB-1 | 1944 | | |MA=$R-PUB-1 | 1945 | | |------------->| 1946 |(8) answer | | | 1947 |<-------------------------------------------| 1948 | |(9) Bind Req | | 1949 | |S=$R-PUB-1 | | 1950 | |D=L-PRIV-1 | | 1951 | |<----------------------------| 1952 | |Dropped | | 1953 |(10) Bind Req | | | 1954 |S=$L-PRIV-1 | | | 1955 |D=$R-PUB-1 | | | 1956 |------------->| | | 1957 | |(11) Bind Req | | 1958 | |S=$NAT-PUB-1 | | 1959 | |D=$R-PUB-1 | | 1960 | |---------------------------->| 1961 | |(12) Bind Res | | 1962 | |S=$R-PUB-1 | | 1963 | |D=$NAT-PUB-1 | | 1964 | |MA=$NAT-PUB-1 | | 1965 | |<----------------------------| 1966 |(13) Bind Res | | | 1967 |S=$R-PUB-1 | | | 1968 |D=$L-PRIV-1 | | | 1969 |MA=$NAT-PUB-1 | | | 1970 |<-------------| | | 1971 |(14) Offer | | | 1972 |------------------------------------------->| 1973 |(15) Answer | | | 1974 |<-------------------------------------------| 1975 | |(16) Bind Req | | 1976 | |S=$R-PUB-1 | | 1977 | |D=$NAT-PUB-1 | | 1978 | |<----------------------------| 1979 |(17) Bind Req | | | 1980 |S=$R-PUB-1 | | | 1981 |D=$L-PRIV-1 | | | 1982 |<-------------| | | 1983 |(18) Bind Res | | | 1984 |S=$L-PRIV-1 | | | 1985 |D=$R-PUB-1 | | | 1986 |MA=$R-PUB-1 | | | 1987 |------------->| | | 1988 | |(19) Bind Res | | 1989 | |S=$NAT-PUB-1 | | 1990 | |D=$R-PUB-1 | | 1991 | |MA=$R-PUB-1 | | 1992 | |---------------------------->| 1993 |RTP flows | | | 1995 Figure 9 1997 First, agent L obtains a host candidate from its local interface (not 1998 shown), and from that, sends a STUN Binding Request to the STUN 1999 server to get a server reflexive candidate (messages 1-4). Recall 2000 that the NAT has the address and port independent mapping property. 2001 Here, it creates a binding of NAT-PUB-1 for this UDP request, and 2002 this becomes the server reflexive candidate for RTP. 2004 Agent L sets a type preference of 9 for the host candidate and 5 for 2005 the server reflexive. The local preference is 9. Based on this, the 2006 priority of the host candidate is 9909 and for the server reflexive 2007 candidate is 5909. The host candidate is assigned a foundation of 1, 2008 and the server reflexive, a foundation of 2. It chooses its server 2009 reflexive candidate as the in-use candidate, and encodes it into the 2010 m/c-line. The resulting offer (message 5) looks like (lines folded 2011 for clarity): 2013 v=0 2014 o=jdoe 2890844526 2890842807 IN IP4 $L-PRIV-1.IP 2015 s= 2016 c=IN IP4 $NAT-PUB-1.IP 2017 t=0 0 2018 a=ice-pwd:asd88fgpdd777uzjYhagZg 2019 a=ice-ufrag:8hhY 2020 m=audio $NAT-PUB-1.PORT RTP/AVP 0 2021 a=rtpmap:0 PCMU/8000 2022 a=candidate:1 1 UDP 9909 $L-PRIV-1.IP $L-PRIV-1.PORT typ local 2023 a=candidate:2 1 UDP 5909 $NAT-PUB-1.IP $NAT-PUB-1.PORT typ srflx raddr 2024 $L-PRIV-1.IP rport $L-PRIV-1.PORT 2026 The offer, with the variables replaced with their values, will look 2027 like (lines folded for clarity): 2029 v=0 2030 o=jdoe 2890844526 2890842807 IN IP4 10.0.1.1 2031 s= 2032 c=IN IP4 192.0.2.3 2033 t=0 0 2034 a=ice-pwd:asd88fgpdd777uzjYhagZg 2035 a=ice-ufrag:8hhY 2036 m=audio 45664 RTP/AVP 0 2037 a=rtpmap:0 PCMU/8000 2038 a=candidate:1 1 UDP 9909 10.0.1.1 8998 typ local 2039 a=candidate:2 1 UDP 5909 192.0.2.3 45664 typ srflx raddr 2040 10.0.1.1 rport 8998 2042 This offer is received at agent R. Agent R will obtain a host 2043 candidate, and from it, obtain a server reflexive candidate (messages 2044 6-7). Since R is not behind a NAT, this candidate is identical to 2045 its host candidate, and they share the same base. It therefore 2046 discards this candidate and ends up with a single host candidate. 2047 With identical type and local preferences as L, the priority for this 2048 candidate is 9909. It chooses a foundation of 1 for its single 2049 candidate. Its resulting answer looks like: 2051 v=0 2052 o=bob 2808844564 2808844564 IN IP4 $R-PUB-1.IP 2053 s= 2054 c=IN IP4 $R-PUB-1.IP 2055 t=0 0 2056 a=ice-pwd:YH75Fviy6338Vbrhrlp8Yh 2057 a=ice-ufrag:9uB6 2058 m=audio $R-PUB-1.PORT RTP/AVP 0 2059 a=rtpmap:0 PCMU/8000 2060 a=candidate:1 1 UDP 9909 $R-PUB-1.IP $R-PUB-1.PORT typ local 2062 With the variables filled in: 2064 v=0 2065 o=bob 2808844564 2808844564 IN IP4 192.0.2.1 2066 s= 2067 c=IN IP4 192.0.2.1 2068 t=0 0 2069 a=ice-pwd:YH75Fviy6338Vbrhrlp8Yh 2070 a=ice-ufrag:9uB6 2071 m=audio 3478 RTP/AVP 0 2072 a=rtpmap:0 PCMU/8000 2073 a=candidate:1 1 UDP 9909 192.0.2.1 3478 typ local 2075 Agents L and R both pair up the candidates. They both initially have 2076 two. However, agent L will prune the pair containing its server 2077 reflexive candidate, resulting in just one. At agent L, this pair 2078 (the check) has a local candidate of $L_PRIV_1 and remote candidate 2079 of $R_PUB_1, and has a candidate pair priority of 99099909.039. At 2080 agent R, there are two checks. The highest priority has a local 2081 candidate of $R_PUB_1 and remote candidate of $L_PRIV_1 and has a 2082 priority of 99099909.039, and the second has a local candidate of 2083 $R_PUB_1 and remote candidate of $NAT_PUB_1 and priority 59099909.75. 2085 Agent R begins its connectivity check (message 9) for the first pair 2086 (between the two host candidates). The host candidate from agent L 2087 is private and behind a different NAT, and thus this check is 2088 discarded. 2090 When agent L gets the answer, it performs its one and only 2091 connectivity check (messages 10-13). This will succeed. This causes 2092 agent L to create a new pair, whos local candidate is from the mapped 2093 address in the binding response (NAT-PUB-1 from message 13) and whose 2094 remote candidate is the destination of the request (R-PUB-1 from 2095 message 10). This is added to the valid list. At this point, agent 2096 L examines the valid list and sees that there is a candidate there 2097 for each component of each media stream (which is just RTP for the 2098 single audio stream). It therefore considers ICE checks complete and 2099 sends an updated offer (message 14). This offer serves only to 2100 remove the candidate that was not selected and indicate the remote 2101 candidates; the m/c-line remains unchanged. This offer looks like: 2103 v=0 2104 o=jdoe 2890844528 2890842809 IN IP4 10.0.1.1 2105 s= 2106 c=IN IP4 192.0.2.3 2107 t=0 0 2108 a=ice-pwd:asd88fgpdd777uzjYhagZg 2109 a=ice-ufrag:8hhY 2110 m=audio 45664 RTP/AVP 0 2111 a=remote-candidates 1 192.0.2.1 3478 2112 a=rtpmap:0 PCMU/8000 2113 a=candidate:2 1 UDP 5909 192.0.2.3 45664 typ srflx raddr 2114 10.0.1.1 rport 8998 2116 Agent R can construct the answer. Since the remote-candidates listed 2117 in the offer match the ones that agent R had already selected for the 2118 m/c-line in the previous answer, there is no change there. Its 2119 answer therefore looks like: 2121 v=0 2122 o=bob 2808844565 2808844566 IN IP4 192.0.2.1 2123 s= 2124 c=IN IP4 192.0.2.1 2125 t=0 0 2126 a=ice-pwd:YH75Fviy6338Vbrhrlp8Yh 2127 a=ice-ufrag:9uB6 2128 m=audio 3478 RTP/AVP 0 2129 a=rtpmap:0 PCMU/8000 2130 a=candidate:1 1 UDP 9909 192.0.2.1 3478 typ local 2132 Upon receipt of the check from agent L (message 11), agent R will 2133 generate its triggered check. This check happens to match the next 2134 one on its check list - from its host candidate to agent L's server 2135 reflexive candidate. This check (messages 16-19) will succeed. 2136 Consequently, agent R constructs a new candidate pair using the 2137 mapped address from the response as the local candidate (R-PUB-1) and 2138 the destination of the request (NAT-PUB-1) as the remote candidate. 2139 This pair is added to the valid list. Since this pair matches the 2140 pair in the m/c-lines, agent R can send media as well. 2142 15. Security Considerations 2144 There are several types of attacks possible in an ICE system. This 2145 section considers these attacks and their countermeasures. 2147 15.1. Attacks on Connectivity Checks 2149 An attacker might attempt to disrupt the STUN connectivity checks. 2150 Ultimately, all of these attacks fool an agent into thinking 2151 something incorrect about the results of the connectivity checks. 2152 The possible false conclusions an attacker can try and cause are: 2154 False Invalid: An attacker can fool a pair of agents into thinking a 2155 candidate pair is invalid, when it isn't. This can be used to 2156 cause an agent to prefer a different candidate (such as one 2157 injected by the attacker), or to disrupt a call by forcing all 2158 candidates to fail. 2160 False Valid: An attacker can fool a pair of agents into thinking a 2161 candidate pair is valid, when it isn't. This can cause an agent 2162 to proceed with a session, but then not be able to receive any 2163 media. 2165 False Peer-Reflexive Candidate: An attacker can cause an agent to 2166 discover a new peer reflexive candidate, when it shouldn't have. 2167 This can be used to redirect media streams to a DoS target or to 2168 the attacker, for eavesdropping or other purposes. 2170 False Valid on False Candidate: An attacker has already convinced an 2171 agent that there is a candidate with an address that doesn't 2172 actually route to that agent (for example, by injecting a false 2173 peer reflexive candidate or false server reflexive candidate). It 2174 must then launch an attack that forces the agents to believe that 2175 this candidate is valid. 2177 Of the various techniques for creating faked STUN messages described 2178 in [11], many are not applicable for the connectivity checks. 2179 Compromises of STUN servers are not much of a concern, since the STUN 2180 servers are embedded in endpoints and distributed throughout the 2181 network. Thus, compromising the STUN server is equivalent to 2182 comprimising the endpoint, and if that happens, far more problematic 2183 attacks are possible than those against ICE. Similarly, DNS attacks 2184 are usually irrelevant since STUN servers are not typically 2185 discovered via DNS, they are signaled via IP addresses embedded in 2186 SDP. Injection of fake responses and relaying modified requests all 2187 can be handled in ICE with the countermeasures discussed below. 2189 To force the false invalid result, the attacker has to wait for the 2190 connectivity check from one of the agents to be sent. When it is, 2191 the attacker needs to inject a fake response with an unrecoverable 2192 error response, such as a 600. However, since the candidate is, in 2193 fact, valid, the original request may reach the peer agent, and 2194 result in a success response. The attacker needs to force this 2195 packet or its response to be dropped, through a DoS attack, layer 2 2196 network disruption, or other technique. If it doesn't do this, the 2197 success response will also reach the originator, alerting it to a 2198 possible attack. Fortunately, this attack is mitigated completely 2199 through the STUN message integrity mechanism. The attacker needs to 2200 inject a fake response, and in order for this response to be 2201 processed, the attacker needs the password. If the offer/answer 2202 signaling is secured, the attacker will not have the password. 2204 Forcing the fake valid result works in a similar way. The agent 2205 needs to wait for the Binding Request from each agent, and inject a 2206 fake success response. The attacker won't need to worry about 2207 disrupting the actual response since, if the candidate is not valid, 2208 it presumably wouldn't be received anyway. However, like the fake 2209 invalid attack, this attack is mitigated completely through the STUN 2210 message integrity and offer/answer security techniques. 2212 Forcing the false peer reflexive candidate result can be done either 2213 with fake requests or responses, or with replays. We consider the 2214 fake requests and responses case first. It requires the attacker to 2215 send a Binding Request to one agent with a source IP address and port 2216 for the false candidate. In addition, the attacker must wait for a 2217 Binding Request from the other agent, and generate a fake response 2218 with a XOR-MAPPED-ADDRESS attribute containing the false candidate. 2219 Like the other attacks described here, this attack is mitigated by 2220 the STUN message integrity mechanisms and secure offer/answer 2221 exchanges. 2223 Forcing the false peer reflexive candidate result with packet replays 2224 is different. The attacker waits until one of the agents sends a 2225 check. It intercepts this request, and replays it towards the other 2226 agent with a faked source IP address. It must also prevent the 2227 original request from reaching the remote agent, either by launching 2228 a DoS attack to cause the packet to be dropped, or forcing it to be 2229 dropped using layer 2 mechanisms. The replayed packet is received at 2230 the other agent, and accepted, since the integrity check passes (the 2231 integrity check cannot and does not cover the source IP address and 2232 port). It is then responded to. This response will contain a XOR- 2233 MAPPED-ADDRESS with the false candidate, and will be sent to that 2234 false candidate. The attacker must then intercept it and relay it 2235 towards the originator. 2237 The other agent will then initiate a connectivity check towards that 2238 false candidate. This validation needs to succeed. This requires 2239 the attacker to force a false valid on a false candidate. Injecting 2240 of fake requests or responses to achieve this goal is prevented using 2241 the integrity mechanisms of STUN and the offer/answer exchange. 2242 Thus, this attack can only be launched through replays. To do that, 2243 the attacker must intercept the check towards this false candidate, 2244 and replay it towards the other agent. Then, it must intercept the 2245 response and replay that back as well. 2247 This attack is very hard to launch unless the attacker themself is 2248 identified by the fake candidate. This is because it requires the 2249 attacker to intercept and replay packets sent by two different hosts. 2250 If both agents are on different networks (for example, across the 2251 public Internet), this attack can be hard to coordinate, since it 2252 needs to occur against two different endpoints on different parts of 2253 the network at the same time. 2255 If the attacker themself is identified by the fake candidate the 2256 attack is easier to coordinate. However, if SRTP is used [21], the 2257 attacker will not be able to play the media packets, they will only 2258 be able to discard them, effectively disabling the media stream for 2259 the call. However, this attack requires the agent to disrupt packets 2260 in order to block the connectivity check from reaching the target. 2262 In that case, if the goal is to disrupt the media stream, its much 2263 easier to just disrupt it with the same mechanism, rather than attack 2264 ICE. 2266 15.2. Attacks on Address Gathering 2268 ICE endpoints make use of STUN for gathering candidates rom a STUN 2269 server in the network. This is corresponds to the Binding Discovery 2270 usage of STUN described in [11]. As a consequence, the attacks 2271 against STUN itself that are described in that specification can 2272 still be used against the binding discovery usage when utilized with 2273 ICE. 2275 However, the additional mechanisms provided by ICE actually 2276 counteract such attacks, making binding discovery with STUN more 2277 secure when combined with ICE than without ICE. 2279 Consider an attacker which is able to provide an agent with a faked 2280 mapped address in a STUN Binding Request that is used for address 2281 gathering. This is the primary attack primitive described in [11]. 2282 This address will be used as a server reflexive candidate in the ICE 2283 exchange. For this candidate to actually be used for media, the 2284 attacker must also attack the connectivity checks, and in particular, 2285 force a false valid on a false candidate. This attack is very hard 2286 to launch if the false address identifies a third party, and is 2287 prevented by SRTP if it identifies the attacker themself. 2289 If the attacker elects not to attack the connectivity checks, the 2290 worst it can do is prevent the server reflexive candidate from being 2291 used. However, if the peer agent has at least one candidate that is 2292 reachable by the agent under attack, the STUN connectivity checks 2293 themselves will provide a peer reflexive candidate that can be used 2294 for the exchange of media. Peer reflexive candidates are generally 2295 preferred over server reflexive candidates. As such, an attack 2296 solely on the STUN address gathering will normally have no impact on 2297 a session at all. 2299 15.3. Attacks on the Offer/Answer Exchanges 2301 An attacker that can modify or disrupt the offer/answer exchanges 2302 themselves can readily launch a variety of attacks with ICE. They 2303 could direct media to a target of a DoS attack, they could insert 2304 themselves into the media stream, and so on. These are similar to 2305 the general security considerations for offer/answer exchanges, and 2306 the security considerations in RFC 3264 [4] apply. These require 2307 techniques for message integrity and encryption for offers and 2308 answers, which are satisfied by the SIPS mechanism [3] when SIP is 2309 used. As such, the usage of SIPS with ICE is RECOMMENDED. 2311 15.4. Insider Attacks 2313 In addition to attacks where the attacker is a third party trying to 2314 insert fake offers, answers or stun messages, there are several 2315 attacks possible with ICE when the attacker is an authenticated and 2316 valid participant in the ICE exchange. 2318 15.4.1. The Voice Hammer Attack 2320 The voice hammer attack is an amplification attack. In this attack, 2321 the attacker initiates sessions to other agents, and includes the IP 2322 address and port of a DoS target in the m/c-line of their SDP. This 2323 causes substantial amplification; a single offer/answer exchange can 2324 create a continuing flood of media packets, possibly at high rates 2325 (consider video sources). This attack is not specific to ICE, but 2326 ICE can help provide remediation. 2328 Specifically, if ICE is used, the agent receiving the malicious SDP 2329 will first peform connectivity checks to the target of media before 2330 sending it there. If this target is a third party host, the checks 2331 will not succeed, and media is never sent. 2333 Unfortunately, ICE doesn't help if its not used, in which case an 2334 attacker could simply send the offer without the ICE parameters. 2335 However, in environments where the set of clients are known, and 2336 limited to ones that support ICE, the server can reject any offers or 2337 answers that don't indicate ICE support. 2339 15.4.2. STUN Amplification Attack 2341 The STUN amplification attack is similar to the voice hammer. 2342 However, instead of voice packets being directed to the target, STUN 2343 connectivity checks are directed to the target. This attack is 2344 accomplished by having the offerer send an offer with a large number 2345 of candidates, say 50. The answerer receives the offer, and starts 2346 its checks, which are directed at the target, and consequently, never 2347 generate a response. The answerer will start a new connectivity 2348 check every 50ms, and each check is a STUN transaction consisting of 2349 9 retransmits of a message 65 bytes in length (plus 28 bytes for the 2350 IP/UDP header) that runs for 7.9 seconds, for a total of 105 bytes/ 2351 second per transaction on average. In the worst case, there can be 2352 158 transactions in progress at once (7.9 seconds divided by 50ms), 2353 for a total of 132 kbps, just for STUN requests. 2355 It is impossible to eliminate the amplification, but the volume can 2356 be reduced through a variety of heuristics. For example, agents can 2357 limit the number of candidates they'll accept in an offer or answer, 2358 they can increase the value of Ta, or exponentially increase Ta as 2359 time goes on. All of these ultimately trade off the time for the ICE 2360 exchanges to complete, with the amount of traffic that gets sent. 2362 OPEN ISSUE: Need better remediation for this. Especially an issue 2363 if we reduce Ta to be as fast as media packets themselves, in 2364 which case this attack is as equally devastating as the voice 2365 hammer. 2367 16. IANA Considerations 2369 This specification defines four new SDP attributes per the procedures 2370 of Section 8.2.4 of [10]. The required information for the 2371 registrations are included here. 2373 16.1. candidate Attribute 2375 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2377 Attribute Name: candidate 2379 Long Form: candidate 2381 Type of Attribute: media level 2383 Charset Considerations: The attribute is not subject to the charset 2384 attribute. 2386 Purpose: This attribute is used with Interactive Connectivity 2387 Establishment (ICE), and provides one of many possible candidate 2388 addresses for communication. These addresses are validated with 2389 an end-to-end connectivity check using Simple Traversal Underneath 2390 NAT (STUN). 2392 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2393 please replace XXXX with the RFC number of this specification]. 2395 16.2. remote-candidates Attribute 2397 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2399 Attribute Name: remote-candidates 2401 Long Form: remote-candidates 2402 Type of Attribute: media level 2404 Charset Considerations: The attribute is not subject to the charset 2405 attribute. 2407 Purpose: This attribute is used with Interactive Connectivity 2408 Establishment (ICE), and provides the identity of the remote 2409 candidates that the offerer wishes the answerer to use in its 2410 answer. 2412 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2413 please replace XXXX with the RFC number of this specification]. 2415 16.3. ice-pwd Attribute 2417 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2419 Attribute Name: ice-pwd 2421 Long Form: ice-pwd 2423 Type of Attribute: session or media level 2425 Charset Considerations: The attribute is not subject to the charset 2426 attribute. 2428 Purpose: This attribute is used with Interactive Connectivity 2429 Establishment (ICE), and provides the password used to protect 2430 STUN connectivity checks. 2432 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2433 please replace XXXX with the RFC number of this specification]. 2435 16.4. ice-ufrag Attribute 2437 Contact Name: Jonathan Rosenberg, jdrosen@jdrosen.net. 2439 Attribute Name: ice-ufrag 2441 Long Form: ice-ufrag 2443 Type of Attribute: session or media level 2445 Charset Considerations: The attribute is not subject to the charset 2446 attribute. 2448 Purpose: This attribute is used with Interactive Connectivity 2449 Establishment (ICE), and provides the fragments used to construct 2450 the username in STUN connectivity checks. 2452 Appropriate Values: See Section 13 of RFC XXXX [Note to RFC-ed: 2453 please replace XXXX with the RFC number of this specification]. 2455 17. IAB Considerations 2457 The IAB has studied the problem of "Unilateral Self Address Fixing", 2458 which is the general process by which a agent attempts to determine 2459 its address in another realm on the other side of a NAT through a 2460 collaborative protocol reflection mechanism [19]. ICE is an example 2461 of a protocol that performs this type of function. Interestingly, 2462 the process for ICE is not unilateral, but bilateral, and the 2463 difference has a signficant impact on the issues raised by IAB. 2464 Indeed, ICE can be considered a B-SAF (Bilateral Self-Address Fixing) 2465 protocol, rather than an UNSAF protocol. Regardless, the IAB has 2466 mandated that any protocols developed for this purpose document a 2467 specific set of considerations. This section meets those 2468 requirements. 2470 17.1. Problem Definition 2472 From RFC 3424 any UNSAF proposal must provide: 2474 Precise definition of a specific, limited-scope problem that is to 2475 be solved with the UNSAF proposal. A short term fix should not be 2476 generalized to solve other problems; this is why "short term fixes 2477 usually aren't". 2479 The specific problems being solved by ICE are: 2481 Provide a means for two peers to determine the set of transport 2482 addresses which can be used for communication. 2484 Provide a means for resolving many of the limitations of other 2485 UNSAF mechanisms by wrapping them in an additional layer of 2486 processing (the ICE methodology). 2488 Provide a means for a agent to determine an address that is 2489 reachable by another peer with which it wishes to communicate. 2491 17.2. Exit Strategy 2493 From RFC 3424, any UNSAF proposal must provide: 2495 Description of an exit strategy/transition plan. The better short 2496 term fixes are the ones that will naturally see less and less use 2497 as the appropriate technology is deployed. 2499 ICE itself doesn't easily get phased out. However, it is useful even 2500 in a globally connected Internet, to serve as a means for detecting 2501 whether a router failure has temporarily disrupted connectivity, for 2502 example. ICE also helps prevent certain security attacks which have 2503 nothing to do with NAT. However, what ICE does is help phase out 2504 other UNSAF mechanisms. ICE effectively selects amongst those 2505 mechanisms, prioritizing ones that are better, and deprioritizing 2506 ones that are worse. Local IPv6 addresses can be preferred. As NATs 2507 begin to dissipate as IPv6 is introduced, server reflexive and 2508 relayed candidates (both forms of UNSAF mechanisms) simply never get 2509 used, because higher priority connectivity exists to the native host 2510 candidates. Therefore, the servers get used less and less, and can 2511 eventually be remove when their usage goes to zero. 2513 Indeed, ICE can assist in the transition from IPv4 to IPv6. It can 2514 be used to determine whether to use IPv6 or IPv4 when two dual-stack 2515 hosts communicate with SIP (IPv6 gets used). It can also allow a 2516 network with both 6to4 and native v6 connectivity to determine which 2517 address to use when communicating with a peer. 2519 17.3. Brittleness Introduced by ICE 2521 From RFC3424, any UNSAF proposal must provide: 2523 Discussion of specific issues that may render systems more 2524 "brittle". For example, approaches that involve using data at 2525 multiple network layers create more dependencies, increase 2526 debugging challenges, and make it harder to transition. 2528 ICE actually removes brittleness from existing UNSAF mechanisms. In 2529 particular, traditional STUN (as described in RFC 3489 [13]) has 2530 several points of brittleness. One of them is the discovery process 2531 which requires a agent to try and classify the type of NAT it is 2532 behind. This process is error-prone. With ICE, that discovery 2533 process is simply not used. Rather than unilaterally assessing the 2534 validity of the address, its validity is dynamically determined by 2535 measuring connectivity to a peer. The process of determining 2536 connectivity is very robust. 2538 Another point of brittleness in traditional STUN and any other 2539 unilateral mechanism is its absolute reliance on an additional 2540 server. ICE makes use of a server for allocating unilateral 2541 addresses, but allows agents to directly connect if possible. 2542 Therefore, in some cases, the failure of a STUN server would still 2543 allow for a call to progress when ICE is used. 2545 Another point of brittleness in traditional STUN is that it assumes 2546 that the STUN server is on the public Internet. Interestingly, with 2547 ICE, that is not necessary. There can be a multitude of STUN servers 2548 in a variety of address realms. ICE will discover the one that has 2549 provided a usable address. 2551 The most troubling point of brittleness in traditional STUN is that 2552 it doesn't work in all network topologies. In cases where there is a 2553 shared NAT between each agent and the STUN server, traditional STUN 2554 may not work. With ICE, that restriction is removed. 2556 Traditional STUN also introduces some security considerations. 2557 Fortunately, those security considerations are also mitigated by ICE. 2559 Consequently, ICE serves to repair the brittleness introduced in 2560 other UNSAF mechanisms, and does not introduce any additional 2561 brittleness into the system. 2563 17.4. Requirements for a Long Term Solution 2565 From RFC 3424, any UNSAF proposal must provide: 2567 Identify requirements for longer term, sound technical solutions 2568 -- contribute to the process of finding the right longer term 2569 solution. 2571 Our conclusions from STUN remain unchanged. However, we feel ICE 2572 actually helps because we believe it can be part of the long term 2573 solution. 2575 17.5. Issues with Existing NAPT Boxes 2577 From RFC 3424, any UNSAF proposal must provide: 2579 Discussion of the impact of the noted practical issues with 2580 existing, deployed NA[P]Ts and experience reports. 2582 A number of NAT boxes are now being deployed into the market which 2583 try and provide "generic" ALG functionality. These generic ALGs hunt 2584 for IP addresses, either in text or binary form within a packet, and 2585 rewrite them if they match a binding. This interferes with 2586 traditional STUN. However, the update to STUN [11] uses an encoding 2587 which hides these binary addresses from generic ALGs. Since [11] is 2588 required for all ICE implementations, this NAPT problem does not 2589 impact ICE. 2591 Existing NAPT boxes have non-deterministic and typically short 2592 expiration times for UDP-based bindings. This requires 2593 implementations to send periodic keepalives to maintain those 2594 bindings. ICE uses a default of 15s, which is a very conservative 2595 estimate. Eventually, over time, as NAT boxes become compliant to 2596 behave [30], this minimum keepalive will become deterministic and 2597 well-known, and the ICE timers can be adjusted. Having a way to 2598 discover and control the minimum keepalive interval would be far 2599 better still. 2601 18. Acknowledgements 2603 The authors would like to thank Flemming Andreasen, Rohan Mahy, Dean 2604 Willis, Eric Cooper, Dan Wing, Douglas Otis, Tim Moore, and Francois 2605 Audet for their comments and input. A special thanks goes to Bill 2606 May, who suggested several of the concepts in this specification, 2607 Philip Matthews, who suggested many of the key performance 2608 optimizations in this specification, Eric Rescorla, who drafted the 2609 text in the introduction, and Magnus Westerlund, for doing several 2610 detailed reviews on the various revisions of this specification. 2612 19. References 2614 19.1. Normative References 2616 [1] Bradner, S., "Key words for use in RFCs to Indicate Requirement 2617 Levels", BCP 14, RFC 2119, March 1997. 2619 [2] Huitema, C., "Real Time Control Protocol (RTCP) attribute in 2620 Session Description Protocol (SDP)", RFC 3605, October 2003. 2622 [3] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, A., 2623 Peterson, J., Sparks, R., Handley, M., and E. Schooler, "SIP: 2624 Session Initiation Protocol", RFC 3261, June 2002. 2626 [4] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model with 2627 Session Description Protocol (SDP)", RFC 3264, June 2002. 2629 [5] Casner, S., "Session Description Protocol (SDP) Bandwidth 2630 Modifiers for RTP Control Protocol (RTCP) Bandwidth", RFC 3556, 2631 July 2003. 2633 [6] Camarillo, G., Marshall, W., and J. Rosenberg, "Integration of 2634 Resource Management and Session Initiation Protocol (SIP)", 2635 RFC 3312, October 2002. 2637 [7] Camarillo, G. and P. Kyzivat, "Update to the Session Initiation 2638 Protocol (SIP) Preconditions Framework", RFC 4032, March 2005. 2640 [8] Crocker, D. and P. Overell, "Augmented BNF for Syntax 2641 Specifications: ABNF", RFC 4234, October 2005. 2643 [9] Rosenberg, J. and H. Schulzrinne, "Reliability of Provisional 2644 Responses in Session Initiation Protocol (SIP)", RFC 3262, 2645 June 2002. 2647 [10] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 2648 Description Protocol", RFC 4566, July 2006. 2650 [11] Rosenberg, J., "Simple Traversal Underneath Network Address 2651 Translators (NAT) (STUN)", draft-ietf-behave-rfc3489bis-04 2652 (work in progress), July 2006. 2654 [12] Rosenberg, J., "Obtaining Relay Addresses from Simple Traversal 2655 of UDP Through NAT (STUN)", draft-ietf-behave-turn-01 (work in 2656 progress), June 2006. 2658 19.2. Informative References 2660 [13] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, "STUN 2661 - Simple Traversal of User Datagram Protocol (UDP) Through 2662 Network Address Translators (NATs)", RFC 3489, March 2003. 2664 [14] Senie, D., "Network Address Translator (NAT)-Friendly 2665 Application Design Guidelines", RFC 3235, January 2002. 2667 [15] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and A. 2668 Rayhan, "Middlebox communication architecture and framework", 2669 RFC 3303, August 2002. 2671 [16] Rosenberg, J., Peterson, J., Schulzrinne, H., and G. Camarillo, 2672 "Best Current Practices for Third Party Call Control (3pcc) in 2673 the Session Initiation Protocol (SIP)", BCP 85, RFC 3725, 2674 April 2004. 2676 [17] Borella, M., Lo, J., Grabelsky, D., and G. Montenegro, "Realm 2677 Specific IP: Framework", RFC 3102, October 2001. 2679 [18] Borella, M., Grabelsky, D., Lo, J., and K. Taniguchi, "Realm 2680 Specific IP: Protocol Specification", RFC 3103, October 2001. 2682 [19] Daigle, L. and IAB, "IAB Considerations for UNilateral Self- 2683 Address Fixing (UNSAF) Across Network Address Translation", 2684 RFC 3424, November 2002. 2686 [20] Schulzrinne, H., Casner, S., Frederick, R., and V. Jacobson, 2687 "RTP: A Transport Protocol for Real-Time Applications", 2688 RFC 3550, July 2003. 2690 [21] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 2691 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 2692 RFC 3711, March 2004. 2694 [22] Carpenter, B. and K. Moore, "Connection of IPv6 Domains via 2695 IPv4 Clouds", RFC 3056, February 2001. 2697 [23] Zopf, R., "Real-time Transport Protocol (RTP) Payload for 2698 Comfort Noise (CN)", RFC 3389, September 2002. 2700 [24] Rosenberg, J., "The Session Initiation Protocol (SIP) UPDATE 2701 Method", RFC 3311, October 2002. 2703 [25] Camarillo, G. and H. Schulzrinne, "Early Media and Ringing Tone 2704 Generation in the Session Initiation Protocol (SIP)", RFC 3960, 2705 December 2004. 2707 [26] Andreasen, F., "Connectivity Preconditions for Session 2708 Description Protocol Media Streams", 2709 draft-ietf-mmusic-connectivity-precon-02 (work in progress), 2710 June 2006. 2712 [27] Andreasen, F., "A No-Op Payload Format for RTP", 2713 draft-ietf-avt-rtp-no-op-00 (work in progress), May 2005. 2715 [28] Kohler, E., Handley, M., and S. Floyd, "Datagram Congestion 2716 Control Protocol (DCCP)", RFC 4340, March 2006. 2718 [29] Hellstrom, G. and P. Jones, "RTP Payload for Text 2719 Conversation", RFC 4103, June 2005. 2721 [30] Audet, F. and C. Jennings, "NAT Behavioral Requirements for 2722 Unicast UDP", draft-ietf-behave-nat-udp-07 (work in progress), 2723 June 2006. 2725 [31] Jennings, C. and R. Mahy, "Managing Client Initiated 2726 Connections in the Session Initiation Protocol (SIP)", 2727 draft-ietf-sip-outbound-04 (work in progress), June 2006. 2729 Appendix A. Design Motivations 2731 ICE contains a number of normative behaviors which may themselves be 2732 simple, but derive from complicated or non-obvious thinking or use 2733 cases which merit further discussion. Since these design motivations 2734 are not neccesary to understand for purposes of implementation, they 2735 are discussed here in an appendix to the specification. This section 2736 is non-normative. 2738 A.1. Applicability to Gateways and Servers 2740 Section 4.1 discusses procedures for gathering candidates, including 2741 host, server reflexive and relayed. In that section, recommendations 2742 are given for when an agent should obtain each of these three types. 2743 In particular, for agents embedded in PSTN gateways, media servers, 2744 conferencing servers, and so on, ICE specifies that an agent can 2745 stick with just host candidates, since it has a public IP address. 2747 This leads to an important question - why would such an endpoint even 2748 bother with ICE? If it has a public IP address, what additional 2749 value do the ICE procedures bring? There are many, actually. 2751 First, doing so greatly facilitates NAT traversal for clients that 2752 connect to it. Consider a PC softphone behind a NAT whose mapping 2753 policy is address and port dependent. The softphone initiates a call 2754 through a gateway that implements ICE. The gateway doesn't obtain 2755 any server reflexive or relayed candidates, but it implements ICE, 2756 and consequently, is prepared to receive STUN connectivity checks on 2757 its host candidates. The softphone will send a STUN connectivity 2758 check to the gateway, which passes through the intervending NAT. 2759 This causes the NAT to allocate a new binding for the softphone. The 2760 connectivity is received by the gateway, and will cause it gateway to 2761 send a check back to the softphone, at this newly created candidate. 2762 A successful response confirms that this candidate is usable, and the 2763 gateway can send media immediately to the softphone. This allows 2764 direct media transmission between the gateway and softphone, without 2765 the need for relays, even though the softphone was behind a 'bad' 2766 NAT. 2768 Second, implementation of the STUN connectivity checks allows for NAT 2769 bindings along the way to be kept open. Keeping these bindings open 2770 is essential for continued communications between the gateway and 2771 softphone. 2773 Third, ICE prevents a fairly destructive attack in multimedia 2774 systems, called the voice hammer. The STUN connectivity check used 2775 by an ICE endpoint allows it to be certain that the target of media 2776 packets is, in fact, the same entity that requested the packets 2777 through the offer/answer exchange. See Section 15 for a more 2778 complete discussion on this attack. 2780 A.2. Pacing of STUN Transactions 2782 STUN transactions used to gather candidates and to verify 2783 connectivity are paced out at an approximate rate of one new 2784 transaction every Ta seconds, where Ta has a default of 50ms. Why 2785 are these transactions paced, and why was 50ms chosen as default? 2787 Sending of these STUN requests will often have the effect of creating 2788 bindings on NAT devices between the client and the STUN servers. 2789 Experience has shown that many NAT devices have upper limits on the 2790 rate at which they will create new bindings. Furthermore, 2791 transmission of these packets on the network makes use of bandwidth 2792 and needs to be rate limited by the agent. As a consequence, the 2793 pacing ensures that the NAT devices does not get overloaded and that 2794 traffic is kept at a reasonable rate. 2796 Another aspect of the STUN requests is their bandwidth usage. In 2797 ICE, each STUN request contains the STUN 20 byte header, in addition 2798 to the USERNAME, MESSAGE-INTEGRITY and PRIORITY attributes. The 2799 USERNAME attribute contains a 4-byte attribute overhead, plus the 2800 username value itself. This username is the concatenation of the two 2801 fragments, plus a colon. Each fragment is supposed to be at least 4 2802 bytes long, making the total length of the USERNAME attribute (4*2 + 2803 1 + 4) = 13 bytes. The MESSAGE-INTEGRITY attribute is 4 bytes of 2804 overhead plus 20 bytes value, for 24 bytes. The PRIORITY attribute 2805 is 4 bytes of overhead plus 4 bytes of value, for 8 bytes. Thus, the 2806 total length of the STUN Binding Request is (20 + 13 + 24 + 8) = 65 2807 bytes, with 28 bytes of overhead for IP and UDP for a total of 93 2808 bytes. The response contains the STUN 20 byte header, the XOR- 2809 MAPPED-ADDRESS, and MESSAGE-INTEGRITY attributes. XOR-MAPPED-ADDRESS 2810 has 4 bytes overhead plus an 8 byte value, for a total of 12 bytes. 2811 Thus, each STUN response is (20 + 12 + 24) = 56 bytes plus 28 bytes 2812 of UDP/IP overhead for a total of 84 bytes. Checks typically fall 2813 into one of two cases. If a check works, each transaction has a 2814 single request and a single response, for a total of 2 packets and 2815 177 bytes over one RTT interval. Assuming a fairly agressive RTT of 2816 70ms, this produces 20.23 kbps, but only briefly. If a check fails 2817 because the pair is invalid, there will be nine requests and no 2818 responses. This produces 837 bytes over 7.9s, for a total of 105.9 2819 bps, but over a long period of time. 2821 OPEN ISSUE: The bandwidth computations are pretty complex because 2822 ICE is not a CBR stream, and its bandwidth utilization depends on 2823 how many transactions it ends up generating before it finishes. 2824 Need to work this model more. 2826 Given that these numbers are close to, if not greater than, the 2827 bandwidths utilized by many voice codecs, this seems a reasonable 2828 value to use. 2830 OPEN ISSUE: There is some debate about whether to reduce this 2831 pacing interval smaller, say 20ms, to speed up ICE, or perhaps 2832 make it equal to the bandwidth that would be utilized by the media 2833 streams themselves. 2835 A.3. Candidates with Multiple Bases 2837 Section 4.1 talks about merging together candidates that are 2838 identical but have different bases. When can an agent have two 2839 candidates that have the same IP address and port, but different 2840 bases? Consider the topology of Figure 16: 2842 +----------+ 2843 | STUN Srvr| 2844 +----------+ 2845 | 2846 | 2847 ----- 2848 // \\ 2849 | | 2850 | B:net10 | 2851 | | 2852 \\ // 2853 ----- 2854 | 2855 | 2856 +----------+ 2857 | NAT | 2858 +----------+ 2859 | 2860 | 2861 ----- 2862 // \\ 2863 | A | 2864 |192.168/16 | 2865 | | 2866 \\ // 2867 ----- 2868 | 2869 | 2870 |192.168.1.1 ----- 2871 +----------+ // \\ +----------+ 2872 | | | | | | 2873 | Offerer |---------| C:net10 |---------| Answerer | 2874 | |10.0.1.1 | | 10.0.1.2 | | 2875 +----------+ \\ // +----------+ 2876 ----- 2878 Figure 16 2880 In this case, the offerer is multi-homed. It has one interface, 2881 10.0.1.1, on network C, which is a net 10 private network. The 2882 Answerer is on this same network. The offerer is also connected to 2883 network A, which is 192.168/16. The offerer has an interface of 2884 192.168.1.1 on this network. There is a NAT on this network, natting 2885 into network B, which is another net10 private network, but not 2886 connected to network C. There is a STUN server on network B. 2888 The offerer obtains a host candidate on its interface on network C 2889 (10.0.1.1:2498) and a host candidate on its interface on network A 2890 (192.168.1.1:3344). It performs a STUN query to its configured STUN 2891 server from 192.168.1.1:3344. This query passes through the NAT, 2892 which happens to assign the binding 10.0.1.1:2498. The STUN server 2893 reflects this in the STUN Binding Response. Now, the offerer has 2894 obtained a server reflexive candidate with a transport address that 2895 is identical to a host candidate (10.0.1.1:2498). However, the 2896 server reflexive candidate has a base of 192.168.1.1:3344, and the 2897 host candidate has a base of 10.0.1.1:2498. 2899 A.4. Purpose of the Translation 2901 When a candidate is relayed, the SDP offer or answer contain both the 2902 relayed candidate and its translation. However, the translation is 2903 never used by ICE itself. Why is it present in the message? 2905 There are two motivations for its inclusion. The first is 2906 diagnostic. It is very useful to know the relationship between the 2907 different types of candidates. By including the translation, an 2908 agent can know which relayed candidate is associated with which 2909 reflexive candidate, which in turn is associated with a specific host 2910 candidate. When checks for one candidate succeed and not the others, 2911 this provides useful diagnostics on what is going on in the network. 2913 The second reason has to do with off-path Quality of Service (QoS) 2914 mechanisms. When ICE is used in environments such as PacketCable 2.0 2915 [[TODO: need PC2.0 reference]], proxies will, in addition to 2916 performing normal SIP operations, inspect the SDP in SIP messages, 2917 and extract the IP address and port for media traffic. They can then 2918 interact, through policy servers, with access routers in the network, 2919 to establish guaranteed QoS for the media flows. This QoS is 2920 provided by classifying the RTP traffic based on 5-tuple, and then 2921 providing it a guaranteed rate, or marking its Diffserv codepoints 2922 appropriately. When a residential NAT is present, and a relayed 2923 candidate gets selected for media, this relayed candidate will be a 2924 transport address on an actual STUN relay. That address says nothing 2925 about the actual transport address in the access router that would be 2926 used to classify packets for QoS treatment. Rather, the translation 2927 of that relayed address is needed. By carrying the translation in 2928 the SDP, the proxy can use that transport address to request QoS from 2929 the access router. 2931 A.5. Importance of the STUN Username 2933 ICE requires the usage of message integrity with STUN using its short 2934 term credential functionality. The actual short term credential is 2935 formed by exchanging username fragments in the SDP offer/answer 2936 exchange. The need for this mechanism goes beyond just security; it 2937 is actual required for correct operation of ICE in the first place. 2939 Consider agents A, B, and C. A and B are within private enterprise 1, 2940 which is using 10.0.0.0/8. C is within private enterprise 2, which 2941 is also using 10.0.0.0/8. As it turns out, B and C both have IP 2942 address 10.0.1.1. A sends an offer to C. C, in its answer, provides 2943 A with its host candidates. In this case, those candidates are 2944 10.0.1.1:8866 and 10.0.1.1:8877. As it turns out, B is in a session 2945 at that same time, and is also using 10.0.1.1:8866 and 10.0.1.1:8877 2946 as host candidates. This means that B is prepared to accept STUN 2947 messages on those ports, just as C is. A will send a STUN request to 2948 10.0.1.1:8866 and and another to 10.0.1.1:8877. However, these do 2949 not go to C as expected. Instead, they go to B! If B just replied 2950 to them, A would believe it has connectivity to C, when in fact it 2951 has connectivity to a completely different user, B. To fix this, the 2952 STUN short term credential mechanisms are used. The username 2953 fragments are sufficiently random that it is highly unlikely that B 2954 would be using the same values as A. Consequently, B would reject the 2955 STUN request since the credentials were invalid. In essence, the 2956 STUN username fragments provide a form of transient host identifiers, 2957 bound to a particular offer/answer session. 2959 An unfortunate consequence of the non-uniqueness of IP addresses is 2960 that, in the above example, B might not even be an ICE agent. It 2961 could be any host, and the port to which the STUN packet is directed 2962 could be any ephemeral port on that host. If there is an application 2963 listening on this socket for packets, and it is not prepared to 2964 handle malformed packets for whatever protocol is in use, the 2965 operation of that application could be affected. Fortunately, since 2966 the ports exchanged in SDP are ephemeral and usually drawn from the 2967 dynamic or registered range, the odds are good that the port is not 2968 used to run a server on host B, but rather is the agent side of some 2969 protocol. This decreases the probability of hitting a port in-use, 2970 due to the transient nature of port usage in this range. However, 2971 the possibility of a problem does exist, and network deployers should 2972 be prepared for it. Note that this is not a problem specific to ICE; 2973 stray packets can arrive at a port at any time for any type of 2974 protocol, especially ones on the public Internet. As such, this 2975 requirement is just restating a general design guideline for Internet 2976 applications - be prepared for unknown packets on any port. 2978 A.6. The Candidate Pair Sequence Number Formula 2980 The sequence number for a candidate pair has an odd form. It is: 2982 PAIR-SN = 10000*MAX(O-SN,A-SN) + MIN(O-SN,A-SN) + O-IP/SZ 2984 Why is this? When the candidate pairs are sorted based on this 2985 value, the resulting sorting has the MAX/MIN property. This means 2986 that the pairs are first sorted based on increasing value of the 2987 maximum of the two sequence numbers. For pairs that have the same 2988 value of the maximum sequence number, the minimum sequence number is 2989 used to sort amongst them. If the max and the min sequence numbers 2990 are the same, the IP address of the offerers candidate serves as a 2991 tie breaker. The factor of 1000 is used since there will always be 2992 fewer than a 1000 candidates, and thus the largest value a sequence 2993 number (and thus the minimum sequence number) can have is always less 2994 than 1000. This creates the desired sorting property. 2996 Recall that candidate sequence numbers are assigned such that, for a 2997 particular set of candidates of the same type, the RTP components 2998 have lower sequence numbers than the corresponding RTCP component. 2999 Also recall that, if an agent prefers host candidates to server 3000 reflexive to relayed, sequence numbers for host candidates are always 3001 lower than server reflexive which are always lower than relayed. 3002 Because of this, 3004 A.7. The Frozen State 3006 The Frozen state is used for two purposes. Firstly, it allows ICE to 3007 first perform checks for the first component of a media stream. Once 3008 a successful check has completed for the first component, the other 3009 components of the same type and local preference will get performed. 3010 Secondly, when there are multiple media streams, it allows ICE to 3011 first check candidates for a single media stream, and once a set of 3012 candidates has been found, candidates of that same type for other 3013 media streams can be checked first. This effectively 'caches' the 3014 results of a check for one media stream, and applies them to another. 3015 For example, if only the relayed candidates for audio (which were the 3016 last resort candidates) succeed, ICE will check the relayed 3017 candidates for video first. 3019 A.8. The remote-candidates attribute 3021 The a=remote-candidates attribute exists to eliminate a race 3022 condition between the updated offer and the response to the STUN 3023 Binding Request that moved a candidate into the Valid list. This 3024 race condition is shown in Figure 17. On receipt of message 4, agent 3025 A adds a candidate pair to the valid list. If there was only a 3026 single media stream with a single component, agent A could now send 3027 an updated offer. However, the check from agent B has not yet 3028 generated a response, and agent B receives the updated offer (message 3029 7) before getting the response (message 10). Thus, it does not yet 3030 know that this particular pair is valid. To eliminate this 3031 condition, the actual candidates at B that were selected by the 3032 offerer (the remote candidates) are included in the offer itself. 3034 Note, however, that agent B will not send media until it has received 3035 this STUN response. 3037 Agent A Network Agent B 3038 |(1) Offer | | 3039 |------------------------------------------>| 3040 |(2) Answer | | 3041 |<------------------------------------------| 3042 |(3) STUN Req. | | 3043 |------------------------------------------>| 3044 |(4) STUN Res. | | 3045 |<------------------------------------------| 3046 |(5) STUN Req. | | 3047 |<------------------------------------------| 3048 |(6) STUN Res. | | 3049 |-------------------->| | 3050 | |Lost | 3051 |(7) Offer | | 3052 |------------------------------------------>| 3053 |(8) Answer | | 3054 |<------------------------------------------| 3055 |(9) STUN Req. | | 3056 |<------------------------------------------| 3057 |(10) STUN Res. | | 3058 |------------------------------------------>| 3060 Figure 17 3062 A.9. Why are Keepalives Needed? 3064 Once media begins flowing on a candidate pair, it is still necessary 3065 to keep the bindings alive at intermediate NATs for the duration of 3066 the session. Normally, the media stream packets themselves (e.g., 3067 RTP) meet this objective. However, several cases merit further 3068 discussion. Firstly, in some RTP usages, such as SIP, the media 3069 streams can be "put on hold". This is accomplished by using the SDP 3070 "sendonly" or "inactive" attributes, as defined in RFC 3264 [4]. RFC 3071 3264 directs implementations to cease transmission of media in these 3072 cases. However, doing so may cause NAT bindings to timeout, and 3073 media won't be able to come off hold. 3075 Secondly, some RTP payload formats, such as the payload format for 3076 text conversation [29], may send packets so infrequently that the 3077 interval exceeds the NAT binding timeouts. 3079 Thirdly, if silence suppression is in use, long periods of silence 3080 may cause media transmission to cease sufficiently long for NAT 3081 bindings to time out. 3083 For these reasons, the media packets themselves cannot be relied 3084 upon. ICE defines a simple periodic keepalive that operates 3085 indpendently of media transmission. This makes its bandwidth 3086 requirements highly predictable, and thus amenable to QoS 3087 reservations. 3089 A.10. Why Prefer Peer Reflexive Candidates? 3091 Section 4.2 describes procedures for computing the priority of 3092 candidate based on its type and local preferences. That section 3093 requires that the type preference for peer reflexive candidates 3094 always be lower than server reflexive. Why is that? The reason has 3095 to do with the security considerations in Section 15. It is much 3096 easier for an attacker to cause an agent to use a false server 3097 reflexive candidate than it is for an attacker to cause an agent to 3098 use a false peer reflexive candidate. Consequently, attacks against 3099 the STUN binding discovery usage are thwarted by ICE by preferring 3100 the peer reflexive candidates. 3102 A.11. Why Can't Offerers Send Media When a Pair Validates 3104 Section 11.1 describes rules for sending media. The rules are 3105 asymmetric, and not the same for offerers and answerers. In 3106 particular, an answerer can send media right away to a candidate pair 3107 once it validates, even if it doesnt match the pairs in the m/c-line. 3108 THe offerer cannot - it must wait for an updated offer/answer 3109 exchange. Why is that? 3111 This, in fact, relates to a bigger question - why is the updated 3112 offer/answer exchange needed at all? Indeed, in a pure offer/answer 3113 environment, it would not be. The offerer and answerer will agree on 3114 the candidates to use through ICE, and then can begin using them. As 3115 far as the agents themselves are concerned, the updated offer/answer 3116 provides no new information. However, in practice, numerous 3117 components along the signaling path look at the SDP information. 3118 These include entities performing off-path QoS reservations, NAT 3119 traversal components such as ALGs and Session Border Controllers 3120 (SBCs) and diagnostic tools that passively monitor the network. For 3121 these tools to continue to function without change, the core property 3122 of SDP - that the m/c-lines represent the addresses used for media - 3123 must be retained. For this reason, an updated offer must be sent. 3125 To ensure that an updated offerer is sent, ICE purposefully prevents 3126 the offerer from sending media until that offer is sent. It 3127 furthermore restricts the answerer in how long it can send media 3128 until an updated offer is received. This provides protocol 3129 incentives for sending the updated offer. 3131 The updated offer also helps ensure that ICE did the right thing. In 3132 very unusual cases, the offerer and answerer might not agree on the 3133 candidates selected by ICE. This would be detected in the updated 3134 offer/answer exchange, allowing them to restart ICE procedures to fix 3135 the problem. 3137 Author's Address 3139 Jonathan Rosenberg 3140 Cisco Systems 3141 600 Lanidex Plaza 3142 Parsippany, NJ 07054 3143 US 3145 Phone: +1 973 952-5000 3146 Email: jdrosen@cisco.com 3147 URI: http://www.jdrosen.net 3149 Intellectual Property Statement 3151 The IETF takes no position regarding the validity or scope of any 3152 Intellectual Property Rights or other rights that might be claimed to 3153 pertain to the implementation or use of the technology described in 3154 this document or the extent to which any license under such rights 3155 might or might not be available; nor does it represent that it has 3156 made any independent effort to identify any such rights. Information 3157 on the procedures with respect to rights in RFC documents can be 3158 found in BCP 78 and BCP 79. 3160 Copies of IPR disclosures made to the IETF Secretariat and any 3161 assurances of licenses to be made available, or the result of an 3162 attempt made to obtain a general license or permission for the use of 3163 such proprietary rights by implementers or users of this 3164 specification can be obtained from the IETF on-line IPR repository at 3165 http://www.ietf.org/ipr. 3167 The IETF invites any interested party to bring to its attention any 3168 copyrights, patents or patent applications, or other proprietary 3169 rights that may cover technology that may be required to implement 3170 this standard. Please address the information to the IETF at 3171 ietf-ipr@ietf.org. 3173 Disclaimer of Validity 3175 This document and the information contained herein are provided on an 3176 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS 3177 OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET 3178 ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, 3179 INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE 3180 INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED 3181 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 3183 Copyright Statement 3185 Copyright (C) The Internet Society (2006). This document is subject 3186 to the rights, licenses and restrictions contained in BCP 78, and 3187 except as set forth therein, the authors retain all their rights. 3189 Acknowledgment 3191 Funding for the RFC Editor function is currently provided by the 3192 Internet Society.