Understanding Peer to Peer networks

21 Feb, 2024
What make a network P2P and what are the advantages and difficulties to create a P2P network.

Let’s first compare a client-server network to a peer-to-peer network.

A Client-Server communications has two parts,

Server which has a known location (Static IP) and is assumed to always be available.\ Client which is an edge on the network that uses a server as a mediator.

Peer-to-Peer communication on the other hand has entirely different properties.

A Peer(node) in the connection doesn’t necessarily need to have a static location like a static IP. And all the Peers in the network run the same program(similar programs) to interact with each other.

These two communications can also be visualized as a Star Topology vs a Mesh Topology. Let’s discuss why would one be better than the other or vice-versa? So much of the internet runs on client/server architecture but there are many cases where it is not feasible to run a system in a client/server architecture.

An example could be a file sharing system, Let’s say a file needs to be shared to multiple different computers. And the file is massive. At small number of connections it could work well but as the connections increatse and the file needs to be shared to more and more systems it will eventually create a bottleneck due to limited badwidth, And to solve this p2p protocols like torrent can be used.

Another use case could be games which allow creation of lobbies with 100’s of players. Servering 100s of players with equally high number of concurrent lobbies could end up giving very bad latenct and response times for the player. If we were to be able to somehow create networks where each player’s computer could connect to another player’s computer directly without a central server it would be a lot better.

A Peer to Peer network is decentralized, with little to no connection to a central server(specific protocols may use a relay server to establish initial connection between the nodes). But it has its issues:

Connectivity - The nodes may have changing IP, and on top of that a network inside a NAT is not accessible from the outside.\ Instability - Nodes don’t always have to be online, so they are not reliable and periodic status checks need to be done.\ Discovery & Searching - How do we find desired information about the nodes in the first place?