Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP/TCP hole punching vs UPnP vs STUN vs?

I try to make a P2P Program and need help with getting through the NAT of the clients. I have read many questions here on stackoverflow, but i never got what the drawbacks and benefits of all the Methods to get through a NAT are. How many routers support which methods? Which methods are commonly used by the big companies? (BitTorrent, TeamViewer,...) What are the drawbacks/benefits of the three methods i listed and which else exists?

like image 812
user2422196 Avatar asked Jan 05 '14 21:01

user2422196


1 Answers

UPnP requires software support in your router. Even when routers have it, it's sometimes turned off due to security concerns.

STUN uses a simple public server to detect the presence of NAT and the real IP addresses. This is useful for other, higher-level protocols that do the useful work.

Hole punching is a simple technique to connect two computers. It requires a 3rd public computer to communicate between the 2 computers behind NAT. You could run your own server with a custom protocol, our you could use STUN and existing STUN servers. (Only a few packets are needed for setup, the rest are peer-to-peer).

Of course, some NAT firewalls are incompatible with the above, so you may need a custom protocol. Bittorrent does this: they use different techniques depending on which clients are behind firewalls and whatnot.

like image 120
BraveNewCurrency Avatar answered Sep 17 '22 15:09

BraveNewCurrency