idnits 2.17.1 draft-ietf-tram-turnbis-20.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- 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? -- The draft header indicates that this document obsoletes RFC6156, but the abstract doesn't seem to directly say this. It does mention RFC6156 though, so this could be OK. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 11, 2018) is 2017 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) == Outdated reference: A later version (-21) exists of draft-ietf-tram-stunbis-18 ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 6347 (Obsoleted by RFC 9147) == Outdated reference: A later version (-20) exists of draft-ietf-tram-stun-pmtud-10 -- Obsolete informational reference (is this intentional?): RFC 5245 (Obsoleted by RFC 8445, RFC 8839) -- Obsolete informational reference (is this intentional?): RFC 5766 (Obsoleted by RFC 8656) -- Obsolete informational reference (is this intentional?): RFC 6156 (Obsoleted by RFC 8656) Summary: 2 errors (**), 0 flaws (~~), 3 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 TRAM WG T. Reddy, Ed. 3 Internet-Draft McAfee 4 Obsoletes: 5766,6156 (if approved) A. Johnston, Ed. 5 Intended status: Standards Track Rowan University 6 Expires: April 14, 2019 P. Matthews 7 Alcatel-Lucent 8 J. Rosenberg 9 jdrosen.net 10 October 11, 2018 12 Traversal Using Relays around NAT (TURN): Relay Extensions to Session 13 Traversal Utilities for NAT (STUN) 14 draft-ietf-tram-turnbis-20 16 Abstract 18 If a host is located behind a NAT, then in certain situations it can 19 be impossible for that host to communicate directly with other hosts 20 (peers). In these situations, it is necessary for the host to use 21 the services of an intermediate node that acts as a communication 22 relay. This specification defines a protocol, called TURN (Traversal 23 Using Relays around NAT), that allows the host to control the 24 operation of the relay and to exchange packets with its peers using 25 the relay. TURN differs from some other relay control protocols in 26 that it allows a client to communicate with multiple peers using a 27 single relay address. 29 The TURN protocol was designed to be used as part of the ICE 30 (Interactive Connectivity Establishment) approach to NAT traversal, 31 though it also can be used without ICE. 33 This document obsoletes RFC 5766 and RFC 6156. 35 Status of This Memo 37 This Internet-Draft is submitted in full conformance with the 38 provisions of BCP 78 and BCP 79. 40 Internet-Drafts are working documents of the Internet Engineering 41 Task Force (IETF). Note that other groups may also distribute 42 working documents as Internet-Drafts. The list of current Internet- 43 Drafts is at https://datatracker.ietf.org/drafts/current/. 45 Internet-Drafts are draft documents valid for a maximum of six months 46 and may be updated, replaced, or obsoleted by other documents at any 47 time. It is inappropriate to use Internet-Drafts as reference 48 material or to cite them other than as "work in progress." 49 This Internet-Draft will expire on April 14, 2019. 51 Copyright Notice 53 Copyright (c) 2018 IETF Trust and the persons identified as the 54 document authors. All rights reserved. 56 This document is subject to BCP 78 and the IETF Trust's Legal 57 Provisions Relating to IETF Documents 58 (https://trustee.ietf.org/license-info) in effect on the date of 59 publication of this document. Please review these documents 60 carefully, as they describe your rights and restrictions with respect 61 to this document. Code Components extracted from this document must 62 include Simplified BSD License text as described in Section 4.e of 63 the Trust Legal Provisions and are provided without warranty as 64 described in the Simplified BSD License. 66 Table of Contents 68 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 69 2. Overview of Operation . . . . . . . . . . . . . . . . . . . . 6 70 2.1. Transports . . . . . . . . . . . . . . . . . . . . . . . 8 71 2.2. Allocations . . . . . . . . . . . . . . . . . . . . . . . 9 72 2.3. Permissions . . . . . . . . . . . . . . . . . . . . . . . 11 73 2.4. Send Mechanism . . . . . . . . . . . . . . . . . . . . . 12 74 2.5. Channels . . . . . . . . . . . . . . . . . . . . . . . . 14 75 2.6. Unprivileged TURN Servers . . . . . . . . . . . . . . . . 16 76 2.7. Avoiding IP Fragmentation . . . . . . . . . . . . . . . . 17 77 2.8. RTP Support . . . . . . . . . . . . . . . . . . . . . . . 18 78 2.9. Happy Eyeballs for TURN . . . . . . . . . . . . . . . . . 18 79 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 19 80 4. Discovery of TURN server . . . . . . . . . . . . . . . . . . 21 81 4.1. TURN URI Scheme Semantics . . . . . . . . . . . . . . . . 21 82 5. General Behavior . . . . . . . . . . . . . . . . . . . . . . 21 83 6. Allocations . . . . . . . . . . . . . . . . . . . . . . . . . 24 84 7. Creating an Allocation . . . . . . . . . . . . . . . . . . . 25 85 7.1. Sending an Allocate Request . . . . . . . . . . . . . . . 25 86 7.2. Receiving an Allocate Request . . . . . . . . . . . . . . 27 87 7.3. Receiving an Allocate Success Response . . . . . . . . . 32 88 7.4. Receiving an Allocate Error Response . . . . . . . . . . 33 89 8. Refreshing an Allocation . . . . . . . . . . . . . . . . . . 35 90 8.1. Sending a Refresh Request . . . . . . . . . . . . . . . . 35 91 8.2. Receiving a Refresh Request . . . . . . . . . . . . . . . 36 92 8.3. Receiving a Refresh Response . . . . . . . . . . . . . . 37 93 9. Permissions . . . . . . . . . . . . . . . . . . . . . . . . . 37 94 10. CreatePermission . . . . . . . . . . . . . . . . . . . . . . 38 95 10.1. Forming a CreatePermission Request . . . . . . . . . . . 39 96 10.2. Receiving a CreatePermission Request . . . . . . . . . . 39 97 10.3. Receiving a CreatePermission Response . . . . . . . . . 40 98 11. Send and Data Methods . . . . . . . . . . . . . . . . . . . . 40 99 11.1. Forming a Send Indication . . . . . . . . . . . . . . . 40 100 11.2. Receiving a Send Indication . . . . . . . . . . . . . . 40 101 11.3. Receiving a UDP Datagram . . . . . . . . . . . . . . . . 41 102 11.4. Receiving a Data Indication . . . . . . . . . . . . . . 42 103 11.5. Receiving an ICMP Packet . . . . . . . . . . . . . . . . 42 104 11.6. Receiving a Data Indication with an ICMP attribute . . . 43 105 12. Channels . . . . . . . . . . . . . . . . . . . . . . . . . . 43 106 12.1. Sending a ChannelBind Request . . . . . . . . . . . . . 45 107 12.2. Receiving a ChannelBind Request . . . . . . . . . . . . 46 108 12.3. Receiving a ChannelBind Response . . . . . . . . . . . . 47 109 12.4. The ChannelData Message . . . . . . . . . . . . . . . . 47 110 12.5. Sending a ChannelData Message . . . . . . . . . . . . . 48 111 12.6. Receiving a ChannelData Message . . . . . . . . . . . . 49 112 12.7. Relaying Data from the Peer . . . . . . . . . . . . . . 50 113 13. Packet Translations . . . . . . . . . . . . . . . . . . . . . 50 114 13.1. IPv4-to-IPv6 Translations . . . . . . . . . . . . . . . 50 115 13.2. IPv6-to-IPv6 Translations . . . . . . . . . . . . . . . 51 116 13.3. IPv6-to-IPv4 Translations . . . . . . . . . . . . . . . 53 117 14. IP Header Fields . . . . . . . . . . . . . . . . . . . . . . 53 118 15. STUN Methods . . . . . . . . . . . . . . . . . . . . . . . . 55 119 16. STUN Attributes . . . . . . . . . . . . . . . . . . . . . . . 55 120 16.1. CHANNEL-NUMBER . . . . . . . . . . . . . . . . . . . . . 56 121 16.2. LIFETIME . . . . . . . . . . . . . . . . . . . . . . . . 56 122 16.3. XOR-PEER-ADDRESS . . . . . . . . . . . . . . . . . . . . 56 123 16.4. DATA . . . . . . . . . . . . . . . . . . . . . . . . . . 56 124 16.5. XOR-RELAYED-ADDRESS . . . . . . . . . . . . . . . . . . 57 125 16.6. REQUESTED-ADDRESS-FAMILY . . . . . . . . . . . . . . . . 57 126 16.7. EVEN-PORT . . . . . . . . . . . . . . . . . . . . . . . 57 127 16.8. REQUESTED-TRANSPORT . . . . . . . . . . . . . . . . . . 58 128 16.9. DONT-FRAGMENT . . . . . . . . . . . . . . . . . . . . . 58 129 16.10. RESERVATION-TOKEN . . . . . . . . . . . . . . . . . . . 58 130 16.11. ADDITIONAL-ADDRESS-FAMILY . . . . . . . . . . . . . . . 58 131 16.12. ADDRESS-ERROR-CODE Attribute . . . . . . . . . . . . . . 59 132 16.13. ICMP Attribute . . . . . . . . . . . . . . . . . . . . . 59 133 17. STUN Error Response Codes . . . . . . . . . . . . . . . . . . 60 134 18. Detailed Example . . . . . . . . . . . . . . . . . . . . . . 61 135 19. Security Considerations . . . . . . . . . . . . . . . . . . . 69 136 19.1. Outsider Attacks . . . . . . . . . . . . . . . . . . . . 69 137 19.1.1. Obtaining Unauthorized Allocations . . . . . . . . . 69 138 19.1.2. Offline Dictionary Attacks . . . . . . . . . . . . . 69 139 19.1.3. Faked Refreshes and Permissions . . . . . . . . . . 70 140 19.1.4. Fake Data . . . . . . . . . . . . . . . . . . . . . 70 141 19.1.5. Impersonating a Server . . . . . . . . . . . . . . . 71 142 19.1.6. Eavesdropping Traffic . . . . . . . . . . . . . . . 71 143 19.1.7. TURN Loop Attack . . . . . . . . . . . . . . . . . . 72 144 19.2. Firewall Considerations . . . . . . . . . . . . . . . . 72 145 19.2.1. Faked Permissions . . . . . . . . . . . . . . . . . 73 146 19.2.2. Blacklisted IP Addresses . . . . . . . . . . . . . . 74 147 19.2.3. Running Servers on Well-Known Ports . . . . . . . . 74 148 19.3. Insider Attacks . . . . . . . . . . . . . . . . . . . . 74 149 19.3.1. DoS against TURN Server . . . . . . . . . . . . . . 74 150 19.3.2. Anonymous Relaying of Malicious Traffic . . . . . . 75 151 19.3.3. Manipulating Other Allocations . . . . . . . . . . . 75 152 19.4. Tunnel Amplification Attack . . . . . . . . . . . . . . 75 153 19.5. Other Considerations . . . . . . . . . . . . . . . . . . 76 154 20. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 76 155 21. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 77 156 22. Changes since RFC 5766 . . . . . . . . . . . . . . . . . . . 79 157 23. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 79 158 24. References . . . . . . . . . . . . . . . . . . . . . . . . . 80 159 24.1. Normative References . . . . . . . . . . . . . . . . . . 80 160 24.2. Informative References . . . . . . . . . . . . . . . . . 81 161 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 84 163 1. Introduction 165 A host behind a NAT may wish to exchange packets with other hosts, 166 some of which may also be behind NATs. To do this, the hosts 167 involved can use "hole punching" techniques (see [RFC5128]) in an 168 attempt discover a direct communication path; that is, a 169 communication path that goes from one host to another through 170 intervening NATs and routers, but does not traverse any relays. 172 As described in [RFC5128] and [RFC4787], hole punching techniques 173 will fail if both hosts are behind NATs that are not well behaved. 174 For example, if both hosts are behind NATs that have a mapping 175 behavior of "address-dependent mapping" or "address- and port- 176 dependent mapping", then hole punching techniques generally fail. 178 When a direct communication path cannot be found, it is necessary to 179 use the services of an intermediate host that acts as a relay for the 180 packets. This relay typically sits in the public Internet and relays 181 packets between two hosts that both sit behind NATs. 183 This specification defines a protocol, called TURN, that allows a 184 host behind a NAT (called the TURN client) to request that another 185 host (called the TURN server) act as a relay. The client can arrange 186 for the server to relay packets to and from certain other hosts 187 (called peers) and can control aspects of how the relaying is done. 188 The client does this by obtaining an IP address and port on the 189 server, called the relayed transport address. When a peer sends a 190 packet to the relayed transport address, the server relays the packet 191 to the client. When the client sends a data packet to the server, 192 the server relays it to the appropriate peer using the relayed 193 transport address as the source. 195 A client using TURN must have some way to communicate the relayed 196 transport address to its peers, and to learn each peer's IP address 197 and port (more precisely, each peer's server-reflexive transport 198 address, see Section 2). How this is done is out of the scope of the 199 TURN protocol. One way this might be done is for the client and 200 peers to exchange email messages. Another way is for the client and 201 its peers to use a special-purpose "introduction" or "rendezvous" 202 protocol (see [RFC5128] for more details). 204 If TURN is used with ICE [RFC5245], then the relayed transport 205 address and the IP addresses and ports of the peers are included in 206 the ICE candidate information that the rendezvous protocol must 207 carry. For example, if TURN and ICE are used as part of a multimedia 208 solution using SIP [RFC3261], then SIP serves the role of the 209 rendezvous protocol, carrying the ICE candidate information inside 210 the body of SIP messages. If TURN and ICE are used with some other 211 rendezvous protocol, then [I-D.rosenberg-mmusic-ice-nonsip] provides 212 guidance on the services the rendezvous protocol must perform. 214 Though the use of a TURN server to enable communication between two 215 hosts behind NATs is very likely to work, it comes at a high cost to 216 the provider of the TURN server, since the server typically needs a 217 high-bandwidth connection to the Internet. As a consequence, it is 218 best to use a TURN server only when a direct communication path 219 cannot be found. When the client and a peer use ICE to determine the 220 communication path, ICE will use hole punching techniques to search 221 for a direct path first and only use a TURN server when a direct path 222 cannot be found. 224 TURN was originally invented to support multimedia sessions signaled 225 using SIP. Since SIP supports forking, TURN supports multiple peers 226 per relayed transport address; a feature not supported by other 227 approaches (e.g., SOCKS [RFC1928]). However, care has been taken to 228 make sure that TURN is suitable for other types of applications. 230 TURN was designed as one piece in the larger ICE approach to NAT 231 traversal. Implementors of TURN are urged to investigate ICE and 232 seriously consider using it for their application. However, it is 233 possible to use TURN without ICE. 235 TURN is an extension to the STUN (Session Traversal Utilities for 236 NAT) protocol [I-D.ietf-tram-stunbis]. Most, though not all, TURN 237 messages are STUN-formatted messages. A reader of this document 238 should be familiar with STUN. 240 2. Overview of Operation 242 This section gives an overview of the operation of TURN. It is non- 243 normative. 245 In a typical configuration, a TURN client is connected to a private 246 network [RFC1918] and through one or more NATs to the public 247 Internet. On the public Internet is a TURN server. Elsewhere in the 248 Internet are one or more peers with which the TURN client wishes to 249 communicate. These peers may or may not be behind one or more NATs. 250 The client uses the server as a relay to send packets to these peers 251 and to receive packets from these peers. 253 Peer A 254 Server-Reflexive +---------+ 255 Transport Address | | 256 192.0.2.150:32102 | | 257 | /| | 258 TURN | / ^| Peer A | 259 Client's Server | / || | 260 Host Transport Transport | // || | 261 Address Address | // |+---------+ 262 198.51.100.2:49721 192.0.2.15:3478 |+-+ // Peer A 263 | | ||N| / Host Transport 264 | +-+ | ||A|/ Address 265 | | | | v|T| 203.0.113.2:49582 266 | | | | /+-+ 267 +---------+| | | |+---------+ / +---------+ 268 | || |N| || | // | | 269 | TURN |v | | v| TURN |/ | | 270 | Client |----|A|----------| Server |------------------| Peer B | 271 | | | |^ | |^ ^| | 272 | | |T|| | || || | 273 +---------+ | || +---------+| |+---------+ 274 | || | | 275 | || | | 276 +-+| | | 277 | | | 278 | | | 279 Client's | Peer B 280 Server-Reflexive Relayed Transport 281 Transport Address Transport Address Address 282 192.0.2.1:7000 192.0.2.15:50000 192.0.2.210:49191 284 Figure 1 286 Figure 1 shows a typical deployment. In this figure, the TURN client 287 and the TURN server are separated by a NAT, with the client on the 288 private side and the server on the public side of the NAT. This NAT 289 is assumed to be a "bad" NAT; for example, it might have a mapping 290 property of "address-and-port-dependent mapping" (see [RFC4787]). 292 The client talks to the server from a (IP address, port) combination 293 called the client's HOST TRANSPORT ADDRESS. (The combination of an 294 IP address and port is called a TRANSPORT ADDRESS.) 296 The client sends TURN messages from its host transport address to a 297 transport address on the TURN server that is known as the TURN SERVER 298 TRANSPORT ADDRESS. The client learns the TURN server transport 299 address through some unspecified means (e.g., configuration), and 300 this address is typically used by many clients simultaneously. 302 Since the client is behind a NAT, the server sees packets from the 303 client as coming from a transport address on the NAT itself. This 304 address is known as the client's SERVER-REFLEXIVE transport address; 305 packets sent by the server to the client's server-reflexive transport 306 address will be forwarded by the NAT to the client's host transport 307 address. 309 The client uses TURN commands to create and manipulate an ALLOCATION 310 on the server. An allocation is a data structure on the server. 311 This data structure contains, amongst other things, the RELAYED 312 TRANSPORT ADDRESS for the allocation. The relayed transport address 313 is the transport address on the server that peers can use to have the 314 server relay data to the client. An allocation is uniquely 315 identified by its relayed transport address. 317 Once an allocation is created, the client can send application data 318 to the server along with an indication of to which peer the data is 319 to be sent, and the server will relay this data to the appropriate 320 peer. The client sends the application data to the server inside a 321 TURN message; at the server, the data is extracted from the TURN 322 message and sent to the peer in a UDP datagram. In the reverse 323 direction, a peer can send application data in a UDP datagram to the 324 relayed transport address for the allocation; the server will then 325 encapsulate this data inside a TURN message and send it to the client 326 along with an indication of which peer sent the data. Since the TURN 327 message always contains an indication of which peer the client is 328 communicating with, the client can use a single allocation to 329 communicate with multiple peers. 331 When the peer is behind a NAT, then the client must identify the peer 332 using its server-reflexive transport address rather than its host 333 transport address. For example, to send application data to Peer A 334 in the example above, the client must specify 192.0.2.150:32102 (Peer 335 A's server-reflexive transport address) rather than 203.0.113.2:49582 336 (Peer A's host transport address). 338 Each allocation on the server belongs to a single client and has 339 exactly one relayed transport address that is used only by that 340 allocation. Thus, when a packet arrives at a relayed transport 341 address on the server, the server knows for which client the data is 342 intended. 344 The client may have multiple allocations on a server at the same 345 time. 347 2.1. Transports 349 TURN, as defined in this specification, always uses UDP between the 350 server and the peer. However, this specification allows the use of 351 any one of UDP, TCP, Transport Layer Security (TLS) over TCP or 352 Datagram Transport Layer Security (DTLS) over UDP to carry the TURN 353 messages between the client and the server. 355 +----------------------------+---------------------+ 356 | TURN client to TURN server | TURN server to peer | 357 +----------------------------+---------------------+ 358 | UDP | UDP | 359 | TCP | UDP | 360 | TLS-over-TCP | UDP | 361 | DTLS-over-UDP | UDP | 362 +----------------------------+---------------------+ 364 If TCP or TLS-over-TCP is used between the client and the server, 365 then the server will convert between these transports and UDP 366 transport when relaying data to/from the peer. 368 Since this version of TURN only supports UDP between the server and 369 the peer, it is expected that most clients will prefer to use UDP 370 between the client and the server as well. That being the case, some 371 readers may wonder: Why also support TCP and TLS-over-TCP? 373 TURN supports TCP transport between the client and the server because 374 some firewalls are configured to block UDP entirely. These firewalls 375 block UDP but not TCP, in part because TCP has properties that make 376 the intention of the nodes being protected by the firewall more 377 obvious to the firewall. For example, TCP has a three-way handshake 378 that makes in clearer that the protected node really wishes to have 379 that particular connection established, while for UDP the best the 380 firewall can do is guess which flows are desired by using filtering 381 rules. Also, TCP has explicit connection teardown; while for UDP, 382 the firewall has to use timers to guess when the flow is finished. 384 TURN supports TLS-over-TCP transport and DTLS-over-UDP transport 385 between the client and the server because (D)TLS provides additional 386 security properties not provided by TURN's default digest 387 authentication; properties that some clients may wish to take 388 advantage of. In particular, (D)TLS provides a way for the client to 389 ascertain that it is talking to the correct server, and provides for 390 confidentiality of TURN control messages. TURN does not require 391 (D)TLS because the overhead of using (D)TLS is higher than that of 392 digest authentication; for example, using (D)TLS likely means that 393 most application data will be doubly encrypted (once by (D)TLS and 394 once to ensure it is still encrypted in the UDP datagram). 396 There is an extension to TURN for TCP transport between the server 397 and the peers [RFC6062]. For this reason, allocations that use UDP 398 between the server and the peers are known as UDP allocations, while 399 allocations that use TCP between the server and the peers are known 400 as TCP allocations. This specification describes only UDP 401 allocations. 403 In some applications for TURN, the client may send and receive 404 packets other than TURN packets on the host transport address it uses 405 to communicate with the server. This can happen, for example, when 406 using TURN with ICE. In these cases, the client can distinguish TURN 407 packets from other packets by examining the source address of the 408 arriving packet: those arriving from the TURN server will be TURN 409 packets. The algorithm of demultiplexing packets received from 410 multiple protocols on the host transport address is discussed in 411 [RFC7983]. 413 2.2. Allocations 415 To create an allocation on the server, the client uses an Allocate 416 transaction. The client sends an Allocate request to the server, and 417 the server replies with an Allocate success response containing the 418 allocated relayed transport address. The client can include 419 attributes in the Allocate request that describe the type of 420 allocation it desires (e.g., the lifetime of the allocation). Since 421 relaying data has security implications, the server requires that the 422 client authenticate itself, typically using STUN's long-term 423 credential mechanism or the STUN Extension for Third-Party 424 Authorization [RFC7635], to show that it is authorized to use the 425 server. 427 Once a relayed transport address is allocated, a client must keep the 428 allocation alive. To do this, the client periodically sends a 429 Refresh request to the server. TURN deliberately uses a different 430 method (Refresh rather than Allocate) for refreshes to ensure that 431 the client is informed if the allocation vanishes for some reason. 433 The frequency of the Refresh transaction is determined by the 434 lifetime of the allocation. The default lifetime of an allocation is 435 10 minutes -- this value was chosen to be long enough so that 436 refreshing is not typically a burden on the client, while expiring 437 allocations where the client has unexpectedly quit in a timely 438 manner. However, the client can request a longer lifetime in the 439 Allocate request and may modify its request in a Refresh request, and 440 the server always indicates the actual lifetime in the response. The 441 client must issue a new Refresh transaction within "lifetime" seconds 442 of the previous Allocate or Refresh transaction. Once a client no 443 longer wishes to use an allocation, it should delete the allocation 444 using a Refresh request with a requested lifetime of 0. 446 Both the server and client keep track of a value known as the 447 5-TUPLE. At the client, the 5-tuple consists of the client's host 448 transport address, the server transport address, and the transport 449 protocol used by the client to communicate with the server. At the 450 server, the 5-tuple value is the same except that the client's host 451 transport address is replaced by the client's server-reflexive 452 address, since that is the client's address as seen by the server. 454 Both the client and the server remember the 5-tuple used in the 455 Allocate request. Subsequent messages between the client and the 456 server use the same 5-tuple. In this way, the client and server know 457 which allocation is being referred to. If the client wishes to 458 allocate a second relayed transport address, it must create a second 459 allocation using a different 5-tuple (e.g., by using a different 460 client host address or port). 462 NOTE: While the terminology used in this document refers to 463 5-tuples, the TURN server can store whatever identifier it likes 464 that yields identical results. Specifically, an implementation 465 may use a file-descriptor in place of a 5-tuple to represent a TCP 466 connection. 468 TURN TURN Peer Peer 469 client server A B 470 |-- Allocate request --------------->| | | 471 | (invalid or missing credentials) | | | 472 | | | | 473 |<--------------- Allocate failure --| | | 474 | (401 Unauthenticated) | | | 475 | | | | 476 |-- Allocate request --------------->| | | 477 | (valid credentials) | | | 478 | | | | 479 |<---------- Allocate success resp --| | | 480 | (192.0.2.15:50000) | | | 481 // // // // 482 | | | | 483 |-- Refresh request ---------------->| | | 484 | | | | 485 |<----------- Refresh success resp --| | | 486 | | | | 488 Figure 2 490 In Figure 2, the client sends an Allocate request to the server with 491 invalid or missing credentials. Since the server requires that all 492 requests be authenticated using STUN's long-term credential 493 mechanism, the server rejects the request with a 401 (Unauthorized) 494 error code. The client then tries again, this time including 495 credentials. This time, the server accepts the Allocate request and 496 returns an Allocate success response containing (amongst other 497 things) the relayed transport address assigned to the allocation. 498 Sometime later, the client decides to refresh the allocation and thus 499 sends a Refresh request to the server. The refresh is accepted and 500 the server replies with a Refresh success response. 502 2.3. Permissions 504 To ease concerns amongst enterprise IT administrators that TURN could 505 be used to bypass corporate firewall security, TURN includes the 506 notion of permissions. TURN permissions mimic the address-restricted 507 filtering mechanism of NATs that comply with [RFC4787]. 509 An allocation can have zero or more permissions. Each permission 510 consists of an IP address and a lifetime. When the server receives a 511 UDP datagram on the allocation's relayed transport address, there are 512 two conditions that cause it to forward that packet: permissions or 513 TURN server configuration. It first checks the list of permissions. 514 If the source IP address of the datagram matches a permission, the 515 application data is relayed to the client, otherwise the UDP datagram 516 is silently discarded. Second, a TURN server can be configured to 517 permit inbound STUN packets on the allocation's relayed address even 518 if the source IP addresses of the STUN packets do not match the 519 permissions installed. The filtering rule to block all traffic 520 except STUN packets speeds up STUN connectivity checks, addressing 521 the race condition that exists when the remote peer sends 522 connectivity checks before the client has had a chance to create 523 permissions in the TURN server for the remote peer IP addresses. 525 A permission expires after 5 minutes if it is not refreshed, and 526 there is no way to explicitly delete a permission. This behavior was 527 selected to match the behavior of a NAT that complies with [RFC4787]. 529 The client can install or refresh a permission using either a 530 CreatePermission request or a ChannelBind request. Using the 531 CreatePermission request, multiple permissions can be installed or 532 refreshed with a single request -- this is important for applications 533 that use ICE. For security reasons, permissions can only be 534 installed or refreshed by transactions that can be authenticated; 535 thus, Send indications and ChannelData messages (which are used to 536 send data to peers) do not install or refresh any permissions. 538 Note that permissions are within the context of an allocation, so 539 adding or expiring a permission in one allocation does not affect 540 other allocations. 542 2.4. Send Mechanism 544 There are two mechanisms for the client and peers to exchange 545 application data using the TURN server. The first mechanism uses the 546 Send and Data methods, the second mechanism uses channels. Common to 547 both mechanisms is the ability of the client to communicate with 548 multiple peers using a single allocated relayed transport address; 549 thus, both mechanisms include a means for the client to indicate to 550 the server which peer should receive the data, and for the server to 551 indicate to the client which peer sent the data. 553 The Send mechanism uses Send and Data indications. Send indications 554 are used to send application data from the client to the server, 555 while Data indications are used to send application data from the 556 server to the client. 558 When using the Send mechanism, the client sends a Send indication to 559 the TURN server containing (a) an XOR-PEER-ADDRESS attribute 560 specifying the (server-reflexive) transport address of the peer and 561 (b) a DATA attribute holding the application data. When the TURN 562 server receives the Send indication, it extracts the application data 563 from the DATA attribute and sends it in a UDP datagram to the peer, 564 using the allocated relay address as the source address. Note that 565 there is no need to specify the relayed transport address, since it 566 is implied by the 5-tuple used for the Send indication. 568 In the reverse direction, UDP datagrams arriving at the relayed 569 transport address on the TURN server are converted into Data 570 indications and sent to the client, with the server-reflexive 571 transport address of the peer included in an XOR-PEER-ADDRESS 572 attribute and the data itself in a DATA attribute. Since the relayed 573 transport address uniquely identified the allocation, the server 574 knows which client should receive the data. 576 Some ICMP (Internet Control Message Protocol) packets arriving at the 577 relayed transport address on the TURN server may be converted into 578 Data indications and sent to the client, with the transport address 579 of the peer included in an XOR-PEER-ADDRESS attribute and the ICMP 580 type and code in a ICMP attribute. ICMP attribute forwarding always 581 uses Data indications containing the XOR-PEER-ADDRESS and ICMP 582 attributes, even when using the channel mechanism to forward UDP 583 data. 585 Send and Data indications cannot be authenticated, since the long- 586 term credential mechanism of STUN does not support authenticating 587 indications. This is not as big an issue as it might first appear, 588 since the client-to-server leg is only half of the total path to the 589 peer. Applications that want proper security should encrypt the data 590 sent between the client and a peer. 592 Because Send indications are not authenticated, it is possible for an 593 attacker to send bogus Send indications to the server, which will 594 then relay these to a peer. To partly mitigate this attack, TURN 595 requires that the client install a permission towards a peer before 596 sending data to it using a Send indication. 598 TURN TURN Peer Peer 599 client server A B 600 | | | | 601 |-- CreatePermission req (Peer A) -->| | | 602 |<-- CreatePermission success resp --| | | 603 | | | | 604 |--- Send ind (Peer A)-------------->| | | 605 | |=== data ===>| | 606 | | | | 607 | |<== data ====| | 608 |<-------------- Data ind (Peer A) --| | | 609 | | | | 610 | | | | 611 |--- Send ind (Peer B)-------------->| | | 612 | | dropped | | 613 | | | | 614 | |<== data ==================| 615 | dropped | | | 616 | | | | 618 Figure 3 620 In Figure 3, the client has already created an allocation and now 621 wishes to send data to its peers. The client first creates a 622 permission by sending the server a CreatePermission request 623 specifying Peer A's (server-reflexive) IP address in the XOR-PEER- 624 ADDRESS attribute; if this was not done, the server would not relay 625 data between the client and the server. The client then sends data 626 to Peer A using a Send indication; at the server, the application 627 data is extracted and forwarded in a UDP datagram to Peer A, using 628 the relayed transport address as the source transport address. When 629 a UDP datagram from Peer A is received at the relayed transport 630 address, the contents are placed into a Data indication and forwarded 631 to the client. Later, the client attempts to exchange data with Peer 632 B; however, no permission has been installed for Peer B, so the Send 633 indication from the client and the UDP datagram from the peer are 634 both dropped by the server. 636 2.5. Channels 638 For some applications (e.g., Voice over IP), the 36 bytes of overhead 639 that a Send indication or Data indication adds to the application 640 data can substantially increase the bandwidth required between the 641 client and the server. To remedy this, TURN offers a second way for 642 the client and server to associate data with a specific peer. 644 This second way uses an alternate packet format known as the 645 ChannelData message. The ChannelData message does not use the STUN 646 header used by other TURN messages, but instead has a 4-byte header 647 that includes a number known as a channel number. Each channel 648 number in use is bound to a specific peer and thus serves as a 649 shorthand for the peer's host transport address. 651 To bind a channel to a peer, the client sends a ChannelBind request 652 to the server, and includes an unbound channel number and the 653 transport address of the peer. Once the channel is bound, the client 654 can use a ChannelData message to send the server data destined for 655 the peer. Similarly, the server can relay data from that peer 656 towards the client using a ChannelData message. 658 Channel bindings last for 10 minutes unless refreshed -- this 659 lifetime was chosen to be longer than the permission lifetime. 660 Channel bindings are refreshed by sending another ChannelBind request 661 rebinding the channel to the peer. Like permissions (but unlike 662 allocations), there is no way to explicitly delete a channel binding; 663 the client must simply wait for it to time out. 665 TURN TURN Peer Peer 666 client server A B 667 | | | | 668 |-- ChannelBind req ---------------->| | | 669 | (Peer A to 0x4001) | | | 670 | | | | 671 |<---------- ChannelBind succ resp --| | | 672 | | | | 673 |-- (0x4001) data ------------------>| | | 674 | |=== data ===>| | 675 | | | | 676 | |<== data ====| | 677 |<------------------ (0x4001) data --| | | 678 | | | | 679 |--- Send ind (Peer A)-------------->| | | 680 | |=== data ===>| | 681 | | | | 682 | |<== data ====| | 683 |<------------------ (0x4001) data --| | | 684 | | | | 686 Figure 4 688 Figure 4 shows the channel mechanism in use. The client has already 689 created an allocation and now wishes to bind a channel to Peer A. To 690 do this, the client sends a ChannelBind request to the server, 691 specifying the transport address of Peer A and a channel number 692 (0x4001). After that, the client can send application data 693 encapsulated inside ChannelData messages to Peer A: this is shown as 694 "(0x4001) data" where 0x4001 is the channel number. When the 695 ChannelData message arrives at the server, the server transfers the 696 data to a UDP datagram and sends it to Peer A (which is the peer 697 bound to channel number 0x4001). 699 In the reverse direction, when Peer A sends a UDP datagram to the 700 relayed transport address, this UDP datagram arrives at the server on 701 the relayed transport address assigned to the allocation. Since the 702 UDP datagram was received from Peer A, which has a channel number 703 assigned to it, the server encapsulates the data into a ChannelData 704 message when sending the data to the client. 706 Once a channel has been bound, the client is free to intermix 707 ChannelData messages and Send indications. In the figure, the client 708 later decides to use a Send indication rather than a ChannelData 709 message to send additional data to Peer A. The client might decide 710 to do this, for example, so it can use the DONT-FRAGMENT attribute 711 (see the next section). However, once a channel is bound, the server 712 will always use a ChannelData message, as shown in the call flow. 714 Note that ChannelData messages can only be used for peers to which 715 the client has bound a channel. In the example above, Peer A has 716 been bound to a channel, but Peer B has not, so application data to 717 and from Peer B would use the Send mechanism. 719 2.6. Unprivileged TURN Servers 721 This version of TURN is designed so that the server can be 722 implemented as an application that runs in user space under commonly 723 available operating systems without requiring special privileges. 724 This design decision was made to make it easy to deploy a TURN 725 server: for example, to allow a TURN server to be integrated into a 726 peer-to-peer application so that one peer can offer NAT traversal 727 services to another peer. 729 This design decision has the following implications for data relayed 730 by a TURN server: 732 o The value of the Diffserv field may not be preserved across the 733 server; 735 o The Time to Live (TTL) field may be reset, rather than 736 decremented, across the server; 738 o The Explicit Congestion Notification (ECN) field may be reset by 739 the server; 741 o There is no end-to-end fragmentation, since the packet is re- 742 assembled at the server. 744 Future work may specify alternate TURN semantics that address these 745 limitations. 747 2.7. Avoiding IP Fragmentation 749 For reasons described in [Frag-Harmful], applications, especially 750 those sending large volumes of data, should try hard to avoid having 751 their packets fragmented. Applications using TCP can more or less 752 ignore this issue because fragmentation avoidance is now a standard 753 part of TCP, but applications using UDP (and thus any application 754 using this version of TURN) must handle fragmentation avoidance 755 themselves. 757 The application running on the client and the peer can take one of 758 two approaches to avoid IP fragmentation. 760 The first approach is to avoid sending large amounts of application 761 data in the TURN messages/UDP datagrams exchanged between the client 762 and the peer. This is the approach taken by most VoIP (Voice-over- 763 IP) applications. In this approach, the application exploits the 764 fact that the IP specification [RFC0791] specifies that IP packets up 765 to 576 bytes should never need to be fragmented. 767 The exact amount of application data that can be included while 768 avoiding fragmentation depends on the details of the TURN session 769 between the client and the server: whether UDP, TCP, or (D)TLS 770 transport is used, whether ChannelData messages or Send/Data 771 indications are used, and whether any additional attributes (such as 772 the DONT-FRAGMENT attribute) are included. Another factor, which is 773 hard to determine, is whether the MTU is reduced somewhere along the 774 path for other reasons, such as the use of IP-in-IP tunneling. 776 As a guideline, sending a maximum of 500 bytes of application data in 777 a single TURN message (by the client on the client-to-server leg) or 778 a UDP datagram (by the peer on the peer-to-server leg) will generally 779 avoid IP fragmentation. To further reduce the chance of 780 fragmentation, it is recommended that the client use ChannelData 781 messages when transferring significant volumes of data, since the 782 overhead of the ChannelData message is less than Send and Data 783 indications. 785 The second approach the client and peer can take to avoid 786 fragmentation is to use a path MTU discovery algorithm to determine 787 the maximum amount of application data that can be sent without 788 fragmentation. The classic path MTU discovery algorithm defined in 790 [RFC1191] may not be able to discover the MTU of the transmission 791 path between the client and the peer since: 793 - a probe packet with DF bit set to test a path for a larger MTU 794 can be dropped by routers, or 796 - ICMP error messages can be dropped by middle boxes. 798 As a result, the client and server need to use a path MTU discovery 799 algorithm that does not require ICMP messages. The Packetized Path 800 MTU Discovery algorithm defined in [RFC4821] is one such algorithm. 802 [I-D.ietf-tram-stun-pmtud] is an implementation of [RFC4821] that 803 uses STUN to discover the path MTU, and so might be a suitable 804 approach to be used in conjunction with a TURN server that supports 805 the DONT-FRAGMENT attribute. When the client includes the DONT- 806 FRAGMENT attribute in a Send indication, this tells the server to set 807 the DF bit in the resulting UDP datagram that it sends to the peer. 808 Since some servers may be unable to set the DF bit, the client should 809 also include this attribute in the Allocate request -- any server 810 that does not support the DONT-FRAGMENT attribute will indicate this 811 by rejecting the Allocate request. 813 2.8. RTP Support 815 One of the envisioned uses of TURN is as a relay for clients and 816 peers wishing to exchange real-time data (e.g., voice or video) using 817 RTP. To facilitate the use of TURN for this purpose, TURN includes 818 some special support for older versions of RTP. 820 Old versions of RTP [RFC3550] required that the RTP stream be on an 821 even port number and the associated RTP Control Protocol (RTCP) 822 stream, if present, be on the next highest port. To allow clients to 823 work with peers that still require this, TURN allows the client to 824 request that the server allocate a relayed transport address with an 825 even port number, and to optionally request the server reserve the 826 next-highest port number for a subsequent allocation. 828 2.9. Happy Eyeballs for TURN 830 If an IPv4 path to reach a TURN server is found, but the TURN 831 server's IPv6 path is not working, a dual-stack TURN client can 832 experience a significant connection delay compared to an IPv4-only 833 TURN client. To overcome these connection setup problems, the TURN 834 client MUST query both A and AAAA records for the TURN server 835 specified using a domain name and try connecting to the TURN server 836 using both IPv6 and IPv4 addresses in a fashion similar to the Happy 837 Eyeballs mechanism defined in [RFC8305]. The TURN client performs 838 the following steps based on the transport protocol being used to 839 connect to the TURN server. 841 o For TCP or TLS-over-TCP, initiate TCP connection to both IP 842 address families as discussed in [RFC8305], and use the first TCP 843 connection that is established. If connections are established on 844 both IP address families then terminate the TCP connection using 845 the IP address family with lower precedence [RFC6724]. 847 o For clear text UDP, send TURN Allocate requests to both IP address 848 families as discussed in [RFC8305], without authentication 849 information. If the TURN server requires authentication, it will 850 send back a 401 unauthenticated response and the TURN client uses 851 the first UDP connection on which a 401 error response is 852 received. If a 401 error response is received from both IP 853 address families then the TURN client can silently abandon the UDP 854 connection on the IP address family with lower precedence. If the 855 TURN server does not require authentication (as described in 856 Section 9 of [RFC8155]), it is possible for both Allocate requests 857 to succeed. In this case, the TURN client sends a Refresh with 858 LIFETIME value of 0 on the allocation using the IP address family 859 with lower precedence to delete the allocation. 861 o For DTLS over UDP, initiate DTLS handshake to both IP address 862 families as discussed in [RFC8305] and use the first DTLS session 863 that is established. If the DTLS session is established on both 864 IP address families then the client sends DTLS close_notify alert 865 to terminate the DTLS session using the IP address family with 866 lower precedence. If TURN over DTLS server has been configured to 867 require a cookie exchange (Section 4.2 in [RFC6347]) and 868 HelloVerifyRequest is received from the TURN servers on both IP 869 address families then the client can silently abandon the 870 connection on the IP address family with lower precedence. 872 3. Terminology 874 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 875 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 876 document are to be interpreted as described in RFC 2119 [RFC2119]. 878 Readers are expected to be familiar with [I-D.ietf-tram-stunbis] and 879 the terms defined there. 881 The following terms are used in this document: 883 TURN: The protocol spoken between a TURN client and a TURN server. 884 It is an extension to the STUN protocol [I-D.ietf-tram-stunbis]. 886 The protocol allows a client to allocate and use a relayed 887 transport address. 889 TURN client: A STUN client that implements this specification. 891 TURN server: A STUN server that implements this specification. It 892 relays data between a TURN client and its peer(s). 894 Peer: A host with which the TURN client wishes to communicate. The 895 TURN server relays traffic between the TURN client and its 896 peer(s). The peer does not interact with the TURN server using 897 the protocol defined in this document; rather, the peer receives 898 data sent by the TURN server and the peer sends data towards the 899 TURN server. 901 Transport Address: The combination of an IP address and a port. 903 Host Transport Address: A transport address on a client or a peer. 905 Server-Reflexive Transport Address: A transport address on the 906 "public side" of a NAT. This address is allocated by the NAT to 907 correspond to a specific host transport address. 909 Relayed Transport Address: A transport address on the TURN server 910 that is used for relaying packets between the client and a peer. 911 A peer sends to this address on the TURN server, and the packet is 912 then relayed to the client. 914 TURN Server Transport Address: A transport address on the TURN 915 server that is used for sending TURN messages to the server. This 916 is the transport address that the client uses to communicate with 917 the server. 919 Peer Transport Address: The transport address of the peer as seen by 920 the server. When the peer is behind a NAT, this is the peer's 921 server-reflexive transport address. 923 Allocation: The relayed transport address granted to a client 924 through an Allocate request, along with related state, such as 925 permissions and expiration timers. 927 5-tuple: The combination (client IP address and port, server IP 928 address and port, and transport protocol (currently one of UDP, 929 TCP, or (D)TLS)) used to communicate between the client and the 930 server. The 5-tuple uniquely identifies this communication 931 stream. The 5-tuple also uniquely identifies the Allocation on 932 the server. 934 Channel: A channel number and associated peer transport address. 935 Once a channel number is bound to a peer's transport address, the 936 client and server can use the more bandwidth-efficient ChannelData 937 message to exchange data. 939 Permission: The IP address and transport protocol (but not the port) 940 of a peer that is permitted to send traffic to the TURN server and 941 have that traffic relayed to the TURN client. The TURN server 942 will only forward traffic to its client from peers that match an 943 existing permission. 945 Realm: A string used to describe the server or a context within the 946 server. The realm tells the client which username and password 947 combination to use to authenticate requests. 949 Nonce: A string chosen at random by the server and included in the 950 message-digest. To prevent replay attacks, the server should 951 change the nonce regularly. 953 (D)TLS: This term is used for statements that apply to both 954 Transport Layer Security [RFC5246] and Datagram Transport Layer 955 Security [RFC6347]. 957 4. Discovery of TURN server 959 Methods of TURN server discovery, including using anycast, are 960 described in [RFC8155]. The syntax of the "turn" and "turns" URIs 961 are defined in Section 3.1 of [RFC7065]. 963 4.1. TURN URI Scheme Semantics 965 The "turn" and "turns" URI schemes are used to designate a TURN 966 server (also known as a relay) on Internet hosts accessible using the 967 TURN protocol. The TURN protocol supports sending messages over UDP, 968 TCP, TLS-over-TCP or DTLS-over-UDP. The "turns" URI scheme MUST be 969 used when TURN is run over TLS-over-TCP or in DTLS-over-UDP, and the 970 "turn" scheme MUST be used otherwise. The required part of 971 the "turn" URI denotes the TURN server host. The part, if 972 present, denotes the port on which the TURN server is awaiting 973 connection requests. If it is absent, the default port is 3478 for 974 both UDP and TCP. The default port for TURN over TLS and TURN over 975 DTLS is 5349. 977 5. General Behavior 979 This section contains general TURN processing rules that apply to all 980 TURN messages. 982 TURN is an extension to STUN. All TURN messages, with the exception 983 of the ChannelData message, are STUN-formatted messages. All the 984 base processing rules described in [I-D.ietf-tram-stunbis] apply to 985 STUN-formatted messages. This means that all the message-forming and 986 message-processing descriptions in this document are implicitly 987 prefixed with the rules of [I-D.ietf-tram-stunbis]. 989 [I-D.ietf-tram-stunbis] specifies an authentication mechanism called 990 the long-term credential mechanism. TURN servers and clients MUST 991 implement this mechanism. The server MUST demand that all requests 992 from the client be authenticated using this mechanism, or that a 993 equally strong or stronger mechanism for client authentication is 994 used. 996 Note that the long-term credential mechanism applies only to requests 997 and cannot be used to authenticate indications; thus, indications in 998 TURN are never authenticated. If the server requires requests to be 999 authenticated, then the server's administrator MUST choose a realm 1000 value that will uniquely identify the username and password 1001 combination that the client must use, even if the client uses 1002 multiple servers under different administrations. The server's 1003 administrator MAY choose to allocate a unique username to each 1004 client, or MAY choose to allocate the same username to more than one 1005 client (for example, to all clients from the same department or 1006 company). For each Allocate request, the server SHOULD generate a 1007 new random nonce when the allocation is first attempted following the 1008 randomness recommendations in [RFC4086] and SHOULD expire the nonce 1009 at least once every hour during the lifetime of the allocation. 1011 All requests after the initial Allocate must use the same username as 1012 that used to create the allocation, to prevent attackers from 1013 hijacking the client's allocation. Specifically, if the server 1014 requires the use of the long-term credential mechanism, and if a non- 1015 Allocate request passes authentication under this mechanism, and if 1016 the 5-tuple identifies an existing allocation, but the request does 1017 not use the same username as used to create the allocation, then the 1018 request MUST be rejected with a 441 (Wrong Credentials) error. 1020 When a TURN message arrives at the server from the client, the server 1021 uses the 5-tuple in the message to identify the associated 1022 allocation. For all TURN messages (including ChannelData) EXCEPT an 1023 Allocate request, if the 5-tuple does not identify an existing 1024 allocation, then the message MUST either be rejected with a 437 1025 Allocation Mismatch error (if it is a request) or silently ignored 1026 (if it is an indication or a ChannelData message). A client 1027 receiving a 437 error response to a request other than Allocate MUST 1028 assume the allocation no longer exists. 1030 [I-D.ietf-tram-stunbis] defines a number of attributes, including the 1031 SOFTWARE and FINGERPRINT attributes. The client SHOULD include the 1032 SOFTWARE attribute in all Allocate and Refresh requests and MAY 1033 include it in any other requests or indications. The server SHOULD 1034 include the SOFTWARE attribute in all Allocate and Refresh responses 1035 (either success or failure) and MAY include it in other responses or 1036 indications. The client and the server MAY include the FINGERPRINT 1037 attribute in any STUN-formatted messages defined in this document. 1039 TURN does not use the backwards-compatibility mechanism described in 1040 [I-D.ietf-tram-stunbis]. 1042 TURN, as defined in this specification, supports both IPv4 and IPv6. 1043 IPv6 support in TURN includes IPv4-to-IPv6, IPv6-to-IPv6, and IPv6- 1044 to-IPv4 relaying. The REQUESTED-ADDRESS-FAMILY attribute allows a 1045 client to explicitly request the address type the TURN server will 1046 allocate (e.g., an IPv4-only node may request the TURN server to 1047 allocate an IPv6 address). The ADDITIONAL-ADDRESS-FAMILY attribute 1048 allows a client to request the server to allocate one IPv4 and one 1049 IPv6 relay address in a single Allocate request. This saves local 1050 ports on the client and reduces the number of messages sent between 1051 the client and the TURN server. 1053 By default, TURN runs on the same ports as STUN: 3478 for TURN over 1054 UDP and TCP, and 5349 for TURN over (D)TLS. However, TURN has its 1055 own set of Service Record (SRV) names: "turn" for UDP and TCP, and 1056 "turns" for (D)TLS. Either the DNS resolution procedures or the 1057 ALTERNATE-SERVER procedures, both described in Section 7, can be used 1058 to run TURN on a different port. 1060 To ensure interoperability, a TURN server MUST support the use of UDP 1061 transport between the client and the server, and SHOULD support the 1062 use of TCP, TLS-over-TCP and DTLS-over-UDP transports. 1064 When UDP or DTLS-over-UDP transport is used between the client and 1065 the server, the client will retransmit a request if it does not 1066 receive a response within a certain timeout period. Because of this, 1067 the server may receive two (or more) requests with the same 5-tuple 1068 and same transaction id. STUN requires that the server recognize 1069 this case and treat the request as idempotent (see 1070 [I-D.ietf-tram-stunbis]). Some implementations may choose to meet 1071 this requirement by remembering all received requests and the 1072 corresponding responses for 40 seconds. Other implementations may 1073 choose to reprocess the request and arrange that such reprocessing 1074 returns essentially the same response. To aid implementors who 1075 choose the latter approach (the so-called "stateless stack 1076 approach"), this specification includes some implementation notes on 1077 how this might be done. Implementations are free to choose either 1078 approach or choose some other approach that gives the same results. 1080 When TCP transport is used between the client and the server, it is 1081 possible that a bit error will cause a length field in a TURN packet 1082 to become corrupted, causing the receiver to lose synchronization 1083 with the incoming stream of TURN messages. A client or server that 1084 detects a long sequence of invalid TURN messages over TCP transport 1085 SHOULD close the corresponding TCP connection to help the other end 1086 detect this situation more rapidly. 1088 To mitigate either intentional or unintentional denial-of-service 1089 attacks against the server by clients with valid usernames and 1090 passwords, it is RECOMMENDED that the server impose limits on both 1091 the number of allocations active at one time for a given username and 1092 on the amount of bandwidth those allocations can use. The server 1093 should reject new allocations that would exceed the limit on the 1094 allowed number of allocations active at one time with a 486 1095 (Allocation Quota Exceeded) (see Section 7.2), and should discard 1096 application data traffic that exceeds the bandwidth quota. 1098 6. Allocations 1100 All TURN operations revolve around allocations, and all TURN messages 1101 are associated with either a single or dual allocation. An 1102 allocation conceptually consists of the following state data: 1104 o the relayed transport address or addresses; 1106 o the 5-tuple: (client's IP address, client's port, server IP 1107 address, server port, transport protocol); 1109 o the authentication information; 1111 o the time-to-expiry for each relayed transport address; 1113 o a list of permissions for each relayed transport address; 1115 o a list of channel to peer bindings for each relayed transport 1116 address. 1118 The relayed transport address is the transport address allocated by 1119 the server for communicating with peers, while the 5-tuple describes 1120 the communication path between the client and the server. On the 1121 client, the 5-tuple uses the client's host transport address; on the 1122 server, the 5-tuple uses the client's server-reflexive transport 1123 address. The relayed transport address MUST be unique across all 1124 allocations, so it can be used to uniquely identify the allocation. 1126 Both the relayed transport address and the 5-tuple MUST be unique 1127 across all allocations, so either one can be used to uniquely 1128 identify the allocation, and an allocation in this context can be 1129 either a single or dual allocation. 1131 The authentication information (e.g., username, password, realm, and 1132 nonce) is used to both verify subsequent requests and to compute the 1133 message integrity of responses. The username, realm, and nonce 1134 values are initially those used in the authenticated Allocate request 1135 that creates the allocation, though the server can change the nonce 1136 value during the lifetime of the allocation using a 438 (Stale Nonce) 1137 reply. Note that, rather than storing the password explicitly, for 1138 security reasons, it may be desirable for the server to store the key 1139 value, which is a secure hash over the username, realm, and password 1140 (see [I-D.ietf-tram-stunbis]). 1142 The time-to-expiry is the time in seconds left until the allocation 1143 expires. Each Allocate or Refresh transaction sets this timer, which 1144 then ticks down towards 0. By default, each Allocate or Refresh 1145 transaction resets this timer to the default lifetime value of 600 1146 seconds (10 minutes), but the client can request a different value in 1147 the Allocate and Refresh request. Allocations can only be refreshed 1148 using the Refresh request; sending data to a peer does not refresh an 1149 allocation. When an allocation expires, the state data associated 1150 with the allocation can be freed. 1152 The list of permissions is described in Section 9 and the list of 1153 channels is described in Section 12. 1155 7. Creating an Allocation 1157 An allocation on the server is created using an Allocate transaction. 1159 7.1. Sending an Allocate Request 1161 The client forms an Allocate request as follows. 1163 The client first picks a host transport address. It is RECOMMENDED 1164 that the client pick a currently unused transport address, typically 1165 by allowing the underlying OS to pick a currently unused port for a 1166 new socket. 1168 The client then picks a transport protocol to use between the client 1169 and the server. The transport protocol MUST be one of UDP, TCP, TLS- 1170 over-TCP or DTLS-over-UDP. Since this specification only allows UDP 1171 between the server and the peers, it is RECOMMENDED that the client 1172 pick UDP unless it has a reason to use a different transport. One 1173 reason to pick a different transport would be that the client 1174 believes, either through configuration or by experiment, that it is 1175 unable to contact any TURN server using UDP. See Section 2.1 for 1176 more discussion. 1178 The client also picks a server transport address, which SHOULD be 1179 done as follows. The client uses one or more procedures described in 1180 [RFC8155] to discover a TURN server and uses the TURN server 1181 resolution mechanism defined in [RFC5928] to get a list of server 1182 transport addresses that can be tried to create a TURN allocation. 1184 The client MUST include a REQUESTED-TRANSPORT attribute in the 1185 request. This attribute specifies the transport protocol between the 1186 server and the peers (note that this is NOT the transport protocol 1187 that appears in the 5-tuple). In this specification, the REQUESTED- 1188 TRANSPORT type is always UDP. This attribute is included to allow 1189 future extensions to specify other protocols. 1191 If the client wishes to obtain a relayed transport address of a 1192 specific address type then it includes a REQUESTED-ADDRESS-FAMILY 1193 attribute in the request. This attribute indicates the specific 1194 address type the client wishes the TURN server to allocate. Clients 1195 MUST NOT include more than one REQUESTED-ADDRESS-FAMILY attribute in 1196 an Allocate request. Clients MUST NOT include a REQUESTED-ADDRESS- 1197 FAMILY attribute in an Allocate request that contains a RESERVATION- 1198 TOKEN attribute, for the reasons outlined in [RFC6156]. 1200 If the client wishes to obtain one IPv6 and one IPv4 relayed 1201 transport address then it includes an ADDITIONAL-ADDRESS-FAMILY 1202 attribute in the request. This attribute specifies that the server 1203 must allocate both address types. The attribute value in the 1204 ADDITIONAL-ADDRESS-FAMILY MUST be set to 0x02 (IPv6 address family). 1205 Clients MUST NOT include REQUESTED-ADDRESS-FAMILY and ADDITIONAL- 1206 ADDRESS-FAMILY attributes in the same request. Clients MUST NOT 1207 include ADDITIONAL-ADDRESS-FAMILY attribute in a Allocate request 1208 that contains a RESERVATION-TOKEN attribute. Clients MUST NOT 1209 include ADDITIONAL-ADDRESS-FAMILY attribute in a Allocate request 1210 that contains an EVEN-PORT attribute with the R bit set to 1. The 1211 reason behind the restriction is if EVEN-PORT with R bit set to 1 is 1212 allowed with the ADDITIONAL-ADDRESS-FAMILY attribute, two tokens will 1213 have to be returned in success response and requires changes to the 1214 way RESERVATION-TOKEN is handled. 1216 If the client wishes the server to initialize the time-to-expiry 1217 field of the allocation to some value other than the default 1218 lifetime, then it MAY include a LIFETIME attribute specifying its 1219 desired value. This is just a hint, and the server may elect to use 1220 a different value. Note that the server will ignore requests to 1221 initialize the field to less than the default value. 1223 If the client wishes to later use the DONT-FRAGMENT attribute in one 1224 or more Send indications on this allocation, then the client SHOULD 1225 include the DONT-FRAGMENT attribute in the Allocate request. This 1226 allows the client to test whether this attribute is supported by the 1227 server. 1229 If the client requires the port number of the relayed transport 1230 address be even, the client includes the EVEN-PORT attribute. If 1231 this attribute is not included, then the port can be even or odd. By 1232 setting the R bit in the EVEN-PORT attribute to 1, the client can 1233 request that the server reserve the next highest port number (on the 1234 same IP address) for a subsequent allocation. If the R bit is 0, no 1235 such request is made. 1237 The client MAY also include a RESERVATION-TOKEN attribute in the 1238 request to ask the server to use a previously reserved port for the 1239 allocation. If the RESERVATION-TOKEN attribute is included, then the 1240 client MUST omit the EVEN-PORT attribute. 1242 Once constructed, the client sends the Allocate request on the 1243 5-tuple. 1245 7.2. Receiving an Allocate Request 1247 When the server receives an Allocate request, it performs the 1248 following checks: 1250 1. The server SHOULD require that the request be authenticated. 1251 The authentication of the request is optional to allow TURN 1252 servers provided by the local or access network to accept 1253 Allocation requests from new and/or guest users in the network 1254 who do not necessarily possess long term credentials for STUN 1255 authentication and its security implications are discussed in 1256 [RFC8155]. If the request is authenticated, the authentication 1257 MUST be done using the long-term credential mechanism of 1258 [I-D.ietf-tram-stunbis] unless the client and server agree to 1259 use another mechanism through some procedure outside the scope 1260 of this document. 1262 2. The server checks if the 5-tuple is currently in use by an 1263 existing allocation. If yes, the server rejects the request 1264 with a 437 (Allocation Mismatch) error. 1266 3. The server checks if the request contains a REQUESTED-TRANSPORT 1267 attribute. If the REQUESTED-TRANSPORT attribute is not included 1268 or is malformed, the server rejects the request with a 400 (Bad 1269 Request) error. Otherwise, if the attribute is included but 1270 specifies a protocol other that UDP, the server rejects the 1271 request with a 442 (Unsupported Transport Protocol) error. 1273 4. The request may contain a DONT-FRAGMENT attribute. If it does, 1274 but the server does not support sending UDP datagrams with the 1275 DF bit set to 1 (see Section 14), then the server treats the 1276 DONT-FRAGMENT attribute in the Allocate request as an unknown 1277 comprehension-required attribute. 1279 5. The server checks if the request contains a RESERVATION-TOKEN 1280 attribute. If yes, and the request also contains an EVEN-PORT 1281 or REQUESTED-ADDRESS-FAMILY or ADDITIONAL-ADDRESS-FAMILY 1282 attribute, the server rejects the request with a 400 (Bad 1283 Request) error. Otherwise, it checks to see if the token is 1284 valid (i.e., the token is in range and has not expired and the 1285 corresponding relayed transport address is still available). If 1286 the token is not valid for some reason, the server rejects the 1287 request with a 508 (Insufficient Capacity) error. 1289 6. The server checks if the request contains both REQUESTED- 1290 ADDRESS-FAMILY and ADDITIONAL-ADDRESS-FAMILY attributes. If 1291 yes, then the server rejects the request with a 400 (Bad 1292 Request) error. 1294 7. If the server does not support the address family requested by 1295 the client in REQUESTED-ADDRESS-FAMILY or is disabled by local 1296 policy, it MUST generate an Allocate error response, and it MUST 1297 include an ERROR-CODE attribute with the 440 (Address Family not 1298 Supported) response code. If the REQUESTED-ADDRESS-FAMILY 1299 attribute is absent and the server does not support IPv4 address 1300 family, the server MUST include an ERROR-CODE attribute with the 1301 440 (Address Family not Supported) response code. If the 1302 REQUESTED-ADDRESS-FAMILY attribute is absent and the server 1303 supports IPv4 address family, the server MUST allocate an IPv4 1304 relayed transport address for the TURN client. 1306 8. The server checks if the request contains an EVEN-PORT attribute 1307 with the R bit set to 1. If yes, and the request also contains 1308 an ADDITIONAL-ADDRESS-FAMILY attribute, the server rejects the 1309 request with a 400 (Bad Request) error. Otherwise, the server 1310 checks if it can satisfy the request (i.e., can allocate a 1311 relayed transport address as described below). If the server 1312 cannot satisfy the request, then the server rejects the request 1313 with a 508 (Insufficient Capacity) error. 1315 9. The server checks if the request contains an ADDITIONAL-ADDRESS- 1316 FAMILY attribute. If yes, and the attribute value is 0x01 (IPv4 1317 address family), then the server rejects the request with a 400 1318 (Bad Request) error. Otherwise, the server checks if it can 1319 allocate relayed transport addresses of both address types. If 1320 the server cannot satisfy the request, then the server rejects 1321 the request with a 508 (Insufficient Capacity) error. If the 1322 server can partially meet the request, i.e. if it can only 1323 allocate one relayed transport address of a specific address 1324 type, then it includes ADDRESS-ERROR-CODE attribute in the 1325 response to inform the client the reason for partial failure of 1326 the request. The error code value signaled in the ADDRESS- 1327 ERROR-CODE attribute could be 440 (Address Family not Supported) 1328 or 508 (Insufficient Capacity). If the server can fully meet 1329 the request, then the server allocates one IPv4 and one IPv6 1330 relay address, and returns an Allocate success response 1331 containing the relayed transport addresses assigned to the dual 1332 allocation in two XOR-RELAYED-ADDRESS attributes. 1334 10. At any point, the server MAY choose to reject the request with a 1335 486 (Allocation Quota Reached) error if it feels the client is 1336 trying to exceed some locally defined allocation quota. The 1337 server is free to define this allocation quota any way it 1338 wishes, but SHOULD define it based on the username used to 1339 authenticate the request, and not on the client's transport 1340 address. 1342 11. Also at any point, the server MAY choose to reject the request 1343 with a 300 (Try Alternate) error if it wishes to redirect the 1344 client to a different server. The use of this error code and 1345 attribute follow the specification in [I-D.ietf-tram-stunbis]. 1347 If all the checks pass, the server creates the allocation. The 1348 5-tuple is set to the 5-tuple from the Allocate request, while the 1349 list of permissions and the list of channels are initially empty. 1351 The server chooses a relayed transport address for the allocation as 1352 follows: 1354 o If the request contains a RESERVATION-TOKEN attribute, the server 1355 uses the previously reserved transport address corresponding to 1356 the included token (if it is still available). Note that the 1357 reservation is a server-wide reservation and is not specific to a 1358 particular allocation, since the Allocate request containing the 1359 RESERVATION-TOKEN uses a different 5-tuple than the Allocate 1360 request that made the reservation. The 5-tuple for the Allocate 1361 request containing the RESERVATION-TOKEN attribute can be any 1362 allowed 5-tuple; it can use a different client IP address and 1363 port, a different transport protocol, and even different server IP 1364 address and port (provided, of course, that the server IP address 1365 and port are ones on which the server is listening for TURN 1366 requests). 1368 o If the request contains an EVEN-PORT attribute with the R bit set 1369 to 0, then the server allocates a relayed transport address with 1370 an even port number. 1372 o If the request contains an EVEN-PORT attribute with the R bit set 1373 to 1, then the server looks for a pair of port numbers N and N+1 1374 on the same IP address, where N is even. Port N is used in the 1375 current allocation, while the relayed transport address with port 1376 N+1 is assigned a token and reserved for a future allocation. The 1377 server MUST hold this reservation for at least 30 seconds, and MAY 1378 choose to hold longer (e.g., until the allocation with port N 1379 expires). The server then includes the token in a RESERVATION- 1380 TOKEN attribute in the success response. 1382 o Otherwise, the server allocates any available relayed transport 1383 address. 1385 In all cases, the server SHOULD only allocate ports from the range 1386 49152 - 65535 (the Dynamic and/or Private Port range [Port-Numbers]), 1387 unless the TURN server application knows, through some means not 1388 specified here, that other applications running on the same host as 1389 the TURN server application will not be impacted by allocating ports 1390 outside this range. This condition can often be satisfied by running 1391 the TURN server application on a dedicated machine and/or by 1392 arranging that any other applications on the machine allocate ports 1393 before the TURN server application starts. In any case, the TURN 1394 server SHOULD NOT allocate ports in the range 0 - 1023 (the Well- 1395 Known Port range) to discourage clients from using TURN to run 1396 standard services. 1398 NOTE: The use of randomized port assignments to avoid certain 1399 types of attacks is described in [RFC6056]. It is RECOMMENDED 1400 that a TURN server implement a randomized port assignment 1401 algorithm from [RFC6056]. This is especially applicable to 1402 servers that choose to pre-allocate a number of ports from the 1403 underlying OS and then later assign them to allocations; for 1404 example, a server may choose this technique to implement the EVEN- 1405 PORT attribute. 1407 The server determines the initial value of the time-to-expiry field 1408 as follows. If the request contains a LIFETIME attribute, then the 1409 server computes the minimum of the client's proposed lifetime and the 1410 server's maximum allowed lifetime. If this computed value is greater 1411 than the default lifetime, then the server uses the computed lifetime 1412 as the initial value of the time-to-expiry field. Otherwise, the 1413 server uses the default lifetime. It is RECOMMENDED that the server 1414 use a maximum allowed lifetime value of no more than 3600 seconds (1 1415 hour). Servers that implement allocation quotas or charge users for 1416 allocations in some way may wish to use a smaller maximum allowed 1417 lifetime (perhaps as small as the default lifetime) to more quickly 1418 remove orphaned allocations (that is, allocations where the 1419 corresponding client has crashed or terminated or the client 1420 connection has been lost for some reason). Also, note that the time- 1421 to-expiry is recomputed with each successful Refresh request, and 1422 thus the value computed here applies only until the first refresh. 1424 Once the allocation is created, the server replies with a success 1425 response. The success response contains: 1427 o An XOR-RELAYED-ADDRESS attribute containing the relayed transport 1428 address. 1430 o A LIFETIME attribute containing the current value of the time-to- 1431 expiry timer. 1433 o A RESERVATION-TOKEN attribute (if a second relayed transport 1434 address was reserved). 1436 o An XOR-MAPPED-ADDRESS attribute containing the client's IP address 1437 and port (from the 5-tuple). 1439 NOTE: The XOR-MAPPED-ADDRESS attribute is included in the response 1440 as a convenience to the client. TURN itself does not make use of 1441 this value, but clients running ICE can often need this value and 1442 can thus avoid having to do an extra Binding transaction with some 1443 STUN server to learn it. 1445 The response (either success or error) is sent back to the client on 1446 the 5-tuple. 1448 NOTE: When the Allocate request is sent over UDP, 1449 [I-D.ietf-tram-stunbis] requires that the server handle the 1450 possible retransmissions of the request so that retransmissions do 1451 not cause multiple allocations to be created. Implementations may 1452 achieve this using the so-called "stateless stack approach" as 1453 follows. To detect retransmissions when the original request was 1454 successful in creating an allocation, the server can store the 1455 transaction id that created the request with the allocation data 1456 and compare it with incoming Allocate requests on the same 1457 5-tuple. Once such a request is detected, the server can stop 1458 parsing the request and immediately generate a success response. 1459 When building this response, the value of the LIFETIME attribute 1460 can be taken from the time-to-expiry field in the allocate state 1461 data, even though this value may differ slightly from the LIFETIME 1462 value originally returned. In addition, the server may need to 1463 store an indication of any reservation token returned in the 1464 original response, so that this may be returned in any 1465 retransmitted responses. 1467 For the case where the original request was unsuccessful in 1468 creating an allocation, the server may choose to do nothing 1469 special. Note, however, that there is a rare case where the 1470 server rejects the original request but accepts the retransmitted 1471 request (because conditions have changed in the brief intervening 1472 time period). If the client receives the first failure response, 1473 it will ignore the second (success) response and believe that an 1474 allocation was not created. An allocation created in this matter 1475 will eventually timeout, since the client will not refresh it. 1476 Furthermore, if the client later retries with the same 5-tuple but 1477 different transaction id, it will receive a 437 (Allocation 1478 Mismatch), which will cause it to retry with a different 5-tuple. 1479 The server may use a smaller maximum lifetime value to minimize 1480 the lifetime of allocations "orphaned" in this manner. 1482 7.3. Receiving an Allocate Success Response 1484 If the client receives an Allocate success response, then it MUST 1485 check that the mapped address and the relayed transport address or 1486 addresses are part of an address family or families that the client 1487 understands and is prepared to handle. If these addresses are not 1488 part of an address family or families which the client is prepared to 1489 handle, then the client MUST delete the allocation (Section 8) and 1490 MUST NOT attempt to create another allocation on that server until it 1491 believes the mismatch has been fixed. 1493 Otherwise, the client creates its own copy of the allocation data 1494 structure to track what is happening on the server. In particular, 1495 the client needs to remember the actual lifetime received back from 1496 the server, rather than the value sent to the server in the request. 1497 The client must also remember the 5-tuple used for the request and 1498 the username and password it used to authenticate the request to 1499 ensure that it reuses them for subsequent messages. The client also 1500 needs to track the channels and permissions it establishes on the 1501 server. 1503 If the client receives an Allocate success response but with ADDRESS- 1504 ERROR-CODE attribute in the response and the error code value 1505 signaled in the ADDRESS-ERROR-CODE attribute is 440 (Address Family 1506 not Supported), the client MUST NOT retry its request for the 1507 rejected address type. If the client receives an ADDRESS-ERROR-CODE 1508 attribute in the response and the error code value signaled in the 1509 ADDRESS-ERROR-CODE attribute is 508 (Insufficient Capacity), the 1510 client SHOULD wait at least 1 minute before trying to request any 1511 more allocations on this server for the rejected address type. 1513 The client will probably wish to send the relayed transport address 1514 to peers (using some method not specified here) so the peers can 1515 communicate with it. The client may also wish to use the server- 1516 reflexive address it receives in the XOR-MAPPED-ADDRESS attribute in 1517 its ICE processing. 1519 7.4. Receiving an Allocate Error Response 1521 If the client receives an Allocate error response, then the 1522 processing depends on the actual error code returned: 1524 o (Request timed out): There is either a problem with the server, or 1525 a problem reaching the server with the chosen transport. The 1526 client considers the current transaction as having failed but MAY 1527 choose to retry the Allocate request using a different transport 1528 (e.g., TCP instead of UDP). 1530 o 300 (Try Alternate): The server would like the client to use the 1531 server specified in the ALTERNATE-SERVER attribute instead. The 1532 client considers the current transaction as having failed, but 1533 SHOULD try the Allocate request with the alternate server before 1534 trying any other servers (e.g., other servers discovered using the 1535 DNS resolution procedures). When trying the Allocate request with 1536 the alternate server, the client follows the ALTERNATE-SERVER 1537 procedures specified in [I-D.ietf-tram-stunbis]. 1539 o 400 (Bad Request): The server believes the client's request is 1540 malformed for some reason. The client considers the current 1541 transaction as having failed. The client MAY notify the user or 1542 operator and SHOULD NOT retry the request with this server until 1543 it believes the problem has been fixed. 1545 o 401 (Unauthorized): If the client has followed the procedures of 1546 the long-term credential mechanism and still gets this error, then 1547 the server is not accepting the client's credentials. In this 1548 case, the client considers the current transaction as having 1549 failed and SHOULD notify the user or operator. The client SHOULD 1550 NOT send any further requests to this server until it believes the 1551 problem has been fixed. 1553 o 403 (Forbidden): The request is valid, but the server is refusing 1554 to perform it, likely due to administrative restrictions. The 1555 client considers the current transaction as having failed. The 1556 client MAY notify the user or operator and SHOULD NOT retry the 1557 same request with this server until it believes the problem has 1558 been fixed. 1560 o 420 (Unknown Attribute): If the client included a DONT-FRAGMENT 1561 attribute in the request and the server rejected the request with 1562 a 420 error code and listed the DONT-FRAGMENT attribute in the 1563 UNKNOWN-ATTRIBUTES attribute in the error response, then the 1564 client now knows that the server does not support the DONT- 1565 FRAGMENT attribute. The client considers the current transaction 1566 as having failed but MAY choose to retry the Allocate request 1567 without the DONT-FRAGMENT attribute. 1569 o 437 (Allocation Mismatch): This indicates that the client has 1570 picked a 5-tuple that the server sees as already in use. One way 1571 this could happen is if an intervening NAT assigned a mapped 1572 transport address that was used by another client that recently 1573 crashed. The client considers the current transaction as having 1574 failed. The client SHOULD pick another client transport address 1575 and retry the Allocate request (using a different transaction id). 1576 The client SHOULD try three different client transport addresses 1577 before giving up on this server. Once the client gives up on the 1578 server, it SHOULD NOT try to create another allocation on the 1579 server for 2 minutes. 1581 o 438 (Stale Nonce): See the procedures for the long-term credential 1582 mechanism [I-D.ietf-tram-stunbis]. 1584 o 440 (Address Family not Supported): The server does not support 1585 the address family requested by the client. If the client 1586 receives an Allocate error response with the 440 (Unsupported 1587 Address Family) error code, the client MUST NOT retry the request. 1589 o 441 (Wrong Credentials): The client should not receive this error 1590 in response to a Allocate request. The client MAY notify the user 1591 or operator and SHOULD NOT retry the same request with this server 1592 until it believes the problem has been fixed. 1594 o 442 (Unsupported Transport Address): The client should not receive 1595 this error in response to a request for a UDP allocation. The 1596 client MAY notify the user or operator and SHOULD NOT reattempt 1597 the request with this server until it believes the problem has 1598 been fixed. 1600 o 486 (Allocation Quota Reached): The server is currently unable to 1601 create any more allocations with this username. The client 1602 considers the current transaction as having failed. The client 1603 SHOULD wait at least 1 minute before trying to create any more 1604 allocations on the server. 1606 o 508 (Insufficient Capacity): The server has no more relayed 1607 transport addresses available, or has none with the requested 1608 properties, or the one that was reserved is no longer available. 1609 The client considers the current operation as having failed. If 1610 the client is using either the EVEN-PORT or the RESERVATION-TOKEN 1611 attribute, then the client MAY choose to remove or modify this 1612 attribute and try again immediately. Otherwise, the client SHOULD 1613 wait at least 1 minute before trying to create any more 1614 allocations on this server. 1616 An unknown error response MUST be handled as described in 1617 [I-D.ietf-tram-stunbis]. 1619 8. Refreshing an Allocation 1621 A Refresh transaction can be used to either (a) refresh an existing 1622 allocation and update its time-to-expiry or (b) delete an existing 1623 allocation. 1625 If a client wishes to continue using an allocation, then the client 1626 MUST refresh it before it expires. It is suggested that the client 1627 refresh the allocation roughly 1 minute before it expires. If a 1628 client no longer wishes to use an allocation, then it SHOULD 1629 explicitly delete the allocation. A client MAY refresh an allocation 1630 at any time for other reasons. 1632 8.1. Sending a Refresh Request 1634 If the client wishes to immediately delete an existing allocation, it 1635 includes a LIFETIME attribute with a value of 0. All other forms of 1636 the request refresh the allocation. 1638 When refreshing a dual allocation, the client includes REQUESTED- 1639 ADDRESS-FAMILY attribute indicating the address family type that 1640 should be refreshed. If no REQUESTED-ADDRESS-FAMILY is included then 1641 the request should be treated as applying to all current allocations. 1642 The client MUST only include family types it previously allocated and 1643 has not yet deleted. This process can also be used to delete an 1644 allocation of a specific address type, by setting the lifetime of 1645 that refresh request to 0. Deleting a single allocation destroys any 1646 permissions or channels associated with that particular allocation; 1647 it MUST NOT affect any permissions or channels associated with 1648 allocations for the other address family. 1650 The Refresh transaction updates the time-to-expiry timer of an 1651 allocation. If the client wishes the server to set the time-to- 1652 expiry timer to something other than the default lifetime, it 1653 includes a LIFETIME attribute with the requested value. The server 1654 then computes a new time-to-expiry value in the same way as it does 1655 for an Allocate transaction, with the exception that a requested 1656 lifetime of 0 causes the server to immediately delete the allocation. 1658 8.2. Receiving a Refresh Request 1660 When the server receives a Refresh request, it processes the request 1661 as per Section 5 plus the specific rules mentioned here. 1663 If the server receives a Refresh Request with a REQUESTED-ADDRESS- 1664 FAMILY attribute and the attribute value does not match the address 1665 family of the allocation, the server MUST reply with a 443 (Peer 1666 Address Family Mismatch) Refresh error response. 1668 The server computes a value called the "desired lifetime" as follows: 1669 if the request contains a LIFETIME attribute and the attribute value 1670 is 0, then the "desired lifetime" is 0. Otherwise, if the request 1671 contains a LIFETIME attribute, then the server computes the minimum 1672 of the client's requested lifetime and the server's maximum allowed 1673 lifetime. If this computed value is greater than the default 1674 lifetime, then the "desired lifetime" is the computed value. 1675 Otherwise, the "desired lifetime" is the default lifetime. 1677 Subsequent processing depends on the "desired lifetime" value: 1679 o If the "desired lifetime" is 0, then the request succeeds and the 1680 allocation is deleted. 1682 o If the "desired lifetime" is non-zero, then the request succeeds 1683 and the allocation's time-to-expiry is set to the "desired 1684 lifetime". 1686 If the request succeeds, then the server sends a success response 1687 containing: 1689 o A LIFETIME attribute containing the current value of the time-to- 1690 expiry timer. 1692 NOTE: A server need not do anything special to implement 1693 idempotency of Refresh requests over UDP using the "stateless 1694 stack approach". Retransmitted Refresh requests with a non-zero 1695 "desired lifetime" will simply refresh the allocation. A 1696 retransmitted Refresh request with a zero "desired lifetime" will 1697 cause a 437 (Allocation Mismatch) response if the allocation has 1698 already been deleted, but the client will treat this as equivalent 1699 to a success response (see below). 1701 8.3. Receiving a Refresh Response 1703 If the client receives a success response to its Refresh request with 1704 a non-zero lifetime, it updates its copy of the allocation data 1705 structure with the time-to-expiry value contained in the response. 1707 If the client receives a 437 (Allocation Mismatch) error response to 1708 a request to delete the allocation, then the allocation no longer 1709 exists and it should consider its request as having effectively 1710 succeeded. 1712 9. Permissions 1714 For each allocation, the server keeps a list of zero or more 1715 permissions. Each permission consists of an IP address and an 1716 associated time-to-expiry. While a permission exists, all peers 1717 using the IP address in the permission are allowed to send data to 1718 the client. The time-to-expiry is the number of seconds until the 1719 permission expires. Within the context of an allocation, a 1720 permission is uniquely identified by its associated IP address. 1722 By sending either CreatePermission requests or ChannelBind requests, 1723 the client can cause the server to install or refresh a permission 1724 for a given IP address. This causes one of two things to happen: 1726 o If no permission for that IP address exists, then a permission is 1727 created with the given IP address and a time-to-expiry equal to 1728 Permission Lifetime. 1730 o If a permission for that IP address already exists, then the time- 1731 to-expiry for that permission is reset to Permission Lifetime. 1733 The Permission Lifetime MUST be 300 seconds (= 5 minutes). 1735 Each permission's time-to-expiry decreases down once per second until 1736 it reaches 0; at which point, the permission expires and is deleted. 1738 CreatePermission and ChannelBind requests may be freely intermixed on 1739 a permission. A given permission may be initially installed and/or 1740 refreshed with a CreatePermission request, and then later refreshed 1741 with a ChannelBind request, or vice versa. 1743 A TURN server MUST have a configuration knob to allow inbound STUN 1744 packets on the allocation's relayed address even if the source IP 1745 addresses of the STUN packets do not match the permissions installed. 1746 This configuration knob MUST default to drop the inbound STUN packets 1747 on the allocation's relayed address if the source IP addresses of the 1748 STUN packets do not match the permissions installed unless explicitly 1749 configured to do otherwise. The default configuration to drop 1750 inbound packets not matching the permissions installed resembles 1751 firewall default behavior to block unsolicited inbound traffic. 1753 When a UDP datagram arrives at the relayed transport address for the 1754 allocation, the server extracts the source IP address from the IP 1755 header. The server then compares this address with the IP address 1756 associated with each permission in the list of permissions for the 1757 allocation. Note that only addresses are compared and port numbers 1758 are not considered. If no match is found and the received datagram 1759 is not a STUN packet, the permission check is considered to have 1760 failed. If an exact match is found, the permission check is 1761 considered to have succeeded. If no match is found and the received 1762 datagram is a STUN packet and the server is configured to allow STUN 1763 packets without explicit permission, the permission check is 1764 considered to have succeeded. If no match is found and the received 1765 datagram is a STUN packet and the server is not configured to allow 1766 STUN packets without explicit permission, the permission check is 1767 considered to have failed. If the permission check fails, relaying 1768 is not permitted and the server silently discards the UDP datagram. 1769 If the permission check succeeds, the services continues to process 1770 the UDP datagram as specified elsewhere (Section 11.3). 1772 The permissions for one allocation are totally unrelated to the 1773 permissions for a different allocation. If an allocation expires, 1774 all its permissions expire with it. 1776 NOTE: Though TURN permissions expire after 5 minutes, many NATs 1777 deployed at the time of publication expire their UDP bindings 1778 considerably faster. Thus, an application using TURN will 1779 probably wish to send some sort of keep-alive traffic at a much 1780 faster rate. Applications using ICE should follow the keep-alive 1781 guidelines of ICE [RFC5245], and applications not using ICE are 1782 advised to do something similar. 1784 10. CreatePermission 1786 TURN supports two ways for the client to install or refresh 1787 permissions on the server. This section describes one way: the 1788 CreatePermission request. 1790 A CreatePermission request may be used in conjunction with either the 1791 Send mechanism in Section 11 or the Channel mechanism in Section 12. 1793 10.1. Forming a CreatePermission Request 1795 The client who wishes to install or refresh one or more permissions 1796 can send a CreatePermission request to the server. 1798 When forming a CreatePermission request, the client MUST include at 1799 least one XOR-PEER-ADDRESS attribute, and MAY include more than one 1800 such attribute. The IP address portion of each XOR-PEER-ADDRESS 1801 attribute contains the IP address for which a permission should be 1802 installed or refreshed. The port portion of each XOR-PEER-ADDRESS 1803 attribute will be ignored and can be any arbitrary value. The 1804 various XOR-PEER-ADDRESS attributes MAY appear in any order. The 1805 client MUST only include XOR-PEER-ADDRESS attributes with addresses 1806 of the same address family as that of the relayed transport address 1807 for the allocation. For dual allocations obtained using the 1808 ADDITIONAL-ADDRESS-FAMILY attribute, the client MAY include XOR-PEER- 1809 ADDRESS attributes with addresses of IPv4 and IPv6 address families. 1811 10.2. Receiving a CreatePermission Request 1813 When the server receives the CreatePermission request, it processes 1814 as per Section 5 plus the specific rules mentioned here. 1816 The message is checked for validity. The CreatePermission request 1817 MUST contain at least one XOR-PEER-ADDRESS attribute and MAY contain 1818 multiple such attributes. If no such attribute exists, or if any of 1819 these attributes are invalid, then a 400 (Bad Request) error is 1820 returned. If the request is valid, but the server is unable to 1821 satisfy the request due to some capacity limit or similar, then a 508 1822 (Insufficient Capacity) error is returned. 1824 If an XOR-PEER-ADDRESS attribute contains an address of an address 1825 family that is not the same as that of a relayed transport address 1826 for the allocation, the server MUST generate an error response with 1827 the 443 (Peer Address Family Mismatch) response code. 1829 The server MAY impose restrictions on the IP address allowed in the 1830 XOR-PEER-ADDRESS attribute -- if a value is not allowed, the server 1831 rejects the request with a 403 (Forbidden) error. 1833 If the message is valid and the server is capable of carrying out the 1834 request, then the server installs or refreshes a permission for the 1835 IP address contained in each XOR-PEER-ADDRESS attribute as described 1836 in Section 9. The port portion of each attribute is ignored and may 1837 be any arbitrary value. 1839 The server then responds with a CreatePermission success response. 1840 There are no mandatory attributes in the success response. 1842 NOTE: A server need not do anything special to implement 1843 idempotency of CreatePermission requests over UDP using the 1844 "stateless stack approach". Retransmitted CreatePermission 1845 requests will simply refresh the permissions. 1847 10.3. Receiving a CreatePermission Response 1849 If the client receives a valid CreatePermission success response, 1850 then the client updates its data structures to indicate that the 1851 permissions have been installed or refreshed. 1853 11. Send and Data Methods 1855 TURN supports two mechanisms for sending and receiving data from 1856 peers. This section describes the use of the Send and Data 1857 mechanisms, while Section 12 describes the use of the Channel 1858 mechanism. 1860 11.1. Forming a Send Indication 1862 The client can use a Send indication to pass data to the server for 1863 relaying to a peer. A client may use a Send indication even if a 1864 channel is bound to that peer. However, the client MUST ensure that 1865 there is a permission installed for the IP address of the peer to 1866 which the Send indication is being sent; this prevents a third party 1867 from using a TURN server to send data to arbitrary destinations. 1869 When forming a Send indication, the client MUST include an XOR-PEER- 1870 ADDRESS attribute and a DATA attribute. The XOR-PEER-ADDRESS 1871 attribute contains the transport address of the peer to which the 1872 data is to be sent, and the DATA attribute contains the actual 1873 application data to be sent to the peer. 1875 The client MAY include a DONT-FRAGMENT attribute in the Send 1876 indication if it wishes the server to set the DF bit on the UDP 1877 datagram sent to the peer. 1879 11.2. Receiving a Send Indication 1881 When the server receives a Send indication, it processes as per 1882 Section 5 plus the specific rules mentioned here. 1884 The message is first checked for validity. The Send indication MUST 1885 contain both an XOR-PEER-ADDRESS attribute and a DATA attribute. If 1886 one of these attributes is missing or invalid, then the message is 1887 discarded. Note that the DATA attribute is allowed to contain zero 1888 bytes of data. 1890 The Send indication may also contain the DONT-FRAGMENT attribute. If 1891 the server is unable to set the DF bit on outgoing UDP datagrams when 1892 this attribute is present, then the server acts as if the DONT- 1893 FRAGMENT attribute is an unknown comprehension-required attribute 1894 (and thus the Send indication is discarded). 1896 The server also checks that there is a permission installed for the 1897 IP address contained in the XOR-PEER-ADDRESS attribute. If no such 1898 permission exists, the message is discarded. Note that a Send 1899 indication never causes the server to refresh the permission. 1901 The server MAY impose restrictions on the IP address and port values 1902 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 1903 allowed, the server silently discards the Send indication. 1905 If everything is OK, then the server forms a UDP datagram as follows: 1907 o the source transport address is the relayed transport address of 1908 the allocation, where the allocation is determined by the 5-tuple 1909 on which the Send indication arrived; 1911 o the destination transport address is taken from the XOR-PEER- 1912 ADDRESS attribute; 1914 o the data following the UDP header is the contents of the value 1915 field of the DATA attribute. 1917 The handling of the DONT-FRAGMENT attribute (if present), is 1918 described in Section 14. 1920 The resulting UDP datagram is then sent to the peer. 1922 11.3. Receiving a UDP Datagram 1924 When the server receives a UDP datagram at a currently allocated 1925 relayed transport address, the server looks up the allocation 1926 associated with the relayed transport address. The server then 1927 checks to see whether the set of permissions for the allocation allow 1928 the relaying of the UDP datagram as described in Section 9. 1930 If relaying is permitted, then the server checks if there is a 1931 channel bound to the peer that sent the UDP datagram (see 1932 Section 12). If a channel is bound, then processing proceeds as 1933 described in Section 12.7. 1935 If relaying is permitted but no channel is bound to the peer, then 1936 the server forms and sends a Data indication. The Data indication 1937 MUST contain both an XOR-PEER-ADDRESS and a DATA attribute. The DATA 1938 attribute is set to the value of the 'data octets' field from the 1939 datagram, and the XOR-PEER-ADDRESS attribute is set to the source 1940 transport address of the received UDP datagram. The Data indication 1941 is then sent on the 5-tuple associated with the allocation. 1943 11.4. Receiving a Data Indication 1945 When the client receives a Data indication, it checks that the Data 1946 indication contains an XOR-PEER-ADDRESS attribute, and discards the 1947 indication if it does not. The client SHOULD also check that the 1948 XOR-PEER-ADDRESS attribute value contains an IP address with which 1949 the client believes there is an active permission, and discard the 1950 Data indication otherwise. 1952 NOTE: The latter check protects the client against an attacker who 1953 somehow manages to trick the server into installing permissions 1954 not desired by the client. 1956 If the XOR-PEER-ADDRESS is present and valid, the client checks that 1957 the Data indication contains either a DATA attribute or an ICMP 1958 attribute and discards the indication if it does not. Note that a 1959 DATA attribute is allowed to contain zero bytes of data. Processing 1960 of Data indications with an ICMP attribute is described in 1961 Section 11.6. 1963 If the Data indication passes the above checks, the client delivers 1964 the data octets inside the DATA attribute to the application, along 1965 with an indication that they were received from the peer whose 1966 transport address is given by the XOR-PEER-ADDRESS attribute. 1968 11.5. Receiving an ICMP Packet 1970 When the server receives an ICMP packet, the server verifies that the 1971 type is either 3, 11 or 12 for an ICMPv4 [RFC0792] packet or either 1972 1, 2, or 3 for an ICMPv6 [RFC4443] packet. It also verifies that the 1973 IP packet in the ICMP packet payload contains a UDP header. If 1974 either of these conditions fail, then the ICMP packet is silently 1975 dropped. 1977 The server looks up the allocation whose relayed transport address 1978 corresponds to the encapsulated packet's source IP address and UDP 1979 port. If no such allocation exists, the packet is silently dropped. 1980 The server then checks to see whether the set of permissions for the 1981 allocation allows the relaying of the ICMP packet. For ICMP packets, 1982 the source IP address MUST NOT be checked against the permissions 1983 list as it would be for UDP packets. Instead, the server extracts 1984 the destination IP address from the encapsulated IP header. The 1985 server then compares this address with the IP address associated with 1986 each permission in the list of permissions for the allocation. If no 1987 match is found, relaying is not permitted, and the server silently 1988 discards the ICMP packet. Note that only addresses are compared and 1989 port numbers are not considered. 1991 If relaying is permitted then the server forms and sends a Data 1992 indication. The Data indication MUST contain both an XOR-PEER- 1993 ADDRESS and an ICMP attribute. The ICMP attribute is set to the 1994 value of the type and code fields from the ICMP packet. The IP 1995 address portion of XOR-PEER-ADDRESS attribute is set to the 1996 destination IP address in the encapsulated IP header. At the time of 1997 writing of this specification, Socket APIs on some operating systems 1998 do not deliver the destination port in the encapsulated UDP header to 1999 applications without superuser privileges. If destination port in 2000 the encapsulated UDP header is available to the server then the port 2001 portion of XOR-PEER-ADDRESS attribute is set to the destination port 2002 otherwise the port portion is set to 0. The Data indication is then 2003 sent on the 5-tuple associated with the allocation. 2005 11.6. Receiving a Data Indication with an ICMP attribute 2007 When the client receives a Data indication with an ICMP attribute, it 2008 checks that the Data indication contains an XOR-PEER-ADDRESS 2009 attribute, and discards the indication if it does not. The client 2010 SHOULD also check that the XOR-PEER-ADDRESS attribute value contains 2011 an IP address with an active permission, and discard the Data 2012 indication otherwise. 2014 If the Data indication passes the above checks, the client signals 2015 the application of the error condition, along with an indication that 2016 it was received from the peer whose transport address is given by the 2017 XOR-PEER-ADDRESS attribute. The application can make sense of the 2018 meaning of the type and code values in the ICMP attribute by using 2019 the family field in the XOR-PEER-ADDRESS attribute. 2021 12. Channels 2023 Channels provide a way for the client and server to send application 2024 data using ChannelData messages, which have less overhead than Send 2025 and Data indications. 2027 The ChannelData message (see Section 12.4) starts with a two-byte 2028 field that carries the channel number. The values of this field are 2029 allocated as follows: 2031 0x0000 through 0x3FFF: These values can never be used for channel 2032 numbers. 2034 0x4000 through 0x4FFF: These values are the allowed channel 2035 numbers (4096 possible values). 2037 0x5000-0xFFFF: Reserved (For DTLS-SRTP multiplexing collision 2038 avoidance, see [RFC7983]. 2040 According to [RFC7983], ChannelData messages can be distinguished 2041 from other multiplexed protocols by examining the first byte of the 2042 message: 2044 +------------+------------------------------+ 2045 | [0..3] | STUN | 2046 | | | 2047 +-------------------------------------------+ 2048 | [16..19] | ZRTP | 2049 | | | 2050 +-------------------------------------------+ 2051 | [20..63] | DTLS | 2052 | | | 2053 +-------------------------------------------+ 2054 | [64..79] | TURN Channel | 2055 | | | 2056 +-------------------------------------------+ 2057 | [128..191] | RTP/RTCP | 2058 | | | 2059 +-------------------------------------------+ 2060 | Others | Reserved, MUST be dropped | 2061 | | and an alert MAY be logged | 2062 +-------------------------------------------+ 2064 Reserved values may be used in the future by other protocols. When 2065 the client uses channel binding, it MUST comply with the 2066 demultiplexing scheme discussed above. 2068 Channel bindings are always initiated by the client. The client can 2069 bind a channel to a peer at any time during the lifetime of the 2070 allocation. The client may bind a channel to a peer before 2071 exchanging data with it, or after exchanging data with it (using Send 2072 and Data indications) for some time, or may choose never to bind a 2073 channel to it. The client can also bind channels to some peers while 2074 not binding channels to other peers. 2076 Channel bindings are specific to an allocation, so that the use of a 2077 channel number or peer transport address in a channel binding in one 2078 allocation has no impact on their use in a different allocation. If 2079 an allocation expires, all its channel bindings expire with it. 2081 A channel binding consists of: 2083 o a channel number; 2085 o a transport address (of the peer); and 2087 o A time-to-expiry timer. 2089 Within the context of an allocation, a channel binding is uniquely 2090 identified either by the channel number or by the peer's transport 2091 address. Thus, the same channel cannot be bound to two different 2092 transport addresses, nor can the same transport address be bound to 2093 two different channels. 2095 A channel binding lasts for 10 minutes unless refreshed. Refreshing 2096 the binding (by the server receiving a ChannelBind request rebinding 2097 the channel to the same peer) resets the time-to-expiry timer back to 2098 10 minutes. 2100 When the channel binding expires, the channel becomes unbound. Once 2101 unbound, the channel number can be bound to a different transport 2102 address, and the transport address can be bound to a different 2103 channel number. To prevent race conditions, the client MUST wait 5 2104 minutes after the channel binding expires before attempting to bind 2105 the channel number to a different transport address or the transport 2106 address to a different channel number. 2108 When binding a channel to a peer, the client SHOULD be prepared to 2109 receive ChannelData messages on the channel from the server as soon 2110 as it has sent the ChannelBind request. Over UDP, it is possible for 2111 the client to receive ChannelData messages from the server before it 2112 receives a ChannelBind success response. 2114 In the other direction, the client MAY elect to send ChannelData 2115 messages before receiving the ChannelBind success response. Doing 2116 so, however, runs the risk of having the ChannelData messages dropped 2117 by the server if the ChannelBind request does not succeed for some 2118 reason (e.g., packet lost if the request is sent over UDP, or the 2119 server being unable to fulfill the request). A client that wishes to 2120 be safe should either queue the data or use Send indications until 2121 the channel binding is confirmed. 2123 12.1. Sending a ChannelBind Request 2125 A channel binding is created or refreshed using a ChannelBind 2126 transaction. A ChannelBind transaction also creates or refreshes a 2127 permission towards the peer (see Section 9). 2129 To initiate the ChannelBind transaction, the client forms a 2130 ChannelBind request. The channel to be bound is specified in a 2131 CHANNEL-NUMBER attribute, and the peer's transport address is 2132 specified in an XOR-PEER-ADDRESS attribute. Section 12.2 describes 2133 the restrictions on these attributes. The client MUST only include 2134 an XOR-PEER-ADDRESS attribute with an address of the same address 2135 family as that of a relayed transport address for the allocation. 2137 Rebinding a channel to the same transport address that it is already 2138 bound to provides a way to refresh a channel binding and the 2139 corresponding permission without sending data to the peer. Note 2140 however, that permissions need to be refreshed more frequently than 2141 channels. 2143 12.2. Receiving a ChannelBind Request 2145 When the server receives a ChannelBind request, it processes as per 2146 Section 5 plus the specific rules mentioned here. 2148 The server checks the following: 2150 o The request contains both a CHANNEL-NUMBER and an XOR-PEER-ADDRESS 2151 attribute; 2153 o The channel number is in the range 0x4000 through 0x4FFF 2154 (inclusive); 2156 o The channel number is not currently bound to a different transport 2157 address (same transport address is OK); 2159 o The transport address is not currently bound to a different 2160 channel number. 2162 o If the XOR-PEER-ADDRESS attribute contains an address of an 2163 address family that is not the same as that of a relayed transport 2164 address for the allocation, the server MUST generate an error 2165 response with the 443 (Peer Address Family Mismatch) response 2166 code. 2168 If any of these tests fail, the server replies with a 400 (Bad 2169 Request) error. 2171 The server MAY impose restrictions on the IP address and port values 2172 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 2173 allowed, the server rejects the request with a 403 (Forbidden) error. 2175 If the request is valid, but the server is unable to fulfill the 2176 request due to some capacity limit or similar, the server replies 2177 with a 508 (Insufficient Capacity) error. 2179 Otherwise, the server replies with a ChannelBind success response. 2180 There are no required attributes in a successful ChannelBind 2181 response. 2183 If the server can satisfy the request, then the server creates or 2184 refreshes the channel binding using the channel number in the 2185 CHANNEL-NUMBER attribute and the transport address in the XOR-PEER- 2186 ADDRESS attribute. The server also installs or refreshes a 2187 permission for the IP address in the XOR-PEER-ADDRESS attribute as 2188 described in Section 9. 2190 NOTE: A server need not do anything special to implement 2191 idempotency of ChannelBind requests over UDP using the "stateless 2192 stack approach". Retransmitted ChannelBind requests will simply 2193 refresh the channel binding and the corresponding permission. 2194 Furthermore, the client must wait 5 minutes before binding a 2195 previously bound channel number or peer address to a different 2196 channel, eliminating the possibility that the transaction would 2197 initially fail but succeed on a retransmission. 2199 12.3. Receiving a ChannelBind Response 2201 When the client receives a ChannelBind success response, it updates 2202 its data structures to record that the channel binding is now active. 2203 It also updates its data structures to record that the corresponding 2204 permission has been installed or refreshed. 2206 If the client receives a ChannelBind failure response that indicates 2207 that the channel information is out-of-sync between the client and 2208 the server (e.g., an unexpected 400 "Bad Request" response), then it 2209 is RECOMMENDED that the client immediately delete the allocation and 2210 start afresh with a new allocation. 2212 12.4. The ChannelData Message 2214 The ChannelData message is used to carry application data between the 2215 client and the server. It has the following format: 2217 0 1 2 3 2218 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 2219 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2220 | Channel Number | Length | 2221 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2222 | | 2223 / Application Data / 2224 / / 2225 | | 2226 | +-------------------------------+ 2227 | | 2228 +-------------------------------+ 2230 The Channel Number field specifies the number of the channel on which 2231 the data is traveling, and thus the address of the peer that is 2232 sending or is to receive the data. 2234 The Length field specifies the length in bytes of the application 2235 data field (i.e., it does not include the size of the ChannelData 2236 header). Note that 0 is a valid length. 2238 The Application Data field carries the data the client is trying to 2239 send to the peer, or that the peer is sending to the client. 2241 12.5. Sending a ChannelData Message 2243 Once a client has bound a channel to a peer, then when the client has 2244 data to send to that peer it may use either a ChannelData message or 2245 a Send indication; that is, the client is not obligated to use the 2246 channel when it exists and may freely intermix the two message types 2247 when sending data to the peer. The server, on the other hand, MUST 2248 use the ChannelData message if a channel has been bound to the peer. 2249 The server uses a Data indication to signal the XOR-PEER-ADDRESS and 2250 ICMP attributes to the client even if a channel has been bound to the 2251 peer. 2253 The fields of the ChannelData message are filled in as described in 2254 Section 12.4. 2256 Over TCP and TLS-over-TCP, the ChannelData message MUST be padded to 2257 a multiple of four bytes in order to ensure the alignment of 2258 subsequent messages. The padding is not reflected in the length 2259 field of the ChannelData message, so the actual size of a ChannelData 2260 message (including padding) is (4 + Length) rounded up to the nearest 2261 multiple of 4. Over UDP, the padding is not required but MAY be 2262 included. 2264 The ChannelData message is then sent on the 5-tuple associated with 2265 the allocation. 2267 12.6. Receiving a ChannelData Message 2269 The receiver of the ChannelData message uses the first byte to 2270 distinguish it from other multiplexed protocols, as described above. 2271 If the message uses a value in the reserved range (0x5000 through 2272 0xFFFF), then the message is silently discarded. 2274 If the ChannelData message is received in a UDP datagram, and if the 2275 UDP datagram is too short to contain the claimed length of the 2276 ChannelData message (i.e., the UDP header length field value is less 2277 than the ChannelData header length field value + 4 + 8), then the 2278 message is silently discarded. 2280 If the ChannelData message is received over TCP or over TLS-over-TCP, 2281 then the actual length of the ChannelData message is as described in 2282 Section 12.5. 2284 If the ChannelData message is received on a channel that is not bound 2285 to any peer, then the message is silently discarded. 2287 On the client, it is RECOMMENDED that the client discard the 2288 ChannelData message if the client believes there is no active 2289 permission towards the peer. On the server, the receipt of a 2290 ChannelData message MUST NOT refresh either the channel binding or 2291 the permission towards the peer. 2293 On the server, if no errors are detected, the server relays the 2294 application data to the peer by forming a UDP datagram as follows: 2296 o the source transport address is the relayed transport address of 2297 the allocation, where the allocation is determined by the 5-tuple 2298 on which the ChannelData message arrived; 2300 o the destination transport address is the transport address to 2301 which the channel is bound; 2303 o the data following the UDP header is the contents of the data 2304 field of the ChannelData message. 2306 The resulting UDP datagram is then sent to the peer. Note that if 2307 the Length field in the ChannelData message is 0, then there will be 2308 no data in the UDP datagram, but the UDP datagram is still formed and 2309 sent. 2311 12.7. Relaying Data from the Peer 2313 When the server receives a UDP datagram on the relayed transport 2314 address associated with an allocation, the server processes it as 2315 described in Section 11.3. If that section indicates that a 2316 ChannelData message should be sent (because there is a channel bound 2317 to the peer that sent to the UDP datagram), then the server forms and 2318 sends a ChannelData message as described in Section 12.5. 2320 When the server receives an ICMP packet, the server processes it as 2321 described in Section 11.5. A Data indication MUST be sent regardless 2322 of whether there is a channel bound to the peer that was the 2323 destination of the UDP datagram that triggered the reception of the 2324 ICMP packet. 2326 13. Packet Translations 2328 This section addresses IPv4-to-IPv6, IPv6-to-IPv4, and IPv6-to-IPv6 2329 translations. Requirements for translation of the IP addresses and 2330 port numbers of the packets are described above. The following 2331 sections specify how to translate other header fields. 2333 As discussed in Section 2.6, translations in TURN are designed so 2334 that a TURN server can be implemented as an application that runs in 2335 userland under commonly available operating systems and that does not 2336 require special privileges. The translations specified in the 2337 following sections follow this principle. 2339 The descriptions below have two parts: a preferred behavior and an 2340 alternate behavior. The server SHOULD implement the preferred 2341 behavior. Otherwise, the server MUST implement the alternate 2342 behavior and MUST NOT do anything else for the reasons detailed in 2343 [RFC7915]. 2345 13.1. IPv4-to-IPv6 Translations 2347 Traffic Class 2349 Preferred behavior: As specified in Section 4 of [RFC7915]. 2351 Alternate behavior: The relay sets the Traffic Class to the 2352 default value for outgoing packets. 2354 Flow Label 2356 Preferred behavior: The relay sets the Flow label to 0. The relay 2357 can choose to set the Flow label to a different value if it 2358 supports the IPv6 Flow Label field [RFC6437]. 2360 Alternate behavior: The relay sets the Flow label to the default 2361 value for outgoing packets. 2363 Hop Limit 2365 Preferred behavior: As specified in Section 4 of [RFC7915]. 2367 Alternate behavior: The relay sets the Hop Limit to the default 2368 value for outgoing packets. 2370 Fragmentation 2372 Preferred behavior: As specified in Section 4 of [RFC7915]. 2374 Alternate behavior: The relay assembles incoming fragments. The 2375 relay follows its default behavior to send outgoing packets. 2377 For both preferred and alternate behavior, the DONT-FRAGMENT 2378 attribute MUST be ignored by the server. 2380 Extension Headers 2382 Preferred behavior: The relay sends outgoing packet without any 2383 IPv6 extension headers, with the exception of the Fragmentation 2384 header as described above. 2386 Alternate behavior: Same as preferred. 2388 13.2. IPv6-to-IPv6 Translations 2390 Flow Label 2392 The relay should consider that it is handling two different IPv6 2393 flows. Therefore, the Flow label [RFC6437] SHOULD NOT be copied as 2394 part of the translation. 2396 Preferred behavior: The relay sets the Flow label to 0. The relay 2397 can choose to set the Flow label to a different value if it 2398 supports the IPv6 Flow Label field [RFC6437]. 2400 Alternate behavior: The relay sets the Flow label to the default 2401 value for outgoing packets. 2403 Hop Limit 2405 Preferred behavior: The relay acts as a regular router with 2406 respect to decrementing the Hop Limit and generating an ICMPv6 2407 error if it reaches zero. 2409 Alternate behavior: The relay sets the Hop Limit to the default 2410 value for outgoing packets. 2412 Fragmentation 2414 Preferred behavior: If the incoming packet did not include a 2415 Fragment header and the outgoing packet size does not exceed the 2416 outgoing link's MTU, the relay sends the outgoing packet without a 2417 Fragment header. 2419 If the incoming packet did not include a Fragment header and the 2420 outgoing packet size exceeds the outgoing link's MTU, the relay 2421 drops the outgoing packet and send an ICMP message of type 2 code 2422 0 ("Packet too big") to the sender of the incoming packet. If 2423 the packet is being sent to the peer, the relay reduces the MTU 2424 reported in the ICMP message by 48 bytes to allow room for the 2425 overhead of a Data indication. 2427 If the incoming packet included a Fragment header and the outgoing 2428 packet size (with a Fragment header included) does not exceed the 2429 outgoing link's MTU, the relay sends the outgoing packet with a 2430 Fragment header. The relay sets the fields of the Fragment header 2431 as appropriate for a packet originating from the server. 2433 If the incoming packet included a Fragment header and the outgoing 2434 packet size exceeds the outgoing link's MTU, the relay MUST 2435 fragment the outgoing packet into fragments of no more than 1280 2436 bytes. The relay sets the fields of the Fragment header as 2437 appropriate for a packet originating from the server. 2439 Alternate behavior: The relay assembles incoming fragments. The 2440 relay follows its default behavior to send outgoing packets. 2442 For both preferred and alternate behavior, the DONT-FRAGMENT 2443 attribute MUST be ignored by the server. 2445 Extension Headers 2447 Preferred behavior: The relay sends outgoing packet without any 2448 IPv6 extension headers, with the exception of the Fragmentation 2449 header as described above. 2451 Alternate behavior: Same as preferred. 2453 13.3. IPv6-to-IPv4 Translations 2455 Type of Service and Precedence 2457 Preferred behavior: As specified in Section 5 of [RFC7915]. 2459 Alternate behavior: The relay sets the Type of Service and 2460 Precedence to the default value for outgoing packets. 2462 Time to Live 2464 Preferred behavior: As specified in Section 5 of [RFC7915]. 2466 Alternate behavior: The relay sets the Time to Live to the default 2467 value for outgoing packets. 2469 Fragmentation 2471 Preferred behavior: As specified in Section 5 of [RFC7915]. 2472 Additionally, when the outgoing packet's size exceeds the outgoing 2473 link's MTU, the relay needs to generate an ICMP error (ICMPv6 2474 Packet Too Big) reporting the MTU size. If the packet is being 2475 sent to the peer, the relay SHOULD reduce the MTU reported in the 2476 ICMP message by 48 bytes to allow room for the overhead of a Data 2477 indication. 2479 Alternate behavior: The relay assembles incoming fragments. The 2480 relay follows its default behavior to send outgoing packets. 2482 For both preferred and alternate behavior, the DONT-FRAGMENT 2483 attribute MUST be ignored by the server. 2485 14. IP Header Fields 2487 This section describes how the server sets various fields in the IP 2488 header when relaying between the client and the peer or vice versa. 2489 The descriptions in this section apply: (a) when the server sends a 2490 UDP datagram to the peer, or (b) when the server sends a Data 2491 indication or ChannelData message to the client over UDP transport. 2492 The descriptions in this section do not apply to TURN messages sent 2493 over TCP or TLS transport from the server to the client. 2495 The descriptions below have two parts: a preferred behavior and an 2496 alternate behavior. The server SHOULD implement the preferred 2497 behavior, but if that is not possible for a particular field, then it 2498 SHOULD implement the alternative behavior. 2500 Time to Live (TTL) field 2501 Preferred Behavior: If the incoming value is 0, then the drop the 2502 incoming packet. Otherwise, set the outgoing Time to Live/Hop 2503 Count to one less than the incoming value. 2505 Alternate Behavior: Set the outgoing value to the default for 2506 outgoing packets. 2508 Differentiated Services Code Point (DSCP) field [RFC2474] 2510 Preferred Behavior: Set the outgoing value to the incoming value, 2511 unless the server includes a differentiated services classifier 2512 and marker [RFC2474]. 2514 Alternate Behavior: Set the outgoing value to a fixed value, which 2515 by default is Best Effort unless configured otherwise. 2517 In both cases, if the server is immediately adjacent to a 2518 differentiated services classifier and marker, then DSCP MAY be 2519 set to any arbitrary value in the direction towards the 2520 classifier. 2522 Explicit Congestion Notification (ECN) field [RFC3168] 2524 Preferred Behavior: Set the outgoing value to the incoming value, 2525 UNLESS the server is doing Active Queue Management, the incoming 2526 ECN field is ECT(1) (=0b01) or ECT(0) (=0b10), and the server 2527 wishes to indicate that congestion has been experienced, in which 2528 case set the outgoing value to CE (=0b11). 2530 Alternate Behavior: Set the outgoing value to Not-ECT (=0b00). 2532 IPv4 Fragmentation fields 2534 Preferred Behavior: When the server sends a packet to a peer in 2535 response to a Send indication containing the DONT-FRAGMENT 2536 attribute, then set the DF bit in the outgoing IP header to 1. In 2537 all other cases when sending an outgoing packet containing 2538 application data (e.g., Data indication, ChannelData message, or 2539 DONT-FRAGMENT attribute not included in the Send indication), copy 2540 the DF bit from the DF bit of the incoming packet that contained 2541 the application data. 2543 Set the other fragmentation fields (Identification, More 2544 Fragments, Fragment Offset) as appropriate for a packet 2545 originating from the server. 2547 Alternate Behavior: As described in the Preferred Behavior, except 2548 always assume the incoming DF bit is 0. 2550 In both the Preferred and Alternate Behaviors, the resulting 2551 packet may be too large for the outgoing link. If this is the 2552 case, then the normal fragmentation rules apply [RFC1122]. 2554 IPv4 Options 2556 Preferred Behavior: The outgoing packet is sent without any IPv4 2557 options. 2559 Alternate Behavior: Same as preferred. 2561 15. STUN Methods 2563 This section lists the codepoints for the STUN methods defined in 2564 this specification. See elsewhere in this document for the semantics 2565 of these methods. 2567 0x003 : Allocate (only request/response semantics defined) 2568 0x004 : Refresh (only request/response semantics defined) 2569 0x006 : Send (only indication semantics defined) 2570 0x007 : Data (only indication semantics defined) 2571 0x008 : CreatePermission (only request/response semantics defined 2572 0x009 : ChannelBind (only request/response semantics defined) 2574 16. STUN Attributes 2576 This STUN extension defines the following attributes: 2578 0x000C: CHANNEL-NUMBER 2579 0x000D: LIFETIME 2580 0x0010: Reserved (was BANDWIDTH) 2581 0x0012: XOR-PEER-ADDRESS 2582 0x0013: DATA 2583 0x0016: XOR-RELAYED-ADDRESS 2584 0x0017: REQUESTED-ADDRESS-FAMILY 2585 0x0018: EVEN-PORT 2586 0x0019: REQUESTED-TRANSPORT 2587 0x001A: DONT-FRAGMENT 2588 0x0021: Reserved (was TIMER-VAL) 2589 0x0022: RESERVATION-TOKEN 2590 TBD-CA: ADDITIONAL-ADDRESS-FAMILY 2591 TBD-CA: ADDRESS-ERROR-CODE 2592 TBD-CA: ICMP 2594 Some of these attributes have lengths that are not multiples of 4. 2595 By the rules of STUN, any attribute whose length is not a multiple of 2596 4 bytes MUST be immediately followed by 1 to 3 padding bytes to 2597 ensure the next attribute (if any) would start on a 4-byte boundary 2598 (see [I-D.ietf-tram-stunbis]). 2600 16.1. CHANNEL-NUMBER 2602 The CHANNEL-NUMBER attribute contains the number of the channel. The 2603 value portion of this attribute is 4 bytes long and consists of a 2604 16-bit unsigned integer, followed by a two-octet RFFU (Reserved For 2605 Future Use) field, which MUST be set to 0 on transmission and MUST be 2606 ignored on reception. 2608 0 1 2 3 2609 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 2610 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2611 | Channel Number | RFFU = 0 | 2612 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2614 16.2. LIFETIME 2616 The LIFETIME attribute represents the duration for which the server 2617 will maintain an allocation in the absence of a refresh. The value 2618 portion of this attribute is 4-bytes long and consists of a 32-bit 2619 unsigned integral value representing the number of seconds remaining 2620 until expiration. 2622 16.3. XOR-PEER-ADDRESS 2624 The XOR-PEER-ADDRESS specifies the address and port of the peer as 2625 seen from the TURN server. (For example, the peer's server-reflexive 2626 transport address if the peer is behind a NAT.) It is encoded in the 2627 same way as XOR-MAPPED-ADDRESS [I-D.ietf-tram-stunbis]. 2629 16.4. DATA 2631 The DATA attribute is present in all Send and Data indications. The 2632 value portion of this attribute is variable length and consists of 2633 the application data (that is, the data that would immediately follow 2634 the UDP header if the data was been sent directly between the client 2635 and the peer). If the length of this attribute is not a multiple of 2636 4, then padding must be added after this attribute. 2638 16.5. XOR-RELAYED-ADDRESS 2640 The XOR-RELAYED-ADDRESS is present in Allocate responses. It 2641 specifies the address and port that the server allocated to the 2642 client. It is encoded in the same way as XOR-MAPPED-ADDRESS 2643 [I-D.ietf-tram-stunbis]. 2645 16.6. REQUESTED-ADDRESS-FAMILY 2647 This attribute is used in Allocate and Refresh requests to specify 2648 the address type requested by the client. The value of this 2649 attribute is 4 bytes with the following format: 2651 0 1 2 3 2652 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 2653 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2654 | Family | Reserved | 2655 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2657 Family: there are two values defined for this field and specified in 2658 [I-D.ietf-tram-stunbis], Section 14.1: 0x01 for IPv4 addresses and 2659 0x02 for IPv6 addresses. 2661 Reserved: at this point, the 24 bits in the Reserved field MUST be 2662 set to zero by the client and MUST be ignored by the server. 2664 16.7. EVEN-PORT 2666 This attribute allows the client to request that the port in the 2667 relayed transport address be even, and (optionally) that the server 2668 reserve the next-higher port number. The value portion of this 2669 attribute is 1 byte long. Its format is: 2671 0 2672 0 1 2 3 4 5 6 7 2673 +-+-+-+-+-+-+-+-+ 2674 |R| RFFU | 2675 +-+-+-+-+-+-+-+-+ 2677 The value contains a single 1-bit flag: 2679 R: If 1, the server is requested to reserve the next-higher port 2680 number (on the same IP address) for a subsequent allocation. If 2681 0, no such reservation is requested. 2683 The other 7 bits of the attribute's value must be set to zero on 2684 transmission and ignored on reception. 2686 Since the length of this attribute is not a multiple of 4, padding 2687 must immediately follow this attribute. 2689 16.8. REQUESTED-TRANSPORT 2691 This attribute is used by the client to request a specific transport 2692 protocol for the allocated transport address. The value of this 2693 attribute is 4 bytes with the following format: 2695 0 1 2 3 2696 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 2697 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2698 | Protocol | RFFU | 2699 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2701 The Protocol field specifies the desired protocol. The codepoints 2702 used in this field are taken from those allowed in the Protocol field 2703 in the IPv4 header and the NextHeader field in the IPv6 header 2704 [Protocol-Numbers]. This specification only allows the use of 2705 codepoint 17 (User Datagram Protocol). 2707 The RFFU field MUST be set to zero on transmission and MUST be 2708 ignored on reception. It is reserved for future uses. 2710 16.9. DONT-FRAGMENT 2712 This attribute is used by the client to request that the server set 2713 the DF (Don't Fragment) bit in the IP header when relaying the 2714 application data onward to the peer. This attribute has no value 2715 part and thus the attribute length field is 0. 2717 16.10. RESERVATION-TOKEN 2719 The RESERVATION-TOKEN attribute contains a token that uniquely 2720 identifies a relayed transport address being held in reserve by the 2721 server. The server includes this attribute in a success response to 2722 tell the client about the token, and the client includes this 2723 attribute in a subsequent Allocate request to request the server use 2724 that relayed transport address for the allocation. 2726 The attribute value is 8 bytes and contains the token value. 2728 16.11. ADDITIONAL-ADDRESS-FAMILY 2730 This attribute is used by clients to request the allocation of a IPv4 2731 and IPv6 address type from a server. It is encoded in the same way 2732 as REQUESTED-ADDRESS-FAMILY Section 16.6. The ADDITIONAL-ADDRESS- 2733 FAMILY attribute MAY be present in Allocate request. The attribute 2734 value of 0x02 (IPv6 address) is the only valid value in Allocate 2735 request. 2737 16.12. ADDRESS-ERROR-CODE Attribute 2739 This attribute is used by servers to signal the reason for not 2740 allocating the requested address family. The value portion of this 2741 attribute is variable length with the following format: 2743 0 1 2 3 2744 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 2745 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2746 | Family | Rsvd |Class| Number | 2747 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2748 | Reason Phrase (variable) .. 2749 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2751 Family: there are two values defined for this field and specified in 2752 [I-D.ietf-tram-stunbis], Section 14.1: 0x01 for IPv4 addresses and 2753 0x02 for IPv6 addresses. 2755 Reserved: at this point, the 13 bits in the Reserved field MUST be 2756 set to zero by the client and MUST be ignored by the server. 2758 Class: The Class represents the hundreds digit of the error code and 2759 is defined in section 14.8 of [I-D.ietf-tram-stunbis]. 2761 Number: this 8-bit field contains the reason server cannot allocate 2762 one of the requested address types. The error code values could 2763 be either 440 (unsupported address family) or 508 (insufficient 2764 capacity). The number representation is defined in section 14.8 2765 of [I-D.ietf-tram-stunbis]. 2767 Reason Phrase: The recommended reason phrases for error codes 440 2768 and 508 are explained in Section 17. 2770 16.13. ICMP Attribute 2772 This attribute is used by servers to signal the reason an UDP packet 2773 was dropped. The following is the format of the ICMP attribute. 2775 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 2776 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2777 | Reserved | ICMP Type | ICMP Code | 2778 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2780 Reserved: This field MUST be set to 0 when sent, and MUST be ignored 2781 when received. 2783 ICMP Type: The field contains the value in the ICMP type. Its 2784 interpretation depends whether the ICMP was received over IPv4 or 2785 IPv6. 2787 ICMP Code: The field contains the value in the ICMP code. Its 2788 interpretation depends whether the ICMP was received over IPv4 or 2789 IPv6. 2791 17. STUN Error Response Codes 2793 This document defines the following error response codes: 2795 403 (Forbidden): The request was valid but cannot be performed due 2796 to administrative or similar restrictions. 2798 437 (Allocation Mismatch): A request was received by the server that 2799 requires an allocation to be in place, but no allocation exists, 2800 or a request was received that requires no allocation, but an 2801 allocation exists. 2803 440 (Address Family not Supported): The server does not support the 2804 address family requested by the client. 2806 441 (Wrong Credentials): The credentials in the (non-Allocate) 2807 request do not match those used to create the allocation. 2809 442 (Unsupported Transport Protocol): The Allocate request asked the 2810 server to use a transport protocol between the server and the peer 2811 that the server does not support. NOTE: This does NOT refer to 2812 the transport protocol used in the 5-tuple. 2814 443 (Peer Address Family Mismatch). A peer address is part of a 2815 different address family than that of the relayed transport 2816 address of the allocation. 2818 486 (Allocation Quota Reached): No more allocations using this 2819 username can be created at the present time. 2821 508 (Insufficient Capacity): The server is unable to carry out the 2822 request due to some capacity limit being reached. In an Allocate 2823 response, this could be due to the server having no more relayed 2824 transport addresses available at that time, having none with the 2825 requested properties, or the one that corresponds to the specified 2826 reservation token is not available. 2828 18. Detailed Example 2830 This section gives an example of the use of TURN, showing in detail 2831 the contents of the messages exchanged. The example uses the network 2832 diagram shown in the Overview (Figure 1). 2834 For each message, the attributes included in the message and their 2835 values are shown. For convenience, values are shown in a human- 2836 readable format rather than showing the actual octets; for example, 2837 "XOR-RELAYED-ADDRESS=192.0.2.15:9000" shows that the XOR-RELAYED- 2838 ADDRESS attribute is included with an address of 192.0.2.15 and a 2839 port of 9000, here the address and port are shown before the xor-ing 2840 is done. For attributes with string-like values (e.g., 2841 SOFTWARE="Example client, version 1.03" and 2842 NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda"), the value of the attribute 2843 is shown in quotes for readability, but these quotes do not appear in 2844 the actual value. 2846 TURN TURN Peer Peer 2847 client server A B 2848 | | | | 2849 |--- Allocate request -------------->| | | 2850 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2851 | SOFTWARE="Example client, version 1.03" | | 2852 | LIFETIME=3600 (1 hour) | | | 2853 | REQUESTED-TRANSPORT=17 (UDP) | | | 2854 | DONT-FRAGMENT | | | 2855 | | | | 2856 |<-- Allocate error response --------| | | 2857 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2858 | SOFTWARE="Example server, version 1.17" | | 2859 | ERROR-CODE=401 (Unauthorized) | | | 2860 | REALM="example.com" | | | 2861 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2862 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 2863 | | | | 2864 |--- Allocate request -------------->| | | 2865 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2866 | SOFTWARE="Example client 1.03" | | | 2867 | LIFETIME=3600 (1 hour) | | | 2868 | REQUESTED-TRANSPORT=17 (UDP) | | | 2869 | DONT-FRAGMENT | | | 2870 | USERNAME="George" | | | 2871 | REALM="example.com" | | | 2872 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2873 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 2874 | PASSWORD-ALGORITHM=SHA256 | | | 2875 | MESSAGE-INTEGRITY=... | | | 2876 | MESSAGE-INTEGRITY-SHA256=... | | | 2877 | | | | 2878 |<-- Allocate success response ------| | | 2879 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2880 | SOFTWARE="Example server, version 1.17" | | 2881 | LIFETIME=1200 (20 minutes) | | | 2882 | XOR-RELAYED-ADDRESS=192.0.2.15:50000 | | 2883 | XOR-MAPPED-ADDRESS=192.0.2.1:7000 | | 2884 | MESSAGE-INTEGRITY=... | | | 2886 The client begins by selecting a host transport address to use for 2887 the TURN session; in this example, the client has selected 2888 198.51.100.2:49721 as shown in Figure 1. The client then sends an 2889 Allocate request to the server at the server transport address. The 2890 client randomly selects a 96-bit transaction id of 2891 0xA56250D3F17ABE679422DE85 for this transaction; this is encoded in 2892 the transaction id field in the fixed header. The client includes a 2893 SOFTWARE attribute that gives information about the client's 2894 software; here the value is "Example client, version 1.03" to 2895 indicate that this is version 1.03 of something called the Example 2896 client. The client includes the LIFETIME attribute because it wishes 2897 the allocation to have a longer lifetime than the default of 10 2898 minutes; the value of this attribute is 3600 seconds, which 2899 corresponds to 1 hour. The client must always include a REQUESTED- 2900 TRANSPORT attribute in an Allocate request and the only value allowed 2901 by this specification is 17, which indicates UDP transport between 2902 the server and the peers. The client also includes the DONT-FRAGMENT 2903 attribute because it wishes to use the DONT-FRAGMENT attribute later 2904 in Send indications; this attribute consists of only an attribute 2905 header, there is no value part. We assume the client has not 2906 recently interacted with the server, thus the client does not include 2907 USERNAME, USERHASH, REALM, NONCE, PASSWORD-ALGORITHMS, PASSWORD- 2908 ALGORITHM, MESSAGE-INTEGRITY or MESSAGE-INTEGRITY-SHA256 attribute. 2909 Finally, note that the order of attributes in a message is arbitrary 2910 (except for the MESSAGE-INTEGRITY, MESSAGE-INTEGRITY-SHA256 and 2911 FINGERPRINT attributes) and the client could have used a different 2912 order. 2914 Servers require any request to be authenticated. Thus, when the 2915 server receives the initial Allocate request, it rejects the request 2916 because the request does not contain the authentication attributes. 2917 Following the procedures of the long-term credential mechanism of 2918 STUN [I-D.ietf-tram-stunbis], the server includes an ERROR-CODE 2919 attribute with a value of 401 (Unauthorized), a REALM attribute that 2920 specifies the authentication realm used by the server (in this case, 2921 the server's domain "example.com"), and a nonce value in a NONCE 2922 attribute. The NONCE attribute starts with the "nonce cookie" with 2923 the STUN Security Feature "Password algorithm" bit set to 1. The 2924 server includes a PASSWORD-ALGORITHMS attribute that specifies the 2925 list of algorithms that the server can use to derive the long-term 2926 password. If the server sets the STUN Security Feature "Username 2927 anonymity" bit to 1 then the client uses the USERHASH attribute 2928 instead of the USERNAME attribute in the Allocate request to 2929 anonymise the username. The server also includes a SOFTWARE 2930 attribute that gives information about the server's software. 2932 The client, upon receipt of the 401 error, re-attempts the Allocate 2933 request, this time including the authentication attributes. The 2934 client selects a new transaction id, and then populates the new 2935 Allocate request with the same attributes as before. The client 2936 includes a USERNAME attribute and uses the realm value received from 2937 the server to help it determine which value to use; here the client 2938 is configured to use the username "George" for the realm 2939 "example.com". The client includes the PASSWORD-ALGORITHM attribute 2940 indicating the algorithm that the server must use to derive the long- 2941 term password. The client also includes the REALM and NONCE 2942 attributes, which are just copied from the 401 error response. 2943 Finally, the client includes MESSAGE-INTEGRITY and MESSAGE-INTEGRITY- 2944 SHA256 attributes as the last attributes in the message, whose values 2945 are Hashed Message Authentication Code - Secure Hash Algorithm 1 2946 (HMAC-SHA1) hash and Hashed Message Authentication Code - Secure Hash 2947 Algorithm 2 (HMAC-SHA2) hash over the contents of the message (shown 2948 as just "..." above); this HMAC-SHA1 and HMAC-SHA2 computation 2949 includes a password value. Thus, an attacker cannot compute the 2950 message integrity value without somehow knowing the secret password. 2952 The server, upon receipt of the authenticated Allocate request, 2953 checks that everything is OK, then creates an allocation. The server 2954 replies with an Allocate success response. The server includes a 2955 LIFETIME attribute giving the lifetime of the allocation; here, the 2956 server has reduced the client's requested 1-hour lifetime to just 20 2957 minutes, because this particular server doesn't allow lifetimes 2958 longer than 20 minutes. The server includes an XOR-RELAYED-ADDRESS 2959 attribute whose value is the relayed transport address of the 2960 allocation. The server includes an XOR-MAPPED-ADDRESS attribute 2961 whose value is the server-reflexive address of the client; this value 2962 is not used otherwise in TURN but is returned as a convenience to the 2963 client. The server includes either a MESSAGE-INTEGRITY or MESSAGE- 2964 INTEGRITY-SHA256 attribute to authenticate the response and to ensure 2965 its integrity; note that the response does not contain the USERNAME, 2966 REALM, and NONCE attributes. The server also includes a SOFTWARE 2967 attribute. 2969 TURN TURN Peer Peer 2970 client server A B 2971 |--- CreatePermission request ------>| | | 2972 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2973 | XOR-PEER-ADDRESS=192.0.2.150:0 | | | 2974 | USERNAME="George" | | | 2975 | REALM="example.com" | | | 2976 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2977 | MESSAGE-INTEGRITY=... | | | 2978 | | | | 2979 |<-- CreatePermission success resp.--| | | 2980 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2981 | MESSAGE-INTEGRITY=... | | | 2983 The client then creates a permission towards Peer A in preparation 2984 for sending it some application data. This is done through a 2985 CreatePermission request. The XOR-PEER-ADDRESS attribute contains 2986 the IP address for which a permission is established (the IP address 2987 of peer A); note that the port number in the attribute is ignored 2988 when used in a CreatePermission request, and here it has been set to 2989 0; also, note how the client uses Peer A's server-reflexive IP 2990 address and not its (private) host address. The client uses the same 2991 username, realm, and nonce values as in the previous request on the 2992 allocation. Though it is allowed to do so, the client has chosen not 2993 to include a SOFTWARE attribute in this request. 2995 The server receives the CreatePermission request, creates the 2996 corresponding permission, and then replies with a CreatePermission 2997 success response. Like the client, the server chooses not to include 2998 the SOFTWARE attribute in its reply. Again, note how success 2999 responses contain a MESSAGE-INTEGRITY or MESSAGE-INTEGRITY-SHA256 3000 attribute (assuming the server uses the long-term credential 3001 mechanism), but no USERNAME, REALM, and NONCE attributes. 3003 TURN TURN Peer Peer 3004 client server A B 3005 |--- Send indication --------------->| | | 3006 | Transaction-Id=0x1278E9ACA2711637EF7D3328 | | 3007 | XOR-PEER-ADDRESS=192.0.2.150:32102 | | 3008 | DONT-FRAGMENT | | | 3009 | DATA=... | | | 3010 | |-- UDP dgm ->| | 3011 | | data=... | | 3012 | | | | 3013 | |<- UDP dgm --| | 3014 | | data=... | | 3015 |<-- Data indication ----------------| | | 3016 | Transaction-Id=0x8231AE8F9242DA9FF287FEFF | | 3017 | XOR-PEER-ADDRESS=192.0.2.150:32102 | | 3018 | DATA=... | | | 3020 The client now sends application data to Peer A using a Send 3021 indication. Peer A's server-reflexive transport address is specified 3022 in the XOR-PEER-ADDRESS attribute, and the application data (shown 3023 here as just "...") is specified in the DATA attribute. The client 3024 is doing a form of path MTU discovery at the application layer and 3025 thus specifies (by including the DONT-FRAGMENT attribute) that the 3026 server should set the DF bit in the UDP datagram to send to the peer. 3027 Indications cannot be authenticated using the long-term credential 3028 mechanism of STUN, so no MESSAGE-INTEGRITY or MESSAGE-INTEGRITY- 3029 SHA256 attribute is included in the message. An application wishing 3030 to ensure that its data is not altered or forged must integrity- 3031 protect its data at the application level. 3033 Upon receipt of the Send indication, the server extracts the 3034 application data and sends it in a UDP datagram to Peer A, with the 3035 relayed transport address as the source transport address of the 3036 datagram, and with the DF bit set as requested. Note that, had the 3037 client not previously established a permission for Peer A's server- 3038 reflexive IP address, then the server would have silently discarded 3039 the Send indication instead. 3041 Peer A then replies with its own UDP datagram containing application 3042 data. The datagram is sent to the relayed transport address on the 3043 server. When this arrives, the server creates a Data indication 3044 containing the source of the UDP datagram in the XOR-PEER-ADDRESS 3045 attribute, and the data from the UDP datagram in the DATA attribute. 3046 The resulting Data indication is then sent to the client. 3048 TURN TURN Peer Peer 3049 client server A B 3050 |--- ChannelBind request ----------->| | | 3051 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 3052 | CHANNEL-NUMBER=0x4000 | | | 3053 | XOR-PEER-ADDRESS=192.0.2.210:49191 | | 3054 | USERNAME="George" | | | 3055 | REALM="example.com" | | | 3056 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 3057 | MESSAGE-INTEGRITY=... | | | 3058 | | | | 3059 |<-- ChannelBind success response ---| | | 3060 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 3061 | MESSAGE-INTEGRITY=... | | | 3063 The client now binds a channel to Peer B, specifying a free channel 3064 number (0x4000) in the CHANNEL-NUMBER attribute, and Peer B's 3065 transport address in the XOR-PEER-ADDRESS attribute. As before, the 3066 client re-uses the username, realm, and nonce from its last request 3067 in the message. 3069 Upon receipt of the request, the server binds the channel number to 3070 the peer, installs a permission for Peer B's IP address, and then 3071 replies with ChannelBind success response. 3073 TURN TURN Peer Peer 3074 client server A B 3075 |--- ChannelData ------------------->| | | 3076 | Channel-number=0x4000 |--- UDP datagram --------->| 3077 | Data=... | Data=... | 3078 | | | | 3079 | |<-- UDP datagram ----------| 3080 | | Data=... | | 3081 |<-- ChannelData --------------------| | | 3082 | Channel-number=0x4000 | | | 3083 | Data=... | | | 3085 The client now sends a ChannelData message to the server with data 3086 destined for Peer B. The ChannelData message is not a STUN message, 3087 and thus has no transaction id. Instead, it has only three fields: a 3088 channel number, data, and data length; here the channel number field 3089 is 0x4000 (the channel the client just bound to Peer B). When the 3090 server receives the ChannelData message, it checks that the channel 3091 is currently bound (which it is) and then sends the data onward to 3092 Peer B in a UDP datagram, using the relayed transport address as the 3093 source transport address and 192.0.2.210:49191 (the value of the XOR- 3094 PEER-ADDRESS attribute in the ChannelBind request) as the destination 3095 transport address. 3097 Later, Peer B sends a UDP datagram back to the relayed transport 3098 address. This causes the server to send a ChannelData message to the 3099 client containing the data from the UDP datagram. The server knows 3100 to which client to send the ChannelData message because of the 3101 relayed transport address at which the UDP datagram arrived, and 3102 knows to use channel 0x4000 because this is the channel bound to 3103 192.0.2.210:49191. Note that if there had not been any channel 3104 number bound to that address, the server would have used a Data 3105 indication instead. 3107 TURN TURN Peer Peer 3108 client server A B 3109 |--- Refresh request --------------->| | | 3110 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 3111 | SOFTWARE="Example client 1.03" | | | 3112 | USERNAME="George" | | | 3113 | REALM="example.com" | | | 3114 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 3115 | MESSAGE-INTEGRITY=... | | | 3116 | | | | 3117 |<-- Refresh error response ---------| | | 3118 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 3119 | SOFTWARE="Example server, version 1.17" | | 3120 | ERROR-CODE=438 (Stale Nonce) | | | 3121 | REALM="example.com" | | | 3122 | NONCE="obMatJos2AAABnpSw1Xw239bBwGYhjN" | | 3123 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 3124 | | | | 3125 |--- Refresh request --------------->| | | 3126 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 3127 | SOFTWARE="Example client 1.03" | | | 3128 | USERNAME="George" | | | 3129 | REALM="example.com" | | | 3130 | NONCE="obMatJos2AAABnpSw1Xw239bBwGYhjNj" | | 3131 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 3132 | PASSWORD-ALGORITHM=SHA256 | | | 3133 | MESSAGE-INTEGRITY=... | | | 3134 | | | | 3135 |<-- Refresh success response -------| | | 3136 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 3137 | SOFTWARE="Example server, version 1.17" | | 3138 | LIFETIME=600 (10 minutes) | | | 3140 Sometime before the 20 minute lifetime is up, the client refreshes 3141 the allocation. This is done using a Refresh request. As before, 3142 the client includes the latest username, realm, and nonce values in 3143 the request. The client also includes the SOFTWARE attribute, 3144 following the recommended practice of always including this attribute 3145 in Allocate and Refresh messages. When the server receives the 3146 Refresh request, it notices that the nonce value has expired, and so 3147 replies with 438 (Stale Nonce) error given a new nonce value. The 3148 client then reattempts the request, this time with the new nonce 3149 value. This second attempt is accepted, and the server replies with 3150 a success response. Note that the client did not include a LIFETIME 3151 attribute in the request, so the server refreshes the allocation for 3152 the default lifetime of 10 minutes (as can be seen by the LIFETIME 3153 attribute in the success response). 3155 19. Security Considerations 3157 This section considers attacks that are possible in a TURN 3158 deployment, and discusses how they are mitigated by mechanisms in the 3159 protocol or recommended practices in the implementation. 3161 Most of the attacks on TURN are mitigated by the server requiring 3162 requests be authenticated. Thus, this specification requires the use 3163 of authentication. The mandatory-to-implement mechanism is the long- 3164 term credential mechanism of STUN. Other authentication mechanisms 3165 of equal or stronger security properties may be used. However, it is 3166 important to ensure that they can be invoked in an inter-operable 3167 way. 3169 19.1. Outsider Attacks 3171 Outsider attacks are ones where the attacker has no credentials in 3172 the system, and is attempting to disrupt the service seen by the 3173 client or the server. 3175 19.1.1. Obtaining Unauthorized Allocations 3177 An attacker might wish to obtain allocations on a TURN server for any 3178 number of nefarious purposes. A TURN server provides a mechanism for 3179 sending and receiving packets while cloaking the actual IP address of 3180 the client. This makes TURN servers an attractive target for 3181 attackers who wish to use it to mask their true identity. 3183 An attacker might also wish to simply utilize the services of a TURN 3184 server without paying for them. Since TURN services require 3185 resources from the provider, it is anticipated that their usage will 3186 come with a cost. 3188 These attacks are prevented using the long-term credential mechanism, 3189 which allows the TURN server to determine the identity of the 3190 requestor and whether the requestor is allowed to obtain the 3191 allocation. 3193 19.1.2. Offline Dictionary Attacks 3195 The long-term credential mechanism used by TURN is subject to offline 3196 dictionary attacks. An attacker that is capable of eavesdropping on 3197 a message exchange between a client and server can determine the 3198 password by trying a number of candidate passwords and seeing if one 3199 of them is correct. This attack works when the passwords are low 3200 entropy, such as a word from the dictionary. This attack can be 3201 mitigated by using strong passwords with large entropy. In 3202 situations where even stronger mitigation is required, (D)TLS 3203 transport between the client and the server can be used. 3205 19.1.3. Faked Refreshes and Permissions 3207 An attacker might wish to attack an active allocation by sending it a 3208 Refresh request with an immediate expiration, in order to delete it 3209 and disrupt service to the client. This is prevented by 3210 authentication of refreshes. Similarly, an attacker wishing to send 3211 CreatePermission requests to create permissions to undesirable 3212 destinations is prevented from doing so through authentication. The 3213 motivations for such an attack are described in Section 19.2. 3215 19.1.4. Fake Data 3217 An attacker might wish to send data to the client or the peer, as if 3218 they came from the peer or client, respectively. To do that, the 3219 attacker can send the client a faked Data Indication or ChannelData 3220 message, or send the TURN server a faked Send Indication or 3221 ChannelData message. 3223 Since indications and ChannelData messages are not authenticated, 3224 this attack is not prevented by TURN. However, this attack is 3225 generally present in IP-based communications and is not substantially 3226 worsened by TURN. Consider a normal, non-TURN IP session between 3227 hosts A and B. An attacker can send packets to B as if they came 3228 from A by sending packets towards A with a spoofed IP address of B. 3229 This attack requires the attacker to know the IP addresses of A and 3230 B. With TURN, an attacker wishing to send packets towards a client 3231 using a Data indication needs to know its IP address (and port), the 3232 IP address and port of the TURN server, and the IP address and port 3233 of the peer (for inclusion in the XOR-PEER-ADDRESS attribute). To 3234 send a fake ChannelData message to a client, an attacker needs to 3235 know the IP address and port of the client, the IP address and port 3236 of the TURN server, and the channel number. This particular 3237 combination is mildly more guessable than in the non-TURN case. 3239 These attacks are more properly mitigated by application-layer 3240 authentication techniques. In the case of real-time traffic, usage 3241 of SRTP [RFC3711] prevents these attacks. 3243 In some situations, the TURN server may be situated in the network 3244 such that it is able to send to hosts to which the client cannot 3245 directly send. This can happen, for example, if the server is 3246 located behind a firewall that allows packets from outside the 3247 firewall to be delivered to the server, but not to other hosts behind 3248 the firewall. In these situations, an attacker could send the server 3249 a Send indication with an XOR-PEER-ADDRESS attribute containing the 3250 transport address of one of the other hosts behind the firewall. If 3251 the server was to allow relaying of traffic to arbitrary peers, then 3252 this would provide a way for the attacker to attack arbitrary hosts 3253 behind the firewall. 3255 To mitigate this attack, TURN requires that the client establish a 3256 permission to a host before sending it data. Thus, an attacker can 3257 only attack hosts with which the client is already communicating, 3258 unless the attacker is able to create authenticated requests. 3259 Furthermore, the server administrator may configure the server to 3260 restrict the range of IP addresses and ports to which it will relay 3261 data. To provide even greater security, the server administrator can 3262 require that the client use (D)TLS for all communication between the 3263 client and the server. 3265 19.1.5. Impersonating a Server 3267 When a client learns a relayed address from a TURN server, it uses 3268 that relayed address in application protocols to receive traffic. 3269 Therefore, an attacker wishing to intercept or redirect that traffic 3270 might try to impersonate a TURN server and provide the client with a 3271 faked relayed address. 3273 This attack is prevented through the long-term credential mechanism, 3274 which provides message integrity for responses in addition to 3275 verifying that they came from the server. Furthermore, an attacker 3276 cannot replay old server responses as the transaction id in the STUN 3277 header prevents this. Replay attacks are further thwarted through 3278 frequent changes to the nonce value. 3280 19.1.6. Eavesdropping Traffic 3282 TURN concerns itself primarily with authentication and message 3283 integrity. Confidentiality is only a secondary concern, as TURN 3284 control messages do not include information that is particularly 3285 sensitive. The primary protocol content of the messages is the IP 3286 address of the peer. If it is important to prevent an eavesdropper 3287 on a TURN connection from learning this, TURN can be run over (D)TLS. 3289 Confidentiality for the application data relayed by TURN is best 3290 provided by the application protocol itself, since running TURN over 3291 (D)TLS does not protect application data between the server and the 3292 peer. If confidentiality of application data is important, then the 3293 application should encrypt or otherwise protect its data. For 3294 example, for real-time media, confidentiality can be provided by 3295 using SRTP. 3297 19.1.7. TURN Loop Attack 3299 An attacker might attempt to cause data packets to loop indefinitely 3300 between two TURN servers. The attack goes as follows. First, the 3301 attacker sends an Allocate request to server A, using the source 3302 address of server B. Server A will send its response to server B, 3303 and for the attack to succeed, the attacker must have the ability to 3304 either view or guess the contents of this response, so that the 3305 attacker can learn the allocated relayed transport address. The 3306 attacker then sends an Allocate request to server B, using the source 3307 address of server A. Again, the attacker must be able to view or 3308 guess the contents of the response, so it can send learn the 3309 allocated relayed transport address. Using the same spoofed source 3310 address technique, the attacker then binds a channel number on server 3311 A to the relayed transport address on server B, and similarly binds 3312 the same channel number on server B to the relayed transport address 3313 on server A. Finally, the attacker sends a ChannelData message to 3314 server A. 3316 The result is a data packet that loops from the relayed transport 3317 address on server A to the relayed transport address on server B, 3318 then from server B's transport address to server A's transport 3319 address, and then around the loop again. 3321 This attack is mitigated as follows. By requiring all requests to be 3322 authenticated and/or by randomizing the port number allocated for the 3323 relayed transport address, the server forces the attacker to either 3324 intercept or view responses sent to a third party (in this case, the 3325 other server) so that the attacker can authenticate the requests and 3326 learn the relayed transport address. Without one of these two 3327 measures, an attacker can guess the contents of the responses without 3328 needing to see them, which makes the attack much easier to perform. 3329 Furthermore, by requiring authenticated requests, the server forces 3330 the attacker to have credentials acceptable to the server, which 3331 turns this from an outsider attack into an insider attack and allows 3332 the attack to be traced back to the client initiating it. 3334 The attack can be further mitigated by imposing a per-username limit 3335 on the bandwidth used to relay data by allocations owned by that 3336 username, to limit the impact of this attack on other allocations. 3337 More mitigation can be achieved by decrementing the TTL when relaying 3338 data packets (if the underlying OS allows this). 3340 19.2. Firewall Considerations 3342 A key security consideration of TURN is that TURN should not weaken 3343 the protections afforded by firewalls deployed between a client and a 3344 TURN server. It is anticipated that TURN servers will often be 3345 present on the public Internet, and clients may often be inside 3346 enterprise networks with corporate firewalls. If TURN servers 3347 provide a 'backdoor' for reaching into the enterprise, TURN will be 3348 blocked by these firewalls. 3350 TURN servers therefore emulate the behavior of NAT devices that 3351 implement address-dependent filtering [RFC4787], a property common in 3352 many firewalls as well. When a NAT or firewall implements this 3353 behavior, packets from an outside IP address are only allowed to be 3354 sent to an internal IP address and port if the internal IP address 3355 and port had recently sent a packet to that outside IP address. TURN 3356 servers introduce the concept of permissions, which provide exactly 3357 this same behavior on the TURN server. An attacker cannot send a 3358 packet to a TURN server and expect it to be relayed towards the 3359 client, unless the client has tried to contact the attacker first. 3361 It is important to note that some firewalls have policies that are 3362 even more restrictive than address-dependent filtering. Firewalls 3363 can also be configured with address- and port-dependent filtering, or 3364 can be configured to disallow inbound traffic entirely. In these 3365 cases, if a client is allowed to connect the TURN server, 3366 communications to the client will be less restrictive than what the 3367 firewall would normally allow. 3369 When a TURN server is configured to permit inbound STUN packets on 3370 the allocation's relayed address even if the source IP addresses of 3371 the STUN packets do not match the permissions installed, the TURN 3372 server MUST have a security policy for inbound STUN packets from IP 3373 addresses not matching the permissions installed in order to prevent 3374 an attacker from flooding the TURN client with STUN-like packets. 3375 The TURN server can limit forwarding to well-formed STUN connectivity 3376 check packets by looking for the STUN attributes USERNAME and 3377 MESSAGE-INTEGRITY and verifying that the message does not exceed a 3378 specific configurable packet size. Additionally, the TURN server 3379 policy can be configured with maximum rate-limits for the number of 3380 STUN packets allowed in a TURN session, STUN packets allowed per 3381 second, and IP addresses allowed to send STUN packets. 3383 19.2.1. Faked Permissions 3385 In firewalls and NAT devices, permissions are granted implicitly 3386 through the traversal of a packet from the inside of the network 3387 towards the outside peer. Thus, a permission cannot, by definition, 3388 be created by any entity except one inside the firewall or NAT. With 3389 TURN, this restriction no longer holds. Since the TURN server sits 3390 outside the firewall, at attacker outside the firewall can now send a 3391 message to the TURN server and try to create a permission for itself. 3393 This attack is prevented because all messages that create permissions 3394 (i.e., ChannelBind and CreatePermission) are authenticated. 3396 19.2.2. Blacklisted IP Addresses 3398 Many firewalls can be configured with blacklists that prevent a 3399 client behind the firewall from sending packets to, or receiving 3400 packets from, ranges of blacklisted IP addresses. This is 3401 accomplished by inspecting the source and destination addresses of 3402 packets entering and exiting the firewall, respectively. 3404 This feature is also present in TURN, since TURN servers are allowed 3405 to arbitrarily restrict the range of addresses of peers that they 3406 will relay to. 3408 19.2.3. Running Servers on Well-Known Ports 3410 A malicious client behind a firewall might try to connect to a TURN 3411 server and obtain an allocation which it then uses to run a server. 3412 For example, a client might try to run a DNS server or FTP server. 3414 This is not possible in TURN. A TURN server will never accept 3415 traffic from a peer for which the client has not installed a 3416 permission. Thus, peers cannot just connect to the allocated port in 3417 order to obtain the service. 3419 19.3. Insider Attacks 3421 In insider attacks, a client has legitimate credentials but defies 3422 the trust relationship that goes with those credentials. These 3423 attacks cannot be prevented by cryptographic means but need to be 3424 considered in the design of the protocol. 3426 19.3.1. DoS against TURN Server 3428 A client wishing to disrupt service to other clients might obtain an 3429 allocation and then flood it with traffic, in an attempt to swamp the 3430 server and prevent it from servicing other legitimate clients. This 3431 is mitigated by the recommendation that the server limit the amount 3432 of bandwidth it will relay for a given username. This won't prevent 3433 a client from sending a large amount of traffic, but it allows the 3434 server to immediately discard traffic in excess. 3436 Since each allocation uses a port number on the IP address of the 3437 TURN server, the number of allocations on a server is finite. An 3438 attacker might attempt to consume all of them by requesting a large 3439 number of allocations. This is prevented by the recommendation that 3440 the server impose a limit of the number of allocations active at a 3441 time for a given username. 3443 19.3.2. Anonymous Relaying of Malicious Traffic 3445 TURN servers provide a degree of anonymization. A client can send 3446 data to peers without revealing its own IP address. TURN servers may 3447 therefore become attractive vehicles for attackers to launch attacks 3448 against targets without fear of detection. Indeed, it is possible 3449 for a client to chain together multiple TURN servers, such that any 3450 number of relays can be used before a target receives a packet. 3452 Administrators who are worried about this attack can maintain logs 3453 that capture the actual source IP and port of the client, and perhaps 3454 even every permission that client installs. This will allow for 3455 forensic tracing to determine the original source, should it be 3456 discovered that an attack is being relayed through a TURN server. 3458 19.3.3. Manipulating Other Allocations 3460 An attacker might attempt to disrupt service to other users of the 3461 TURN server by sending Refresh requests or CreatePermission requests 3462 that (through source address spoofing) appear to be coming from 3463 another user of the TURN server. TURN prevents this by requiring 3464 that the credentials used in CreatePermission, Refresh, and 3465 ChannelBind messages match those used to create the initial 3466 allocation. Thus, the fake requests from the attacker will be 3467 rejected. 3469 19.4. Tunnel Amplification Attack 3471 An attacker might attempt to cause data packets to loop numerous 3472 times between a TURN server and a tunnel between IPv4 and IPv6. The 3473 attack goes as follows. 3475 Suppose an attacker knows that a tunnel endpoint will forward 3476 encapsulated packets from a given IPv6 address (this doesn't 3477 necessarily need to be the tunnel endpoint's address). Suppose he 3478 then spoofs two packets from this address: 3480 1. An Allocate request asking for a v4 address, and 3482 2. A ChannelBind request establishing a channel to the IPv4 address 3483 of the tunnel endpoint 3485 Then he has set up an amplification attack: 3487 o The TURN relay will re-encapsulate IPv6 UDP data in v4 and send it 3488 to the tunnel endpoint 3490 o The tunnel endpoint will de-encapsulate packets from the v4 3491 interface and send them to v6 3493 So if the attacker sends a packet of the following form... 3495 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3496 UDP: 3497 TURN: 3498 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3499 UDP: 3500 TURN: 3501 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3502 UDP: 3503 TURN: 3504 ... 3506 Then the TURN relay and the tunnel endpoint will send it back and 3507 forth until the last TURN header is consumed, at which point the TURN 3508 relay will send an empty packet, which the tunnel endpoint will drop. 3510 The amplification potential here is limited by the MTU, so it's not 3511 huge: IPv6+UDP+TURN takes 334 bytes, so a four-to-one amplification 3512 out of a 1500-byte packet is possible. But the attacker could still 3513 increase traffic volume by sending multiple packets or by 3514 establishing multiple channels spoofed from different addresses 3515 behind the same tunnel endpoint. 3517 The attack is mitigated as follows. It is RECOMMENDED that TURN 3518 relays not accept allocation or channel binding requests from 3519 addresses known to be tunneled, and that they not forward data to 3520 such addresses. In particular, a TURN relay MUST NOT accept Teredo 3521 or 6to4 addresses in these requests. 3523 19.5. Other Considerations 3525 Any relay addresses learned through an Allocate request will not 3526 operate properly with IPsec Authentication Header (AH) [RFC4302] in 3527 transport or tunnel mode. However, tunnel-mode IPsec Encapsulating 3528 Security Payload (ESP) [RFC4303] should still operate. 3530 20. IANA Considerations 3532 [Paragraphs in braces should be removed by the RFC Editor upon 3533 publication] 3534 The codepoints for the STUN methods defined in this specification are 3535 listed in Section 15. [IANA is requested to update the reference 3536 from [RFC5766] to RFC-to-be for the STUN methods listed in 3537 Section 15.] 3539 The codepoints for the STUN attributes defined in this specification 3540 are listed in Section 16. [IANA is requested to update the reference 3541 from [RFC5766] to RFC-to-be for the STUN attributes CHANNEL-NUMBER, 3542 LIFETIME, Reserved (was BANDWIDTH), XOR-PEER-ADDRESS, DATA, XOR- 3543 RELAYED-ADDRESS, REQUESTED-ADDRESS-FAMILY, EVEN-PORT, REQUESTED- 3544 TRANSPORT, DONT-FRAGMENT, Reserved (was TIMER-VAL) and RESERVATION- 3545 TOKEN listed in Section 16.] 3547 [The ADDITIONAL-ADDRESS-FAMILY, ADDRESS-ERROR-CODE and ICMP 3548 attributes requires that IANA allocate a value in the "STUN 3549 attributes Registry" from the comprehension-optional range 3550 (0x8000-0xFFFF), to be replaced for TBD-CA throughout this document] 3552 The codepoints for the STUN error codes defined in this specification 3553 are listed in Section 17. [IANA is requested to update the reference 3554 from [RFC5766] to RFC-to-be for the STUN error codes listed in 3555 Section 17.] 3557 IANA has allocated the SRV service name of "turn" for TURN over UDP 3558 or TCP, and the service name of "turns" for TURN over (D)TLS. 3560 IANA has created a registry for TURN channel numbers, initially 3561 populated as follows: 3563 o 0x0000 through 0x3FFF: Reserved and not available for use, since 3564 they conflict with the STUN header. 3566 o 0x4000 through 0x4FFF: A TURN implementation is free to use 3567 channel numbers in this range. 3569 o 0x5000 through 0xFFFF: Unassigned. 3571 Any change to this registry must be made through an IETF Standards 3572 Action. 3574 21. IAB Considerations 3576 The IAB has studied the problem of "Unilateral Self Address Fixing" 3577 (UNSAF), which is the general process by which a client attempts to 3578 determine its address in another realm on the other side of a NAT 3579 through a collaborative protocol-reflection mechanism [RFC3424]. The 3580 TURN extension is an example of a protocol that performs this type of 3581 function. The IAB has mandated that any protocols developed for this 3582 purpose document a specific set of considerations. These 3583 considerations and the responses for TURN are documented in this 3584 section. 3586 Consideration 1: Precise definition of a specific, limited-scope 3587 problem that is to be solved with the UNSAF proposal. A short-term 3588 fix should not be generalized to solve other problems. Such 3589 generalizations lead to the prolonged dependence on and usage of the 3590 supposed short-term fix -- meaning that it is no longer accurate to 3591 call it "short-term". 3593 Response: TURN is a protocol for communication between a relay (= 3594 TURN server) and its client. The protocol allows a client that is 3595 behind a NAT to obtain and use a public IP address on the relay. As 3596 a convenience to the client, TURN also allows the client to determine 3597 its server-reflexive transport address. 3599 Consideration 2: Description of an exit strategy/transition plan. 3600 The better short-term fixes are the ones that will naturally see less 3601 and less use as the appropriate technology is deployed. 3603 Response: TURN will no longer be needed once there are no longer any 3604 NATs. Unfortunately, as of the date of publication of this document, 3605 it no longer seems very likely that NATs will go away any time soon. 3606 However, the need for TURN will also decrease as the number of NATs 3607 with the mapping property of Endpoint-Independent Mapping [RFC4787] 3608 increases. 3610 Consideration 3: Discussion of specific issues that may render 3611 systems more "brittle". For example, approaches that involve using 3612 data at multiple network layers create more dependencies, increase 3613 debugging challenges, and make it harder to transition. 3615 Response: TURN is "brittle" in that it requires the NAT bindings 3616 between the client and the server to be maintained unchanged for the 3617 lifetime of the allocation. This is typically done using keep- 3618 alives. If this is not done, then the client will lose its 3619 allocation and can no longer exchange data with its peers. 3621 Consideration 4: Identify requirements for longer-term, sound 3622 technical solutions; contribute to the process of finding the right 3623 longer-term solution. 3625 Response: The need for TURN will be reduced once NATs implement the 3626 recommendations for NAT UDP behavior documented in [RFC4787]. 3627 Applications are also strongly urged to use ICE [RFC5245] to 3628 communicate with peers; though ICE uses TURN, it does so only as a 3629 last resort, and uses it in a controlled manner. 3631 Consideration 5: Discussion of the impact of the noted practical 3632 issues with existing deployed NATs and experience reports. 3634 Response: Some NATs deployed today exhibit a mapping behavior other 3635 than Endpoint-Independent mapping. These NATs are difficult to work 3636 with, as they make it difficult or impossible for protocols like ICE 3637 to use server-reflexive transport addresses on those NATs. A client 3638 behind such a NAT is often forced to use a relay protocol like TURN 3639 because "UDP hole punching" techniques [RFC5128] do not work. 3641 22. Changes since RFC 5766 3643 This section lists the major changes in the TURN protocol from the 3644 original [RFC5766] specification. 3646 o IPv6 support. 3648 o REQUESTED-ADDRESS-FAMILY, ADDITIONAL-ADDRESS-FAMILY, AND ADDRESS- 3649 ERR-CODE attributes. 3651 o 440 (Address Family not Supported) and 443 (Peer Address Family 3652 Mismatch) responses. 3654 o Description of the tunnel amplification attack. 3656 o DTLS support. 3658 o More details on packet translations. 3660 o Add support for receiving ICMP packets. 3662 o Updates PMTUD. 3664 23. Acknowledgements 3666 Most of the text in this note comes from the original TURN 3667 specification, [RFC5766]. The authors would like to thank Rohan Mahy 3668 co-author of original TURN specification and everyone who had 3669 contributed to that document. The authors would also like to 3670 acknowledge that this document inherits material from [RFC6156]. 3672 Thanks to Justin Uberti, Pal Martinsen, Oleg Moskalenko, Aijun Wang 3673 and Simon Perreault for their help on the ADDITIONAL-ADDRESS-FAMILY 3674 mechanism. Authors would like to thank Gonzalo Salgueiro, Simon 3675 Perreault, Jonathan Lennox, Brandon Williams, Karl Stahl, Noriyuki 3676 Torii, Nils Ohlmeier, Dan Wing, Justin Uberti and Oleg Moskalenko for 3677 comments and review. The authors would like to thank Marc for his 3678 contributions to the text. Thanks to Eric Rescorla for proposing the 3679 update to allow the TURN server to forward inbound STUN connectivity 3680 checks without permission. 3682 24. References 3684 24.1. Normative References 3686 [I-D.ietf-tram-stunbis] 3687 Petit-Huguenin, M., Salgueiro, G., Rosenberg, J., Wing, 3688 D., Mahy, R., and P. Matthews, "Session Traversal 3689 Utilities for NAT (STUN)", draft-ietf-tram-stunbis-18 3690 (work in progress), May 2018. 3692 [RFC0792] Postel, J., "Internet Control Message Protocol", STD 5, 3693 RFC 792, DOI 10.17487/RFC0792, September 1981, 3694 . 3696 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 3697 Communication Layers", STD 3, RFC 1122, 3698 DOI 10.17487/RFC1122, October 1989, 3699 . 3701 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3702 Requirement Levels", BCP 14, RFC 2119, 3703 DOI 10.17487/RFC2119, March 1997, 3704 . 3706 [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black, 3707 "Definition of the Differentiated Services Field (DS 3708 Field) in the IPv4 and IPv6 Headers", RFC 2474, 3709 DOI 10.17487/RFC2474, December 1998, 3710 . 3712 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 3713 of Explicit Congestion Notification (ECN) to IP", 3714 RFC 3168, DOI 10.17487/RFC3168, September 2001, 3715 . 3717 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 3718 Control Message Protocol (ICMPv6) for the Internet 3719 Protocol Version 6 (IPv6) Specification", STD 89, 3720 RFC 4443, DOI 10.17487/RFC4443, March 2006, 3721 . 3723 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 3724 (TLS) Protocol Version 1.2", RFC 5246, 3725 DOI 10.17487/RFC5246, August 2008, 3726 . 3728 [RFC6347] Rescorla, E. and N. Modadugu, "Datagram Transport Layer 3729 Security Version 1.2", RFC 6347, DOI 10.17487/RFC6347, 3730 January 2012, . 3732 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 3733 "IPv6 Flow Label Specification", RFC 6437, 3734 DOI 10.17487/RFC6437, November 2011, 3735 . 3737 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3738 "Default Address Selection for Internet Protocol Version 6 3739 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3740 . 3742 [RFC7065] Petit-Huguenin, M., Nandakumar, S., Salgueiro, G., and P. 3743 Jones, "Traversal Using Relays around NAT (TURN) Uniform 3744 Resource Identifiers", RFC 7065, DOI 10.17487/RFC7065, 3745 November 2013, . 3747 [RFC7915] Bao, C., Li, X., Baker, F., Anderson, T., and F. Gont, 3748 "IP/ICMP Translation Algorithm", RFC 7915, 3749 DOI 10.17487/RFC7915, June 2016, 3750 . 3752 [RFC8305] Schinazi, D. and T. Pauly, "Happy Eyeballs Version 2: 3753 Better Connectivity Using Concurrency", RFC 8305, 3754 DOI 10.17487/RFC8305, December 2017, 3755 . 3757 24.2. Informative References 3759 [Frag-Harmful] 3760 "Fragmentation Considered Harmful", . 3763 [I-D.ietf-tram-stun-pmtud] 3764 Petit-Huguenin, M. and G. Salgueiro, "Path MTU Discovery 3765 Using Session Traversal Utilities for NAT (STUN)", draft- 3766 ietf-tram-stun-pmtud-10 (work in progress), September 3767 2018. 3769 [I-D.rosenberg-mmusic-ice-nonsip] 3770 Rosenberg, J., "Guidelines for Usage of Interactive 3771 Connectivity Establishment (ICE) by non Session Initiation 3772 Protocol (SIP) Protocols", draft-rosenberg-mmusic-ice- 3773 nonsip-01 (work in progress), July 2008. 3775 [Port-Numbers] 3776 "IANA Port Numbers Registry", 2005, 3777 . 3779 [Protocol-Numbers] 3780 "IANA Protocol Numbers Registry", 2005, 3781 . 3783 [RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791, 3784 DOI 10.17487/RFC0791, September 1981, 3785 . 3787 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 3788 DOI 10.17487/RFC1191, November 1990, 3789 . 3791 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3792 and E. Lear, "Address Allocation for Private Internets", 3793 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3794 . 3796 [RFC1928] Leech, M., Ganis, M., Lee, Y., Kuris, R., Koblas, D., and 3797 L. Jones, "SOCKS Protocol Version 5", RFC 1928, 3798 DOI 10.17487/RFC1928, March 1996, 3799 . 3801 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3802 A., Peterson, J., Sparks, R., Handley, M., and E. 3803 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3804 DOI 10.17487/RFC3261, June 2002, 3805 . 3807 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3808 UNilateral Self-Address Fixing (UNSAF) Across Network 3809 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3810 November 2002, . 3812 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3813 Jacobson, "RTP: A Transport Protocol for Real-Time 3814 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3815 July 2003, . 3817 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3818 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3819 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3820 . 3822 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 3823 "Randomness Requirements for Security", BCP 106, RFC 4086, 3824 DOI 10.17487/RFC4086, June 2005, 3825 . 3827 [RFC4302] Kent, S., "IP Authentication Header", RFC 4302, 3828 DOI 10.17487/RFC4302, December 2005, 3829 . 3831 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 3832 RFC 4303, DOI 10.17487/RFC4303, December 2005, 3833 . 3835 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3836 Translation (NAT) Behavioral Requirements for Unicast 3837 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3838 2007, . 3840 [RFC4821] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 3841 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 3842 . 3844 [RFC5128] Srisuresh, P., Ford, B., and D. Kegel, "State of Peer-to- 3845 Peer (P2P) Communication across Network Address 3846 Translators (NATs)", RFC 5128, DOI 10.17487/RFC5128, March 3847 2008, . 3849 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3850 (ICE): A Protocol for Network Address Translator (NAT) 3851 Traversal for Offer/Answer Protocols", RFC 5245, 3852 DOI 10.17487/RFC5245, April 2010, 3853 . 3855 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3856 Relays around NAT (TURN): Relay Extensions to Session 3857 Traversal Utilities for NAT (STUN)", RFC 5766, 3858 DOI 10.17487/RFC5766, April 2010, 3859 . 3861 [RFC5928] Petit-Huguenin, M., "Traversal Using Relays around NAT 3862 (TURN) Resolution Mechanism", RFC 5928, 3863 DOI 10.17487/RFC5928, August 2010, 3864 . 3866 [RFC6056] Larsen, M. and F. Gont, "Recommendations for Transport- 3867 Protocol Port Randomization", BCP 156, RFC 6056, 3868 DOI 10.17487/RFC6056, January 2011, 3869 . 3871 [RFC6062] Perreault, S., Ed. and J. Rosenberg, "Traversal Using 3872 Relays around NAT (TURN) Extensions for TCP Allocations", 3873 RFC 6062, DOI 10.17487/RFC6062, November 2010, 3874 . 3876 [RFC6156] Camarillo, G., Novo, O., and S. Perreault, Ed., "Traversal 3877 Using Relays around NAT (TURN) Extension for IPv6", 3878 RFC 6156, DOI 10.17487/RFC6156, April 2011, 3879 . 3881 [RFC7635] Reddy, T., Patil, P., Ravindranath, R., and J. Uberti, 3882 "Session Traversal Utilities for NAT (STUN) Extension for 3883 Third-Party Authorization", RFC 7635, 3884 DOI 10.17487/RFC7635, August 2015, 3885 . 3887 [RFC7983] Petit-Huguenin, M. and G. Salgueiro, "Multiplexing Scheme 3888 Updates for Secure Real-time Transport Protocol (SRTP) 3889 Extension for Datagram Transport Layer Security (DTLS)", 3890 RFC 7983, DOI 10.17487/RFC7983, September 2016, 3891 . 3893 [RFC8155] Patil, P., Reddy, T., and D. Wing, "Traversal Using Relays 3894 around NAT (TURN) Server Auto Discovery", RFC 8155, 3895 DOI 10.17487/RFC8155, April 2017, 3896 . 3898 Authors' Addresses 3900 Tirumaleswar Reddy (editor) 3901 McAfee, Inc. 3902 Embassy Golf Link Business Park 3903 Bangalore, Karnataka 560071 3904 India 3906 Email: kondtir@gmail.com 3908 Alan Johnston (editor) 3909 Rowan University 3910 Glassboro, NJ 3911 USA 3913 Email: alan.b.johnston@gmail.com 3914 Philip Matthews 3915 Alcatel-Lucent 3916 600 March Road 3917 Ottawa, Ontario 3918 Canada 3920 Email: philip_matthews@magma.ca 3922 Jonathan Rosenberg 3923 jdrosen.net 3924 Edison, NJ 3925 USA 3927 Email: jdrosen@jdrosen.net 3928 URI: http://www.jdrosen.net