Hosted onantonioperez.hyper.mediavia theHypermedia Protocol

BitTorrent

BitTorrent is the most successful P2P file distribution protocol by traffic volume. Its design principles—swarming, tit-for-tat, and separation of discovery from transfer—have influenced nearly every P2P system that followed.

Core Protocol


    Torrent files / magnet links: metadata describing the file (piece hashes, tracker URLs, file structure) or a compact magnet link containing only the info hash for DHT-based bootstrapping.

    Pieces: the file is divided into fixed-size pieces (typically 256 KB–4 MB), each identified by a SHA-1 hash in the torrent metadata. This is a form of content addressing.

    Swarming: download different pieces from different peers simultaneously, turning every downloader into an uploader.

    Rarest-first piece selection: prefer pieces that are least available in the swarm, maximizing redundancy and preventing the "last piece" problem.

    Tit-for-tat incentives: preferentially upload to peers who upload to you. Combined with optimistic unchoking (randomly uploading to new peers), this creates a cooperative equilibrium.

Discovery

BitTorrent uses a layered discovery pattern:


    Trackers: centralized servers that maintain peer lists per torrent. Simple, fast, but a single point of failure and a compliance target.

    DHT (BEP-5): a Kademlia-based DHT for trackerless peer discovery. The BitTorrent mainline DHT is one of the largest DHTs in operation with tens of millions of nodes.

    Peer Exchange (PEX): connected peers share their peer lists, supplementing tracker/DHT discovery.

    Magnet links: encode the info hash, enabling pure DHT bootstrapping without any torrent file or tracker.

This hybrid approach provides resilience: if trackers go down, DHT and PEX continue working.

Transport


    TCP: traditional BitTorrent transport.

    uTP/LEDBAT: UDP-based transport with delay-sensitive congestion control that yields to interactive traffic, making bulk transfers ISP-friendly.

Extensions and Evolution


    BEP-9 (metadata download): fetch torrent metadata from peers via the DHT, eliminating the need for a separate torrent file.

    BEP-29 (uTP): standardized LEDBAT transport.

    WebTorrent: BitTorrent over WebRTC for browser-native P2P file sharing.

    BitTorrent v2 (BEP-52): SHA-256 piece hashes, per-file Merkle trees for better content addressing and cross-torrent deduplication. Hybrid torrents support both v1 and v2 simultaneously.

Lessons for P2P Design

BitTorrent demonstrates principles that apply across all P2P design:


    Simple incentives (tit-for-tat) can be remarkably effective at preventing free-riding.

    Hybrid discovery (tracker + DHT + PEX) provides resilience through redundancy.

    Content addressing (piece hashes) enables trustless transfer from untrusted peers.

    Low-priority transport (LEDBAT) makes bulk P2P traffic coexist with interactive traffic.

    Security considerations include DHT poisoning, tracker manipulation, and content poisoning (served data not matching piece hashes).

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime