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 ?
Each client get its public IP and temporary port number (UDP) using STUN server. STUN server helps client to detect presence of NAT and detecting public ip + temporary port number (assigned by NAT). Then client tries to establish a direct connection to other peer using punching hole technique (see wikipedia).
Network Address Translation (NAT) causes well-known difficulties for peer-to-peer (P2P) communication, since the peers involved may not be reachable at any globally valid IP address.
Data transport in BitTorrent Typically, BitTorrent uses TCP as its transport protocol for exchanging pieces, and it uses HTTP for tracker comms. The well known TCP port for BitTorrent traffic is 6881-6889 (and 6969 for the tracker port).
A BitTorrent client enables a user to exchange data as a peer in one or more swarms. Because BitTorrent is a peer-to-peer communications protocol that does not need a server, the BitTorrent definition of client differs from the conventional meaning expressed in the client–server model.
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. Failure is an option.
Thus it does not use sip/turn/etc.
Various clients use some combination of the following approaches to improve connectivity for the bulk transport connections:
ut_holepunch extension
that uses mutually reachable swarm members in place of stun servers.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With