idnits 2.17.1 draft-ietf-behave-turn-13.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** The document seems to lack a License Notice according IETF Trust Provisions of 28 Dec 2009, Section 6.b.i or Provisions of 12 Sep 2009 Section 6.b -- however, there's a paragraph with a matching beginning. Boilerplate error? (You're using the IETF Trust Provisions' Section 6.b License Notice from 12 Feb 2009 rather than one of the newer Notices. See https://trustee.ietf.org/license-info/.) Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- == There are 4 instances of lines with private range IPv4 addresses in the document. If these are generic example addresses, they should be changed to use any of the ranges defined in RFC 6890 (or successor): 192.0.2.x, 198.51.100.x or 203.0.113.x. -- The document has examples using IPv4 documentation addresses according to RFC6890, but does not use any IPv6 documentation addresses. Maybe there should be IPv6 examples, too? Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document seems to contain a disclaimer for pre-RFC5378 work, and may have content which was first submitted before 10 November 2008. The disclaimer is necessary when there are original authors that you have been unable to contact, or if some do not wish to grant the BCP78 rights to the IETF Trust. If you are able to get all authors (current and original) to grant those rights, you can and should remove the disclaimer; otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (February 24, 2009) is 5540 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) == Missing Reference: '0x4001' is mentioned on line 652, but not defined ** Obsolete normative reference: RFC 5389 (Obsoleted by RFC 8489) == Outdated reference: A later version (-07) exists of draft-ietf-behave-turn-tcp-01 == Outdated reference: A later version (-11) exists of draft-ietf-behave-turn-ipv6-05 == Outdated reference: A later version (-09) exists of draft-ietf-tsvwg-port-randomization-02 Summary: 2 errors (**), 0 flaws (~~), 6 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 BEHAVE WG J. Rosenberg 3 Internet-Draft Cisco 4 Intended status: Standards Track R. Mahy 5 Expires: August 28, 2009 (Unaffiliated) 6 P. Matthews 7 Alcatel-Lucent 8 February 24, 2009 10 Traversal Using Relays around NAT (TURN): Relay Extensions to Session 11 Traversal Utilities for NAT (STUN) 12 draft-ietf-behave-turn-13 14 Status of this Memo 16 This Internet-Draft is submitted to IETF in full conformance with the 17 provisions of BCP 78 and BCP 79. 19 Internet-Drafts are working documents of the Internet Engineering 20 Task Force (IETF), its areas, and its working groups. Note that 21 other groups may also distribute working documents as Internet- 22 Drafts. 24 Internet-Drafts are draft documents valid for a maximum of six months 25 and may be updated, replaced, or obsoleted by other documents at any 26 time. It is inappropriate to use Internet-Drafts as reference 27 material or to cite them other than as "work in progress." 29 The list of current Internet-Drafts can be accessed at 30 http://www.ietf.org/ietf/1id-abstracts.txt. 32 The list of Internet-Draft Shadow Directories can be accessed at 33 http://www.ietf.org/shadow.html. 35 This Internet-Draft will expire on August 28, 2009. 37 Copyright Notice 39 Copyright (c) 2009 IETF Trust and the persons identified as the 40 document authors. All rights reserved. 42 This document is subject to BCP 78 and the IETF Trust's Legal 43 Provisions Relating to IETF Documents in effect on the date of 44 publication of this document (http://trustee.ietf.org/license-info). 45 Please review these documents carefully, as they describe your rights 46 and restrictions with respect to this document. 48 This document may contain material from IETF Documents or IETF 49 Contributions published or made publicly available before November 50 10, 2008. The person(s) controlling the copyright in some of this 51 material may not have granted the IETF Trust the right to allow 52 modifications of such material outside the IETF Standards Process. 53 Without obtaining an adequate license from the person(s) controlling 54 the copyright in such materials, this document may not be modified 55 outside the IETF Standards Process, and derivative works of it may 56 not be created outside the IETF Standards Process, except to format 57 it for publication as an RFC or to translate it into languages other 58 than English. 60 Abstract 62 If a host is located behind a NAT, then in certain situations it can 63 be impossible for that host to communicate directly with other hosts 64 (peers). In these situations, it is necessary for the host to use 65 the services of an intermediate node that acts as a communication 66 relay. This specification defines a protocol, called TURN (Traversal 67 Using Relays around NAT), that allows the host to control the 68 operation of the relay and to exchange packets with its peers using 69 the relay. TURN differs from some other relay control protocols in 70 that it allows a client to communicate with multiple peers using a 71 single relay address. 73 The TURN protocol was designed to be used as part of the ICE 74 (Interactive Connectivity Establishment) approach to NAT traversal, 75 though it can be also used without ICE. 77 Table of Contents 79 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 80 2. Overview of Operation . . . . . . . . . . . . . . . . . . . . 6 81 2.1. Transports . . . . . . . . . . . . . . . . . . . . . . . . 8 82 2.2. Allocations . . . . . . . . . . . . . . . . . . . . . . . 10 83 2.3. Permissions . . . . . . . . . . . . . . . . . . . . . . . 11 84 2.4. Send Mechanism . . . . . . . . . . . . . . . . . . . . . . 12 85 2.5. Channels . . . . . . . . . . . . . . . . . . . . . . . . . 14 86 2.6. Other Features . . . . . . . . . . . . . . . . . . . . . . 16 87 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 17 88 4. General Behavior . . . . . . . . . . . . . . . . . . . . . . . 18 89 5. Allocations . . . . . . . . . . . . . . . . . . . . . . . . . 20 90 6. Creating an Allocation . . . . . . . . . . . . . . . . . . . . 22 91 6.1. Sending an Allocate Request . . . . . . . . . . . . . . . 22 92 6.2. Receiving an Allocate Request . . . . . . . . . . . . . . 23 93 6.3. Receiving an Allocate Success Response . . . . . . . . . . 27 94 6.4. Receiving an Allocate Error Response . . . . . . . . . . . 28 95 7. Refreshing an Allocation . . . . . . . . . . . . . . . . . . . 30 96 7.1. Sending a Refresh Request . . . . . . . . . . . . . . . . 30 97 7.2. Receiving a Refresh Request . . . . . . . . . . . . . . . 30 98 7.3. Receiving a Refresh Response . . . . . . . . . . . . . . . 31 99 8. Permissions . . . . . . . . . . . . . . . . . . . . . . . . . 31 100 9. CreatePermission . . . . . . . . . . . . . . . . . . . . . . . 32 101 9.1. Forming a CreatePermission request . . . . . . . . . . . . 33 102 9.2. Receiving a CreatePermission request . . . . . . . . . . . 33 103 9.3. Receiving a CreatePermission response . . . . . . . . . . 34 104 10. Send and Data Methods . . . . . . . . . . . . . . . . . . . . 34 105 10.1. Forming a Send Indication . . . . . . . . . . . . . . . . 34 106 10.2. Receiving a Send Indication . . . . . . . . . . . . . . . 34 107 10.3. Receiving a UDP Datagram . . . . . . . . . . . . . . . . . 35 108 10.4. Receiving a Data Indication . . . . . . . . . . . . . . . 36 109 11. Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 110 11.1. Sending a ChannelBind Request . . . . . . . . . . . . . . 38 111 11.2. Receiving a ChannelBind Request . . . . . . . . . . . . . 38 112 11.3. Receiving a ChannelBind Response . . . . . . . . . . . . . 39 113 11.4. The ChannelData Message . . . . . . . . . . . . . . . . . 40 114 11.5. Sending a ChannelData Message . . . . . . . . . . . . . . 40 115 11.6. Receiving a ChannelData Message . . . . . . . . . . . . . 41 116 11.7. Relaying Data from the Peer . . . . . . . . . . . . . . . 42 117 12. IP Header Fields . . . . . . . . . . . . . . . . . . . . . . . 42 118 13. New STUN Methods . . . . . . . . . . . . . . . . . . . . . . . 43 119 14. New STUN Attributes . . . . . . . . . . . . . . . . . . . . . 44 120 14.1. CHANNEL-NUMBER . . . . . . . . . . . . . . . . . . . . . . 44 121 14.2. LIFETIME . . . . . . . . . . . . . . . . . . . . . . . . . 44 122 14.3. XOR-PEER-ADDRESS . . . . . . . . . . . . . . . . . . . . . 45 123 14.4. DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 124 14.5. XOR-RELAYED-ADDRESS . . . . . . . . . . . . . . . . . . . 45 125 14.6. EVEN-PORT . . . . . . . . . . . . . . . . . . . . . . . . 45 126 14.7. REQUESTED-TRANSPORT . . . . . . . . . . . . . . . . . . . 45 127 14.8. DONT-FRAGMENT . . . . . . . . . . . . . . . . . . . . . . 46 128 14.9. RESERVATION-TOKEN . . . . . . . . . . . . . . . . . . . . 46 129 15. New STUN Error Response Codes . . . . . . . . . . . . . . . . 46 130 16. Detailed Example . . . . . . . . . . . . . . . . . . . . . . . 47 131 17. Security Considerations . . . . . . . . . . . . . . . . . . . 54 132 17.1. Outsider Attacks . . . . . . . . . . . . . . . . . . . . . 54 133 17.1.1. Obtaining Unauthorized Allocations . . . . . . . . . 54 134 17.1.2. Offline Dictionary Attacks . . . . . . . . . . . . . 54 135 17.1.3. Faked Refreshes and Permissions . . . . . . . . . . . 55 136 17.1.4. Fake Data . . . . . . . . . . . . . . . . . . . . . . 55 137 17.1.5. Impersonating a Server . . . . . . . . . . . . . . . 56 138 17.1.6. Eavesdropping Traffic . . . . . . . . . . . . . . . . 56 139 17.1.7. TURN loop attack . . . . . . . . . . . . . . . . . . 57 140 17.2. Firewall Considerations . . . . . . . . . . . . . . . . . 57 141 17.2.1. Faked Permissions . . . . . . . . . . . . . . . . . . 58 142 17.2.2. Blacklisted IP Addresses . . . . . . . . . . . . . . 58 143 17.2.3. Running Servers on Well-Known Ports . . . . . . . . . 59 144 17.3. Insider Attacks . . . . . . . . . . . . . . . . . . . . . 59 145 17.3.1. DoS Against TURN Server . . . . . . . . . . . . . . . 59 146 17.3.2. Anonymous Relaying of Malicious Traffic . . . . . . . 59 147 17.3.3. Manipulating other Allocations . . . . . . . . . . . 60 148 17.4. Other Considerations . . . . . . . . . . . . . . . . . . . 60 149 18. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 60 150 19. IAB Considerations . . . . . . . . . . . . . . . . . . . . . . 61 151 20. Open Issues . . . . . . . . . . . . . . . . . . . . . . . . . 62 152 21. Changes from Previous Versions . . . . . . . . . . . . . . . . 62 153 21.1. Changes from -12 to -13 . . . . . . . . . . . . . . . . . 63 154 21.2. Changes from -11 to -12 . . . . . . . . . . . . . . . . . 63 155 21.3. Changes from -10 to -11 . . . . . . . . . . . . . . . . . 64 156 21.4. Changes from -09 to -10 . . . . . . . . . . . . . . . . . 65 157 21.5. Changes from -08 to -09 . . . . . . . . . . . . . . . . . 67 158 21.6. Changes from -07 to -08 . . . . . . . . . . . . . . . . . 69 159 21.7. Changes from -06 to -07 . . . . . . . . . . . . . . . . . 69 160 21.8. Changes from -05 to -06 . . . . . . . . . . . . . . . . . 71 161 21.9. Changes from -04 to -05 . . . . . . . . . . . . . . . . . 72 162 22. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 73 163 23. References . . . . . . . . . . . . . . . . . . . . . . . . . . 73 164 23.1. Normative References . . . . . . . . . . . . . . . . . . . 73 165 23.2. Informative References . . . . . . . . . . . . . . . . . . 74 166 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 75 168 1. Introduction 170 A host behind a NAT may wish to exchange packets with other hosts, 171 some of which may also be behind NATs. To do this, the hosts 172 involved can use 'Hole Punching' techniques (see [RFC5128]) in an 173 attempt discover a direct communication path; that is, a 174 communication path that goes from host to another through intervening 175 NATs and routers, but does not traverse any relays. 177 As described in [RFC5128] and [RFC4787], hole punching techniques 178 will fail if both hosts are behind NATs that are not well-behaved. 179 For example, if both hosts are behind NATs that have a mapping 180 behavior of "address dependent mapping" or "address and port 181 dependent mapping", then hole punching techniques generally fail. 183 When a direct communication path cannot be found, it is necessary to 184 use the services of an intermediate host that acts as a relay for the 185 packets. This relay typically sits in the public Internet and relays 186 packets between two hosts that both sit behind NATs. 188 This specification defines a protocol, called TURN, that allows a 189 host behind a NAT (called the TURN client) to request that another 190 host (called the TURN server) act as a relay. The client can arrange 191 for the server to relay packets to and from certain other hosts 192 (called peers) and can control aspects of how the relaying is done. 193 The client does this by obtaining an IP address and port on the 194 server, called the relayed-transport-address. When a peer sends a 195 packet to the relayed-transport-address, the server relays the packet 196 to the client. When the client sends a data packet to the server, 197 the server relays it to the appropriate peer using the relayed- 198 transport-address as the source. 200 A client using TURN must have some way to communicate the relayed- 201 transport-address to its peers, and to learn each peer's IP address 202 and port (more precisely, each peer's server-reflexive transport 203 address, see Section 2). How this is done is out of the scope of the 204 TURN protocol. One way this might be done is for the client and 205 peers to exchange e-mail messages. Another way is for the client and 206 its peers to use a special-purpose 'introduction' or 'rendezvous' 207 protocol (see [RFC5128] for more details). 209 If TURN is used with ICE [I-D.ietf-mmusic-ice], then the relayed- 210 transport-address and the IP addresses and ports of the peers are 211 included in the ICE candidate information which the rendezvous 212 protocol must carry. For example, if TURN and ICE are used as part 213 of a multimedia solution using SIP [RFC3261], then SIP serves the 214 role of the rendezvous protocol, carrying the ICE candidate 215 information inside the body of SIP messages. If TURN and ICE are 216 used with some other rendezvous protocol, then 217 [I-D.rosenberg-mmusic-ice-nonsip] provides guidance on the services 218 the rendezvous protocol must perform. 220 Though the use of a TURN server to enable communication between two 221 hosts behind NATs is very likely to work, it comes at a high cost to 222 the provider of the TURN server, since the server typically needs a 223 high bandwidth connection to the Internet . As a consequence, it is 224 best to use a TURN server only when a direct communication path 225 cannot be found. When the client and a peer use ICE to determine the 226 communication path, ICE will use hole punching techniques to search 227 for a direct path first and only use a TURN server when a direct path 228 cannot be found. 230 TURN was originally invented to support multimedia sessions signaled 231 using SIP. Since SIP supports forking, TURN supports multiple peers 232 per relayed-transport-address; a feature not supported by other 233 approaches (e.g., SOCKS [RFC1928]). However, care has been taken to 234 make sure that TURN is suitable for other types of applications. 236 TURN was designed as one piece in the larger ICE approach to NAT 237 traversal. Implementors of TURN are urged to investigate ICE and 238 seriously consider using it for their application. However, it is 239 possible to use TURN without ICE. 241 TURN is an extension to the STUN (Session Traversal Utilities for NAT 242 [RFC5389]) protocol. Most, though not all, TURN messages are STUN- 243 formatted messages. A reader of this document should be familiar 244 with STUN. 246 2. Overview of Operation 248 This section gives an overview of the operation of TURN. It is non- 249 normative. 251 In a typical configuration, a TURN client is connected to a private 252 network [RFC1918] and through one or more NATs to the public 253 Internet. On the public Internet is a TURN server. Elsewhere in the 254 Internet are one or more peers that the TURN client wishes to 255 communicate with. These peers may or may not be behind one or more 256 NATs. The client uses the server as a relay to send packets to these 257 peers and to receive packets from these peers. 259 Peer A 260 Server-Reflexive +---------+ 261 Transport Address | | 262 192.0.2.150:32102 | | 263 | /| | 264 TURN | / ^| Peer A | 265 Client's Server | / || | 266 Host Transport Transport | // || | 267 Address Address | // |+---------+ 268 10.1.1.2:49721 192.0.2.15:3478 |+-+ // Peer A 269 | | ||N| / Host Transport 270 | +-+ | ||A|/ Address 271 | | | | v|T| 192.168.100.2:49582 272 | | | | /+-+ 273 +---------+| | | |+---------+ / +---------+ 274 | || |N| || | // | | 275 | TURN |v | | v| TURN |/ | | 276 | Client |----|A|----------| Server |------------------| Peer B | 277 | | | |^ | |^ ^| | 278 | | |T|| | || || | 279 +---------+ | || +---------+| |+---------+ 280 | || | | 281 | || | | 282 +-+| | | 283 | | | 284 | | | 285 Client's | Peer B 286 Server-Reflexive Relayed Transport 287 Transport Address Transport Address Address 288 192.0.2.1:7000 192.0.2.15:50000 192.0.2.210:49191 290 Figure 1 292 Figure 1 shows a typical deployment. In this figure, the TURN client 293 and the TURN server are separated by a NAT, with the client on the 294 private side and the server on the public side of the NAT. This NAT 295 is assumed to be a "bad" NAT; for example, it might have a mapping 296 property of address-and-port-dependent mapping (see [RFC4787] for a 297 description of what this means). 299 The client talks to the server from a (IP address, port) combination 300 called the client's HOST TRANSPORT ADDRESS. (The combination of an 301 IP address and port is called a TRANSPORT ADDRESS). 303 The client sends TURN messages from its host transport address to a 304 transport address on the TURN server which is known as the TURN 305 SERVER TRANSPORT ADDRESS. The client learns the server's transport 306 address through some unspecified means (e.g., configuration), and 307 this address is typically used by many clients simultaneously. 309 Since the client is behind a NAT, the server sees packets from the 310 client as coming from a transport address on the NAT itself. This 311 address is known as the client's SERVER-REFLEXIVE transport address; 312 packets sent by the server to the client's server-reflexive transport 313 address will be forwarded by the NAT to the client's host transport 314 address. 316 The client uses TURN commands to create and manipulate an ALLOCATION 317 on the server. An allocation is a data structure on the server, an 318 important component of which is a RELAYED TRANSPORT ADDRESS. The 319 relayed transport address for the allocation is a transport address 320 on the server which is used to send and receive packets to the peers. 322 Once an allocation is created, the client can send application data 323 to the server along with an indication of which peer the data is to 324 be sent to, and the server will relay this data to the appropriate 325 peer. The client sends the application data to the server inside a 326 TURN message; at the server, the data is extracted from the TURN 327 message and sent to the peer in a UDP datagram. In the reverse 328 direction, a peer can send application data in a UDP datagram to the 329 relayed transport address for the allocation; the server will then 330 encapsulate this data inside a TURN message and send it to the client 331 along with an indication of which peer sent the data. Since the TURN 332 message always contains an indication of which peer the client is 333 communicating with, the client can use a single allocation to 334 communicate with multiple peers. 336 When the peer is behind a NAT, then the client must identify the peer 337 using its server-reflexive transport address rather than its host 338 transport address. For example, to application data to peer A in the 339 example above, the client must specify 192.0.2.150:32102 (peer A's 340 server-reflexive transport address) rather than 192.168.100.2:49582 341 (peer A's host transport address). 343 Each allocation on the server belongs to a single client and has 344 exactly one relayed transport address which is used only by that 345 allocation. Thus when a packet arrives at a relayed transport 346 address on the server, the server knows which client the data is 347 intended for. However, the client may have multiple allocations on a 348 server at the same time. 350 2.1. Transports 352 TURN as defined in this specification always uses UDP between the 353 server and the peer. However, this specification allows the use of 354 any one of UDP, TCP, or TLS over TCP to carry the TURN messages 355 between the client and the server. 357 +----------------------------+---------------------+ 358 | TURN client to TURN server | TURN server to peer | 359 +----------------------------+---------------------+ 360 | UDP | UDP | 361 | TCP | UDP | 362 | TLS over TCP | UDP | 363 +----------------------------+---------------------+ 365 If TCP or TLS over TCP is used between the client and the server, 366 then the server will convert between these transports and UDP 367 transport when relaying data to/from the peer. 369 TURN supports TCP transport between the client and the server because 370 some firewalls are configured to block UDP entirely. These firewalls 371 block UDP but not TCP in part because TCP has properties that make 372 the intention of the nodes being protected by the firewall more 373 obvious to the firewall. For example, TCP has a three-way handshake 374 that makes in clearer that the protected node really wishes to have 375 that particular connection established, while for UDP the best the 376 firewall can do is guess which flows are desired by using filtering 377 rules. Also, TCP has explicit connection teardown, while for UDP the 378 firewall has to use timers to guess when the flow is finished. 380 TURN supports TLS over TCP transport between the client and the 381 server because TLS provides additional security properties not 382 provided by TURN's default digest authentication; properties which 383 some clients may wish to take advantage of. In particular, TLS 384 provides a way for the client to ascertain that it is talking to the 385 server that it intended to, and also provides for confidentiality of 386 TURN control messages. TURN does not require TLS because the 387 overhead of using TLS is higher than that of digest authentication; 388 for example, using TLS likely means that most application data will 389 be doubly encrypted (once by TLS and once to ensure it is still 390 encrypted in the UDP datagram). 392 There is a planned extension to TURN to add support for TCP between 393 the server and the peers [I-D.ietf-behave-turn-tcp]. For this 394 reason, allocations that use UDP between the server and the peers are 395 known as UDP allocations, while allocations that use TCP between the 396 server and the peers are known as TCP allocations. This 397 specification describes only UDP allocations. 399 TURN as defined in this specification only supports IPv4. All IP 400 addresses in this specification must be IPv4 addresses. However, 401 there is a planned extension to TURN to add support for IPv6 and for 402 relaying between IPv4 and IPv6 [I-D.ietf-behave-turn-ipv6]. 404 In some applications for TURN, the client may send and receive 405 packets other than TURN packets on the host transport address it uses 406 to communicate with the server. This can happen, for example, when 407 using TURN with ICE. In these cases, the client can distinguish TURN 408 packets from other packets by examining the source address of the 409 arriving packet: those arriving from the TURN server will be TURN 410 packets. 412 2.2. Allocations 414 To create an allocation on the server, the client uses an Allocate 415 transaction. The client sends a Allocate request to the server, and 416 the server replies with an Allocate success response containing the 417 allocated relayed transport address. The client can include 418 attributes in the Allocate request that describe the type of 419 allocation it desires (e.g., the lifetime of the allocation). Since 420 relaying data may require lots of bandwidth, the server typically 421 requires that the client authenticate itself using STUN's long-term 422 credential mechanism, to show that it is authorized to use the 423 server. 425 Once a relayed transport address is allocated, a client must keep the 426 allocation alive. To do this, the client periodically sends a 427 Refresh request to the server. TURN deliberately uses a different 428 method (Refresh rather than Allocate) for refreshes to ensure that 429 the client is informed if the allocation vanishes for some reason. 431 The frequency of the Refresh transaction is determined by the 432 lifetime of the allocation. The client can request a lifetime in the 433 Allocate request and may modify its request in a Refresh request, and 434 the server always indicates the actual lifetime in the response. The 435 client must issue a new Refresh transaction within 'lifetime' seconds 436 of the previous Allocate or Refresh transaction. Once a client no 437 longer wishes to use an Allocation, it should delete the allocation 438 using a Refresh request with a requested lifetime of 0. 440 Both the server and client keep track of a value known as the 441 5-TUPLE. At the client, the 5-tuple consists of the client's host 442 transport address, the server transport address, and the transport 443 protocol used by the client to communicate with the server. At the 444 server, the 5-tuple value is the same except that the client's host 445 transport address is replaced by the client's server-reflexive 446 address, since that is the client's address as seen by the server. 448 Both the client and the server remember the 5-tuple used in the 449 Allocate request. Subsequent messages between the client and the 450 server uses the same 5-tuple. In this way, the client and server 451 know which allocation is being referred to. If the client wishes to 452 allocate a second relayed transport address, it must create a second 453 allocation using a different 5-tuple (e.g., by using a different 454 client host address or port). 456 NOTE: While the terminology used in this document refers to 457 5-tuples, the TURN server can store whatever identifier it likes 458 that yields identical results. Specifically, an implementation 459 may use a file-descriptor in place of a 5-tuple to represent a TCP 460 connection 462 TURN TURN Peer Peer 463 client server A B 464 |-- Allocate request --------------->| | | 465 | | | | 466 |<--------------- Allocate failure --| | | 467 | (401 Unauthorized) | | | 468 | | | | 469 |-- Allocate request --------------->| | | 470 | | | | 471 |<---------- Allocate success resp --| | | 472 | (192.0.2.15:50000) | | | 473 // // // // 474 | | | | 475 |-- Refresh request ---------------->| | | 476 | | | | 477 |<----------- Refresh success resp --| | | 478 | | | | 480 Figure 2 482 In Figure 2, the client sends an Allocate request to the server 483 without credentials. Since the server requires that all requests be 484 authenticated using STUN's long-term credential mechanism, the server 485 rejects the request with a 401 (Unauthorized) error code. The client 486 then tries again, this time including credentials (not shown). This 487 time, the server accepts the Allocate request and returns an Allocate 488 success response containing (amongst other things) the relayed 489 transport address assigned to the allocation. Sometime later the 490 client decides to refresh the allocation and thus sends a Refresh 491 request to the server. The refresh is accepted and the server 492 replies with a Refresh success response. 494 2.3. Permissions 496 To ease concerns amongst enterprise IT administrators that TURN could 497 be used to bypass corporate firewall security, TURN includes the 498 notion of permissions. TURN permissions mimic the address-restricted 499 filtering mechanism of NATs that comply with [RFC4787]. 501 An allocation can have zero or more permissions. Each permission 502 consists of an IP address and a lifetime. When the server receives a 503 UDP datagram on the allocation's relayed transport address, it first 504 checks the list of permissions. If the source IP address of the 505 datagram matches a permission, the application data is relayed to the 506 client, otherwise the UDP datagram is silently discarded. 508 A permission expires after 5 minutes if it is not refreshed. There 509 is no way to explicitly delete a permission. 511 The client can install or refresh a permission using either a 512 CreatePermission request or a ChannelBind request. Using the 513 CreatePermission request, multiple permissions can be installed or 514 refreshed with a single request. For security reasons, permissions 515 can only be installed or refreshed by transactions that can be 516 authenticated; thus Send indications and ChannelData messages (which 517 are used to send data to peers) do not install or refresh any 518 permissions. 520 Note that permissions are within the context of an allocation, so 521 adding or expiring a permission in one allocation does not affect 522 other allocations. 524 2.4. Send Mechanism 526 There are two mechanisms for the client and peers to exchange 527 application data using the TURN server. The first mechanism uses the 528 Send and Data methods, the second way uses channels. Common to both 529 ways is the ability of the client to communicate with multiple peers 530 using a single allocated relayed transport address; thus both ways 531 include a means for the client to indicate to the server which peer 532 to forward the data to, and for the server to indicate which peer 533 sent the data. 535 The Send mechanism uses Send and Data indications. Send indications 536 are used to send application data from the client to the server, 537 while Data indications are used to send application data from the 538 server to the client. 540 When using the Send mechanism, the client sends a Send indication to 541 the TURN server containing (a) an XOR-PEER-ADDRESS attribute specify 542 the (server-reflexive) transport address of the peer and (b) a DATA 543 attribute holding the application data. When the TURN server 544 receives the Send indication, it extracts the application data from 545 the DATA attribute and sends it in a UDP datagram to the peer, using 546 the allocated relay address as the source address. Note that there 547 is no need to specify the relayed transport address, since it is 548 implied by the 5-tuple used for the Send indication. 550 In the reverse direction, UDP datagrams arriving at the relayed 551 transport address on the TURN server are converted into Data 552 indications and sent to the client, with the server-reflexive 553 transport address of the peer included in an XOR-PEER-ADDRESS 554 attribute and the data itself in a DATA attribute. Since the relayed 555 transport address uniquely identified the allocation, the server 556 knows which client to relay the data to. 558 Send and Data indications cannot be authenticated, since the Long- 559 Term Credential Mechanism of STUN does not support authenticating 560 indications. This is not as big an issue as it might first appear, 561 since the client-to-server leg is only half of the total path to the 562 peer; applications that want proper security need to use encryption 563 or similar to protect their data in the UDP datagrams between the 564 server and the peer. However, to prevent attackers from injecting 565 rogue Send indications to arbitrary destinations, TURN requires that 566 a client install a permission to a peer before sending data to it 567 using a Send indication. 568 TURN TURN Peer Peer 569 client server A B 570 | | | | 571 |-- CreatePermission req (Peer A) -->| | | 572 |<-- CreatePermission success resp --| | | 573 | | | | 574 |--- Send ind (Peer A)-------------->| | | 575 | |=== data ===>| | 576 | | | | 577 | |<== data ====| | 578 |<-------------- Data ind (Peer A) --| | | 579 | | | | 580 | | | | 581 |--- Send ind (Peer B)-------------->| | | 582 | | dropped | | 583 | | | | 584 | |<== data ==================| 585 | dropped | | | 586 | | | | 588 Figure 3 590 In Figure 3, the client has already created an allocation and now 591 wishes to send data to its peers. The client first creates a 592 permission by sending the server a CreatePermission request 593 specifying peer A's (server reflexive) IP address in the XOR-PEER- 594 ADDRESS attribute; if this was not done, the server would not relay 595 data between the client and the server. The client then sends data 596 to Peer A using a Send indication; at the server, the application 597 data is extracted and forwarded in a UDP datagram to Peer A, using 598 the relayed transport address as the source transport address. When 599 a UDP datagram from Peer A is received at the relayed transport 600 address, the contents are placed into a Data indication and forwarded 601 to the client. Later, the client attempts to exchange data with Peer 602 B, however no permission has been installed for Peer B, so the Send 603 indication from the client and the UDP datagram from the peer are 604 both dropped by the server. 606 2.5. Channels 608 For some applications (e.g. Voice over IP), the 36 bytes of overhead 609 that a Send indication or Data indication adds to the application 610 data can substantially increase the bandwidth required between the 611 client and the server. To remedy this, TURN offers a second way for 612 the client and server to associate data with a specific peer. 614 This second way uses an alternate packet format known as the 615 ChannelData message. The ChannelData message does not use the STUN 616 header used by other TURN messages, but instead has a 4-byte header 617 that includes a number known as a channel number. Each channel 618 number in use is bound to a specific peer and thus serves as a 619 shorthand for the peer's host transport address. 621 To bind a channel to a peer, the client sends a ChannelBind request 622 to the server, and includes an unbound channel number and the 623 transport address of the peer. Once the channel is bound, the client 624 can use a ChannelData message to send the server data destined for 625 the peer. Similarly, the server can relay data from that peer 626 towards the client using a ChannelData message. 628 Channel bindings last for 10 minutes unless refreshed. Channel 629 bindings are refreshed by sending another ChannelBind request 630 rebinding the channel to the peer. Like permissions (but unlike 631 allocations), there is no way to explicitly delete a channel binding; 632 the client must simply wait for it to time out. 634 TURN TURN Peer Peer 635 client server A B 636 | | | | 637 |-- ChannelBind req ---------------->| | | 638 | (Peer A to 0x4001) | | | 639 | | | | 640 |<---------- ChannelBind succ resp --| | | 641 | | | | 642 |-- [0x4001] data ------------------>| | | 643 | |=== data ===>| | 644 | | | | 645 | |<== data ====| | 646 |<------------------ [0x4001] data --| | | 647 | | | | 648 |--- Send ind (Peer A)-------------->| | | 649 | |=== data ===>| | 650 | | | | 651 | |<== data ====| | 652 |<------------------ [0x4001] data --| | | 653 | | | | 655 Figure 4 657 shows the channel mechanism in use. The client has already created 658 an allocation and now wishes to bind a channel to peer A. To do this, 659 the client sends a ChannelBind request to the server, specifying the 660 transport address of Peer A and a channel number (0x4001). After 661 that, the client can send application data encapsulated inside 662 ChannelData messages to Peer A: this is shown as "[0x4001] data" 663 where 0x4001 is the channel number. When the ChannelData message 664 arrives at the server, the server transfers the data to a UDP 665 datagram and sends it to the peer A, as indicated by the channel 666 number. When peer A sends a UDP datagram to the relayed transport 667 address, the data is placed inside a ChannelData message and sent to 668 the client. 670 Once a channel has been bound, the client is free to intermix 671 ChannelData messages and Send indications. In the figure, the client 672 later decides to use a Send indication rather than a ChannelData 673 message to send additional data to peer A. The client might decide to 674 do this, for example, so it can use the DONT-FRAGMENT attribute (see 675 the next section). However, once a channel is bound, the server will 676 always use a ChannelData message, as shown in the call flow. 678 Note that ChannelData messages can only be used for peers to which 679 the client has bound a channel. In the example above, Peer A has 680 been bound to a channel, but Peer B has not, so application data to 681 and from Peer B would use the Send mechanism. 683 2.6. Other Features 685 This section describes a few other features of TURN. 687 Old versions of RTP [RFC3550] required that the RTP stream be on an 688 even port number and the associated RTCP stream, if present, be on 689 the next highest port. To allow clients to work with nodes that 690 still require this, TURN allows the client to request that the server 691 allocate a relayed-transport-address with an even port number, and to 692 optionally request the server reserve the next-highest port number 693 for a subsequent allocation. 695 If appropriate, a TURN server can reject an Allocate request with the 696 suggestion that the client try an alternative server. 698 TURN is designed so that the server can be implemented as an 699 application that runs in userland under commonly available operating 700 systems and which does not requiring special privileges. This design 701 decision has the following implications: 703 o The value of the Diff-Serv field may not be preserved across the 704 server; 706 o The TTL field may be reset, rather than decremented, across the 707 server; 709 o The ECN field may be reset by the server; 711 o ICMP messages are not relayed by the server; 713 o Path MTU Discovery does not work, except in the limited way 714 available using the DONT-FRAGMENT attribute (see below); and 716 o There is no end-to-end fragmentation, since the packet is re- 717 assembled at the server. 719 Future work may specify alternate TURN semantics that address these 720 limitations. 722 To provide a limited form of Path MTU discovery, TURN has a DONT- 723 FRAGMENT attribute. The client may include this attribute in a Send 724 indication to specify that the server set the DF (Don't Fragment) bit 725 in the UDP datagram that it sends to the peer. Since some servers 726 may be unable to set the DF bit, the client should also include this 727 attribute in the Allocate request; servers that do not support this 728 feature will reject the Allocate request. Note that, because the 729 server does not relay ICMP messages, the client may need to use a 730 Path MTU discovery algorithm based on the one in [RFC4821]. 732 3. Terminology 734 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 735 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 736 document are to be interpreted as described in RFC 2119 [RFC2119]. 738 Readers are expected to be familiar with [RFC5389] and the terms 739 defined there. 741 The following terms are used in this document: 743 TURN: The protocol spoken between a TURN client and a TURN server. 744 It is an extension to the STUN protocol [RFC5389]. The protocol 745 allows a client to allocate and use a relayed transport address. 747 TURN client: A STUN client that implements this specification. 749 TURN server: A STUN server that implements this specification. It 750 relays data between a TURN client and its peer(s). 752 Peer: A host with which the TURN client wishes to communicate. The 753 TURN server relays traffic between the TURN client and its 754 peer(s). The peer does not interact with the TURN server using 755 the protocol defined in this document; rather, the peer receives 756 data sent by the TURN server and the peer sends data towards the 757 TURN server. 759 Transport Address: The combination of an IP address and a port. 761 Host Transport Address: A transport address on a client or a peer. 763 Server-Reflexive Transport Address: A transport address on the 764 "public side" of a NAT. This address is allocated by the NAT to 765 correspond to a specific host transport address. 767 Relayed Transport Address: A transport address on the TURN server 768 that is used for relaying packets between the client and a peer. 769 A peer sends to this address on the TURN server, and the packet is 770 then relayed to the client. 772 TURN Server Transport Address: A transport address on the TURN 773 server that is used for sending TURN messages to the server. This 774 is the transport address that the client uses to communicate with 775 the server. 777 Peer Transport Address: The transport address of the peer as seen by 778 the server. When the peer is behind a NAT, this is the peer's 779 server-reflexive transport address. 781 Allocation: The relayed transport address granted to a client 782 through an Allocate request, along with related state, such as 783 permissions and expiration timers. 785 5-tuple: The combination (client IP address and port, server IP 786 address and port, and transport protocol (currently one of UDP, 787 TCP, or TLS)) used to communicate between the client and the 788 server. The 5-tuple uniquely identifies this communication 789 stream. The 5-tuple also uniquely identifies the Allocation on 790 the server. 792 Channel: A channel number and associated peer transport address. 793 Once a channel number is bound to a peer's transport address, the 794 client and server can use the more bandwidth-efficient ChannelData 795 message to exchange data. 797 Permission: The IP address and transport protocol (but not the port) 798 of a peer that is permitted to send traffic to the TURN server and 799 have that traffic relayed to the TURN client. The TURN server 800 will only forward traffic to its client from peers that match an 801 existing permission. 803 Realm A string used to describe the server or a context within the 804 server. The realm tells the client which username and password 805 combination to use to authenticate requests. 807 Nonce A string chosen at random by the server and included in the 808 message-digest. To prevent reply attacks, the server should 809 change the nonce regularly. 811 4. General Behavior 813 This section contains general TURN processing rules that apply to all 814 TURN messages. 816 TURN is an extension to STUN. All TURN messages, with the exception 817 of the ChannelData message, are STUN-formatted messages. All the 818 base processing rules described in [RFC5389] apply to STUN-formatted 819 messages. This means that all the message-forming and -processing 820 descriptions in this document are implicitly prefixed with the rules 821 of [RFC5389]. 823 In addition, the server SHOULD demand that all requests from the 824 client be authenticated, using the Long-Term Credential mechanism 825 described in [RFC5389], and the client MUST be prepared to 826 authenticate requests if required. Note that this authentication 827 mechanism applies only to requests and cannot be used to authenticate 828 indications, thus indications in TURN are never authenticated. If 829 the server requires requests to be authenticated, then the server's 830 administrator MUST choose a realm value that will uniquely identify 831 the username and password combination that the client must use, even 832 if the client uses multiple servers under different administrations. 833 The server's administrator MAY choose to allocate a unique username 834 to each client, or MAY choose to allocate the same username to more 835 than one client (for example, to all clients from the same department 836 or company). For each allocation, the server SHOULD generate a new 837 random nonce when the allocation is first attempted following the 838 randomness recommendations in [RFC4086] and SHOULD expire the nonce 839 at least once every hour during the lifetime of the allocation. 841 All requests after the initial Allocate must use the same username as 842 that used to create the allocation, to prevent attackers from 843 hijacking the client's allocation. Specifically, if the server 844 requires the use of the Long-Term Credential mechanism, and if a non- 845 Allocate request passes authentication under this mechanism, and if 846 the 5-tuple identifies an existing allocation, but the request does 847 not use the same username as used to create the allocation, then the 848 request MUST be rejected with a 441 (Wrong Credentials) error. 850 When a TURN message arrives at the server from the client, the server 851 uses the 5-tuple in the message to identify the associated 852 allocation. For all TURN messages (including ChannelData) EXCEPT an 853 Allocate request, if the 5-tuple does not identify an existing 854 allocation, then the message MUST either be rejected with a 437 855 Allocation Mismatch error (if it is a request), or silently ignored 856 (if it is an indication or a ChannelData message). A client 857 receiving a 437 error response to a request other than Allocate MUST 858 assume the allocation no longer exists. 860 The client SHOULD include the SOFTWARE attribute in all Allocate and 861 Refresh requests and MAY include it in any other requests or 862 indications. The server SHOULD include the SOFTWARE attribute in all 863 Allocate and Refresh responses (either success or failure) and MAY 864 include it in other responses or indications. The client and the 865 server MAY include the FINGERPRINT attribute in any STUN-formatted 866 messages defined in this document. 868 TURN does not use the backwards-compatibility mechanism described in 869 [RFC5389]. 871 By default, TURN runs on the same ports as STUN: 3478 for TURN over 872 UDP and TCP, and 5349 for TURN over TLS. However, TURN has its own 873 set of SRV service names: "turn" for UDP and TCP, and "turns" for 874 TLS. Either the SRV procedures or the ALTERNATE-SERVER procedures, 875 both described in Section 6, can be used to run TURN on a different 876 port. 878 TURN as defined in this specification only supports IPv4. The 879 client's IP address, the server's IP address and all IP addresses 880 appearing in a relayed-transport-address MUST be IPv4 addresses. 882 When UDP transport is used between the client and the server, the 883 client will retransmit a request if it does not receive a response 884 within a certain timeout period. Because of this, the server may 885 receive two (or more) requests with the same 5-tuple and same 886 transaction id. STUN requires that the server recognize this case 887 and treat the request as idempotent (see [RFC5389]). Some 888 implementations may choose to meet this requirement by remembering 889 all received requests and the corresponding responses for 40 seconds. 890 Other implementations may choose to reprocess the request and arrange 891 that such reprocessing returns essentially the same response. To aid 892 implementors who choose the latter approach (the so-called "stateless 893 stack approach"), this specification includes some implementation 894 notes on how this might be done. Implementations are free to choose 895 either approach or choose some other approach that gives the same 896 results. 898 When TCP transport is used between the client and the server, it is 899 possible that a bit error will cause a length field in a TURN packet 900 to become corrupted, causing the receiver to lose synchronization 901 with the incoming stream of TURN messages. A client or server which 902 detects a long sequence of invalid TURN messages over TCP transport 903 SHOULD close the corresponding TCP connection to help the other end 904 detect this situation more rapidly. 906 To mitigate either intentional or unintentional denial-of-service 907 attacks against the server by clients with valid usernames and 908 passwords, it is RECOMMENDED that the server impose limits on both 909 the number of allocations active at one time for a given username and 910 on the amount of bandwidth those allocations can use. The server 911 should reject new allocations that would exceed the limit on the 912 allowed number of allocations active at one time with a 486 913 (Allocation Quota Exceeded) (see Section 6.2), and should discard 914 application data traffic that exceeds the bandwidth quota. 916 5. Allocations 918 All TURN operations revolve around allocations, and all TURN messages 919 are associated with an allocation. An allocation conceptually 920 consists of the following state data: 922 o the relayed transport address 924 o The 5-tuple: (client's IP address, client's port, server IP 925 address, server port, transport protocol) 927 o the authentication information 929 o the time-to-expiry 931 o A list of permissions 933 o A list of channel to peer bindings 935 The relayed transport address is the transport address allocated by 936 the server for communicating with peers, while the 5-tuple describes 937 the communication path between the client and the server. On the 938 client, the 5-tuple uses the client's host transport address, while 939 on the server the 5-tuple uses the client's server-reflexive 940 transport address. 942 Both the relayed-transport-address and the 5-tuple MUST be unique 943 across all allocations, so either one can be used to uniquely 944 identify the allocation. 946 The authentication information (e.g., username, password, realm, and 947 nonce) are used to both verify subsequent requests and to compute the 948 message integrity of responses. The username, realm, and nonce 949 values are initially those used in the authenticated Allocate request 950 that creates the allocation, though the server can change the nonce 951 value during the lifetime of the allocation using a 438 (Stale Nonce) 952 reply. Note that rather than storing the password explicitly, it may 953 be desirable for security reasons for the server to store the key 954 value which is an MD5 hash over the username, realm and password (see 955 [RFC5389]). 957 The time-to-expiry is the time in seconds left until the allocation 958 expires. Each Allocate or Refresh transaction sets this timer, which 959 then ticks down towards 0. By default, each Allocate or Refresh 960 transaction resets this timer to 600 seconds (10 minutes), but the 961 client can request a different value in the Allocate and Refresh 962 request. Allocations can only be refreshed using the Refresh 963 request; sending data to a peer does not refresh an allocation. When 964 an allocation expires, the state data associated with the allocation 965 can be freed. 967 The list of permissions is described in Section 8 and the list of 968 channels is described in Section 11. 970 6. Creating an Allocation 972 An allocation on the server is created using an Allocate transaction. 974 6.1. Sending an Allocate Request 976 The client forms an Allocate request as follows. 978 The client first picks a host transport address. It is RECOMMENDED 979 that the client pick a currently-unused transport address, typically 980 by allowing the underlying OS to pick a currently-unused port for a 981 new socket. 983 The client then picks a transport protocol to use between the client 984 and the server. The transport protocol MUST be one of UDP, TCP, or 985 TLS over TCP. Since this specification only allows UDP between the 986 server and the peers, it is RECOMMENDED that the client pick UDP 987 unless it has a reason to use a different transport. One reason to 988 pick a different transport would be that the client believes, either 989 through configuration or by experiment, that it is unable to contact 990 any TURN server using UDP. See Section 2.1 for more discussion. 992 The client also picks a server transport address, which SHOULD be 993 done as follows. The client receives (perhaps through configuration) 994 a domain name for a TURN server. The client then uses the DNS 995 procedures described in [RFC5389], but using an SRV service name of 996 "turn" (or "turns" for TURN over TLS) instead of "stun" (or "stuns"). 997 For example, to find servers in the example.com domain, the client 998 performs a lookup for '_turn._udp.example.com', 999 '_turn._tcp.example.com', and '_turns._tcp.example.com' if the client 1000 wants to communicate with the server using UDP, TCP, or TLS over TCP, 1001 respectively. 1003 The client MUST include a REQUESTED-TRANSPORT attribute in the 1004 request. This attribute specifies the transport protocol between the 1005 server and the peers (note that this is NOT the transport protocol 1006 that appears in the 5-tuple). In this specification, the REQUESTED- 1007 TRANSPORT type is always UDP. This attribute is included to allow 1008 future extensions specify other protocols. 1010 If the client wishes the server to initialize the time-to-expiry 1011 field of the allocation to some value other the default lifetime, 1012 then it MAY include a LIFETIME attribute specifying its desired 1013 value. This is just a request, and the server may elect to use a 1014 different value. Note that the server will ignore requests to 1015 initialize the field to less than the default value. 1017 If the client wishes to later use the DONT-FRAGMENT attribute in one 1018 or more Send indications on this allocation, then the client SHOULD 1019 include the DONT-FRAGMENT attribute in the Allocate request. This 1020 allows the client to test whether this attribute is supported by the 1021 server. 1023 If the client requires the port number of the relayed-transport 1024 address be even, the client includes the EVEN-PORT attribute. If 1025 this attribute is not included, then the port can be even or odd. By 1026 setting the R bit in the EVEN-PORT attribute to 1, the client can 1027 request that the server reserve the next highest port number (on the 1028 same IP address) for a subsequent allocation. If the R bit is 0, no 1029 such request is made. 1031 The client MAY also include a RESERVATION-TOKEN attribute in the 1032 request to ask the server to use a previously reserved port for the 1033 allocation. If the RESERVATION-TOKEN attribute is included, then the 1034 client MUST omit the EVEN-PORT attribute. 1036 Once constructed, the client sends the Allocate request on the 1037 5-tuple. 1039 6.2. Receiving an Allocate Request 1041 When the server receives an Allocate request, it performs the 1042 following checks: 1044 1. The server SHOULD require that the request be authenticated using 1045 the Long-Term Credential mechanism of [RFC5389]. 1047 2. The server checks if the 5-tuple is currently in use by an 1048 existing allocation. If yes, the server rejects the request with 1049 a 437 (Allocation Mismatch) error. 1051 3. The server checks if the request contain a REQUESTED-TRANSPORT 1052 attribute. If the REQUESTED-TRANSPORT attribute is not included 1053 or is malformed, the server rejects the request with a 400 (Bad 1054 Request) error. Otherwise, if the attribute is included but 1055 specifies a protocol other that UDP, the server rejects the 1056 request with a 442 (Unsupported Transport Protocol) error. 1058 4. The request may contain a DONT-FRAGMENT attribute. If it does, 1059 but the server does not support sending UDP datagrams with the DF 1060 bit set to 1 (see Section 12), then the server treats the DONT- 1061 FRAGMENT attribute in the Allocate request as an unknown 1062 comprehension-required attribute. 1064 5. The server checks if the request contains an EVEN-PORT attribute. 1065 If yes, then the server checks that it satisfy the request. If 1066 the server cannot satisfy the request, then the server rejects 1067 the request with a 508 (Insufficient Port Capacity) error. 1069 6. The server checks if the request contains a RESERVATION-TOKEN 1070 attribute. If yes, and the request also contains a EVEN-PORT 1071 attribute, then the server rejects the request with a 400 (Bad 1072 Request) error. Otherwise it checks to see if the token is valid 1073 (i.e., the token is in range and has not expired, and the 1074 corresponding relayed transport address is still available). If 1075 the token is not valid for some reason, the server rejects the 1076 request with a 508 (Insufficient Port Capacity) error. 1078 7. At any point, the server MAY choose to reject the request with a 1079 486 (Allocation Quota Reached) error if it feels the client is 1080 trying to exceed some locally-defined allocation quota. The 1081 server is free to define this allocation quota any way it wishes, 1082 but SHOULD define it based on the username used to authenticate 1083 the request, and not on the client's transport address. 1085 8. Also at any point, the server MAY choose to reject the request 1086 with a 300 (Try Alternate) error if it wishes to redirect the 1087 client to a different server. The use of this error code and 1088 attribute follow the specification in [RFC5389], with the 1089 modification that a TURN server MAY return this error code and 1090 attribute in unauthenticated error responses as well as in 1091 authenticated error responses. 1093 If all the checks pass, the server creates the allocation. The 1094 5-tuple is set to the 5-tuple from the Allocate request, while the 1095 list of permissions and the list of channels are initially empty. 1097 The server chooses a relayed-transport-address for the allocation as 1098 follows: 1100 o If the request contains an EVEN-PORT attribute with the R bit set 1101 to 0, then the server allocates a relayed-transport-address with 1102 an even port number. 1104 o If the request contains an EVEN-PORT attribute with the R bit set 1105 to 1, then the server looks for a pair of port numbers N and N+1 1106 on the same IP address, where N is even. Port N is used in the 1107 current allocation, while the relayed transport address with port 1108 N+1 is assigned a token and reserved for a future allocation. The 1109 server MUST hold this reservation for at least 30 seconds, and MAY 1110 choose to hold longer (e.g. until the allocation with port N 1111 expires). The server then includes the token in a RESERVATION- 1112 TOKEN attribute in the success response. 1114 o If the request contains a RESERVATION-TOKEN, the server uses the 1115 previously-reserved transport address corresponding to the 1116 included token (if it is still available). Note that the 1117 reservation is a server-wide reservation and is not specific to a 1118 particular allocation, since the Allocate request containing the 1119 RESERVATION-TOKEN uses a different 5-tuple than the Allocate 1120 request that made the reservation. The 5-tuple for the Allocate 1121 request containing the RESERVATION-TOKEN attribute can be any 1122 allowed 5-tuple; it can use a different client IP address and 1123 port, a different transport protocol, and even different server IP 1124 address and port (provided, of course, that the server IP address 1125 and port is one that the server is listening for TURN requests 1126 on). 1128 o Otherwise, the server allocates any available relayed-transport- 1129 address. 1131 In all cases, the server SHOULD only allocate ports from the range 1132 49152 - 65535 (the Dynamic and/or Private Port range [Port-Numbers]), 1133 unless the TURN server application knows, through some means not 1134 specified here, that other applications running on the same host as 1135 the TURN server application will not be impacted by allocating ports 1136 outside this range. This condition can often be satisfied by running 1137 the TURN server application on a dedicated machine and/or by 1138 arranging that any other applications on the machine allocate ports 1139 before the TURN server application starts. In any case, the TURN 1140 server SHOULD NOT allocate ports in the range 0 - 1023 (the Well- 1141 Known Port range) to discourage clients from using TURN to run 1142 standard services. 1144 NOTE: The IETF is currently investigating the topic of randomized 1145 port assignments to avoid certain types of attacks (see 1146 [I-D.ietf-tsvwg-port-randomization]). It is strongly recommended 1147 that a TURN implementor keep abreast of this topic and, if 1148 appropriate, implement a randomized port assignment algorithm. 1149 This is especially applicable to servers that choose to pre- 1150 allocate a number of ports from the underlying OS and then later 1151 assign them to allocations; for example, a server may choose this 1152 technique to implement the EVEN-PORT attribute. 1154 The server determines the initial value of the time-to-expiry field 1155 as follows. If the request contains a LIFETIME attribute, and the 1156 proposed lifetime value is greater than the default lifetime, and the 1157 proposed lifetime value is otherwise acceptable to the server, then 1158 the server uses that value. Otherwise, the server uses the default 1159 lifetime. It is RECOMMENDED that the server impose a maximum 1160 lifetime of no more than 3600 seconds (1 hour). Servers that 1161 implement allocation quotas or charge users for allocations in some 1162 way may wish to use a smaller maximum lifetime (perhaps as small as 1163 the default lifetime) to more quickly remove orphaned allocations 1164 (that is, allocations where the corresponding client has crashed or 1165 terminated or the client connection has been lost for some reason). 1166 Also note that the time-to-expiry is recomputed with each successful 1167 Refresh request, and thus the value computed here applies only until 1168 the first refresh. 1170 Once the allocation is created, the server replies with a success 1171 response. The success response contains: 1173 o A XOR-RELAYED-ADDRESS attribute containing the relayed transport 1174 address; 1176 o A LIFETIME attribute containing the current value of the time-to- 1177 expiry timer; 1179 o A RESERVATION-TOKEN attribute (if a second relayed transport 1180 address was reserved). 1182 o An XOR-MAPPED-ADDRESS attribute containing the client's IP address 1183 and port (from the 5-tuple). 1185 NOTE: The XOR-MAPPED-ADDRESS attribute is included in the response 1186 as a convenience to the client. TURN itself does not make use of 1187 this value, but clients running ICE can often need this value and 1188 can thus avoid having to do an extra Binding transaction with some 1189 STUN server to learn it. 1191 The response (either success or error) is sent back to the client on 1192 the 5-tuple. 1194 NOTE: Implementations may implement the idempotency of the 1195 Allocate request over UDP using the so-called "stateless stack 1196 approach" as follows. To detect retransmissions when the original 1197 request was successful in creating an allocation, the server can 1198 store the transaction id that created the request with the 1199 allocation data and compare it with incoming Allocate requests on 1200 the same 5-tuple. Once such a request is detected, the server can 1201 stop parsing the request and immediately generate a success 1202 response. When building this response, the value of the LIFETIME 1203 attribute can be taken from the time-to-expiry field in the 1204 allocate state data, even though this value may differ slightly 1205 from the LIFETIME value originally returned. In addition, the 1206 server may need to store an indication of any reservation token 1207 returned in the original response, so that this may be returned in 1208 any retransmitted responses. 1210 For the case where the original request was unsuccessful in 1211 creating an allocation, the server may choose to do nothing 1212 special. Note, however, that there is a rare case where the 1213 server rejects the original request but accepts the retransmitted 1214 request (because conditions have changed in the brief intervening 1215 time period). If the client receives the first failure response, 1216 it will ignore the second (success) response and believe that an 1217 allocation was not created. An allocation created in this matter 1218 will eventually timeout, since the client will not refresh it. 1219 Furthermore, if the client later retries with the same 5-tuple but 1220 different transaction id, it will receive a 437 (Allocation 1221 Mismatch), which will cause it to retry with a different 5-tuple. 1222 The server may use a smaller maximum lifetime value to minimize 1223 the lifetime of allocations "orphaned" in this manner. 1225 6.3. Receiving an Allocate Success Response 1227 If the client receives an Allocate success response, then it MUST 1228 check that the mapped address and the relayed transport address are 1229 in an address family that the client understands and is prepared to 1230 deal with. This specification only covers the case where these two 1231 addresses are IPv4 addresses. If these two addresses are not in an 1232 address family that the client is prepared to deal with, then the 1233 client MUST delete the allocation (Section 7) and MUST NOT attempt to 1234 create another allocation on that server until it believes the 1235 mismatch has been fixed. 1237 The IETF is currently considering mechanisms for transitioning 1238 between IPv4 and IPv6 that could result in a client originating an 1239 Allocate request over IPv6, but the request would arrive at the 1240 server over IPv4, or vica-versa. Hence the importance of this 1241 check. 1243 Otherwise, the client creates its own copy of the allocation data 1244 structure to track what is happening on the server. In particular, 1245 the client needs to remember the actual lifetime received back from 1246 the server, rather than the value sent to the server in the request. 1247 The client must also remember the 5-tuple used for the request and 1248 the username and password it used to authenticate the request to 1249 ensure that it reuses them for subsequent messages. The client also 1250 needs to track the channels and permissions it establishes on the 1251 server. 1253 The client will probably wish to send the relayed transport address 1254 to peers (using some method not specified here) so the peers can 1255 communicate with it. The client may also wish to use the server- 1256 reflexive address it receives in the XOR-MAPPED-ADDRESS attribute in 1257 its ICE processing. 1259 6.4. Receiving an Allocate Error Response 1261 If the client receives an Allocate error response, then the 1262 processing depends on the actual error code returned: 1264 o (Request timed out): There is either a problem with the server, or 1265 a problem reaching the server with the chosen transport. The 1266 client considers the current transaction as having failed but MAY 1267 choose to retry the Allocate request using a different transport 1268 (e.g., TCP instead of UDP). 1270 o 300 (Try Alternate): The server would like the client to use the 1271 server specified in the ALTERNATE-SERVER attribute instead. The 1272 client considers the current transaction as having failed, but 1273 SHOULD try the Allocate request with the alternate server before 1274 trying any other servers (e.g., other servers discovered using the 1275 SRV procedures). When trying the Allocate request with the 1276 alternate server, the client follows the ALTERNATE-SERVER 1277 procedures specified in [RFC5389] with the following changes: the 1278 client SHOULD accept unauthenticated error responses containing 1279 the 300 (Try Alternate) error code, the client MUST ensure that 1280 the realm value received from the alternate server is as expected, 1281 the client MUST use the same transport protocol to the alternate 1282 server as it used to the original server, and the client MUST use 1283 the same username and password as it would have with the original 1284 server. The latter checks protect against an attacker sending the 1285 client an unauthenticated Allocate error response that redirects 1286 the client to some totally different and unexpected server. 1288 o 400 (Bad Request): The server believes the client's request is 1289 malformed for some reason. The client considers the current 1290 transaction as having failed. The client MAY notify the user or 1291 operator and SHOULD NOT retry the request with this server until 1292 it believes the problem has been fixed. 1294 o 401 (Unauthorized): If the client has followed the procedures of 1295 the Long-Term Credential mechanism and still gets this error, then 1296 the server is not accepting the client's credentials. In this 1297 case, the client considers the current transaction as having 1298 failed and SHOULD notify the user or operator. The client SHOULD 1299 NOT send any further requests to this server until it believes the 1300 problem has been fixed. 1302 o 403 (Forbidden): The request is valid, but the server is refusing 1303 to perform it, likely due to administrative restrictions. The 1304 client considers the current transaction as having failed. The 1305 client MAY notify the user or operator and SHOULD NOT retry the 1306 same request with this server until it believes the problem has 1307 been fixed. 1309 o 420 (Unknown Attribute): If the client included a DONT-FRAGMENT 1310 attribute in the request and the server rejected the request with 1311 a 420 error code and listed the DONT-FRAGMENT attribute in the 1312 UNKNOWN-ATTRIBUTES attribute in the error response, then the 1313 client now knows that the server does not support the DONT- 1314 FRAGMENT attribute. The client considers the current transaction 1315 as having failed but MAY choose to retry the Allocate request 1316 without the DONT-FRAGMENT attribute. 1318 o 437 (Allocation Mismatch): This indicates that the client has 1319 picked a 5-tuple which the server sees as already in use. One way 1320 this could happen is if an intervening NAT assigned a mapped 1321 transport address that was used by another client which recently 1322 crashed. The client considers the current transaction as having 1323 failed. The client SHOULD pick another client transport address 1324 and retry the Allocate request (using a different transaction id). 1325 The client SHOULD try three different client transport addresses 1326 before giving up on this server. Once the client gives up on the 1327 server, it SHOULD NOT try to create another allocation on the 1328 server for 2 minutes. 1330 o 438 (Stale Nonce): See the procedures for the Long-Term Credential 1331 mechanism [RFC5389]. 1333 o 441 (Wrong Credentials): The client should not receive this error 1334 in response to a Allocate request. The client MAY notify the user 1335 or operator and SHOULD NOT retry the same request with this server 1336 until it believes the problem has been fixed. 1338 o 442 (Unsupported Transport Address): The client should not receive 1339 this error in response to a request for a UDP allocation. The 1340 client MAY notify the user or operator and SHOULD NOT reattempt 1341 the request with this server until it believes the problem has 1342 been fixed. 1344 o 486 (Allocation Quota Reached): The server is currently unable to 1345 create any more allocations with this username. The client 1346 considers the current transaction as having failed. The client 1347 SHOULD wait at least 1 minute before trying to create any more 1348 allocations on the server. 1350 o 508 (Insufficient Port Capacity): The server has no more relayed 1351 transport addresses available, or has none with the requested 1352 properties, or the one that was reserved is no longer available. 1353 The client considers the current operation as having failed. If 1354 the client is using either the EVEN-PORT or the RESERVATION-TOKEN 1355 attribute, then the client MAY choose to remove or modify this 1356 attribute and try again immediately. Otherwise, the client SHOULD 1357 wait at least 1 minute before trying to create any more 1358 allocations on this server. 1360 7. Refreshing an Allocation 1362 A Refresh transaction can be used to either (a) refresh an existing 1363 allocation and update its time-to-expiry, or (b) delete an existing 1364 allocation. 1366 If a client wishes to continue using an allocation, then the client 1367 MUST refresh it before it expires. It is suggested that the client 1368 refresh the allocation roughly 1 minute before it expires. If a 1369 client no longer wishes to use an allocation, then it SHOULD 1370 explicitly delete the allocation. A client MAY also refresh an 1371 allocation at any time for other reasons. 1373 7.1. Sending a Refresh Request 1375 If the client wishes to immediately delete an existing allocation, it 1376 includes a LIFETIME attribute with a value of 0. All other forms of 1377 the request refresh the allocation. 1379 The Refresh transaction updates the time-to-expiry timer of an 1380 allocation. If the client wishes the server to set the time-to- 1381 expiry timer to something other than the default lifetime, it 1382 includes a LIFETIME attribute with the requested value. The server 1383 then computes a new time-to-expiry value in the same way as it does 1384 for an Allocate transaction, with the exception that a requested 1385 lifetime of 0 causes the server to immediately delete the allocation. 1387 7.2. Receiving a Refresh Request 1389 When the server receives a Refresh request, it processes as per 1390 Section 4 plus the specific rules mentioned here. 1392 The server computes a value called the "desired lifetime" as follows: 1393 If the request contains a LIFETIME attribute and the attribute value 1394 is 0, then the desired lifetime is 0. Otherwise, if the request 1395 contains a LIFETIME attribute and the attribute value is greater than 1396 the default lifetime, and if the attribute value is otherwise 1397 acceptable to the server, then the desired lifetime is the attribute 1398 value. Otherwise the desired lifetime is the default value. 1400 Subsequent processing depends on the desired lifetime value: 1402 o If desired lifetime is 0, then the request succeeds and the 1403 allocation is deleted. 1405 o If the desired lifetime is non-zero, then the request succeeds and 1406 the allocation's time-to-expiry is set to the desired lifetime 1408 If the request succeeds, then server sends a success response 1409 containing: 1411 o A LIFETIME attribute containing the current value of the time-to- 1412 expiry timer. 1414 NOTE: A server need not do anything special to implement 1415 idempotency of Refresh requests over UDP using the "stateless 1416 stack approach". Retransmitted Refresh requests with a non-zero 1417 desired lifetime will simply refresh the allocation. A 1418 retransmitted Refresh request with a zero desired lifetime will 1419 cause a 437 (Allocation Mismatch) response if the allocation has 1420 already been deleted, but the client will treat this as equivalent 1421 to a success response (see below). 1423 7.3. Receiving a Refresh Response 1425 If the client receives a success response to its Refresh request with 1426 a non-zero lifetime, it updates its copy of the allocation data 1427 structure with the time-to-expiry value contained in the response. 1429 If the client receives a 437 (Allocation Mismatch) error response to 1430 a request to delete the allocation, then the allocation no longer 1431 exists and it should consider its request as having effectively 1432 succeeded. 1434 8. Permissions 1436 For each allocation, the server keeps a list of zero or more 1437 permissions. Each permission consists of an IP address which 1438 uniquely identifies the permission, and an associated time-to-expiry. 1439 The IP address describes a set of peers that are allowed to send data 1440 to the client, and the time-to-expiry is the number of seconds until 1441 the permission expires. 1443 By sending either CreatePermission requests or ChannelBind requests, 1444 the client can cause the server to install or refresh a permission 1445 for a given IP address. This causes one of two things to happen: 1447 o If no permission for that IP address exists, then a permission is 1448 created with the given IP address and a time-to-expiry equal to 1449 the default permission lifetime. 1451 o If a permission for that IP address already exists, then the 1452 lifetime for that permission is reset to the default permission 1453 lifetime. 1455 The default permission lifetime MUST be 300 seconds (= 5 minutes). 1457 Each permission's time-to-expiry decreases down once per second until 1458 it reaches 0, at which point the permission expires and is deleted. 1460 CreatePermission and ChannelBind requests may be freely intermixed on 1461 a permission. A given permission may be installed or refreshed at 1462 one point in time with a CreatePermission request, and then refreshed 1463 with a ChannelBind request at a different point in time, or vice- 1464 versa. 1466 When a UDP datagram arrives at the relayed transport address for the 1467 allocation, the server checks the list of permissions for that 1468 allocation. If there is a permission with an IP address that is 1469 equal to the source IP address of the UDP datagram, then the UDP 1470 datagram can be relayed to the client. Otherwise, the UDP datagram 1471 is silently discarded. Note that only IP addresses are compared; 1472 port numbers are irrelevant. 1474 The permissions for one allocation are totally unrelated to the 1475 permissions for a different allocation. If an allocation expires, 1476 all its permissions expire with it. 1478 NOTE: Though TURN permissions expire after 5 minutes, many NATs 1479 deployed at the time of publication expire their UDP bindings 1480 considerably faster. Thus an application using TURN will probably 1481 wish to send some sort of keep-alive traffic at a much faster 1482 rate. Applications using ICE should follow the keep-alive 1483 guidelines of ICE [I-D.ietf-mmusic-ice], and applications not 1484 using ICE are advised to do something similar. 1486 9. CreatePermission 1488 TURN supports two ways for the client to install or refresh 1489 permissions on the server. This section describes one way: the 1490 CreatePermission request. 1492 A CreatePermission request may be used in conjunction with either the 1493 Send mechanism in Section 10 or the Channel mechanism in Section 11. 1495 9.1. Forming a CreatePermission request 1497 The client who wishes to install or refresh one or more permissions 1498 can send a CreatePermission request to the server. 1500 When forming a CreatePermission request, the client MUST include at 1501 least one XOR-PEER-ADDRESS attribute, and MAY include more than one 1502 such attribute. The IP address portion of each XOR-PEER-ADDRESS 1503 attribute contains the IP address for which a permission should be 1504 installed or refreshed. The port portion of each XOR-PEER-ADDRESS 1505 attribute will be ignored and can be any arbitrary value. The 1506 various XOR-PEER-ADDRESS attributes can appear in any order. 1508 9.2. Receiving a CreatePermission request 1510 When the server receives the CreatePermission request, it processes 1511 as per Section 4 plus the specific rules mentioned here. 1513 The message is checked for validity. The CreatePermission request 1514 MUST contain at least XOR-PEER-ADDRESS attribute and MAY contain 1515 multiple such attributes. If no such attribute exists, or if any of 1516 these attributes are invalid, then a 400 (Bad Request) error is 1517 returned. If the request is valid, but the server is unable to 1518 satisfy the request due to some capacity limit or similar, then a 508 1519 (Insufficient Capacity) error is returned. 1521 The server MAY impose restrictions on the IP address and port values 1522 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 1523 allowed, the server rejects the request with a 403 (Forbidden) error. 1525 If the message is valid and the server is capable of carrying out the 1526 request, then the server installs or refreshes a permission for the 1527 IP address contained in each XOR-PEER-ADDRESS attribute as described 1528 in Section 8. The port portion of each attribute is ignored and may 1529 be any arbitrary value. 1531 The server then responds with a CreatePermission success response. 1532 There are no mandatory attributes in the success response. 1534 NOTE: A server need not do anything special to implement 1535 idempotency of CreatePermission requests over UDP using the 1536 "stateless stack approach". Retransmitted CreatePermission 1537 requests will simply refresh the permissions. 1539 9.3. Receiving a CreatePermission response 1541 If the client receives a valid CreatePermission success response, 1542 then the client updates its data structures to indicate that the 1543 permissions have been installed or refreshed. 1545 10. Send and Data Methods 1547 TURN supports two mechanisms for sending and receiving data from 1548 peers. This section describes the use of the Send and Data 1549 mechanism, while Section 11 describes the use of the Channel 1550 mechanism. 1552 10.1. Forming a Send Indication 1554 The client can use a Send indication to pass data to the server for 1555 relaying to a peer. A client may use a Send indication even if a 1556 channel is bound to that peer. However the client MUST ensure that 1557 there is a permission installed for the IP address of the peer to 1558 which the Send indication is being sent; this prevents a third party 1559 from using a TURN server to send data to arbitrary destinations. 1561 When forming a Send indication, the client MUST include a XOR-PEER- 1562 ADDRESS attribute and a DATA attribute. The XOR-PEER-ADDRESS 1563 attribute contains the transport address of the peer to which the 1564 data is to be sent, and the DATA attribute contains the actual 1565 application data to be sent to the peer. 1567 The client MAY include a DONT-FRAGMENT attribute in the Send 1568 indication if it wishes the server to set the DF bit on the UDP 1569 datagram sent to the peer. 1571 10.2. Receiving a Send Indication 1573 When the server receives a Send indication, it processes as per 1574 Section 4 plus the specific rules mentioned here. 1576 The message is first checked for validity. The Send indication MUST 1577 contain both a XOR-PEER-ADDRESS attribute and a DATA attribute. If 1578 one of these attributes is missing or invalid, then the message is 1579 discarded. Note that the DATA attribute is allowed to contain zero 1580 bytes of data. 1582 The Send indication may also contain the DONT-FRAGMENT attribute. If 1583 the server is unable to set the DF bit on outgoing UDP datagrams when 1584 this attribute is present, then the server acts as if the DONT- 1585 FRAGMENT attribute is an unknown comprehension-required attribute 1586 (and thus the Send indication is discarded). 1588 The server also checks that there is a permission installed for the 1589 IP address contained in the XOR-PEER-ADDRESS attribute. If no such 1590 permission exists, the message is discarded. Note that a Send 1591 indication never causes the server to refresh the permission. 1593 The server MAY impose restrictions on the IP address and port values 1594 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 1595 allowed, the server silently discards the Send indication. 1597 If everything is OK, then the server forms a UDP datagram as follows: 1599 o the source transport address is the relayed transport address of 1600 the allocation, where the allocation is determined by the 5-tuple 1601 on which the Send indication arrived; 1603 o the destination transport address is taken from the XOR-PEER- 1604 ADDRESS attribute; 1606 o the data following the UDP header is the contents of the value 1607 field of the DATA attribute. 1609 The handling of the DONT-FRAGMENT attribute (if present), is 1610 described in Section 12. 1612 The resulting UDP datagram is then sent to the peer. 1614 10.3. Receiving a UDP Datagram 1616 When the server receives a UDP datagram at a currently allocated 1617 relayed transport address, the server looks up the allocation 1618 associated with the relayed transport address. It then checks to see 1619 if relaying is permitted, as described in Section 8. 1621 If relaying is permitted, then the server checks if there is a 1622 channel bound to the peer that sent the UDP datagram (see 1623 Section 11). If a channel is bound, then processing proceeds as 1624 described in Section 11.7. 1626 If relaying is permitted but no channel is bound to the peer, then 1627 the server forms and sends a Data indication. The Data indication 1628 MUST contain both a XOR-PEER-ADDRESS and a DATA attribute. The DATA 1629 attribute is set to the value of the 'data octets' field from the 1630 datagram, and the XOR-PEER-ADDRESS attribute is set to the source 1631 transport address of the received UDP datagram. The Data indication 1632 is then sent on the 5-tuple associated with the allocation. 1634 10.4. Receiving a Data Indication 1636 When the client receives a Data indication, it checks that the Data 1637 indication contains both a XOR-PEER-ADDRESS and a DATA attribute, and 1638 discards the indication if it does not. The client SHOULD also check 1639 that the XOR-PEER-ADDRESS attribute value contains an IP address with 1640 which the client believes there is an active permission, and discard 1641 the Data indication otherwise. Note that the DATA attribute is 1642 allowed to contain zero bytes of data. 1644 NOTE: The latter check protects the client against an attacker who 1645 somehow manages to trick the server into installing permissions 1646 not desired by the client. 1648 If the Data indication passes the above checks, the client delivers 1649 the data octets inside the DATA attribute to the application, along 1650 with an indication that they were received from the peer whose 1651 transport address is given by the XOR-PEER-ADDRESS attribute. 1653 11. Channels 1655 Channels provide a way for the client and server to send application 1656 data using ChannelData messages, which have less overhead than Send 1657 and Data indications. 1659 The ChannelData message (see Section 11.4) starts with a two-byte 1660 field that carries the channel number. The values of this field are 1661 allocated as follows: 1663 0x0000 through 0x3FFF: These values can never be used for channel 1664 numbers. 1666 0x4000 through 0x7FFF: These values are the allowed channel 1667 numbers (16,383 possible values) 1669 0x8000 through 0xFFFF: These values are reserved for future use. 1671 Because of this division, ChannelData messages can be distinguished 1672 from STUN-formatted messages (e.g., Allocate request, Send 1673 indication, etc) by examining the first two bits of the message: 1675 0b00: STUN-formatted message (since the first two bits of a STUN- 1676 formatted message are always zero) 1678 0b01: ChannelData message (since the channel number is the first 1679 field in the ChannelData message and channel numbers fall in the 1680 range 0x4000 - 0x7FFF) 1681 0b10: Reserved 1683 0b11: Reserved 1685 The reserved values may be used in the future to extend the range of 1686 channel numbers. Thus an implementation MUST NOT assume that a TURN 1687 message always starts with a 0 bit. 1689 Channel bindings are always initiated by the client. The client can 1690 bind a channel to a peer at any time during the lifetime of the 1691 allocation. The client may bind a channel to a peer before 1692 exchanging data with it, or after exchanging data with it (using Send 1693 and Data indications) for some time, or may choose never to bind a 1694 channel to it. The client can also bind channels to some peers while 1695 not binding channels to other peers. 1697 Channel bindings are specific to an allocation, so that the use of a 1698 channel number or peer transport address in a channel binding in one 1699 allocation has no impact on their use in a different allocation. If 1700 an allocation expires, all its channel bindings expire with it. 1702 A channel binding consists of: 1704 o A channel number; 1706 o A transport address (of the peer); 1708 o A time-to-expiry timer. 1710 Within the context of an allocation, a channel binding is uniquely 1711 identified either by the channel number or by the peer's transport 1712 address. Thus the same channel cannot be bound to two different 1713 transport addresses, nor can the same transport address be bound to 1714 two different channels. 1716 A channel binding lasts for 10 minutes unless refreshed. Refreshing 1717 the binding (by the server receiving a ChannelBind request rebinding 1718 the channel to the same peer) resets the time-to-expiry timer back to 1719 10 minutes. 1721 When the channel binding expires, the channel becomes unbound. Once 1722 unbound, the channel number can be bound to a different transport 1723 address, and the transport address can be bound to a different 1724 channel number. To prevent race conditions, the client MUST wait 5 1725 minutes after the channel binding expires before attempting to bind 1726 the channel number to a different transport address or the transport 1727 address to a different channel number. 1729 When binding a channel to a peer, the client SHOULD be prepared to 1730 receive ChannelData messages on the channel from the server as soon 1731 as it has sent the ChannelBind request. Over UDP, it is possible for 1732 the client to receive ChannelData messages from the server before it 1733 receives a ChannelBind success response. 1735 In the other direction, the client MAY elect to send ChannelData 1736 messages before receiving the ChannelBind success response. Doing 1737 so, however, runs the risk of having the ChannelData messages dropped 1738 by the server if the ChannelBind request does not succeed for some 1739 reason (e.g., packet lost if the request is sent over UDP, or the 1740 server being unable to fulfill the request). A client that wishes to 1741 be safe should either queue the data, or use Send indications until 1742 the channel binding is confirmed. 1744 11.1. Sending a ChannelBind Request 1746 A channel binding is created or refreshed using a ChannelBind 1747 transaction. A ChannelBind transaction also creates or refreshes a 1748 permission towards the peer. 1750 To initiate the ChannelBind transaction, the client forms a 1751 ChannelBind request. The channel to be bound is specified in a 1752 CHANNEL-NUMBER attribute, and the peer's transport address is 1753 specified in a XOR-PEER-ADDRESS attribute. Section 11.2 describes 1754 the restrictions on these attributes. 1756 Rebinding a channel to the same transport address that it is already 1757 bound to provides a way to refresh a channel binding and the 1758 corresponding permission without sending data to the peer. Note 1759 however, that permissions need to be refreshed more frequently than 1760 channels. 1762 11.2. Receiving a ChannelBind Request 1764 When the server receives a ChannelBind request, it processes as per 1765 Section 4 plus the specific rules mentioned here. 1767 The server checks the following: 1769 o The request contains both a CHANNEL-NUMBER and a XOR-PEER-ADDRESS 1770 attribute; 1772 o The channel number is in the range 0x4000 through 0x7FFE 1773 (inclusive); 1775 o The channel number is not currently bound to a different transport 1776 address (same transport address is OK); 1778 o The transport address is not currently bound to a different 1779 channel number. 1781 If any of these tests fail, the server replies with a 400 (Bad 1782 Request) error. 1784 The server MAY impose restrictions on the IP address and port values 1785 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 1786 allowed, the server rejects the request with a 403 (Forbidden) error. 1788 If the request is valid, but the server is unable to fulfill the 1789 request due to some capacity limit or similar, the server replies 1790 with a 508 (Insufficient Capacity) error. 1792 Otherwise, the server replies with a ChannelBind success response. 1793 There are no required attributes in a successful ChannelBind 1794 response. 1796 If the server can satisfy the request, then the server creates or 1797 refreshes the channel binding using the channel number in the 1798 CHANNEL-NUMBER attribute and the transport address in the XOR-PEER- 1799 ADDRESS attribute. The server also installs or refreshes a 1800 permission for the IP address in the XOR-PEER-ADDRESS attribute as 1801 described in Section 8. 1803 NOTE: A server need not do anything special to implement 1804 idempotency of ChannelBind requests over UDP using the "stateless 1805 stack approach". Retransmitted ChannelBind requests will simply 1806 refresh the channel binding and the corresponding permission. 1807 Furthermore, the client must wait 5 minutes before binding a 1808 previously bound channel number or peer address to a different 1809 channel, eliminating the possibility that the transaction would 1810 initially fail but succeed on a retransmission. 1812 11.3. Receiving a ChannelBind Response 1814 When the client receives a ChannelBind success response, it updates 1815 its data structures to record that the channel binding is now active. 1816 It also updates its data structures to record that the corresponding 1817 permission has been installed or refreshed. 1819 If the client receives a ChannelBind failure response that indicates 1820 that the channel information is out-of-sync between the client and 1821 the server (e.g., an unexpected 400 "Bad Request" response), then it 1822 is RECOMMENDED that the client immediately delete the allocation and 1823 start afresh with a new allocation. 1825 11.4. The ChannelData Message 1827 The ChannelData message is used to carry application data between the 1828 client and the server. It has the following format: 1830 0 1 2 3 1831 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1832 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1833 | Channel Number | Length | 1834 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1835 | | 1836 / Application Data / 1837 / / 1838 | | 1839 | +-------------------------------+ 1840 | | 1841 +-------------------------------+ 1843 The Channel Number field specifies the number of the channel on which 1844 the data is traveling, and thus the address of the peer that is 1845 sending or is to receive the data. 1847 The Length field specifies the length in bytes of the application 1848 data field (i.e., it does not include the size of the ChannelData 1849 header). Note that 0 is a valid length. 1851 The Application Data field carries the data the client is trying to 1852 send to the peer, or that the peer is sending to the client. 1854 11.5. Sending a ChannelData Message 1856 Once a client has bound a channel to a peer, then when the client has 1857 data to send to that peer it may use either a ChannelData message or 1858 a Send indication; that is, the client is not obligated to use the 1859 channel when it exists and may freely intermix the two message types 1860 when sending data to the peer. The server, on the other hand, MUST 1861 use the ChannelData message if a channel has been bound to the peer. 1863 The fields of the ChannelData message are filled in as described in 1864 Section 11.4. 1866 Over stream transports, the ChannelData message MUST be padded to a 1867 multiple of four bytes in order to ensure the alignment of subsequent 1868 messages. The padding is not reflected in the length field of the 1869 ChannelData message, so the actual size of a ChannelData message 1870 (including padding) is (4 + Length) rounded up to the nearest 1871 multiple of 4. Over UDP, the padding is not required but MAY be 1872 included. 1874 The ChannelData message is then sent on the 5-tuple associated with 1875 the allocation. 1877 11.6. Receiving a ChannelData Message 1879 The receiver of the ChannelData message uses the first two bits to 1880 distinguish it from STUN-formatted messages, as described above. If 1881 the message uses a value in the reserved range (0x8000 through 1882 0xFFFF), then the message is silently discarded. 1884 If the ChannelData message is received in a UDP datagram, and if the 1885 UDP datagram is too short to contain the claimed length of the 1886 ChannelData message (i.e., the UDP header length field value is less 1887 than the ChannelData header length field value + 4 + 8), then the 1888 message is silently discarded. 1890 If the ChannelData message is received over TCP or over TLS over TCP, 1891 then the actual length of the ChannelData message is as described in 1892 Section 11.5. 1894 If the ChannelData message is received on a channel which is not 1895 bound to any peer, then the message is silently discarded. 1897 On the client, it is RECOMMENDED that the client discard the 1898 ChannelData message if the client believes there is no active 1899 permission towards the peer. On the server, the receipt of a 1900 ChannelData message MUST NOT refresh either the channel binding or 1901 the permission towards the peer. 1903 On the server, if no errors are detected, the server relays the 1904 application data to the peer by forming a UDP datagram as follows: 1906 o the source transport address is the relayed transport address of 1907 the allocation, where the allocation is determined by the 5-tuple 1908 on which the ChannelData message arrived; 1910 o the destination transport address is the transport address to 1911 which the channel is bound; 1913 o the data following the UDP header is the contents of the data 1914 field of the ChannelData message. 1916 The resulting UDP datagram is then sent to the peer. Note that if 1917 the Length field in the ChannelData message is 0, then there will be 1918 no data in the UDP datagram, but the UDP datagram is still formed and 1919 sent. 1921 11.7. Relaying Data from the Peer 1923 When the server receives a UDP datagram on the relayed transport 1924 address associated with an allocation, the server processes it as 1925 described in Section 10.3. If that section indicates that a 1926 ChannelData message should be sent (because there is a channel bound 1927 to the peer that sent to UDP datagram), then the server forms and 1928 sends a ChannelData message as described in Section 11.5. 1930 12. IP Header Fields 1932 This section describes how the server sets various fields in the IP 1933 header when relaying between the client and the peer or vica-versa. 1934 The descriptions in this section apply: (a) when the server sends a 1935 UDP datagram to the peer, or (b) when the server sends a Data 1936 indication or ChannelData message to the client over UDP transport. 1937 The descriptions in this section do not apply to TURN messages sent 1938 over TCP or TLS transport from the server to the client. 1940 The descriptions below have two parts: a preferred behavior and an 1941 alternate behavior. The server SHOULD implement the preferred 1942 behavior, but if that is not possible for a particular field, then it 1943 SHOULD implement the alternative behavior. 1945 Time to Live (TTL) field 1947 Preferred Behavior: If the incoming value is 0, then the drop the 1948 incoming packet. Otherwise set the outgoing Time to Live/Hop 1949 Count to one less than the incoming value. 1951 Alternate Behavior: Set the outgoing value to the default for 1952 outgoing packets. 1954 Diff-Serv Code Point (DSCP) field [RFC2474] 1956 Preferred Behavior: Set the outgoing value to the incoming value, 1957 unless the server includes a differentiated services classifier 1958 and marker [RFC2474]. 1960 Alternate Behavior: Set the outgoing value to a fixed value, which 1961 by default is Best Effort unless configured otherwise. 1963 In both cases, if the server is immediately adjacent to a 1964 differentiated services classifier and marker, then DSCP MAY be 1965 set to any arbitrary value in the direction towards the 1966 classifier. 1968 Explicit Congestion Notification (ECN) field [RFC3168] 1970 Preferred Behavior: Set the outgoing value to the incoming value, 1971 UNLESS the server is doing Active Queue Management, the incoming 1972 ECN field is ECT(1) (=0b01) or ECT(0) (=0b10), and the server 1973 wishes to indicate that congestion has been experienced, in which 1974 case set the outgoing value to CE (=0b11). 1976 Alternate Behavior: Set the outgoing value to Not-ECT (=0b00). 1978 IPv4 Fragmentation fields 1980 Preferred Behavior: 1982 When the server sends a packet to a peer in response to a Send 1983 indication containing the DONT-FRAGMENT attribute, then set the 1984 DF bit in the outgoing IP header to 1. In all other cases when 1985 sending an outgoing packet containing application data (e.g., 1986 Data indication, ChannelData message, or DONT-FRAGMENT 1987 attribute not included in the Send indication), copy the DF bit 1988 from the DF bit of the incoming packet that contained the 1989 application data. 1991 Set the other fragmentation fields (Identification, MF, 1992 Fragment Offset) as appropriate for a packet originating from 1993 the server. 1995 Alternate Behavior: As described in the Preferred Behavior, except 1996 always assume the incoming DF bit is 0. 1998 In both the Preferred and Alternate Behaviors, the resulting 1999 packet may be too large for the outgoing link. If this is the 2000 case, then the normal fragmentation rules apply [RFC1122]. 2002 IPv4 Options 2004 Preferred Behavior: The outgoing packet is sent without any IPv4 2005 options. 2007 Alternate Behavior: Same as preferred. 2009 13. New STUN Methods 2011 This section lists the codepoints for the new STUN methods defined in 2012 this specification. See elsewhere in this document for the semantics 2013 of these new methods. 2015 0x003 : Allocate (only request/response semantics defined) 2016 0x004 : Refresh (only request/response semantics defined) 2017 0x006 : Send (only indication semantics defined) 2018 0x007 : Data (only indication semantics defined) 2019 0x008 : CreatePermission (only request/response semantics defined 2020 0x009 : ChannelBind (only request/response semantics defined) 2022 14. New STUN Attributes 2024 This STUN extension defines the following new attributes: 2026 0x000C: CHANNEL-NUMBER 2027 0x000D: LIFETIME 2028 0x0010: Reserved (was BANDWIDTH) 2029 0x0012: XOR-PEER-ADDRESS 2030 0x0013: DATA 2031 0x0016: XOR-RELAYED-ADDRESS 2032 0x0018: EVEN-PORT 2033 0x0019: REQUESTED-TRANSPORT 2034 0x001A: DONT-FRAGMENT 2035 0x0021: Reserved (was TIMER-VAL) 2036 0x0022: RESERVATION-TOKEN 2038 14.1. CHANNEL-NUMBER 2040 The CHANNEL-NUMBER attribute contains the number of the channel. It 2041 is a 16-bit unsigned integer, followed by a two-octet RFFU (Reserved 2042 For Future Use) field which MUST be set to 0 on transmission and MUST 2043 be ignored on reception. 2045 0 1 2 3 2046 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2047 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2048 | Channel Number | RFFU = 0 | 2049 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2051 14.2. LIFETIME 2053 The LIFETIME attribute represents the duration for which the server 2054 will maintain an allocation in the absence of a refresh. It is a 32- 2055 bit unsigned integral value representing the number of seconds 2056 remaining until expiration. 2058 14.3. XOR-PEER-ADDRESS 2060 The XOR-PEER-ADDRESS specifies the address and port of the peer as 2061 seen from the TURN server. (In other words, the peer's server- 2062 reflexive transport address if the peer is behind a NAT). It is 2063 encoded in the same way as XOR-MAPPED-ADDRESS [RFC5389]. 2065 14.4. DATA 2067 The DATA attribute is present in all Send and Data indications. The 2068 contents of DATA attribute is the application data (that is, the data 2069 that would immediately follow the UDP header if the data was been 2070 sent directly between the client and the peer). 2072 14.5. XOR-RELAYED-ADDRESS 2074 The XOR-RELAYED-ADDRESS is present in Allocate responses. It 2075 specifies the address and port that the server allocated to the 2076 client. It is encoded in the same way as XOR-MAPPED-ADDRESS 2077 [RFC5389]. 2079 14.6. EVEN-PORT 2081 This attribute allows the client to request that the port in the 2082 relayed-transport-address be even, and (optionally) that the server 2083 reserve the next-higher port number. The attribute is 8 bits long. 2084 Its format is: 2086 0 2087 0 1 2 3 4 5 6 7 2088 +-+-+-+-+-+-+-+-+ 2089 |R| RFFU | 2090 +-+-+-+-+-+-+-+-+ 2092 The attribute contains a single 1-bit flag: 2094 R: If 1, the server is requested to reserve the next higher port 2095 number (on the same IP address) for a subsequent allocation. If 2096 0, no such reservation is requested. 2098 The other 7 bits of the attribute must be set to zero on transmission 2099 and ignored on reception. 2101 14.7. REQUESTED-TRANSPORT 2103 This attribute is used by the client to request a specific transport 2104 protocol for the allocated transport address. It has the following 2105 format: 2107 0 1 2 3 2108 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2109 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2110 | Protocol | RFFU | 2111 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2113 The Protocol field specifies the desired protocol. The codepoints 2114 used in this field are taken from those allowed in the Protocol field 2115 in the IPv4 header and the NextHeader field in the IPv6 header 2116 [Protocol-Numbers]. This specification only allows the use of 2117 codepoint 17 (User Datagram Protocol). 2119 The RFFU field MUST be set to zero on transmission and MUST be 2120 ignored on reception. It is reserved for future uses. 2122 14.8. DONT-FRAGMENT 2124 This attribute is used by the client to request that the server set 2125 the DF (Don't Fragment) bit in the IP header when relaying the 2126 application data onward to the peer. This attribute has no value 2127 part and thus the attribute length field is 0. 2129 14.9. RESERVATION-TOKEN 2131 The RESERVATION-TOKEN attribute contains a token that uniquely 2132 identifies a relayed transport address being held in reserve by the 2133 server. The server includes this attribute in a success response to 2134 tell the client about the token, and the client includes this 2135 attribute in a subsequent Allocate request to request the server use 2136 that relayed transport address for the allocation. 2138 The attribute value is a 64-bit-long field containing the token 2139 value. 2141 15. New STUN Error Response Codes 2143 This document defines the following new error response codes: 2145 403 (Forbidden): The request was valid, but cannot be performed due 2146 to administrative or similar restrictions. 2148 437 (Allocation Mismatch): A request was received by the server that 2149 requires an allocation to be in place, but there is none, or a 2150 request was received which requires no allocation, but there is 2151 one. 2153 441 (Wrong Credentials): The credentials in the (non-Allocate) 2154 request, though otherwise acceptable to the server, do not match 2155 those used to create the allocation. 2157 442 (Unsupported Transport Protocol): The Allocate request asked the 2158 server to use a transport protocol between the server and the peer 2159 that the server does not support. NOTE: This does NOT refer to 2160 the transport protocol used in the 5-tuple. 2162 486 (Allocation Quota Reached): No more allocations using this 2163 username can be created at the present time. 2165 508 (Insufficient Capacity): The server is unable to carry out the 2166 request due to some capacity limit being reached. In an Allocate 2167 response, this could be due to the server having no more relayed 2168 transport addresses available right now, or having none with the 2169 requested properties, or the one that corresponds to the specified 2170 reservation token is not available. 2172 16. Detailed Example 2174 This section gives a example of the use of TURN, showing in detail 2175 the contents of the messages exchanged. The example uses the network 2176 diagram shown in the Overview (Figure 1). 2178 For each message, the attributes included in the message and their 2179 values are shown. For convenience, values are shown in a human- 2180 readable format rather than showing the actual octets; for example 2181 "XOR-RELAYED-ADDRESS=192.0.2.15:9000" shows that the XOR-RELAYED- 2182 ADDRESS attribute is included with an address of 192.0.2.15 and a 2183 port of 9000, here the address and port are shown before the xor-ing 2184 is done. For attributes with string-like values (e.g. 2185 SOFTWARE="Example client, version 1.03" and 2186 NONCE="adl7W7PeDU4hKE72jdaQvbAMcr6h39sm"), the value of the attribute 2187 is shown in quotes for readability, but these quotes do not appear in 2188 the actual value. 2190 TURN TURN Peer Peer 2191 client server A B 2192 | | | | 2193 |--- Allocate request -------------->| | | 2194 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2195 | SOFTWARE="Example client, version 1.03" | | 2196 | LIFETIME=3600 (1 hour) | | | 2197 | REQUESTED-TRANSPORT=17 (UDP) | | | 2198 | DONT-FRAGMENT | | | 2199 | | | | 2200 |<-- Allocate error response --------| | | 2201 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2202 | SOFTWARE="Example server, version 1.17" | | 2203 | ERROR-CODE=401 (Unauthorized) | | | 2204 | REALM="example.com" | | | 2205 | NONCE="adl7W7PeDU4hKE72jdaQvbAMcr6h39sm" | | 2206 | | | | 2207 |--- Allocate request -------------->| | | 2208 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2209 | SOFTWARE="Example client 1.03" | | | 2210 | LIFETIME=3600 (1 hour) | | | 2211 | REQUESTED-TRANSPORT=17 (UDP) | | | 2212 | DONT-FRAGMENT | | | 2213 | USERNAME="George" | | | 2214 | REALM="example.com" | | | 2215 | NONCE="adl7W7PeDU4hKE72jdaQvbAMcr6h39sm" | | 2216 | MESSAGE-INTEGRITY=... | | | 2217 | | | | 2218 |<-- Allocate success response ------| | | 2219 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2220 | SOFTWARE="Example server, version 1.17" | | 2221 | LIFETIME=1200 (20 minutes) | | | 2222 | XOR-RELAYED-ADDRESS=192.0.2.15:50000 | | 2223 | XOR-MAPPED-ADDRESS=192.0.2.1:7000 | | 2224 | MESSAGE-INTEGRITY=... | | | 2226 The client begins by selecting a host transport address to use for 2227 the TURN session; in this example the client has selected 10.1.1.2: 2228 49721 as shown in Figure 1. The client then sends an Allocate 2229 request to the server at the server transport address. The client 2230 randomly selects a 96-bit transaction id of 2231 0xA56250D3F17ABE679422DE85 for this transaction; this is encoded in 2232 the transaction id field in the fixed header. The client includes a 2233 SOFTWARE attribute that gives information about the client's 2234 software; here the value is "Example client, version 1.03" to 2235 indicate that this is version 1.03 of something called the Example 2236 client. The client includes the LIFETIME attribute because it wishes 2237 the allocation to have a longer lifetime than the default of 10 2238 minutes; the value of this attribute is 3600 seconds, which 2239 corresponds to 1 hour. The client must always include a REQUESTED- 2240 TRANSPORT attribute in an Allocate request and the only value allowed 2241 by this specification is 17, which indicates UDP transport between 2242 the server and the peers. The client also includes the DONT-FRAGMENT 2243 attribute because it wishes to use the DONT-FRAGMENT attribute later 2244 in Send indications; this attribute consists of only an attribute 2245 header, there is no value part. We assume the client has not 2246 recently interacted with the server, thus the client does not include 2247 USERNAME, REALM, NONCE, or MESSAGE-INTEGRITY attribute. Finally, 2248 note that the order of attributes in a message is arbitrary (except 2249 for the MESSAGE-INTEGRITY and FINGERPRINT attributes) and the client 2250 could have used a different order. 2252 The server follows the recommended practice in this specification of 2253 requiring all requests to be authenticated. Thus when the server 2254 receives the initial Allocate request, it rejects the request because 2255 the request does not contain the authentication attributes. 2256 Following the procedures of the Long-Term Credential Mechanism of 2257 STUN [RFC5389], the server includes an ERROR-CODE attribute with a 2258 value of 401 (Unauthorized), a REALM attribute that specifies the 2259 authentication realm used by the server (in this case, the server's 2260 domain "example.com"), and a nonce value in a NONCE attribute. The 2261 server also includes a SOFTWARE attribute that gives information 2262 about the server's software. 2264 The client, upon receipt of the 401 error, re-attempts the Allocate 2265 request, this time including the authentication attributes. The 2266 client selects a new transaction id, and then populates the new 2267 Allocate request with the same attributes as before. The client 2268 includes a USERNAME attribute and uses the realm value received from 2269 the server to help it determine which value to use; here the client 2270 is configured to use the username "George" for the realm 2271 "example.com". The client also includes the REALM and NONCE 2272 attributes, which are just copied from the 401 error response. 2273 Finally, the client includes a MESSAGE-INTEGRITY attribute as the 2274 last attribute in the message, whose value is an HMAC-SHA1 hash over 2275 the contents of the message (shown as just "..." above); this HMAC- 2276 SHA1 computation also covers a password value, thus an attacker 2277 cannot compute the message integrity value without somehow knowing 2278 the secret password. 2280 The server, upon receipt of the authenticated Allocate request, 2281 checks that everything is OK, then creates an allocation. The server 2282 replies with an Allocate success response. The server includes a 2283 LIFETIME attribute giving the lifetime of the allocation; here, the 2284 server as reduced the client's requested 1 hour lifetime to just 20 2285 minutes, because this particular server doesn't allow lifetimes 2286 longer than 20 minutes. The server includes an XOR-RELAYED-ADDRESS 2287 attribute whose value is the relayed transport address of the 2288 allocation. The server includes an XOR-MAPPED-ADDRESS attribute 2289 whose value is the server-reflexive address of the client; this value 2290 is not used otherwise in TURN but is returned as a convenience to the 2291 client. The server includes a MESSAGE-INTEGRITY attribute to 2292 authenticate the response and to insure its integrity; note that the 2293 response does not contain the USERNAME, REALM, and NONCE attributes. 2294 The server also includes a SOFTWARE attribute. 2296 TURN TURN Peer Peer 2297 client server A B 2298 |--- CreatePermission request ------>| | | 2299 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2300 | XOR-PEER-ADDRESS=192.0.2.150:0 | | | 2301 | USERNAME="George" | | | 2302 | REALM="example.com" | | | 2303 | NONCE="adl7W7PeDU4hKE72jdaQvbAMcr6h39sm" | | 2304 | MESSAGE-INTEGRITY=... | | | 2305 | | | | 2306 |<-- CreatePermission success resp.--| | | 2307 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2308 | MESSAGE-INTEGRITY=... | | | 2310 The client then creates a permission towards peer A in preparation 2311 for sending it some application data. This is done through a 2312 CreatePermission request. The XOR-PEER-ADDRESS attribute contains 2313 the IP address for which a permission is established (the IP address 2314 of peer A); note that the port number in the attribute is ignored 2315 when used in a CreatePermission request, and here it has been set to 2316 0; also note how the client uses Peer A's server-reflexive IP address 2317 and not its (private) host address. The client uses the same 2318 username, realm, and nonce values as in the previous request on the 2319 allocation. Though it is allowed to do so, the client has chosen not 2320 to include a SOFTWARE attribute in this request. 2322 The server receives the CreatePermission request, creates the 2323 corresponding permission, and then replies with a CreatePermission 2324 success response. Like the client, the server chooses not to include 2325 the SOFTWARE attribute in its reply. Again, note how success 2326 responses contain a MESSAGE-INTEGRITY attribute (assuming the server 2327 uses the Long-Term Credential Mechanism), but no USERNAME, REALM, and 2328 NONCE attributes. 2330 TURN TURN Peer Peer 2331 client server A B 2332 |--- Send indication --------------->| | | 2333 | Transaction-Id=0x1278E9ACA2711637EF7D3328 | | 2334 | XOR-PEER-ADDRSSS=192.0.2.150:32102 | | 2335 | DONT-FRAGMENT | | | 2336 | DATA=... | | | 2337 | |-- UDP dgm ->| | 2338 | | data=... | | 2339 | | | | 2340 | |<- UDP dgm --| | 2341 | | data=... | | 2342 |<-- Data indication ----------------| | | 2343 | Transaction-Id=0x8231AE8F9242DA9FF287FEFF | | 2344 | XOR-PEER-ADDRSSS=192.0.2.150:32102 | | 2345 | DATA=... | | | 2347 The client now sends application data to Peer A using a Send 2348 indication. Peer A's server-reflexive transport address is specified 2349 in the XOR-PEER-ADDRESS attribute, and the application data (shown 2350 here as just "...") is specified in the DATA attribute. The client 2351 is doing a form of path MTU discovery at the application layer and 2352 thus specifies (by including the DONT-FRAGMENT attribute) that the 2353 server should set the DF bit in the UDP datagram send to the peer. 2354 Indications cannot be authenticated using the Long-Term Credential 2355 Mechanism of STUN, so no MESSAGE-INTEGRITY attribute is included in 2356 the message. An application wishing to ensure that its data is not 2357 altered or forged must integrity-protect its data at the application 2358 level. 2360 Upon receipt of the Send indication, the server extracts the 2361 application data and sends it in a UDP datagram to Peer A, with the 2362 relayed-transport-address as the source transport address of the 2363 datagram, and with the DF bit set as requested. Note that, had the 2364 client not previously established a permission for Peer A's server- 2365 reflexive IP address, then the server would have silently discarded 2366 the Send indication instead. 2368 Peer A then replies with its own UDP datagram containing application 2369 data. The datagram is sent to the relayed-transport-address on the 2370 server. When this arrives, the server creates a Data indication 2371 containing the source of the UDP datagram in the XOR-PEER-ADDRESS 2372 attribute, and the data from the UDP datagram in the DATA attribute. 2373 The resulting Data indication is then sent to the client. 2375 TURN TURN Peer Peer 2376 client server A B 2377 |--- ChannelBind request ----------->| | | 2378 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 2379 | CHANNEL-NUMBER=0x4000 | | | 2380 | XOR-PEER-ADDRESS=192.0.2.210:49191 | | 2381 | USERNAME="George" | | | 2382 | REALM="example.com" | | | 2383 | NONCE="adl7W7PeDU4hKE72jdaQvbAMcr6h39sm" | | 2384 | MESSAGE-INTEGRITY=... | | | 2385 | | | | 2386 |<-- ChannelBind success response ---| | | 2387 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 2388 | MESSAGE-INTEGRITY=... | | | 2390 The client now binds a channel to Peer B, specifying a free channel 2391 number (0x4000) in the CHANNEL-NUMBER attribute, and Peer B's 2392 transport address in the XOR-PEER-ADDRESS attribute. As before, the 2393 client re-uses the username, realm, and nonce from its last request 2394 in the message. 2396 Upon receipt of the request, the server binds the channel number to 2397 the peer, installs a permission for Peer B's IP address, and then 2398 replies with ChannelBind success response. 2400 TURN TURN Peer Peer 2401 client server A B 2402 |--- ChannelData ------------------->| | | 2403 | Channel-number=0x4000 |--- UDP datagram --------->| 2404 | Data=... | Data=... | 2405 | | | | 2406 | |<-- UDP datagram ----------| 2407 | | Data=... | | 2408 |<-- ChannelData --------------------| | | 2409 | Channel-number=0x4000 | | | 2410 | Data=... | | | 2412 The client now sends a ChannelData message to the server with data 2413 destined for Peer B. The ChannelData message is not a STUN message, 2414 and thus has no transaction id. Instead, its fixed header has only 2415 two fields: channel number and data; here the channel number field is 2416 0x4000 (the channel the client just bound to Peer B). When the 2417 server receives the ChannelData message, it checks that the channel 2418 is currently bound (which it is) and then sends the data onward to 2419 Peer B in a UDP datagram, using the relayed-transport-address as the 2420 source transport address and 192.0.2.210:49191 (the value of the XOR- 2421 PEER-ADDRESS attribute in the ChannelBind request) as the destination 2422 transport address. 2424 Later, Peer B sends a UDP datagram back to the relayed-transport- 2425 address. This causes the server to send a ChannelData message to the 2426 client containing the data from the UDP datagram. The server knows 2427 which client to send the ChannelData message to because of the 2428 relayed-transport-address the UDP datagram arrived at, and knows to 2429 use channel 0x4000 because this is the channel bound to 192.0.2.210: 2430 49191. Note that if there had not been any channel number bound to 2431 that address, the server would have used a Data indication instead. 2433 TURN TURN Peer Peer 2434 client server A B 2435 |--- Refresh request --------------->| | | 2436 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 2437 | SOFTWARE="Example client 1.03" | | | 2438 | USERNAME="George" | | | 2439 | REALM="example.com" | | | 2440 | NONCE="adl7W7PeDU4hKE72jdaQvbAMcr6h39sm" | | 2441 | MESSAGE-INTEGRITY=... | | | 2442 | | | | 2443 |<-- Refresh error response ---------| | | 2444 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 2445 | SOFTWARE="Example server, version 1.17" | | 2446 | ERROR-CODE=438 (Stale Nonce) | | | 2447 | REALM="example.com" | | | 2448 | NONCE="npSw1Xw239bBwGYhjNWgz2yH47sxB2j" | | 2449 | | | | 2450 |--- Refresh request --------------->| | | 2451 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 2452 | SOFTWARE="Example client 1.03" | | | 2453 | USERNAME="George" | | | 2454 | REALM="example.com" | | | 2455 | NONCE="npSw1Xw239bBwGYhjNWgz2yH47sxB2j" | | 2456 | MESSAGE-INTEGRITY=... | | | 2457 | | | | 2458 |<-- Refresh success response -------| | | 2459 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 2460 | SOFTWARE="Example server, version 1.17" | | 2461 | LIFETIME=600 (10 minutes) | | | 2463 Sometime before the 20 minute lifetime is up, the client refreshes 2464 the allocation. This is done using a Refresh request. As before, 2465 the client includes the latest username, realm, and nonce values in 2466 the request. The client also includes the SOFTWARE attribute, 2467 following the recommended practice of always including this attribute 2468 in Allocate and Refresh messages. When the server receives the 2469 Refresh request, it notices that the nonce value has expired, and so 2470 replies with 438 (Stale Nonce) error given a new nonce value. The 2471 client then reattempts the request, this time with the new nonce 2472 value. This second attempt is accepted, and the server replies with 2473 a success response. Note that the client did not include a LIFETIME 2474 attribute in the request, so the server refreshes the allocation for 2475 the default lifetime of 10 minutes (as can be seen by the LIFETIME 2476 attribute in the success response). 2478 17. Security Considerations 2480 This section considers attacks that are possible in a TURN 2481 deployment, and discusses how they are mitigated by mechanisms in the 2482 protocol or recommended practices in the implementation. 2484 17.1. Outsider Attacks 2486 Outsider attacks are ones where the attacker has no credentials in 2487 the system, and is attempting to disrupt the service seen by the 2488 client or the server. 2490 17.1.1. Obtaining Unauthorized Allocations 2492 An attacker might wish to obtain allocations on a TURN server for any 2493 number of nefarious purposes. A TURN server provides a mechanism for 2494 sending and receiving packets while cloaking the actual IP address of 2495 the client. This makes TURN servers an attractive target for 2496 attackers who wish to use it to mask their true identity. 2498 An attacker might also wish to simply utilize the services of a TURN 2499 server without paying for them. Since TURN services require 2500 resources from the provider, it is anticipated that their usage will 2501 come with a cost. 2503 These attacks are prevented using the digest authentication mechanism 2504 which allows the TURN server to determine the identity of the 2505 requestor and whether the requestor is allowed to obtain the 2506 allocation. 2508 17.1.2. Offline Dictionary Attacks 2510 The digest authentication mechanism used by TURN is subject to 2511 offline dictionary attacks. An attacker that is capable of 2512 eavesdropping on a message exchange between a client and server can 2513 determine the password by trying a number of candidate passwords and 2514 seeing if one of them is correct. This attack works when the 2515 passwords are low entropy, such as a word from the dictionary. This 2516 attack can be mitigated by using strong passwords with large entropy. 2517 In situations where even stronger mitigation is required, TLS 2518 transport between the client and the server can be used. 2520 17.1.3. Faked Refreshes and Permissions 2522 An attacker might wish to attack an active allocation by sending it a 2523 Refresh request with an immediate expiration, in order to delete it 2524 and disrupt service to the client. This is prevented by 2525 authentication of refreshes. Similarly, an attacker wishing to send 2526 CreatePermission requests to create permissions to undesirable 2527 destinations is prevented from doing so through authentication. The 2528 motivations for such an attack are described in Section 17.2. 2530 17.1.4. Fake Data 2532 An attacker might wish to send data to the client or the peer, as if 2533 they came from the peer or client respectively. To do that, the 2534 attacker can send the client a faked Data Indication or ChannelData 2535 message, or send the TURN server a faked Send Indication or 2536 ChannelData message. 2538 Indeed, since indications and ChannelData messages are not 2539 authenticated, this attack is not prevented by TURN. However, this 2540 attack is generally present in IP-based communications and is not 2541 substantially worsened by TURN. Consider an normal, non-TURN IP 2542 session between hosts A and B. An attacker can send packets to B as 2543 if they came from A by sending packets towards A with a spoofed IP 2544 address of B. This attack requires the attacker to know the IP 2545 addresses of A and B. With TURN, an attacker wishing to send packets 2546 towards a client using a Data indication needs to know its IP address 2547 (and port), the IP address and port of the TURN server, and the IP 2548 address and port of the peer (for inclusion in the XOR-PEER-ADDRESS 2549 attribute). To send a fake ChannelData message to a client, an 2550 attacker needs to know the IP address and port of the client, the IP 2551 address and port of the TURN server, and the channel number. This 2552 particular combination is mildly more guessable than in the non-TURN 2553 case. 2555 These attacks are more properly mitigated by application layer 2556 authentication techniques. In the case of real time traffic, usage 2557 of SRTP [RFC3711] prevents these attacks. 2559 In some situations, the TURN server may be situated in the network 2560 such that it is able to send to hosts that the client cannot directly 2561 send to. This can happen, for example, if the server is located 2562 behind a firewall that allows packets from outside the firewall to be 2563 delivered to the server, but not to other hosts behind the firewall. 2564 In these situations, an attacker could send the server a Send 2565 indication with an XOR-PEER-ADDRESS attribute containing the 2566 transport address of one of the other hosts behind the firewall. If 2567 the server was to allow relaying of traffic to arbitrary peers, then 2568 this would provide a way for the attacker to attack arbitrary hosts 2569 behind the firewall. 2571 To mitigate this attack, TURN requires that the client establish a 2572 permission to a host before sending it data. Thus an attacker can 2573 only attack hosts that the client is already communicating with, 2574 unless the attacker is able to create authenticated requests. 2575 Furthermore, the server administrator may configure the server to 2576 restrict the range of IP addresses and ports that it will relay data 2577 to. To provide even greater security, the server administrator can 2578 require that the client use TLS for all communication between the 2579 client and the server. 2581 17.1.5. Impersonating a Server 2583 When a client learns a relayed address from a TURN server, it uses 2584 that relayed address in application protocols to receive traffic. 2585 Therefore, an attacker wishing to intercept or redirect that traffic 2586 might try to impersonate a TURN server and provide the client with a 2587 faked relayed address. 2589 This attack is prevented through the digest authentication mechanism, 2590 which provides message integrity for responses in addition to 2591 verifying that they came from the server. Furthermore, an attacker 2592 cannot replay old server responses as the transaction ID in the STUN 2593 header prevents this. Replay attacks are further thwarted through 2594 frequent changes to the nonce value. 2596 17.1.6. Eavesdropping Traffic 2598 TURN concerns itself primarily with authentication and message 2599 integrity. Confidentiality is only a secondary concern, as TURN 2600 control messages do not include information that is particularly 2601 sensitive. The primary protocol content of the messages is the IP 2602 address of the peer. If it is important to prevent an eavesdropper 2603 on a TURN connection from learning this, TURN can be run over TLS. 2605 Confidentiality for the application data relayed by TURN is best 2606 provided by the application protocol itself, since running TURN over 2607 TLS does not protect application data between the server and the 2608 peer. If confidentiality of application data is important, then the 2609 application should encrypt or otherwise protect its data. For 2610 example, for real time media, confidentiality can be provided by 2611 using SRTP. 2613 17.1.7. TURN loop attack 2615 An attacker might attempt to cause data packets to loop indefinitely 2616 between two TURN servers. The attack goes as follows. First, the 2617 attacker sends an Allocate request to server A, using the source 2618 address of server B. Server A will send its response to server B, and 2619 for the attack to succeed, the attacker must have the ability to 2620 either view or guess the contents of this response, so that the 2621 attacker can learn the allocated relayed-transport-address. The 2622 attacker then sends an Allocate request to server B, using the source 2623 address of server A. Again, the attacker must be able to view or 2624 guess the contents of the response, so it can send learn the 2625 allocated relayed-transport-address. Using the same spoofed source 2626 address technique, the attacker then binds a channel number on server 2627 A to the relayed-transport-address on server B, and similarly binds 2628 the same channel number on server B to the relayed-transport-address 2629 on server A. Finally, the attacker sends a ChannelData message to 2630 server A. 2632 The result is a data packet that loops from the relayed-transport- 2633 address on server A to the relayed-transport-address on server B, 2634 then from server B's transport address to server A's transport 2635 address, and then around the loop again. 2637 This attack is mitigated as follows. By requiring all requests to be 2638 authenticated and/or by randomizing the port number allocated for the 2639 relayed-transport-address, the server forces the attacker to either 2640 intercept or view responses sent to a third party (in this case, the 2641 other server) so that the attacker can authenticate the requests and 2642 learn the relayed-transport-address. Without one of these two 2643 measures, an attacker can guess the contents of the responses without 2644 needing to see them, which makes the attack much easier to perform. 2645 Furthermore, by requiring authenticated requests, the server forces 2646 the attacker to have credentials acceptable to the server, which 2647 turns this from an outsider attack into an insider attack and allows 2648 the attack to be traced back to the client initiating it. 2650 The attack can be further mitigated by imposing a per-username limit 2651 on the bandwidth used to relay data by allocations owned by that 2652 username, to limit the impact of this attack on other allocations. 2653 More mitigation can be achieved by decrementing the TTL when relaying 2654 data packets (if the underlying OS allows this). 2656 17.2. Firewall Considerations 2658 A key aspect of TURN's security considerations is that it should not 2659 weaken the protections afforded by firewalls deployed between a 2660 client and a TURN server. It is anticipated that TURN servers will 2661 often be present on the public Internet, and clients may often be 2662 inside enterprise networks with corporate firewalls. If TURN servers 2663 provide a 'backdoor' for reaching into the enterprise, TURN will be 2664 blocked by these firewalls. 2666 TURN servers therefore emulate the behavior of NAT devices which 2667 implement address-dependent filtering [RFC4787], a property common in 2668 many firewalls as well. When a NAT or firewall implements this 2669 behavior, packets from an outside IP address are only allowed to be 2670 sent to an internal IP address and port if the internal IP address 2671 and port had recently sent a packet to that outside IP address. TURN 2672 servers introduce the concept of permissions, which provide exactly 2673 this same behavior on the TURN server. An attacker cannot send a 2674 packet to a TURN server and expect it to be relayed towards the 2675 client, unless the client has tried to contact the attacker first. 2677 It is important to note that some firewalls have policies which are 2678 even more restrictive than address-dependent filtering. Firewalls 2679 can also be configured with address and port dependent filtering, or 2680 can be configured to disallow inbound traffic entirely. In these 2681 cases, if a client is allowed to connect the TURN server, 2682 communications to the client will be less restrictive than what the 2683 firewall would normally allow. 2685 17.2.1. Faked Permissions 2687 In firewalls and NAT devices, permissions are granted implicitly 2688 through the traversal of a packet from the inside of the network 2689 towards the outside peer. Thus, a permission cannot, by definition, 2690 be created by any entity except one inside the firewall or NAT. With 2691 TURN, this restriction no longer holds. Since the TURN server sits 2692 outside the firewall, at attacker outside the firewall can now send a 2693 message to the TURN server and try to create a permission for itself. 2695 This attack is prevented because all messages which create 2696 permissions (i.e., ChannelBind and CreatePermission) are 2697 authenticated. 2699 17.2.2. Blacklisted IP Addresses 2701 Many firewalls can be configured with blacklists which prevent a 2702 client behind the firewall from sending packets to, or receiving 2703 packets from, ranges of blacklisted IP addresses. This is 2704 accomplished by inspecting the source and destination addresses of 2705 packets entering and exiting the firewall, respectively. 2707 If a client connects to a TURN server, it will be able to bypass such 2708 blacklisting policies and communicate with IP addresses which the 2709 firewall would otherwise restrict. This is a problem for other 2710 protocols that provide tunneling functions, such as VPNs. It is 2711 possible to build TURN-aware firewalls which inspect TURN messages, 2712 and check the IP address of the correspondent. TURN messages to 2713 offending destinations can then be rejected. TURN is designed so 2714 that this inspection can be done statelessly. 2716 17.2.3. Running Servers on Well-Known Ports 2718 A malicious client behind a firewall might try to connect to a TURN 2719 server and obtain an allocation which it then uses to run a server. 2720 For example, a client might try to run a DNS server or FTP server. 2722 This is not possible in TURN. A TURN server will never accept 2723 traffic from a peer which the client itself has not contacted. Thus, 2724 peers cannot just connect to the allocated port in order to obtain 2725 the service. 2727 17.3. Insider Attacks 2729 In insider attacks, a client has legitimate credentials but defies 2730 the trust relationship that goes with those credentials. These 2731 attacks cannot be prevented by cryptographic means but need to be 2732 considered in the design of the protocol. 2734 17.3.1. DoS Against TURN Server 2736 A client wishing to disrupt service to other clients might obtain an 2737 allocation and then flood it with traffic, in an attempt to swamp the 2738 server and prevent it from servicing other legitimate clients. This 2739 is mitigated by the recommendation that the server limit the amount 2740 of bandwidth it will relay for a given username. This won't prevent 2741 a client from sending a large amount of traffic, but it allows the 2742 server to immediately discard traffic in excess. 2744 Since each allocation uses a port number on the IP address of the 2745 TURN server, the number of allocations on a server is finite. An 2746 attacker might attempt to consume all of them by requesting a large 2747 number of allocations. This is prevented by the recommendation that 2748 the server impose a limit of the number of allocations active at a 2749 time for a given username. 2751 17.3.2. Anonymous Relaying of Malicious Traffic 2753 TURN servers provide a degree of anonymization. A client can send 2754 data to correspondent peers without revealing their own IP addresses. 2755 TURN servers may therefore become attractive vehicles for attackers 2756 to launch attacks against targets without fear of detection. Indeed, 2757 it is possible for a client to chain together multiple TURN servers, 2758 such that any number of relays can be used before a target receives a 2759 packet. 2761 Administrators who are worried about this attack can maintain logs 2762 which capture the actual source IP and port of the client, and 2763 perhaps even every permission that client installs. This will allow 2764 for forensic tracing to determine the original source, should it be 2765 discovered that an attack is being relayed through a TURN server. 2767 17.3.3. Manipulating other Allocations 2769 An attacker might attempt to disrupt service to other users of the 2770 TURN server by sending Refresh requests or CreatePermission requests 2771 which (through source address spoofing) appear to be coming from 2772 another user of the TURN server. TURN prevents this by requiring 2773 that the credentials used in CreatePermission, Refresh, and 2774 ChannelBind messages match those used to create the initial 2775 allocation. Thus, the fake requests from the attacker will be 2776 rejected. 2778 17.4. Other Considerations 2780 Any relay addresses learned through an Allocate request will not 2781 operate properly with IPSec Authentication Header (AH) [RFC4302] in 2782 transport or tunnel mode. However, tunnel-mode IPSec ESP [RFC4303] 2783 should still operate. 2785 18. IANA Considerations 2787 Since TURN is an extension to STUN [RFC5389], the methods, attributes 2788 and error codes defined in this specification are new methods, 2789 attributes, and error codes for STUN. This section requests IANA to 2790 add these new protocol elements to the IANA registry of STUN protocol 2791 elements. 2793 The codepoints for the new STUN methods defined in this specification 2794 are listed in Section 13. 2796 The codepoints for the new STUN attributes defined in this 2797 specification are listed in Section 14. 2799 The codepoints for the new STUN error codes defined in this 2800 specification are listed in Section 15. 2802 IANA is requested to allocate the SRV service name of "turn" for TURN 2803 over UDP or TCP, and the service name of "turns" for TURN over TLS. 2805 IANA is requested to create a registry for TURN channel numbers, 2806 initially populated as follows: 2808 0x0000 through 0x3FFF: Not available for use, since they conflict 2809 with the STUN header. 2811 0x4000 through 0x7FFF: A TURN implementation is free to use 2812 channel numbers in this range. 2814 0x8000 through 0xFFFF: Reserved. 2816 Any change to this registry must be made through an IETF Standards 2817 Action. 2819 19. IAB Considerations 2821 The IAB has studied the problem of "Unilateral Self Address Fixing", 2822 which is the general process by which a client attempts to determine 2823 its address in another realm on the other side of a NAT through a 2824 collaborative protocol reflection mechanism [RFC3424]. The TURN 2825 extension is an example of a protocol that performs this type of 2826 function. The IAB has mandated that any protocols developed for this 2827 purpose document a specific set of considerations. These 2828 considerations and the responses for TURN are documented in this 2829 section. 2831 Consideration 1: Precise definition of a specific, limited-scope 2832 problem that is to be solved with the UNSAF proposal. A short term 2833 fix should not be generalized to solve other problems. Such 2834 generalizations lead to the prolonged dependence on and usage of the 2835 supposed short term fix -- meaning that it is no longer accurate to 2836 call it "short term". 2838 Response: TURN is a protocol for communication between a relay (= 2839 TURN server) and its client. The protocol allows a client that is 2840 behind a NAT to obtain and use a public IP address on the relay. As 2841 a convenience to the client, TURN also allows the client to determine 2842 its server-reflexive transport address. 2844 Consideration 2: Description of an exit strategy/transition plan. 2845 The better short term fixes are the ones that will naturally see less 2846 and less use as the appropriate technology is deployed. 2848 Response: TURN will no longer be needed once there are no longer any 2849 NATs. The need for TURN will also decrease as the number of NATs 2850 with the mapping property of Endpoint-Independent Mapping [RFC4787] 2851 increases. 2853 Consideration 3: Discussion of specific issues that may render 2854 systems more "brittle". For example, approaches that involve using 2855 data at multiple network layers create more dependencies, increase 2856 debugging challenges, and make it harder to transition. 2858 Response: TURN is "brittle" in that it requires the NAT bindings 2859 between the client and the server to be maintained unchanged for the 2860 lifetime of the allocation. This is typically done using keep- 2861 alives. If this is not done, then the client will lose its 2862 allocation and can no longer exchange data with its peers. 2864 Consideration 4: Identify requirements for longer term, sound 2865 technical solutions; contribute to the process of finding the right 2866 longer term solution. 2868 Response: The need for TURN will be reduced once NATs implement the 2869 recommendations for NAT UDP behavior documented in [RFC4787]. 2870 Applications are also strongly urged to use ICE [I-D.ietf-mmusic-ice] 2871 to communicate with peers; though ICE uses TURN, it does so only as a 2872 last resort, and uses it in a controlled manner. 2874 Consideration 5: Discussion of the impact of the noted practical 2875 issues with existing deployed NATs and experience reports. 2877 Response: Some NATs deployed today exhibit a mapping behavior other 2878 than Endpoint-Independent mapping. These NATs are difficult to work 2879 with, as they make it difficult or impossible for protocols like ICE 2880 to use server-reflexive transport addresses on those NATs. A client 2881 behind such a NAT is often forced to use a relay protocol like TURN 2882 because "UDP hole punching" techniques [RFC5128] do not work. 2884 20. Open Issues 2886 Note to RFC Editor: Please remove this section prior to publication 2887 of this document as an RFC. 2889 This section lists the known issues in this version of the 2890 specification. 2892 (No known issues at this time). 2894 21. Changes from Previous Versions 2896 Note to RFC Editor: Please remove this section prior to publication 2897 of this document as an RFC. 2899 This section lists the technical and major editorial changes between 2900 the various versions of this specification. Minor editorial changes 2901 are not described. 2903 21.1. Changes from -12 to -13 2905 o Added a new error code: 403 (Forbidden). 2907 o When processing a CreatePermission or ChannelBind request 2908 containing a XOR-PEER-ADDRESS attribute, the server is allow to 2909 reject certain IP address and port combinations for administrative 2910 or other reasons by returning a 403 (Forbidden) error. 2912 o Added a request to IANA to establish a registery for channel 2913 numbers. 2915 o Clarified the usage of the nonce value: a new random nonce SHOULD 2916 be selected for each Allocate attempt, and the nonce SHOULD be 2917 expired at least once an hour. Referenced [RFC4086] for 2918 guidelines on selecting the nonce value. 2920 o Made a number of minor editoral changes. 2922 21.2. Changes from -11 to -12 2924 o Changed the port numbers used in the examples for the client, the 2925 peers, and the relayed-transport-address to put them in the 2926 Dynamic port range. They were previously in the Registered port 2927 range, which was arguably unrealistic. 2929 o Noted that the XOR-MAPPED-ADDRESS attribute is defined in RFC 2930 5389. 2932 o Used the codepoint names (Not-ECT, ECT(0), ECT(1), and CE) when 2933 talking about the ECN field. 2935 o Updated the Introduction to note that the client must not only 2936 communicate its relayed-transport-address to the peers, but also 2937 learn the peers' server-reflexive transport addresses. As a 2938 result, removed the suggestion that the client could use a webpage 2939 to communicate with its peers. 2941 o Added a description of the "TURN Loop attack" and its mitigation 2942 to the Security Considerations section. 2944 o Fixed some errors in the examples in the Overview section. They 2945 had not been updated to be consistent with the change introduced 2946 in version -11 that a permission must be created before a client 2947 can send data to a peer. 2949 o In the Additional Features subsection of the Overview, reworded 2950 the discussion of what end-to-end features are preserved by TURN. 2951 The previous text said that a number of features did not work, but 2952 as of version -11, these features _may_ work. At the same time, 2953 added a sentence noting that any Path MTU Discovery mechanism 2954 using the DONT-FRAGMENT attribute will not receive ICMP messages 2955 and will thus have to use techniques like those described in 2956 [RFC4821]. 2958 o Added the recommendation that, when TCP transport is used between 2959 the client and the server, both ends should close the connection 2960 if they notice a long sequence of invalid TURN messages. A likely 2961 cause of this is an undetected bit error corrupting a length field 2962 somewhere. 2964 o Reworded the paragraph explaining that channel bindings are per- 2965 allocation to further stress this point. 2967 o In the discussion on setting the fragmentation fields, added a 2968 sentence saying that the client or server should follow the normal 2969 rules for fragmentation as described in [RFC1122]. 2971 21.3. Changes from -10 to -11 2973 o Clarified that, when the client is redirected to an alternate 2974 server, the client uses the same transport protocol to the 2975 alternate server as it did to the original server. 2977 o Clarified the information that the server needs to store to 2978 authenticate requests and to compute the message-integrity on 2979 responses. Noted that the server need not store the password 2980 explicitly, but can instead store the key value, which may be 2981 desirable for security reasons. 2983 o Clarified that TURN runs on the same ports as TURN by default, but 2984 noted that a server can use a different port because TURN has its 2985 own SRV service names. Strengthened the language for using the 2986 SRV procedures from "typically" to "SHOULD". Also added a 2987 sentence in the IANA considerations section requesting that IANA 2988 reserve the service names for TURN; previously they were described 2989 in the text but not mentioned in the IANA considerations section. 2991 o Added a detailed example, complete with attributes and their 2992 values, of the use of TURN. 2994 o Reduced the range of channel numbers. Channel numbers now range 2995 from 0x4000 through 0x7FFF. Values in the range 0x8000 through 2996 0xFFFF are now reserved. 2998 o Rewrote the IAB Considerations section to directly address the 2999 considerations listed in [RFC3424]. 3001 o Generalized the 508 error code so it can be used for any sort of 3002 capacity-related problem. This error code was previously allowed 3003 only in Allocate responses, but is now also allowed in 3004 CreatePermission and ChannelBind responses to indicate that the 3005 server is unable to carry out the request due to some capacity 3006 problem. 3008 o Changed the syntax of the CreatePermission request to allow 3009 multiple XOR-PEER-ADDRESS attributes to appear in the message, so 3010 that multiple permissions can be created or refreshed at the same 3011 time. 3013 o Added the restriction that the server must already have a 3014 permission installed for the IP address in the XOR-PEER-ADDRESS 3015 attribute of a Send indication, otherwise the Send indication is 3016 ignored by the server. 3018 o Put back the preferred behaviors into Section 12, reversing the 3019 change made in version -10. 3021 o Explicitly allow the server to restrict the range of IP addresses 3022 and ports it is willing to relay data too. 3024 21.4. Changes from -09 to -10 3026 o Changed the recommendation for using the SOFTWARE attribute. 3027 Previously its use was recommended in all requests and responses; 3028 now it is only recommended in Allocate and Refresh requests and 3029 responses, though it may appear elsewhere. Also, version -09 3030 incorrectly referred to this attribute as "SOFTWARE-TYPE". 3032 o Changed the name of the PEER-ADDRESS and RELAYED-ADDRESS 3033 attributes to XOR-PEER-ADDRESS and XOR-RELAYED-ADDRESS 3034 respectively for consistency with other specifications. 3036 o Removed the concept of a "preserving" allocation. All allocations 3037 are now non-preserving. This simplifies the base specification 3038 and allows it to advance more rapidly; see the discussion in the 3039 BEHAVE meeting of 29 July 2008. The concept of a preserving 3040 allocation will be advanced as an extension to TURN. As part of 3041 this change, the P bit in the REQUESTED-PROPS attribute, the ICMP 3042 attribute, and ICMP message relaying was removed. Further, in 3043 Section 12, the preferred behaviors were removed, leaving the 3044 alternate behaviors as the specified behaviors. 3046 o Replaced the REQUESTED-PROPS attribute with the EVEN-PORT 3047 attribute. The new attribute lacks the feature of the old 3048 attribute of being an alternate way to specify new allocation 3049 properties. As a consequence, the only way to specify a new 3050 allocation property is to define a new attribute. 3052 o Added text recommending that the client check that the IP address 3053 in XOR-PEER-ADDRESS attribute in a received Data indication is one 3054 with which the client believes there is an active permission. 3055 Similarly, it is recommended that the client check that a 3056 permission exist when receiving a ChannelData message. 3058 o Added text recommending that the client delete the allocation if 3059 it receives a ChannelBind failure response on an unbound channel. 3061 o Added the CreatePermission request/response transaction which adds 3062 or updates permissions, and removed the ability for Send 3063 indications and ChannelBind messages to install or update 3064 permissions. The net effect is that only authenticate-able 3065 messages (i.e., CreatePermission requests and ChannelBind 3066 requests) can install or refresh permissions; unauthenticate-able 3067 Send indications and ChannelData messages do not. 3069 o Removed all support for IPv6. All IPv6 support, including ways of 3070 relaying between IPv4 and IPv6, will now be covered in 3071 [I-D.ietf-behave-turn-ipv6]. 3073 o Reserved attribute code point 0x0021. This was previously used 3074 for the TIMER-VAL attribute, which was removed when the 3075 SetActiveDestination feature was removed. 3077 o Added the DONT-FRAGMENT attribute which allows the client to 3078 request that the server set the DF bit when sending the UDP 3079 datagram to the peer. This attribute may appear in both Allocate 3080 requests and Send indications. 3082 o Changed how the ALTERNATE-SERVER attribute is used. The attribute 3083 can no longer be used with any error code, but must be used with 3084 300 (Try Alternative). It can now appear in unauthenticated 3085 responses, however there are restrictions around how the 3086 subsequent Allocate request is authenticated. 3088 o Reworked the details of how idempotency of requests is handled, 3089 making it clear that the stack can either remember all 3090 transactions for 40 seconds, or can handle this using the so- 3091 called "stateless stack approach". Made some changes to the 3092 semantics of the Allocate, Refresh, and ChannelBind requests as a 3093 consequence. 3095 o Added the requirement that a client cannot re-use previously bound 3096 channel number or transport address until 5 minutes after the 3097 channel binding expires. This avoids various race conditions. 3099 o Removed the requirement that an allocation cannot be re-used 3100 within 2 minutes of having been deleted. This requirement was put 3101 in place to prevent mis-delivered packets but is no longer seen as 3102 having any real value. 3104 o Added a recommendation that the server impose quotas on both the 3105 number of allocations and the amount of bandwidth a given username 3106 can use at one time. These quotas help protect against denial-of- 3107 service attacks. 3109 o Completely rewrote the security considerations section. 3111 o Made quite a few changes to the descriptive text in both the 3112 Overview and the normative text to try to further clarify 3113 concepts. 3115 21.5. Changes from -08 to -09 3117 o Added text to properly define the ICMP attribute. This attribute 3118 was introduced in TURN-08, but not fully defined due to an 3119 oversight. Clarified that the attribute can appear in a Data 3120 indication, but not a Send indication. Added text to the section 3121 on receiving a Data indication that points out that this attribute 3122 may be present. 3124 o Changed the wording around the handling of the DSCP field to allow 3125 the server to set the DSCP to an arbitrary value if the next hop 3126 is a Diff-Serv classifier and marker. 3128 o When the server generates a 508 response due to an unsupported 3129 flag in the REQUESTED-PROPS attribute, the server now includes the 3130 REQUESTED-PROPS attribute in the response with all the flags it 3131 supports set to 1. This allows the client to see if the server 3132 does not understand one of its flags. Similarly, the client is 3133 now allowed to immediately retry the request if it modifies the 3134 included REQUESTED-PROPS attribute. 3136 o Clarified that the REQUESTED-PROPS attribute can be used in 3137 conjunction with the RESERVATION-TOKEN attribute as long as both 3138 the E and R bits are 0. The spec previously contradicted itself 3139 on this point. 3141 o Clarified that when the server receives a ChannelData message with 3142 a length field of 0, it sends a UDP Datagram to the peer that 3143 contains no application data. 3145 o Rewrote some text around relaying incoming UDP Datagrams to avoid 3146 duplication of text in the Data indication and Channel sections. 3148 o Added a note that points out that the on-going work on randomizing 3149 port allocations [I-D.ietf-tsvwg-port-randomization] may be 3150 applicable to TURN. 3152 o Clarified that the Allocate request containing a RESERVATION-TOKEN 3153 attribute can use any 5-tuple, and that 5-tuple need not have any 3154 specific relationship to the 5-tuple of the Allocate request that 3155 created the reservation. 3157 o Added a note that discusses retransmitted Allocate requests over 3158 UDP where the first request receives a failure response, but the 3159 second receives a success response. The server may elect to 3160 remember transmitted failure responses to avoid this situation. 3162 o Added text about the usage of the SOFTWARE-TYPE attribute 3163 (formerly known as the SERVER attribute) in TURN messages. 3165 o Rewrote the text in the Overview that motivates why TURN supports 3166 TCP and TLS between the client and the server. The previous text 3167 had been identified by various readers as inadequate and 3168 misleading. 3170 o Rewrote the section how a server handles a Refresh request to 3171 clarify processing in various error conditions. The new text 3172 makes it clear that it is OK to delete a non-existent allocation. 3173 It also clarifies how to handle retransmissions of Refresh 3174 requests over UDP. 3176 o Renamed the "RELAY-ADDRESS" attribute to "RELAYED-ADDRESS", since 3177 the text consistently uses the term "relayed transport address" 3178 for the concept and ICE uses the term "relayed candidate". 3180 o Changed the codepoint assigned to the error code "Wrong 3181 Credentials" from 438 to 441 to avoid a conflict with the "Stale 3182 Nonce" error code of STUN. 3184 o Changed the text to consistently use non-capitalized "request", 3185 "response" and "indication", except in headings, error code names, 3186 etc. 3188 o Added a note mentioning that TURN packets can be demuxed from 3189 other packets arriving on the same socket by looking at the 3190 5-tuple of the arriving packet. 3192 o Clarified that there are no required attributes is a ChannelBind 3193 success response. 3195 21.6. Changes from -07 to -08 3197 o Removed the BANDWIDTH attribute and all associated text (including 3198 error code 507 "Insufficient Bandwidth Capacity"), as the 3199 requirements for this feature were not clear and it was felt the 3200 feature could be easily added later. 3202 o Changed the format of the REQUESTED-PROPS attribute from a one- 3203 byte field to a set of bit flags. Changed the semantics of the 3204 unused portion of the value from RFFU to "MUST be 0" to give a 3205 more desirable behavior when new flags are defined. 3207 o Introduced the concept of Preserving vs. Non-Preserving 3208 allocations. As a result, completely revamped the rules for how 3209 to set the fields in the IP header, and added rules for relaying 3210 ICMP messages when the allocation is Preserving. 3212 21.7. Changes from -06 to -07 3214 o Rewrote the General Behavior section, making various changes in 3215 the process. 3217 o Changed the usage of authentication from MUST to SHOULD. 3219 o Changed the requirement that subsequent requests use the same 3220 username and password from MUST to SHOULD to allow for the 3221 possibility of changing the credentials using some unspecified 3222 mechanism. 3224 o Introduced a 438 (Wrong Credentials) error which is used when a 3225 non-Allocate request authenticates but does not use the same 3226 username and password as the Allocate request. Having a separate 3227 error code for this case avoids the client being confused over 3228 what the error actually is. 3230 o The server must now prevent the relayed transport address and the 3231 5-tuple from being reused in different allocations for 2 minutes 3232 after the allocation expires. 3234 o Changed the usage of FINGERPRINT from MUST NOT to MAY, to allow 3235 for the possible multiplexing of TURN with some other protocol. 3237 o Rewrote much of the section on Allocations, splitting it into 3238 three new sections (one on allocations in general, one on creating 3239 an allocation, and one on refreshing an allocation). 3241 o Replaced the mechanism for requesting relayed transport addresses 3242 with specific properties. The new mechanism is less powerful: a 3243 client can request an even port, or a pair of ports, but cannot 3244 request a single odd port or a specific port as was possible under 3245 the old mechanism. Nor can the client request a specific IP 3246 address. 3248 o Changed the rules for handling ALTERNATE-SERVER, removing the 3249 requirement that the referring server have "positive knowledge" 3250 about the state of the alternate server. The new rules instead 3251 rely on text in STUN to prevent referral loops. 3253 o Changed the rules for allocation lifetimes. Allocations lifetimes 3254 are now a minimum of 10 minutes; the client can ask for longer 3255 values, but requests for shorter values are ignored. The text now 3256 recommends that the client refresh an allocation one minute before 3257 it expires. 3259 o Put in temporary procedures for handling the BANDWIDTH attribute, 3260 modelled on the LIFETIME attribute. These procedures are mostly 3261 placeholders and likely to change in the next revision. 3263 o Added a detailed description of how a client reacts to the various 3264 errors it can receive in reply to an Allocate request. This 3265 replaces the various descriptions that were previously scattered 3266 throughout the document, which were inconsistent and sometimes 3267 contradictory. 3269 o Added a new section that gives the normative rules for 3270 permissions. 3272 o Changed the rules around permission lifetimes. The text used to 3273 recommend a value of one minute; it MUST now be 5 minutes. 3275 o Removed the errors "Channel Missing or Invalid", "Peer Address 3276 Missing or Invalid" and "Lifetime Malformed or Invalid" and used 3277 400 "Bad Request" instead. 3279 o Rewrote portions of the section on Send and Data indications and 3280 the section on Channels to try to make the client vs. server 3281 behavior clearer. 3283 o Channel bindings now expire after 10 minutes, and must be 3284 refreshed to keep them alive. 3286 o Binding a channel now installs or refreshes a permission for the 3287 IP address of corresponding peer. 3289 o Changed the wording describing the situation when the client sends 3290 a ChannelData message before receiving the ChannelBind success 3291 response. -06 said that client SHOULD NOT do this; -07 now says 3292 that a client MAY, but describes the consequences of doing it. 3294 o Added a section discussing the setting of fields in the IP header. 3296 o Replaced the REQUESTED-PORT-PROPS attribute with the REQUESTED- 3297 PROPS attribute that has a different format and semantics, but 3298 reuses the same code point. 3300 o Replaced the REQUESTED-IP attribute with the RESERVATION-TOKEN 3301 attribute, which has a different format and semantics, but reuses 3302 the same code point. 3304 o Removed error codes 443 and 444, and replaced them with 508 3305 (Insufficient Port Capacity). Also changed the error text for 3306 code 507 from "Insufficient Capacity" to "Insufficient Bandwidth 3307 Capacity". 3309 21.8. Changes from -05 to -06 3311 o Changed the mechanism for allocating channels to the one proposed 3312 by Eric Rescorla at the Dec 2007 IETF meeting. 3314 o Removed the framing mechanism (which was used to frame all 3315 messages) and replaced it with the ChannelData message. As part 3316 of this change, noted that the demux of ChannelData messages from 3317 TURN messages can be done using the first two bits of the message. 3319 o Rewrote the sections on transmitted and receiving data as a result 3320 of the above to changes, splitting it into a section on Send and 3321 Data indications and a separate section on channels. 3323 o Clarified the handling of Allocate request messages. In 3324 particular, subsequent Allocate request messages over UDP with the 3325 same transaction id are not an error but a retransmission. 3327 o Restricted the range of ports available for allocation to the 3328 Dynamic and/or Private Port range, and noted when ports outside 3329 this range can be used. 3331 o Changed the format of the REQUESTED-TRANSPORT attribute. The 3332 previous version used 00 for UDP and 01 for TCP; the new version 3333 uses protocol numbers from the IANA protocol number registry. The 3334 format of the attribute also changed. 3336 o Made a large number of changes to the non-normative portion of the 3337 document to reflect technical changes and improve the 3338 presentation. 3340 o Added the Issues section. 3342 21.9. Changes from -04 to -05 3344 o Removed the ability to allocate addresses for TCP relaying. This 3345 is now covered in a separate document. However, communication 3346 between the client and the server can still run over TCP or TLS/ 3347 TCP. This resulted in the removal of the Connect method and the 3348 TIMER-VAL and CONNECT-STAT attributes. 3350 o Added the concept of channels. All communication between the 3351 client and the server flows on a channel. Channels are numbered 3352 0..65535. Channel 0 is used for TURN messages, while the 3353 remaining channels are used for sending unencapsulated data to/ 3354 from a remote peer. This concept adds a new Channel Confirmation 3355 method and a new CHANNEL-NUMBER attribute. The new attribute is 3356 also used in the Send and Data methods. 3358 o The framing mechanism formally used just for stream-oriented 3359 transports is now also used for UDP, and the former Type and 3360 Reserved fields in the header have been replaced by a Channel 3361 Number field. The length field is zero when running over UDP. 3363 o TURN now runs on its own port, rather than using the STUN port. 3364 The use of channels requires this. 3366 o Removed the SetActiveDestination concept. This has been replaced 3367 by the concept of channels. 3369 o Changed the allocation refresh mechanism. The new mechanism uses 3370 a new Refresh method, rather than repeating the Allocation 3371 transaction. 3373 o Changed the syntax of SRV requests for secure transport. The new 3374 syntax is "_turns._tcp" rather than the old "_turn._tls". This 3375 change mirrors the corresponding change in STUN SRV syntax. 3377 o Renamed the old REMOTE-ADDRESS attribute to PEER-ADDRESS, and 3378 changed it to use the XOR-MAPPED-ADDRESS format. 3380 o Changed the RELAY-ADDRESS attribute to use the XOR-MAPPED-ADDRESS 3381 format (instead of the MAPPED-ADDRESS format)). 3383 o Renamed the 437 error code from "No Binding" to "Allocation 3384 Mismatch". 3386 o Added a discussion of what happens if a client's public binding on 3387 its outermost NAT changes. 3389 o The document now consistently uses the term "peer" as the name of 3390 a remote endpoint with which the client wishes to communicate. 3392 o Rewrote much of the document to describe the new concepts. At the 3393 same time, tried to make the presentation clearer and less 3394 repetitive. 3396 22. Acknowledgements 3398 The authors would like to thank the various participants in the 3399 BEHAVE working group for their many comments on this draft. Marc 3400 Petit-Huguenin, Remi Denis-Courmont, Jason Fischl, Derek MacDonald, 3401 Scott Godin, Cullen Jennings, Lars Eggert, Magnus Westerlund, Benny 3402 Prijono, and Eric Rescorla have been particularly helpful, with Eric 3403 also suggesting the channel allocation mechanism, and Cullen 3404 suggesting the REQUESTED-PORT-PROPS mechanism. Christian Huitema was 3405 an early contributor to this document and was a co-author on the 3406 first few drafts. Finally, the authors would like to thank Dan Wing 3407 for both his contributions to the text and his huge help in 3408 restarting progress on this draft after work had stalled. 3410 23. References 3412 23.1. Normative References 3414 [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, 3415 "Session Traversal Utilities for NAT (STUN)", RFC 5389, 3416 October 2008. 3418 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3419 Requirement Levels", BCP 14, RFC 2119, March 1997. 3421 [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black, 3422 "Definition of the Differentiated Services Field (DS 3423 Field) in the IPv4 and IPv6 Headers", RFC 2474, 3424 December 1998. 3426 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 3427 of Explicit Congestion Notification (ECN) to IP", 3428 RFC 3168, September 2001. 3430 [RFC1122] Braden, R., "Requirements for Internet Hosts - 3431 Communication Layers", STD 3, RFC 1122, October 1989. 3433 23.2. Informative References 3435 [RFC1918] Rekhter, Y., Moskowitz, R., Karrenberg, D., Groot, G., and 3436 E. Lear, "Address Allocation for Private Internets", 3437 BCP 5, RFC 1918, February 1996. 3439 [RFC3424] Daigle, L. and IAB, "IAB Considerations for UNilateral 3440 Self-Address Fixing (UNSAF) Across Network Address 3441 Translation", RFC 3424, November 2002. 3443 [RFC4787] Audet, F. and C. Jennings, "Network Address Translation 3444 (NAT) Behavioral Requirements for Unicast UDP", BCP 127, 3445 RFC 4787, January 2007. 3447 [I-D.ietf-mmusic-ice] 3448 Rosenberg, J., "Interactive Connectivity Establishment 3449 (ICE): A Protocol for Network Address Translator (NAT) 3450 Traversal for Offer/Answer Protocols", 3451 draft-ietf-mmusic-ice-19 (work in progress), October 2007. 3453 [I-D.ietf-behave-turn-tcp] 3454 Rosenberg, J. and R. Mahy, "Traversal Using Relays around 3455 NAT (TURN) Extensions for TCP Allocations", 3456 draft-ietf-behave-turn-tcp-01 (work in progress), 3457 November 2008. 3459 [I-D.ietf-behave-turn-ipv6] 3460 Camarillo, G. and O. Novo, "Traversal Using Relays around 3461 NAT (TURN) Extension for IPv4/IPv6 Transition", 3462 draft-ietf-behave-turn-ipv6-05 (work in progress), 3463 October 2008. 3465 [I-D.ietf-tsvwg-port-randomization] 3466 Larsen, M. and F. Gont, "Port Randomization", 3467 draft-ietf-tsvwg-port-randomization-02 (work in progress), 3468 August 2008. 3470 [RFC5128] Srisuresh, P., Ford, B., and D. Kegel, "State of Peer-to- 3471 Peer (P2P) Communication across Network Address 3472 Translators (NATs)", RFC 5128, March 2008. 3474 [RFC1928] Leech, M., Ganis, M., Lee, Y., Kuris, R., Koblas, D., and 3475 L. Jones, "SOCKS Protocol Version 5", RFC 1928, 3476 March 1996. 3478 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3479 Jacobson, "RTP: A Transport Protocol for Real-Time 3480 Applications", STD 64, RFC 3550, July 2003. 3482 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3483 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3484 RFC 3711, March 2004. 3486 [RFC4302] Kent, S., "IP Authentication Header", RFC 4302, 3487 December 2005. 3489 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 3490 RFC 4303, December 2005. 3492 [RFC4821] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 3493 Discovery", RFC 4821, March 2007. 3495 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3496 A., Peterson, J., Sparks, R., Handley, M., and E. 3497 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3498 June 2002. 3500 [I-D.rosenberg-mmusic-ice-nonsip] 3501 Rosenberg, J., "Guidelines for Usage of Interactive 3502 Connectivity Establishment (ICE) by non Session 3503 Initiation Protocol (SIP) Protocols", 3504 draft-rosenberg-mmusic-ice-nonsip-01 (work in progress), 3505 July 2008. 3507 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 3508 Requirements for Security", BCP 106, RFC 4086, June 2005. 3510 [Port-Numbers] 3511 "IANA Port Numbers Registry", 3512 . 3514 [Protocol-Numbers] 3515 "IANA Protocol Numbers Registry", 2005, 3516 . 3518 Authors' Addresses 3520 Jonathan Rosenberg 3521 Cisco Systems, Inc. 3522 Edison, NJ 3523 USA 3525 Email: jdrosen@cisco.com 3526 URI: http://www.jdrosen.net 3528 Rohan Mahy 3529 (Unaffiliated) 3531 Email: rohan@ekabal.com 3533 Philip Matthews 3534 Alcatel-Lucent 3535 600 March Road 3536 Ottawa, Ontario 3537 Canada 3539 Phone: 3540 Fax: 3541 Email: philip_matthews@magma.ca 3542 URI: