Skip to content
woza.ink
← Notebook
10 min readWritten with AI

Part 5 of 6 in Open protocols

BitTorrent: The Protocol That Refuses to Die

How BitTorrent actually works — peers, pieces, choking, DHT, magnet links — and why a 25-year-old protocol is still the best way to move large files across the internet.

On this page
  1. The core idea
  2. The vocabulary
  3. The protocol under the hood
  4. Piece selection: rarest first
  5. Choking and tit-for-tat
  6. The handshake and wire protocol
  7. The evolution
  8. Phase 1: .torrent files and trackers (2001-2005)
  9. Phase 2: DHT and trackerless torrents (2005-2008)
  10. Phase 3: Magnet links (2008-2012)
  11. Phase 4: BEP extensions and modern clients (2012-present)
  12. Where torrents live today
  13. Why it still matters
  14. Further reading

Every few years someone declares BitTorrent dead. Streaming killed it. Cloud storage killed it. The lawsuits killed it. And yet: 170 million monthly active users1. Every major Linux distribution ships official torrent files. Blizzard used peer-to-peer distribution for World of Warcraft patches. The protocol Bram Cohen sketched out in 2001 is still, in 2026, the most efficient way to move a large file from one place to many.

This is how it works. Not the hand-wavy version — the actual architecture.


The core idea

HTTP puts all upload cost on the server. One machine, serving one file, to thousands of clients. The more popular the file, the more bandwidth the server bleeds. BitTorrent inverts this: the more people downloading, the faster it gets.

The trick is simple. A file gets split into pieces — typically 256KB to 4MB each. Every downloader who has a piece can upload it to others. You don't wait for the whole file before you start helping. The moment you have a single piece, you're part of the supply chain.

This is peer-to-peer in the purest sense. No central server holds the file. The swarm is the server.

Over HTTP one server uploads every copy of a file. In a BitTorrent swarm every peer uploads the pieces it has, so more downloaders add capacity instead of load HTTP One server uploads every copy Server BitTorrent Every peer uploads what it has More downloaders slow a server down, and speed a swarm up.
A server uploads every copy itself. In a swarm every peer uploads what it has, so more downloaders add capacity instead of load.

The vocabulary

Peers are everyone participating in a transfer. Seeders have the complete file and only upload. Leechers are still downloading — they have some pieces but not all. A swarm is the full set of peers sharing a particular torrent.

Trackers are coordination servers. They don't host files. They just maintain a list of which peers are in a given swarm. Your client contacts the tracker, gets a list of peers, and connects to them directly. The tracker never sees the file content.

DHT (Distributed Hash Table) removes even the tracker. Peers themselves form a distributed lookup network — based on Kademlia — where you can find other peers for a given infohash without any central server. This is what makes "trackerless" torrents work.

Magnet links are the logical endpoint of this evolution. A magnet link is just a URI containing the infohash — the SHA1 hash of the torrent's metadata. Your client takes that hash, queries the DHT, finds peers, downloads the metadata from them, and starts the transfer. No .torrent file needed. No tracker needed. Just a 40-character hash.


The protocol under the hood

BitTorrent's genius isn't just "split file, share pieces." It's the incentive design. Bram Cohen's 2003 paper, "Incentives Build Robustness in BitTorrent," laid out the game theory that makes the whole thing work.2

Piece selection: rarest first

When your client needs to decide which piece to download next, it picks the rarest one — the piece fewest peers in the swarm currently have. This is counterintuitive. You might think downloading common pieces first would be safer. But rarest-first ensures that rare pieces get replicated quickly, preventing bottlenecks where everyone has the same 90% and nobody has the last 10%.

Bars show how many peers in the swarm hold each of ten pieces. Your client already has some of them, and fetches the rarest piece it is still missing next Copies of each piece in the swarm Your client fetches the rarest piece it doesn't have yet 6 1 4 2 7 3 3 4 5 5 2 6 1 7 4 8 6 9 2 10 Piece number you have it you need it fetch this one next Rare pieces spread first, so the last 10% doesn't go missing.
Ten pieces and how many peers hold each. The client skips what it already has and goes for the rarest of the rest.

