UDP Hole Punching Simplified – How does bit-torrent work

Altcoins, Cryptocurrency, XRP
A simple and easy-to-understand demo of UDP hole-punching.

This technique is used my most P2P programs like Bit-Torrent and Skype. Hole punching allows these programs to establish a direct communication channel between two computers, which might be behind a NAT router, that doesn’t allow incoming connections.

In this video, we use simple tools like Netcat and hping to get a working UDP hole. Initially, we have netcat listening on out local computer, behind a NAT router.
— We attempt to send packets UDP from a remote computer, to the local one, which fails, as these packets get dropped by the router, as it has no idea, which computer is the exact recipient of these packets.

— Then we send ping UDP packets, from the local computer, to the remote computer. Irrespective of weather these packets reached the remote computer, our router will add an entry in its NAT table for the remote IP address and port and the intended computer in it’s local network.

— Now when we re-attempt to send packets from the remote to the local computer, the router correctly sends the packets to the right host where we have the netcat listening for incoming UDP packets.

— We also demo an exceptional case, when another computer in the same LAN has an active connection for the Host and Port, known as port-collision. And show how to handle it.

— It’s worth noting that all this cannot happen without coordination from a public server, that both hosts have previously established connections to. These are the Bit-torrent Trackers or Skype Servers, that co-ordinate P2P connection establishment.

If you wish to use UDP hole-punching in your program, take a look at Lib-uTP (Mu-T-P), developed by u-torrent guys. It does all the ground work and gives a TCP socket programming like interface, which is much easier to use.

Ledger Wallets
Safe and Secure

Leave a Reply