PiecewiseHow a peer to peer transfer actually works

What peer to peer means, and what still runs on it

Peer to peer

Diagram, client and server, and the other shape: One machine answering everybody, against everybody answering each other. Everything else follows from that.

A peer to peer network is a network in which every machine is both a client and a server: each one asks other machines for data and answers their requests in turn, and none of them depends on a single computer in the middle to do it. The word peer carries the whole definition. A peer is a participant with the same rights and the same job as every other participant, so a laptop that has just finished downloading a file becomes, from that moment, one of the places the file can be downloaded from. BitTorrent is the peer to peer system most people meet, but the shape is older than BitTorrent and it did not stop with it.

What makes a network peer to peer and not merely spread out

A network is peer to peer because of the absence of a privileged role, not because of the number of machines in it. A content delivery network has thousands of servers in dozens of countries and is not peer to peer at all: the servers serve, the browsers ask, and no browser answers another browser's request. In a peer to peer network the same program on the same machine does both jobs at once, and that one property produces everything else that is strange about the shape.

Three problems have to be solved before peers can behave that way: finding each other without a fixed list of addresses, saying what they hold without a catalog on an operator's server, and checking what arrives now that the bytes come from strangers rather than from an authority. BitTorrent answers those three with trackers and a distributed hash table, with an info hash naming one fixed set of files, and with a separate hash for every piece, so a bad piece is discarded rather than written. Other systems answer them differently, and those differences separate the families described below. The Glossary defines each term on its own.

Client and server draws a star, peer to peer draws a mesh

Drawn as a diagram, a client and server network is a star: one point in the middle, a line out to every user, no line between any two users. A peer to peer network drawn the same way is a mesh: a scatter of points with lines running directly between them, and no point all the lines pass through. Almost every practical difference between the two architectures falls out of those pictures.

PropertyClient and serverPeer to peer
Where the file sitsOn one operator's machinesOn every machine that currently holds a copy
What one more user costsMore load, paid by the operatorMore load and more capacity at once
Effect of the middle disappearingNothing works for anybodyConnected peers keep going; new peers struggle to find the others
Who you connect toAn organization you can nameOther users, whose addresses your program sees
Who decides what stays availableThe operatorWhoever still holds a copy and is still switched on
What the shape is good atAccounts, permissions, consistency, editingMoving identical bytes to many people at once
What the shape is bad atSudden popularity, and censorship resistanceAnything rare, private, or changing minute by minute

Why load and failure run in opposite directions

Load and failure are where the star and the mesh behave as mirror images. In a client and server network every extra user is a cost, popularity arrives as a bill, and the classic failure is a release day where demand outruns what the operator provisioned. In a peer to peer network popularity is capacity, because a thousand people who want the same file are also a thousand machines able to hand out pieces of it. That is why Linux and BSD distributions publish their images by torrent on release day, and why the Internet Archive offers a torrent beside the ordinary download.

Unpopularity inverts just as sharply. On a server an obscure file is served as quickly as a famous one, because the server does not care. In a swarm a file nobody is holding is not slow, it is gone. The center of a star is one point of failure and one point of control, while a mesh has neither a single point of failure nor any guarantee at all.

The four families of peer to peer network

Peer to peer networks fall into four families, separated by how a peer finds what it wants rather than by how the bytes travel afterward.

Centrally indexed networks
A central server holds the index of who has what, and the transfer runs directly between the two users. Napster, from 1999, is the plain example, and the arrangement is why shutting one company's servers ended the network in a single action.
Unstructured networks
No index exists anywhere. A query passes from peer to peer, hop by hop, and answers return along the path they arrived by. Gnutella, from 2000, is the plain example. Joining is cheap, searching is expensive, and a search that finds nothing looks identical to one that did not travel far enough.
Supernode networks
Ordinary peers attach to better connected peers, which hold the index for their own neighborhood. FastTrack, used by Kazaa from 2001, worked this way, and the eDonkey network's servers played a comparable part. The design is a compromise: cheaper to search than flooding, and not dependent on one operator.
Structured networks
Peers arrange themselves by identifier so that any key can be located deliberately rather than by broadcasting. Kademlia, described in a 2002 paper, is the design in general use, and both BitTorrent's distributed hash table and the content routing inside IPFS run on it. The hops needed to reach a key grow slowly as the network grows, the property flooding lacks.

What still runs on this shape

Peer to peer still runs a great deal, and the choice is made most often where identical bytes must reach many machines at once.

  • BitTorrent moves large public files, including the installation images Linux and BSD projects publish and the torrents the Internet Archive offers for items in its collections.
  • Syncthing keeps a folder identical across devices one person owns, with no account, no company server holding the data, and no index of any kind.
  • IPFS addresses a file by a hash of its contents rather than by a location, then fetches the blocks from whichever peers hold them.
  • WebTorrent puts the same kind of transfer inside a browser tab, using the connection type browsers are allowed to open, so a page can be a peer while it stays open.
  • Blockchain networks gossip transactions and blocks between nodes: the ledger is the application, and the network carrying it is an unstructured mesh.
  • Operating system update delivery uses the shape quietly, and Windows Delivery Optimization can take parts of an update from other machines on the same local network rather than fetching every copy from the vendor.

The advantages, and the costs attached to each of them

The advantages of peer to peer and its disadvantages are usually one property seen from two sides, which is why either list alone misleads.

  • Capacity grows with demand, and it shrinks with disinterest: when the last peer holding a complete copy switches off, the file stops existing on that network.
  • No operator can withdraw the file, and none is responsible for it either, so there is nobody to ask when something is missing or mislabeled.
  • Verification is done by hash, so bytes from a stranger are safe to assemble, but a hash proves only that the data matches the description, never that the description was honest.
  • Connections are direct, which is fast, and your address is therefore visible to every other participant, because a peer cannot send you anything without knowing where to send it.
  • Every peer serves, and the cost is upload bandwidth, the scarcer direction on most home connections and a metered one on most mobile plans.
  • No middle box is required, though home routers and carrier grade network address translation assume there is one. A client receiving no incoming connections is called firewalled, which means exactly that and not that it is disconnected.

Where the shape shows up in your own client window

Your client window is a readout of the mesh. The seeds figure counts peers holding every piece and the peers figure counts the rest, and both move constantly because the network is other people's computers rather than a service with an uptime target. A transfer that is moving takes pieces from several peers at once, in whatever order they arrive. A transfer marked complete is seeding, which means giving only. A transfer marked stalled or waiting is connected and receiving nothing right now, which is not an error and usually means the pieces you still need are not being offered.

Transmission and the other desktop clients show that same state under different labels, so the vocabulary is worth learning once rather than per program, and the Glossary sets out each term with the conditions that produce it.

Where to go next