📖
[Deprecated] Launchpad Curriculum
  • README
  • About Launchpad
  • Launchpad Learning Resources
    • The Protocol Labs Network
      • What is the PL Network?
      • Teams in the PL Network
      • Protocol Labs Culture
      • Where We are Headed
      • Open Source Stewardship
      • Open Source Contribution
    • IPFS
      • IPFS Setup (Tutorial)
      • Mutable Content
      • IPFS Public DHT
      • Who Uses IPFS
      • How IPFS Works
      • Data Transfer
      • IPFS Subsystems & Architecture
      • The IPFS Gateways
      • The IPFS API (Tutorial)
      • IPFS Resources
    • IPLD
      • Content Addressing & CIDs
      • Graphs: Merkle DAGs
      • The IPLD Data Model
      • IPLD & IPFS
      • Codecs
      • IPLD Schemas
      • Paths & Selectors
      • Distributed Data Structures
      • The CAR Format
      • IPLD Resources
    • libp2p
      • Core Concepts
      • libp2p Connections and Users
      • Decentralized Messaging
      • Gossipsub
      • Distributed Networking Solutions
      • Nat Traversal and Hole Punching
      • libp2p Resources
    • Filecoin
      • How Filecoin Works
      • Filecoin Cryptoeconomics
      • The Filecoin Protocol
      • Drand
      • Progress & Future Work
      • Filecoin Resources
  • Other Resources
    • Pre-Requisites
      • Web3 & Protocol Labs
      • Building Web3
      • Web3 Tools
    • Protocol Labs Toolkits & SDKs
      • Textile
      • Ceramic
      • Fleek
      • Web3.Storage
      • Piñata
    • Built On IPFS and Filecoin
    • Additional Learning
Powered by GitBook
On this page
  • NAT Traversal & Hole Punching
  • Issues & Project Tracking
Edit on GitHub
  1. Launchpad Learning Resources
  2. libp2p

Nat Traversal and Hole Punching

Combining Protocols for NAT Traversal

PreviousDistributed Networking SolutionsNextlibp2p Resources

Last updated 2 years ago

NAT Traversal & Hole Punching

is a problem that arises when you are working with p2p connections and you encounter issues with dialing non-public computers.

NAT Traversal

allows those using different Internet Protocols (such as IPFS and HTTP) to communicate through gateways. A necessary component of this is Network Address Translation. Because the people who originally designed IP addresses (a location address on the internet) didn't make it possible to make enough public IP addresses as there are machines to locate, there are a limited number of public IP addresses, and not every machine connected to the internet can have their own.

In order to address this problem, routers and gateways use to connect each machine's private IP address to one that is publicly addressable on the internet. Machines on a shared home or private network will have private IP addresses used within that network as their address. However, when a machine wants to connect with devices on the public internet, that router or gateway will add the public IP address to any packets of information they send out to communicate with the internet at large.

Hole Punching

Hole Punching is the process of establishing direct connections between two libp2p nodes if one or both are behind firewalls and/or NATs (Network Address Translations).

This includes two types of hosts: publicly reachable and non-publicly reachable hosts. Addresses of the former type can be directly dialed on the public internet. Addresses of the latter type can only be dialed through a relay protocol, or through some means of hole punching. The document refers to publicly reachable hosts as public and non-publicly reachable hosts as private.

See the entirety of the

Project Flare

See

Given the pervasiveness of IPv4 peers that are behind NATs on the internet, NAT traversal is an essential requirement for a peer to peer application. The inability to traverse NATs means that such NATT’d peers are NOT reachable on the network and are thus unable to provide any meaningful service to the network. Nor can they interact with network participants under protocol patterns that require inbound connections (e.g. dialbacks).

libp2p currently executes NAT traversal using wherein publicly dialable Relay servers relay the entirety of user traffic to peers that are NATT’d. This approach does NOT scale because:

  1. It costs bandwidth on the Relay server.

  2. There is NO real incentive to be a Relay server.

  3. Introduces communication latency between the two peers that are interfacing via the Relay server.

Issues & Project Tracking

A more scalable approach to NAT traversal is to enable direct communication between the peers via a technique called . Hole punching removes the need to relay all traffic between two peers via a Relay server.

Hole Punching
Read more in the blog
NAT Traversal
Network Address Translation (NAT)
hole punching documentation
the full proposal here
Circuit Relays
Hole Punching
NAT traversal tracking issue