If firewalls don't accept incoming connections by default how do p2p networks work?

KI4JGT picture KI4JGT · Feb 17, 2013 · Viewed 11.1k times · Source

If firewalls block all incoming connections by default how do p2p technologies work? Like torrents, how do you connect to everyone who shares a file and get the information from them? Does it go through a relay server or something?

Answer

selbie picture selbie · Feb 18, 2013

I'm not up on everything about BitTorrent, as I am about general P2P connectivity techniques. Typically clients in a P2P network rendezvous on a common signaling server (e.g. SIP, XMPP, tracking server, web site) to exchange IP addresses,other meta data, and messages to bootstrap direct connections. Then use any of the following techniques below to get a communications session going:

  • Both sides attempt to connect to each other simultaneously - in case one side can't accept incoming connections, but is allowed to make outbound connections. Such is the case for the firewall scenario.

  • Hole punching (used in conjunction with above). Relays are not required per se, but do help insure connectivity when both peers are behind network devices that are difficult to traverse. There's both UDP Hole Punching as well as TCP Hole Punching techniques. More info here.

  • Relays, including TURN servers, can be deployed into a P2P network when direct connectivity is not possible. All your favorite video call applications deploy relays for these scenarios, but do their best to get peers directly connected to avoid the cost of relaying.

Bing for the following topics: STUN, TURN, ICE (Interactive Connectivity Establishment), libjingle, pjnath, libnice.