A 2006 INRIA paper confirmed this: rarest first and the choke algorithm alone are sufficient to achieve near-optimal piece diversity and download performance3. The simplicity is the point.

One exception: when you first join a swarm with zero pieces, rarest-first is too slow (rare pieces have few sources). So new peers use random first piece selection to get their first few pieces quickly. Once you have something to trade, you switch to rarest-first.

Choking and tit-for-tat

Here's the game theory. BitTorrent uses a tit-for-tat reciprocity model. Each peer maintains a set of connections and decides who to upload to based on who uploads to them.

The mechanism is called choking. At any given time, your client "chokes" most peers — meaning it refuses to upload to them. It "unchokes" a small number (typically 4) based on who's giving you the best download rates. Every 10 seconds, it recalculates.

This creates a natural incentive: if you want fast downloads, you need to upload. Free-riders who only leech get choked by everyone and end up with terrible speeds. It's the prisoner's dilemma, solved through repeated interaction.

There's also optimistic unchoking: every 30 seconds, your client randomly unchokes one peer regardless of their contribution. This serves two purposes — it gives new peers a chance to bootstrap (they have nothing to trade yet), and it lets you discover faster peers you haven't tried.

Every 10s: unchoke top 4 peers by upload-to-me rate
Every 30s: optimistically unchoke 1 random peer
Everyone else: choked (no upload from you)

The handshake and wire protocol

