Internet Draft Document: Draft-Ford-Midcom-P2P-01.txt Expires: April 27, 2004 B. Ford M.t. P. Srisuresh Caymas Systems D. Kegel Kegel.com October 2003
STATUS OF this Memo
THIS Document Is An Internet-Draft and Is Subject To All Provision of Section 10 of
RFC2026. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet- Drafts as reference material or to cite them other than as "work in "
The list of current internet-drafts can be subjectssed at http://www.ietf.org/1ID-ABSTRACTS.HTML
The list of internet-draft shadow directories can be subjectssed at http://www.ietf.org/shadow.html
Distribution of this document is unlimited.
Copyright Notice
Copyright (c) The Internet Society (2003). All Rights Reserved.
Abstract
This memo documents the methods used by the current peer-to-peer (P2P) applications to communicate in the presence of middleboxes such as firewalls and network address translators (NAT). In addition, the memo suggests guidelines to application designers and middlebox implementers on In the use of special proxy, the use of special proxy, the use of special proxy, preload.
Table of contents
1. Introduction ........................................... .
2. Terminology ............................................... ...
3. Techniques for p2p communication over middleboxes ............
3.1. RELAYING ............................................... 3.2. Connection Reversal ................................
3.3. Udp hole punching ..................................
3.3.1. Peers Behind Different Nats ................
3.3.2. Peers Behind The Same Nat ....................
3.3.3. Peers Separated by Multiple Nats ...............
3.3.4. Consistent port bindings .......................
3.4. Udp port number prediction .............................
3.5. Simultaneous TCP Open ................................
4. Application Design Guidelines ................................
4.1. What Works with p2p middleboxes .........................
4.2. Applications Behind The Same Nat ........................
4.3. Peer Discovery ........................................
4.4. TCP P2P Applications ..................................
4.5. Use of midcom protocol ................................
5. Nat Design Guidelines ......................................
5.1. Deprecate The Use of symmetric nats .....................
5.2. Add incremental cone-nat support to symmetric nat devices
5.3. MAINTAING CONSISIT port Bindings for UDP Ports .....
5.3.1. Preserving port numbers ......................
5.4. Maintaining Consistent Port Bindings for TCP Ports .....
5.5. Large Timeout for P2P Applications ....................
6. Security considitys ....................................
INTRODUCTION
Present-day Internet has seen ubiquitous deployment of "middleboxes" such as network address translators (NAT), driven primarily by the ongoing depletion of the IPv4 address space. The asymmetric addressing and connectivity regimes established by these middleboxes, however, have created unique problems for peer-to-peer (P2P) applications and protocols, such as teleconferencing and multiplayer on-line gaming. These issues are likely to persist even into the IPv6 world, where NAT is often used as an IPv4 compatibility mechanism [NAT-PT] , and firewalls will still be commonplace even after NAT is no longer required.Currently deployed middleboxes are designed primarily around the client / server paradigm, in which relatively anonymous client machines actively initiate connections to well-connected servers having stable IP addresses and DNS names. Most Middleboxes Implement An Asymmetric Communication Model in Which Hosts on The Private Internal Network Can Initiate Outgoing Connections to Host s on the public network, but external hosts can not initiate connections to internal hosts except as specifically configured by the middlebox's administrator. In the common case of NAPT, a client on the internal network does not have a unique IP address on the public Internet, but instead must share a single public IP address, managed by the NAPT, with other hosts on the same private network. The anonymity and inaccessibility of the internal hosts behind a middlebox is not a problem for client software such as web browsers, which only need to Initiate Outgoing Connections. This Inaccessibility Is Sometimes Seen As a Privacy Benefit.
In the peer-to-peer paradigm, however, Internet hosts that would normally be considered "clients" need to establish communication sessions directly with each other. The initiator and the responder might lie behind different middleboxes with neither endpoint having any permanent IP address or other form of public network presence. A common on-line gaming architecture, for example, is for the participating application hosts to contact a well-known server for initialization and administration purposes. Subsequent to this, the hosts establish direct connections with each other for fast and efficient propagation of updates during game play. Similarly, a file sharing application might contact a well-known server for resource discovery or searching, but establish direct connections with peer hosts for data transfer. Middleboxes create problems for peer-to-peer connections Because Hosts Behind A Middlebox Normally Have No Permanently Usable Public Ports on The Internet To Which Incoming TCP OR UDP connections from other peers can be directed. RFC 3235 [NAT-APPL] briefly addresses this issue, but does not offer any general solutions.In this document we address the P2P / middlebox problem in two ways. First, we summarize known methods by which P2P applications can work around the presence of middleboxes. Second, we provide a set of application design guidelines based on these practices to make P2P applications operate more robustly over currently-deployed middleboxes. Further, we provide design guidelines for future middleboxes to allow them TO Support P2P Applications More Effectively. Our Focus Is To Enable Immediate and Wide Deployment of P2P Applications Requiring To Traverse Middleboxes.
2. Terminology
In this section we first summarize some middlebox terms. We focus here on the Two Kinds of Middleboxes That Commonly Cause Problems for P2P Applications.firewall
A FireWall Restricts Communication BetWeen a Private Internal
Network and the public Internet, Typically by Dropping Packets, INTERNETS, TYPICOLY
That area deemed unauthorized. A FireWall Examines But Does
NOT MODIFY THE IP Address and TCP / UDP Port Information in
Packets crossing the boundary.
Network Address Translator (NAT)
A Network Address Translator NOT Only Examines But Also Modifies
The Header Information in Packets Flowing Across The Boundary,
ALLOWING MANY HOSTS BEHIND The Nat to Share The Use of A Smaller
Number of Public IP Addresses (Offen ONE).
Network Address Translators in Turn Have Two Main Varieties:
Basic Nat
A Basic Nat Maps An Internal Host's Private IP Address To A
Public IP Address Without Changing The TCP / UDP Port
Numbers in packets crossing the boundary. Basic Nat is generally
ONLY USEFUL WHEN THE NAT HAS A POOL OF PUBLIC IP Addresses from
Which to make address bindings on behalf of infrinks.
Network Address / Port Translator (NAPT)
By Far The Most Common, A Network Address / Port Translator EXAMINES
AND MODIFIES BTH The IP Address and The TCP / UDP Port Number
Fields of Packets Crossing The Boundary, Allowing Multiple
INTERNAL HOSTS TO Share A Single Public IP Address Simultaneously.
Refer to [NAT-TRAD] and [NAT-TERM] for more general information on NAT taxonomy and terminology. Additional terms that further classify NAPT are defined in more recent work [STUN]. When an internal host opens an outgoing TCP or UDP session through a network address / port translator, the NAPT assigns the session a public IP address and port number so that subsequent response packets from the external endpoint can be received by the NAPT, translated, and forwarded to the internal host. The effect is that the NAPT establishes a port binding between (private IP address, private port number) and (public IP address, public port number). The port binding defines the address translation the NAPT will perform for the duration of the session. An issue of relevance to P2P Applications Is HOW The NAT Behaves When An Internal Host Initiates Multiple Simultaneous Sessions from a Single (Private IP, Private Port) Pair to Multiple Distinct Endpoints on The External Network.cone Nat
After Establishing a Port Binding Between A (Private IP, Private
Port) TUPLE AND A (Public IP, Public Port) Tuple, A CONE NAT WILL
Re-use this port binding for subsequent sessions the
Application May Initiate from The Same Private IP Address and
Port Number, for as long as at Least One Session Using The Port
Binding Remains Active.
For Example, Suppose Client a in The Diagram BELOW Initiates TWO
Simultaneous Outgoing Sessions Through A Cone Nat, from the Same
INTERNAL Endpoint (10.0.0.1:1234) To Two Different
External Servers, S1 and S2. The Cone Nat Assigns Just One Public
Endpoint Tuple, 155.99.25.11:62000, To Both of these sessions,
ENSURING That The "Identity" of the client's port is maintained
Across Address Translation. Since Basic Nats and Firewalls Donot Modify Port Numbers as Packets Flow Across
The Middlebox, Thepes of MiddleBoxes Can Be Viewed As A
Degenerate Form of Cove Nat.
Server S1 Server S2
18.181.0.31:1235 138.76.29.7:7:7:1235
| | |
| | |
--------------------------------------------
|
^ Session 1 (A-S1) ^ | ^ session 2 (A-S2) ^
| 18.181.0.31:1235 | | | 138.76.29.7:1235 |
V 155.99.25.11:62000 V | v 155.99.25.11:62000 V
|
CONE NAT
155.99.25.11
|
^ Session 1 (A-S1) ^ | ^ session 2 (A-S2) ^
| 18.181.0.31:1235 | | | 138.76.29.7:1235 |
v 10.0.0.1:1234 v | v 10.0.0.1:1234 v
|
Client a
10.0.0.1:1234
Symmetric Nat
A Symmetric Nat, in Contrast, Does Not maintain a consistent
Port Binding Between (Private IP, Private Port) and (Public IP,
Public Port) Across All Sessions. Instead, IT Assigns A New
Public Port to Each New Session. for Example, Suppose Client A
Initiates Two Outgoing Sessions from the Same Port as Above, One
WITH S1 AND One with s2. A Symmetric Nat Might Allocate the
Public endpoint 155.99.25.11:62000 To session 1, and then allocate
A DiffERENT PUBLIC Endpoint 155.99.25.11:62001, WHEN THE
Application Initiates Session 2. The Nat Is Able To Differentiate
Between the Two sessions for translation purposes because the
External Endpoints Involved in the sessions (Those of S1
And S2) Differ, Even as the endpoint identity of the client
Application is Lost Across The Address Translation Boundary.
Server S1 Server S218.181.0.31: 1235 138.76.29.7:1235
| | |
| | |
--------------------------------------------
|
^ Session 1 (A-S1) ^ | ^ session 2 (A-S2) ^
| 18.181.0.31:1235 | | | 138.76.29.7:1235 |
V 155.99.25.11:62000 V | v 155.99.25.11:62001 V
|
Symmetric Nat
155.99.25.11
|
^ Session 1 (A-S1) ^ | ^ session 2 (A-S2) ^
| 18.181.0.31:1235 | | | 138.76.29.7:1235 |
v 10.0.0.1:1234 v | v 10.0.0.1:1234 v
|
Client a
10.0.0.1:1234
.
Cone NAT is further classified according to how liberally the NAT accepts incoming traffic directed to an already-established (public IP, public port) pair. This classification generally applies only to UDP traffic, since NATs and firewalls reject incoming TCP connection attempts unconditionally unless specifically Configured to do otherwise.
Full Cone Nat
After Establishing a public / private port binding for a New
Outgoing session, A Full CONE NAT WILL SUBSEQUENTLY ACCEPT
incoming Traffic To The Corresponding Public Port from ANY
External Endpoint on The Public Network. Full Cone Nat IS
Also Sometimes Called "Promiscuous" NAT.
Restricted cone nat
A restrified connotation, a restrified connotation packet directed to
a public port if its external (source) ip address matches the
Address of a node to which the internal host Has Previously Sent
One or more outgoing packets. A Restricted CONE NAT EFFECTIELY
Refines the firewall principle of rejecting unsolicited incomingtraffic, by restricting incoming traffic to a set of "known"
External IP Addresses.
Port-restricted cone nat
A port-restricted conge nat, in turn, only forwards an incoming
Packet if ITS External IP Address and Port Number Match Those of Port
An External Endpoint to Which The Internal Host Has Previously
Sent Outgoing Packets. A Port-Restricted Cove Nat Provides
INTERNAL NODES The Same Level of Protection Against Unsolicited
incoming Traffic That A Symmetric Nat Does, While Maintaining A
Private port's Identity Across Translation.
Finally, In this Document We define new Terms for classifying the p2p-release behavior of middleboxes:
P2P-Application
P2P-Application As Used in this Document is an Application in
Which Each P2P Participant Registers with a public
Registration Server, and Subsequently Uses Either ITS
PRIVATE Endpoint, or Both, To Establish
Peering sessions.
P2P-MIDDLEBOX
A p2p-middlebox is middlebox that permits the traversal of
P2P Applications.
P2P-firewall
A p2p-firewall is a p2p-middlebox that provides firewall
Functionality But Performs No Address Translation.
P2P-NAT
A P2P-NAT IS A P2P-MIDDLEBOX THAT PROVIDES NAT FUNCTIONALITY, AND
May Also Provide Firewall FunctionAlity. at minimum, A
P2P-MIDDLEBOX MUST IMPLEMENT CONE NAT Behavior for UDP Traffic,
Allowing Applications to Establish Robust P2P Connectivity Using
The UDP Hole Punching Technique.
Loopback Translation
WHEN a Host In The Private Domain of a Nat Device Attempts To
Connect with Another Host Behind The Same Nat Device Using
The Public Address of the Host, The Nat Device Performs The
Equivalent of a "twice-nat" Translation on the packet asfollows. The Originating Host's Private Endpoint is translated
INTO ITS Assigned Public Endpoint, And The Target Host's Public
Endpoint Is Translated Into ITS Private Endpoint, Before
The packet is forwarded to the target host. We Refer the Above
Translation Performed by a Nat Device As "LoopBack Translation".
3. Techniques for P2P Communication over Middleboxes
..............................
3.1. RELAYING
The most reliable, but least efficient, method of implementing peer- to-peer communication in the presence of a middlebox is to make the peer-to-peer communication look to the network like client / server communication through relaying. For example, suppose two client hosts, A and B, have each initiated TCP or UDP connections with a well-known server S a permanent IP address having. The clients reside on separate private networks, however, and their respective middleboxes prevent either client from directly initiating a connection to The Other.
Server S
|
|
--------------------------------------------
| | |
Nat a nat b
| | |
| | |
Client a Client B
Instead of attempting a direct connection, the two clients can simply use the server S to relay messages between them. For example, to send a message to client B, client A simply sends the message to server S along its already-established client / server connection, and server S then sends the message on to client B using its existing client / server connection with B.This method has the advantage that it will always work as long as both clients have connectivity to the server. Its obvious disadvantages are that it consumes the server's processing power and network bandwidth unnecessarily, and communication latency between the two clients is likely to be increased even if the server is well- connected. The TURN protocol [TURN] defines a method of implementing relaying in a relatively secure fashion.
3.2. Connection Reversal
The Second Technique Works IF Only One of the Clients Is Behind A Middlebox. For Example, Suppose Client A Is Behind A Nat But Client B Has A Globally Routable IP Address, AS in The Following Diagram:
Server S
18.181.0.31:1235
|
|
--------------------------------------------
| | |
NAT A |
155.99.25.11:62000 |
| | |
| | |
Client a Client B
10.0.0.1:1234 138.76.29.7:1234
Client A has private IP address 10.0.0.1, and the application is using TCP port 1234. This client has established a connection with server S at public IP address 18.181.0.31 and port 1235. NAT A has assigned TCP port 62000, at its own public IP address 155.99.25.11, to serve as the temporary public endpoint address for A's session with S: therefore, server S believes that client A is at IP address 155.99.25.11 using port 62000. Client B, however, has its own permanent IP address, 138.76.29.7, and the peer-to-peer application on B is accepting TCP connections at port 1234.Now suppose client B would like to initiate a peer-to-peer communication session with client A. B might first attempt to contact client A either at the address client A believes itself to have, namely 10.0.0.1:1234, or at the address of A as observed by server S, namely 155.99.25.11:62000. In either case, however, the connection will fail. In The First Case, Traffic Directed to IP Address 10.0.0.1 Will Simply Be Droppe d by the network because 10.0.0.1 is not a publicly routable IP address. In the second case, the TCP SYN request from B will arrive at NAT A directed to port 62000, but NAT A will reject the connection request because only outgoing connections are ALOWED.
After attempting and failing to establish a direct connection to A, client B can use server S to relay a request to client A to initiate a "reversed" connection to client B. Client A, upon receiving this relayed request through S, opens a TCP connection to client B at B's public IP address and port number. NAT A allows the connection to proceed because it is originating inside the firewall, and client B can receive the connection because it is not behind a middlebox. A variety of current peer-to -peer systems implement this technique Its main limitation, of course, is that it only works as long as only one of the communicating peers is behind a NAT:.. in the increasingly common case where both peers are behind NATs, the method fails Because connection reversal is not a general solution to the problem, it is nOT recommended as a primary strategy. Applications may choose to attempt connection reversal, but should be able to fall back automatically on another mechanism such as relaying if Neither A "Forward" NOR A "Reverse" Connection Can Be Established.3.3. UDP HOLE PUNCHING
The third technique, and the one of primary interest in this document, is widely known as "UDP Hole Punching." UDP hole punching relies on the properties of common firewalls and cone NATs to allow appropriately designed peer-to-peer applications to "punch Holes "Through The Middlebox and Establish Direct Connectivity with Each Other, Even WHEN Both Communicating Hosts May Lie Behind Middleboxes. This Technique WAS MENTION BRIEFLY IN Section 5.1 of
RFC 3027 [NAT- PROT], and has been informally described elsewhere on the Internet [KEGEL] and used in some recent protocols [TEREDO, ICE]. As the name implies, unfortunately, this technique works reliably only with UDP.We will consider two specific scenarios, and how applications can be designed to handle both of them gracefully. In the first situation, representing the common case, two clients desiring direct peer-to- peer communication reside behind two different NATs. In the second, the two clients Actually Reside Behind The Same Nat, But Do Not Necessarily Know That They Do.
3.3.1. Peers Behind Different Nats
Suppose clients A and B both have private IP addresses and lie behind different network address translators. The peer-to-peer application running on clients A and B and on server S each use UDP port 1234. A and B have each initiated UDP communication sessions WITH Server S, Causeing Nat a to assign ITS OWN PUBLIC UDP Port 62000 for a'session with s, and causing nt b to assign ITS Port 31000 To B 'Sense With s, respective.
Server S
18.181.0.31:1234
|
|
--------------------------------------------
| | |
Nat a nat b
155.99.25.11:62000 138.76.29.7:31000
| | |
| | |
Client a Client B
10.0.0.1:1234 10.1.1.3:1234
Now suppose that client A wants to establish a UDP communication session directly with client B. If A simply starts sending UDP messages to B's public address, 138.76.29.7:31000, then NAT B will typically discard these incoming messages (unless it is a full cone NAT), because the source address and port number does not match those of S, with which the original outgoing session was established. Similarly, if B simply starts sending UDP messages to A's public address, then NAT A will typically discard these messages. Suppose A starts sending UDP messages to B's public address, however, and simultaneously relays a request through server S to B, asking B to start sending UDP messages to A's public address. A's outgoing messages directed to B's public address (138.76.29.7:31000 ) cause NAT A to open up a new communication session between A's private address and B's public address. At the same time, B's messages to A's public address (155.99.25.11:62000) cause NAT B to open up a new communicat ion session between B's private address and A's public address. Once the new UDP sessions have been opened up in each direction, client A and B can communicate with each other directly without further burden on the "introduction" server S.
The UDP hole punching technique has several useful properties. Once a direct peer-to-peer UDP connection has been established between two clients behind middleboxes, either party on that connection can in turn take over the role of "introducer" and help the other party establish peer-to-peer connections with additional peers, minimizing the load on the initial introduction server S. The application does not need to attempt to detect explicitly what kind of middlebox it is behind, if any [STUN], since the procedure above will establish peer- to-peer communication channels equally well if either or both clients do not happen to be behind a middlebox. The hole punching technique even works automatically with multiple NATs, where one or both clients are removed from the public Internet via two or more Levels of address translation.3.3.2. Peers Behind The Same Nat
Now consider the scenario in which the two clients (probably unknowingly) happen to reside behind the same NAT, and are therefore located in the same private IP address space. Client A has established a UDP session with server S, to which the common NAT has Assigned public port number 62000. Client B Has Similarly Established a session with s, to which the Nat Has Assigned Public Port Number 62001.
Server S
18.181.0.31:1234
|
|
NAT
A-S 155.99.25.11:62000
B-S 155.99.25.11:62001
|
--------------------------------------------
| | |
Client a Client B
10.0.0.1:1234 10.1.1.3:1234
Suppose that A and B use the UDP hole punching technique as outlined above to establish a communication channel using server S as an introducer. Then A and B will learn each other's public IP addresses and port numbers as observed by server S, and start sending each other messages at those public addresses. The two clients will be able to communicate with each other this way as long as the NAT allows hosts on the internal network to open translated UDP sessions with other internal hosts and not just with external hosts. We refer to this situation as "loopback translation," because packets arriving at the NAT from the private network are translated and then "looped back" to the private network rather than being passed through to the public network. For example, when A sends a UDP packet to B's Public Address, The Packet Initially Has A Source IP Address and Port Number of 10.0.0.1:124 And A Destination of 155.99.25.11:62001. The Nat Receives this Packet, Translates It To Have A Source O f 155.99.25.11:62000 (A's public address) and a destination of 10.1.1.3:1234, and then forwards it on to B. Even if loopback translation is supported by the NAT, this translation and forwarding step is obviously unnecessary in this situation And is Likey to Add Latency to the Dialog Between a and b as well as budening the nat.
The solution to this problem is straightforward, however. When A and B initially exchange address information through server S, they should include their own IP addresses and port numbers as "observed" by themselves, as well as their addresses as observed by S. The clients then simultaneously start sending packets to each other at each of the alternative addresses they know about, and use the first address that leads to successful communication. If the two clients are behind the same NAT, then the packets directed to their private addresses are likely to arrive first, resulting in a direct communication channel not involving the NAT. If the two clients are behind different NATs, then the packets directed to their private addresses will fail to reach each other at all, but the clients will hopefully establish connectivity using their Respective public addresses. it is important what these packets be authenticated in Some Way, However, Since In The Case Of Different Nats It Is Entirely P Ossible for a's Messages Directed At B's Private Address To Reach Some Other, Unrelated Node on a's private network, or vice versa.3.3.3. Peers Separated by Multiple Nats
In some topologies involving multiple NAT devices, it is not possible for two clients to establish an "optimal" P2P route between them without specific knowledge of the topology. Consider for example the following situation.
Server S
18.181.0.31:1234
|
|
NAT X
A-S 155.99.25.11:62000
B-S 155.99.25.11:62001
|
|
--------------------------------------------
| | |
Nat a nat b
192.168.1.1:30000 192.168.1.2:31000
| | || |
Client a Client B
10.0.0.1:1234 10.1.1.3:1234
Suppose NAT X is a large industrial NAT deployed by an internet service provider (ISP) to multiplex many customers onto a few public IP addresses, and NATs A and B are small consumer NAT gateways deployed independently by two of the ISP's customers to multiplex their private home networks onto respective ISP-provided IP addresses Only server S and NAT X have globally routable IP addresses their;. the "public" IP addresses used by NAT A and NAT B are actually private to the ISP's addressing realm, while client A's and B's addresses in turn are private to the addressing realms of NAT A and B, respectively. each client initiates an outgoing connection to server S as before, causing NATs A and B each to create a single public / private translation, and causing NAT X to establish a public / private translation for each session.
Now suppose clients A and B attempt to establish a direct peer-to- peer UDP connection. The optimal method would be for client A to send messages to client B's public address at NAT B, 192.168.1.2:31000 in the ISP's addressing realm, and for client B to send messages to A's public address at NAT B, namely 192.168.1.1:30000. Unfortunately, A and B have no way to learn these addresses, because server S only sees the "global" public addresses of the clients, 155.99.25.11:62000 and 155.99.25.11:62001. Even if A and B had some way to learn these addresses, there is still no guarantee that they would be usable because the address assignments in the ISP's private addressing realm might conflict with unrelated address assignments in the clients' private realms. The clients therefore have no choice but to use their global public addresses as seen by S for their P2P communication, and rely on NAT X to provide loopback translation.3.3.4. Consistent port bindings
The hole punching technique has one main caveat: it works only if both NATs are cone NATs (or non-NAT firewalls), which maintain a consistent port binding between a given (private IP, private UDP) pair and a (public IP, public UDP) pair for as long as that UDP port is in use. Assigning a new public port for each new session, as a symmetric NAT does, makes it impossible for a UDP application to reuse an already-established translation for communication with different external destinations . Since cone NATs are the most widespread, the UDP hole punching technique is fairly broadly applicable; nevertheless a substantial fraction of deployed NATs are symmetric and do not support the technique.
3.4. UDP Port Number PREDICTION
A variant of the UDP hole punching technique discussed above exists that allows peer-to-peer UDP sessions to be created in the presence of some symmetric NATs. This method is sometimes called the "N 1" technique [BIDIR] and is explored in detail by Takeda [SYM-STUN]. The method works by analyzing the behavior of the NAT and attempting to predict the public port numbers it will assign to future sessions. Consider again the situation in which two clients, A and B, each behind a Separate Nat, Have Each Established UDP Connections With a Permanently Addressable Server S: Server S
18.181.0.31:1234
|
|
--------------------------------------------
| | |
Symmetric Nat A Symmetric Nat B
A-S 155.99.25.11:62000 B-S 138.76.29.7:31000
| | |
| | |
Client a Client B
10.0.0.1:1234 10.1.1.3:1234
NAT A has assigned its own UDP port 62000 to the communication session between A and S, and NAT B has assigned its port 31000 to the session between B and S. By communicating through server S, A and B learn each other's public IP addresses and port numbers as observed by S. Client A now starts sending UDP messages to port 31001 at address 138.76.29.7 (note the port number increment), and client B simultaneously starts sending messages to port 62001 at address 155.99.25.11. If NATs A and B assign port numbers to new sessions sequentially, and if not much time has passed since the AS and BS sessions were initiated, then a working bi-directional communication channel between A and B should result. A's messages to B cause NAT A to open up a new session, to which NAT A will (hopefully) assign public port number 62001, because 62001 is next in sequence after the port number 62000 it previously assigned to the session between A and S. Similarly, B's messages to A will cause NAT B To Open A new session, to which it will (hopefully) assign port number 31001. If both clients have correctly guessed the port numbers each NAT assigns to the new sessions, then a bi-directional UDP communication channel will have been established as shown below.Server S
18.181.0.31:1234
|
|
--------------------------------------------
| | |
Nat a nat b
A-S 155.99.25.11:62000 B-S 138.76.29.7:31000
A-B 155.99.25.11:62001 B-A 138.76.29.7:31001
| | |
| | |
Client a Client B10.0.0.1: 1234 10.1.1.3:1234
Obviously there are many things that can cause this trick to fail. If the predicted port number at either NAT already happens to be in use by an unrelated session, then the NAT will skip over that port number and the connection attempt will fail. If either NAT sometimes or always chooses port numbers non-sequentially, then the trick will fail. If a different client behind NAT A (or B respectively) opens up a new outgoing UDP connection to any external destination after A (B) establishes its connection with S but before sending its first message to B (A), then the unrelated client will inadvertently "steal" the desired port number. This trick is therefore much less likely to work when either NAT involved is under load.
Since in practice a P2P application implementing this trick would still need to work if the NATs are cone NATs, or if one is a cone NAT and the other is a symmetric NAT, the application would need to detect beforehand what kind of NAT is involved on either end [STUN] and modify its behavior accordingly, increasing the complexity of the algorithm and the general brittleness of the network. Finally, port number prediction has no chance of working if either client is behind two or more levels of NAT and the NAT ( S) Closest to The Client Are Symmetric. For all of these reasons, it is not recommended That New Applications IMPLEMENT THIS TRICK; IT IS Mentioned Here For Historical and InformationAl Purposes.
3.5. Simultaneous TCP Open
There is a method that can be used in some cases to establish direct peer-to-peer TCP connections between a pair of nodes that are both behind existing middleboxes. Most TCP sessions start with one endpoint sending a SYN packet, to which the other party responds with a SYN-ACK packet. It is possible and legal, however, for two endpoints to start a TCP session by simultaneously sending each other SYN packets, to which each party subsequently responds with a separate ACK. This procedure is known as a " simultaneous open. "If a middlebox receives a TCP SYN packet from outside the private network attempting to initiate an incoming TCP connection, the middlebox will normally reject the connection attempt by either dropping the SYN packet or sending back a TCP RST (connection reset) packet . IF, HOWEVER, THE SYN PACKET ARRIVES WITH Source and Destination Addresses and Port Numbers That Correspond to a TCP Session That The MiddleBox Believes IS Already Active, The Middlebox Will Allow The P acket to pass through. In particular, if the middlebox has just recently seen and transmitted an outgoing SYN packet with the same addresses and port numbers, then it will consider the session active and allow the incoming SYN through. If clients A and B can each correctly predict the public port number that its respective middlebox will assign the next outgoing TCP connection, and if each client initiates an outgoing TCP connection with the other client timed so that each client's outgoing SYN passes through its local middlebox before either SYN reaches the opposite middlebox .
Unfortunately, this trick may be even more fragile and timing- sensitive than the UDP port number prediction trick described above. First, unless both middleboxes are simple firewalls or implement cone NAT behavior on their TCP traffic, all the same things can go wrong with each side's attempt to predict the public port numbers that the respective NATs will assign to the new sessions. In addition, if either client's SYN arrives at the opposite middlebox too quickly, then the remote middlebox may reject the SYN with a RST packet, causing the local middlebox in turn to close the new session and make future SYN retransmission attempts using the same port numbers futile. Finally, even though support for simultaneous open is technically a mandatory part of the TCP specification [TCP], it is not implemented correctly in some common Operating systems. for this reason, this trick is likewise mentions; it is not recomment design That Require Efficient, Direct Peer-to-Peer Communication over Existing Nats Should Ude UDP.4. Application Design Guidelines
4.1. What works with p2p middleboxes
Since UDP hole punching is the most efficient existing method of establishing direct peer-to-peer communication between two nodes that are both behind NATs, and it works with a wide variety of existing NATs, it is recommended that applications use this technique if efficient peer -to-peer communication is required, but be prepared to fall back on Simple Relaying When Direct Communication Cannot Be Establish.
4.2. Peers Behind The Same Nat
In practice there may be a fairly large number of users who have not two IP addresses, but three or more. In these cases, it is hard or impossible to tell which addresses to send to the registration server. The applications should send all its addresses , in Such a case.4.3. Peer Discovery
Applications sending packets to several addresses to discover which one is best to use for a given peer may become a significant source of 'space junk' littering the net, as the peer may have chosen to use routable addresses improperly as an internal LAN (eg 11.0 .1.1, which is assigned to the dod). Thus Applications Should Exercise Cault When Sending The Speculative Hello Packets.
4.4. TCP P2P Applications
The sockets API, used widely by application developers, is designed with client-server applications in mind. In its native form, only a single socket can bind to a TCP or UDP port. An application is not allowed to have multiple sockets binding to the Same Port (TCP Or UDP) To Initiate Simultaneous Sessions with Multiple External Nodes (OR) Use ONE Socket To Listen On The Port and The Other Sockets To Initiate Outgoing Sessions.
The above single-socket-to-port bind restriction is not a problem however with UDP, because UDP is a datagram based protocol. UDP P2P application designers could use a single socket to send as well as receive datagrams from multiple peers using recvfrom () And sendto () Calls.
This is not the case with TCP. With TCP, each incoming and outgoing connection is to be associated with a separate socket. Linux sockets API addresses this problem with the aid of SO_REUSEADDR option. On FreeBSD and NetBSD, this option does not seem to work ; but, changing it to use the BSD-specific setReuseAddress call (which Linux does not have and is not in the Single Unix Standard) seems to work Win32 API offers an equivalent setReuseAddress call Using any of the above mentioned options,.. An Application Could Use Multiple Sockets To Reuse A TCP Port. Say, Open Two Tcp Stream Sockets Bound To The Same Port, Do a listen () on one and a connection () from the Other.4.5. Use of midcomprocol
IF The Applications Know The Middleboxes The Middle Would Be Traversing and these Middle Mobile The Midcom Protocol, Applications Could Use The Midcom Protocol To Ease Their Way THROUGH The MiddleBoxes.
For example, P2P applications require that NAT middleboxes preserve end-point port bindings. If midcom is supported on the middleboxes, P2P applications can exercise control over port binding (or address binding) parameters such as lifetime, maxidletime, and directionality so the applications can both connect to external peers as well as receive connections from external peers; and do not need to send periodic keep-alives to keep the port binding alive When the application no longer needs the binding, the application could simply dismantle the binding, also using. The Midcom Protocol.
5. Nat Design Guidelines
This Section Discusses Considances In The Design of Network Address Translators, as The Affect Peer-to-Peer Applications.
5.1. DepRecate The Use of Symmetric Nats
Symmetric NATs gained popularity with client-server applications such as web browsers, which only need to initiate outgoing connections. However, in the recent times, P2P applications such as Instant messaging and audio conferencing have been in wide use. Symmetric NATs do not support the concept of retaining endpoint identity and are not suitable for P2P applications. Deprecating symmetric NATs is recommended to support P2P applications.A P2P-middlebox must implement Cone NAT behavior for UDP traffic, allowing applications to establish robust P2P connectivity using the UDP hole punching technique. Ideally, a p2p-middlebox surd Also Allow Applications to make P2P Connections Via Both TCP AND UDP.
5.2. Add incremental cone-nat support to symmetric nat devices
One way for a symmetric NAT device to extend support to P2P applications would be to divide its assignable port namespace, reserving a portion of its ports for one-to-one sessions and a different set of ports for one-to-many sessions.
Further, a Nat Device May Be Explicitly Configured with Applications and Hosts That Need The P2P Feature, So The Nat Device Can Auto Magically Assign A P2P Port from The Right Port Block.
5.3. MAINTAIN CONSISIT port Bindings for UDP Ports
The primary and most important recommendation of this document for NAT designers is that the NAT maintain a consistent and stable port binding between a given (internal IP address, internal UDP port) pair and a corresponding (public IP address, public UDP port) pair for as long as any active sessions exist using that port binding. The NAT may filter incoming traffic on a per-session basis, by examining both the source and destination IP addresses and port numbers in each packet. When a node on the private network initiates connection to a new external destination, using the same source IP address and UDP port as an existing translated UDP session, the NAT should ensure that the new UDP session is given the same public IP address and UDP portnumbers as the existing session.
5.3.1. Preserve Port Numbers
Some NATs, when establishing a new UDP session, attempt to assign the same public port number as the corresponding private port number, if that port number happens to be available. For example, if client A at address 10.0.0.1 initiates an outgoing UDP session with a datagram from port number 1234, and the NAT's public port number 1234 happens to be available, then the NAT uses port number 1234 at the NAT's public IP address as the translated endpoint address for the session. This behavior might be beneficial to some legacy UDP applications that expect to communicate only using specific UDP port numbers, but it is not recommended that applications depend on this behavior since it is only possible for a NAT to preserve the port number if at most one node on the internal network is using that port Number.
In addition, a NAT should NOT try to preserve the port number in a new session if doing so would conflict with the goal of maintaining a consistent binding between public and private endpoint addresses. For example, suppose client A at internal port 1234 has established a session with external server S, and NAT A has assigned public port 62000 to this session because port number 1234 on the NAT was not available at the time. Now suppose port number 1234 on the NAT subsequently becomes available, and while the session between A and S is still active, client A initiates a new session from its same internal port (1234) to a different external node B. In this case, because a port binding has already been established between client A's port 1234 and the NAT's public port 62000, THIS BINDING SHOULD ALSO USE Port 62000 As The Public Port 1234. The Nat Should Not Assign Public Port 1234 To This New Session Just Because P ort 1234 has become available: that behavior would not be likely to benefit the application in any way since the application has already been operating with a translated port number, and it would break any attempts the application might make to establish peer-to-peer connections Using the udp hole punching technique.5.4. Maintaining Consistent Port Bindings for TCP Ports
For consistency with the behavior of UDP translation, cone NAT implementers should also maintain a consistent binding between private and public (IP address, TCP port number) pairs for TCP connections, in the same way as described above for UDP. Maintaining TCP endpoint bindings consistently Will Increase The Nat's Compalings That Multiple TCP Connections from The Same Source Port.5.5. Large Timeout for P2P Applications
We recommend the middlebox implementers to use a minimum timeout of, say, 5 minutes (300 seconds) for P2P applications, ie, configure the middlebox with this idle-timeout for the port bindings for the ports set aside for P2P use. Middlebox implementers are often tempted to use a shorter one, as they are accustomed to doing currently. But, short timeouts are problematic. Consider a P2P application that involved 16 peers. They will flood the network with keepalive packets every 10 seconds to avoid NAT timeouts. This is So Because ONE Might Send The NetWork.
5.6. Support loopback translation
We strongly recommend that middlebox implementers support loopback translation, allowing hosts behind a middlebox to communicate with other hosts behind the same middlebox through their public, possibly translated endpoints. Support for loopback translation is particularly important in the case of large-capacity NATs that are likely to be deployed as the first level of a multi-level NAT scenario. As described in section 3.3.3, hosts behind the same first-level NAT but different second-level NATs have no way to communicate with each other by UDP hole punching, Even if all the middleboxes preserve endpoint ideftities, unless the first-level also supports loopback translation.6. Security considances
Following the recommendations in this document should not inherently create new security issues, for either the applications or the middleboxes. Nevertheless, new security risks may be created if the techniques described here are not adhered to with sufficient care. This section describes security risks the applications Could INADVERTENTLY CREATE INTTEMPTING to Support P2P Communication Across Middleboxes, and Implications for the Security Policies of P2P-Friendly Middleboxes.
6.1. IP Address AliaSing
P2P applications must use appropriate authentication mechanisms to protect their P2P connections from accidental confusion with other P2P connections as well as from malicious connection hijacking or denial-of-service attacks. NAT-friendly P2P applications effectively must interact with multiple distinct IP address domains, but are not generally aware of the exact topology or administrative policies defining these address domains. While attempting to establish P2P connections via UDP hole punching, applications send packets that may frequently arrive at an entirely different host than the intended one.
For example, many consumer-level NAT devices provide DHCP services that are configured by default to hand out site-local IP addresses in a particular address range. Say, a particular consumer NAT device, by default, hands out IP addresses starting with 192.168. 1.100. Most private home networks using that NAT device will have a host with that IP address, and many of these networks will probably have a host at address 192.168.1.101 as well. If host A at address 192.168.1.101 on one private network attempts to establish a connection by UDP hole punching with host B at 192.168.1.100 on a different private network, then as part of this process host A will send discovery packets to address 192.168.1.100 on its local network, and host B will send discovery packets to address 192.168.1.101 on its network. Clearly, these discovery packets will not reach the intended machine since the two hosts are on different private networks, but they are very likely to reach SOME machine on these respective Networks at the standard udp port number used by this Application, Potentially Cause Confusion. Especially et......................
This risk due to aliasing is therefore present even without a malicious attacker. If one endpoint, say host A, is actually malicious, then without proper authentication the attacker could cause host B to connect and interact in unintended ways with another host on its private network having the same IP address as the attacker's (purported) private address. Since the two endpoint hosts A and B presumably discovered each other through a public server S, and neither S nor B has any means to verify A's reported private address, all P2P applications Must assume That any ip address the, find to be suspect unsteil, success, time communication.6.2. denial-of-service attic
P2P applications and the public servers that support them must protect themselves against denial-of-service attacks, and ensure that they can not be used by an attacker to mount denial-of-service attacks against other targets. To protect themselves, P2P applications and servers must avoid taking any action requiring significant local processing or storage resources until authenticated two-way communication is established. To avoid being used as a tool for denial-of-service attacks, P2P applications and servers must minimize the amount and rate of traffic they send To any newly-discovered ip address..
For example, P2P applications that register with a public rendezvous server can claim to have any private IP address, or perhaps multiple IP addresses. A well-connected host or group of hosts that can collectively attract a substantial volume of P2P connection attempts (eg, by offering to serve popular content) could mount a denial-of-service attack on a target host C simply by including C's IP address in their own list of IP addresses they register with the rendezvous server. There is no way the rendezvous server can verify the IP addresses, since they could well be legitimate private network addresses useful to other hosts for establishing network-local communication. The P2P application protocol must therefore be designed to size- and rate-limit traffic to unverified IP addresses in order to avoid the potential DAMAGE SUCH A Concentration Effect Could Cause.6.3 .man-in-The-Middle Attacks
Any network device on the path between a P2P client and a rendezvous server can mount a variety of man-in-the-middle attacks by pretending to be a NAT. For example, suppose host A attempts to register with rendezvous server S, but a network-snooping attacker is able to observe this registration request. The attacker could then flood server S with requests that are identical to the client's original request except with a modified source IP address, such as the IP address of the attacker itself. If the attacker can convince the server to register the client using the attacker's IP address, then the attacker can make itself an active component on the path of all future traffic from the server AND other P2P hosts to the original client, even if the attacker was originally only able to snoop the path from the client to the server.The client can not protect itself from this attack by authenticating its source IP address to the rendezvous server, because in order to be NAT-friendly the applica tion MUST allow intervening NATs to change the source address silently. This appears to be an inherent security weakness of the NAT paradigm. The only defense against such an attack is for the client to authenticate and potentially encrypt the actual content of its communication using appropriate higher -level identities, so that the interposed attacker is not able to take advantage of its position. Even if all application-level communication is authenticated and encrypted, however, this attack could still be used as a traffic analysis tool for observing who the client is Communicating with.
6.4. Impact ON MiddleBox Security
Designing middleboxes to preserve endpoint identities does not weaken the security provided by the middlebox. For example, a Port-Restricted Cone NAT is inherently no more "promiscuous" than a Symmetric NAT in its policies for allowing either incoming or outgoing traffic to pass through the middlebox. As long as outgoing UDP sessions are enabled and the middlebox maintains consistent binding between internal and external UDP ports, the middlebox will filter out any incoming UDP packets that do not match the active sessions initiated from within the enclave. Filtering incoming traffic aggressively while MAINTAING CONSISTENT Port Bindings Thus Allows A Middlebox to Be "Peer-to-Peer Friendly" without compromising the principle of rejecting unsolicited incoming traffic.
Maintaining consistent port binding could arguably increase the predictability of traffic emerging from the middlebox, by revealing the relationships between different UDP sessions and hence about the behavior of applications running within the enclave. This predictability could conceivably be useful to an attacker in exploiting other network or application level vulnerabilities. If the security requirements of a particular deployment scenario are so critical that such subtle information channels are of concern, however, then the middlebox almost certainly should not be configured to allow unrestricted outgoing UDP traffic in the first place. Such a middlebox should only allow communication originating from specific applications at specific ports, or via tightly-controlled application-level gateways. In this situation there is no hope of generic, transparent peer-to-peer connectivity across the middlebox (or transparent client / server connectivity for That Matter; The MiddleBox Must Ei THER IMPLEMENT Appropriate Application-Specific Behavior or Disallow Communication Entirely.7. ACKNOWLEDGMENTS
The Authors Wish To Than Youk Henrik, Dave, And Christian Huitema for Their Valuable feedback.
8. References
8.1. NORMATIVE REFERENCES
[Bidir] Peer-to-Peer Working Group, NAT / FireWall Working Committee,
"Bidirectional Peer-to-Peer Communication with interposing
FireWalls and Nats, August 2001.
http://www.peer-to-peerwg.org/tech/nat/
[Kegel] Dan Kegel, "Nat and Peer-To-Peer Networking", July 1999.
http://www.alumni.caltech.edu/~ Dank/peer-nat.html
[MIDCOM] P. Srisuresh, J. Kuthan, J. Rosenberg, A. Molitor, And
A. Rayhan, "Middlebox Communication Architecture and
Framework ", RFC 3303, August 2002. [NAT-APPL] D. Senie," Network Address Translator (NAT) -Friendly
Application Design Guidelines ", RFC 3235, January 2002.
[NAT-PROT] M. Holdrege and P. Srisuresh, "Protocol Complications
With the ip network address translator, RFC 3027,
January 2001.
[NAT-PT] G. Tsirtsis and P. Srisuresh, "Network Address
Translation - Protocol Translation (NAT-PT) ", RFC 2766,
February 2000.
[NAT-TERM] P. Srisuresh and M. HoldRege, "IP Network Address
Translator (NAT) Terminology and considances, RFC
2663, August 1999.
[NAT-TRAD] P. Srisuresh and K. Egevang, "Traditional IP Network
Address Translator (Traditional Nat ", RFC 3022,
January 2001.
[Stun] J. Rosenberg, J. Weinberger, C. Huitema, And R. Mahy,
"Stun - Simple Traversal of User DataGram Protocol (UDP)
Through Network Address Translators (NATS), RFC 3489,
March 2003.
8.2. INFORMATIONAL REFERENCES
[ICE] J. Rosenberg, "Interactive Connectivity Establishment (ICE):
A Methodology for Network Address Translator (NAT) Traversal
For the session initiation protocol (sip),
Draft-Rosenberg-Sipping-Ice-00 (Work in Progress),
February 2003.
[RSIP] M. Borella, J. LO, D. Grabelsky, And G. Montenegro,
"Realm Specific IP: Framework", RFC 3102, October 2001.
[SOCKS] M. Leech, M. Ganis, Y. Lee, R. Kuris, D. Koblas, And
L. Jones, "Socks Protocol Version 5", RFC 1928, March 1996.
[Sym-Stun] Y. Takeda, "Symmetric Nat Traversal Using Stun",
Draft-takeda-symmetric-nat-traversal-00.txt (Work IN
Progress, June 2003.
[TCP] "Transmission Control Protocol", RFC 793, September 1981.
[TEREDO] C. HuItema, "TEREDO: Tunneling IPv6 Over UDP THROUGH NATS", Draft-Ietf-Ngtrans-ShipWorm-08.txt (Work In Progress),
September 2002.
[Turn] J. Rosenberg, J. Weinberger, R. Mahy, And C. Huitema,
"Traversal Using Relay Nat (TURN),
Draft-rosenberg-midcom-turn-01 (Work In Progress),
March 2003.
[UPNP] UPNP Forum, "Internet Gateway Device (IGD) Standardized
Device Control Protocol v 1.0, November 2001.
http://www.upnp.org/standardizedddcps/igd.asp
9. Author's address
Bryan ford
Laboratory for Computer Science
Massachusetts Institute of Technology Of TECHNOLOGY
77 Massachusetts AVE.
Cambridge, MA 02139
PHONE: (617) 253-5261
E-mail: baford@mit.edu
Web: http://www.brynosaurus.com/
Pyda Srisuresh
Caymas Systems, Inc.
11799-a North McDowell BLVD.
Petaluma, CA 94954
Phone: (707) 283-5063
E-mail: srisuresh@yahoo.com
Dan Kegel
Kegel.com
901 S. Sycamore AVE.
Los Angeles, CA 90036
Phone: 323 931-6717
Email: dank@kegel.com
Web: http://www.kegel.com/
Full Copyright Statement
Copyright (c) The Internet Society (2003). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind , provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations , except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.The limited permissions granted above are perpetual and will not BE REVOKED by the Internet society or its successs.
This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY Rights or Any Implied Warranties of Merchantability Or Fitness for a particular purpose.