UDP Hole Punching
   HOME

TheInfoList



OR:

UDP hole punching is a commonly used technique employed in
network address translation Network address translation (NAT) is a method of mapping an IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic Router (computing), routing device. The te ...
(NAT) applications for maintaining
User Datagram Protocol In computer networking, the User Datagram Protocol (UDP) is one of the core communication protocols of the Internet protocol suite used to send messages (transported as datagrams in Network packet, packets) to other hosts on an Internet Protoco ...
(UDP) packet streams that traverse the NAT.
NAT traversal Network address translation traversal is a computer networking technique of establishing and maintaining Internet Protocol connections across Gateway (telecommunications), gateways that implement network address translation (NAT). NAT traversal te ...
techniques are typically required for client-to-client networking applications on the
Internet The Internet (or internet) is the Global network, global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a internetworking, network of networks ...
involving hosts connected in
private network In Internet networking, a private network is a computer network that uses a private address space of IP addresses. These addresses are commonly used for local area networks (LANs) in residential, office, and enterprise environments. Both the IPv ...
s, especially in
peer-to-peer Peer-to-peer (P2P) computing or networking is a distributed application architecture that partitions tasks or workloads between peers. Peers are equally privileged, equipotent participants in the network, forming a peer-to-peer network of Node ...
,
Direct Client-to-Client Direct Client-to-Client (DCC) (originally Direct Client Connection) is an IRC-related sub-protocol enabling peers to interconnect using an IRC server for handshaking in order to exchange files or perform non-relayed chats. Once established, a t ...
(DCC) and
Voice over Internet Protocol Voice over Internet Protocol (VoIP), also known as IP telephony, is a set of technologies used primarily for voice communication sessions over Internet Protocol (IP) networks, such as the Internet. VoIP enables Voice call, voice calls to be tran ...
(VoIP) deployments. UDP hole punching establishes connectivity between two hosts communicating across one or more network address translators. Typically, third-party hosts on the public transit network are used to establish UDP port states that may be used for direct communications between the communicating hosts. Once port state has been successfully established and the hosts are communicating, port state may be maintained either by normal communications traffic, or in the prolonged absence thereof, by keep-alive packets, usually consisting of empty UDP packets or packets with minimal, non-intrusive content.


Overview

