idnits 2.17.1 draft-ietf-tram-turnbis-18.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 (May 29, 2018) is 2158 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-08 -- 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: November 30, 2018 P. Matthews 7 Alcatel-Lucent 8 J. Rosenberg 9 jdrosen.net 10 May 29, 2018 12 Traversal Using Relays around NAT (TURN): Relay Extensions to Session 13 Traversal Utilities for NAT (STUN) 14 draft-ietf-tram-turnbis-18 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 November 30, 2018. 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 . . . . . . . . . . . 38 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 . . . . . . . . . . . . 48 112 12.7. Relaying Data from the Peer . . . . . . . . . . . . . . 49 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 . . . . . . . . . . . . . . . 52 117 14. IP Header Fields . . . . . . . . . . . . . . . . . . . . . . 53 118 15. STUN Methods . . . . . . . . . . . . . . . . . . . . . . . . 55 119 16. STUN Attributes . . . . . . . . . . . . . . . . . . . . . . . 55 120 16.1. CHANNEL-NUMBER . . . . . . . . . . . . . . . . . . . . . 55 121 16.2. LIFETIME . . . . . . . . . . . . . . . . . . . . . . . . 56 122 16.3. XOR-PEER-ADDRESS . . . . . . . . . . . . . . . . . . . . 56 123 16.4. DATA . . . . . . . . . . . . . . . . . . . . . . . . . . 56 124 16.5. XOR-RELAYED-ADDRESS . . . . . . . . . . . . . . . . . . 56 125 16.6. REQUESTED-ADDRESS-FAMILY . . . . . . . . . . . . . . . . 56 126 16.7. EVEN-PORT . . . . . . . . . . . . . . . . . . . . . . . 57 127 16.8. REQUESTED-TRANSPORT . . . . . . . . . . . . . . . . . . 57 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 . . . . . . . . . . . . . . 58 132 16.13. ICMP Attribute . . . . . . . . . . . . . . . . . . . . . 59 133 17. STUN Error Response Codes . . . . . . . . . . . . . . . . . . 59 134 18. Detailed Example . . . . . . . . . . . . . . . . . . . . . . 60 135 19. Security Considerations . . . . . . . . . . . . . . . . . . . 68 136 19.1. Outsider Attacks . . . . . . . . . . . . . . . . . . . . 68 137 19.1.1. Obtaining Unauthorized Allocations . . . . . . . . . 68 138 19.1.2. Offline Dictionary Attacks . . . . . . . . . . . . . 68 139 19.1.3. Faked Refreshes and Permissions . . . . . . . . . . 69 140 19.1.4. Fake Data . . . . . . . . . . . . . . . . . . . . . 69 141 19.1.5. Impersonating a Server . . . . . . . . . . . . . . . 70 142 19.1.6. Eavesdropping Traffic . . . . . . . . . . . . . . . 70 143 19.1.7. TURN Loop Attack . . . . . . . . . . . . . . . . . . 71 144 19.2. Firewall Considerations . . . . . . . . . . . . . . . . 71 145 19.2.1. Faked Permissions . . . . . . . . . . . . . . . . . 72 146 19.2.2. Blacklisted IP Addresses . . . . . . . . . . . . . . 73 147 19.2.3. Running Servers on Well-Known Ports . . . . . . . . 73 148 19.3. Insider Attacks . . . . . . . . . . . . . . . . . . . . 73 149 19.3.1. DoS against TURN Server . . . . . . . . . . . . . . 73 150 19.3.2. Anonymous Relaying of Malicious Traffic . . . . . . 74 151 19.3.3. Manipulating Other Allocations . . . . . . . . . . . 74 152 19.4. Tunnel Amplification Attack . . . . . . . . . . . . . . 74 153 19.5. Other Considerations . . . . . . . . . . . . . . . . . . 75 154 20. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 75 155 21. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 76 156 22. Changes since RFC 5766 . . . . . . . . . . . . . . . . . . . 78 157 23. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 78 158 24. References . . . . . . . . . . . . . . . . . . . . . . . . . 79 159 24.1. Normative References . . . . . . . . . . . . . . . . . . 79 160 24.2. Informative References . . . . . . . . . . . . . . . . . 80 161 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 83 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 | | | | 472 |<--------------- Allocate failure --| | | 473 | (401 Unauthenticated) | | | 474 | | | | 475 |-- Allocate request --------------->| | | 476 | | | | 477 |<---------- Allocate success resp --| | | 478 | (192.0.2.15:50000) | | | 479 // // // // 480 | | | | 481 |-- Refresh request ---------------->| | | 482 | | | | 483 |<----------- Refresh success resp --| | | 484 | | | | 486 Figure 2 488 In Figure 2, the client sends an Allocate request to the server 489 without credentials. Since the server requires that all requests be 490 authenticated using STUN's long-term credential mechanism, the server 491 rejects the request with a 401 (Unauthorized) error code. The client 492 then tries again, this time including credentials (not shown). This 493 time, the server accepts the Allocate request and returns an Allocate 494 success response containing (amongst other things) the relayed 495 transport address assigned to the allocation. Sometime later, the 496 client decides to refresh the allocation and thus sends a Refresh 497 request to the server. The refresh is accepted and the server 498 replies with a Refresh success response. 500 2.3. Permissions 502 To ease concerns amongst enterprise IT administrators that TURN could 503 be used to bypass corporate firewall security, TURN includes the 504 notion of permissions. TURN permissions mimic the address-restricted 505 filtering mechanism of NATs that comply with [RFC4787]. 507 An allocation can have zero or more permissions. Each permission 508 consists of an IP address and a lifetime. When the server receives a 509 UDP datagram on the allocation's relayed transport address, it first 510 checks the list of permissions. If the source IP address of the 511 datagram matches a permission, the application data is relayed to the 512 client, otherwise the UDP datagram is silently discarded. A TURN 513 server can be configured to permit inbound STUN packets on the 514 allocation's relayed address even if the source IP addresses of the 515 STUN packets do not match the permissions installed. The filtering 516 rule to block all traffic except STUN packets speeds up STUN 517 connectivity checks, allowing the remote peer to initiate 518 connectivity checks to the client while the client is creating 519 permissions in the TURN server for the remote peer IP addresses. 521 A permission expires after 5 minutes if it is not refreshed, and 522 there is no way to explicitly delete a permission. This behavior was 523 selected to match the behavior of a NAT that complies with [RFC4787]. 525 The client can install or refresh a permission using either a 526 CreatePermission request or a ChannelBind request. Using the 527 CreatePermission request, multiple permissions can be installed or 528 refreshed with a single request -- this is important for applications 529 that use ICE. For security reasons, permissions can only be 530 installed or refreshed by transactions that can be authenticated; 531 thus, Send indications and ChannelData messages (which are used to 532 send data to peers) do not install or refresh any permissions. 534 Note that permissions are within the context of an allocation, so 535 adding or expiring a permission in one allocation does not affect 536 other allocations. 538 2.4. Send Mechanism 540 There are two mechanisms for the client and peers to exchange 541 application data using the TURN server. The first mechanism uses the 542 Send and Data methods, the second mechanism uses channels. Common to 543 both mechanisms is the ability of the client to communicate with 544 multiple peers using a single allocated relayed transport address; 545 thus, both mechanisms include a means for the client to indicate to 546 the server which peer should receive the data, and for the server to 547 indicate to the client which peer sent the data. 549 The Send mechanism uses Send and Data indications. Send indications 550 are used to send application data from the client to the server, 551 while Data indications are used to send application data from the 552 server to the client. 554 When using the Send mechanism, the client sends a Send indication to 555 the TURN server containing (a) an XOR-PEER-ADDRESS attribute 556 specifying the (server-reflexive) transport address of the peer and 557 (b) a DATA attribute holding the application data. When the TURN 558 server receives the Send indication, it extracts the application data 559 from the DATA attribute and sends it in a UDP datagram to the peer, 560 using the allocated relay address as the source address. Note that 561 there is no need to specify the relayed transport address, since it 562 is implied by the 5-tuple used for the Send indication. 564 In the reverse direction, UDP datagrams arriving at the relayed 565 transport address on the TURN server are converted into Data 566 indications and sent to the client, with the server-reflexive 567 transport address of the peer included in an XOR-PEER-ADDRESS 568 attribute and the data itself in a DATA attribute. Since the relayed 569 transport address uniquely identified the allocation, the server 570 knows which client should receive the data. 572 Some ICMP (Internet Control Message Protocol) packets arriving at the 573 relayed transport address on the TURN server may be converted into 574 Data indications and sent to the client, with the transport address 575 of the peer included in an XOR-PEER-ADDRESS attribute and the ICMP 576 type and code in a ICMP attribute. ICMP attribute forwarding always 577 uses Data indications containing the XOR-PEER-ADDRESS and ICMP 578 attributes, even when using the channel mechanism to forward UDP 579 data. 581 Send and Data indications cannot be authenticated, since the long- 582 term credential mechanism of STUN does not support authenticating 583 indications. This is not as big an issue as it might first appear, 584 since the client-to-server leg is only half of the total path to the 585 peer. Applications that want proper security should encrypt the data 586 sent between the client and a peer. 588 Because Send indications are not authenticated, it is possible for an 589 attacker to send bogus Send indications to the server, which will 590 then relay these to a peer. To partly mitigate this attack, TURN 591 requires that the client install a permission towards a peer before 592 sending data to it using a Send indication. 594 TURN TURN Peer Peer 595 client server A B 596 | | | | 597 |-- CreatePermission req (Peer A) -->| | | 598 |<-- CreatePermission success resp --| | | 599 | | | | 600 |--- Send ind (Peer A)-------------->| | | 601 | |=== data ===>| | 602 | | | | 603 | |<== data ====| | 604 |<-------------- Data ind (Peer A) --| | | 605 | | | | 606 | | | | 607 |--- Send ind (Peer B)-------------->| | | 608 | | dropped | | 609 | | | | 610 | |<== data ==================| 611 | dropped | | | 612 | | | | 614 Figure 3 616 In Figure 3, the client has already created an allocation and now 617 wishes to send data to its peers. The client first creates a 618 permission by sending the server a CreatePermission request 619 specifying Peer A's (server-reflexive) IP address in the XOR-PEER- 620 ADDRESS attribute; if this was not done, the server would not relay 621 data between the client and the server. The client then sends data 622 to Peer A using a Send indication; at the server, the application 623 data is extracted and forwarded in a UDP datagram to Peer A, using 624 the relayed transport address as the source transport address. When 625 a UDP datagram from Peer A is received at the relayed transport 626 address, the contents are placed into a Data indication and forwarded 627 to the client. Later, the client attempts to exchange data with Peer 628 B; however, no permission has been installed for Peer B, so the Send 629 indication from the client and the UDP datagram from the peer are 630 both dropped by the server. 632 2.5. Channels 634 For some applications (e.g., Voice over IP), the 36 bytes of overhead 635 that a Send indication or Data indication adds to the application 636 data can substantially increase the bandwidth required between the 637 client and the server. To remedy this, TURN offers a second way for 638 the client and server to associate data with a specific peer. 640 This second way uses an alternate packet format known as the 641 ChannelData message. The ChannelData message does not use the STUN 642 header used by other TURN messages, but instead has a 4-byte header 643 that includes a number known as a channel number. Each channel 644 number in use is bound to a specific peer and thus serves as a 645 shorthand for the peer's host transport address. 647 To bind a channel to a peer, the client sends a ChannelBind request 648 to the server, and includes an unbound channel number and the 649 transport address of the peer. Once the channel is bound, the client 650 can use a ChannelData message to send the server data destined for 651 the peer. Similarly, the server can relay data from that peer 652 towards the client using a ChannelData message. 654 Channel bindings last for 10 minutes unless refreshed -- this 655 lifetime was chosen to be longer than the permission lifetime. 656 Channel bindings are refreshed by sending another ChannelBind request 657 rebinding the channel to the peer. Like permissions (but unlike 658 allocations), there is no way to explicitly delete a channel binding; 659 the client must simply wait for it to time out. 661 TURN TURN Peer Peer 662 client server A B 663 | | | | 664 |-- ChannelBind req ---------------->| | | 665 | (Peer A to 0x4001) | | | 666 | | | | 667 |<---------- ChannelBind succ resp --| | | 668 | | | | 669 |-- (0x4001) data ------------------>| | | 670 | |=== data ===>| | 671 | | | | 672 | |<== data ====| | 673 |<------------------ (0x4001) data --| | | 674 | | | | 675 |--- Send ind (Peer A)-------------->| | | 676 | |=== data ===>| | 677 | | | | 678 | |<== data ====| | 679 |<------------------ (0x4001) data --| | | 680 | | | | 682 Figure 4 684 Figure 4 shows the channel mechanism in use. The client has already 685 created an allocation and now wishes to bind a channel to Peer A. To 686 do this, the client sends a ChannelBind request to the server, 687 specifying the transport address of Peer A and a channel number 688 (0x4001). After that, the client can send application data 689 encapsulated inside ChannelData messages to Peer A: this is shown as 690 "(0x4001) data" where 0x4001 is the channel number. When the 691 ChannelData message arrives at the server, the server transfers the 692 data to a UDP datagram and sends it to Peer A (which is the peer 693 bound to channel number 0x4001). 695 In the reverse direction, when Peer A sends a UDP datagram to the 696 relayed transport address, this UDP datagram arrives at the server on 697 the relayed transport address assigned to the allocation. Since the 698 UDP datagram was received from Peer A, which has a channel number 699 assigned to it, the server encapsulates the data into a ChannelData 700 message when sending the data to the client. 702 Once a channel has been bound, the client is free to intermix 703 ChannelData messages and Send indications. In the figure, the client 704 later decides to use a Send indication rather than a ChannelData 705 message to send additional data to Peer A. The client might decide 706 to do this, for example, so it can use the DONT-FRAGMENT attribute 707 (see the next section). However, once a channel is bound, the server 708 will always use a ChannelData message, as shown in the call flow. 710 Note that ChannelData messages can only be used for peers to which 711 the client has bound a channel. In the example above, Peer A has 712 been bound to a channel, but Peer B has not, so application data to 713 and from Peer B would use the Send mechanism. 715 2.6. Unprivileged TURN Servers 717 This version of TURN is designed so that the server can be 718 implemented as an application that runs in user space under commonly 719 available operating systems without requiring special privileges. 720 This design decision was made to make it easy to deploy a TURN 721 server: for example, to allow a TURN server to be integrated into a 722 peer-to-peer application so that one peer can offer NAT traversal 723 services to another peer. 725 This design decision has the following implications for data relayed 726 by a TURN server: 728 o The value of the Diffserv field may not be preserved across the 729 server; 731 o The Time to Live (TTL) field may be reset, rather than 732 decremented, across the server; 734 o The Explicit Congestion Notification (ECN) field may be reset by 735 the server; 737 o There is no end-to-end fragmentation, since the packet is re- 738 assembled at the server. 740 Future work may specify alternate TURN semantics that address these 741 limitations. 743 2.7. Avoiding IP Fragmentation 745 For reasons described in [Frag-Harmful], applications, especially 746 those sending large volumes of data, should try hard to avoid having 747 their packets fragmented. Applications using TCP can more or less 748 ignore this issue because fragmentation avoidance is now a standard 749 part of TCP, but applications using UDP (and thus any application 750 using this version of TURN) must handle fragmentation avoidance 751 themselves. 753 The application running on the client and the peer can take one of 754 two approaches to avoid IP fragmentation. 756 The first approach is to avoid sending large amounts of application 757 data in the TURN messages/UDP datagrams exchanged between the client 758 and the peer. This is the approach taken by most VoIP (Voice-over- 759 IP) applications. In this approach, the application exploits the 760 fact that the IP specification [RFC0791] specifies that IP packets up 761 to 576 bytes should never need to be fragmented. 763 The exact amount of application data that can be included while 764 avoiding fragmentation depends on the details of the TURN session 765 between the client and the server: whether UDP, TCP, or (D)TLS 766 transport is used, whether ChannelData messages or Send/Data 767 indications are used, and whether any additional attributes (such as 768 the DONT-FRAGMENT attribute) are included. Another factor, which is 769 hard to determine, is whether the MTU is reduced somewhere along the 770 path for other reasons, such as the use of IP-in-IP tunneling. 772 As a guideline, sending a maximum of 500 bytes of application data in 773 a single TURN message (by the client on the client-to-server leg) or 774 a UDP datagram (by the peer on the peer-to-server leg) will generally 775 avoid IP fragmentation. To further reduce the chance of 776 fragmentation, it is recommended that the client use ChannelData 777 messages when transferring significant volumes of data, since the 778 overhead of the ChannelData message is less than Send and Data 779 indications. 781 The second approach the client and peer can take to avoid 782 fragmentation is to use a path MTU discovery algorithm to determine 783 the maximum amount of application data that can be sent without 784 fragmentation. The classic path MTU discovery algorithm defined in 786 [RFC1191] may not be able to discover the MTU of the transmission 787 path between the client and the peer since: 789 - a probe packet with DF bit set to test a path for a larger MTU 790 can be dropped by routers, or 792 - ICMP error messages can be dropped by middle boxes. 794 As a result, the client and server need to use a path MTU discovery 795 algorithm that does not require ICMP messages. The Packetized Path 796 MTU Discovery algorithm defined in [RFC4821] is one such algorithm. 798 [I-D.ietf-tram-stun-pmtud] is an implementation of [RFC4821] that 799 uses STUN to discover the path MTU, and so might be a suitable 800 approach to be used in conjunction with a TURN server that supports 801 the DONT-FRAGMENT attribute. When the client includes the DONT- 802 FRAGMENT attribute in a Send indication, this tells the server to set 803 the DF bit in the resulting UDP datagram that it sends to the peer. 804 Since some servers may be unable to set the DF bit, the client should 805 also include this attribute in the Allocate request -- any server 806 that does not support the DONT-FRAGMENT attribute will indicate this 807 by rejecting the Allocate request. 809 2.8. RTP Support 811 One of the envisioned uses of TURN is as a relay for clients and 812 peers wishing to exchange real-time data (e.g., voice or video) using 813 RTP. To facilitate the use of TURN for this purpose, TURN includes 814 some special support for older versions of RTP. 816 Old versions of RTP [RFC3550] required that the RTP stream be on an 817 even port number and the associated RTP Control Protocol (RTCP) 818 stream, if present, be on the next highest port. To allow clients to 819 work with peers that still require this, TURN allows the client to 820 request that the server allocate a relayed transport address with an 821 even port number, and to optionally request the server reserve the 822 next-highest port number for a subsequent allocation. 824 2.9. Happy Eyeballs for TURN 826 If an IPv4 path to reach a TURN server is found, but the TURN 827 server's IPv6 path is not working, a dual-stack TURN client can 828 experience a significant connection delay compared to an IPv4-only 829 TURN client. To overcome these connection setup problems, the TURN 830 client MUST query both A and AAAA records for the TURN server 831 specified using a domain name and try connecting to the TURN server 832 using both IPv6 and IPv4 addresses in a fashion similar to the Happy 833 Eyeballs mechanism defined in [RFC8305]. The TURN client performs 834 the following steps based on the transport protocol being used to 835 connect to the TURN server. 837 o For TCP or TLS-over-TCP, initiate TCP connection to both IP 838 address families as discussed in [RFC8305], and use the first TCP 839 connection that is established. If connections are established on 840 both IP address families then terminate the TCP connection using 841 the IP address family with lower precedence [RFC6724]. 843 o For clear text UDP, send TURN Allocate requests to both IP address 844 families as discussed in [RFC8305], without authentication 845 information. If the TURN server requires authentication, it will 846 send back a 401 unauthenticated response and the TURN client uses 847 the first UDP connection on which a 401 error response is 848 received. If a 401 error response is received from both IP 849 address families then the TURN client can silently abandon the UDP 850 connection on the IP address family with lower precedence. If the 851 TURN server does not require authentication (as described in 852 Section 9 of [RFC8155]), it is possible for both Allocate requests 853 to succeed. In this case, the TURN client sends a Refresh with 854 LIFETIME value of 0 on the allocation using the IP address family 855 with lower precedence to delete the allocation. 857 o For DTLS over UDP, initiate DTLS handshake to both IP address 858 families as discussed in [RFC8305] and use the first DTLS session 859 that is established. If the DTLS session is established on both 860 IP address families then the client sends DTLS close_notify alert 861 to terminate the DTLS session using the IP address family with 862 lower precedence. If TURN over DTLS server has been configured to 863 require a cookie exchange (Section 4.2 in [RFC6347]) and 864 HelloVerifyRequest is received from the TURN servers on both IP 865 address families then the client can silently abandon the 866 connection on the IP address family with lower precedence. 868 3. Terminology 870 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 871 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 872 document are to be interpreted as described in RFC 2119 [RFC2119]. 874 Readers are expected to be familiar with [I-D.ietf-tram-stunbis] and 875 the terms defined there. 877 The following terms are used in this document: 879 TURN: The protocol spoken between a TURN client and a TURN server. 880 It is an extension to the STUN protocol [I-D.ietf-tram-stunbis]. 882 The protocol allows a client to allocate and use a relayed 883 transport address. 885 TURN client: A STUN client that implements this specification. 887 TURN server: A STUN server that implements this specification. It 888 relays data between a TURN client and its peer(s). 890 Peer: A host with which the TURN client wishes to communicate. The 891 TURN server relays traffic between the TURN client and its 892 peer(s). The peer does not interact with the TURN server using 893 the protocol defined in this document; rather, the peer receives 894 data sent by the TURN server and the peer sends data towards the 895 TURN server. 897 Transport Address: The combination of an IP address and a port. 899 Host Transport Address: A transport address on a client or a peer. 901 Server-Reflexive Transport Address: A transport address on the 902 "public side" of a NAT. This address is allocated by the NAT to 903 correspond to a specific host transport address. 905 Relayed Transport Address: A transport address on the TURN server 906 that is used for relaying packets between the client and a peer. 907 A peer sends to this address on the TURN server, and the packet is 908 then relayed to the client. 910 TURN Server Transport Address: A transport address on the TURN 911 server that is used for sending TURN messages to the server. This 912 is the transport address that the client uses to communicate with 913 the server. 915 Peer Transport Address: The transport address of the peer as seen by 916 the server. When the peer is behind a NAT, this is the peer's 917 server-reflexive transport address. 919 Allocation: The relayed transport address granted to a client 920 through an Allocate request, along with related state, such as 921 permissions and expiration timers. 923 5-tuple: The combination (client IP address and port, server IP 924 address and port, and transport protocol (currently one of UDP, 925 TCP, or (D)TLS)) used to communicate between the client and the 926 server. The 5-tuple uniquely identifies this communication 927 stream. The 5-tuple also uniquely identifies the Allocation on 928 the server. 930 Channel: A channel number and associated peer transport address. 931 Once a channel number is bound to a peer's transport address, the 932 client and server can use the more bandwidth-efficient ChannelData 933 message to exchange data. 935 Permission: The IP address and transport protocol (but not the port) 936 of a peer that is permitted to send traffic to the TURN server and 937 have that traffic relayed to the TURN client. The TURN server 938 will only forward traffic to its client from peers that match an 939 existing permission. 941 Realm: A string used to describe the server or a context within the 942 server. The realm tells the client which username and password 943 combination to use to authenticate requests. 945 Nonce: A string chosen at random by the server and included in the 946 message-digest. To prevent replay attacks, the server should 947 change the nonce regularly. 949 (D)TLS: This term is used for statements that apply to both 950 Transport Layer Security [RFC5246] and Datagram Transport Layer 951 Security [RFC6347]. 953 4. Discovery of TURN server 955 Methods of TURN server discovery, including using anycast, are 956 described in [RFC8155]. The syntax of the "turn" and "turns" URIs 957 are defined in Section 3.1 of [RFC7065]. 959 4.1. TURN URI Scheme Semantics 961 The "turn" and "turns" URI schemes are used to designate a TURN 962 server (also known as a relay) on Internet hosts accessible using the 963 TURN protocol. The TURN protocol supports sending messages over UDP, 964 TCP, TLS-over-TCP or DTLS-over-UDP. The "turns" URI scheme MUST be 965 used when TURN is run over TLS-over-TCP or in DTLS-over-UDP, and the 966 "turn" scheme MUST be used otherwise. The required part of 967 the "turn" URI denotes the TURN server host. The part, if 968 present, denotes the port on which the TURN server is awaiting 969 connection requests. If it is absent, the default port is 3478 for 970 both UDP and TCP. The default port for TURN over TLS and TURN over 971 DTLS is 5349. 973 5. General Behavior 975 This section contains general TURN processing rules that apply to all 976 TURN messages. 978 TURN is an extension to STUN. All TURN messages, with the exception 979 of the ChannelData message, are STUN-formatted messages. All the 980 base processing rules described in [I-D.ietf-tram-stunbis] apply to 981 STUN-formatted messages. This means that all the message-forming and 982 message-processing descriptions in this document are implicitly 983 prefixed with the rules of [I-D.ietf-tram-stunbis]. 985 [I-D.ietf-tram-stunbis] specifies an authentication mechanism called 986 the long-term credential mechanism. TURN servers and clients MUST 987 implement this mechanism. The server MUST demand that all requests 988 from the client be authenticated using this mechanism, or that a 989 equally strong or stronger mechanism for client authentication is 990 used. 992 Note that the long-term credential mechanism applies only to requests 993 and cannot be used to authenticate indications; thus, indications in 994 TURN are never authenticated. If the server requires requests to be 995 authenticated, then the server's administrator MUST choose a realm 996 value that will uniquely identify the username and password 997 combination that the client must use, even if the client uses 998 multiple servers under different administrations. The server's 999 administrator MAY choose to allocate a unique username to each 1000 client, or MAY choose to allocate the same username to more than one 1001 client (for example, to all clients from the same department or 1002 company). For each Allocate request, the server SHOULD generate a 1003 new random nonce when the allocation is first attempted following the 1004 randomness recommendations in [RFC4086] and SHOULD expire the nonce 1005 at least once every hour during the lifetime of the allocation. 1007 All requests after the initial Allocate must use the same username as 1008 that used to create the allocation, to prevent attackers from 1009 hijacking the client's allocation. Specifically, if the server 1010 requires the use of the long-term credential mechanism, and if a non- 1011 Allocate request passes authentication under this mechanism, and if 1012 the 5-tuple identifies an existing allocation, but the request does 1013 not use the same username as used to create the allocation, then the 1014 request MUST be rejected with a 441 (Wrong Credentials) error. 1016 When a TURN message arrives at the server from the client, the server 1017 uses the 5-tuple in the message to identify the associated 1018 allocation. For all TURN messages (including ChannelData) EXCEPT an 1019 Allocate request, if the 5-tuple does not identify an existing 1020 allocation, then the message MUST either be rejected with a 437 1021 Allocation Mismatch error (if it is a request) or silently ignored 1022 (if it is an indication or a ChannelData message). A client 1023 receiving a 437 error response to a request other than Allocate MUST 1024 assume the allocation no longer exists. 1026 [I-D.ietf-tram-stunbis] defines a number of attributes, including the 1027 SOFTWARE and FINGERPRINT attributes. The client SHOULD include the 1028 SOFTWARE attribute in all Allocate and Refresh requests and MAY 1029 include it in any other requests or indications. The server SHOULD 1030 include the SOFTWARE attribute in all Allocate and Refresh responses 1031 (either success or failure) and MAY include it in other responses or 1032 indications. The client and the server MAY include the FINGERPRINT 1033 attribute in any STUN-formatted messages defined in this document. 1035 TURN does not use the backwards-compatibility mechanism described in 1036 [I-D.ietf-tram-stunbis]. 1038 TURN, as defined in this specification, supports both IPv4 and IPv6. 1039 IPv6 support in TURN includes IPv4-to-IPv6, IPv6-to-IPv6, and IPv6- 1040 to-IPv4 relaying. The REQUESTED-ADDRESS-FAMILY attribute allows a 1041 client to explicitly request the address type the TURN server will 1042 allocate (e.g., an IPv4-only node may request the TURN server to 1043 allocate an IPv6 address). The ADDITIONAL-ADDRESS-FAMILY attribute 1044 allows a client to request the server to allocate one IPv4 and one 1045 IPv6 relay address in a single Allocate request. This saves local 1046 ports on the client and reduces the number of messages sent between 1047 the client and the TURN server. 1049 By default, TURN runs on the same ports as STUN: 3478 for TURN over 1050 UDP and TCP, and 5349 for TURN over (D)TLS. However, TURN has its 1051 own set of Service Record (SRV) names: "turn" for UDP and TCP, and 1052 "turns" for (D)TLS. Either the DNS resolution procedures or the 1053 ALTERNATE-SERVER procedures, both described in Section 7, can be used 1054 to run TURN on a different port. 1056 To ensure interoperability, a TURN server MUST support the use of UDP 1057 transport between the client and the server, and SHOULD support the 1058 use of TCP, TLS-over-TCP and DTLS-over-UDP transports. 1060 When UDP or DTLS-over-UDP transport is used between the client and 1061 the server, the client will retransmit a request if it does not 1062 receive a response within a certain timeout period. Because of this, 1063 the server may receive two (or more) requests with the same 5-tuple 1064 and same transaction id. STUN requires that the server recognize 1065 this case and treat the request as idempotent (see 1066 [I-D.ietf-tram-stunbis]). Some implementations may choose to meet 1067 this requirement by remembering all received requests and the 1068 corresponding responses for 40 seconds. Other implementations may 1069 choose to reprocess the request and arrange that such reprocessing 1070 returns essentially the same response. To aid implementors who 1071 choose the latter approach (the so-called "stateless stack 1072 approach"), this specification includes some implementation notes on 1073 how this might be done. Implementations are free to choose either 1074 approach or choose some other approach that gives the same results. 1076 When TCP transport is used between the client and the server, it is 1077 possible that a bit error will cause a length field in a TURN packet 1078 to become corrupted, causing the receiver to lose synchronization 1079 with the incoming stream of TURN messages. A client or server that 1080 detects a long sequence of invalid TURN messages over TCP transport 1081 SHOULD close the corresponding TCP connection to help the other end 1082 detect this situation more rapidly. 1084 To mitigate either intentional or unintentional denial-of-service 1085 attacks against the server by clients with valid usernames and 1086 passwords, it is RECOMMENDED that the server impose limits on both 1087 the number of allocations active at one time for a given username and 1088 on the amount of bandwidth those allocations can use. The server 1089 should reject new allocations that would exceed the limit on the 1090 allowed number of allocations active at one time with a 486 1091 (Allocation Quota Exceeded) (see Section 7.2), and should discard 1092 application data traffic that exceeds the bandwidth quota. 1094 6. Allocations 1096 All TURN operations revolve around allocations, and all TURN messages 1097 are associated with either a single or dual allocation. An 1098 allocation conceptually consists of the following state data: 1100 o the relayed transport address or addresses; 1102 o the 5-tuple: (client's IP address, client's port, server IP 1103 address, server port, transport protocol); 1105 o the authentication information; 1107 o the time-to-expiry for each relayed transport address; 1109 o a list of permissions for each relayed transport address; 1111 o a list of channel to peer bindings for each relayed transport 1112 address. 1114 The relayed transport address is the transport address allocated by 1115 the server for communicating with peers, while the 5-tuple describes 1116 the communication path between the client and the server. On the 1117 client, the 5-tuple uses the client's host transport address; on the 1118 server, the 5-tuple uses the client's server-reflexive transport 1119 address. The relayed transport address MUST be unique across all 1120 allocations, so it can be used to uniquely identify the allocation. 1122 Both the relayed transport address and the 5-tuple MUST be unique 1123 across all allocations, so either one can be used to uniquely 1124 identify the allocation, and an allocation in this context can be 1125 either a single or dual allocation. 1127 The authentication information (e.g., username, password, realm, and 1128 nonce) is used to both verify subsequent requests and to compute the 1129 message integrity of responses. The username, realm, and nonce 1130 values are initially those used in the authenticated Allocate request 1131 that creates the allocation, though the server can change the nonce 1132 value during the lifetime of the allocation using a 438 (Stale Nonce) 1133 reply. Note that, rather than storing the password explicitly, for 1134 security reasons, it may be desirable for the server to store the key 1135 value, which is a secure hash over the username, realm, and password 1136 (see [I-D.ietf-tram-stunbis]). 1138 The time-to-expiry is the time in seconds left until the allocation 1139 expires. Each Allocate or Refresh transaction sets this timer, which 1140 then ticks down towards 0. By default, each Allocate or Refresh 1141 transaction resets this timer to the default lifetime value of 600 1142 seconds (10 minutes), but the client can request a different value in 1143 the Allocate and Refresh request. Allocations can only be refreshed 1144 using the Refresh request; sending data to a peer does not refresh an 1145 allocation. When an allocation expires, the state data associated 1146 with the allocation can be freed. 1148 The list of permissions is described in Section 9 and the list of 1149 channels is described in Section 12. 1151 7. Creating an Allocation 1153 An allocation on the server is created using an Allocate transaction. 1155 7.1. Sending an Allocate Request 1157 The client forms an Allocate request as follows. 1159 The client first picks a host transport address. It is RECOMMENDED 1160 that the client pick a currently unused transport address, typically 1161 by allowing the underlying OS to pick a currently unused port for a 1162 new socket. 1164 The client then picks a transport protocol to use between the client 1165 and the server. The transport protocol MUST be one of UDP, TCP, TLS- 1166 over-TCP or DTLS-over-UDP. Since this specification only allows UDP 1167 between the server and the peers, it is RECOMMENDED that the client 1168 pick UDP unless it has a reason to use a different transport. One 1169 reason to pick a different transport would be that the client 1170 believes, either through configuration or by experiment, that it is 1171 unable to contact any TURN server using UDP. See Section 2.1 for 1172 more discussion. 1174 The client also picks a server transport address, which SHOULD be 1175 done as follows. The client uses one or more procedures described in 1176 [RFC8155] to discover a TURN server and uses the TURN server 1177 resolution mechanism defined in [RFC5928] to get a list of server 1178 transport addresses that can be tried to create a TURN allocation. 1180 The client MUST include a REQUESTED-TRANSPORT attribute in the 1181 request. This attribute specifies the transport protocol between the 1182 server and the peers (note that this is NOT the transport protocol 1183 that appears in the 5-tuple). In this specification, the REQUESTED- 1184 TRANSPORT type is always UDP. This attribute is included to allow 1185 future extensions to specify other protocols. 1187 If the client wishes to obtain a relayed transport address of a 1188 specific address type then it includes a REQUESTED-ADDRESS-FAMILY 1189 attribute in the request. This attribute indicates the specific 1190 address type the client wishes the TURN server to allocate. Clients 1191 MUST NOT include more than one REQUESTED-ADDRESS-FAMILY attribute in 1192 an Allocate request. Clients MUST NOT include a REQUESTED-ADDRESS- 1193 FAMILY attribute in an Allocate request that contains a RESERVATION- 1194 TOKEN attribute, for the reasons outlined in [RFC6156]. 1196 If the client wishes to obtain one IPv6 and one IPv4 relayed 1197 transport address then it includes an ADDITIONAL-ADDRESS-FAMILY 1198 attribute in the request. This attribute specifies that the server 1199 must allocate both address types. The attribute value in the 1200 ADDITIONAL-ADDRESS-FAMILY MUST be set to 0x02 (IPv6 address family). 1201 Clients MUST NOT include REQUESTED-ADDRESS-FAMILY and ADDITIONAL- 1202 ADDRESS-FAMILY attributes in the same request. Clients MUST NOT 1203 include ADDITIONAL-ADDRESS-FAMILY attribute in a Allocate request 1204 that contains a RESERVATION-TOKEN attribute. Clients MUST NOT 1205 include ADDITIONAL-ADDRESS-FAMILY attribute in a Allocate request 1206 that contains an EVEN-PORT attribute with the R bit set to 1. The 1207 reason behind the restriction is if EVEN-PORT with R bit set to 1 is 1208 allowed with the ADDITIONAL-ADDRESS-FAMILY attribute, two tokens will 1209 have to be returned in success response and requires changes to the 1210 way RESERVATION-TOKEN is handled. 1212 If the client wishes the server to initialize the time-to-expiry 1213 field of the allocation to some value other than the default 1214 lifetime, then it MAY include a LIFETIME attribute specifying its 1215 desired value. This is just a hint, and the server may elect to use 1216 a different value. Note that the server will ignore requests to 1217 initialize the field to less than the default value. 1219 If the client wishes to later use the DONT-FRAGMENT attribute in one 1220 or more Send indications on this allocation, then the client SHOULD 1221 include the DONT-FRAGMENT attribute in the Allocate request. This 1222 allows the client to test whether this attribute is supported by the 1223 server. 1225 If the client requires the port number of the relayed transport 1226 address be even, the client includes the EVEN-PORT attribute. If 1227 this attribute is not included, then the port can be even or odd. By 1228 setting the R bit in the EVEN-PORT attribute to 1, the client can 1229 request that the server reserve the next highest port number (on the 1230 same IP address) for a subsequent allocation. If the R bit is 0, no 1231 such request is made. 1233 The client MAY also include a RESERVATION-TOKEN attribute in the 1234 request to ask the server to use a previously reserved port for the 1235 allocation. If the RESERVATION-TOKEN attribute is included, then the 1236 client MUST omit the EVEN-PORT attribute. 1238 Once constructed, the client sends the Allocate request on the 1239 5-tuple. 1241 7.2. Receiving an Allocate Request 1243 When the server receives an Allocate request, it performs the 1244 following checks: 1246 1. The server SHOULD require that the request be authenticated. 1247 The authentication of the request is optional to allow TURN 1248 servers provided by the local or access network to accept 1249 Allocation requests from new and/or guest users in the network 1250 who do not necessarily possess long term credentials for STUN 1251 authentication and its security implications are discussed in 1252 [RFC8155]. If the request is authenticated, the authentication 1253 MUST be done using the long-term credential mechanism of 1254 [I-D.ietf-tram-stunbis] unless the client and server agree to 1255 use another mechanism through some procedure outside the scope 1256 of this document. 1258 2. The server checks if the 5-tuple is currently in use by an 1259 existing allocation. If yes, the server rejects the request 1260 with a 437 (Allocation Mismatch) error. 1262 3. The server checks if the request contains a REQUESTED-TRANSPORT 1263 attribute. If the REQUESTED-TRANSPORT attribute is not included 1264 or is malformed, the server rejects the request with a 400 (Bad 1265 Request) error. Otherwise, if the attribute is included but 1266 specifies a protocol other that UDP, the server rejects the 1267 request with a 442 (Unsupported Transport Protocol) error. 1269 4. The request may contain a DONT-FRAGMENT attribute. If it does, 1270 but the server does not support sending UDP datagrams with the 1271 DF bit set to 1 (see Section 14), then the server treats the 1272 DONT-FRAGMENT attribute in the Allocate request as an unknown 1273 comprehension-required attribute. 1275 5. The server checks if the request contains a RESERVATION-TOKEN 1276 attribute. If yes, and the request also contains an EVEN-PORT 1277 or REQUESTED-ADDRESS-FAMILY or ADDITIONAL-ADDRESS-FAMILY 1278 attribute, the server rejects the request with a 400 (Bad 1279 Request) error. Otherwise, it checks to see if the token is 1280 valid (i.e., the token is in range and has not expired and the 1281 corresponding relayed transport address is still available). If 1282 the token is not valid for some reason, the server rejects the 1283 request with a 508 (Insufficient Capacity) error. 1285 6. The server checks if the request contains both REQUESTED- 1286 ADDRESS-FAMILY and ADDITIONAL-ADDRESS-FAMILY attributes. If 1287 yes, then the server rejects the request with a 400 (Bad 1288 Request) error. 1290 7. If the server does not support the address family requested by 1291 the client in REQUESTED-ADDRESS-FAMILY or is disabled by local 1292 policy, it MUST generate an Allocate error response, and it MUST 1293 include an ERROR-CODE attribute with the 440 (Address Family not 1294 Supported) response code. If the REQUESTED-ADDRESS-FAMILY 1295 attribute is absent and the server does not support IPv4 address 1296 family, the server MUST include an ERROR-CODE attribute with the 1297 440 (Address Family not Supported) response code. If the 1298 REQUESTED-ADDRESS-FAMILY attribute is absent and the server 1299 supports IPv4 address family, the server MUST allocate an IPv4 1300 relayed transport address for the TURN client. 1302 8. The server checks if the request contains an EVEN-PORT attribute 1303 with the R bit set to 1. If yes, and the request also contains 1304 an ADDITIONAL-ADDRESS-FAMILY attribute, the server rejects the 1305 request with a 400 (Bad Request) error. Otherwise, the server 1306 checks if it can satisfy the request (i.e., can allocate a 1307 relayed transport address as described below). If the server 1308 cannot satisfy the request, then the server rejects the request 1309 with a 508 (Insufficient Capacity) error. 1311 9. The server checks if the request contains an ADDITIONAL-ADDRESS- 1312 FAMILY attribute. If yes, and the attribute value is 0x01 (IPv4 1313 address family), then the server rejects the request with a 400 1314 (Bad Request) error. Otherwise, the server checks if it can 1315 allocate relayed transport addresses of both address types. If 1316 the server cannot satisfy the request, then the server rejects 1317 the request with a 508 (Insufficient Capacity) error. If the 1318 server can partially meet the request, i.e. if it can only 1319 allocate one relayed transport address of a specific address 1320 type, then it includes ADDRESS-ERROR-CODE attribute in the 1321 response to inform the client the reason for partial failure of 1322 the request. The error code value signaled in the ADDRESS- 1323 ERROR-CODE attribute could be 440 (Address Family not Supported) 1324 or 508 (Insufficient Capacity). If the server can fully meet 1325 the request, then the server allocates one IPv4 and one IPv6 1326 relay address, and returns an Allocate success response 1327 containing the relayed transport addresses assigned to the dual 1328 allocation in two XOR-RELAYED-ADDRESS attributes. 1330 10. At any point, the server MAY choose to reject the request with a 1331 486 (Allocation Quota Reached) error if it feels the client is 1332 trying to exceed some locally defined allocation quota. The 1333 server is free to define this allocation quota any way it 1334 wishes, but SHOULD define it based on the username used to 1335 authenticate the request, and not on the client's transport 1336 address. 1338 11. Also at any point, the server MAY choose to reject the request 1339 with a 300 (Try Alternate) error if it wishes to redirect the 1340 client to a different server. The use of this error code and 1341 attribute follow the specification in [I-D.ietf-tram-stunbis]. 1343 If all the checks pass, the server creates the allocation. The 1344 5-tuple is set to the 5-tuple from the Allocate request, while the 1345 list of permissions and the list of channels are initially empty. 1347 The server chooses a relayed transport address for the allocation as 1348 follows: 1350 o If the request contains a RESERVATION-TOKEN attribute, the server 1351 uses the previously reserved transport address corresponding to 1352 the included token (if it is still available). Note that the 1353 reservation is a server-wide reservation and is not specific to a 1354 particular allocation, since the Allocate request containing the 1355 RESERVATION-TOKEN uses a different 5-tuple than the Allocate 1356 request that made the reservation. The 5-tuple for the Allocate 1357 request containing the RESERVATION-TOKEN attribute can be any 1358 allowed 5-tuple; it can use a different client IP address and 1359 port, a different transport protocol, and even different server IP 1360 address and port (provided, of course, that the server IP address 1361 and port are ones on which the server is listening for TURN 1362 requests). 1364 o If the request contains an EVEN-PORT attribute with the R bit set 1365 to 0, then the server allocates a relayed transport address with 1366 an even port number. 1368 o If the request contains an EVEN-PORT attribute with the R bit set 1369 to 1, then the server looks for a pair of port numbers N and N+1 1370 on the same IP address, where N is even. Port N is used in the 1371 current allocation, while the relayed transport address with port 1372 N+1 is assigned a token and reserved for a future allocation. The 1373 server MUST hold this reservation for at least 30 seconds, and MAY 1374 choose to hold longer (e.g., until the allocation with port N 1375 expires). The server then includes the token in a RESERVATION- 1376 TOKEN attribute in the success response. 1378 o Otherwise, the server allocates any available relayed transport 1379 address. 1381 In all cases, the server SHOULD only allocate ports from the range 1382 49152 - 65535 (the Dynamic and/or Private Port range [Port-Numbers]), 1383 unless the TURN server application knows, through some means not 1384 specified here, that other applications running on the same host as 1385 the TURN server application will not be impacted by allocating ports 1386 outside this range. This condition can often be satisfied by running 1387 the TURN server application on a dedicated machine and/or by 1388 arranging that any other applications on the machine allocate ports 1389 before the TURN server application starts. In any case, the TURN 1390 server SHOULD NOT allocate ports in the range 0 - 1023 (the Well- 1391 Known Port range) to discourage clients from using TURN to run 1392 standard services. 1394 NOTE: The use of randomized port assignments to avoid certain 1395 types of attacks is described in [RFC6056]. It is RECOMMENDED 1396 that a TURN server implement a randomized port assignment 1397 algorithm from [RFC6056]. This is especially applicable to 1398 servers that choose to pre-allocate a number of ports from the 1399 underlying OS and then later assign them to allocations; for 1400 example, a server may choose this technique to implement the EVEN- 1401 PORT attribute. 1403 The server determines the initial value of the time-to-expiry field 1404 as follows. If the request contains a LIFETIME attribute, then the 1405 server computes the minimum of the client's proposed lifetime and the 1406 server's maximum allowed lifetime. If this computed value is greater 1407 than the default lifetime, then the server uses the computed lifetime 1408 as the initial value of the time-to-expiry field. Otherwise, the 1409 server uses the default lifetime. It is RECOMMENDED that the server 1410 use a maximum allowed lifetime value of no more than 3600 seconds (1 1411 hour). Servers that implement allocation quotas or charge users for 1412 allocations in some way may wish to use a smaller maximum allowed 1413 lifetime (perhaps as small as the default lifetime) to more quickly 1414 remove orphaned allocations (that is, allocations where the 1415 corresponding client has crashed or terminated or the client 1416 connection has been lost for some reason). Also, note that the time- 1417 to-expiry is recomputed with each successful Refresh request, and 1418 thus the value computed here applies only until the first refresh. 1420 Once the allocation is created, the server replies with a success 1421 response. The success response contains: 1423 o An XOR-RELAYED-ADDRESS attribute containing the relayed transport 1424 address. 1426 o A LIFETIME attribute containing the current value of the time-to- 1427 expiry timer. 1429 o A RESERVATION-TOKEN attribute (if a second relayed transport 1430 address was reserved). 1432 o An XOR-MAPPED-ADDRESS attribute containing the client's IP address 1433 and port (from the 5-tuple). 1435 NOTE: The XOR-MAPPED-ADDRESS attribute is included in the response 1436 as a convenience to the client. TURN itself does not make use of 1437 this value, but clients running ICE can often need this value and 1438 can thus avoid having to do an extra Binding transaction with some 1439 STUN server to learn it. 1441 The response (either success or error) is sent back to the client on 1442 the 5-tuple. 1444 NOTE: When the Allocate request is sent over UDP, 1445 [I-D.ietf-tram-stunbis] requires that the server handle the 1446 possible retransmissions of the request so that retransmissions do 1447 not cause multiple allocations to be created. Implementations may 1448 achieve this using the so-called "stateless stack approach" as 1449 follows. To detect retransmissions when the original request was 1450 successful in creating an allocation, the server can store the 1451 transaction id that created the request with the allocation data 1452 and compare it with incoming Allocate requests on the same 1453 5-tuple. Once such a request is detected, the server can stop 1454 parsing the request and immediately generate a success response. 1455 When building this response, the value of the LIFETIME attribute 1456 can be taken from the time-to-expiry field in the allocate state 1457 data, even though this value may differ slightly from the LIFETIME 1458 value originally returned. In addition, the server may need to 1459 store an indication of any reservation token returned in the 1460 original response, so that this may be returned in any 1461 retransmitted responses. 1463 For the case where the original request was unsuccessful in 1464 creating an allocation, the server may choose to do nothing 1465 special. Note, however, that there is a rare case where the 1466 server rejects the original request but accepts the retransmitted 1467 request (because conditions have changed in the brief intervening 1468 time period). If the client receives the first failure response, 1469 it will ignore the second (success) response and believe that an 1470 allocation was not created. An allocation created in this matter 1471 will eventually timeout, since the client will not refresh it. 1472 Furthermore, if the client later retries with the same 5-tuple but 1473 different transaction id, it will receive a 437 (Allocation 1474 Mismatch), which will cause it to retry with a different 5-tuple. 1475 The server may use a smaller maximum lifetime value to minimize 1476 the lifetime of allocations "orphaned" in this manner. 1478 7.3. Receiving an Allocate Success Response 1480 If the client receives an Allocate success response, then it MUST 1481 check that the mapped address and the relayed transport address or 1482 addresses are part of an address family or families that the client 1483 understands and is prepared to handle. If these addresses are not 1484 part of an address family or families which the client is prepared to 1485 handle, then the client MUST delete the allocation (Section 8) and 1486 MUST NOT attempt to create another allocation on that server until it 1487 believes the mismatch has been fixed. 1489 Otherwise, the client creates its own copy of the allocation data 1490 structure to track what is happening on the server. In particular, 1491 the client needs to remember the actual lifetime received back from 1492 the server, rather than the value sent to the server in the request. 1493 The client must also remember the 5-tuple used for the request and 1494 the username and password it used to authenticate the request to 1495 ensure that it reuses them for subsequent messages. The client also 1496 needs to track the channels and permissions it establishes on the 1497 server. 1499 If the client receives an Allocate success response but with ADDRESS- 1500 ERROR-CODE attribute in the response and the error code value 1501 signaled in the ADDRESS-ERROR-CODE attribute is 440 (Address Family 1502 not Supported), the client MUST NOT retry its request for the 1503 rejected address type. If the client receives an ADDRESS-ERROR-CODE 1504 attribute in the response and the error code value signaled in the 1505 ADDRESS-ERROR-CODE attribute is 508 (Insufficient Capacity), the 1506 client SHOULD wait at least 1 minute before trying to request any 1507 more allocations on this server for the rejected address type. 1509 The client will probably wish to send the relayed transport address 1510 to peers (using some method not specified here) so the peers can 1511 communicate with it. The client may also wish to use the server- 1512 reflexive address it receives in the XOR-MAPPED-ADDRESS attribute in 1513 its ICE processing. 1515 7.4. Receiving an Allocate Error Response 1517 If the client receives an Allocate error response, then the 1518 processing depends on the actual error code returned: 1520 o (Request timed out): There is either a problem with the server, or 1521 a problem reaching the server with the chosen transport. The 1522 client considers the current transaction as having failed but MAY 1523 choose to retry the Allocate request using a different transport 1524 (e.g., TCP instead of UDP). 1526 o 300 (Try Alternate): The server would like the client to use the 1527 server specified in the ALTERNATE-SERVER attribute instead. The 1528 client considers the current transaction as having failed, but 1529 SHOULD try the Allocate request with the alternate server before 1530 trying any other servers (e.g., other servers discovered using the 1531 DNS resolution procedures). When trying the Allocate request with 1532 the alternate server, the client follows the ALTERNATE-SERVER 1533 procedures specified in [I-D.ietf-tram-stunbis]. 1535 o 400 (Bad Request): The server believes the client's request is 1536 malformed for some reason. The client considers the current 1537 transaction as having failed. The client MAY notify the user or 1538 operator and SHOULD NOT retry the request with this server until 1539 it believes the problem has been fixed. 1541 o 401 (Unauthorized): If the client has followed the procedures of 1542 the long-term credential mechanism and still gets this error, then 1543 the server is not accepting the client's credentials. In this 1544 case, the client considers the current transaction as having 1545 failed and SHOULD notify the user or operator. The client SHOULD 1546 NOT send any further requests to this server until it believes the 1547 problem has been fixed. 1549 o 403 (Forbidden): The request is valid, but the server is refusing 1550 to perform it, likely due to administrative restrictions. The 1551 client considers the current transaction as having failed. The 1552 client MAY notify the user or operator and SHOULD NOT retry the 1553 same request with this server until it believes the problem has 1554 been fixed. 1556 o 420 (Unknown Attribute): If the client included a DONT-FRAGMENT 1557 attribute in the request and the server rejected the request with 1558 a 420 error code and listed the DONT-FRAGMENT attribute in the 1559 UNKNOWN-ATTRIBUTES attribute in the error response, then the 1560 client now knows that the server does not support the DONT- 1561 FRAGMENT attribute. The client considers the current transaction 1562 as having failed but MAY choose to retry the Allocate request 1563 without the DONT-FRAGMENT attribute. 1565 o 437 (Allocation Mismatch): This indicates that the client has 1566 picked a 5-tuple that the server sees as already in use. One way 1567 this could happen is if an intervening NAT assigned a mapped 1568 transport address that was used by another client that recently 1569 crashed. The client considers the current transaction as having 1570 failed. The client SHOULD pick another client transport address 1571 and retry the Allocate request (using a different transaction id). 1572 The client SHOULD try three different client transport addresses 1573 before giving up on this server. Once the client gives up on the 1574 server, it SHOULD NOT try to create another allocation on the 1575 server for 2 minutes. 1577 o 438 (Stale Nonce): See the procedures for the long-term credential 1578 mechanism [I-D.ietf-tram-stunbis]. 1580 o 440 (Address Family not Supported): The server does not support 1581 the address family requested by the client. If the client 1582 receives an Allocate error response with the 440 (Unsupported 1583 Address Family) error code, the client MUST NOT retry the request. 1585 o 441 (Wrong Credentials): The client should not receive this error 1586 in response to a Allocate request. The client MAY notify the user 1587 or operator and SHOULD NOT retry the same request with this server 1588 until it believes the problem has been fixed. 1590 o 442 (Unsupported Transport Address): The client should not receive 1591 this error in response to a request for a UDP allocation. The 1592 client MAY notify the user or operator and SHOULD NOT reattempt 1593 the request with this server until it believes the problem has 1594 been fixed. 1596 o 486 (Allocation Quota Reached): The server is currently unable to 1597 create any more allocations with this username. The client 1598 considers the current transaction as having failed. The client 1599 SHOULD wait at least 1 minute before trying to create any more 1600 allocations on the server. 1602 o 508 (Insufficient Capacity): The server has no more relayed 1603 transport addresses available, or has none with the requested 1604 properties, or the one that was reserved is no longer available. 1605 The client considers the current operation as having failed. If 1606 the client is using either the EVEN-PORT or the RESERVATION-TOKEN 1607 attribute, then the client MAY choose to remove or modify this 1608 attribute and try again immediately. Otherwise, the client SHOULD 1609 wait at least 1 minute before trying to create any more 1610 allocations on this server. 1612 An unknown error response MUST be handled as described in 1613 [I-D.ietf-tram-stunbis]. 1615 8. Refreshing an Allocation 1617 A Refresh transaction can be used to either (a) refresh an existing 1618 allocation and update its time-to-expiry or (b) delete an existing 1619 allocation. 1621 If a client wishes to continue using an allocation, then the client 1622 MUST refresh it before it expires. It is suggested that the client 1623 refresh the allocation roughly 1 minute before it expires. If a 1624 client no longer wishes to use an allocation, then it SHOULD 1625 explicitly delete the allocation. A client MAY refresh an allocation 1626 at any time for other reasons. 1628 8.1. Sending a Refresh Request 1630 If the client wishes to immediately delete an existing allocation, it 1631 includes a LIFETIME attribute with a value of 0. All other forms of 1632 the request refresh the allocation. 1634 When refreshing a dual allocation, the client includes REQUESTED- 1635 ADDRESS-FAMILY attribute indicating the address family type that 1636 should be refreshed. If no REQUESTED-ADDRESS-FAMILY is included then 1637 the request should be treated as applying to all current allocations. 1638 The client MUST only include family types it previously allocated and 1639 has not yet deleted. This process can also be used to delete an 1640 allocation of a specific address type, by setting the lifetime of 1641 that refresh request to 0. Deleting a single allocation destroys any 1642 permissions or channels associated with that particular allocation; 1643 it MUST NOT affect any permissions or channels associated with 1644 allocations for the other address family. 1646 The Refresh transaction updates the time-to-expiry timer of an 1647 allocation. If the client wishes the server to set the time-to- 1648 expiry timer to something other than the default lifetime, it 1649 includes a LIFETIME attribute with the requested value. The server 1650 then computes a new time-to-expiry value in the same way as it does 1651 for an Allocate transaction, with the exception that a requested 1652 lifetime of 0 causes the server to immediately delete the allocation. 1654 8.2. Receiving a Refresh Request 1656 When the server receives a Refresh request, it processes the request 1657 as per Section 5 plus the specific rules mentioned here. 1659 If the server receives a Refresh Request with a REQUESTED-ADDRESS- 1660 FAMILY attribute and the attribute value does not match the address 1661 family of the allocation, the server MUST reply with a 443 (Peer 1662 Address Family Mismatch) Refresh error response. 1664 The server computes a value called the "desired lifetime" as follows: 1665 if the request contains a LIFETIME attribute and the attribute value 1666 is 0, then the "desired lifetime" is 0. Otherwise, if the request 1667 contains a LIFETIME attribute, then the server computes the minimum 1668 of the client's requested lifetime and the server's maximum allowed 1669 lifetime. If this computed value is greater than the default 1670 lifetime, then the "desired lifetime" is the computed value. 1671 Otherwise, the "desired lifetime" is the default lifetime. 1673 Subsequent processing depends on the "desired lifetime" value: 1675 o If the "desired lifetime" is 0, then the request succeeds and the 1676 allocation is deleted. 1678 o If the "desired lifetime" is non-zero, then the request succeeds 1679 and the allocation's time-to-expiry is set to the "desired 1680 lifetime". 1682 If the request succeeds, then the server sends a success response 1683 containing: 1685 o A LIFETIME attribute containing the current value of the time-to- 1686 expiry timer. 1688 NOTE: A server need not do anything special to implement 1689 idempotency of Refresh requests over UDP using the "stateless 1690 stack approach". Retransmitted Refresh requests with a non-zero 1691 "desired lifetime" will simply refresh the allocation. A 1692 retransmitted Refresh request with a zero "desired lifetime" will 1693 cause a 437 (Allocation Mismatch) response if the allocation has 1694 already been deleted, but the client will treat this as equivalent 1695 to a success response (see below). 1697 8.3. Receiving a Refresh Response 1699 If the client receives a success response to its Refresh request with 1700 a non-zero lifetime, it updates its copy of the allocation data 1701 structure with the time-to-expiry value contained in the response. 1703 If the client receives a 437 (Allocation Mismatch) error response to 1704 a request to delete the allocation, then the allocation no longer 1705 exists and it should consider its request as having effectively 1706 succeeded. 1708 9. Permissions 1710 For each allocation, the server keeps a list of zero or more 1711 permissions. Each permission consists of an IP address and an 1712 associated time-to-expiry. While a permission exists, all peers 1713 using the IP address in the permission are allowed to send data to 1714 the client. The time-to-expiry is the number of seconds until the 1715 permission expires. Within the context of an allocation, a 1716 permission is uniquely identified by its associated IP address. 1718 By sending either CreatePermission requests or ChannelBind requests, 1719 the client can cause the server to install or refresh a permission 1720 for a given IP address. This causes one of two things to happen: 1722 o If no permission for that IP address exists, then a permission is 1723 created with the given IP address and a time-to-expiry equal to 1724 Permission Lifetime. 1726 o If a permission for that IP address already exists, then the time- 1727 to-expiry for that permission is reset to Permission Lifetime. 1729 The Permission Lifetime MUST be 300 seconds (= 5 minutes). 1731 Each permission's time-to-expiry decreases down once per second until 1732 it reaches 0; at which point, the permission expires and is deleted. 1734 CreatePermission and ChannelBind requests may be freely intermixed on 1735 a permission. A given permission may be initially installed and/or 1736 refreshed with a CreatePermission request, and then later refreshed 1737 with a ChannelBind request, or vice versa. 1739 A TURN server MUST have a configuration knob to allow inbound STUN 1740 packets on the allocation's relayed address even if the source IP 1741 addresses of the STUN packets do not match the permissions installed. 1742 This configuration knob MUST default to drop the inbound STUN packets 1743 on the allocation's relayed address if the source IP addresses of the 1744 STUN packets do not match the permissions installed unless explicitly 1745 configured to do otherwise. 1747 When a UDP datagram arrives at the relayed transport address for the 1748 allocation, the server extracts the source IP address from the IP 1749 header. The server then compares this address with the IP address 1750 associated with each permission in the list of permissions for the 1751 allocation. If no match is found and the received datagram is not a 1752 STUN packet, the permission check is considered to have failed. If 1753 an exact match is found, the permission check is considered to have 1754 succeeded. If no match is found and the received datagram is a STUN 1755 packet, the permission check is considered to have failed unless the 1756 server is configured to allow STUN packets without explicit 1757 permission, in which case the permission check is considered to have 1758 succeeded. If the permission check fails, relaying is not permitted 1759 and the server silently discards the UDP datagram. If the permission 1760 check succeeds, the services continues to process the UDP datagram as 1761 specified elsewhere (Section 11.3). Note that only addresses are 1762 compared and port numbers are not considered. 1764 The permissions for one allocation are totally unrelated to the 1765 permissions for a different allocation. If an allocation expires, 1766 all its permissions expire with it. 1768 NOTE: Though TURN permissions expire after 5 minutes, many NATs 1769 deployed at the time of publication expire their UDP bindings 1770 considerably faster. Thus, an application using TURN will 1771 probably wish to send some sort of keep-alive traffic at a much 1772 faster rate. Applications using ICE should follow the keep-alive 1773 guidelines of ICE [RFC5245], and applications not using ICE are 1774 advised to do something similar. 1776 10. CreatePermission 1778 TURN supports two ways for the client to install or refresh 1779 permissions on the server. This section describes one way: the 1780 CreatePermission request. 1782 A CreatePermission request may be used in conjunction with either the 1783 Send mechanism in Section 11 or the Channel mechanism in Section 12. 1785 10.1. Forming a CreatePermission Request 1787 The client who wishes to install or refresh one or more permissions 1788 can send a CreatePermission request to the server. 1790 When forming a CreatePermission request, the client MUST include at 1791 least one XOR-PEER-ADDRESS attribute, and MAY include more than one 1792 such attribute. The IP address portion of each XOR-PEER-ADDRESS 1793 attribute contains the IP address for which a permission should be 1794 installed or refreshed. The port portion of each XOR-PEER-ADDRESS 1795 attribute will be ignored and can be any arbitrary value. The 1796 various XOR-PEER-ADDRESS attributes MAY appear in any order. The 1797 client MUST only include XOR-PEER-ADDRESS attributes with addresses 1798 of the same address family as that of the relayed transport address 1799 for the allocation. For dual allocations obtained using the 1800 ADDITIONAL-ADDRESS-FAMILY attribute, the client MAY include XOR-PEER- 1801 ADDRESS attributes with addresses of IPv4 and IPv6 address families. 1803 10.2. Receiving a CreatePermission Request 1805 When the server receives the CreatePermission request, it processes 1806 as per Section 5 plus the specific rules mentioned here. 1808 The message is checked for validity. The CreatePermission request 1809 MUST contain at least one XOR-PEER-ADDRESS attribute and MAY contain 1810 multiple such attributes. If no such attribute exists, or if any of 1811 these attributes are invalid, then a 400 (Bad Request) error is 1812 returned. If the request is valid, but the server is unable to 1813 satisfy the request due to some capacity limit or similar, then a 508 1814 (Insufficient Capacity) error is returned. 1816 If an XOR-PEER-ADDRESS attribute contains an address of an address 1817 family that is not the same as that of a relayed transport address 1818 for the allocation, the server MUST generate an error response with 1819 the 443 (Peer Address Family Mismatch) response code. 1821 The server MAY impose restrictions on the IP address allowed in the 1822 XOR-PEER-ADDRESS attribute -- if a value is not allowed, the server 1823 rejects the request with a 403 (Forbidden) error. 1825 If the message is valid and the server is capable of carrying out the 1826 request, then the server installs or refreshes a permission for the 1827 IP address contained in each XOR-PEER-ADDRESS attribute as described 1828 in Section 9. The port portion of each attribute is ignored and may 1829 be any arbitrary value. 1831 The server then responds with a CreatePermission success response. 1832 There are no mandatory attributes in the success response. 1834 NOTE: A server need not do anything special to implement 1835 idempotency of CreatePermission requests over UDP using the 1836 "stateless stack approach". Retransmitted CreatePermission 1837 requests will simply refresh the permissions. 1839 10.3. Receiving a CreatePermission Response 1841 If the client receives a valid CreatePermission success response, 1842 then the client updates its data structures to indicate that the 1843 permissions have been installed or refreshed. 1845 11. Send and Data Methods 1847 TURN supports two mechanisms for sending and receiving data from 1848 peers. This section describes the use of the Send and Data 1849 mechanisms, while Section 12 describes the use of the Channel 1850 mechanism. 1852 11.1. Forming a Send Indication 1854 The client can use a Send indication to pass data to the server for 1855 relaying to a peer. A client may use a Send indication even if a 1856 channel is bound to that peer. However, the client MUST ensure that 1857 there is a permission installed for the IP address of the peer to 1858 which the Send indication is being sent; this prevents a third party 1859 from using a TURN server to send data to arbitrary destinations. 1861 When forming a Send indication, the client MUST include an XOR-PEER- 1862 ADDRESS attribute and a DATA attribute. The XOR-PEER-ADDRESS 1863 attribute contains the transport address of the peer to which the 1864 data is to be sent, and the DATA attribute contains the actual 1865 application data to be sent to the peer. 1867 The client MAY include a DONT-FRAGMENT attribute in the Send 1868 indication if it wishes the server to set the DF bit on the UDP 1869 datagram sent to the peer. 1871 11.2. Receiving a Send Indication 1873 When the server receives a Send indication, it processes as per 1874 Section 5 plus the specific rules mentioned here. 1876 The message is first checked for validity. The Send indication MUST 1877 contain both an XOR-PEER-ADDRESS attribute and a DATA attribute. If 1878 one of these attributes is missing or invalid, then the message is 1879 discarded. Note that the DATA attribute is allowed to contain zero 1880 bytes of data. 1882 The Send indication may also contain the DONT-FRAGMENT attribute. If 1883 the server is unable to set the DF bit on outgoing UDP datagrams when 1884 this attribute is present, then the server acts as if the DONT- 1885 FRAGMENT attribute is an unknown comprehension-required attribute 1886 (and thus the Send indication is discarded). 1888 The server also checks that there is a permission installed for the 1889 IP address contained in the XOR-PEER-ADDRESS attribute. If no such 1890 permission exists, the message is discarded. Note that a Send 1891 indication never causes the server to refresh the permission. 1893 The server MAY impose restrictions on the IP address and port values 1894 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 1895 allowed, the server silently discards the Send indication. 1897 If everything is OK, then the server forms a UDP datagram as follows: 1899 o the source transport address is the relayed transport address of 1900 the allocation, where the allocation is determined by the 5-tuple 1901 on which the Send indication arrived; 1903 o the destination transport address is taken from the XOR-PEER- 1904 ADDRESS attribute; 1906 o the data following the UDP header is the contents of the value 1907 field of the DATA attribute. 1909 The handling of the DONT-FRAGMENT attribute (if present), is 1910 described in Section 14. 1912 The resulting UDP datagram is then sent to the peer. 1914 11.3. Receiving a UDP Datagram 1916 When the server receives a UDP datagram at a currently allocated 1917 relayed transport address, the server looks up the allocation 1918 associated with the relayed transport address. The server then 1919 checks to see whether the set of permissions for the allocation allow 1920 the relaying of the UDP datagram as described in Section 9. 1922 If relaying is permitted, then the server checks if there is a 1923 channel bound to the peer that sent the UDP datagram (see 1924 Section 12). If a channel is bound, then processing proceeds as 1925 described in Section 12.7. 1927 If relaying is permitted but no channel is bound to the peer, then 1928 the server forms and sends a Data indication. The Data indication 1929 MUST contain both an XOR-PEER-ADDRESS and a DATA attribute. The DATA 1930 attribute is set to the value of the 'data octets' field from the 1931 datagram, and the XOR-PEER-ADDRESS attribute is set to the source 1932 transport address of the received UDP datagram. The Data indication 1933 is then sent on the 5-tuple associated with the allocation. 1935 11.4. Receiving a Data Indication 1937 When the client receives a Data indication, it checks that the Data 1938 indication contains an XOR-PEER-ADDRESS attribute, and discards the 1939 indication if it does not. The client SHOULD also check that the 1940 XOR-PEER-ADDRESS attribute value contains an IP address with which 1941 the client believes there is an active permission, and discard the 1942 Data indication otherwise. 1944 NOTE: The latter check protects the client against an attacker who 1945 somehow manages to trick the server into installing permissions 1946 not desired by the client. 1948 If the XOR-PEER-ADDRESS is present and valid, the client checks that 1949 the Data indication contains either a DATA attribute or an ICMP 1950 attribute and discards the indication if it does not. Note that a 1951 DATA attribute is allowed to contain zero bytes of data. Processing 1952 of Data indications with an ICMP attribute is described in 1953 Section 11.6. 1955 If the Data indication passes the above checks, the client delivers 1956 the data octets inside the DATA attribute to the application, along 1957 with an indication that they were received from the peer whose 1958 transport address is given by the XOR-PEER-ADDRESS attribute. 1960 11.5. Receiving an ICMP Packet 1962 When the server receives an ICMP packet, the server verifies that the 1963 type is either 3, 11 or 12 for an ICMPv4 [RFC0792] packet or either 1964 1, 2, or 3 for an ICMPv6 [RFC4443] packet. It also verifies that the 1965 IP packet in the ICMP packet payload contains a UDP header. If 1966 either of these conditions fail, then the ICMP packet is silently 1967 dropped. 1969 The server looks up the allocation whose relayed transport address 1970 corresponds to the encapsulated packet's source IP address and UDP 1971 port. If no such allocation exists, the packet is silently dropped. 1972 The server then checks to see whether the set of permissions for the 1973 allocation allows the relaying of the ICMP packet. For ICMP packets, 1974 the source IP address MUST NOT be checked against the permissions 1975 list as it would be for UDP packets. Instead, the server extracts 1976 the destination IP address from the encapsulated IP header. The 1977 server then compares this address with the IP address associated with 1978 each permission in the list of permissions for the allocation. If no 1979 match is found, relaying is not permitted, and the server silently 1980 discards the ICMP packet. Note that only addresses are compared and 1981 port numbers are not considered. 1983 If relaying is permitted then the server forms and sends a Data 1984 indication. The Data indication MUST contain both an XOR-PEER- 1985 ADDRESS and an ICMP attribute. The ICMP attribute is set to the 1986 value of the type and code fields from the ICMP packet. The IP 1987 address portion of XOR-PEER-ADDRESS attribute is set to the 1988 destination IP address in the encapsulated IP header. At the time of 1989 writing of this specification, Socket APIs on some operating systems 1990 do not deliver the destination port in the encapsulated UDP header to 1991 applications without superuser privileges. If destination port in 1992 the encapsulated UDP header is available to the server then the port 1993 portion of XOR-PEER-ADDRESS attribute is set to the destination port 1994 otherwise the port portion is set to 0. The Data indication is then 1995 sent on the 5-tuple associated with the allocation. 1997 11.6. Receiving a Data Indication with an ICMP attribute 1999 When the client receives a Data indication with an ICMP attribute, it 2000 checks that the Data indication contains an XOR-PEER-ADDRESS 2001 attribute, and discards the indication if it does not. The client 2002 SHOULD also check that the XOR-PEER-ADDRESS attribute value contains 2003 an IP address with an active permission, and discard the Data 2004 indication otherwise. 2006 If the Data indication passes the above checks, the client signals 2007 the application of the error condition, along with an indication that 2008 it was received from the peer whose transport address is given by the 2009 XOR-PEER-ADDRESS attribute. The application can make sense of the 2010 meaning of the type and code values in the ICMP attribute by using 2011 the family field in the XOR-PEER-ADDRESS attribute. 2013 12. Channels 2015 Channels provide a way for the client and server to send application 2016 data using ChannelData messages, which have less overhead than Send 2017 and Data indications. 2019 The ChannelData message (see Section 12.4) starts with a two-byte 2020 field that carries the channel number. The values of this field are 2021 allocated as follows: 2023 0x0000 through 0x3FFF: These values can never be used for channel 2024 numbers. 2026 0x4000 through 0x4FFF: These values are the allowed channel 2027 numbers (4096 possible values). 2029 0x5000-0xFFFF: Reserved (For DTLS-SRTP multiplexing collision 2030 avoidance, see [RFC7983]. 2032 According to [RFC7983], ChannelData messages can be distinguished 2033 from other multiplexed protocols by examining the first byte of the 2034 message: 2036 +------------+------------------------------+ 2037 | [0..3] | STUN | 2038 | | | 2039 +-------------------------------------------+ 2040 | [16..19] | ZRTP | 2041 | | | 2042 +-------------------------------------------+ 2043 | [20..63] | DTLS | 2044 | | | 2045 +-------------------------------------------+ 2046 | [64..79] | TURN Channel | 2047 | | | 2048 +-------------------------------------------+ 2049 | [128..191] | RTP/RTCP | 2050 | | | 2051 +-------------------------------------------+ 2052 | Others | Reserved, MUST be dropped | 2053 | | and an alert MAY be logged | 2054 +-------------------------------------------+ 2056 Reserved values may be used in the future by other protocols. When 2057 the client uses channel binding, it MUST comply with the 2058 demultiplexing scheme discussed above. 2060 Channel bindings are always initiated by the client. The client can 2061 bind a channel to a peer at any time during the lifetime of the 2062 allocation. The client may bind a channel to a peer before 2063 exchanging data with it, or after exchanging data with it (using Send 2064 and Data indications) for some time, or may choose never to bind a 2065 channel to it. The client can also bind channels to some peers while 2066 not binding channels to other peers. 2068 Channel bindings are specific to an allocation, so that the use of a 2069 channel number or peer transport address in a channel binding in one 2070 allocation has no impact on their use in a different allocation. If 2071 an allocation expires, all its channel bindings expire with it. 2073 A channel binding consists of: 2075 o a channel number; 2077 o a transport address (of the peer); and 2079 o A time-to-expiry timer. 2081 Within the context of an allocation, a channel binding is uniquely 2082 identified either by the channel number or by the peer's transport 2083 address. Thus, the same channel cannot be bound to two different 2084 transport addresses, nor can the same transport address be bound to 2085 two different channels. 2087 A channel binding lasts for 10 minutes unless refreshed. Refreshing 2088 the binding (by the server receiving a ChannelBind request rebinding 2089 the channel to the same peer) resets the time-to-expiry timer back to 2090 10 minutes. 2092 When the channel binding expires, the channel becomes unbound. Once 2093 unbound, the channel number can be bound to a different transport 2094 address, and the transport address can be bound to a different 2095 channel number. To prevent race conditions, the client MUST wait 5 2096 minutes after the channel binding expires before attempting to bind 2097 the channel number to a different transport address or the transport 2098 address to a different channel number. 2100 When binding a channel to a peer, the client SHOULD be prepared to 2101 receive ChannelData messages on the channel from the server as soon 2102 as it has sent the ChannelBind request. Over UDP, it is possible for 2103 the client to receive ChannelData messages from the server before it 2104 receives a ChannelBind success response. 2106 In the other direction, the client MAY elect to send ChannelData 2107 messages before receiving the ChannelBind success response. Doing 2108 so, however, runs the risk of having the ChannelData messages dropped 2109 by the server if the ChannelBind request does not succeed for some 2110 reason (e.g., packet lost if the request is sent over UDP, or the 2111 server being unable to fulfill the request). A client that wishes to 2112 be safe should either queue the data or use Send indications until 2113 the channel binding is confirmed. 2115 12.1. Sending a ChannelBind Request 2117 A channel binding is created or refreshed using a ChannelBind 2118 transaction. A ChannelBind transaction also creates or refreshes a 2119 permission towards the peer (see Section 9). 2121 To initiate the ChannelBind transaction, the client forms a 2122 ChannelBind request. The channel to be bound is specified in a 2123 CHANNEL-NUMBER attribute, and the peer's transport address is 2124 specified in an XOR-PEER-ADDRESS attribute. Section 12.2 describes 2125 the restrictions on these attributes. The client MUST only include 2126 an XOR-PEER-ADDRESS attribute with an address of the same address 2127 family as that of a relayed transport address for the allocation. 2129 Rebinding a channel to the same transport address that it is already 2130 bound to provides a way to refresh a channel binding and the 2131 corresponding permission without sending data to the peer. Note 2132 however, that permissions need to be refreshed more frequently than 2133 channels. 2135 12.2. Receiving a ChannelBind Request 2137 When the server receives a ChannelBind request, it processes as per 2138 Section 5 plus the specific rules mentioned here. 2140 The server checks the following: 2142 o The request contains both a CHANNEL-NUMBER and an XOR-PEER-ADDRESS 2143 attribute; 2145 o The channel number is in the range 0x4000 through 0x4FFF 2146 (inclusive); 2148 o The channel number is not currently bound to a different transport 2149 address (same transport address is OK); 2151 o The transport address is not currently bound to a different 2152 channel number. 2154 o If the XOR-PEER-ADDRESS attribute contains an address of an 2155 address family that is not the same as that of a relayed transport 2156 address for the allocation, the server MUST generate an error 2157 response with the 443 (Peer Address Family Mismatch) response 2158 code. 2160 If any of these tests fail, the server replies with a 400 (Bad 2161 Request) error. 2163 The server MAY impose restrictions on the IP address and port values 2164 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 2165 allowed, the server rejects the request with a 403 (Forbidden) error. 2167 If the request is valid, but the server is unable to fulfill the 2168 request due to some capacity limit or similar, the server replies 2169 with a 508 (Insufficient Capacity) error. 2171 Otherwise, the server replies with a ChannelBind success response. 2172 There are no required attributes in a successful ChannelBind 2173 response. 2175 If the server can satisfy the request, then the server creates or 2176 refreshes the channel binding using the channel number in the 2177 CHANNEL-NUMBER attribute and the transport address in the XOR-PEER- 2178 ADDRESS attribute. The server also installs or refreshes a 2179 permission for the IP address in the XOR-PEER-ADDRESS attribute as 2180 described in Section 9. 2182 NOTE: A server need not do anything special to implement 2183 idempotency of ChannelBind requests over UDP using the "stateless 2184 stack approach". Retransmitted ChannelBind requests will simply 2185 refresh the channel binding and the corresponding permission. 2186 Furthermore, the client must wait 5 minutes before binding a 2187 previously bound channel number or peer address to a different 2188 channel, eliminating the possibility that the transaction would 2189 initially fail but succeed on a retransmission. 2191 12.3. Receiving a ChannelBind Response 2193 When the client receives a ChannelBind success response, it updates 2194 its data structures to record that the channel binding is now active. 2195 It also updates its data structures to record that the corresponding 2196 permission has been installed or refreshed. 2198 If the client receives a ChannelBind failure response that indicates 2199 that the channel information is out-of-sync between the client and 2200 the server (e.g., an unexpected 400 "Bad Request" response), then it 2201 is RECOMMENDED that the client immediately delete the allocation and 2202 start afresh with a new allocation. 2204 12.4. The ChannelData Message 2206 The ChannelData message is used to carry application data between the 2207 client and the server. It has the following format: 2209 0 1 2 3 2210 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 2211 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2212 | Channel Number | Length | 2213 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2214 | | 2215 / Application Data / 2216 / / 2217 | | 2218 | +-------------------------------+ 2219 | | 2220 +-------------------------------+ 2222 The Channel Number field specifies the number of the channel on which 2223 the data is traveling, and thus the address of the peer that is 2224 sending or is to receive the data. 2226 The Length field specifies the length in bytes of the application 2227 data field (i.e., it does not include the size of the ChannelData 2228 header). Note that 0 is a valid length. 2230 The Application Data field carries the data the client is trying to 2231 send to the peer, or that the peer is sending to the client. 2233 12.5. Sending a ChannelData Message 2235 Once a client has bound a channel to a peer, then when the client has 2236 data to send to that peer it may use either a ChannelData message or 2237 a Send indication; that is, the client is not obligated to use the 2238 channel when it exists and may freely intermix the two message types 2239 when sending data to the peer. The server, on the other hand, MUST 2240 use the ChannelData message if a channel has been bound to the peer. 2241 The server uses a Data indication to signal the XOR-PEER-ADDRESS and 2242 ICMP attributes to the client even if a channel has been bound to the 2243 peer. 2245 The fields of the ChannelData message are filled in as described in 2246 Section 12.4. 2248 Over TCP and TLS-over-TCP, the ChannelData message MUST be padded to 2249 a multiple of four bytes in order to ensure the alignment of 2250 subsequent messages. The padding is not reflected in the length 2251 field of the ChannelData message, so the actual size of a ChannelData 2252 message (including padding) is (4 + Length) rounded up to the nearest 2253 multiple of 4. Over UDP, the padding is not required but MAY be 2254 included. 2256 The ChannelData message is then sent on the 5-tuple associated with 2257 the allocation. 2259 12.6. Receiving a ChannelData Message 2261 The receiver of the ChannelData message uses the first byte to 2262 distinguish it from other multiplexed protocols, as described above. 2263 If the message uses a value in the reserved range (0x5000 through 2264 0xFFFF), then the message is silently discarded. 2266 If the ChannelData message is received in a UDP datagram, and if the 2267 UDP datagram is too short to contain the claimed length of the 2268 ChannelData message (i.e., the UDP header length field value is less 2269 than the ChannelData header length field value + 4 + 8), then the 2270 message is silently discarded. 2272 If the ChannelData message is received over TCP or over TLS-over-TCP, 2273 then the actual length of the ChannelData message is as described in 2274 Section 12.5. 2276 If the ChannelData message is received on a channel that is not bound 2277 to any peer, then the message is silently discarded. 2279 On the client, it is RECOMMENDED that the client discard the 2280 ChannelData message if the client believes there is no active 2281 permission towards the peer. On the server, the receipt of a 2282 ChannelData message MUST NOT refresh either the channel binding or 2283 the permission towards the peer. 2285 On the server, if no errors are detected, the server relays the 2286 application data to the peer by forming a UDP datagram as follows: 2288 o the source transport address is the relayed transport address of 2289 the allocation, where the allocation is determined by the 5-tuple 2290 on which the ChannelData message arrived; 2292 o the destination transport address is the transport address to 2293 which the channel is bound; 2295 o the data following the UDP header is the contents of the data 2296 field of the ChannelData message. 2298 The resulting UDP datagram is then sent to the peer. Note that if 2299 the Length field in the ChannelData message is 0, then there will be 2300 no data in the UDP datagram, but the UDP datagram is still formed and 2301 sent. 2303 12.7. Relaying Data from the Peer 2305 When the server receives a UDP datagram on the relayed transport 2306 address associated with an allocation, the server processes it as 2307 described in Section 11.3. If that section indicates that a 2308 ChannelData message should be sent (because there is a channel bound 2309 to the peer that sent to the UDP datagram), then the server forms and 2310 sends a ChannelData message as described in Section 12.5. 2312 When the server receives an ICMP packet, the server processes it as 2313 described in Section 11.5. A Data indication MUST be sent regardless 2314 of whether there is a channel bound to the peer that was the 2315 destination of the UDP datagram that triggered the reception of the 2316 ICMP packet. 2318 13. Packet Translations 2320 This section addresses IPv4-to-IPv6, IPv6-to-IPv4, and IPv6-to-IPv6 2321 translations. Requirements for translation of the IP addresses and 2322 port numbers of the packets are described above. The following 2323 sections specify how to translate other header fields. 2325 As discussed in Section 2.6, translations in TURN are designed so 2326 that a TURN server can be implemented as an application that runs in 2327 userland under commonly available operating systems and that does not 2328 require special privileges. The translations specified in the 2329 following sections follow this principle. 2331 The descriptions below have two parts: a preferred behavior and an 2332 alternate behavior. The server SHOULD implement the preferred 2333 behavior. Otherwise, the server MUST implement the alternate 2334 behavior and MUST NOT do anything else for the reasons detailed in 2335 [RFC7915]. 2337 13.1. IPv4-to-IPv6 Translations 2339 Traffic Class 2341 Preferred behavior: As specified in Section 4 of [RFC7915]. 2343 Alternate behavior: The relay sets the Traffic Class to the 2344 default value for outgoing packets. 2346 Flow Label 2348 Preferred behavior: The relay sets the Flow label to 0. The relay 2349 can choose to set the Flow label to a different value if it 2350 supports the IPv6 Flow Label field [RFC6437]. 2352 Alternate behavior: The relay sets the Flow label to the default 2353 value for outgoing packets. 2355 Hop Limit 2357 Preferred behavior: As specified in Section 4 of [RFC7915]. 2359 Alternate behavior: The relay sets the Hop Limit to the default 2360 value for outgoing packets. 2362 Fragmentation 2364 Preferred behavior: As specified in Section 4 of [RFC7915]. 2366 Alternate behavior: The relay assembles incoming fragments. The 2367 relay follows its default behavior to send outgoing packets. 2369 For both preferred and alternate behavior, the DONT-FRAGMENT 2370 attribute MUST be ignored by the server. 2372 Extension Headers 2374 Preferred behavior: The relay sends outgoing packet without any 2375 IPv6 extension headers, with the exception of the Fragmentation 2376 header as described above. 2378 Alternate behavior: Same as preferred. 2380 13.2. IPv6-to-IPv6 Translations 2382 Flow Label 2384 The relay should consider that it is handling two different IPv6 2385 flows. Therefore, the Flow label [RFC6437] SHOULD NOT be copied as 2386 part of the translation. 2388 Preferred behavior: The relay sets the Flow label to 0. The relay 2389 can choose to set the Flow label to a different value if it 2390 supports the IPv6 Flow Label field [RFC6437]. 2392 Alternate behavior: The relay sets the Flow label to the default 2393 value for outgoing packets. 2395 Hop Limit 2397 Preferred behavior: The relay acts as a regular router with 2398 respect to decrementing the Hop Limit and generating an ICMPv6 2399 error if it reaches zero. 2401 Alternate behavior: The relay sets the Hop Limit to the default 2402 value for outgoing packets. 2404 Fragmentation 2406 Preferred behavior: If the incoming packet did not include a 2407 Fragment header and the outgoing packet size does not exceed the 2408 outgoing link's MTU, the relay sends the outgoing packet without a 2409 Fragment header. 2411 If the incoming packet did not include a Fragment header and the 2412 outgoing packet size exceeds the outgoing link's MTU, the relay 2413 drops the outgoing packet and send an ICMP message of type 2 code 2414 0 ("Packet too big") to the sender of the incoming packet. If 2415 the packet is being sent to the peer, the relay reduces the MTU 2416 reported in the ICMP message by 48 bytes to allow room for the 2417 overhead of a Data indication. 2419 If the incoming packet included a Fragment header and the outgoing 2420 packet size (with a Fragment header included) does not exceed the 2421 outgoing link's MTU, the relay sends the outgoing packet with a 2422 Fragment header. The relay sets the fields of the Fragment header 2423 as appropriate for a packet originating from the server. 2425 If the incoming packet included a Fragment header and the outgoing 2426 packet size exceeds the outgoing link's MTU, the relay MUST 2427 fragment the outgoing packet into fragments of no more than 1280 2428 bytes. The relay sets the fields of the Fragment header as 2429 appropriate for a packet originating from the server. 2431 Alternate behavior: The relay assembles incoming fragments. The 2432 relay follows its default behavior to send outgoing packets. 2434 For both preferred and alternate behavior, the DONT-FRAGMENT 2435 attribute MUST be ignored by the server. 2437 Extension Headers 2439 Preferred behavior: The relay sends outgoing packet without any 2440 IPv6 extension headers, with the exception of the Fragmentation 2441 header as described above. 2443 Alternate behavior: Same as preferred. 2445 13.3. IPv6-to-IPv4 Translations 2447 Type of Service and Precedence 2449 Preferred behavior: As specified in Section 5 of [RFC7915]. 2451 Alternate behavior: The relay sets the Type of Service and 2452 Precedence to the default value for outgoing packets. 2454 Time to Live 2456 Preferred behavior: As specified in Section 5 of [RFC7915]. 2458 Alternate behavior: The relay sets the Time to Live to the default 2459 value for outgoing packets. 2461 Fragmentation 2462 Preferred behavior: As specified in Section 5 of [RFC7915]. 2463 Additionally, when the outgoing packet's size exceeds the outgoing 2464 link's MTU, the relay needs to generate an ICMP error (ICMPv6 2465 Packet Too Big) reporting the MTU size. If the packet is being 2466 sent to the peer, the relay SHOULD reduce the MTU reported in the 2467 ICMP message by 48 bytes to allow room for the overhead of a Data 2468 indication. 2470 Alternate behavior: The relay assembles incoming fragments. The 2471 relay follows its default behavior to send outgoing packets. 2473 For both preferred and alternate behavior, the DONT-FRAGMENT 2474 attribute MUST be ignored by the server. 2476 14. IP Header Fields 2478 This section describes how the server sets various fields in the IP 2479 header when relaying between the client and the peer or vice versa. 2480 The descriptions in this section apply: (a) when the server sends a 2481 UDP datagram to the peer, or (b) when the server sends a Data 2482 indication or ChannelData message to the client over UDP transport. 2483 The descriptions in this section do not apply to TURN messages sent 2484 over TCP or TLS transport from the server to the client. 2486 The descriptions below have two parts: a preferred behavior and an 2487 alternate behavior. The server SHOULD implement the preferred 2488 behavior, but if that is not possible for a particular field, then it 2489 SHOULD implement the alternative behavior. 2491 Time to Live (TTL) field 2493 Preferred Behavior: If the incoming value is 0, then the drop the 2494 incoming packet. Otherwise, set the outgoing Time to Live/Hop 2495 Count to one less than the incoming value. 2497 Alternate Behavior: Set the outgoing value to the default for 2498 outgoing packets. 2500 Differentiated Services Code Point (DSCP) field [RFC2474] 2502 Preferred Behavior: Set the outgoing value to the incoming value, 2503 unless the server includes a differentiated services classifier 2504 and marker [RFC2474]. 2506 Alternate Behavior: Set the outgoing value to a fixed value, which 2507 by default is Best Effort unless configured otherwise. 2509 In both cases, if the server is immediately adjacent to a 2510 differentiated services classifier and marker, then DSCP MAY be 2511 set to any arbitrary value in the direction towards the 2512 classifier. 2514 Explicit Congestion Notification (ECN) field [RFC3168] 2516 Preferred Behavior: Set the outgoing value to the incoming value, 2517 UNLESS the server is doing Active Queue Management, the incoming 2518 ECN field is ECT(1) (=0b01) or ECT(0) (=0b10), and the server 2519 wishes to indicate that congestion has been experienced, in which 2520 case set the outgoing value to CE (=0b11). 2522 Alternate Behavior: Set the outgoing value to Not-ECT (=0b00). 2524 IPv4 Fragmentation fields 2526 Preferred Behavior: When the server sends a packet to a peer in 2527 response to a Send indication containing the DONT-FRAGMENT 2528 attribute, then set the DF bit in the outgoing IP header to 1. In 2529 all other cases when sending an outgoing packet containing 2530 application data (e.g., Data indication, ChannelData message, or 2531 DONT-FRAGMENT attribute not included in the Send indication), copy 2532 the DF bit from the DF bit of the incoming packet that contained 2533 the application data. 2535 Set the other fragmentation fields (Identification, More 2536 Fragments, Fragment Offset) as appropriate for a packet 2537 originating from the server. 2539 Alternate Behavior: As described in the Preferred Behavior, except 2540 always assume the incoming DF bit is 0. 2542 In both the Preferred and Alternate Behaviors, the resulting 2543 packet may be too large for the outgoing link. If this is the 2544 case, then the normal fragmentation rules apply [RFC1122]. 2546 IPv4 Options 2548 Preferred Behavior: The outgoing packet is sent without any IPv4 2549 options. 2551 Alternate Behavior: Same as preferred. 2553 15. STUN Methods 2555 This section lists the codepoints for the STUN methods defined in 2556 this specification. See elsewhere in this document for the semantics 2557 of these methods. 2559 0x003 : Allocate (only request/response semantics defined) 2560 0x004 : Refresh (only request/response semantics defined) 2561 0x006 : Send (only indication semantics defined) 2562 0x007 : Data (only indication semantics defined) 2563 0x008 : CreatePermission (only request/response semantics defined 2564 0x009 : ChannelBind (only request/response semantics defined) 2566 16. STUN Attributes 2568 This STUN extension defines the following attributes: 2570 0x000C: CHANNEL-NUMBER 2571 0x000D: LIFETIME 2572 0x0010: Reserved (was BANDWIDTH) 2573 0x0012: XOR-PEER-ADDRESS 2574 0x0013: DATA 2575 0x0016: XOR-RELAYED-ADDRESS 2576 0x0017: REQUESTED-ADDRESS-FAMILY 2577 0x0018: EVEN-PORT 2578 0x0019: REQUESTED-TRANSPORT 2579 0x001A: DONT-FRAGMENT 2580 0x0021: Reserved (was TIMER-VAL) 2581 0x0022: RESERVATION-TOKEN 2582 TBD-CA: ADDITIONAL-ADDRESS-FAMILY 2583 TBD-CA: ADDRESS-ERROR-CODE 2584 TBD-CA: ICMP 2586 Some of these attributes have lengths that are not multiples of 4. 2587 By the rules of STUN, any attribute whose length is not a multiple of 2588 4 bytes MUST be immediately followed by 1 to 3 padding bytes to 2589 ensure the next attribute (if any) would start on a 4-byte boundary 2590 (see [I-D.ietf-tram-stunbis]). 2592 16.1. CHANNEL-NUMBER 2594 The CHANNEL-NUMBER attribute contains the number of the channel. The 2595 value portion of this attribute is 4 bytes long and consists of a 2596 16-bit unsigned integer, followed by a two-octet RFFU (Reserved For 2597 Future Use) field, which MUST be set to 0 on transmission and MUST be 2598 ignored on reception. 2600 0 1 2 3 2601 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 2602 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2603 | Channel Number | RFFU = 0 | 2604 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2606 16.2. LIFETIME 2608 The LIFETIME attribute represents the duration for which the server 2609 will maintain an allocation in the absence of a refresh. The value 2610 portion of this attribute is 4-bytes long and consists of a 32-bit 2611 unsigned integral value representing the number of seconds remaining 2612 until expiration. 2614 16.3. XOR-PEER-ADDRESS 2616 The XOR-PEER-ADDRESS specifies the address and port of the peer as 2617 seen from the TURN server. (For example, the peer's server-reflexive 2618 transport address if the peer is behind a NAT.) It is encoded in the 2619 same way as XOR-MAPPED-ADDRESS [I-D.ietf-tram-stunbis]. 2621 16.4. DATA 2623 The DATA attribute is present in all Send and Data indications. The 2624 value portion of this attribute is variable length and consists of 2625 the application data (that is, the data that would immediately follow 2626 the UDP header if the data was been sent directly between the client 2627 and the peer). If the length of this attribute is not a multiple of 2628 4, then padding must be added after this attribute. 2630 16.5. XOR-RELAYED-ADDRESS 2632 The XOR-RELAYED-ADDRESS is present in Allocate responses. It 2633 specifies the address and port that the server allocated to the 2634 client. It is encoded in the same way as XOR-MAPPED-ADDRESS 2635 [I-D.ietf-tram-stunbis]. 2637 16.6. REQUESTED-ADDRESS-FAMILY 2639 This attribute is used in Allocate and Refresh requests to specify 2640 the address type requested by the client. The value of this 2641 attribute is 4 bytes with the following format: 2643 0 1 2 3 2644 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 2645 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2646 | Family | Reserved | 2647 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2649 Family: there are two values defined for this field and specified in 2650 [I-D.ietf-tram-stunbis], Section 14.1: 0x01 for IPv4 addresses and 2651 0x02 for IPv6 addresses. 2653 Reserved: at this point, the 24 bits in the Reserved field MUST be 2654 set to zero by the client and MUST be ignored by the server. 2656 16.7. EVEN-PORT 2658 This attribute allows the client to request that the port in the 2659 relayed transport address be even, and (optionally) that the server 2660 reserve the next-higher port number. The value portion of this 2661 attribute is 1 byte long. Its format is: 2663 0 2664 0 1 2 3 4 5 6 7 2665 +-+-+-+-+-+-+-+-+ 2666 |R| RFFU | 2667 +-+-+-+-+-+-+-+-+ 2669 The value contains a single 1-bit flag: 2671 R: If 1, the server is requested to reserve the next-higher port 2672 number (on the same IP address) for a subsequent allocation. If 2673 0, no such reservation is requested. 2675 The other 7 bits of the attribute's value must be set to zero on 2676 transmission and ignored on reception. 2678 Since the length of this attribute is not a multiple of 4, padding 2679 must immediately follow this attribute. 2681 16.8. REQUESTED-TRANSPORT 2683 This attribute is used by the client to request a specific transport 2684 protocol for the allocated transport address. The value of this 2685 attribute is 4 bytes with the following format: 2687 0 1 2 3 2688 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 2689 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2690 | Protocol | RFFU | 2691 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2693 The Protocol field specifies the desired protocol. The codepoints 2694 used in this field are taken from those allowed in the Protocol field 2695 in the IPv4 header and the NextHeader field in the IPv6 header 2697 [Protocol-Numbers]. This specification only allows the use of 2698 codepoint 17 (User Datagram Protocol). 2700 The RFFU field MUST be set to zero on transmission and MUST be 2701 ignored on reception. It is reserved for future uses. 2703 16.9. DONT-FRAGMENT 2705 This attribute is used by the client to request that the server set 2706 the DF (Don't Fragment) bit in the IP header when relaying the 2707 application data onward to the peer. This attribute has no value 2708 part and thus the attribute length field is 0. 2710 16.10. RESERVATION-TOKEN 2712 The RESERVATION-TOKEN attribute contains a token that uniquely 2713 identifies a relayed transport address being held in reserve by the 2714 server. The server includes this attribute in a success response to 2715 tell the client about the token, and the client includes this 2716 attribute in a subsequent Allocate request to request the server use 2717 that relayed transport address for the allocation. 2719 The attribute value is 8 bytes and contains the token value. 2721 16.11. ADDITIONAL-ADDRESS-FAMILY 2723 This attribute is used by clients to request the allocation of a IPv4 2724 and IPv6 address type from a server. It is encoded in the same way 2725 as REQUESTED-ADDRESS-FAMILY Section 16.6. The ADDITIONAL-ADDRESS- 2726 FAMILY attribute MAY be present in Allocate request. The attribute 2727 value of 0x02 (IPv6 address) is the only valid value in Allocate 2728 request. 2730 16.12. ADDRESS-ERROR-CODE Attribute 2732 This attribute is used by servers to signal the reason for not 2733 allocating the requested address family. The value portion of this 2734 attribute is variable length with the following format: 2736 0 1 2 3 2737 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 2738 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2739 | Family | Rsvd |Class| Number | 2740 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2741 | Reason Phrase (variable) .. 2742 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2744 Family: there are two values defined for this field and specified in 2745 [I-D.ietf-tram-stunbis], Section 14.1: 0x01 for IPv4 addresses and 2746 0x02 for IPv6 addresses. 2748 Reserved: at this point, the 13 bits in the Reserved field MUST be 2749 set to zero by the client and MUST be ignored by the server. 2751 Class: The Class represents the hundreds digit of the error code and 2752 is defined in section 14.8 of [I-D.ietf-tram-stunbis]. 2754 Number: this 8-bit field contains the reason server cannot allocate 2755 one of the requested address types. The error code values could 2756 be either 440 (unsupported address family) or 508 (insufficient 2757 capacity). The number representation is defined in section 14.8 2758 of [I-D.ietf-tram-stunbis]. 2760 Reason Phrase: The recommended reason phrases for error codes 440 2761 and 508 are explained in Section 17. 2763 16.13. ICMP Attribute 2765 This attribute is used by servers to signal the reason an UDP packet 2766 was dropped. The following is the format of the ICMP attribute. 2768 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 2769 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2770 | Reserved | ICMP Type | ICMP Code | 2771 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2773 Reserved: This field MUST be set to 0 when sent, and MUST be ignored 2774 when received. 2776 ICMP Type: The field contains the value in the ICMP type. Its 2777 interpretation depends whether the ICMP was received over IPv4 or 2778 IPv6. 2780 ICMP Code: The field contains the value in the ICMP code. Its 2781 interpretation depends whether the ICMP was received over IPv4 or 2782 IPv6. 2784 17. STUN Error Response Codes 2786 This document defines the following error response codes: 2788 403 (Forbidden): The request was valid but cannot be performed due 2789 to administrative or similar restrictions. 2791 437 (Allocation Mismatch): A request was received by the server that 2792 requires an allocation to be in place, but no allocation exists, 2793 or a request was received that requires no allocation, but an 2794 allocation exists. 2796 440 (Address Family not Supported): The server does not support the 2797 address family requested by the client. 2799 441 (Wrong Credentials): The credentials in the (non-Allocate) 2800 request do not match those used to create the allocation. 2802 442 (Unsupported Transport Protocol): The Allocate request asked the 2803 server to use a transport protocol between the server and the peer 2804 that the server does not support. NOTE: This does NOT refer to 2805 the transport protocol used in the 5-tuple. 2807 443 (Peer Address Family Mismatch). A peer address is part of a 2808 different address family than that of the relayed transport 2809 address of the allocation. 2811 486 (Allocation Quota Reached): No more allocations using this 2812 username can be created at the present time. 2814 508 (Insufficient Capacity): The server is unable to carry out the 2815 request due to some capacity limit being reached. In an Allocate 2816 response, this could be due to the server having no more relayed 2817 transport addresses available at that time, having none with the 2818 requested properties, or the one that corresponds to the specified 2819 reservation token is not available. 2821 18. Detailed Example 2823 This section gives an example of the use of TURN, showing in detail 2824 the contents of the messages exchanged. The example uses the network 2825 diagram shown in the Overview (Figure 1). 2827 For each message, the attributes included in the message and their 2828 values are shown. For convenience, values are shown in a human- 2829 readable format rather than showing the actual octets; for example, 2830 "XOR-RELAYED-ADDRESS=192.0.2.15:9000" shows that the XOR-RELAYED- 2831 ADDRESS attribute is included with an address of 192.0.2.15 and a 2832 port of 9000, here the address and port are shown before the xor-ing 2833 is done. For attributes with string-like values (e.g., 2834 SOFTWARE="Example client, version 1.03" and 2835 NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda"), the value of the attribute 2836 is shown in quotes for readability, but these quotes do not appear in 2837 the actual value. 2839 TURN TURN Peer Peer 2840 client server A B 2841 | | | | 2842 |--- Allocate request -------------->| | | 2843 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2844 | SOFTWARE="Example client, version 1.03" | | 2845 | LIFETIME=3600 (1 hour) | | | 2846 | REQUESTED-TRANSPORT=17 (UDP) | | | 2847 | DONT-FRAGMENT | | | 2848 | | | | 2849 |<-- Allocate error response --------| | | 2850 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2851 | SOFTWARE="Example server, version 1.17" | | 2852 | ERROR-CODE=401 (Unauthorized) | | | 2853 | REALM="example.com" | | | 2854 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2855 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 2856 | | | | 2857 |--- Allocate request -------------->| | | 2858 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2859 | SOFTWARE="Example client 1.03" | | | 2860 | LIFETIME=3600 (1 hour) | | | 2861 | REQUESTED-TRANSPORT=17 (UDP) | | | 2862 | DONT-FRAGMENT | | | 2863 | USERNAME="George" | | | 2864 | REALM="example.com" | | | 2865 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2866 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 2867 | PASSWORD-ALGORITHM=SHA256 | | | 2868 | MESSAGE-INTEGRITY=... | | | 2869 | MESSAGE-INTEGRITY-SHA256=... | | | 2870 | | | | 2871 |<-- Allocate success response ------| | | 2872 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2873 | SOFTWARE="Example server, version 1.17" | | 2874 | LIFETIME=1200 (20 minutes) | | | 2875 | XOR-RELAYED-ADDRESS=192.0.2.15:50000 | | 2876 | XOR-MAPPED-ADDRESS=192.0.2.1:7000 | | 2877 | MESSAGE-INTEGRITY=... | | | 2879 The client begins by selecting a host transport address to use for 2880 the TURN session; in this example, the client has selected 2881 198.51.100.2:49721 as shown in Figure 1. The client then sends an 2882 Allocate request to the server at the server transport address. The 2883 client randomly selects a 96-bit transaction id of 2884 0xA56250D3F17ABE679422DE85 for this transaction; this is encoded in 2885 the transaction id field in the fixed header. The client includes a 2886 SOFTWARE attribute that gives information about the client's 2887 software; here the value is "Example client, version 1.03" to 2888 indicate that this is version 1.03 of something called the Example 2889 client. The client includes the LIFETIME attribute because it wishes 2890 the allocation to have a longer lifetime than the default of 10 2891 minutes; the value of this attribute is 3600 seconds, which 2892 corresponds to 1 hour. The client must always include a REQUESTED- 2893 TRANSPORT attribute in an Allocate request and the only value allowed 2894 by this specification is 17, which indicates UDP transport between 2895 the server and the peers. The client also includes the DONT-FRAGMENT 2896 attribute because it wishes to use the DONT-FRAGMENT attribute later 2897 in Send indications; this attribute consists of only an attribute 2898 header, there is no value part. We assume the client has not 2899 recently interacted with the server, thus the client does not include 2900 USERNAME, USERHASH, REALM, NONCE, PASSWORD-ALGORITHMS, PASSWORD- 2901 ALGORITHM, MESSAGE-INTEGRITY or MESSAGE-INTEGRITY-SHA256 attribute. 2902 Finally, note that the order of attributes in a message is arbitrary 2903 (except for the MESSAGE-INTEGRITY, MESSAGE-INTEGRITY-SHA256 and 2904 FINGERPRINT attributes) and the client could have used a different 2905 order. 2907 Servers require any request to be authenticated. Thus, when the 2908 server receives the initial Allocate request, it rejects the request 2909 because the request does not contain the authentication attributes. 2910 Following the procedures of the long-term credential mechanism of 2911 STUN [I-D.ietf-tram-stunbis], the server includes an ERROR-CODE 2912 attribute with a value of 401 (Unauthorized), a REALM attribute that 2913 specifies the authentication realm used by the server (in this case, 2914 the server's domain "example.com"), and a nonce value in a NONCE 2915 attribute. The NONCE attribute starts with the "nonce cookie" with 2916 the STUN Security Feature "Password algorithm" bit set to 1. The 2917 server includes a PASSWORD-ALGORITHMS attribute that specifies the 2918 list of algorithms that the server can use to derive the long-term 2919 password. If the server sets the STUN Security Feature "Username 2920 anonymity" bit to 1 then the client uses the USERHASH attribute 2921 instead of the USERNAME attribute in the Allocate request to 2922 anonymise the username. The server also includes a SOFTWARE 2923 attribute that gives information about the server's software. 2925 The client, upon receipt of the 401 error, re-attempts the Allocate 2926 request, this time including the authentication attributes. The 2927 client selects a new transaction id, and then populates the new 2928 Allocate request with the same attributes as before. The client 2929 includes a USERNAME attribute and uses the realm value received from 2930 the server to help it determine which value to use; here the client 2931 is configured to use the username "George" for the realm 2932 "example.com". The client includes the PASSWORD-ALGORITHM attribute 2933 indicating the algorithm that the server must use to derive the long- 2934 term password. The client also includes the REALM and NONCE 2935 attributes, which are just copied from the 401 error response. 2936 Finally, the client includes MESSAGE-INTEGRITY and MESSAGE-INTEGRITY- 2937 SHA256 attributes as the last attributes in the message, whose values 2938 are Hashed Message Authentication Code - Secure Hash Algorithm 1 2939 (HMAC-SHA1) hash and Hashed Message Authentication Code - Secure Hash 2940 Algorithm 2 (HMAC-SHA2) hash over the contents of the message (shown 2941 as just "..." above); this HMAC-SHA1 and HMAC-SHA2 computation 2942 includes a password value. Thus, an attacker cannot compute the 2943 message integrity value without somehow knowing the secret password. 2945 The server, upon receipt of the authenticated Allocate request, 2946 checks that everything is OK, then creates an allocation. The server 2947 replies with an Allocate success response. The server includes a 2948 LIFETIME attribute giving the lifetime of the allocation; here, the 2949 server has reduced the client's requested 1-hour lifetime to just 20 2950 minutes, because this particular server doesn't allow lifetimes 2951 longer than 20 minutes. The server includes an XOR-RELAYED-ADDRESS 2952 attribute whose value is the relayed transport address of the 2953 allocation. The server includes an XOR-MAPPED-ADDRESS attribute 2954 whose value is the server-reflexive address of the client; this value 2955 is not used otherwise in TURN but is returned as a convenience to the 2956 client. The server includes either a MESSAGE-INTEGRITY or MESSAGE- 2957 INTEGRITY-SHA256 attribute to authenticate the response and to ensure 2958 its integrity; note that the response does not contain the USERNAME, 2959 REALM, and NONCE attributes. The server also includes a SOFTWARE 2960 attribute. 2962 TURN TURN Peer Peer 2963 client server A B 2964 |--- CreatePermission request ------>| | | 2965 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2966 | XOR-PEER-ADDRESS=192.0.2.150:0 | | | 2967 | USERNAME="George" | | | 2968 | REALM="example.com" | | | 2969 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2970 | MESSAGE-INTEGRITY=... | | | 2971 | | | | 2972 |<-- CreatePermission success resp.--| | | 2973 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2974 | MESSAGE-INTEGRITY=... | | | 2976 The client then creates a permission towards Peer A in preparation 2977 for sending it some application data. This is done through a 2978 CreatePermission request. The XOR-PEER-ADDRESS attribute contains 2979 the IP address for which a permission is established (the IP address 2980 of peer A); note that the port number in the attribute is ignored 2981 when used in a CreatePermission request, and here it has been set to 2982 0; also, note how the client uses Peer A's server-reflexive IP 2983 address and not its (private) host address. The client uses the same 2984 username, realm, and nonce values as in the previous request on the 2985 allocation. Though it is allowed to do so, the client has chosen not 2986 to include a SOFTWARE attribute in this request. 2988 The server receives the CreatePermission request, creates the 2989 corresponding permission, and then replies with a CreatePermission 2990 success response. Like the client, the server chooses not to include 2991 the SOFTWARE attribute in its reply. Again, note how success 2992 responses contain a MESSAGE-INTEGRITY or MESSAGE-INTEGRITY-SHA256 2993 attribute (assuming the server uses the long-term credential 2994 mechanism), but no USERNAME, REALM, and NONCE attributes. 2996 TURN TURN Peer Peer 2997 client server A B 2998 |--- Send indication --------------->| | | 2999 | Transaction-Id=0x1278E9ACA2711637EF7D3328 | | 3000 | XOR-PEER-ADDRESS=192.0.2.150:32102 | | 3001 | DONT-FRAGMENT | | | 3002 | DATA=... | | | 3003 | |-- UDP dgm ->| | 3004 | | data=... | | 3005 | | | | 3006 | |<- UDP dgm --| | 3007 | | data=... | | 3008 |<-- Data indication ----------------| | | 3009 | Transaction-Id=0x8231AE8F9242DA9FF287FEFF | | 3010 | XOR-PEER-ADDRESS=192.0.2.150:32102 | | 3011 | DATA=... | | | 3013 The client now sends application data to Peer A using a Send 3014 indication. Peer A's server-reflexive transport address is specified 3015 in the XOR-PEER-ADDRESS attribute, and the application data (shown 3016 here as just "...") is specified in the DATA attribute. The client 3017 is doing a form of path MTU discovery at the application layer and 3018 thus specifies (by including the DONT-FRAGMENT attribute) that the 3019 server should set the DF bit in the UDP datagram to send to the peer. 3020 Indications cannot be authenticated using the long-term credential 3021 mechanism of STUN, so no MESSAGE-INTEGRITY or MESSAGE-INTEGRITY- 3022 SHA256 attribute is included in the message. An application wishing 3023 to ensure that its data is not altered or forged must integrity- 3024 protect its data at the application level. 3026 Upon receipt of the Send indication, the server extracts the 3027 application data and sends it in a UDP datagram to Peer A, with the 3028 relayed transport address as the source transport address of the 3029 datagram, and with the DF bit set as requested. Note that, had the 3030 client not previously established a permission for Peer A's server- 3031 reflexive IP address, then the server would have silently discarded 3032 the Send indication instead. 3034 Peer A then replies with its own UDP datagram containing application 3035 data. The datagram is sent to the relayed transport address on the 3036 server. When this arrives, the server creates a Data indication 3037 containing the source of the UDP datagram in the XOR-PEER-ADDRESS 3038 attribute, and the data from the UDP datagram in the DATA attribute. 3039 The resulting Data indication is then sent to the client. 3041 TURN TURN Peer Peer 3042 client server A B 3043 |--- ChannelBind request ----------->| | | 3044 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 3045 | CHANNEL-NUMBER=0x4000 | | | 3046 | XOR-PEER-ADDRESS=192.0.2.210:49191 | | 3047 | USERNAME="George" | | | 3048 | REALM="example.com" | | | 3049 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 3050 | MESSAGE-INTEGRITY=... | | | 3051 | | | | 3052 |<-- ChannelBind success response ---| | | 3053 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 3054 | MESSAGE-INTEGRITY=... | | | 3056 The client now binds a channel to Peer B, specifying a free channel 3057 number (0x4000) in the CHANNEL-NUMBER attribute, and Peer B's 3058 transport address in the XOR-PEER-ADDRESS attribute. As before, the 3059 client re-uses the username, realm, and nonce from its last request 3060 in the message. 3062 Upon receipt of the request, the server binds the channel number to 3063 the peer, installs a permission for Peer B's IP address, and then 3064 replies with ChannelBind success response. 3066 TURN TURN Peer Peer 3067 client server A B 3068 |--- ChannelData ------------------->| | | 3069 | Channel-number=0x4000 |--- UDP datagram --------->| 3070 | Data=... | Data=... | 3071 | | | | 3072 | |<-- UDP datagram ----------| 3073 | | Data=... | | 3074 |<-- ChannelData --------------------| | | 3075 | Channel-number=0x4000 | | | 3076 | Data=... | | | 3078 The client now sends a ChannelData message to the server with data 3079 destined for Peer B. The ChannelData message is not a STUN message, 3080 and thus has no transaction id. Instead, it has only three fields: a 3081 channel number, data, and data length; here the channel number field 3082 is 0x4000 (the channel the client just bound to Peer B). When the 3083 server receives the ChannelData message, it checks that the channel 3084 is currently bound (which it is) and then sends the data onward to 3085 Peer B in a UDP datagram, using the relayed transport address as the 3086 source transport address and 192.0.2.210:49191 (the value of the XOR- 3087 PEER-ADDRESS attribute in the ChannelBind request) as the destination 3088 transport address. 3090 Later, Peer B sends a UDP datagram back to the relayed transport 3091 address. This causes the server to send a ChannelData message to the 3092 client containing the data from the UDP datagram. The server knows 3093 to which client to send the ChannelData message because of the 3094 relayed transport address at which the UDP datagram arrived, and 3095 knows to use channel 0x4000 because this is the channel bound to 3096 192.0.2.210:49191. Note that if there had not been any channel 3097 number bound to that address, the server would have used a Data 3098 indication instead. 3100 TURN TURN Peer Peer 3101 client server A B 3102 |--- Refresh request --------------->| | | 3103 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 3104 | SOFTWARE="Example client 1.03" | | | 3105 | USERNAME="George" | | | 3106 | REALM="example.com" | | | 3107 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 3108 | MESSAGE-INTEGRITY=... | | | 3109 | | | | 3110 |<-- Refresh error response ---------| | | 3111 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 3112 | SOFTWARE="Example server, version 1.17" | | 3113 | ERROR-CODE=438 (Stale Nonce) | | | 3114 | REALM="example.com" | | | 3115 | NONCE="obMatJos2AAABnpSw1Xw239bBwGYhjN" | | 3116 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 3117 | | | | 3118 |--- Refresh request --------------->| | | 3119 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 3120 | SOFTWARE="Example client 1.03" | | | 3121 | USERNAME="George" | | | 3122 | REALM="example.com" | | | 3123 | NONCE="obMatJos2AAABnpSw1Xw239bBwGYhjNj" | | 3124 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 3125 | PASSWORD-ALGORITHM=SHA256 | | | 3126 | MESSAGE-INTEGRITY=... | | | 3127 | | | | 3128 |<-- Refresh success response -------| | | 3129 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 3130 | SOFTWARE="Example server, version 1.17" | | 3131 | LIFETIME=600 (10 minutes) | | | 3133 Sometime before the 20 minute lifetime is up, the client refreshes 3134 the allocation. This is done using a Refresh request. As before, 3135 the client includes the latest username, realm, and nonce values in 3136 the request. The client also includes the SOFTWARE attribute, 3137 following the recommended practice of always including this attribute 3138 in Allocate and Refresh messages. When the server receives the 3139 Refresh request, it notices that the nonce value has expired, and so 3140 replies with 438 (Stale Nonce) error given a new nonce value. The 3141 client then reattempts the request, this time with the new nonce 3142 value. This second attempt is accepted, and the server replies with 3143 a success response. Note that the client did not include a LIFETIME 3144 attribute in the request, so the server refreshes the allocation for 3145 the default lifetime of 10 minutes (as can be seen by the LIFETIME 3146 attribute in the success response). 3148 19. Security Considerations 3150 This section considers attacks that are possible in a TURN 3151 deployment, and discusses how they are mitigated by mechanisms in the 3152 protocol or recommended practices in the implementation. 3154 Most of the attacks on TURN are mitigated by the server requiring 3155 requests be authenticated. Thus, this specification requires the use 3156 of authentication. The mandatory-to-implement mechanism is the long- 3157 term credential mechanism of STUN. Other authentication mechanisms 3158 of equal or stronger security properties may be used. However, it is 3159 important to ensure that they can be invoked in an inter-operable 3160 way. 3162 19.1. Outsider Attacks 3164 Outsider attacks are ones where the attacker has no credentials in 3165 the system, and is attempting to disrupt the service seen by the 3166 client or the server. 3168 19.1.1. Obtaining Unauthorized Allocations 3170 An attacker might wish to obtain allocations on a TURN server for any 3171 number of nefarious purposes. A TURN server provides a mechanism for 3172 sending and receiving packets while cloaking the actual IP address of 3173 the client. This makes TURN servers an attractive target for 3174 attackers who wish to use it to mask their true identity. 3176 An attacker might also wish to simply utilize the services of a TURN 3177 server without paying for them. Since TURN services require 3178 resources from the provider, it is anticipated that their usage will 3179 come with a cost. 3181 These attacks are prevented using the long-term credential mechanism, 3182 which allows the TURN server to determine the identity of the 3183 requestor and whether the requestor is allowed to obtain the 3184 allocation. 3186 19.1.2. Offline Dictionary Attacks 3188 The long-term credential mechanism used by TURN is subject to offline 3189 dictionary attacks. An attacker that is capable of eavesdropping on 3190 a message exchange between a client and server can determine the 3191 password by trying a number of candidate passwords and seeing if one 3192 of them is correct. This attack works when the passwords are low 3193 entropy, such as a word from the dictionary. This attack can be 3194 mitigated by using strong passwords with large entropy. In 3195 situations where even stronger mitigation is required, (D)TLS 3196 transport between the client and the server can be used. 3198 19.1.3. Faked Refreshes and Permissions 3200 An attacker might wish to attack an active allocation by sending it a 3201 Refresh request with an immediate expiration, in order to delete it 3202 and disrupt service to the client. This is prevented by 3203 authentication of refreshes. Similarly, an attacker wishing to send 3204 CreatePermission requests to create permissions to undesirable 3205 destinations is prevented from doing so through authentication. The 3206 motivations for such an attack are described in Section 19.2. 3208 19.1.4. Fake Data 3210 An attacker might wish to send data to the client or the peer, as if 3211 they came from the peer or client, respectively. To do that, the 3212 attacker can send the client a faked Data Indication or ChannelData 3213 message, or send the TURN server a faked Send Indication or 3214 ChannelData message. 3216 Since indications and ChannelData messages are not authenticated, 3217 this attack is not prevented by TURN. However, this attack is 3218 generally present in IP-based communications and is not substantially 3219 worsened by TURN. Consider a normal, non-TURN IP session between 3220 hosts A and B. An attacker can send packets to B as if they came 3221 from A by sending packets towards A with a spoofed IP address of B. 3222 This attack requires the attacker to know the IP addresses of A and 3223 B. With TURN, an attacker wishing to send packets towards a client 3224 using a Data indication needs to know its IP address (and port), the 3225 IP address and port of the TURN server, and the IP address and port 3226 of the peer (for inclusion in the XOR-PEER-ADDRESS attribute). To 3227 send a fake ChannelData message to a client, an attacker needs to 3228 know the IP address and port of the client, the IP address and port 3229 of the TURN server, and the channel number. This particular 3230 combination is mildly more guessable than in the non-TURN case. 3232 These attacks are more properly mitigated by application-layer 3233 authentication techniques. In the case of real-time traffic, usage 3234 of SRTP [RFC3711] prevents these attacks. 3236 In some situations, the TURN server may be situated in the network 3237 such that it is able to send to hosts to which the client cannot 3238 directly send. This can happen, for example, if the server is 3239 located behind a firewall that allows packets from outside the 3240 firewall to be delivered to the server, but not to other hosts behind 3241 the firewall. In these situations, an attacker could send the server 3242 a Send indication with an XOR-PEER-ADDRESS attribute containing the 3243 transport address of one of the other hosts behind the firewall. If 3244 the server was to allow relaying of traffic to arbitrary peers, then 3245 this would provide a way for the attacker to attack arbitrary hosts 3246 behind the firewall. 3248 To mitigate this attack, TURN requires that the client establish a 3249 permission to a host before sending it data. Thus, an attacker can 3250 only attack hosts with which the client is already communicating, 3251 unless the attacker is able to create authenticated requests. 3252 Furthermore, the server administrator may configure the server to 3253 restrict the range of IP addresses and ports to which it will relay 3254 data. To provide even greater security, the server administrator can 3255 require that the client use (D)TLS for all communication between the 3256 client and the server. 3258 19.1.5. Impersonating a Server 3260 When a client learns a relayed address from a TURN server, it uses 3261 that relayed address in application protocols to receive traffic. 3262 Therefore, an attacker wishing to intercept or redirect that traffic 3263 might try to impersonate a TURN server and provide the client with a 3264 faked relayed address. 3266 This attack is prevented through the long-term credential mechanism, 3267 which provides message integrity for responses in addition to 3268 verifying that they came from the server. Furthermore, an attacker 3269 cannot replay old server responses as the transaction id in the STUN 3270 header prevents this. Replay attacks are further thwarted through 3271 frequent changes to the nonce value. 3273 19.1.6. Eavesdropping Traffic 3275 TURN concerns itself primarily with authentication and message 3276 integrity. Confidentiality is only a secondary concern, as TURN 3277 control messages do not include information that is particularly 3278 sensitive. The primary protocol content of the messages is the IP 3279 address of the peer. If it is important to prevent an eavesdropper 3280 on a TURN connection from learning this, TURN can be run over (D)TLS. 3282 Confidentiality for the application data relayed by TURN is best 3283 provided by the application protocol itself, since running TURN over 3284 (D)TLS does not protect application data between the server and the 3285 peer. If confidentiality of application data is important, then the 3286 application should encrypt or otherwise protect its data. For 3287 example, for real-time media, confidentiality can be provided by 3288 using SRTP. 3290 19.1.7. TURN Loop Attack 3292 An attacker might attempt to cause data packets to loop indefinitely 3293 between two TURN servers. The attack goes as follows. First, the 3294 attacker sends an Allocate request to server A, using the source 3295 address of server B. Server A will send its response to server B, 3296 and for the attack to succeed, the attacker must have the ability to 3297 either view or guess the contents of this response, so that the 3298 attacker can learn the allocated relayed transport address. The 3299 attacker then sends an Allocate request to server B, using the source 3300 address of server A. Again, the attacker must be able to view or 3301 guess the contents of the response, so it can send learn the 3302 allocated relayed transport address. Using the same spoofed source 3303 address technique, the attacker then binds a channel number on server 3304 A to the relayed transport address on server B, and similarly binds 3305 the same channel number on server B to the relayed transport address 3306 on server A. Finally, the attacker sends a ChannelData message to 3307 server A. 3309 The result is a data packet that loops from the relayed transport 3310 address on server A to the relayed transport address on server B, 3311 then from server B's transport address to server A's transport 3312 address, and then around the loop again. 3314 This attack is mitigated as follows. By requiring all requests to be 3315 authenticated and/or by randomizing the port number allocated for the 3316 relayed transport address, the server forces the attacker to either 3317 intercept or view responses sent to a third party (in this case, the 3318 other server) so that the attacker can authenticate the requests and 3319 learn the relayed transport address. Without one of these two 3320 measures, an attacker can guess the contents of the responses without 3321 needing to see them, which makes the attack much easier to perform. 3322 Furthermore, by requiring authenticated requests, the server forces 3323 the attacker to have credentials acceptable to the server, which 3324 turns this from an outsider attack into an insider attack and allows 3325 the attack to be traced back to the client initiating it. 3327 The attack can be further mitigated by imposing a per-username limit 3328 on the bandwidth used to relay data by allocations owned by that 3329 username, to limit the impact of this attack on other allocations. 3330 More mitigation can be achieved by decrementing the TTL when relaying 3331 data packets (if the underlying OS allows this). 3333 19.2. Firewall Considerations 3335 A key security consideration of TURN is that TURN should not weaken 3336 the protections afforded by firewalls deployed between a client and a 3337 TURN server. It is anticipated that TURN servers will often be 3338 present on the public Internet, and clients may often be inside 3339 enterprise networks with corporate firewalls. If TURN servers 3340 provide a 'backdoor' for reaching into the enterprise, TURN will be 3341 blocked by these firewalls. 3343 TURN servers therefore emulate the behavior of NAT devices that 3344 implement address-dependent filtering [RFC4787], a property common in 3345 many firewalls as well. When a NAT or firewall implements this 3346 behavior, packets from an outside IP address are only allowed to be 3347 sent to an internal IP address and port if the internal IP address 3348 and port had recently sent a packet to that outside IP address. TURN 3349 servers introduce the concept of permissions, which provide exactly 3350 this same behavior on the TURN server. An attacker cannot send a 3351 packet to a TURN server and expect it to be relayed towards the 3352 client, unless the client has tried to contact the attacker first. 3354 It is important to note that some firewalls have policies that are 3355 even more restrictive than address-dependent filtering. Firewalls 3356 can also be configured with address- and port-dependent filtering, or 3357 can be configured to disallow inbound traffic entirely. In these 3358 cases, if a client is allowed to connect the TURN server, 3359 communications to the client will be less restrictive than what the 3360 firewall would normally allow. 3362 When a TURN server is configured to permit inbound STUN packets on 3363 the allocation's relayed address even if the source IP addresses of 3364 the STUN packets do not match the permissions installed, the TURN 3365 server MUST have a security policy for inbound STUN packets from IP 3366 addresses not matching the permissions installed in order to prevent 3367 an attacker from flooding the TURN client with STUN-like packets. 3368 The TURN server can limit forwarding to well-formed STUN connectivity 3369 check packets by looking for the STUN atrributes USERNAME and 3370 MESSAGE-INTEGRITY and verifying that the message does not exceed a 3371 specific configurable packet size. Additionally, the TURN server 3372 policy can be configured with maximum rate-limits for the number of 3373 STUN packets allowed in a TURN session, STUN packets allowed per 3374 second, and IP addresses allowed to send STUN packets. 3376 19.2.1. Faked Permissions 3378 In firewalls and NAT devices, permissions are granted implicitly 3379 through the traversal of a packet from the inside of the network 3380 towards the outside peer. Thus, a permission cannot, by definition, 3381 be created by any entity except one inside the firewall or NAT. With 3382 TURN, this restriction no longer holds. Since the TURN server sits 3383 outside the firewall, at attacker outside the firewall can now send a 3384 message to the TURN server and try to create a permission for itself. 3386 This attack is prevented because all messages that create permissions 3387 (i.e., ChannelBind and CreatePermission) are authenticated. 3389 19.2.2. Blacklisted IP Addresses 3391 Many firewalls can be configured with blacklists that prevent a 3392 client behind the firewall from sending packets to, or receiving 3393 packets from, ranges of blacklisted IP addresses. This is 3394 accomplished by inspecting the source and destination addresses of 3395 packets entering and exiting the firewall, respectively. 3397 This feature is also present in TURN, since TURN servers are allowed 3398 to arbitrarily restrict the range of addresses of peers that they 3399 will relay to. 3401 19.2.3. Running Servers on Well-Known Ports 3403 A malicious client behind a firewall might try to connect to a TURN 3404 server and obtain an allocation which it then uses to run a server. 3405 For example, a client might try to run a DNS server or FTP server. 3407 This is not possible in TURN. A TURN server will never accept 3408 traffic from a peer for which the client has not installed a 3409 permission. Thus, peers cannot just connect to the allocated port in 3410 order to obtain the service. 3412 19.3. Insider Attacks 3414 In insider attacks, a client has legitimate credentials but defies 3415 the trust relationship that goes with those credentials. These 3416 attacks cannot be prevented by cryptographic means but need to be 3417 considered in the design of the protocol. 3419 19.3.1. DoS against TURN Server 3421 A client wishing to disrupt service to other clients might obtain an 3422 allocation and then flood it with traffic, in an attempt to swamp the 3423 server and prevent it from servicing other legitimate clients. This 3424 is mitigated by the recommendation that the server limit the amount 3425 of bandwidth it will relay for a given username. This won't prevent 3426 a client from sending a large amount of traffic, but it allows the 3427 server to immediately discard traffic in excess. 3429 Since each allocation uses a port number on the IP address of the 3430 TURN server, the number of allocations on a server is finite. An 3431 attacker might attempt to consume all of them by requesting a large 3432 number of allocations. This is prevented by the recommendation that 3433 the server impose a limit of the number of allocations active at a 3434 time for a given username. 3436 19.3.2. Anonymous Relaying of Malicious Traffic 3438 TURN servers provide a degree of anonymization. A client can send 3439 data to peers without revealing its own IP address. TURN servers may 3440 therefore become attractive vehicles for attackers to launch attacks 3441 against targets without fear of detection. Indeed, it is possible 3442 for a client to chain together multiple TURN servers, such that any 3443 number of relays can be used before a target receives a packet. 3445 Administrators who are worried about this attack can maintain logs 3446 that capture the actual source IP and port of the client, and perhaps 3447 even every permission that client installs. This will allow for 3448 forensic tracing to determine the original source, should it be 3449 discovered that an attack is being relayed through a TURN server. 3451 19.3.3. Manipulating Other Allocations 3453 An attacker might attempt to disrupt service to other users of the 3454 TURN server by sending Refresh requests or CreatePermission requests 3455 that (through source address spoofing) appear to be coming from 3456 another user of the TURN server. TURN prevents this by requiring 3457 that the credentials used in CreatePermission, Refresh, and 3458 ChannelBind messages match those used to create the initial 3459 allocation. Thus, the fake requests from the attacker will be 3460 rejected. 3462 19.4. Tunnel Amplification Attack 3464 An attacker might attempt to cause data packets to loop numerous 3465 times between a TURN server and a tunnel between IPv4 and IPv6. The 3466 attack goes as follows. 3468 Suppose an attacker knows that a tunnel endpoint will forward 3469 encapsulated packets from a given IPv6 address (this doesn't 3470 necessarily need to be the tunnel endpoint's address). Suppose he 3471 then spoofs two packets from this address: 3473 1. An Allocate request asking for a v4 address, and 3475 2. A ChannelBind request establishing a channel to the IPv4 address 3476 of the tunnel endpoint 3478 Then he has set up an amplification attack: 3480 o The TURN relay will re-encapsulate IPv6 UDP data in v4 and send it 3481 to the tunnel endpoint 3483 o The tunnel endpoint will de-encapsulate packets from the v4 3484 interface and send them to v6 3486 So if the attacker sends a packet of the following form... 3488 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3489 UDP: 3490 TURN: 3491 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3492 UDP: 3493 TURN: 3494 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3495 UDP: 3496 TURN: 3497 ... 3499 Then the TURN relay and the tunnel endpoint will send it back and 3500 forth until the last TURN header is consumed, at which point the TURN 3501 relay will send an empty packet, which the tunnel endpoint will drop. 3503 The amplification potential here is limited by the MTU, so it's not 3504 huge: IPv6+UDP+TURN takes 334 bytes, so a four-to-one amplification 3505 out of a 1500-byte packet is possible. But the attacker could still 3506 increase traffic volume by sending multiple packets or by 3507 establishing multiple channels spoofed from different addresses 3508 behind the same tunnel endpoint. 3510 The attack is mitigated as follows. It is RECOMMENDED that TURN 3511 relays not accept allocation or channel binding requests from 3512 addresses known to be tunneled, and that they not forward data to 3513 such addresses. In particular, a TURN relay MUST NOT accept Teredo 3514 or 6to4 addresses in these requests. 3516 19.5. Other Considerations 3518 Any relay addresses learned through an Allocate request will not 3519 operate properly with IPsec Authentication Header (AH) [RFC4302] in 3520 transport or tunnel mode. However, tunnel-mode IPsec Encapsulating 3521 Security Payload (ESP) [RFC4303] should still operate. 3523 20. IANA Considerations 3525 [Paragraphs in braces should be removed by the RFC Editor upon 3526 publication] 3527 The codepoints for the STUN methods defined in this specification are 3528 listed in Section 15. [IANA is requested to update the reference 3529 from [RFC5766] to RFC-to-be for the STUN methods listed in 3530 Section 15.] 3532 The codepoints for the STUN attributes defined in this specification 3533 are listed in Section 16. [IANA is requested to update the reference 3534 from [RFC5766] to RFC-to-be for the STUN attributes CHANNEL-NUMBER, 3535 LIFETIME, Reserved (was BANDWIDTH), XOR-PEER-ADDRESS, DATA, XOR- 3536 RELAYED-ADDRESS, REQUESTED-ADDRESS-FAMILY, EVEN-PORT, REQUESTED- 3537 TRANSPORT, DONT-FRAGMENT, Reserved (was TIMER-VAL) and RESERVATION- 3538 TOKEN listed in Section 16.] 3540 [The ADDITIONAL-ADDRESS-FAMILY, ADDRESS-ERROR-CODE and ICMP 3541 attributes requires that IANA allocate a value in the "STUN 3542 attributes Registry" from the comprehension-optional range 3543 (0x8000-0xFFFF), to be replaced for TBD-CA throughout this document] 3545 The codepoints for the STUN error codes defined in this specification 3546 are listed in Section 17. [IANA is requested to update the reference 3547 from [RFC5766] to RFC-to-be for the STUN error codes listed in 3548 Section 17.] 3550 IANA has allocated the SRV service name of "turn" for TURN over UDP 3551 or TCP, and the service name of "turns" for TURN over (D)TLS. 3553 IANA has created a registry for TURN channel numbers, initially 3554 populated as follows: 3556 o 0x0000 through 0x3FFF: Reserved and not available for use, since 3557 they conflict with the STUN header. 3559 o 0x4000 through 0x4FFF: A TURN implementation is free to use 3560 channel numbers in this range. 3562 o 0x5000 through 0xFFFF: Unassigned. 3564 Any change to this registry must be made through an IETF Standards 3565 Action. 3567 21. IAB Considerations 3569 The IAB has studied the problem of "Unilateral Self Address Fixing" 3570 (UNSAF), which is the general process by which a client attempts to 3571 determine its address in another realm on the other side of a NAT 3572 through a collaborative protocol-reflection mechanism [RFC3424]. The 3573 TURN extension is an example of a protocol that performs this type of 3574 function. The IAB has mandated that any protocols developed for this 3575 purpose document a specific set of considerations. These 3576 considerations and the responses for TURN are documented in this 3577 section. 3579 Consideration 1: Precise definition of a specific, limited-scope 3580 problem that is to be solved with the UNSAF proposal. A short-term 3581 fix should not be generalized to solve other problems. Such 3582 generalizations lead to the prolonged dependence on and usage of the 3583 supposed short-term fix -- meaning that it is no longer accurate to 3584 call it "short-term". 3586 Response: TURN is a protocol for communication between a relay (= 3587 TURN server) and its client. The protocol allows a client that is 3588 behind a NAT to obtain and use a public IP address on the relay. As 3589 a convenience to the client, TURN also allows the client to determine 3590 its server-reflexive transport address. 3592 Consideration 2: Description of an exit strategy/transition plan. 3593 The better short-term fixes are the ones that will naturally see less 3594 and less use as the appropriate technology is deployed. 3596 Response: TURN will no longer be needed once there are no longer any 3597 NATs. Unfortunately, as of the date of publication of this document, 3598 it no longer seems very likely that NATs will go away any time soon. 3599 However, the need for TURN will also decrease as the number of NATs 3600 with the mapping property of Endpoint-Independent Mapping [RFC4787] 3601 increases. 3603 Consideration 3: Discussion of specific issues that may render 3604 systems more "brittle". For example, approaches that involve using 3605 data at multiple network layers create more dependencies, increase 3606 debugging challenges, and make it harder to transition. 3608 Response: TURN is "brittle" in that it requires the NAT bindings 3609 between the client and the server to be maintained unchanged for the 3610 lifetime of the allocation. This is typically done using keep- 3611 alives. If this is not done, then the client will lose its 3612 allocation and can no longer exchange data with its peers. 3614 Consideration 4: Identify requirements for longer-term, sound 3615 technical solutions; contribute to the process of finding the right 3616 longer-term solution. 3618 Response: The need for TURN will be reduced once NATs implement the 3619 recommendations for NAT UDP behavior documented in [RFC4787]. 3620 Applications are also strongly urged to use ICE [RFC5245] to 3621 communicate with peers; though ICE uses TURN, it does so only as a 3622 last resort, and uses it in a controlled manner. 3624 Consideration 5: Discussion of the impact of the noted practical 3625 issues with existing deployed NATs and experience reports. 3627 Response: Some NATs deployed today exhibit a mapping behavior other 3628 than Endpoint-Independent mapping. These NATs are difficult to work 3629 with, as they make it difficult or impossible for protocols like ICE 3630 to use server-reflexive transport addresses on those NATs. A client 3631 behind such a NAT is often forced to use a relay protocol like TURN 3632 because "UDP hole punching" techniques [RFC5128] do not work. 3634 22. Changes since RFC 5766 3636 This section lists the major changes in the TURN protocol from the 3637 original [RFC5766] specification. 3639 o IPv6 support. 3641 o REQUESTED-ADDRESS-FAMILY, ADDITIONAL-ADDRESS-FAMILY, AND ADDRESS- 3642 ERR-CODE attributes. 3644 o 440 (Address Family not Supported) and 443 (Peer Address Family 3645 Mismatch) responses. 3647 o Description of the tunnel amplification attack. 3649 o DTLS support. 3651 o More details on packet translations. 3653 o Add support for receiving ICMP packets. 3655 o Updates PMTUD. 3657 23. Acknowledgements 3659 Most of the text in this note comes from the original TURN 3660 specification, [RFC5766]. The authors would like to thank Rohan Mahy 3661 co-author of original TURN specification and everyone who had 3662 contributed to that document. The authors would also like to 3663 acknowledge that this document inherits material from [RFC6156]. 3665 Thanks to Justin Uberti, Pal Martinsen, Oleg Moskalenko, Aijun Wang 3666 and Simon Perreault for their help on SSODA mechanism. Authors would 3667 like to thank Gonzalo Salgueiro, Simon Perreault, Jonathan Lennox, 3668 Brandon Williams, Karl Stahl, Noriyuki Torii and Oleg Moskalenko for 3669 comments and review. The authors would like to thank Marc for his 3670 contributions to the text. Thanks to Eric Rescorla for proposing the 3671 update to allow the TURN server to forward inbound STUN connectivity 3672 checks without permission. 3674 24. References 3676 24.1. Normative References 3678 [I-D.ietf-tram-stunbis] 3679 Petit-Huguenin, M., Salgueiro, G., Rosenberg, J., Wing, 3680 D., Mahy, R., and P. Matthews, "Session Traversal 3681 Utilities for NAT (STUN)", draft-ietf-tram-stunbis-18 3682 (work in progress), May 2018. 3684 [RFC0792] Postel, J., "Internet Control Message Protocol", STD 5, 3685 RFC 792, DOI 10.17487/RFC0792, September 1981, 3686 . 3688 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 3689 Communication Layers", STD 3, RFC 1122, 3690 DOI 10.17487/RFC1122, October 1989, 3691 . 3693 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3694 Requirement Levels", BCP 14, RFC 2119, 3695 DOI 10.17487/RFC2119, March 1997, 3696 . 3698 [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black, 3699 "Definition of the Differentiated Services Field (DS 3700 Field) in the IPv4 and IPv6 Headers", RFC 2474, 3701 DOI 10.17487/RFC2474, December 1998, 3702 . 3704 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 3705 of Explicit Congestion Notification (ECN) to IP", 3706 RFC 3168, DOI 10.17487/RFC3168, September 2001, 3707 . 3709 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 3710 Control Message Protocol (ICMPv6) for the Internet 3711 Protocol Version 6 (IPv6) Specification", STD 89, 3712 RFC 4443, DOI 10.17487/RFC4443, March 2006, 3713 . 3715 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 3716 (TLS) Protocol Version 1.2", RFC 5246, 3717 DOI 10.17487/RFC5246, August 2008, 3718 . 3720 [RFC6347] Rescorla, E. and N. Modadugu, "Datagram Transport Layer 3721 Security Version 1.2", RFC 6347, DOI 10.17487/RFC6347, 3722 January 2012, . 3724 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 3725 "IPv6 Flow Label Specification", RFC 6437, 3726 DOI 10.17487/RFC6437, November 2011, 3727 . 3729 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3730 "Default Address Selection for Internet Protocol Version 6 3731 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3732 . 3734 [RFC7065] Petit-Huguenin, M., Nandakumar, S., Salgueiro, G., and P. 3735 Jones, "Traversal Using Relays around NAT (TURN) Uniform 3736 Resource Identifiers", RFC 7065, DOI 10.17487/RFC7065, 3737 November 2013, . 3739 [RFC7915] Bao, C., Li, X., Baker, F., Anderson, T., and F. Gont, 3740 "IP/ICMP Translation Algorithm", RFC 7915, 3741 DOI 10.17487/RFC7915, June 2016, 3742 . 3744 [RFC8305] Schinazi, D. and T. Pauly, "Happy Eyeballs Version 2: 3745 Better Connectivity Using Concurrency", RFC 8305, 3746 DOI 10.17487/RFC8305, December 2017, 3747 . 3749 24.2. Informative References 3751 [Frag-Harmful] 3752 "Fragmentation Considered Harmful", . 3755 [I-D.ietf-tram-stun-pmtud] 3756 Petit-Huguenin, M. and G. Salgueiro, "Path MTU Discovery 3757 Using Session Traversal Utilities for NAT (STUN)", draft- 3758 ietf-tram-stun-pmtud-08 (work in progress), May 2018. 3760 [I-D.rosenberg-mmusic-ice-nonsip] 3761 Rosenberg, J., "Guidelines for Usage of Interactive 3762 Connectivity Establishment (ICE) by non Session Initiation 3763 Protocol (SIP) Protocols", draft-rosenberg-mmusic-ice- 3764 nonsip-01 (work in progress), July 2008. 3766 [Port-Numbers] 3767 "IANA Port Numbers Registry", 2005, 3768 . 3770 [Protocol-Numbers] 3771 "IANA Protocol Numbers Registry", 2005, 3772 . 3774 [RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791, 3775 DOI 10.17487/RFC0791, September 1981, 3776 . 3778 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 3779 DOI 10.17487/RFC1191, November 1990, 3780 . 3782 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3783 and E. Lear, "Address Allocation for Private Internets", 3784 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3785 . 3787 [RFC1928] Leech, M., Ganis, M., Lee, Y., Kuris, R., Koblas, D., and 3788 L. Jones, "SOCKS Protocol Version 5", RFC 1928, 3789 DOI 10.17487/RFC1928, March 1996, 3790 . 3792 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3793 A., Peterson, J., Sparks, R., Handley, M., and E. 3794 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3795 DOI 10.17487/RFC3261, June 2002, 3796 . 3798 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3799 UNilateral Self-Address Fixing (UNSAF) Across Network 3800 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3801 November 2002, . 3803 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3804 Jacobson, "RTP: A Transport Protocol for Real-Time 3805 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3806 July 2003, . 3808 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3809 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3810 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3811 . 3813 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 3814 "Randomness Requirements for Security", BCP 106, RFC 4086, 3815 DOI 10.17487/RFC4086, June 2005, 3816 . 3818 [RFC4302] Kent, S., "IP Authentication Header", RFC 4302, 3819 DOI 10.17487/RFC4302, December 2005, 3820 . 3822 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 3823 RFC 4303, DOI 10.17487/RFC4303, December 2005, 3824 . 3826 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3827 Translation (NAT) Behavioral Requirements for Unicast 3828 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3829 2007, . 3831 [RFC4821] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 3832 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 3833 . 3835 [RFC5128] Srisuresh, P., Ford, B., and D. Kegel, "State of Peer-to- 3836 Peer (P2P) Communication across Network Address 3837 Translators (NATs)", RFC 5128, DOI 10.17487/RFC5128, March 3838 2008, . 3840 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 3841 (ICE): A Protocol for Network Address Translator (NAT) 3842 Traversal for Offer/Answer Protocols", RFC 5245, 3843 DOI 10.17487/RFC5245, April 2010, 3844 . 3846 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3847 Relays around NAT (TURN): Relay Extensions to Session 3848 Traversal Utilities for NAT (STUN)", RFC 5766, 3849 DOI 10.17487/RFC5766, April 2010, 3850 . 3852 [RFC5928] Petit-Huguenin, M., "Traversal Using Relays around NAT 3853 (TURN) Resolution Mechanism", RFC 5928, 3854 DOI 10.17487/RFC5928, August 2010, 3855 . 3857 [RFC6056] Larsen, M. and F. Gont, "Recommendations for Transport- 3858 Protocol Port Randomization", BCP 156, RFC 6056, 3859 DOI 10.17487/RFC6056, January 2011, 3860 . 3862 [RFC6062] Perreault, S., Ed. and J. Rosenberg, "Traversal Using 3863 Relays around NAT (TURN) Extensions for TCP Allocations", 3864 RFC 6062, DOI 10.17487/RFC6062, November 2010, 3865 . 3867 [RFC6156] Camarillo, G., Novo, O., and S. Perreault, Ed., "Traversal 3868 Using Relays around NAT (TURN) Extension for IPv6", 3869 RFC 6156, DOI 10.17487/RFC6156, April 2011, 3870 . 3872 [RFC7635] Reddy, T., Patil, P., Ravindranath, R., and J. Uberti, 3873 "Session Traversal Utilities for NAT (STUN) Extension for 3874 Third-Party Authorization", RFC 7635, 3875 DOI 10.17487/RFC7635, August 2015, 3876 . 3878 [RFC7983] Petit-Huguenin, M. and G. Salgueiro, "Multiplexing Scheme 3879 Updates for Secure Real-time Transport Protocol (SRTP) 3880 Extension for Datagram Transport Layer Security (DTLS)", 3881 RFC 7983, DOI 10.17487/RFC7983, September 2016, 3882 . 3884 [RFC8155] Patil, P., Reddy, T., and D. Wing, "Traversal Using Relays 3885 around NAT (TURN) Server Auto Discovery", RFC 8155, 3886 DOI 10.17487/RFC8155, April 2017, 3887 . 3889 Authors' Addresses 3891 Tirumaleswar Reddy (editor) 3892 McAfee, Inc. 3893 Embassy Golf Link Business Park 3894 Bangalore, Karnataka 560071 3895 India 3897 Email: kondtir@gmail.com 3899 Alan Johnston (editor) 3900 Rowan University 3901 Glassboro, NJ 3902 USA 3904 Email: alan.b.johnston@gmail.com 3905 Philip Matthews 3906 Alcatel-Lucent 3907 600 March Road 3908 Ottawa, Ontario 3909 Canada 3911 Email: philip_matthews@magma.ca 3913 Jonathan Rosenberg 3914 jdrosen.net 3915 Edison, NJ 3916 USA 3918 Email: jdrosen@jdrosen.net 3919 URI: http://www.jdrosen.net