p2pnatbittorrentstundht

How NAT traversal works in case of peer to peer protocols like bittorrent.


I know about NAT traversal and about STUN, TURN and ICE and its use. I want to know whether these are implemented in peer to peer file sharing application like bittorrent. Whether trackers facilitate peers behind NATs to communicate with each other by helping in creating direct connection using STUN or relay through TURN. In the case of Distributed Hash Table(DHT) how one peer would communicate with other peer behind NAT ?


Solution

  • BitTorrent does not need to connect to any particular member in a swarm, it's not a p2p chat protocol where two specific end points want to talk to each other. All it cares about is that the connection graph of the swarm has a sufficiently high connectivity degree.

    In other words, getting clients behind a NATs to talk to each other is somewhat desirable, but not to the point where major resources, such as traffic forwarding, would be expended on that goal. On the individual node level failure is an option. Thus it does not use sip/turn/etc.

    Of course on the aggregate swarm level performance will still degrade with an increasing fraction of non-reachable nodes. If nobody can accept incoming connections then BitTorrent doesn't work.

    Various clients use some combination of the following approaches to improve connectivity for the bulk transport connections:

    In the case of the DHT only the first two points (gateway negotiation and port reuse) are used. The overhead of attempting nat traversal for a single request-reply cycle would be >100% and is not worth it.