idnits 2.17.1 draft-ietf-tram-turnbis-22.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 (February 27, 2019) is 1882 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-19 ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 6347 (Obsoleted by RFC 9147) ** Obsolete normative reference: RFC 7525 (Obsoleted by RFC 9325) == Outdated reference: A later version (-43) exists of draft-ietf-tls-dtls13-30 == Outdated reference: A later version (-20) exists of draft-ietf-tram-stun-pmtud-10 -- 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: 3 errors (**), 0 flaws (~~), 4 warnings (==), 5 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 Villanova University 6 Expires: August 31, 2019 P. Matthews 7 Alcatel-Lucent 8 J. Rosenberg 9 jdrosen.net 10 February 27, 2019 12 Traversal Using Relays around NAT (TURN): Relay Extensions to Session 13 Traversal Utilities for NAT (STUN) 14 draft-ietf-tram-turnbis-22 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 August 31, 2019. 51 Copyright Notice 53 Copyright (c) 2019 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 . . . . . . . . . . . . . . . . . . . . . . . 9 71 2.2. Allocations . . . . . . . . . . . . . . . . . . . . . . . 10 72 2.3. Permissions . . . . . . . . . . . . . . . . . . . . . . . 12 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 . . . . . . . . . 39 98 11. Send and Data Methods . . . . . . . . . . . . . . . . . . . . 39 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 . . . . . . . . . . . . . . 41 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 . . . . . . . . . . . . . . 72 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 . . . . . . 73 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 . . . . . . . . . . . . . . . . . . . . . . . . . 78 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 [RFC8445], 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 The TURN specification was originally published as [RFC5766], which 241 was updated by [RFC6156] to add IPv6 support. This document 242 supersedes and obsoletes both [RFC5766] and [RFC6156]. 244 2. Overview of Operation 246 This section gives an overview of the operation of TURN. It is non- 247 normative. 249 In a typical configuration, a TURN client is connected to a private 250 network [RFC1918] and through one or more NATs to the public 251 Internet. On the public Internet is a TURN server. Elsewhere in the 252 Internet are one or more peers with which the TURN client wishes to 253 communicate. These peers may or may not be behind one or more NATs. 254 The client uses the server as a relay to send packets to these peers 255 and to receive packets from these peers. 257 Peer A 258 Server-Reflexive +---------+ 259 Transport Address | | 260 192.0.2.150:32102 | | 261 | /| | 262 TURN | / ^| Peer A | 263 Client's Server | / || | 264 Host Transport Transport | // || | 265 Address Address | // |+---------+ 266 198.51.100.2:49721 192.0.2.15:3478 |+-+ // Peer A 267 | | ||N| / Host Transport 268 | +-+ | ||A|/ Address 269 | | | | v|T| 203.0.113.2:49582 270 | | | | /+-+ 271 +---------+| | | |+---------+ / +---------+ 272 | || |N| || | // | | 273 | TURN |v | | v| TURN |/ | | 274 | Client |----|A|----------| Server |------------------| Peer B | 275 | | | |^ | |^ ^| | 276 | | |T|| | || || | 277 +---------+ | || +---------+| |+---------+ 278 | || | | 279 | || | | 280 +-+| | | 281 | | | 282 | | | 283 Client's | Peer B 284 Server-Reflexive Relayed Transport 285 Transport Address Transport Address Address 286 192.0.2.1:7000 192.0.2.15:50000 192.0.2.210:49191 288 Figure 1 290 Figure 1 shows a typical deployment. In this figure, the TURN client 291 and the TURN server are separated by a NAT, with the client on the 292 private side and the server on the public side of the NAT. This NAT 293 is assumed to be a "bad" NAT; for example, it might have a mapping 294 property of "address-and-port-dependent mapping" (see [RFC4787]). 296 The client talks to the server from a (IP address, port) combination 297 called the client's HOST TRANSPORT ADDRESS. (The combination of an 298 IP address and port is called a TRANSPORT ADDRESS.) 300 The client sends TURN messages from its host transport address to a 301 transport address on the TURN server that is known as the TURN SERVER 302 TRANSPORT ADDRESS. The client learns the TURN server transport 303 address through some unspecified means (e.g., configuration), and 304 this address is typically used by many clients simultaneously. 306 Since the client is behind a NAT, the server sees packets from the 307 client as coming from a transport address on the NAT itself. This 308 address is known as the client's SERVER-REFLEXIVE transport address; 309 packets sent by the server to the client's server-reflexive transport 310 address will be forwarded by the NAT to the client's host transport 311 address. 313 The client uses TURN commands to create and manipulate an ALLOCATION 314 on the server. An allocation is a data structure on the server. 315 This data structure contains, amongst other things, the RELAYED 316 TRANSPORT ADDRESS for the allocation. The relayed transport address 317 is the transport address on the server that peers can use to have the 318 server relay data to the client. An allocation is uniquely 319 identified by its relayed transport address. 321 Once an allocation is created, the client can send application data 322 to the server along with an indication of to which peer the data is 323 to be sent, and the server will relay this data to the appropriate 324 peer. The client sends the application data to the server inside a 325 TURN message; at the server, the data is extracted from the TURN 326 message and sent to the peer in a UDP datagram. In the reverse 327 direction, a peer can send application data in a UDP datagram to the 328 relayed transport address for the allocation; the server will then 329 encapsulate this data inside a TURN message and send it to the client 330 along with an indication of which peer sent the data. Since the TURN 331 message always contains an indication of which peer the client is 332 communicating with, the client can use a single allocation to 333 communicate with multiple peers. 335 When the peer is behind a NAT, then the client must identify the peer 336 using its server-reflexive transport address rather than its host 337 transport address. For example, to send application data to Peer A 338 in the example above, the client must specify 192.0.2.150:32102 (Peer 339 A's server-reflexive transport address) rather than 203.0.113.2:49582 340 (Peer A's host transport address). 342 Each allocation on the server belongs to a single client and has 343 exactly one relayed transport address that is used only by that 344 allocation. Thus, when a packet arrives at a relayed transport 345 address on the server, the server knows for which client the data is 346 intended. 348 The client may have multiple allocations on a server at the same 349 time. 351 2.1. Transports 353 TURN, as defined in this specification, always uses UDP between the 354 server and the peer. However, this specification allows the use of 355 any one of UDP, TCP, Transport Layer Security (TLS) over TCP or 356 Datagram Transport Layer Security (DTLS) over UDP to carry the TURN 357 messages between the client and the server. 359 +----------------------------+---------------------+ 360 | TURN client to TURN server | TURN server to peer | 361 +----------------------------+---------------------+ 362 | UDP | UDP | 363 | TCP | UDP | 364 | TLS-over-TCP | UDP | 365 | DTLS-over-UDP | UDP | 366 +----------------------------+---------------------+ 368 If TCP or TLS-over-TCP is used between the client and the server, 369 then the server will convert between these transports and UDP 370 transport when relaying data to/from the peer. 372 Since this version of TURN only supports UDP between the server and 373 the peer, it is expected that most clients will prefer to use UDP 374 between the client and the server as well. That being the case, some 375 readers may wonder: Why also support TCP and TLS-over-TCP? 377 TURN supports TCP transport between the client and the server because 378 some firewalls are configured to block UDP entirely. These firewalls 379 block UDP but not TCP, in part because TCP has properties that make 380 the intention of the nodes being protected by the firewall more 381 obvious to the firewall. For example, TCP has a three-way handshake 382 that makes in clearer that the protected node really wishes to have 383 that particular connection established, while for UDP the best the 384 firewall can do is guess which flows are desired by using filtering 385 rules. Also, TCP has explicit connection teardown; while for UDP, 386 the firewall has to use timers to guess when the flow is finished. 388 TURN supports TLS-over-TCP transport and DTLS-over-UDP transport 389 between the client and the server because (D)TLS provides additional 390 security properties not provided by TURN's default digest 391 authentication; properties that some clients may wish to take 392 advantage of. In particular, (D)TLS provides a way for the client to 393 ascertain that it is talking to the correct server, and provides for 394 confidentiality of TURN control messages. If (D)TLS transport is 395 used between the TURN client and the TURN server, the guidance given 396 in [RFC7525] MUST be followed to avoid attacks on (D)TLS. TURN does 397 not require (D)TLS because the overhead of using (D)TLS is higher 398 than that of digest authentication; for example, using (D)TLS likely 399 means that most application data will be doubly encrypted (once by 400 (D)TLS and once to ensure it is still encrypted in the UDP datagram). 402 There is an extension to TURN for TCP transport between the server 403 and the peers [RFC6062]. For this reason, allocations that use UDP 404 between the server and the peers are known as UDP allocations, while 405 allocations that use TCP between the server and the peers are known 406 as TCP allocations. This specification describes only UDP 407 allocations. 409 In some applications for TURN, the client may send and receive 410 packets other than TURN packets on the host transport address it uses 411 to communicate with the server. This can happen, for example, when 412 using TURN with ICE. In these cases, the client can distinguish TURN 413 packets from other packets by examining the source address of the 414 arriving packet: those arriving from the TURN server will be TURN 415 packets. The algorithm of demultiplexing packets received from 416 multiple protocols on the host transport address is discussed in 417 [RFC7983]. 419 2.2. Allocations 421 To create an allocation on the server, the client uses an Allocate 422 transaction. The client sends an Allocate request to the server, and 423 the server replies with an Allocate success response containing the 424 allocated relayed transport address. The client can include 425 attributes in the Allocate request that describe the type of 426 allocation it desires (e.g., the lifetime of the allocation). Since 427 relaying data has security implications, the server requires that the 428 client authenticate itself, typically using STUN's long-term 429 credential mechanism or the STUN Extension for Third-Party 430 Authorization [RFC7635], to show that it is authorized to use the 431 server. 433 Once a relayed transport address is allocated, a client must keep the 434 allocation alive. To do this, the client periodically sends a 435 Refresh request to the server. TURN deliberately uses a different 436 method (Refresh rather than Allocate) for refreshes to ensure that 437 the client is informed if the allocation vanishes for some reason. 439 The frequency of the Refresh transaction is determined by the 440 lifetime of the allocation. The default lifetime of an allocation is 441 10 minutes -- this value was chosen to be long enough so that 442 refreshing is not typically a burden on the client, while expiring 443 allocations where the client has unexpectedly quit in a timely 444 manner. However, the client can request a longer lifetime in the 445 Allocate request and may modify its request in a Refresh request, and 446 the server always indicates the actual lifetime in the response. The 447 client must issue a new Refresh transaction within "lifetime" seconds 448 of the previous Allocate or Refresh transaction. Once a client no 449 longer wishes to use an allocation, it should delete the allocation 450 using a Refresh request with a requested lifetime of 0. 452 Both the server and client keep track of a value known as the 453 5-TUPLE. At the client, the 5-tuple consists of the client's host 454 transport address, the server transport address, and the transport 455 protocol used by the client to communicate with the server. At the 456 server, the 5-tuple value is the same except that the client's host 457 transport address is replaced by the client's server-reflexive 458 address, since that is the client's address as seen by the server. 460 Both the client and the server remember the 5-tuple used in the 461 Allocate request. Subsequent messages between the client and the 462 server use the same 5-tuple. In this way, the client and server know 463 which allocation is being referred to. If the client wishes to 464 allocate a second relayed transport address, it must create a second 465 allocation using a different 5-tuple (e.g., by using a different 466 client host address or port). 468 NOTE: While the terminology used in this document refers to 469 5-tuples, the TURN server can store whatever identifier it likes 470 that yields identical results. Specifically, an implementation 471 may use a file-descriptor in place of a 5-tuple to represent a TCP 472 connection. 474 TURN TURN Peer Peer 475 client server A B 476 |-- Allocate request --------------->| | | 477 | (invalid or missing credentials) | | | 478 | | | | 479 |<--------------- Allocate failure --| | | 480 | (401 Unauthenticated) | | | 481 | | | | 482 |-- Allocate request --------------->| | | 483 | (valid credentials) | | | 484 | | | | 485 |<---------- Allocate success resp --| | | 486 | (192.0.2.15:50000) | | | 487 // // // // 488 | | | | 489 |-- Refresh request ---------------->| | | 490 | | | | 491 |<----------- Refresh success resp --| | | 492 | | | | 494 Figure 2 496 In Figure 2, the client sends an Allocate request to the server with 497 invalid or missing credentials. Since the server requires that all 498 requests be authenticated using STUN's long-term credential 499 mechanism, the server rejects the request with a 401 (Unauthorized) 500 error code. The client then tries again, this time including 501 credentials. This time, the server accepts the Allocate request and 502 returns an Allocate success response containing (amongst other 503 things) the relayed transport address assigned to the allocation. 504 Sometime later, the client decides to refresh the allocation and thus 505 sends a Refresh request to the server. The refresh is accepted and 506 the server replies with a Refresh success response. 508 2.3. Permissions 510 To ease concerns amongst enterprise IT administrators that TURN could 511 be used to bypass corporate firewall security, TURN includes the 512 notion of permissions. TURN permissions mimic the address-restricted 513 filtering mechanism of NATs that comply with [RFC4787]. 515 An allocation can have zero or more permissions. Each permission 516 consists of an IP address and a lifetime. When the server receives a 517 UDP datagram on the allocation's relayed transport address, it first 518 checks the list of permissions. If the source IP address of the 519 datagram matches a permission, the application data is relayed to the 520 client, otherwise the UDP datagram is silently discarded. 522 A permission expires after 5 minutes if it is not refreshed, and 523 there is no way to explicitly delete a permission. This behavior was 524 selected to match the behavior of a NAT that complies with [RFC4787]. 526 The client can install or refresh a permission using either a 527 CreatePermission request or a ChannelBind request. Using the 528 CreatePermission request, multiple permissions can be installed or 529 refreshed with a single request -- this is important for applications 530 that use ICE. For security reasons, permissions can only be 531 installed or refreshed by transactions that can be authenticated; 532 thus, Send indications and ChannelData messages (which are used to 533 send data to peers) do not install or refresh any permissions. 535 Note that permissions are within the context of an allocation, so 536 adding or expiring a permission in one allocation does not affect 537 other allocations. 539 2.4. Send Mechanism 541 There are two mechanisms for the client and peers to exchange 542 application data using the TURN server. The first mechanism uses the 543 Send and Data methods, the second mechanism uses channels. Common to 544 both mechanisms is the ability of the client to communicate with 545 multiple peers using a single allocated relayed transport address; 546 thus, both mechanisms include a means for the client to indicate to 547 the server which peer should receive the data, and for the server to 548 indicate to the client which peer sent the data. 550 The Send mechanism uses Send and Data indications. Send indications 551 are used to send application data from the client to the server, 552 while Data indications are used to send application data from the 553 server to the client. 555 When using the Send mechanism, the client sends a Send indication to 556 the TURN server containing (a) an XOR-PEER-ADDRESS attribute 557 specifying the (server-reflexive) transport address of the peer and 558 (b) a DATA attribute holding the application data. When the TURN 559 server receives the Send indication, it extracts the application data 560 from the DATA attribute and sends it in a UDP datagram to the peer, 561 using the allocated relay address as the source address. Note that 562 there is no need to specify the relayed transport address, since it 563 is implied by the 5-tuple used for the Send indication. 565 In the reverse direction, UDP datagrams arriving at the relayed 566 transport address on the TURN server are converted into Data 567 indications and sent to the client, with the server-reflexive 568 transport address of the peer included in an XOR-PEER-ADDRESS 569 attribute and the data itself in a DATA attribute. Since the relayed 570 transport address uniquely identified the allocation, the server 571 knows which client should receive the data. 573 Some ICMP (Internet Control Message Protocol) packets arriving at the 574 relayed transport address on the TURN server may be converted into 575 Data indications and sent to the client, with the transport address 576 of the peer included in an XOR-PEER-ADDRESS attribute and the ICMP 577 type and code in a ICMP attribute. ICMP attribute forwarding always 578 uses Data indications containing the XOR-PEER-ADDRESS and ICMP 579 attributes, even when using the channel mechanism to forward UDP 580 data. 582 Send and Data indications cannot be authenticated, since the long- 583 term credential mechanism of STUN does not support authenticating 584 indications. This is not as big an issue as it might first appear, 585 since the client-to-server leg is only half of the total path to the 586 peer. Applications that want proper security should encrypt the data 587 sent between the client and a peer. 589 Because Send indications are not authenticated, it is possible for an 590 attacker to send bogus Send indications to the server, which will 591 then relay these to a peer. To partly mitigate this attack, TURN 592 requires that the client install a permission towards a peer before 593 sending data to it using a Send indication. 595 TURN TURN Peer Peer 596 client server A B 597 | | | | 598 |-- CreatePermission req (Peer A) -->| | | 599 |<-- CreatePermission success resp --| | | 600 | | | | 601 |--- Send ind (Peer A)-------------->| | | 602 | |=== data ===>| | 603 | | | | 604 | |<== data ====| | 605 |<-------------- Data ind (Peer A) --| | | 606 | | | | 607 | | | | 608 |--- Send ind (Peer B)-------------->| | | 609 | | dropped | | 610 | | | | 611 | |<== data ==================| 612 | dropped | | | 613 | | | | 615 Figure 3 617 In Figure 3, the client has already created an allocation and now 618 wishes to send data to its peers. The client first creates a 619 permission by sending the server a CreatePermission request 620 specifying Peer A's (server-reflexive) IP address in the XOR-PEER- 621 ADDRESS attribute; if this was not done, the server would not relay 622 data between the client and the server. The client then sends data 623 to Peer A using a Send indication; at the server, the application 624 data is extracted and forwarded in a UDP datagram to Peer A, using 625 the relayed transport address as the source transport address. When 626 a UDP datagram from Peer A is received at the relayed transport 627 address, the contents are placed into a Data indication and forwarded 628 to the client. Later, the client attempts to exchange data with Peer 629 B; however, no permission has been installed for Peer B, so the Send 630 indication from the client and the UDP datagram from the peer are 631 both dropped by the server. 633 2.5. Channels 635 For some applications (e.g., Voice over IP), the 36 bytes of overhead 636 that a Send indication or Data indication adds to the application 637 data can substantially increase the bandwidth required between the 638 client and the server. To remedy this, TURN offers a second way for 639 the client and server to associate data with a specific peer. 641 This second way uses an alternate packet format known as the 642 ChannelData message. The ChannelData message does not use the STUN 643 header used by other TURN messages, but instead has a 4-byte header 644 that includes a number known as a channel number. Each channel 645 number in use is bound to a specific peer and thus serves as a 646 shorthand for the peer's host transport address. 648 To bind a channel to a peer, the client sends a ChannelBind request 649 to the server, and includes an unbound channel number and the 650 transport address of the peer. Once the channel is bound, the client 651 can use a ChannelData message to send the server data destined for 652 the peer. Similarly, the server can relay data from that peer 653 towards the client using a ChannelData message. 655 Channel bindings last for 10 minutes unless refreshed -- this 656 lifetime was chosen to be longer than the permission lifetime. 657 Channel bindings are refreshed by sending another ChannelBind request 658 rebinding the channel to the peer. Like permissions (but unlike 659 allocations), there is no way to explicitly delete a channel binding; 660 the client must simply wait for it to time out. 662 TURN TURN Peer Peer 663 client server A B 664 | | | | 665 |-- ChannelBind req ---------------->| | | 666 | (Peer A to 0x4001) | | | 667 | | | | 668 |<---------- ChannelBind succ resp --| | | 669 | | | | 670 |-- (0x4001) data ------------------>| | | 671 | |=== data ===>| | 672 | | | | 673 | |<== data ====| | 674 |<------------------ (0x4001) data --| | | 675 | | | | 676 |--- Send ind (Peer A)-------------->| | | 677 | |=== data ===>| | 678 | | | | 679 | |<== data ====| | 680 |<------------------ (0x4001) data --| | | 681 | | | | 683 Figure 4 685 Figure 4 shows the channel mechanism in use. The client has already 686 created an allocation and now wishes to bind a channel to Peer A. To 687 do this, the client sends a ChannelBind request to the server, 688 specifying the transport address of Peer A and a channel number 689 (0x4001). After that, the client can send application data 690 encapsulated inside ChannelData messages to Peer A: this is shown as 691 "(0x4001) data" where 0x4001 is the channel number. When the 692 ChannelData message arrives at the server, the server transfers the 693 data to a UDP datagram and sends it to Peer A (which is the peer 694 bound to channel number 0x4001). 696 In the reverse direction, when Peer A sends a UDP datagram to the 697 relayed transport address, this UDP datagram arrives at the server on 698 the relayed transport address assigned to the allocation. Since the 699 UDP datagram was received from Peer A, which has a channel number 700 assigned to it, the server encapsulates the data into a ChannelData 701 message when sending the data to the client. 703 Once a channel has been bound, the client is free to intermix 704 ChannelData messages and Send indications. In the figure, the client 705 later decides to use a Send indication rather than a ChannelData 706 message to send additional data to Peer A. The client might decide 707 to do this, for example, so it can use the DONT-FRAGMENT attribute 708 (see the next section). However, once a channel is bound, the server 709 will always use a ChannelData message, as shown in the call flow. 711 Note that ChannelData messages can only be used for peers to which 712 the client has bound a channel. In the example above, Peer A has 713 been bound to a channel, but Peer B has not, so application data to 714 and from Peer B would use the Send mechanism. 716 2.6. Unprivileged TURN Servers 718 This version of TURN is designed so that the server can be 719 implemented as an application that runs in user space under commonly 720 available operating systems without requiring special privileges. 721 This design decision was made to make it easy to deploy a TURN 722 server: for example, to allow a TURN server to be integrated into a 723 peer-to-peer application so that one peer can offer NAT traversal 724 services to another peer. 726 This design decision has the following implications for data relayed 727 by a TURN server: 729 o The value of the Diffserv field may not be preserved across the 730 server; 732 o The Time to Live (TTL) field may be reset, rather than 733 decremented, across the server; 735 o The Explicit Congestion Notification (ECN) field may be reset by 736 the server; 738 o There is no end-to-end fragmentation, since the packet is re- 739 assembled at the server. 741 Future work may specify alternate TURN semantics that address these 742 limitations. 744 2.7. Avoiding IP Fragmentation 746 For reasons described in [Frag-Harmful], applications, especially 747 those sending large volumes of data, should try hard to avoid having 748 their packets fragmented. Applications using TCP can more or less 749 ignore this issue because fragmentation avoidance is now a standard 750 part of TCP, but applications using UDP (and thus any application 751 using this version of TURN) must handle fragmentation avoidance 752 themselves. 754 The application running on the client and the peer can take one of 755 two approaches to avoid IP fragmentation. 757 The first approach is to avoid sending large amounts of application 758 data in the TURN messages/UDP datagrams exchanged between the client 759 and the peer. This is the approach taken by most VoIP (Voice-over- 760 IP) applications. In this approach, the application exploits the 761 fact that the IP specification [RFC0791] specifies that IP packets up 762 to 576 bytes should never need to be fragmented. 764 The exact amount of application data that can be included while 765 avoiding fragmentation depends on the details of the TURN session 766 between the client and the server: whether UDP, TCP, or (D)TLS 767 transport is used, whether ChannelData messages or Send/Data 768 indications are used, and whether any additional attributes (such as 769 the DONT-FRAGMENT attribute) are included. Another factor, which is 770 hard to determine, is whether the MTU is reduced somewhere along the 771 path for other reasons, such as the use of IP-in-IP tunneling. 773 As a guideline, sending a maximum of 500 bytes of application data in 774 a single TURN message (by the client on the client-to-server leg) or 775 a UDP datagram (by the peer on the peer-to-server leg) will generally 776 avoid IP fragmentation. To further reduce the chance of 777 fragmentation, it is recommended that the client use ChannelData 778 messages when transferring significant volumes of data, since the 779 overhead of the ChannelData message is less than Send and Data 780 indications. 782 The second approach the client and peer can take to avoid 783 fragmentation is to use a path MTU discovery algorithm to determine 784 the maximum amount of application data that can be sent without 785 fragmentation. The classic path MTU discovery algorithm defined in 787 [RFC1191] may not be able to discover the MTU of the transmission 788 path between the client and the peer since: 790 - a probe packet with DF bit set to test a path for a larger MTU 791 can be dropped by routers, or 793 - ICMP error messages can be dropped by middle boxes. 795 As a result, the client and server need to use a path MTU discovery 796 algorithm that does not require ICMP messages. The Packetized Path 797 MTU Discovery algorithm defined in [RFC4821] is one such algorithm. 799 [I-D.ietf-tram-stun-pmtud] is an implementation of [RFC4821] that 800 uses STUN to discover the path MTU, and so might be a suitable 801 approach to be used in conjunction with a TURN server that supports 802 the DONT-FRAGMENT attribute. When the client includes the DONT- 803 FRAGMENT attribute in a Send indication, this tells the server to set 804 the DF bit in the resulting UDP datagram that it sends to the peer. 805 Since some servers may be unable to set the DF bit, the client should 806 also include this attribute in the Allocate request -- any server 807 that does not support the DONT-FRAGMENT attribute will indicate this 808 by rejecting the Allocate request. 810 2.8. RTP Support 812 One of the envisioned uses of TURN is as a relay for clients and 813 peers wishing to exchange real-time data (e.g., voice or video) using 814 RTP. To facilitate the use of TURN for this purpose, TURN includes 815 some special support for older versions of RTP. 817 Old versions of RTP [RFC3550] required that the RTP stream be on an 818 even port number and the associated RTP Control Protocol (RTCP) 819 stream, if present, be on the next highest port. To allow clients to 820 work with peers that still require this, TURN allows the client to 821 request that the server allocate a relayed transport address with an 822 even port number, and to optionally request the server reserve the 823 next-highest port number for a subsequent allocation. 825 2.9. Happy Eyeballs for TURN 827 If an IPv4 path to reach a TURN server is found, but the TURN 828 server's IPv6 path is not working, a dual-stack TURN client can 829 experience a significant connection delay compared to an IPv4-only 830 TURN client. To overcome these connection setup problems, the TURN 831 client needs to query both A and AAAA records for the TURN server 832 specified using a domain name and try connecting to the TURN server 833 using both IPv6 and IPv4 addresses in a fashion similar to the Happy 834 Eyeballs mechanism defined in [RFC8305]. The TURN client performs 835 the following steps based on the transport protocol being used to 836 connect to the TURN server. 838 o For TCP or TLS-over-TCP, initiate TCP connection to both IP 839 address families as discussed in [RFC8305], and use the first TCP 840 connection that is established. If connections are established on 841 both IP address families then terminate the TCP connection using 842 the IP address family with lower precedence [RFC6724]. 844 o For clear text UDP, send TURN Allocate requests to both IP address 845 families as discussed in [RFC8305], without authentication 846 information. If the TURN server requires authentication, it will 847 send back a 401 unauthenticated response and the TURN client uses 848 the first UDP connection on which a 401 error response is 849 received. If a 401 error response is received from both IP 850 address families then the TURN client can silently abandon the UDP 851 connection on the IP address family with lower precedence. If the 852 TURN server does not require authentication (as described in 853 Section 9 of [RFC8155]), it is possible for both Allocate requests 854 to succeed. In this case, the TURN client sends a Refresh with 855 LIFETIME value of 0 on the allocation using the IP address family 856 with lower precedence to delete the allocation. 858 o For DTLS over UDP, initiate DTLS handshake to both IP address 859 families as discussed in [RFC8305] and use the first DTLS session 860 that is established. If the DTLS session is established on both 861 IP address families then the client sends DTLS close_notify alert 862 to terminate the DTLS session using the IP address family with 863 lower precedence. If TURN over DTLS server has been configured to 864 require a cookie exchange (Section 4.2 in [RFC6347]) and 865 HelloVerifyRequest is received from the TURN servers on both IP 866 address families then the client can silently abandon the 867 connection on the IP address family with lower precedence. 869 3. Terminology 871 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 872 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 873 document are to be interpreted as described in RFC 2119 [RFC2119]. 875 Readers are expected to be familiar with [I-D.ietf-tram-stunbis] and 876 the terms defined there. 878 The following terms are used in this document: 880 TURN: The protocol spoken between a TURN client and a TURN server. 881 It is an extension to the STUN protocol [I-D.ietf-tram-stunbis]. 883 The protocol allows a client to allocate and use a relayed 884 transport address. 886 TURN client: A STUN client that implements this specification. 888 TURN server: A STUN server that implements this specification. It 889 relays data between a TURN client and its peer(s). 891 Peer: A host with which the TURN client wishes to communicate. The 892 TURN server relays traffic between the TURN client and its 893 peer(s). The peer does not interact with the TURN server using 894 the protocol defined in this document; rather, the peer receives 895 data sent by the TURN server and the peer sends data towards the 896 TURN server. 898 Transport Address: The combination of an IP address and a port. 900 Host Transport Address: A transport address on a client or a peer. 902 Server-Reflexive Transport Address: A transport address on the 903 "public side" of a NAT. This address is allocated by the NAT to 904 correspond to a specific host transport address. 906 Relayed Transport Address: A transport address on the TURN server 907 that is used for relaying packets between the client and a peer. 908 A peer sends to this address on the TURN server, and the packet is 909 then relayed to the client. 911 TURN Server Transport Address: A transport address on the TURN 912 server that is used for sending TURN messages to the server. This 913 is the transport address that the client uses to communicate with 914 the server. 916 Peer Transport Address: The transport address of the peer as seen by 917 the server. When the peer is behind a NAT, this is the peer's 918 server-reflexive transport address. 920 Allocation: The relayed transport address granted to a client 921 through an Allocate request, along with related state, such as 922 permissions and expiration timers. 924 5-tuple: The combination (client IP address and port, server IP 925 address and port, and transport protocol (currently one of UDP, 926 TCP, or (D)TLS)) used to communicate between the client and the 927 server. The 5-tuple uniquely identifies this communication 928 stream. The 5-tuple also uniquely identifies the Allocation on 929 the server. 931 Channel: A channel number and associated peer transport address. 932 Once a channel number is bound to a peer's transport address, the 933 client and server can use the more bandwidth-efficient ChannelData 934 message to exchange data. 936 Permission: The IP address and transport protocol (but not the port) 937 of a peer that is permitted to send traffic to the TURN server and 938 have that traffic relayed to the TURN client. The TURN server 939 will only forward traffic to its client from peers that match an 940 existing permission. 942 Realm: A string used to describe the server or a context within the 943 server. The realm tells the client which username and password 944 combination to use to authenticate requests. 946 Nonce: A string chosen at random by the server and included in the 947 message-digest. To prevent replay attacks, the server should 948 change the nonce regularly. 950 (D)TLS: This term is used for statements that apply to both 951 Transport Layer Security [RFC5246] [RFC8446] and Datagram 952 Transport Layer Security [RFC6347] [I-D.ietf-tls-dtls13]. 954 4. Discovery of TURN server 956 Methods of TURN server discovery, including using anycast, are 957 described in [RFC8155]. The syntax of the "turn" and "turns" URIs 958 are defined in Section 3.1 of [RFC7065]. 960 4.1. TURN URI Scheme Semantics 962 The "turn" and "turns" URI schemes are used to designate a TURN 963 server (also known as a relay) on Internet hosts accessible using the 964 TURN protocol. The TURN protocol supports sending messages over UDP, 965 TCP, TLS-over-TCP or DTLS-over-UDP. The "turns" URI scheme MUST be 966 used when TURN is run over TLS-over-TCP or in DTLS-over-UDP, and the 967 "turn" scheme MUST be used otherwise. The required part of 968 the "turn" URI denotes the TURN server host. The part, if 969 present, denotes the port on which the TURN server is awaiting 970 connection requests. If it is absent, the default port is 3478 for 971 both UDP and TCP. The default port for TURN over TLS and TURN over 972 DTLS is 5349. 974 5. General Behavior 976 This section contains general TURN processing rules that apply to all 977 TURN messages. 979 TURN is an extension to STUN. All TURN messages, with the exception 980 of the ChannelData message, are STUN-formatted messages. All the 981 base processing rules described in [I-D.ietf-tram-stunbis] apply to 982 STUN-formatted messages. This means that all the message-forming and 983 message-processing descriptions in this document are implicitly 984 prefixed with the rules of [I-D.ietf-tram-stunbis]. 986 [I-D.ietf-tram-stunbis] specifies an authentication mechanism called 987 the long-term credential mechanism. TURN servers and clients MUST 988 implement this mechanism. The server MUST demand that all requests 989 from the client be authenticated using this mechanism, or that a 990 equally strong or stronger mechanism for client authentication is 991 used. 993 Note that the long-term credential mechanism applies only to requests 994 and cannot be used to authenticate indications; thus, indications in 995 TURN are never authenticated. If the server requires requests to be 996 authenticated, then the server's administrator MUST choose a realm 997 value that will uniquely identify the username and password 998 combination that the client must use, even if the client uses 999 multiple servers under different administrations. The server's 1000 administrator MAY choose to allocate a unique username to each 1001 client, or MAY choose to allocate the same username to more than one 1002 client (for example, to all clients from the same department or 1003 company). For each Allocate request, the server SHOULD generate a 1004 new random nonce when the allocation is first attempted following the 1005 randomness recommendations in [RFC4086] and SHOULD expire the nonce 1006 at least once every hour during the lifetime of the allocation. 1008 All requests after the initial Allocate must use the same username as 1009 that used to create the allocation, to prevent attackers from 1010 hijacking the client's allocation. Specifically, if the server 1011 requires the use of the long-term credential mechanism, and if a non- 1012 Allocate request passes authentication under this mechanism, and if 1013 the 5-tuple identifies an existing allocation, but the request does 1014 not use the same username as used to create the allocation, then the 1015 request MUST be rejected with a 441 (Wrong Credentials) error. 1017 When a TURN message arrives at the server from the client, the server 1018 uses the 5-tuple in the message to identify the associated 1019 allocation. For all TURN messages (including ChannelData) EXCEPT an 1020 Allocate request, if the 5-tuple does not identify an existing 1021 allocation, then the message MUST either be rejected with a 437 1022 Allocation Mismatch error (if it is a request) or silently ignored 1023 (if it is an indication or a ChannelData message). A client 1024 receiving a 437 error response to a request other than Allocate MUST 1025 assume the allocation no longer exists. 1027 [I-D.ietf-tram-stunbis] defines a number of attributes, including the 1028 SOFTWARE and FINGERPRINT attributes. The client SHOULD include the 1029 SOFTWARE attribute in all Allocate and Refresh requests and MAY 1030 include it in any other requests or indications. The server SHOULD 1031 include the SOFTWARE attribute in all Allocate and Refresh responses 1032 (either success or failure) and MAY include it in other responses or 1033 indications. The client and the server MAY include the FINGERPRINT 1034 attribute in any STUN-formatted messages defined in this document. 1036 TURN does not use the backwards-compatibility mechanism described in 1037 [I-D.ietf-tram-stunbis]. 1039 TURN, as defined in this specification, supports both IPv4 and IPv6. 1040 IPv6 support in TURN includes IPv4-to-IPv6, IPv6-to-IPv6, and IPv6- 1041 to-IPv4 relaying. The REQUESTED-ADDRESS-FAMILY attribute allows a 1042 client to explicitly request the address type the TURN server will 1043 allocate (e.g., an IPv4-only node may request the TURN server to 1044 allocate an IPv6 address). The ADDITIONAL-ADDRESS-FAMILY attribute 1045 allows a client to request the server to allocate one IPv4 and one 1046 IPv6 relay address in a single Allocate request. This saves local 1047 ports on the client and reduces the number of messages sent between 1048 the client and the TURN server. 1050 By default, TURN runs on the same ports as STUN: 3478 for TURN over 1051 UDP and TCP, and 5349 for TURN over (D)TLS. However, TURN has its 1052 own set of Service Record (SRV) names: "turn" for UDP and TCP, and 1053 "turns" for (D)TLS. Either the DNS resolution procedures or the 1054 ALTERNATE-SERVER procedures, both described in Section 7, can be used 1055 to run TURN on a different port. 1057 To ensure interoperability, a TURN server MUST support the use of UDP 1058 transport between the client and the server, and SHOULD support the 1059 use of TCP, TLS-over-TCP and DTLS-over-UDP transports. 1061 When UDP or DTLS-over-UDP transport is used between the client and 1062 the server, the client will retransmit a request if it does not 1063 receive a response within a certain timeout period. Because of this, 1064 the server may receive two (or more) requests with the same 5-tuple 1065 and same transaction id. STUN requires that the server recognize 1066 this case and treat the request as idempotent (see 1067 [I-D.ietf-tram-stunbis]). Some implementations may choose to meet 1068 this requirement by remembering all received requests and the 1069 corresponding responses for 40 seconds. Other implementations may 1070 choose to reprocess the request and arrange that such reprocessing 1071 returns essentially the same response. To aid implementors who 1072 choose the latter approach (the so-called "stateless stack 1073 approach"), this specification includes some implementation notes on 1074 how this might be done. Implementations are free to choose either 1075 approach or choose some other approach that gives the same results. 1077 When TCP transport is used between the client and the server, it is 1078 possible that a bit error will cause a length field in a TURN packet 1079 to become corrupted, causing the receiver to lose synchronization 1080 with the incoming stream of TURN messages. A client or server that 1081 detects a long sequence of invalid TURN messages over TCP transport 1082 SHOULD close the corresponding TCP connection to help the other end 1083 detect this situation more rapidly. 1085 To mitigate either intentional or unintentional denial-of-service 1086 attacks against the server by clients with valid usernames and 1087 passwords, it is RECOMMENDED that the server impose limits on both 1088 the number of allocations active at one time for a given username and 1089 on the amount of bandwidth those allocations can use. The server 1090 should reject new allocations that would exceed the limit on the 1091 allowed number of allocations active at one time with a 486 1092 (Allocation Quota Exceeded) (see Section 7.2), and should discard 1093 application data traffic that exceeds the bandwidth quota. 1095 6. Allocations 1097 All TURN operations revolve around allocations, and all TURN messages 1098 are associated with either a single or dual allocation. An 1099 allocation conceptually consists of the following state data: 1101 o the relayed transport address or addresses; 1103 o the 5-tuple: (client's IP address, client's port, server IP 1104 address, server port, transport protocol); 1106 o the authentication information; 1108 o the time-to-expiry for each relayed transport address; 1110 o a list of permissions for each relayed transport address; 1112 o a list of channel to peer bindings for each relayed transport 1113 address. 1115 The relayed transport address is the transport address allocated by 1116 the server for communicating with peers, while the 5-tuple describes 1117 the communication path between the client and the server. On the 1118 client, the 5-tuple uses the client's host transport address; on the 1119 server, the 5-tuple uses the client's server-reflexive transport 1120 address. The relayed transport address MUST be unique across all 1121 allocations, so it can be used to uniquely identify the allocation. 1123 Both the relayed transport address and the 5-tuple MUST be unique 1124 across all allocations, so either one can be used to uniquely 1125 identify the allocation, and an allocation in this context can be 1126 either a single or dual allocation. 1128 The authentication information (e.g., username, password, realm, and 1129 nonce) is used to both verify subsequent requests and to compute the 1130 message integrity of responses. The username, realm, and nonce 1131 values are initially those used in the authenticated Allocate request 1132 that creates the allocation, though the server can change the nonce 1133 value during the lifetime of the allocation using a 438 (Stale Nonce) 1134 reply. Note that, rather than storing the password explicitly, for 1135 security reasons, it may be desirable for the server to store the key 1136 value, which is a secure hash over the username, realm, and password 1137 (see [I-D.ietf-tram-stunbis]). 1139 The time-to-expiry is the time in seconds left until the allocation 1140 expires. Each Allocate or Refresh transaction sets this timer, which 1141 then ticks down towards 0. By default, each Allocate or Refresh 1142 transaction resets this timer to the default lifetime value of 600 1143 seconds (10 minutes), but the client can request a different value in 1144 the Allocate and Refresh request. Allocations can only be refreshed 1145 using the Refresh request; sending data to a peer does not refresh an 1146 allocation. When an allocation expires, the state data associated 1147 with the allocation can be freed. 1149 The list of permissions is described in Section 9 and the list of 1150 channels is described in Section 12. 1152 7. Creating an Allocation 1154 An allocation on the server is created using an Allocate transaction. 1156 7.1. Sending an Allocate Request 1158 The client forms an Allocate request as follows. 1160 The client first picks a host transport address. It is RECOMMENDED 1161 that the client pick a currently unused transport address, typically 1162 by allowing the underlying OS to pick a currently unused port for a 1163 new socket. 1165 The client then picks a transport protocol to use between the client 1166 and the server. The transport protocol MUST be one of UDP, TCP, TLS- 1167 over-TCP or DTLS-over-UDP. Since this specification only allows UDP 1168 between the server and the peers, it is RECOMMENDED that the client 1169 pick UDP unless it has a reason to use a different transport. One 1170 reason to pick a different transport would be that the client 1171 believes, either through configuration or by experiment, that it is 1172 unable to contact any TURN server using UDP. See Section 2.1 for 1173 more discussion. 1175 The client also picks a server transport address, which SHOULD be 1176 done as follows. The client uses one or more procedures described in 1177 [RFC8155] to discover a TURN server and uses the TURN server 1178 resolution mechanism defined in [RFC5928] to get a list of server 1179 transport addresses that can be tried to create a TURN allocation. 1181 The client MUST include a REQUESTED-TRANSPORT attribute in the 1182 request. This attribute specifies the transport protocol between the 1183 server and the peers (note that this is NOT the transport protocol 1184 that appears in the 5-tuple). In this specification, the REQUESTED- 1185 TRANSPORT type is always UDP. This attribute is included to allow 1186 future extensions to specify other protocols. 1188 If the client wishes to obtain a relayed transport address of a 1189 specific address type then it includes a REQUESTED-ADDRESS-FAMILY 1190 attribute in the request. This attribute indicates the specific 1191 address type the client wishes the TURN server to allocate. Clients 1192 MUST NOT include more than one REQUESTED-ADDRESS-FAMILY attribute in 1193 an Allocate request. Clients MUST NOT include a REQUESTED-ADDRESS- 1194 FAMILY attribute in an Allocate request that contains a RESERVATION- 1195 TOKEN attribute, for the reasons outlined in [RFC6156]. 1197 If the client wishes to obtain one IPv6 and one IPv4 relayed 1198 transport address then it includes an ADDITIONAL-ADDRESS-FAMILY 1199 attribute in the request. This attribute specifies that the server 1200 must allocate both address types. The attribute value in the 1201 ADDITIONAL-ADDRESS-FAMILY MUST be set to 0x02 (IPv6 address family). 1202 Clients MUST NOT include REQUESTED-ADDRESS-FAMILY and ADDITIONAL- 1203 ADDRESS-FAMILY attributes in the same request. Clients MUST NOT 1204 include ADDITIONAL-ADDRESS-FAMILY attribute in a Allocate request 1205 that contains a RESERVATION-TOKEN attribute. Clients MUST NOT 1206 include ADDITIONAL-ADDRESS-FAMILY attribute in a Allocate request 1207 that contains an EVEN-PORT attribute with the R bit set to 1. The 1208 reason behind the restriction is if EVEN-PORT with R bit set to 1 is 1209 allowed with the ADDITIONAL-ADDRESS-FAMILY attribute, two tokens will 1210 have to be returned in success response and requires changes to the 1211 way RESERVATION-TOKEN is handled. 1213 If the client wishes the server to initialize the time-to-expiry 1214 field of the allocation to some value other than the default 1215 lifetime, then it MAY include a LIFETIME attribute specifying its 1216 desired value. This is just a hint, and the server may elect to use 1217 a different value. Note that the server will ignore requests to 1218 initialize the field to less than the default value. 1220 If the client wishes to later use the DONT-FRAGMENT attribute in one 1221 or more Send indications on this allocation, then the client SHOULD 1222 include the DONT-FRAGMENT attribute in the Allocate request. This 1223 allows the client to test whether this attribute is supported by the 1224 server. 1226 If the client requires the port number of the relayed transport 1227 address be even, the client includes the EVEN-PORT attribute. If 1228 this attribute is not included, then the port can be even or odd. By 1229 setting the R bit in the EVEN-PORT attribute to 1, the client can 1230 request that the server reserve the next highest port number (on the 1231 same IP address) for a subsequent allocation. If the R bit is 0, no 1232 such request is made. 1234 The client MAY also include a RESERVATION-TOKEN attribute in the 1235 request to ask the server to use a previously reserved port for the 1236 allocation. If the RESERVATION-TOKEN attribute is included, then the 1237 client MUST omit the EVEN-PORT attribute. 1239 Once constructed, the client sends the Allocate request on the 1240 5-tuple. 1242 7.2. Receiving an Allocate Request 1244 When the server receives an Allocate request, it performs the 1245 following checks: 1247 1. The server SHOULD require that the request be authenticated. 1248 The authentication of the request is optional to allow TURN 1249 servers provided by the local or access network to accept 1250 Allocation requests from new and/or guest users in the network 1251 who do not necessarily possess long term credentials for STUN 1252 authentication and its security implications are discussed in 1253 [RFC8155]. If the request is authenticated, the authentication 1254 MUST be done using the long-term credential mechanism of 1255 [I-D.ietf-tram-stunbis] unless the client and server agree to 1256 use another mechanism through some procedure outside the scope 1257 of this document. 1259 2. The server checks if the 5-tuple is currently in use by an 1260 existing allocation. If yes, the server rejects the request 1261 with a 437 (Allocation Mismatch) error. 1263 3. The server checks if the request contains a REQUESTED-TRANSPORT 1264 attribute. If the REQUESTED-TRANSPORT attribute is not included 1265 or is malformed, the server rejects the request with a 400 (Bad 1266 Request) error. Otherwise, if the attribute is included but 1267 specifies a protocol other that UDP, the server rejects the 1268 request with a 442 (Unsupported Transport Protocol) error. 1270 4. The request may contain a DONT-FRAGMENT attribute. If it does, 1271 but the server does not support sending UDP datagrams with the 1272 DF bit set to 1 (see Section 14), then the server treats the 1273 DONT-FRAGMENT attribute in the Allocate request as an unknown 1274 comprehension-required attribute. 1276 5. The server checks if the request contains a RESERVATION-TOKEN 1277 attribute. If yes, and the request also contains an EVEN-PORT 1278 or REQUESTED-ADDRESS-FAMILY or ADDITIONAL-ADDRESS-FAMILY 1279 attribute, the server rejects the request with a 400 (Bad 1280 Request) error. Otherwise, it checks to see if the token is 1281 valid (i.e., the token is in range and has not expired and the 1282 corresponding relayed transport address is still available). If 1283 the token is not valid for some reason, the server rejects the 1284 request with a 508 (Insufficient Capacity) error. 1286 6. The server checks if the request contains both REQUESTED- 1287 ADDRESS-FAMILY and ADDITIONAL-ADDRESS-FAMILY attributes. If 1288 yes, then the server rejects the request with a 400 (Bad 1289 Request) error. 1291 7. If the server does not support the address family requested by 1292 the client in REQUESTED-ADDRESS-FAMILY or is disabled by local 1293 policy, it MUST generate an Allocate error response, and it MUST 1294 include an ERROR-CODE attribute with the 440 (Address Family not 1295 Supported) response code. If the REQUESTED-ADDRESS-FAMILY 1296 attribute is absent and the server does not support IPv4 address 1297 family, the server MUST include an ERROR-CODE attribute with the 1298 440 (Address Family not Supported) response code. If the 1299 REQUESTED-ADDRESS-FAMILY attribute is absent and the server 1300 supports IPv4 address family, the server MUST allocate an IPv4 1301 relayed transport address for the TURN client. 1303 8. The server checks if the request contains an EVEN-PORT attribute 1304 with the R bit set to 1. If yes, and the request also contains 1305 an ADDITIONAL-ADDRESS-FAMILY attribute, the server rejects the 1306 request with a 400 (Bad Request) error. Otherwise, the server 1307 checks if it can satisfy the request (i.e., can allocate a 1308 relayed transport address as described below). If the server 1309 cannot satisfy the request, then the server rejects the request 1310 with a 508 (Insufficient Capacity) error. 1312 9. The server checks if the request contains an ADDITIONAL-ADDRESS- 1313 FAMILY attribute. If yes, and the attribute value is 0x01 (IPv4 1314 address family), then the server rejects the request with a 400 1315 (Bad Request) error. Otherwise, the server checks if it can 1316 allocate relayed transport addresses of both address types. If 1317 the server cannot satisfy the request, then the server rejects 1318 the request with a 508 (Insufficient Capacity) error. If the 1319 server can partially meet the request, i.e. if it can only 1320 allocate one relayed transport address of a specific address 1321 type, then it includes ADDRESS-ERROR-CODE attribute in the 1322 response to inform the client the reason for partial failure of 1323 the request. The error code value signaled in the ADDRESS- 1324 ERROR-CODE attribute could be 440 (Address Family not Supported) 1325 or 508 (Insufficient Capacity). If the server can fully meet 1326 the request, then the server allocates one IPv4 and one IPv6 1327 relay address, and returns an Allocate success response 1328 containing the relayed transport addresses assigned to the dual 1329 allocation in two XOR-RELAYED-ADDRESS attributes. 1331 10. At any point, the server MAY choose to reject the request with a 1332 486 (Allocation Quota Reached) error if it feels the client is 1333 trying to exceed some locally defined allocation quota. The 1334 server is free to define this allocation quota any way it 1335 wishes, but SHOULD define it based on the username used to 1336 authenticate the request, and not on the client's transport 1337 address. 1339 11. Also at any point, the server MAY choose to reject the request 1340 with a 300 (Try Alternate) error if it wishes to redirect the 1341 client to a different server. The use of this error code and 1342 attribute follow the specification in [I-D.ietf-tram-stunbis]. 1344 If all the checks pass, the server creates the allocation. The 1345 5-tuple is set to the 5-tuple from the Allocate request, while the 1346 list of permissions and the list of channels are initially empty. 1348 The server chooses a relayed transport address for the allocation as 1349 follows: 1351 o If the request contains a RESERVATION-TOKEN attribute, the server 1352 uses the previously reserved transport address corresponding to 1353 the included token (if it is still available). Note that the 1354 reservation is a server-wide reservation and is not specific to a 1355 particular allocation, since the Allocate request containing the 1356 RESERVATION-TOKEN uses a different 5-tuple than the Allocate 1357 request that made the reservation. The 5-tuple for the Allocate 1358 request containing the RESERVATION-TOKEN attribute can be any 1359 allowed 5-tuple; it can use a different client IP address and 1360 port, a different transport protocol, and even different server IP 1361 address and port (provided, of course, that the server IP address 1362 and port are ones on which the server is listening for TURN 1363 requests). 1365 o If the request contains an EVEN-PORT attribute with the R bit set 1366 to 0, then the server allocates a relayed transport address with 1367 an even port number. 1369 o If the request contains an EVEN-PORT attribute with the R bit set 1370 to 1, then the server looks for a pair of port numbers N and N+1 1371 on the same IP address, where N is even. Port N is used in the 1372 current allocation, while the relayed transport address with port 1373 N+1 is assigned a token and reserved for a future allocation. The 1374 server MUST hold this reservation for at least 30 seconds, and MAY 1375 choose to hold longer (e.g., until the allocation with port N 1376 expires). The server then includes the token in a RESERVATION- 1377 TOKEN attribute in the success response. 1379 o Otherwise, the server allocates any available relayed transport 1380 address. 1382 In all cases, the server SHOULD only allocate ports from the range 1383 49152 - 65535 (the Dynamic and/or Private Port range [Port-Numbers]), 1384 unless the TURN server application knows, through some means not 1385 specified here, that other applications running on the same host as 1386 the TURN server application will not be impacted by allocating ports 1387 outside this range. This condition can often be satisfied by running 1388 the TURN server application on a dedicated machine and/or by 1389 arranging that any other applications on the machine allocate ports 1390 before the TURN server application starts. In any case, the TURN 1391 server SHOULD NOT allocate ports in the range 0 - 1023 (the Well- 1392 Known Port range) to discourage clients from using TURN to run 1393 standard services. 1395 NOTE: The use of randomized port assignments to avoid certain 1396 types of attacks is described in [RFC6056]. It is RECOMMENDED 1397 that a TURN server implement a randomized port assignment 1398 algorithm from [RFC6056]. This is especially applicable to 1399 servers that choose to pre-allocate a number of ports from the 1400 underlying OS and then later assign them to allocations; for 1401 example, a server may choose this technique to implement the EVEN- 1402 PORT attribute. 1404 The server determines the initial value of the time-to-expiry field 1405 as follows. If the request contains a LIFETIME attribute, then the 1406 server computes the minimum of the client's proposed lifetime and the 1407 server's maximum allowed lifetime. If this computed value is greater 1408 than the default lifetime, then the server uses the computed lifetime 1409 as the initial value of the time-to-expiry field. Otherwise, the 1410 server uses the default lifetime. It is RECOMMENDED that the server 1411 use a maximum allowed lifetime value of no more than 3600 seconds (1 1412 hour). Servers that implement allocation quotas or charge users for 1413 allocations in some way may wish to use a smaller maximum allowed 1414 lifetime (perhaps as small as the default lifetime) to more quickly 1415 remove orphaned allocations (that is, allocations where the 1416 corresponding client has crashed or terminated or the client 1417 connection has been lost for some reason). Also, note that the time- 1418 to-expiry is recomputed with each successful Refresh request, and 1419 thus the value computed here applies only until the first refresh. 1421 Once the allocation is created, the server replies with a success 1422 response. The success response contains: 1424 o An XOR-RELAYED-ADDRESS attribute containing the relayed transport 1425 address. 1427 o A LIFETIME attribute containing the current value of the time-to- 1428 expiry timer. 1430 o A RESERVATION-TOKEN attribute (if a second relayed transport 1431 address was reserved). 1433 o An XOR-MAPPED-ADDRESS attribute containing the client's IP address 1434 and port (from the 5-tuple). 1436 NOTE: The XOR-MAPPED-ADDRESS attribute is included in the response 1437 as a convenience to the client. TURN itself does not make use of 1438 this value, but clients running ICE can often need this value and 1439 can thus avoid having to do an extra Binding transaction with some 1440 STUN server to learn it. 1442 The response (either success or error) is sent back to the client on 1443 the 5-tuple. 1445 NOTE: When the Allocate request is sent over UDP, 1446 [I-D.ietf-tram-stunbis] requires that the server handle the 1447 possible retransmissions of the request so that retransmissions do 1448 not cause multiple allocations to be created. Implementations may 1449 achieve this using the so-called "stateless stack approach" as 1450 follows. To detect retransmissions when the original request was 1451 successful in creating an allocation, the server can store the 1452 transaction id that created the request with the allocation data 1453 and compare it with incoming Allocate requests on the same 1454 5-tuple. Once such a request is detected, the server can stop 1455 parsing the request and immediately generate a success response. 1456 When building this response, the value of the LIFETIME attribute 1457 can be taken from the time-to-expiry field in the allocate state 1458 data, even though this value may differ slightly from the LIFETIME 1459 value originally returned. In addition, the server may need to 1460 store an indication of any reservation token returned in the 1461 original response, so that this may be returned in any 1462 retransmitted responses. 1464 For the case where the original request was unsuccessful in 1465 creating an allocation, the server may choose to do nothing 1466 special. Note, however, that there is a rare case where the 1467 server rejects the original request but accepts the retransmitted 1468 request (because conditions have changed in the brief intervening 1469 time period). If the client receives the first failure response, 1470 it will ignore the second (success) response and believe that an 1471 allocation was not created. An allocation created in this matter 1472 will eventually timeout, since the client will not refresh it. 1473 Furthermore, if the client later retries with the same 5-tuple but 1474 different transaction id, it will receive a 437 (Allocation 1475 Mismatch), which will cause it to retry with a different 5-tuple. 1476 The server may use a smaller maximum lifetime value to minimize 1477 the lifetime of allocations "orphaned" in this manner. 1479 7.3. Receiving an Allocate Success Response 1481 If the client receives an Allocate success response, then it MUST 1482 check that the mapped address and the relayed transport address or 1483 addresses are part of an address family or families that the client 1484 understands and is prepared to handle. If these addresses are not 1485 part of an address family or families which the client is prepared to 1486 handle, then the client MUST delete the allocation (Section 8) and 1487 MUST NOT attempt to create another allocation on that server until it 1488 believes the mismatch has been fixed. 1490 Otherwise, the client creates its own copy of the allocation data 1491 structure to track what is happening on the server. In particular, 1492 the client needs to remember the actual lifetime received back from 1493 the server, rather than the value sent to the server in the request. 1494 The client must also remember the 5-tuple used for the request and 1495 the username and password it used to authenticate the request to 1496 ensure that it reuses them for subsequent messages. The client also 1497 needs to track the channels and permissions it establishes on the 1498 server. 1500 If the client receives an Allocate success response but with ADDRESS- 1501 ERROR-CODE attribute in the response and the error code value 1502 signaled in the ADDRESS-ERROR-CODE attribute is 440 (Address Family 1503 not Supported), the client MUST NOT retry its request for the 1504 rejected address type. If the client receives an ADDRESS-ERROR-CODE 1505 attribute in the response and the error code value signaled in the 1506 ADDRESS-ERROR-CODE attribute is 508 (Insufficient Capacity), the 1507 client SHOULD wait at least 1 minute before trying to request any 1508 more allocations on this server for the rejected address type. 1510 The client will probably wish to send the relayed transport address 1511 to peers (using some method not specified here) so the peers can 1512 communicate with it. The client may also wish to use the server- 1513 reflexive address it receives in the XOR-MAPPED-ADDRESS attribute in 1514 its ICE processing. 1516 7.4. Receiving an Allocate Error Response 1518 If the client receives an Allocate error response, then the 1519 processing depends on the actual error code returned: 1521 o (Request timed out): There is either a problem with the server, or 1522 a problem reaching the server with the chosen transport. The 1523 client considers the current transaction as having failed but MAY 1524 choose to retry the Allocate request using a different transport 1525 (e.g., TCP instead of UDP). 1527 o 300 (Try Alternate): The server would like the client to use the 1528 server specified in the ALTERNATE-SERVER attribute instead. The 1529 client considers the current transaction as having failed, but 1530 SHOULD try the Allocate request with the alternate server before 1531 trying any other servers (e.g., other servers discovered using the 1532 DNS resolution procedures). When trying the Allocate request with 1533 the alternate server, the client follows the ALTERNATE-SERVER 1534 procedures specified in [I-D.ietf-tram-stunbis]. 1536 o 400 (Bad Request): The server believes the client's request is 1537 malformed for some reason. The client considers the current 1538 transaction as having failed. The client MAY notify the user or 1539 operator and SHOULD NOT retry the request with this server until 1540 it believes the problem has been fixed. 1542 o 401 (Unauthorized): If the client has followed the procedures of 1543 the long-term credential mechanism and still gets this error, then 1544 the server is not accepting the client's credentials. In this 1545 case, the client considers the current transaction as having 1546 failed and SHOULD notify the user or operator. The client SHOULD 1547 NOT send any further requests to this server until it believes the 1548 problem has been fixed. 1550 o 403 (Forbidden): The request is valid, but the server is refusing 1551 to perform it, likely due to administrative restrictions. The 1552 client considers the current transaction as having failed. The 1553 client MAY notify the user or operator and SHOULD NOT retry the 1554 same request with this server until it believes the problem has 1555 been fixed. 1557 o 420 (Unknown Attribute): If the client included a DONT-FRAGMENT 1558 attribute in the request and the server rejected the request with 1559 a 420 error code and listed the DONT-FRAGMENT attribute in the 1560 UNKNOWN-ATTRIBUTES attribute in the error response, then the 1561 client now knows that the server does not support the DONT- 1562 FRAGMENT attribute. The client considers the current transaction 1563 as having failed but MAY choose to retry the Allocate request 1564 without the DONT-FRAGMENT attribute. 1566 o 437 (Allocation Mismatch): This indicates that the client has 1567 picked a 5-tuple that the server sees as already in use. One way 1568 this could happen is if an intervening NAT assigned a mapped 1569 transport address that was used by another client that recently 1570 crashed. The client considers the current transaction as having 1571 failed. The client SHOULD pick another client transport address 1572 and retry the Allocate request (using a different transaction id). 1573 The client SHOULD try three different client transport addresses 1574 before giving up on this server. Once the client gives up on the 1575 server, it SHOULD NOT try to create another allocation on the 1576 server for 2 minutes. 1578 o 438 (Stale Nonce): See the procedures for the long-term credential 1579 mechanism [I-D.ietf-tram-stunbis]. 1581 o 440 (Address Family not Supported): The server does not support 1582 the address family requested by the client. If the client 1583 receives an Allocate error response with the 440 (Unsupported 1584 Address Family) error code, the client MUST NOT retry the request. 1586 o 441 (Wrong Credentials): The client should not receive this error 1587 in response to a Allocate request. The client MAY notify the user 1588 or operator and SHOULD NOT retry the same request with this server 1589 until it believes the problem has been fixed. 1591 o 442 (Unsupported Transport Address): The client should not receive 1592 this error in response to a request for a UDP allocation. The 1593 client MAY notify the user or operator and SHOULD NOT reattempt 1594 the request with this server until it believes the problem has 1595 been fixed. 1597 o 486 (Allocation Quota Reached): The server is currently unable to 1598 create any more allocations with this username. The client 1599 considers the current transaction as having failed. The client 1600 SHOULD wait at least 1 minute before trying to create any more 1601 allocations on the server. 1603 o 508 (Insufficient Capacity): The server has no more relayed 1604 transport addresses available, or has none with the requested 1605 properties, or the one that was reserved is no longer available. 1606 The client considers the current operation as having failed. If 1607 the client is using either the EVEN-PORT or the RESERVATION-TOKEN 1608 attribute, then the client MAY choose to remove or modify this 1609 attribute and try again immediately. Otherwise, the client SHOULD 1610 wait at least 1 minute before trying to create any more 1611 allocations on this server. 1613 An unknown error response MUST be handled as described in 1614 [I-D.ietf-tram-stunbis]. 1616 8. Refreshing an Allocation 1618 A Refresh transaction can be used to either (a) refresh an existing 1619 allocation and update its time-to-expiry or (b) delete an existing 1620 allocation. 1622 If a client wishes to continue using an allocation, then the client 1623 MUST refresh it before it expires. It is suggested that the client 1624 refresh the allocation roughly 1 minute before it expires. If a 1625 client no longer wishes to use an allocation, then it SHOULD 1626 explicitly delete the allocation. A client MAY refresh an allocation 1627 at any time for other reasons. 1629 8.1. Sending a Refresh Request 1631 If the client wishes to immediately delete an existing allocation, it 1632 includes a LIFETIME attribute with a value of 0. All other forms of 1633 the request refresh the allocation. 1635 When refreshing a dual allocation, the client includes REQUESTED- 1636 ADDRESS-FAMILY attribute indicating the address family type that 1637 should be refreshed. If no REQUESTED-ADDRESS-FAMILY is included then 1638 the request should be treated as applying to all current allocations. 1639 The client MUST only include family types it previously allocated and 1640 has not yet deleted. This process can also be used to delete an 1641 allocation of a specific address type, by setting the lifetime of 1642 that refresh request to 0. Deleting a single allocation destroys any 1643 permissions or channels associated with that particular allocation; 1644 it MUST NOT affect any permissions or channels associated with 1645 allocations for the other address family. 1647 The Refresh transaction updates the time-to-expiry timer of an 1648 allocation. If the client wishes the server to set the time-to- 1649 expiry timer to something other than the default lifetime, it 1650 includes a LIFETIME attribute with the requested value. The server 1651 then computes a new time-to-expiry value in the same way as it does 1652 for an Allocate transaction, with the exception that a requested 1653 lifetime of 0 causes the server to immediately delete the allocation. 1655 8.2. Receiving a Refresh Request 1657 When the server receives a Refresh request, it processes the request 1658 as per Section 5 plus the specific rules mentioned here. 1660 If the server receives a Refresh Request with a REQUESTED-ADDRESS- 1661 FAMILY attribute and the attribute value does not match the address 1662 family of the allocation, the server MUST reply with a 443 (Peer 1663 Address Family Mismatch) Refresh error response. 1665 The server computes a value called the "desired lifetime" as follows: 1666 if the request contains a LIFETIME attribute and the attribute value 1667 is 0, then the "desired lifetime" is 0. Otherwise, if the request 1668 contains a LIFETIME attribute, then the server computes the minimum 1669 of the client's requested lifetime and the server's maximum allowed 1670 lifetime. If this computed value is greater than the default 1671 lifetime, then the "desired lifetime" is the computed value. 1672 Otherwise, the "desired lifetime" is the default lifetime. 1674 Subsequent processing depends on the "desired lifetime" value: 1676 o If the "desired lifetime" is 0, then the request succeeds and the 1677 allocation is deleted. 1679 o If the "desired lifetime" is non-zero, then the request succeeds 1680 and the allocation's time-to-expiry is set to the "desired 1681 lifetime". 1683 If the request succeeds, then the server sends a success response 1684 containing: 1686 o A LIFETIME attribute containing the current value of the time-to- 1687 expiry timer. 1689 NOTE: A server need not do anything special to implement 1690 idempotency of Refresh requests over UDP using the "stateless 1691 stack approach". Retransmitted Refresh requests with a non-zero 1692 "desired lifetime" will simply refresh the allocation. A 1693 retransmitted Refresh request with a zero "desired lifetime" will 1694 cause a 437 (Allocation Mismatch) response if the allocation has 1695 already been deleted, but the client will treat this as equivalent 1696 to a success response (see below). 1698 8.3. Receiving a Refresh Response 1700 If the client receives a success response to its Refresh request with 1701 a non-zero lifetime, it updates its copy of the allocation data 1702 structure with the time-to-expiry value contained in the response. 1704 If the client receives a 437 (Allocation Mismatch) error response to 1705 a request to delete the allocation, then the allocation no longer 1706 exists and it should consider its request as having effectively 1707 succeeded. 1709 9. Permissions 1711 For each allocation, the server keeps a list of zero or more 1712 permissions. Each permission consists of an IP address and an 1713 associated time-to-expiry. While a permission exists, all peers 1714 using the IP address in the permission are allowed to send data to 1715 the client. The time-to-expiry is the number of seconds until the 1716 permission expires. Within the context of an allocation, a 1717 permission is uniquely identified by its associated IP address. 1719 By sending either CreatePermission requests or ChannelBind requests, 1720 the client can cause the server to install or refresh a permission 1721 for a given IP address. This causes one of two things to happen: 1723 o If no permission for that IP address exists, then a permission is 1724 created with the given IP address and a time-to-expiry equal to 1725 Permission Lifetime. 1727 o If a permission for that IP address already exists, then the time- 1728 to-expiry for that permission is reset to Permission Lifetime. 1730 The Permission Lifetime MUST be 300 seconds (= 5 minutes). 1732 Each permission's time-to-expiry decreases down once per second until 1733 it reaches 0; at which point, the permission expires and is deleted. 1735 CreatePermission and ChannelBind requests may be freely intermixed on 1736 a permission. A given permission may be initially installed and/or 1737 refreshed with a CreatePermission request, and then later refreshed 1738 with a ChannelBind request, or vice versa. 1740 When a UDP datagram arrives at the relayed transport address for the 1741 allocation, the server extracts the source IP address from the IP 1742 header. The server then compares this address with the IP address 1743 associated with each permission in the list of permissions for the 1744 allocation. Note that only addresses are compared and port numbers 1745 are not considered. If no match is found, relaying is not permitted, 1746 and the server silently discards the UDP datagram. If an exact match 1747 is found, the permission check is considered to have succeeded and 1748 the server continues to process the UDP datagram as specified 1749 elsewhere (Section 11.3). 1751 The permissions for one allocation are totally unrelated to the 1752 permissions for a different allocation. If an allocation expires, 1753 all its permissions expire with it. 1755 NOTE: Though TURN permissions expire after 5 minutes, many NATs 1756 deployed at the time of publication expire their UDP bindings 1757 considerably faster. Thus, an application using TURN will 1758 probably wish to send some sort of keep-alive traffic at a much 1759 faster rate. Applications using ICE should follow the keep-alive 1760 guidelines of ICE [RFC8445], and applications not using ICE are 1761 advised to do something similar. 1763 10. CreatePermission 1765 TURN supports two ways for the client to install or refresh 1766 permissions on the server. This section describes one way: the 1767 CreatePermission request. 1769 A CreatePermission request may be used in conjunction with either the 1770 Send mechanism in Section 11 or the Channel mechanism in Section 12. 1772 10.1. Forming a CreatePermission Request 1774 The client who wishes to install or refresh one or more permissions 1775 can send a CreatePermission request to the server. 1777 When forming a CreatePermission request, the client MUST include at 1778 least one XOR-PEER-ADDRESS attribute, and MAY include more than one 1779 such attribute. The IP address portion of each XOR-PEER-ADDRESS 1780 attribute contains the IP address for which a permission should be 1781 installed or refreshed. The port portion of each XOR-PEER-ADDRESS 1782 attribute will be ignored and can be any arbitrary value. The 1783 various XOR-PEER-ADDRESS attributes MAY appear in any order. The 1784 client MUST only include XOR-PEER-ADDRESS attributes with addresses 1785 of the same address family as that of the relayed transport address 1786 for the allocation. For dual allocations obtained using the 1787 ADDITIONAL-ADDRESS-FAMILY attribute, the client MAY include XOR-PEER- 1788 ADDRESS attributes with addresses of IPv4 and IPv6 address families. 1790 10.2. Receiving a CreatePermission Request 1792 When the server receives the CreatePermission request, it processes 1793 as per Section 5 plus the specific rules mentioned here. 1795 The message is checked for validity. The CreatePermission request 1796 MUST contain at least one XOR-PEER-ADDRESS attribute and MAY contain 1797 multiple such attributes. If no such attribute exists, or if any of 1798 these attributes are invalid, then a 400 (Bad Request) error is 1799 returned. If the request is valid, but the server is unable to 1800 satisfy the request due to some capacity limit or similar, then a 508 1801 (Insufficient Capacity) error is returned. 1803 If an XOR-PEER-ADDRESS attribute contains an address of an address 1804 family that is not the same as that of a relayed transport address 1805 for the allocation, the server MUST generate an error response with 1806 the 443 (Peer Address Family Mismatch) response code. 1808 The server MAY impose restrictions on the IP address allowed in the 1809 XOR-PEER-ADDRESS attribute -- if a value is not allowed, the server 1810 rejects the request with a 403 (Forbidden) error. 1812 If the message is valid and the server is capable of carrying out the 1813 request, then the server installs or refreshes a permission for the 1814 IP address contained in each XOR-PEER-ADDRESS attribute as described 1815 in Section 9. The port portion of each attribute is ignored and may 1816 be any arbitrary value. 1818 The server then responds with a CreatePermission success response. 1819 There are no mandatory attributes in the success response. 1821 NOTE: A server need not do anything special to implement 1822 idempotency of CreatePermission requests over UDP using the 1823 "stateless stack approach". Retransmitted CreatePermission 1824 requests will simply refresh the permissions. 1826 10.3. Receiving a CreatePermission Response 1828 If the client receives a valid CreatePermission success response, 1829 then the client updates its data structures to indicate that the 1830 permissions have been installed or refreshed. 1832 11. Send and Data Methods 1834 TURN supports two mechanisms for sending and receiving data from 1835 peers. This section describes the use of the Send and Data 1836 mechanisms, while Section 12 describes the use of the Channel 1837 mechanism. 1839 11.1. Forming a Send Indication 1841 The client can use a Send indication to pass data to the server for 1842 relaying to a peer. A client may use a Send indication even if a 1843 channel is bound to that peer. However, the client MUST ensure that 1844 there is a permission installed for the IP address of the peer to 1845 which the Send indication is being sent; this prevents a third party 1846 from using a TURN server to send data to arbitrary destinations. 1848 When forming a Send indication, the client MUST include an XOR-PEER- 1849 ADDRESS attribute and a DATA attribute. The XOR-PEER-ADDRESS 1850 attribute contains the transport address of the peer to which the 1851 data is to be sent, and the DATA attribute contains the actual 1852 application data to be sent to the peer. 1854 The client MAY include a DONT-FRAGMENT attribute in the Send 1855 indication if it wishes the server to set the DF bit on the UDP 1856 datagram sent to the peer. 1858 11.2. Receiving a Send Indication 1860 When the server receives a Send indication, it processes as per 1861 Section 5 plus the specific rules mentioned here. 1863 The message is first checked for validity. The Send indication MUST 1864 contain both an XOR-PEER-ADDRESS attribute and a DATA attribute. If 1865 one of these attributes is missing or invalid, then the message is 1866 discarded. Note that the DATA attribute is allowed to contain zero 1867 bytes of data. 1869 The Send indication may also contain the DONT-FRAGMENT attribute. If 1870 the server is unable to set the DF bit on outgoing UDP datagrams when 1871 this attribute is present, then the server acts as if the DONT- 1872 FRAGMENT attribute is an unknown comprehension-required attribute 1873 (and thus the Send indication is discarded). 1875 The server also checks that there is a permission installed for the 1876 IP address contained in the XOR-PEER-ADDRESS attribute. If no such 1877 permission exists, the message is discarded. Note that a Send 1878 indication never causes the server to refresh the permission. 1880 The server MAY impose restrictions on the IP address and port values 1881 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 1882 allowed, the server silently discards the Send indication. 1884 If everything is OK, then the server forms a UDP datagram as follows: 1886 o the source transport address is the relayed transport address of 1887 the allocation, where the allocation is determined by the 5-tuple 1888 on which the Send indication arrived; 1890 o the destination transport address is taken from the XOR-PEER- 1891 ADDRESS attribute; 1893 o the data following the UDP header is the contents of the value 1894 field of the DATA attribute. 1896 The handling of the DONT-FRAGMENT attribute (if present), is 1897 described in Section 14. 1899 The resulting UDP datagram is then sent to the peer. 1901 11.3. Receiving a UDP Datagram 1903 When the server receives a UDP datagram at a currently allocated 1904 relayed transport address, the server looks up the allocation 1905 associated with the relayed transport address. The server then 1906 checks to see whether the set of permissions for the allocation allow 1907 the relaying of the UDP datagram as described in Section 9. 1909 If relaying is permitted, then the server checks if there is a 1910 channel bound to the peer that sent the UDP datagram (see 1911 Section 12). If a channel is bound, then processing proceeds as 1912 described in Section 12.7. 1914 If relaying is permitted but no channel is bound to the peer, then 1915 the server forms and sends a Data indication. The Data indication 1916 MUST contain both an XOR-PEER-ADDRESS and a DATA attribute. The DATA 1917 attribute is set to the value of the 'data octets' field from the 1918 datagram, and the XOR-PEER-ADDRESS attribute is set to the source 1919 transport address of the received UDP datagram. The Data indication 1920 is then sent on the 5-tuple associated with the allocation. 1922 11.4. Receiving a Data Indication 1924 When the client receives a Data indication, it checks that the Data 1925 indication contains an XOR-PEER-ADDRESS attribute, and discards the 1926 indication if it does not. The client SHOULD also check that the 1927 XOR-PEER-ADDRESS attribute value contains an IP address with which 1928 the client believes there is an active permission, and discard the 1929 Data indication otherwise. 1931 NOTE: The latter check protects the client against an attacker who 1932 somehow manages to trick the server into installing permissions 1933 not desired by the client. 1935 If the XOR-PEER-ADDRESS is present and valid, the client checks that 1936 the Data indication contains either a DATA attribute or an ICMP 1937 attribute and discards the indication if it does not. Note that a 1938 DATA attribute is allowed to contain zero bytes of data. Processing 1939 of Data indications with an ICMP attribute is described in 1940 Section 11.6. 1942 If the Data indication passes the above checks, the client delivers 1943 the data octets inside the DATA attribute to the application, along 1944 with an indication that they were received from the peer whose 1945 transport address is given by the XOR-PEER-ADDRESS attribute. 1947 11.5. Receiving an ICMP Packet 1949 When the server receives an ICMP packet, the server verifies that the 1950 type is either 3, 11 or 12 for an ICMPv4 [RFC0792] packet or either 1951 1, 2, or 3 for an ICMPv6 [RFC4443] packet. It also verifies that the 1952 IP packet in the ICMP packet payload contains a UDP header. If 1953 either of these conditions fail, then the ICMP packet is silently 1954 dropped. 1956 The server looks up the allocation whose relayed transport address 1957 corresponds to the encapsulated packet's source IP address and UDP 1958 port. If no such allocation exists, the packet is silently dropped. 1959 The server then checks to see whether the set of permissions for the 1960 allocation allows the relaying of the ICMP packet. For ICMP packets, 1961 the source IP address MUST NOT be checked against the permissions 1962 list as it would be for UDP packets. Instead, the server extracts 1963 the destination IP address from the encapsulated IP header. The 1964 server then compares this address with the IP address associated with 1965 each permission in the list of permissions for the allocation. If no 1966 match is found, relaying is not permitted, and the server silently 1967 discards the ICMP packet. Note that only addresses are compared and 1968 port numbers are not considered. 1970 If relaying is permitted then the server forms and sends a Data 1971 indication. The Data indication MUST contain both an XOR-PEER- 1972 ADDRESS and an ICMP attribute. The ICMP attribute is set to the 1973 value of the type and code fields from the ICMP packet. The IP 1974 address portion of XOR-PEER-ADDRESS attribute is set to the 1975 destination IP address in the encapsulated IP header. At the time of 1976 writing of this specification, Socket APIs on some operating systems 1977 do not deliver the destination port in the encapsulated UDP header to 1978 applications without superuser privileges. If destination port in 1979 the encapsulated UDP header is available to the server then the port 1980 portion of XOR-PEER-ADDRESS attribute is set to the destination port 1981 otherwise the port portion is set to 0. The Data indication is then 1982 sent on the 5-tuple associated with the allocation. 1984 11.6. Receiving a Data Indication with an ICMP attribute 1986 When the client receives a Data indication with an ICMP attribute, it 1987 checks that the Data indication contains an XOR-PEER-ADDRESS 1988 attribute, and discards the indication if it does not. The client 1989 SHOULD also check that the XOR-PEER-ADDRESS attribute value contains 1990 an IP address with an active permission, and discard the Data 1991 indication otherwise. 1993 If the Data indication passes the above checks, the client signals 1994 the application of the error condition, along with an indication that 1995 it was received from the peer whose transport address is given by the 1996 XOR-PEER-ADDRESS attribute. The application can make sense of the 1997 meaning of the type and code values in the ICMP attribute by using 1998 the family field in the XOR-PEER-ADDRESS attribute. 2000 12. Channels 2002 Channels provide a way for the client and server to send application 2003 data using ChannelData messages, which have less overhead than Send 2004 and Data indications. 2006 The ChannelData message (see Section 12.4) starts with a two-byte 2007 field that carries the channel number. The values of this field are 2008 allocated as follows: 2010 0x0000 through 0x3FFF: These values can never be used for channel 2011 numbers. 2013 0x4000 through 0x4FFF: These values are the allowed channel 2014 numbers (4096 possible values). 2016 0x5000-0xFFFF: Reserved (For DTLS-SRTP multiplexing collision 2017 avoidance, see [RFC7983]. 2019 According to [RFC7983], ChannelData messages can be distinguished 2020 from other multiplexed protocols by examining the first byte of the 2021 message: 2023 +------------+------------------------------+ 2024 | [0..3] | STUN | 2025 | | | 2026 +-------------------------------------------+ 2027 | [16..19] | ZRTP | 2028 | | | 2029 +-------------------------------------------+ 2030 | [20..63] | DTLS | 2031 | | | 2032 +-------------------------------------------+ 2033 | [64..79] | TURN Channel | 2034 | | | 2035 +-------------------------------------------+ 2036 | [128..191] | RTP/RTCP | 2037 | | | 2038 +-------------------------------------------+ 2039 | Others | Reserved, MUST be dropped | 2040 | | and an alert MAY be logged | 2041 +-------------------------------------------+ 2043 Reserved values may be used in the future by other protocols. When 2044 the client uses channel binding, it MUST comply with the 2045 demultiplexing scheme discussed above. 2047 Channel bindings are always initiated by the client. The client can 2048 bind a channel to a peer at any time during the lifetime of the 2049 allocation. The client may bind a channel to a peer before 2050 exchanging data with it, or after exchanging data with it (using Send 2051 and Data indications) for some time, or may choose never to bind a 2052 channel to it. The client can also bind channels to some peers while 2053 not binding channels to other peers. 2055 Channel bindings are specific to an allocation, so that the use of a 2056 channel number or peer transport address in a channel binding in one 2057 allocation has no impact on their use in a different allocation. If 2058 an allocation expires, all its channel bindings expire with it. 2060 A channel binding consists of: 2062 o a channel number; 2064 o a transport address (of the peer); and 2066 o A time-to-expiry timer. 2068 Within the context of an allocation, a channel binding is uniquely 2069 identified either by the channel number or by the peer's transport 2070 address. Thus, the same channel cannot be bound to two different 2071 transport addresses, nor can the same transport address be bound to 2072 two different channels. 2074 A channel binding lasts for 10 minutes unless refreshed. Refreshing 2075 the binding (by the server receiving a ChannelBind request rebinding 2076 the channel to the same peer) resets the time-to-expiry timer back to 2077 10 minutes. 2079 When the channel binding expires, the channel becomes unbound. Once 2080 unbound, the channel number can be bound to a different transport 2081 address, and the transport address can be bound to a different 2082 channel number. To prevent race conditions, the client MUST wait 5 2083 minutes after the channel binding expires before attempting to bind 2084 the channel number to a different transport address or the transport 2085 address to a different channel number. 2087 When binding a channel to a peer, the client SHOULD be prepared to 2088 receive ChannelData messages on the channel from the server as soon 2089 as it has sent the ChannelBind request. Over UDP, it is possible for 2090 the client to receive ChannelData messages from the server before it 2091 receives a ChannelBind success response. 2093 In the other direction, the client MAY elect to send ChannelData 2094 messages before receiving the ChannelBind success response. Doing 2095 so, however, runs the risk of having the ChannelData messages dropped 2096 by the server if the ChannelBind request does not succeed for some 2097 reason (e.g., packet lost if the request is sent over UDP, or the 2098 server being unable to fulfill the request). A client that wishes to 2099 be safe should either queue the data or use Send indications until 2100 the channel binding is confirmed. 2102 12.1. Sending a ChannelBind Request 2104 A channel binding is created or refreshed using a ChannelBind 2105 transaction. A ChannelBind transaction also creates or refreshes a 2106 permission towards the peer (see Section 9). 2108 To initiate the ChannelBind transaction, the client forms a 2109 ChannelBind request. The channel to be bound is specified in a 2110 CHANNEL-NUMBER attribute, and the peer's transport address is 2111 specified in an XOR-PEER-ADDRESS attribute. Section 12.2 describes 2112 the restrictions on these attributes. The client MUST only include 2113 an XOR-PEER-ADDRESS attribute with an address of the same address 2114 family as that of a relayed transport address for the allocation. 2116 Rebinding a channel to the same transport address that it is already 2117 bound to provides a way to refresh a channel binding and the 2118 corresponding permission without sending data to the peer. Note 2119 however, that permissions need to be refreshed more frequently than 2120 channels. 2122 12.2. Receiving a ChannelBind Request 2124 When the server receives a ChannelBind request, it processes as per 2125 Section 5 plus the specific rules mentioned here. 2127 The server checks the following: 2129 o The request contains both a CHANNEL-NUMBER and an XOR-PEER-ADDRESS 2130 attribute; 2132 o The channel number is in the range 0x4000 through 0x4FFF 2133 (inclusive); 2135 o The channel number is not currently bound to a different transport 2136 address (same transport address is OK); 2138 o The transport address is not currently bound to a different 2139 channel number. 2141 o If the XOR-PEER-ADDRESS attribute contains an address of an 2142 address family that is not the same as that of a relayed transport 2143 address for the allocation, the server MUST generate an error 2144 response with the 443 (Peer Address Family Mismatch) response 2145 code. 2147 If any of these tests fail, the server replies with a 400 (Bad 2148 Request) error. 2150 The server MAY impose restrictions on the IP address and port values 2151 allowed in the XOR-PEER-ADDRESS attribute -- if a value is not 2152 allowed, the server rejects the request with a 403 (Forbidden) error. 2154 If the request is valid, but the server is unable to fulfill the 2155 request due to some capacity limit or similar, the server replies 2156 with a 508 (Insufficient Capacity) error. 2158 Otherwise, the server replies with a ChannelBind success response. 2159 There are no required attributes in a successful ChannelBind 2160 response. 2162 If the server can satisfy the request, then the server creates or 2163 refreshes the channel binding using the channel number in the 2164 CHANNEL-NUMBER attribute and the transport address in the XOR-PEER- 2165 ADDRESS attribute. The server also installs or refreshes a 2166 permission for the IP address in the XOR-PEER-ADDRESS attribute as 2167 described in Section 9. 2169 NOTE: A server need not do anything special to implement 2170 idempotency of ChannelBind requests over UDP using the "stateless 2171 stack approach". Retransmitted ChannelBind requests will simply 2172 refresh the channel binding and the corresponding permission. 2173 Furthermore, the client must wait 5 minutes before binding a 2174 previously bound channel number or peer address to a different 2175 channel, eliminating the possibility that the transaction would 2176 initially fail but succeed on a retransmission. 2178 12.3. Receiving a ChannelBind Response 2180 When the client receives a ChannelBind success response, it updates 2181 its data structures to record that the channel binding is now active. 2182 It also updates its data structures to record that the corresponding 2183 permission has been installed or refreshed. 2185 If the client receives a ChannelBind failure response that indicates 2186 that the channel information is out-of-sync between the client and 2187 the server (e.g., an unexpected 400 "Bad Request" response), then it 2188 is RECOMMENDED that the client immediately delete the allocation and 2189 start afresh with a new allocation. 2191 12.4. The ChannelData Message 2193 The ChannelData message is used to carry application data between the 2194 client and the server. It has the following format: 2196 0 1 2 3 2197 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 2198 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2199 | Channel Number | Length | 2200 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2201 | | 2202 / Application Data / 2203 / / 2204 | | 2205 | +-------------------------------+ 2206 | | 2207 +-------------------------------+ 2209 The Channel Number field specifies the number of the channel on which 2210 the data is traveling, and thus the address of the peer that is 2211 sending or is to receive the data. 2213 The Length field specifies the length in bytes of the application 2214 data field (i.e., it does not include the size of the ChannelData 2215 header). Note that 0 is a valid length. 2217 The Application Data field carries the data the client is trying to 2218 send to the peer, or that the peer is sending to the client. 2220 12.5. Sending a ChannelData Message 2222 Once a client has bound a channel to a peer, then when the client has 2223 data to send to that peer it may use either a ChannelData message or 2224 a Send indication; that is, the client is not obligated to use the 2225 channel when it exists and may freely intermix the two message types 2226 when sending data to the peer. The server, on the other hand, MUST 2227 use the ChannelData message if a channel has been bound to the peer. 2228 The server uses a Data indication to signal the XOR-PEER-ADDRESS and 2229 ICMP attributes to the client even if a channel has been bound to the 2230 peer. 2232 The fields of the ChannelData message are filled in as described in 2233 Section 12.4. 2235 Over TCP and TLS-over-TCP, the ChannelData message MUST be padded to 2236 a multiple of four bytes in order to ensure the alignment of 2237 subsequent messages. The padding is not reflected in the length 2238 field of the ChannelData message, so the actual size of a ChannelData 2239 message (including padding) is (4 + Length) rounded up to the nearest 2240 multiple of 4. Over UDP, the padding is not required but MAY be 2241 included. 2243 The ChannelData message is then sent on the 5-tuple associated with 2244 the allocation. 2246 12.6. Receiving a ChannelData Message 2248 The receiver of the ChannelData message uses the first byte to 2249 distinguish it from other multiplexed protocols, as described above. 2250 If the message uses a value in the reserved range (0x5000 through 2251 0xFFFF), then the message is silently discarded. 2253 If the ChannelData message is received in a UDP datagram, and if the 2254 UDP datagram is too short to contain the claimed length of the 2255 ChannelData message (i.e., the UDP header length field value is less 2256 than the ChannelData header length field value + 4 + 8), then the 2257 message is silently discarded. 2259 If the ChannelData message is received over TCP or over TLS-over-TCP, 2260 then the actual length of the ChannelData message is as described in 2261 Section 12.5. 2263 If the ChannelData message is received on a channel that is not bound 2264 to any peer, then the message is silently discarded. 2266 On the client, it is RECOMMENDED that the client discard the 2267 ChannelData message if the client believes there is no active 2268 permission towards the peer. On the server, the receipt of a 2269 ChannelData message MUST NOT refresh either the channel binding or 2270 the permission towards the peer. 2272 On the server, if no errors are detected, the server relays the 2273 application data to the peer by forming a UDP datagram as follows: 2275 o the source transport address is the relayed transport address of 2276 the allocation, where the allocation is determined by the 5-tuple 2277 on which the ChannelData message arrived; 2279 o the destination transport address is the transport address to 2280 which the channel is bound; 2282 o the data following the UDP header is the contents of the data 2283 field of the ChannelData message. 2285 The resulting UDP datagram is then sent to the peer. Note that if 2286 the Length field in the ChannelData message is 0, then there will be 2287 no data in the UDP datagram, but the UDP datagram is still formed and 2288 sent. 2290 12.7. Relaying Data from the Peer 2292 When the server receives a UDP datagram on the relayed transport 2293 address associated with an allocation, the server processes it as 2294 described in Section 11.3. If that section indicates that a 2295 ChannelData message should be sent (because there is a channel bound 2296 to the peer that sent to the UDP datagram), then the server forms and 2297 sends a ChannelData message as described in Section 12.5. 2299 When the server receives an ICMP packet, the server processes it as 2300 described in Section 11.5. A Data indication MUST be sent regardless 2301 of whether there is a channel bound to the peer that was the 2302 destination of the UDP datagram that triggered the reception of the 2303 ICMP packet. 2305 13. Packet Translations 2307 This section addresses IPv4-to-IPv6, IPv6-to-IPv4, and IPv6-to-IPv6 2308 translations. Requirements for translation of the IP addresses and 2309 port numbers of the packets are described above. The following 2310 sections specify how to translate other header fields. 2312 As discussed in Section 2.6, translations in TURN are designed so 2313 that a TURN server can be implemented as an application that runs in 2314 userland under commonly available operating systems and that does not 2315 require special privileges. The translations specified in the 2316 following sections follow this principle. 2318 The descriptions below have two parts: a preferred behavior and an 2319 alternate behavior. The server SHOULD implement the preferred 2320 behavior. Otherwise, the server MUST implement the alternate 2321 behavior and MUST NOT do anything else for the reasons detailed in 2322 [RFC7915]. 2324 13.1. IPv4-to-IPv6 Translations 2326 Traffic Class 2328 Preferred behavior: As specified in Section 4 of [RFC7915]. 2330 Alternate behavior: The relay sets the Traffic Class to the 2331 default value for outgoing packets. 2333 Flow Label 2335 Preferred behavior: The relay sets the Flow label to 0. The relay 2336 can choose to set the Flow label to a different value if it 2337 supports the IPv6 Flow Label field [RFC6437]. 2339 Alternate behavior: The relay sets the Flow label to the default 2340 value for outgoing packets. 2342 Hop Limit 2344 Preferred behavior: As specified in Section 4 of [RFC7915]. 2346 Alternate behavior: The relay sets the Hop Limit to the default 2347 value for outgoing packets. 2349 Fragmentation 2351 Preferred behavior: As specified in Section 4 of [RFC7915]. 2353 Alternate behavior: The relay assembles incoming fragments. The 2354 relay follows its default behavior to send outgoing packets. 2356 For both preferred and alternate behavior, the DONT-FRAGMENT 2357 attribute MUST be ignored by the server. 2359 Extension Headers 2361 Preferred behavior: The relay sends outgoing packet without any 2362 IPv6 extension headers, with the exception of the Fragmentation 2363 header as described above. 2365 Alternate behavior: Same as preferred. 2367 13.2. IPv6-to-IPv6 Translations 2369 Flow Label 2371 The relay should consider that it is handling two different IPv6 2372 flows. Therefore, the Flow label [RFC6437] SHOULD NOT be copied as 2373 part of the translation. 2375 Preferred behavior: The relay sets the Flow label to 0. The relay 2376 can choose to set the Flow label to a different value if it 2377 supports the IPv6 Flow Label field [RFC6437]. 2379 Alternate behavior: The relay sets the Flow label to the default 2380 value for outgoing packets. 2382 Hop Limit 2384 Preferred behavior: The relay acts as a regular router with 2385 respect to decrementing the Hop Limit and generating an ICMPv6 2386 error if it reaches zero. 2388 Alternate behavior: The relay sets the Hop Limit to the default 2389 value for outgoing packets. 2391 Fragmentation 2393 Preferred behavior: If the incoming packet did not include a 2394 Fragment header and the outgoing packet size does not exceed the 2395 outgoing link's MTU, the relay sends the outgoing packet without a 2396 Fragment header. 2398 If the incoming packet did not include a Fragment header and the 2399 outgoing packet size exceeds the outgoing link's MTU, the relay 2400 drops the outgoing packet and send an ICMP message of type 2 code 2401 0 ("Packet too big") to the sender of the incoming packet. If 2402 the packet is being sent to the peer, the relay reduces the MTU 2403 reported in the ICMP message by 48 bytes to allow room for the 2404 overhead of a Data indication. 2406 If the incoming packet included a Fragment header and the outgoing 2407 packet size (with a Fragment header included) does not exceed the 2408 outgoing link's MTU, the relay sends the outgoing packet with a 2409 Fragment header. The relay sets the fields of the Fragment header 2410 as appropriate for a packet originating from the server. 2412 If the incoming packet included a Fragment header and the outgoing 2413 packet size exceeds the outgoing link's MTU, the relay MUST 2414 fragment the outgoing packet into fragments of no more than 1280 2415 bytes. The relay sets the fields of the Fragment header as 2416 appropriate for a packet originating from the server. 2418 Alternate behavior: The relay assembles incoming fragments. The 2419 relay follows its default behavior to send outgoing packets. 2421 For both preferred and alternate behavior, the DONT-FRAGMENT 2422 attribute MUST be ignored by the server. 2424 Extension Headers 2426 Preferred behavior: The relay sends outgoing packet without any 2427 IPv6 extension headers, with the exception of the Fragmentation 2428 header as described above. 2430 Alternate behavior: Same as preferred. 2432 13.3. IPv6-to-IPv4 Translations 2434 Type of Service and Precedence 2436 Preferred behavior: As specified in Section 5 of [RFC7915]. 2438 Alternate behavior: The relay sets the Type of Service and 2439 Precedence to the default value for outgoing packets. 2441 Time to Live 2443 Preferred behavior: As specified in Section 5 of [RFC7915]. 2445 Alternate behavior: The relay sets the Time to Live to the default 2446 value for outgoing packets. 2448 Fragmentation 2449 Preferred behavior: As specified in Section 5 of [RFC7915]. 2450 Additionally, when the outgoing packet's size exceeds the outgoing 2451 link's MTU, the relay needs to generate an ICMP error (ICMPv6 2452 Packet Too Big) reporting the MTU size. If the packet is being 2453 sent to the peer, the relay SHOULD reduce the MTU reported in the 2454 ICMP message by 48 bytes to allow room for the overhead of a Data 2455 indication. 2457 Alternate behavior: The relay assembles incoming fragments. The 2458 relay follows its default behavior to send outgoing packets. 2460 For both preferred and alternate behavior, the DONT-FRAGMENT 2461 attribute MUST be ignored by the server. 2463 14. IP Header Fields 2465 This section describes how the server sets various fields in the IP 2466 header when relaying between the client and the peer or vice versa. 2467 The descriptions in this section apply: (a) when the server sends a 2468 UDP datagram to the peer, or (b) when the server sends a Data 2469 indication or ChannelData message to the client over UDP transport. 2470 The descriptions in this section do not apply to TURN messages sent 2471 over TCP or TLS transport from the server to the client. 2473 The descriptions below have two parts: a preferred behavior and an 2474 alternate behavior. The server SHOULD implement the preferred 2475 behavior, but if that is not possible for a particular field, then it 2476 SHOULD implement the alternative behavior. 2478 Time to Live (TTL) field 2480 Preferred Behavior: If the incoming value is 0, then the drop the 2481 incoming packet. Otherwise, set the outgoing Time to Live/Hop 2482 Count to one less than the incoming value. 2484 Alternate Behavior: Set the outgoing value to the default for 2485 outgoing packets. 2487 Differentiated Services Code Point (DSCP) field [RFC2474] 2489 Preferred Behavior: Set the outgoing value to the incoming value, 2490 unless the server includes a differentiated services classifier 2491 and marker [RFC2474]. 2493 Alternate Behavior: Set the outgoing value to a fixed value, which 2494 by default is Best Effort unless configured otherwise. 2496 In both cases, if the server is immediately adjacent to a 2497 differentiated services classifier and marker, then DSCP MAY be 2498 set to any arbitrary value in the direction towards the 2499 classifier. 2501 Explicit Congestion Notification (ECN) field [RFC3168] 2503 Preferred Behavior: Set the outgoing value to the incoming value, 2504 UNLESS the server is doing Active Queue Management, the incoming 2505 ECN field is ECT(1) (=0b01) or ECT(0) (=0b10), and the server 2506 wishes to indicate that congestion has been experienced, in which 2507 case set the outgoing value to CE (=0b11). 2509 Alternate Behavior: Set the outgoing value to Not-ECT (=0b00). 2511 IPv4 Fragmentation fields 2513 Preferred Behavior: When the server sends a packet to a peer in 2514 response to a Send indication containing the DONT-FRAGMENT 2515 attribute, then set the DF bit in the outgoing IP header to 1. In 2516 all other cases when sending an outgoing packet containing 2517 application data (e.g., Data indication, ChannelData message, or 2518 DONT-FRAGMENT attribute not included in the Send indication), copy 2519 the DF bit from the DF bit of the incoming packet that contained 2520 the application data. 2522 Set the other fragmentation fields (Identification, More 2523 Fragments, Fragment Offset) as appropriate for a packet 2524 originating from the server. 2526 Alternate Behavior: As described in the Preferred Behavior, except 2527 always assume the incoming DF bit is 0. 2529 In both the Preferred and Alternate Behaviors, the resulting 2530 packet may be too large for the outgoing link. If this is the 2531 case, then the normal fragmentation rules apply [RFC1122]. 2533 IPv4 Options 2535 Preferred Behavior: The outgoing packet is sent without any IPv4 2536 options. 2538 Alternate Behavior: Same as preferred. 2540 15. STUN Methods 2542 This section lists the codepoints for the STUN methods defined in 2543 this specification. See elsewhere in this document for the semantics 2544 of these methods. 2546 0x003 : Allocate (only request/response semantics defined) 2547 0x004 : Refresh (only request/response semantics defined) 2548 0x006 : Send (only indication semantics defined) 2549 0x007 : Data (only indication semantics defined) 2550 0x008 : CreatePermission (only request/response semantics defined 2551 0x009 : ChannelBind (only request/response semantics defined) 2553 16. STUN Attributes 2555 This STUN extension defines the following attributes: 2557 0x000C: CHANNEL-NUMBER 2558 0x000D: LIFETIME 2559 0x0010: Reserved (was BANDWIDTH) 2560 0x0012: XOR-PEER-ADDRESS 2561 0x0013: DATA 2562 0x0016: XOR-RELAYED-ADDRESS 2563 0x0017: REQUESTED-ADDRESS-FAMILY 2564 0x0018: EVEN-PORT 2565 0x0019: REQUESTED-TRANSPORT 2566 0x001A: DONT-FRAGMENT 2567 0x0021: Reserved (was TIMER-VAL) 2568 0x0022: RESERVATION-TOKEN 2569 TBD-CA: ADDITIONAL-ADDRESS-FAMILY 2570 TBD-CA: ADDRESS-ERROR-CODE 2571 TBD-CA: ICMP 2573 Some of these attributes have lengths that are not multiples of 4. 2574 By the rules of STUN, any attribute whose length is not a multiple of 2575 4 bytes MUST be immediately followed by 1 to 3 padding bytes to 2576 ensure the next attribute (if any) would start on a 4-byte boundary 2577 (see [I-D.ietf-tram-stunbis]). 2579 16.1. CHANNEL-NUMBER 2581 The CHANNEL-NUMBER attribute contains the number of the channel. The 2582 value portion of this attribute is 4 bytes long and consists of a 2583 16-bit unsigned integer, followed by a two-octet RFFU (Reserved For 2584 Future Use) field, which MUST be set to 0 on transmission and MUST be 2585 ignored on reception. 2587 0 1 2 3 2588 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 2589 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2590 | Channel Number | RFFU = 0 | 2591 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2593 16.2. LIFETIME 2595 The LIFETIME attribute represents the duration for which the server 2596 will maintain an allocation in the absence of a refresh. The value 2597 portion of this attribute is 4-bytes long and consists of a 32-bit 2598 unsigned integral value representing the number of seconds remaining 2599 until expiration. 2601 16.3. XOR-PEER-ADDRESS 2603 The XOR-PEER-ADDRESS specifies the address and port of the peer as 2604 seen from the TURN server. (For example, the peer's server-reflexive 2605 transport address if the peer is behind a NAT.) It is encoded in the 2606 same way as XOR-MAPPED-ADDRESS [I-D.ietf-tram-stunbis]. 2608 16.4. DATA 2610 The DATA attribute is present in all Send and Data indications. The 2611 value portion of this attribute is variable length and consists of 2612 the application data (that is, the data that would immediately follow 2613 the UDP header if the data was been sent directly between the client 2614 and the peer). If the length of this attribute is not a multiple of 2615 4, then padding must be added after this attribute. 2617 16.5. XOR-RELAYED-ADDRESS 2619 The XOR-RELAYED-ADDRESS is present in Allocate responses. It 2620 specifies the address and port that the server allocated to the 2621 client. It is encoded in the same way as XOR-MAPPED-ADDRESS 2622 [I-D.ietf-tram-stunbis]. 2624 16.6. REQUESTED-ADDRESS-FAMILY 2626 This attribute is used in Allocate and Refresh requests to specify 2627 the address type requested by the client. The value of this 2628 attribute is 4 bytes with the following format: 2630 0 1 2 3 2631 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 2632 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2633 | Family | Reserved | 2634 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2636 Family: there are two values defined for this field and specified in 2637 [I-D.ietf-tram-stunbis], Section 14.1: 0x01 for IPv4 addresses and 2638 0x02 for IPv6 addresses. 2640 Reserved: at this point, the 24 bits in the Reserved field MUST be 2641 set to zero by the client and MUST be ignored by the server. 2643 16.7. EVEN-PORT 2645 This attribute allows the client to request that the port in the 2646 relayed transport address be even, and (optionally) that the server 2647 reserve the next-higher port number. The value portion of this 2648 attribute is 1 byte long. Its format is: 2650 0 2651 0 1 2 3 4 5 6 7 2652 +-+-+-+-+-+-+-+-+ 2653 |R| RFFU | 2654 +-+-+-+-+-+-+-+-+ 2656 The value contains a single 1-bit flag: 2658 R: If 1, the server is requested to reserve the next-higher port 2659 number (on the same IP address) for a subsequent allocation. If 2660 0, no such reservation is requested. 2662 The other 7 bits of the attribute's value must be set to zero on 2663 transmission and ignored on reception. 2665 Since the length of this attribute is not a multiple of 4, padding 2666 must immediately follow this attribute. 2668 16.8. REQUESTED-TRANSPORT 2670 This attribute is used by the client to request a specific transport 2671 protocol for the allocated transport address. The value of this 2672 attribute is 4 bytes with the following format: 2674 0 1 2 3 2675 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 2676 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2677 | Protocol | RFFU | 2678 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2680 The Protocol field specifies the desired protocol. The codepoints 2681 used in this field are taken from those allowed in the Protocol field 2682 in the IPv4 header and the NextHeader field in the IPv6 header 2684 [Protocol-Numbers]. This specification only allows the use of 2685 codepoint 17 (User Datagram Protocol). 2687 The RFFU field MUST be set to zero on transmission and MUST be 2688 ignored on reception. It is reserved for future uses. 2690 16.9. DONT-FRAGMENT 2692 This attribute is used by the client to request that the server set 2693 the DF (Don't Fragment) bit in the IP header when relaying the 2694 application data onward to the peer. This attribute has no value 2695 part and thus the attribute length field is 0. 2697 16.10. RESERVATION-TOKEN 2699 The RESERVATION-TOKEN attribute contains a token that uniquely 2700 identifies a relayed transport address being held in reserve by the 2701 server. The server includes this attribute in a success response to 2702 tell the client about the token, and the client includes this 2703 attribute in a subsequent Allocate request to request the server use 2704 that relayed transport address for the allocation. 2706 The attribute value is 8 bytes and contains the token value. 2708 16.11. ADDITIONAL-ADDRESS-FAMILY 2710 This attribute is used by clients to request the allocation of a IPv4 2711 and IPv6 address type from a server. It is encoded in the same way 2712 as REQUESTED-ADDRESS-FAMILY Section 16.6. The ADDITIONAL-ADDRESS- 2713 FAMILY attribute MAY be present in Allocate request. The attribute 2714 value of 0x02 (IPv6 address) is the only valid value in Allocate 2715 request. 2717 16.12. ADDRESS-ERROR-CODE Attribute 2719 This attribute is used by servers to signal the reason for not 2720 allocating the requested address family. The value portion of this 2721 attribute is variable length with the following format: 2723 0 1 2 3 2724 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 2725 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2726 | Family | Rsvd |Class| Number | 2727 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2728 | Reason Phrase (variable) .. 2729 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2731 Family: there are two values defined for this field and specified in 2732 [I-D.ietf-tram-stunbis], Section 14.1: 0x01 for IPv4 addresses and 2733 0x02 for IPv6 addresses. 2735 Reserved: at this point, the 13 bits in the Reserved field MUST be 2736 set to zero by the client and MUST be ignored by the server. 2738 Class: The Class represents the hundreds digit of the error code and 2739 is defined in section 14.8 of [I-D.ietf-tram-stunbis]. 2741 Number: this 8-bit field contains the reason server cannot allocate 2742 one of the requested address types. The error code values could 2743 be either 440 (unsupported address family) or 508 (insufficient 2744 capacity). The number representation is defined in section 14.8 2745 of [I-D.ietf-tram-stunbis]. 2747 Reason Phrase: The recommended reason phrases for error codes 440 2748 and 508 are explained in Section 17. 2750 16.13. ICMP Attribute 2752 This attribute is used by servers to signal the reason an UDP packet 2753 was dropped. The following is the format of the ICMP attribute. 2755 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 2756 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2757 | Reserved | ICMP Type | ICMP Code | 2758 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2760 Reserved: This field MUST be set to 0 when sent, and MUST be ignored 2761 when received. 2763 ICMP Type: The field contains the value in the ICMP type. Its 2764 interpretation depends whether the ICMP was received over IPv4 or 2765 IPv6. 2767 ICMP Code: The field contains the value in the ICMP code. Its 2768 interpretation depends whether the ICMP was received over IPv4 or 2769 IPv6. 2771 17. STUN Error Response Codes 2773 This document defines the following error response codes: 2775 403 (Forbidden): The request was valid but cannot be performed due 2776 to administrative or similar restrictions. 2778 437 (Allocation Mismatch): A request was received by the server that 2779 requires an allocation to be in place, but no allocation exists, 2780 or a request was received that requires no allocation, but an 2781 allocation exists. 2783 440 (Address Family not Supported): The server does not support the 2784 address family requested by the client. 2786 441 (Wrong Credentials): The credentials in the (non-Allocate) 2787 request do not match those used to create the allocation. 2789 442 (Unsupported Transport Protocol): The Allocate request asked the 2790 server to use a transport protocol between the server and the peer 2791 that the server does not support. NOTE: This does NOT refer to 2792 the transport protocol used in the 5-tuple. 2794 443 (Peer Address Family Mismatch). A peer address is part of a 2795 different address family than that of the relayed transport 2796 address of the allocation. 2798 486 (Allocation Quota Reached): No more allocations using this 2799 username can be created at the present time. 2801 508 (Insufficient Capacity): The server is unable to carry out the 2802 request due to some capacity limit being reached. In an Allocate 2803 response, this could be due to the server having no more relayed 2804 transport addresses available at that time, having none with the 2805 requested properties, or the one that corresponds to the specified 2806 reservation token is not available. 2808 18. Detailed Example 2810 This section gives an example of the use of TURN, showing in detail 2811 the contents of the messages exchanged. The example uses the network 2812 diagram shown in the Overview (Figure 1). 2814 For each message, the attributes included in the message and their 2815 values are shown. For convenience, values are shown in a human- 2816 readable format rather than showing the actual octets; for example, 2817 "XOR-RELAYED-ADDRESS=192.0.2.15:9000" shows that the XOR-RELAYED- 2818 ADDRESS attribute is included with an address of 192.0.2.15 and a 2819 port of 9000, here the address and port are shown before the xor-ing 2820 is done. For attributes with string-like values (e.g., 2821 SOFTWARE="Example client, version 1.03" and 2822 NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda"), the value of the attribute 2823 is shown in quotes for readability, but these quotes do not appear in 2824 the actual value. 2826 TURN TURN Peer Peer 2827 client server A B 2828 | | | | 2829 |--- Allocate request -------------->| | | 2830 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2831 | SOFTWARE="Example client, version 1.03" | | 2832 | LIFETIME=3600 (1 hour) | | | 2833 | REQUESTED-TRANSPORT=17 (UDP) | | | 2834 | DONT-FRAGMENT | | | 2835 | | | | 2836 |<-- Allocate error response --------| | | 2837 | Transaction-Id=0xA56250D3F17ABE679422DE85 | | 2838 | SOFTWARE="Example server, version 1.17" | | 2839 | ERROR-CODE=401 (Unauthorized) | | | 2840 | REALM="example.com" | | | 2841 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2842 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 2843 | | | | 2844 |--- Allocate request -------------->| | | 2845 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2846 | SOFTWARE="Example client 1.03" | | | 2847 | LIFETIME=3600 (1 hour) | | | 2848 | REQUESTED-TRANSPORT=17 (UDP) | | | 2849 | DONT-FRAGMENT | | | 2850 | USERNAME="George" | | | 2851 | REALM="example.com" | | | 2852 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2853 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 2854 | PASSWORD-ALGORITHM=SHA256 | | | 2855 | MESSAGE-INTEGRITY=... | | | 2856 | MESSAGE-INTEGRITY-SHA256=... | | | 2857 | | | | 2858 |<-- Allocate success response ------| | | 2859 | Transaction-Id=0xC271E932AD7446A32C234492 | | 2860 | SOFTWARE="Example server, version 1.17" | | 2861 | LIFETIME=1200 (20 minutes) | | | 2862 | XOR-RELAYED-ADDRESS=192.0.2.15:50000 | | 2863 | XOR-MAPPED-ADDRESS=192.0.2.1:7000 | | 2864 | MESSAGE-INTEGRITY=... | | | 2866 The client begins by selecting a host transport address to use for 2867 the TURN session; in this example, the client has selected 2868 198.51.100.2:49721 as shown in Figure 1. The client then sends an 2869 Allocate request to the server at the server transport address. The 2870 client randomly selects a 96-bit transaction id of 2871 0xA56250D3F17ABE679422DE85 for this transaction; this is encoded in 2872 the transaction id field in the fixed header. The client includes a 2873 SOFTWARE attribute that gives information about the client's 2874 software; here the value is "Example client, version 1.03" to 2875 indicate that this is version 1.03 of something called the Example 2876 client. The client includes the LIFETIME attribute because it wishes 2877 the allocation to have a longer lifetime than the default of 10 2878 minutes; the value of this attribute is 3600 seconds, which 2879 corresponds to 1 hour. The client must always include a REQUESTED- 2880 TRANSPORT attribute in an Allocate request and the only value allowed 2881 by this specification is 17, which indicates UDP transport between 2882 the server and the peers. The client also includes the DONT-FRAGMENT 2883 attribute because it wishes to use the DONT-FRAGMENT attribute later 2884 in Send indications; this attribute consists of only an attribute 2885 header, there is no value part. We assume the client has not 2886 recently interacted with the server, thus the client does not include 2887 USERNAME, USERHASH, REALM, NONCE, PASSWORD-ALGORITHMS, PASSWORD- 2888 ALGORITHM, MESSAGE-INTEGRITY or MESSAGE-INTEGRITY-SHA256 attribute. 2889 Finally, note that the order of attributes in a message is arbitrary 2890 (except for the MESSAGE-INTEGRITY, MESSAGE-INTEGRITY-SHA256 and 2891 FINGERPRINT attributes) and the client could have used a different 2892 order. 2894 Servers require any request to be authenticated. Thus, when the 2895 server receives the initial Allocate request, it rejects the request 2896 because the request does not contain the authentication attributes. 2897 Following the procedures of the long-term credential mechanism of 2898 STUN [I-D.ietf-tram-stunbis], the server includes an ERROR-CODE 2899 attribute with a value of 401 (Unauthorized), a REALM attribute that 2900 specifies the authentication realm used by the server (in this case, 2901 the server's domain "example.com"), and a nonce value in a NONCE 2902 attribute. The NONCE attribute starts with the "nonce cookie" with 2903 the STUN Security Feature "Password algorithm" bit set to 1. The 2904 server includes a PASSWORD-ALGORITHMS attribute that specifies the 2905 list of algorithms that the server can use to derive the long-term 2906 password. If the server sets the STUN Security Feature "Username 2907 anonymity" bit to 1 then the client uses the USERHASH attribute 2908 instead of the USERNAME attribute in the Allocate request to 2909 anonymise the username. The server also includes a SOFTWARE 2910 attribute that gives information about the server's software. 2912 The client, upon receipt of the 401 error, re-attempts the Allocate 2913 request, this time including the authentication attributes. The 2914 client selects a new transaction id, and then populates the new 2915 Allocate request with the same attributes as before. The client 2916 includes a USERNAME attribute and uses the realm value received from 2917 the server to help it determine which value to use; here the client 2918 is configured to use the username "George" for the realm 2919 "example.com". The client includes the PASSWORD-ALGORITHM attribute 2920 indicating the algorithm that the server must use to derive the long- 2921 term password. The client also includes the REALM and NONCE 2922 attributes, which are just copied from the 401 error response. 2923 Finally, the client includes MESSAGE-INTEGRITY and MESSAGE-INTEGRITY- 2924 SHA256 attributes as the last attributes in the message, whose values 2925 are Hashed Message Authentication Code - Secure Hash Algorithm 1 2926 (HMAC-SHA1) hash and Hashed Message Authentication Code - Secure Hash 2927 Algorithm 2 (HMAC-SHA2) hash over the contents of the message (shown 2928 as just "..." above); this HMAC-SHA1 and HMAC-SHA2 computation 2929 includes a password value. Thus, an attacker cannot compute the 2930 message integrity value without somehow knowing the secret password. 2932 The server, upon receipt of the authenticated Allocate request, 2933 checks that everything is OK, then creates an allocation. The server 2934 replies with an Allocate success response. The server includes a 2935 LIFETIME attribute giving the lifetime of the allocation; here, the 2936 server has reduced the client's requested 1-hour lifetime to just 20 2937 minutes, because this particular server doesn't allow lifetimes 2938 longer than 20 minutes. The server includes an XOR-RELAYED-ADDRESS 2939 attribute whose value is the relayed transport address of the 2940 allocation. The server includes an XOR-MAPPED-ADDRESS attribute 2941 whose value is the server-reflexive address of the client; this value 2942 is not used otherwise in TURN but is returned as a convenience to the 2943 client. The server includes either a MESSAGE-INTEGRITY or MESSAGE- 2944 INTEGRITY-SHA256 attribute to authenticate the response and to ensure 2945 its integrity; note that the response does not contain the USERNAME, 2946 REALM, and NONCE attributes. The server also includes a SOFTWARE 2947 attribute. 2949 TURN TURN Peer Peer 2950 client server A B 2951 |--- CreatePermission request ------>| | | 2952 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2953 | XOR-PEER-ADDRESS=192.0.2.150:0 | | | 2954 | USERNAME="George" | | | 2955 | REALM="example.com" | | | 2956 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 2957 | MESSAGE-INTEGRITY=... | | | 2958 | | | | 2959 |<-- CreatePermission success resp.--| | | 2960 | Transaction-Id=0xE5913A8F460956CA277D3319 | | 2961 | MESSAGE-INTEGRITY=... | | | 2963 The client then creates a permission towards Peer A in preparation 2964 for sending it some application data. This is done through a 2965 CreatePermission request. The XOR-PEER-ADDRESS attribute contains 2966 the IP address for which a permission is established (the IP address 2967 of peer A); note that the port number in the attribute is ignored 2968 when used in a CreatePermission request, and here it has been set to 2969 0; also, note how the client uses Peer A's server-reflexive IP 2970 address and not its (private) host address. The client uses the same 2971 username, realm, and nonce values as in the previous request on the 2972 allocation. Though it is allowed to do so, the client has chosen not 2973 to include a SOFTWARE attribute in this request. 2975 The server receives the CreatePermission request, creates the 2976 corresponding permission, and then replies with a CreatePermission 2977 success response. Like the client, the server chooses not to include 2978 the SOFTWARE attribute in its reply. Again, note how success 2979 responses contain a MESSAGE-INTEGRITY or MESSAGE-INTEGRITY-SHA256 2980 attribute (assuming the server uses the long-term credential 2981 mechanism), but no USERNAME, REALM, and NONCE attributes. 2983 TURN TURN Peer Peer 2984 client server A B 2985 |--- Send indication --------------->| | | 2986 | Transaction-Id=0x1278E9ACA2711637EF7D3328 | | 2987 | XOR-PEER-ADDRESS=192.0.2.150:32102 | | 2988 | DONT-FRAGMENT | | | 2989 | DATA=... | | | 2990 | |-- UDP dgm ->| | 2991 | | data=... | | 2992 | | | | 2993 | |<- UDP dgm --| | 2994 | | data=... | | 2995 |<-- Data indication ----------------| | | 2996 | Transaction-Id=0x8231AE8F9242DA9FF287FEFF | | 2997 | XOR-PEER-ADDRESS=192.0.2.150:32102 | | 2998 | DATA=... | | | 3000 The client now sends application data to Peer A using a Send 3001 indication. Peer A's server-reflexive transport address is specified 3002 in the XOR-PEER-ADDRESS attribute, and the application data (shown 3003 here as just "...") is specified in the DATA attribute. The client 3004 is doing a form of path MTU discovery at the application layer and 3005 thus specifies (by including the DONT-FRAGMENT attribute) that the 3006 server should set the DF bit in the UDP datagram to send to the peer. 3007 Indications cannot be authenticated using the long-term credential 3008 mechanism of STUN, so no MESSAGE-INTEGRITY or MESSAGE-INTEGRITY- 3009 SHA256 attribute is included in the message. An application wishing 3010 to ensure that its data is not altered or forged must integrity- 3011 protect its data at the application level. 3013 Upon receipt of the Send indication, the server extracts the 3014 application data and sends it in a UDP datagram to Peer A, with the 3015 relayed transport address as the source transport address of the 3016 datagram, and with the DF bit set as requested. Note that, had the 3017 client not previously established a permission for Peer A's server- 3018 reflexive IP address, then the server would have silently discarded 3019 the Send indication instead. 3021 Peer A then replies with its own UDP datagram containing application 3022 data. The datagram is sent to the relayed transport address on the 3023 server. When this arrives, the server creates a Data indication 3024 containing the source of the UDP datagram in the XOR-PEER-ADDRESS 3025 attribute, and the data from the UDP datagram in the DATA attribute. 3026 The resulting Data indication is then sent to the client. 3028 TURN TURN Peer Peer 3029 client server A B 3030 |--- ChannelBind request ----------->| | | 3031 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 3032 | CHANNEL-NUMBER=0x4000 | | | 3033 | XOR-PEER-ADDRESS=192.0.2.210:49191 | | 3034 | USERNAME="George" | | | 3035 | REALM="example.com" | | | 3036 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 3037 | MESSAGE-INTEGRITY=... | | | 3038 | | | | 3039 |<-- ChannelBind success response ---| | | 3040 | Transaction-Id=0x6490D3BC175AFF3D84513212 | | 3041 | MESSAGE-INTEGRITY=... | | | 3043 The client now binds a channel to Peer B, specifying a free channel 3044 number (0x4000) in the CHANNEL-NUMBER attribute, and Peer B's 3045 transport address in the XOR-PEER-ADDRESS attribute. As before, the 3046 client re-uses the username, realm, and nonce from its last request 3047 in the message. 3049 Upon receipt of the request, the server binds the channel number to 3050 the peer, installs a permission for Peer B's IP address, and then 3051 replies with ChannelBind success response. 3053 TURN TURN Peer Peer 3054 client server A B 3055 |--- ChannelData ------------------->| | | 3056 | Channel-number=0x4000 |--- UDP datagram --------->| 3057 | Data=... | Data=... | 3058 | | | | 3059 | |<-- UDP datagram ----------| 3060 | | Data=... | | 3061 |<-- ChannelData --------------------| | | 3062 | Channel-number=0x4000 | | | 3063 | Data=... | | | 3065 The client now sends a ChannelData message to the server with data 3066 destined for Peer B. The ChannelData message is not a STUN message, 3067 and thus has no transaction id. Instead, it has only three fields: a 3068 channel number, data, and data length; here the channel number field 3069 is 0x4000 (the channel the client just bound to Peer B). When the 3070 server receives the ChannelData message, it checks that the channel 3071 is currently bound (which it is) and then sends the data onward to 3072 Peer B in a UDP datagram, using the relayed transport address as the 3073 source transport address and 192.0.2.210:49191 (the value of the XOR- 3074 PEER-ADDRESS attribute in the ChannelBind request) as the destination 3075 transport address. 3077 Later, Peer B sends a UDP datagram back to the relayed transport 3078 address. This causes the server to send a ChannelData message to the 3079 client containing the data from the UDP datagram. The server knows 3080 to which client to send the ChannelData message because of the 3081 relayed transport address at which the UDP datagram arrived, and 3082 knows to use channel 0x4000 because this is the channel bound to 3083 192.0.2.210:49191. Note that if there had not been any channel 3084 number bound to that address, the server would have used a Data 3085 indication instead. 3087 TURN TURN Peer Peer 3088 client server A B 3089 |--- Refresh request --------------->| | | 3090 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 3091 | SOFTWARE="Example client 1.03" | | | 3092 | USERNAME="George" | | | 3093 | REALM="example.com" | | | 3094 | NONCE="obMatJos2AAABadl7W7PeDU4hKE72jda" | | 3095 | MESSAGE-INTEGRITY=... | | | 3096 | | | | 3097 |<-- Refresh error response ---------| | | 3098 | Transaction-Id=0x0864B3C27ADE9354B4312414 | | 3099 | SOFTWARE="Example server, version 1.17" | | 3100 | ERROR-CODE=438 (Stale Nonce) | | | 3101 | REALM="example.com" | | | 3102 | NONCE="obMatJos2AAABnpSw1Xw239bBwGYhjN" | | 3103 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 3104 | | | | 3105 |--- Refresh request --------------->| | | 3106 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 3107 | SOFTWARE="Example client 1.03" | | | 3108 | USERNAME="George" | | | 3109 | REALM="example.com" | | | 3110 | NONCE="obMatJos2AAABnpSw1Xw239bBwGYhjNj" | | 3111 | PASSWORD-ALGORITHMS=MD5 and SHA256 | | 3112 | PASSWORD-ALGORITHM=SHA256 | | | 3113 | MESSAGE-INTEGRITY=... | | | 3114 | | | | 3115 |<-- Refresh success response -------| | | 3116 | Transaction-Id=0x427BD3E625A85FC731DC4191 | | 3117 | SOFTWARE="Example server, version 1.17" | | 3118 | LIFETIME=600 (10 minutes) | | | 3120 Sometime before the 20 minute lifetime is up, the client refreshes 3121 the allocation. This is done using a Refresh request. As before, 3122 the client includes the latest username, realm, and nonce values in 3123 the request. The client also includes the SOFTWARE attribute, 3124 following the recommended practice of always including this attribute 3125 in Allocate and Refresh messages. When the server receives the 3126 Refresh request, it notices that the nonce value has expired, and so 3127 replies with 438 (Stale Nonce) error given a new nonce value. The 3128 client then reattempts the request, this time with the new nonce 3129 value. This second attempt is accepted, and the server replies with 3130 a success response. Note that the client did not include a LIFETIME 3131 attribute in the request, so the server refreshes the allocation for 3132 the default lifetime of 10 minutes (as can be seen by the LIFETIME 3133 attribute in the success response). 3135 19. Security Considerations 3137 This section considers attacks that are possible in a TURN 3138 deployment, and discusses how they are mitigated by mechanisms in the 3139 protocol or recommended practices in the implementation. 3141 Most of the attacks on TURN are mitigated by the server requiring 3142 requests be authenticated. Thus, this specification requires the use 3143 of authentication. The mandatory-to-implement mechanism is the long- 3144 term credential mechanism of STUN. Other authentication mechanisms 3145 of equal or stronger security properties may be used. However, it is 3146 important to ensure that they can be invoked in an inter-operable 3147 way. 3149 19.1. Outsider Attacks 3151 Outsider attacks are ones where the attacker has no credentials in 3152 the system, and is attempting to disrupt the service seen by the 3153 client or the server. 3155 19.1.1. Obtaining Unauthorized Allocations 3157 An attacker might wish to obtain allocations on a TURN server for any 3158 number of nefarious purposes. A TURN server provides a mechanism for 3159 sending and receiving packets while cloaking the actual IP address of 3160 the client. This makes TURN servers an attractive target for 3161 attackers who wish to use it to mask their true identity. 3163 An attacker might also wish to simply utilize the services of a TURN 3164 server without paying for them. Since TURN services require 3165 resources from the provider, it is anticipated that their usage will 3166 come with a cost. 3168 These attacks are prevented using the long-term credential mechanism, 3169 which allows the TURN server to determine the identity of the 3170 requestor and whether the requestor is allowed to obtain the 3171 allocation. 3173 19.1.2. Offline Dictionary Attacks 3175 The long-term credential mechanism used by TURN is subject to offline 3176 dictionary attacks. An attacker that is capable of eavesdropping on 3177 a message exchange between a client and server can determine the 3178 password by trying a number of candidate passwords and seeing if one 3179 of them is correct. This attack works when the passwords are low 3180 entropy, such as a word from the dictionary. This attack can be 3181 mitigated by using strong passwords with large entropy. In 3182 situations where even stronger mitigation is required, (D)TLS 3183 transport between the client and the server can be used. 3185 19.1.3. Faked Refreshes and Permissions 3187 An attacker might wish to attack an active allocation by sending it a 3188 Refresh request with an immediate expiration, in order to delete it 3189 and disrupt service to the client. This is prevented by 3190 authentication of refreshes. Similarly, an attacker wishing to send 3191 CreatePermission requests to create permissions to undesirable 3192 destinations is prevented from doing so through authentication. The 3193 motivations for such an attack are described in Section 19.2. 3195 19.1.4. Fake Data 3197 An attacker might wish to send data to the client or the peer, as if 3198 they came from the peer or client, respectively. To do that, the 3199 attacker can send the client a faked Data Indication or ChannelData 3200 message, or send the TURN server a faked Send Indication or 3201 ChannelData message. 3203 Since indications and ChannelData messages are not authenticated, 3204 this attack is not prevented by TURN. However, this attack is 3205 generally present in IP-based communications and is not substantially 3206 worsened by TURN. Consider a normal, non-TURN IP session between 3207 hosts A and B. An attacker can send packets to B as if they came 3208 from A by sending packets towards A with a spoofed IP address of B. 3209 This attack requires the attacker to know the IP addresses of A and 3210 B. With TURN, an attacker wishing to send packets towards a client 3211 using a Data indication needs to know its IP address (and port), the 3212 IP address and port of the TURN server, and the IP address and port 3213 of the peer (for inclusion in the XOR-PEER-ADDRESS attribute). To 3214 send a fake ChannelData message to a client, an attacker needs to 3215 know the IP address and port of the client, the IP address and port 3216 of the TURN server, and the channel number. This particular 3217 combination is mildly more guessable than in the non-TURN case. 3219 These attacks are more properly mitigated by application-layer 3220 authentication techniques. In the case of real-time traffic, usage 3221 of SRTP [RFC3711] prevents these attacks. 3223 In some situations, the TURN server may be situated in the network 3224 such that it is able to send to hosts to which the client cannot 3225 directly send. This can happen, for example, if the server is 3226 located behind a firewall that allows packets from outside the 3227 firewall to be delivered to the server, but not to other hosts behind 3228 the firewall. In these situations, an attacker could send the server 3229 a Send indication with an XOR-PEER-ADDRESS attribute containing the 3230 transport address of one of the other hosts behind the firewall. If 3231 the server was to allow relaying of traffic to arbitrary peers, then 3232 this would provide a way for the attacker to attack arbitrary hosts 3233 behind the firewall. 3235 To mitigate this attack, TURN requires that the client establish a 3236 permission to a host before sending it data. Thus, an attacker can 3237 only attack hosts with which the client is already communicating, 3238 unless the attacker is able to create authenticated requests. 3239 Furthermore, the server administrator may configure the server to 3240 restrict the range of IP addresses and ports to which it will relay 3241 data. To provide even greater security, the server administrator can 3242 require that the client use (D)TLS for all communication between the 3243 client and the server. 3245 19.1.5. Impersonating a Server 3247 When a client learns a relayed address from a TURN server, it uses 3248 that relayed address in application protocols to receive traffic. 3249 Therefore, an attacker wishing to intercept or redirect that traffic 3250 might try to impersonate a TURN server and provide the client with a 3251 faked relayed address. 3253 This attack is prevented through the long-term credential mechanism, 3254 which provides message integrity for responses in addition to 3255 verifying that they came from the server. Furthermore, an attacker 3256 cannot replay old server responses as the transaction id in the STUN 3257 header prevents this. Replay attacks are further thwarted through 3258 frequent changes to the nonce value. 3260 19.1.6. Eavesdropping Traffic 3262 TURN concerns itself primarily with authentication and message 3263 integrity. Confidentiality is only a secondary concern, as TURN 3264 control messages do not include information that is particularly 3265 sensitive. The primary protocol content of the messages is the IP 3266 address of the peer. If it is important to prevent an eavesdropper 3267 on a TURN connection from learning this, TURN can be run over (D)TLS. 3269 Confidentiality for the application data relayed by TURN is best 3270 provided by the application protocol itself, since running TURN over 3271 (D)TLS does not protect application data between the server and the 3272 peer. If confidentiality of application data is important, then the 3273 application should encrypt or otherwise protect its data. For 3274 example, for real-time media, confidentiality can be provided by 3275 using SRTP. 3277 19.1.7. TURN Loop Attack 3279 An attacker might attempt to cause data packets to loop indefinitely 3280 between two TURN servers. The attack goes as follows. First, the 3281 attacker sends an Allocate request to server A, using the source 3282 address of server B. Server A will send its response to server B, 3283 and for the attack to succeed, the attacker must have the ability to 3284 either view or guess the contents of this response, so that the 3285 attacker can learn the allocated relayed transport address. The 3286 attacker then sends an Allocate request to server B, using the source 3287 address of server A. Again, the attacker must be able to view or 3288 guess the contents of the response, so it can send learn the 3289 allocated relayed transport address. Using the same spoofed source 3290 address technique, the attacker then binds a channel number on server 3291 A to the relayed transport address on server B, and similarly binds 3292 the same channel number on server B to the relayed transport address 3293 on server A. Finally, the attacker sends a ChannelData message to 3294 server A. 3296 The result is a data packet that loops from the relayed transport 3297 address on server A to the relayed transport address on server B, 3298 then from server B's transport address to server A's transport 3299 address, and then around the loop again. 3301 This attack is mitigated as follows. By requiring all requests to be 3302 authenticated and/or by randomizing the port number allocated for the 3303 relayed transport address, the server forces the attacker to either 3304 intercept or view responses sent to a third party (in this case, the 3305 other server) so that the attacker can authenticate the requests and 3306 learn the relayed transport address. Without one of these two 3307 measures, an attacker can guess the contents of the responses without 3308 needing to see them, which makes the attack much easier to perform. 3309 Furthermore, by requiring authenticated requests, the server forces 3310 the attacker to have credentials acceptable to the server, which 3311 turns this from an outsider attack into an insider attack and allows 3312 the attack to be traced back to the client initiating it. 3314 The attack can be further mitigated by imposing a per-username limit 3315 on the bandwidth used to relay data by allocations owned by that 3316 username, to limit the impact of this attack on other allocations. 3317 More mitigation can be achieved by decrementing the TTL when relaying 3318 data packets (if the underlying OS allows this). 3320 19.2. Firewall Considerations 3322 A key security consideration of TURN is that TURN should not weaken 3323 the protections afforded by firewalls deployed between a client and a 3324 TURN server. It is anticipated that TURN servers will often be 3325 present on the public Internet, and clients may often be inside 3326 enterprise networks with corporate firewalls. If TURN servers 3327 provide a 'backdoor' for reaching into the enterprise, TURN will be 3328 blocked by these firewalls. 3330 TURN servers therefore emulate the behavior of NAT devices that 3331 implement address-dependent filtering [RFC4787], a property common in 3332 many firewalls as well. When a NAT or firewall implements this 3333 behavior, packets from an outside IP address are only allowed to be 3334 sent to an internal IP address and port if the internal IP address 3335 and port had recently sent a packet to that outside IP address. TURN 3336 servers introduce the concept of permissions, which provide exactly 3337 this same behavior on the TURN server. An attacker cannot send a 3338 packet to a TURN server and expect it to be relayed towards the 3339 client, unless the client has tried to contact the attacker first. 3341 It is important to note that some firewalls have policies that are 3342 even more restrictive than address-dependent filtering. Firewalls 3343 can also be configured with address- and port-dependent filtering, or 3344 can be configured to disallow inbound traffic entirely. In these 3345 cases, if a client is allowed to connect the TURN server, 3346 communications to the client will be less restrictive than what the 3347 firewall would normally allow. 3349 19.2.1. Faked Permissions 3351 In firewalls and NAT devices, permissions are granted implicitly 3352 through the traversal of a packet from the inside of the network 3353 towards the outside peer. Thus, a permission cannot, by definition, 3354 be created by any entity except one inside the firewall or NAT. With 3355 TURN, this restriction no longer holds. Since the TURN server sits 3356 outside the firewall, at attacker outside the firewall can now send a 3357 message to the TURN server and try to create a permission for itself. 3359 This attack is prevented because all messages that create permissions 3360 (i.e., ChannelBind and CreatePermission) are authenticated. 3362 19.2.2. Blacklisted IP Addresses 3364 Many firewalls can be configured with blacklists that prevent a 3365 client behind the firewall from sending packets to, or receiving 3366 packets from, ranges of blacklisted IP addresses. This is 3367 accomplished by inspecting the source and destination addresses of 3368 packets entering and exiting the firewall, respectively. 3370 This feature is also present in TURN, since TURN servers are allowed 3371 to arbitrarily restrict the range of addresses of peers that they 3372 will relay to. 3374 19.2.3. Running Servers on Well-Known Ports 3376 A malicious client behind a firewall might try to connect to a TURN 3377 server and obtain an allocation which it then uses to run a server. 3378 For example, a client might try to run a DNS server or FTP server. 3380 This is not possible in TURN. A TURN server will never accept 3381 traffic from a peer for which the client has not installed a 3382 permission. Thus, peers cannot just connect to the allocated port in 3383 order to obtain the service. 3385 19.3. Insider Attacks 3387 In insider attacks, a client has legitimate credentials but defies 3388 the trust relationship that goes with those credentials. These 3389 attacks cannot be prevented by cryptographic means but need to be 3390 considered in the design of the protocol. 3392 19.3.1. DoS against TURN Server 3394 A client wishing to disrupt service to other clients might obtain an 3395 allocation and then flood it with traffic, in an attempt to swamp the 3396 server and prevent it from servicing other legitimate clients. This 3397 is mitigated by the recommendation that the server limit the amount 3398 of bandwidth it will relay for a given username. This won't prevent 3399 a client from sending a large amount of traffic, but it allows the 3400 server to immediately discard traffic in excess. 3402 Since each allocation uses a port number on the IP address of the 3403 TURN server, the number of allocations on a server is finite. An 3404 attacker might attempt to consume all of them by requesting a large 3405 number of allocations. This is prevented by the recommendation that 3406 the server impose a limit of the number of allocations active at a 3407 time for a given username. 3409 19.3.2. Anonymous Relaying of Malicious Traffic 3411 TURN servers provide a degree of anonymization. A client can send 3412 data to peers without revealing its own IP address. TURN servers may 3413 therefore become attractive vehicles for attackers to launch attacks 3414 against targets without fear of detection. Indeed, it is possible 3415 for a client to chain together multiple TURN servers, such that any 3416 number of relays can be used before a target receives a packet. 3418 Administrators who are worried about this attack can maintain logs 3419 that capture the actual source IP and port of the client, and perhaps 3420 even every permission that client installs. This will allow for 3421 forensic tracing to determine the original source, should it be 3422 discovered that an attack is being relayed through a TURN server. 3424 19.3.3. Manipulating Other Allocations 3426 An attacker might attempt to disrupt service to other users of the 3427 TURN server by sending Refresh requests or CreatePermission requests 3428 that (through source address spoofing) appear to be coming from 3429 another user of the TURN server. TURN prevents this by requiring 3430 that the credentials used in CreatePermission, Refresh, and 3431 ChannelBind messages match those used to create the initial 3432 allocation. Thus, the fake requests from the attacker will be 3433 rejected. 3435 19.4. Tunnel Amplification Attack 3437 An attacker might attempt to cause data packets to loop numerous 3438 times between a TURN server and a tunnel between IPv4 and IPv6. The 3439 attack goes as follows. 3441 Suppose an attacker knows that a tunnel endpoint will forward 3442 encapsulated packets from a given IPv6 address (this doesn't 3443 necessarily need to be the tunnel endpoint's address). Suppose he 3444 then spoofs two packets from this address: 3446 1. An Allocate request asking for a v4 address, and 3448 2. A ChannelBind request establishing a channel to the IPv4 address 3449 of the tunnel endpoint 3451 Then he has set up an amplification attack: 3453 o The TURN relay will re-encapsulate IPv6 UDP data in v4 and send it 3454 to the tunnel endpoint 3456 o The tunnel endpoint will de-encapsulate packets from the v4 3457 interface and send them to v6 3459 So if the attacker sends a packet of the following form... 3461 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3462 UDP: 3463 TURN: 3464 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3465 UDP: 3466 TURN: 3467 IPv6: src=2001:DB8:1::1 dst=2001:DB8::2 3468 UDP: 3469 TURN: 3470 ... 3472 Then the TURN relay and the tunnel endpoint will send it back and 3473 forth until the last TURN header is consumed, at which point the TURN 3474 relay will send an empty packet, which the tunnel endpoint will drop. 3476 The amplification potential here is limited by the MTU, so it's not 3477 huge: IPv6+UDP+TURN takes 334 bytes, so a four-to-one amplification 3478 out of a 1500-byte packet is possible. But the attacker could still 3479 increase traffic volume by sending multiple packets or by 3480 establishing multiple channels spoofed from different addresses 3481 behind the same tunnel endpoint. 3483 The attack is mitigated as follows. It is RECOMMENDED that TURN 3484 relays not accept allocation or channel binding requests from 3485 addresses known to be tunneled, and that they not forward data to 3486 such addresses. In particular, a TURN relay MUST NOT accept Teredo 3487 or 6to4 addresses in these requests. 3489 19.5. Other Considerations 3491 Any relay addresses learned through an Allocate request will not 3492 operate properly with IPsec Authentication Header (AH) [RFC4302] in 3493 transport or tunnel mode. However, tunnel-mode IPsec Encapsulating 3494 Security Payload (ESP) [RFC4303] should still operate. 3496 20. IANA Considerations 3498 [Paragraphs in braces should be removed by the RFC Editor upon 3499 publication] 3501 The codepoints for the STUN methods defined in this specification are 3502 listed in Section 15. [IANA is requested to update the reference 3503 from [RFC5766] to RFC-to-be for the STUN methods listed in 3504 Section 15.] 3506 The codepoints for the STUN attributes defined in this specification 3507 are listed in Section 16. [IANA is requested to update the reference 3508 from [RFC5766] to RFC-to-be for the STUN attributes CHANNEL-NUMBER, 3509 LIFETIME, Reserved (was BANDWIDTH), XOR-PEER-ADDRESS, DATA, XOR- 3510 RELAYED-ADDRESS, REQUESTED-ADDRESS-FAMILY, EVEN-PORT, REQUESTED- 3511 TRANSPORT, DONT-FRAGMENT, Reserved (was TIMER-VAL) and RESERVATION- 3512 TOKEN listed in Section 16.] 3514 [The ADDITIONAL-ADDRESS-FAMILY, ADDRESS-ERROR-CODE and ICMP 3515 attributes requires that IANA allocate a value in the "STUN 3516 attributes Registry" from the comprehension-optional range 3517 (0x8000-0xFFFF), to be replaced for TBD-CA throughout this document] 3519 The codepoints for the STUN error codes defined in this specification 3520 are listed in Section 17. [IANA is requested to update the reference 3521 from [RFC5766] to RFC-to-be for the STUN error codes listed in 3522 Section 17.] 3524 IANA has allocated the SRV service name of "turn" for TURN over UDP 3525 or TCP, and the service name of "turns" for TURN over (D)TLS. 3527 IANA has created a registry for TURN channel numbers, initially 3528 populated as follows: 3530 o 0x0000 through 0x3FFF: Reserved and not available for use, since 3531 they conflict with the STUN header. 3533 o 0x4000 through 0x4FFF: A TURN implementation is free to use 3534 channel numbers in this range. 3536 o 0x5000 through 0xFFFF: Unassigned. 3538 Any change to this registry must be made through an IETF Standards 3539 Action. 3541 21. IAB Considerations 3543 The IAB has studied the problem of "Unilateral Self Address Fixing" 3544 (UNSAF), which is the general process by which a client attempts to 3545 determine its address in another realm on the other side of a NAT 3546 through a collaborative protocol-reflection mechanism [RFC3424]. The 3547 TURN extension is an example of a protocol that performs this type of 3548 function. The IAB has mandated that any protocols developed for this 3549 purpose document a specific set of considerations. These 3550 considerations and the responses for TURN are documented in this 3551 section. 3553 Consideration 1: Precise definition of a specific, limited-scope 3554 problem that is to be solved with the UNSAF proposal. A short-term 3555 fix should not be generalized to solve other problems. Such 3556 generalizations lead to the prolonged dependence on and usage of the 3557 supposed short-term fix -- meaning that it is no longer accurate to 3558 call it "short-term". 3560 Response: TURN is a protocol for communication between a relay (= 3561 TURN server) and its client. The protocol allows a client that is 3562 behind a NAT to obtain and use a public IP address on the relay. As 3563 a convenience to the client, TURN also allows the client to determine 3564 its server-reflexive transport address. 3566 Consideration 2: Description of an exit strategy/transition plan. 3567 The better short-term fixes are the ones that will naturally see less 3568 and less use as the appropriate technology is deployed. 3570 Response: TURN will no longer be needed once there are no longer any 3571 NATs. Unfortunately, as of the date of publication of this document, 3572 it no longer seems very likely that NATs will go away any time soon. 3573 However, the need for TURN will also decrease as the number of NATs 3574 with the mapping property of Endpoint-Independent Mapping [RFC4787] 3575 increases. 3577 Consideration 3: Discussion of specific issues that may render 3578 systems more "brittle". For example, approaches that involve using 3579 data at multiple network layers create more dependencies, increase 3580 debugging challenges, and make it harder to transition. 3582 Response: TURN is "brittle" in that it requires the NAT bindings 3583 between the client and the server to be maintained unchanged for the 3584 lifetime of the allocation. This is typically done using keep- 3585 alives. If this is not done, then the client will lose its 3586 allocation and can no longer exchange data with its peers. 3588 Consideration 4: Identify requirements for longer-term, sound 3589 technical solutions; contribute to the process of finding the right 3590 longer-term solution. 3592 Response: The need for TURN will be reduced once NATs implement the 3593 recommendations for NAT UDP behavior documented in [RFC4787]. 3594 Applications are also strongly urged to use ICE [RFC8445] to 3595 communicate with peers; though ICE uses TURN, it does so only as a 3596 last resort, and uses it in a controlled manner. 3598 Consideration 5: Discussion of the impact of the noted practical 3599 issues with existing deployed NATs and experience reports. 3601 Response: Some NATs deployed today exhibit a mapping behavior other 3602 than Endpoint-Independent mapping. These NATs are difficult to work 3603 with, as they make it difficult or impossible for protocols like ICE 3604 to use server-reflexive transport addresses on those NATs. A client 3605 behind such a NAT is often forced to use a relay protocol like TURN 3606 because "UDP hole punching" techniques [RFC5128] do not work. 3608 22. Changes since RFC 5766 3610 This section lists the major changes in the TURN protocol from the 3611 original [RFC5766] specification. 3613 o IPv6 support. 3615 o REQUESTED-ADDRESS-FAMILY, ADDITIONAL-ADDRESS-FAMILY, AND ADDRESS- 3616 ERR-CODE attributes. 3618 o 440 (Address Family not Supported) and 443 (Peer Address Family 3619 Mismatch) responses. 3621 o Description of the tunnel amplification attack. 3623 o DTLS support. 3625 o More details on packet translations. 3627 o Add support for receiving ICMP packets. 3629 o Updates PMTUD. 3631 23. Acknowledgements 3633 Most of the text in this note comes from the original TURN 3634 specification, [RFC5766]. The authors would like to thank Rohan Mahy 3635 co-author of original TURN specification and everyone who had 3636 contributed to that document. The authors would also like to 3637 acknowledge that this document inherits material from [RFC6156]. 3639 Thanks to Justin Uberti, Pal Martinsen, Oleg Moskalenko, Aijun Wang 3640 and Simon Perreault for their help on the ADDITIONAL-ADDRESS-FAMILY 3641 mechanism. Authors would like to thank Gonzalo Salgueiro, Simon 3642 Perreault, Jonathan Lennox, Brandon Williams, Karl Stahl, Noriyuki 3643 Torii, Nils Ohlmeier, Dan Wing, Justin Uberti and Oleg Moskalenko for 3644 comments and review. The authors would like to thank Marc for his 3645 contributions to the text. 3647 24. References 3648 24.1. Normative References 3650 [I-D.ietf-tram-stunbis] 3651 Petit-Huguenin, M., Salgueiro, G., Rosenberg, J., Wing, 3652 D., Mahy, R., and P. Matthews, "Session Traversal 3653 Utilities for NAT (STUN)", draft-ietf-tram-stunbis-19 3654 (work in progress), October 2018. 3656 [RFC0792] Postel, J., "Internet Control Message Protocol", STD 5, 3657 RFC 792, DOI 10.17487/RFC0792, September 1981, 3658 . 3660 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 3661 Communication Layers", STD 3, RFC 1122, 3662 DOI 10.17487/RFC1122, October 1989, 3663 . 3665 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3666 Requirement Levels", BCP 14, RFC 2119, 3667 DOI 10.17487/RFC2119, March 1997, 3668 . 3670 [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black, 3671 "Definition of the Differentiated Services Field (DS 3672 Field) in the IPv4 and IPv6 Headers", RFC 2474, 3673 DOI 10.17487/RFC2474, December 1998, 3674 . 3676 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 3677 of Explicit Congestion Notification (ECN) to IP", 3678 RFC 3168, DOI 10.17487/RFC3168, September 2001, 3679 . 3681 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 3682 Control Message Protocol (ICMPv6) for the Internet 3683 Protocol Version 6 (IPv6) Specification", STD 89, 3684 RFC 4443, DOI 10.17487/RFC4443, March 2006, 3685 . 3687 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 3688 (TLS) Protocol Version 1.2", RFC 5246, 3689 DOI 10.17487/RFC5246, August 2008, 3690 . 3692 [RFC6347] Rescorla, E. and N. Modadugu, "Datagram Transport Layer 3693 Security Version 1.2", RFC 6347, DOI 10.17487/RFC6347, 3694 January 2012, . 3696 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 3697 "IPv6 Flow Label Specification", RFC 6437, 3698 DOI 10.17487/RFC6437, November 2011, 3699 . 3701 [RFC6724] Thaler, D., Ed., Draves, R., Matsumoto, A., and T. Chown, 3702 "Default Address Selection for Internet Protocol Version 6 3703 (IPv6)", RFC 6724, DOI 10.17487/RFC6724, September 2012, 3704 . 3706 [RFC7065] Petit-Huguenin, M., Nandakumar, S., Salgueiro, G., and P. 3707 Jones, "Traversal Using Relays around NAT (TURN) Uniform 3708 Resource Identifiers", RFC 7065, DOI 10.17487/RFC7065, 3709 November 2013, . 3711 [RFC7525] Sheffer, Y., Holz, R., and P. Saint-Andre, 3712 "Recommendations for Secure Use of Transport Layer 3713 Security (TLS) and Datagram Transport Layer Security 3714 (DTLS)", BCP 195, RFC 7525, DOI 10.17487/RFC7525, May 3715 2015, . 3717 [RFC7915] Bao, C., Li, X., Baker, F., Anderson, T., and F. Gont, 3718 "IP/ICMP Translation Algorithm", RFC 7915, 3719 DOI 10.17487/RFC7915, June 2016, 3720 . 3722 [RFC8305] Schinazi, D. and T. Pauly, "Happy Eyeballs Version 2: 3723 Better Connectivity Using Concurrency", RFC 8305, 3724 DOI 10.17487/RFC8305, December 2017, 3725 . 3727 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 3728 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 3729 . 3731 24.2. Informative References 3733 [Frag-Harmful] 3734 "Fragmentation Considered Harmful", . 3737 [I-D.ietf-tls-dtls13] 3738 Rescorla, E., Tschofenig, H., and N. Modadugu, "The 3739 Datagram Transport Layer Security (DTLS) Protocol Version 3740 1.3", draft-ietf-tls-dtls13-30 (work in progress), 3741 November 2018. 3743 [I-D.ietf-tram-stun-pmtud] 3744 Petit-Huguenin, M. and G. Salgueiro, "Path MTU Discovery 3745 Using Session Traversal Utilities for NAT (STUN)", draft- 3746 ietf-tram-stun-pmtud-10 (work in progress), September 3747 2018. 3749 [I-D.rosenberg-mmusic-ice-nonsip] 3750 Rosenberg, J., "Guidelines for Usage of Interactive 3751 Connectivity Establishment (ICE) by non Session Initiation 3752 Protocol (SIP) Protocols", draft-rosenberg-mmusic-ice- 3753 nonsip-01 (work in progress), July 2008. 3755 [Port-Numbers] 3756 "IANA Port Numbers Registry", 2005, 3757 . 3759 [Protocol-Numbers] 3760 "IANA Protocol Numbers Registry", 2005, 3761 . 3763 [RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791, 3764 DOI 10.17487/RFC0791, September 1981, 3765 . 3767 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 3768 DOI 10.17487/RFC1191, November 1990, 3769 . 3771 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 3772 and E. Lear, "Address Allocation for Private Internets", 3773 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 3774 . 3776 [RFC1928] Leech, M., Ganis, M., Lee, Y., Kuris, R., Koblas, D., and 3777 L. Jones, "SOCKS Protocol Version 5", RFC 1928, 3778 DOI 10.17487/RFC1928, March 1996, 3779 . 3781 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 3782 A., Peterson, J., Sparks, R., Handley, M., and E. 3783 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 3784 DOI 10.17487/RFC3261, June 2002, 3785 . 3787 [RFC3424] Daigle, L., Ed. and IAB, "IAB Considerations for 3788 UNilateral Self-Address Fixing (UNSAF) Across Network 3789 Address Translation", RFC 3424, DOI 10.17487/RFC3424, 3790 November 2002, . 3792 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 3793 Jacobson, "RTP: A Transport Protocol for Real-Time 3794 Applications", STD 64, RFC 3550, DOI 10.17487/RFC3550, 3795 July 2003, . 3797 [RFC3711] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. 3798 Norrman, "The Secure Real-time Transport Protocol (SRTP)", 3799 RFC 3711, DOI 10.17487/RFC3711, March 2004, 3800 . 3802 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 3803 "Randomness Requirements for Security", BCP 106, RFC 4086, 3804 DOI 10.17487/RFC4086, June 2005, 3805 . 3807 [RFC4302] Kent, S., "IP Authentication Header", RFC 4302, 3808 DOI 10.17487/RFC4302, December 2005, 3809 . 3811 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 3812 RFC 4303, DOI 10.17487/RFC4303, December 2005, 3813 . 3815 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 3816 Translation (NAT) Behavioral Requirements for Unicast 3817 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 3818 2007, . 3820 [RFC4821] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 3821 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 3822 . 3824 [RFC5128] Srisuresh, P., Ford, B., and D. Kegel, "State of Peer-to- 3825 Peer (P2P) Communication across Network Address 3826 Translators (NATs)", RFC 5128, DOI 10.17487/RFC5128, March 3827 2008, . 3829 [RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using 3830 Relays around NAT (TURN): Relay Extensions to Session 3831 Traversal Utilities for NAT (STUN)", RFC 5766, 3832 DOI 10.17487/RFC5766, April 2010, 3833 . 3835 [RFC5928] Petit-Huguenin, M., "Traversal Using Relays around NAT 3836 (TURN) Resolution Mechanism", RFC 5928, 3837 DOI 10.17487/RFC5928, August 2010, 3838 . 3840 [RFC6056] Larsen, M. and F. Gont, "Recommendations for Transport- 3841 Protocol Port Randomization", BCP 156, RFC 6056, 3842 DOI 10.17487/RFC6056, January 2011, 3843 . 3845 [RFC6062] Perreault, S., Ed. and J. Rosenberg, "Traversal Using 3846 Relays around NAT (TURN) Extensions for TCP Allocations", 3847 RFC 6062, DOI 10.17487/RFC6062, November 2010, 3848 . 3850 [RFC6156] Camarillo, G., Novo, O., and S. Perreault, Ed., "Traversal 3851 Using Relays around NAT (TURN) Extension for IPv6", 3852 RFC 6156, DOI 10.17487/RFC6156, April 2011, 3853 . 3855 [RFC7635] Reddy, T., Patil, P., Ravindranath, R., and J. Uberti, 3856 "Session Traversal Utilities for NAT (STUN) Extension for 3857 Third-Party Authorization", RFC 7635, 3858 DOI 10.17487/RFC7635, August 2015, 3859 . 3861 [RFC7983] Petit-Huguenin, M. and G. Salgueiro, "Multiplexing Scheme 3862 Updates for Secure Real-time Transport Protocol (SRTP) 3863 Extension for Datagram Transport Layer Security (DTLS)", 3864 RFC 7983, DOI 10.17487/RFC7983, September 2016, 3865 . 3867 [RFC8155] Patil, P., Reddy, T., and D. Wing, "Traversal Using Relays 3868 around NAT (TURN) Server Auto Discovery", RFC 8155, 3869 DOI 10.17487/RFC8155, April 2017, 3870 . 3872 [RFC8445] Keranen, A., Holmberg, C., and J. Rosenberg, "Interactive 3873 Connectivity Establishment (ICE): A Protocol for Network 3874 Address Translator (NAT) Traversal", RFC 8445, 3875 DOI 10.17487/RFC8445, July 2018, 3876 . 3878 Authors' Addresses 3880 Tirumaleswar Reddy (editor) 3881 McAfee, Inc. 3882 Embassy Golf Link Business Park 3883 Bangalore, Karnataka 560071 3884 India 3886 Email: kondtir@gmail.com 3887 Alan Johnston (editor) 3888 Villanova University 3889 Villanova, PA 3890 USA 3892 Email: alan.b.johnston@gmail.com 3894 Philip Matthews 3895 Alcatel-Lucent 3896 600 March Road 3897 Ottawa, Ontario 3898 Canada 3900 Email: philip_matthews@magma.ca 3902 Jonathan Rosenberg 3903 jdrosen.net 3904 Edison, NJ 3905 USA 3907 Email: jdrosen@jdrosen.net 3908 URI: http://www.jdrosen.net