Two BitTorrent peers connect over TCP. The handshake includes the protocol identifier, the infohash (so both sides confirm they're talking about the same torrent), and each peer's 20-byte ID.

The 68-byte handshake drawn to scale: one length byte, 19 bytes of protocol name, 8 reserved bytes, the 20-byte infohash and the 20-byte peer ID The handshake, byte by byte 68 bytes, drawn to scale Length 1 byte The number 19 Protocol name 19 bytes BitTorrent protocol Reserved 8 bytes Extension flags Infohash 20 bytes Which torrent Peer ID 20 bytes Who's talking
The handshake is the same 68-byte greeting from each side.

After the handshake, communication happens through a simple message protocol:

  • bitfield — "here are the pieces I have"
  • have — "I just got piece #N"
  • interested / not interested — "I want something you have" / "I don't"
  • choke / unchoke — "I'm not uploading to you" / "I will now"
  • request — "send me block X of piece Y"
  • piece — the actual data

It's remarkably minimal. The entire wire protocol fits in a few pages of spec.

Your client asks a tracker or the DHT who is in the swarm. A seeder sends it pieces and a leecher trades with it. A newcomer gets an optimistic unchoke, and a free-rider stays choked Tracker Lists the swarm's peers DHT Same lookup, no server Seeder Every piece Leecher Trades pieces Free-rider Never uploads Newcomer No pieces yet You Your client Solid: pieces flow. Dashed: choked, so no upload from you.
Your client finds peers through a tracker or the DHT, then decides who to upload to. A sketch: the four peers stand for the kinds it will meet.

The evolution

Phase 1: .torrent files and trackers (2001-2005)

The original model. You'd find a .torrent file on a website, open it in your client, and your client would contact the tracker listed in the file to find peers. The tracker was a single point of failure — take it down, and the swarm can't find new peers.

This era gave birth to the iconic torrent sites. It also gave copyright holders a clear target: the trackers.

Phase 2: DHT and trackerless torrents (2005-2008)

The Mainline DHT arrived in 2005, and BEP 5 wrote it down in 2008. Based on the Kademlia distributed hash table, it let peers find each other without a centralized tracker. Millions of BitTorrent clients now form one of the largest DHTs ever deployed — measurements showed 16 to 28 million concurrent nodes by 20134.

The tracker became optional. Even if every tracker went down, existing swarms could survive through DHT.

BEP 9 enabled peers to exchange torrent metadata over the wire protocol itself. Combined with DHT, this meant you could start a download from nothing but a 40-character hash encoded in a magnet URI. No .torrent file, no tracker, no website hosting metadata. Just a link.

A magnet link holds only the infohash. Your client asks the DHT which peers are in the swarm, downloads the torrent's metadata from those peers, and then the normal transfer starts Magnet link A URI holding the 40-character infohash look up the infohash DHT Peers run the lookup, with no central server a list of peers Peers in the swarm Send the torrent's metadata over the wire protocol now you know the pieces The transfer Rarest first, choking, tit-for-tat No .torrent file, no tracker, no website.
A magnet link holds only the infohash. The DHT finds the peers, the peers supply the metadata, and the transfer starts.

Magnet links made BitTorrent nearly impossible to shut down at the infrastructure level. The Pirate Bay famously switched to magnet-only in 20125, dropping .torrent file hosting entirely.

Phase 4: BEP extensions and modern clients (2012-present)

The protocol kept evolving through the BEP (BitTorrent Enhancement Proposal) process, and several of these drafts go back to 2008 and 2009:

  • BEP 29 — uTorrent transport protocol (uTP), a UDP-based transport that plays nicer with home routers and ISP throttling
  • BEP 10 — extension protocol, allowing clients to negotiate capabilities
  • BEP 27 — private torrents, disabling DHT and peer exchange for controlled swarms
  • BitTorrent v2 (BEP 52) — SHA-256 hashes, per-file Merkle trees, better deduplication
A vertical timeline to scale from 2001 to 2017, beside the post's four phases. The protocol in 2001, the incentives paper in 2003, the Mainline DHT in 2005, BEPs 5, 9, 10 and 27 in 2008, BEP 29 in 2009, The Pirate Bay going magnet-only in 2012, and BEP 52 last revised in 2017 The dates behind the phases Years to scale Phase 1 Phase 2 Phase 3 Phase 4 2001 Bram Cohen sketches the protocol 2003 The incentives paper 2005 The Mainline DHT ships 2008 BEPs 5, 9, 10 and 27 are written 2009 BEP 29: uTP 2012 The Pirate Bay goes magnet-only 2017 BEP 52, BitTorrent v2, last revised
The headline dates, to scale, beside this post's four phases. Much of the spec work landed in 2008.

Where torrents live today

The piracy narrative dominated BitTorrent's public perception for 15 years. That story obscured the legitimate infrastructure built on top of the protocol.

Linux distributions. Ubuntu, Fedora, Arch, Debian — they all offer official torrent downloads. For a new release that millions of people want simultaneously, BitTorrent is the obvious distribution mechanism. It offloads mirror bandwidth to the community.

Game distribution. Blizzard's downloader used peer-to-peer. So did early Steam updates. When you're pushing a 50GB patch to millions of players at once, CDNs are expensive. Peer-to-peer is not.

Scientific datasets. Academic institutions distribute large datasets via torrent. The Internet Archive hosts over a million torrents. When a file is measured in terabytes and the audience is global, HTTP doesn't scale economically.

WebTorrent. Created by Feross Aboukhadijeh, WebTorrent implements BitTorrent over WebRTC6, making it work natively in browsers. No plugins, no extensions. A website can serve video via torrent connections between viewers. Brave browser shipped with WebTorrent built in until 2025.

IPFS lineage. IPFS borrowed heavily from BitTorrent7 — content-addressing, Merkle trees, distributed hash tables, swarming. The key evolution: IPFS addresses individual blocks by content hash rather than grouping everything under one infohash, enabling deduplication across datasets. BitTorrent is the ancestor; IPFS is the mutation that tried to build a permanent web.


Why it still matters

BitTorrent solved a hard problem elegantly: distribute a large file to many recipients without bankrupting the source. The solution was not better servers. It was turning every consumer into a producer.

Twenty-five years later, nothing has replaced it for this specific job. CDNs are fast but expensive. Cloud storage is convenient but centralized. HTTP downloads create a linear relationship between popularity and cost. BitTorrent creates an inverse one.

A sketch of cost for the source against the number of downloaders. For HTTP it climbs in a straight line. For BitTorrent it falls, because every downloader also uploads What popularity costs the source A sketch of the shapes, not a measurement HTTP: linear One more copy to serve BitTorrent: inverse One more uploader Downloaders Cost
More downloaders cost a server more. In a swarm they share the load. A sketch of the shapes.

The protocol also demonstrated something about system design that holds up: you don't need altruism for cooperation. You need aligned incentives. Tit-for-tat, rarest-first, and optimistic unchoking are not complicated algorithms. They're simple rules that produce emergent cooperation in a network of self-interested participants. Bram Cohen didn't build a charity. He built a market.

That design philosophy — make selfishness productive — influenced everything from blockchain consensus mechanisms to federated protocol design. It's the reason BitTorrent works without moderators, without terms of service, without anyone in charge. The protocol is the governance.

BitTorrent accounts for roughly 3% of global internet traffic today, down from 35% at its peak8. But that 3% moves data that nothing else handles as well. The protocol didn't die. It just became infrastructure — invisible, reliable, and still the fastest way to get a 4GB ISO from zero to done.


Further reading

Notes

  1. 1Source

    As of 2025, the BitTorrent ecosystem reports over 170 million monthly active users, 500 million network nodes, and 10 million daily active users. The BitTorrent client software has exceeded 2 billion cumulative installations across Windows, Mac, and Android platforms.

    source →
  2. 2Source

    Cohen's paper was presented at the 1st Workshop on Economics of Peer-to-Peer Systems on June 5, 2003. The paper has over 3,100 citations and remains one of the most referenced works in peer-to-peer systems research. Its central thesis: "BitTorrent file distribution uses tit-for-tat as a method of seeking Pareto efficiency." The protocol achieves cooperation not through trust or altruism, but through repeated-game incentive alignment.

    — Bram Cohen

    source →
  3. 3Source

    The 2006 paper "Rarest First and Choke Algorithms Are Enough" by Arnaud Legout, Guillaume Urvoy-Keller, and Pietro Michiardi (INRIA/Institut Eurecom) showed through extensive real-world experiments that rarest-first guarantees close to ideal piece diversity among peers, and that these two simple algorithms account for the vast majority of BitTorrent's performance characteristics. No complex scheduling or optimization is needed.

    — Legout, Urvoy-Keller, Michiardi — IMC 2006

    source →
  4. 4Source

    The Mainline DHT, specified in BEP 5 and based on the Kademlia distributed hash table design, is one of the largest deployed DHTs in the world. It was first shipped in BitTorrent client version 4.2.0 in November 2005. By 2013, researchers measured 16–28 million concurrent nodes with intra-day variation of at least 10 million, making it larger than many centralized services.

    source →
  5. 5Context

    BEP 9 (Extension for Peers to Send Metadata Files) is what makes magnet links viable. It allows clients to join a swarm and download the torrent metadata — file names, piece hashes, structure — directly from other peers using only the 20-byte infohash. The magnet URI scheme itself was originally developed by Bitzi in 2002 as a vendor-neutral generalization of earlier P2P URI formats (ed2k, freenet). BitTorrent adopted it years later.

    source →
  6. 6Note

    WebTorrent uses WebRTC data channels as its transport layer instead of TCP/UDP, which means it works in any modern browser without plugins. The tradeoff: WebTorrent peers can only connect to other WebTorrent peers (WebRTC) by default, not traditional BitTorrent peers (TCP). WebTorrent Desktop bridges this gap by speaking both protocols. Brave shipped WebTorrent natively until it removed it in 2025, and the library has been used for browser-based video streaming, decentralized CDNs, and peer-assisted delivery.

    source →
  7. 7Context

    IPFS and BitTorrent both use Merkle trees and distributed hash tables, but differ fundamentally in addressing granularity. BitTorrent groups all data under a single infohash per torrent; IPFS addresses each block individually by content hash (CID). This enables cross-dataset deduplication in IPFS but comes at a cost: IPFS nodes are significantly more resource-intensive, and content retrieval benchmarks show BitTorrent at ~800ms (50th percentile) vs IPFS at ~2.9s for comparable operations.

    source →
  8. 8Source

    BitTorrent currently drives approximately 2.91% of global consumer internet traffic — but the distribution is asymmetric: it accounts for roughly 22% of upstream traffic and only 3% of downstream traffic globally. The decline from ~35% at peak is largely explained by the rise of streaming video, which now comprises over 50% of total internet traffic volume. BitTorrent lost its traffic crown not because fewer people use it, but because Netflix and YouTube grew the denominator.

    source →