UDP hole punching is a method for establishing bidirectional UDP connections between
Internet The Internet (or internet) is the Global network, global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a internetworking, network of networks ...
hosts in private networks using network address translators. The technique is not applicable in all scenarios or with all types of NATs, as NAT operating characteristics are not standardized. Hosts with network connectivity inside a private network connected via a NAT to the Internet typically use the Session Traversal Utilities for NAT (STUN) method or Interactive Connectivity Establishment (ICE) to determine the public address of the NAT that its communications peers require. In this process another host on the public network is used to establish port mapping and other UDP port state that is assumed to be valid for direct communication between the application hosts. Since UDP state usually expires after short periods of time in the range of tens of seconds to a few minutes, and the UDP port is closed in the process, UDP hole punching employs the transmission of periodic ''keep-alive'' packets, each renewing the life-time counters in the UDP state machine of the NAT. UDP hole punching will not work with
symmetric NAT Network address translation (NAT) is a method of mapping an IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic routing device. The technique was initial ...
devices (also known as bi-directional NAT) which tend to be found in large corporate networks. In symmetric NAT, the NAT's mapping associated with the connection to the known STUN server is restricted to receiving data from the known server, and therefore the NAT mapping the known server sees is not useful information to the endpoint. In a somewhat more elaborate approach both hosts will start sending to each other, using multiple attempts. On a Restricted Cone NAT, the first packet from the other host will be blocked. After that the NAT device has a record of having sent a packet to the other machine, and will let any packets coming from this IP address and port number through. This technique is widely used in
peer-to-peer Peer-to-peer (P2P) computing or networking is a distributed application architecture that partitions tasks or workloads between peers. Peers are equally privileged, equipotent participants in the network, forming a peer-to-peer network of Node ...
software and
Voice over Internet Protocol Voice over Internet Protocol (VoIP), also known as IP telephony, is a set of technologies used primarily for voice communication sessions over Internet Protocol (IP) networks, such as the Internet. VoIP enables Voice call, voice calls to be tran ...
telephony. It can also be used to assist the establishment of
virtual private network Virtual private network (VPN) is a network architecture for virtually extending a private network (i.e. any computer network which is not the public Internet) across one or multiple other networks which are either untrusted (as they are not con ...
s operating over UDP. The same technique is sometimes extended to
Transmission Control Protocol The Transmission Control Protocol (TCP) is one of the main communications protocol, protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, th ...
(TCP) connections, though with less success because TCP connection streams are controlled by the host OS, not the application, and sequence numbers are selected randomly; thus any NAT device that performs sequence-number checking will not consider the packets to be associated with an existing connection and drop them.


Flow

Let A and B be the two hosts with internal IP addresses iAddrA and iAddrB respectively, each in its own private network; NA and NB are the two NAT devices with external IP addresses eAddrA and eAddrB respectively; S is a public server with a known IP address. # A and B each begin a UDP conversation with S; the NAT devices NA and NB create UDP translation states and assign temporary external port numbers ePortA and ePortB. # S examines the UDP packets to get the source port used by NA and NB (the external NAT ports ePortA and ePortB). # S informs B about the values of eAddrA:ePortA and informs A about the values of eAddrB:ePortB. # A sends a packet to eAddrB:ePortB and B sends a packet to eAddrA:ePortA (not necessarily at the same time nor in any particular order). #* When those packets leave their private network, each NAT device adds an entry to its translation table: #** NA examines A's packet and finds an entry already exists (iAddrA, iPortA, eAddrA, ePortA) but the destination is different (S) . NA will create a new entry with the same translation for traffic sourced from A ( iAddrA) to B (eAddrB). #** NB examines B's packet and finds an entry already exists (iAddrB, iPortB, eAddrB, ePortB) but the destination is different (S). NB will create a new entry with the same translation for traffic sourced from B (iAddrB) to A (eAddrA). #* Depending on the state of each NAT's translation table upon arrival of the remote's packet: #** If the new entry was already added to NA's translation table before the arrival of B's packet, then NA passes B's packet, but otherwise drops it. #** If the new entry was already added to NB's translation table before the arrival of A's packet, then NB passes A's packet, but otherwise drops it. # Once both NAT's have those tuples added, then "holes" have been "punched" in the NATs, allowing both hosts to directly communicate. * If both hosts have Restricted cone NATs or
Symmetric NAT Network address translation (NAT) is a method of mapping an IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic routing device. The technique was initial ...
s, the external NAT ports will differ from those used with S. On some routers, the external ports are picked sequentially, making it possible to establish a conversation through guessing nearby ports.


See also

* Hamachi *
Hyphanet Hyphanet (until mid-2023: Freenet) is a peer-to-peer platform for censorship-resistant, anonymous communication. It uses a decentralized distributed data store to keep and deliver information, and has a suite of free software for publishing and ...
* ICMP hole punching *
TCP hole punching TCP NAT traversal and TCP hole punching (sometimes NAT punch-through) in computer networking occurs when two hosts behind a network address translation (NAT) are trying to connect to each other with outbound TCP connections. Such a scenario is pa ...
*
Hole punching (networking) Hole punching (or sometimes punch-through) is a technique in computer networking for establishing a direct connection between two parties in which one or both are behind firewalls or behind routers that use network address translation (NAT). To ...
*
WebRTC WebRTC (Web Real-Time Communication) is a free and open-source project providing web browsers and mobile applications with real-time communication (RTC) via application programming interfaces (APIs). It allows audio and video communication and ...
* Port Control Protocol (PCP) *
Teredo tunneling In computer networking, Teredo is a Microsoft transition technology that gives full IPv6 connectivity for IPv6-capable hosts that are on the IPv4 Internet but have no native connection to an IPv6 network. Unlike similar protocols such as 6to4, ...


References


External links


Peer-to-Peer Communication Across Network Address TranslatorsPDF
contains a detailed explanation of the hole punching process
STUNT
Simple Traversal of UDP Through NATs and TCP too
Network Address Translation and Peer-to-Peer Applications (NATP2P)
{{DEFAULTSORT:Udp Hole Punching Computer network security