Overview of the BitTorrent architecture



1206 views BitTorrent Internals



The BitTorrent Architecture BitTorrent architecture consists of the following entities

  • Torrent File
  • Tracker
  • Leecher
  • Seeders

Each torrent is independent and it holds information about one or many files that need to be distributed. To download a specific file, we need to hunt its torrent file from any torrent search engine.

Pieces

The original file is split into equal size pieces and the SHA-1 of each piece is put into the .torrent file. The hash is then used by the peers to download the corresponding piece and once all the pieces are downloaded, they are merged to re-generate the file.

Tracker

Tracker is the only central entity and it holds the information about all the peers participating in the torrent network. It is a simple HTTP server that responds to the queries of the peers and stores status information coming in from the peers.

Each torrent file holds a Tracker URL that helps the peers locate and talk to the tracker to participate in the torrent. The tracker keeps track of

  • peers who hold the pieces of the file
  • peers who are downloading
  • peers who need help to find other peers

Although the tracker keeps track of a lot of information, it does not download or participate in the download of the actual content of the file; it simply holds the meta information.

Leecher

Leecher is any peer in the network that is downloading the pieces and is awaiting the completion of the file. Leecher talks to the tracker to get the list of 50 peers and then talks to them to get the desired pieces.

The leechers also help other leechers by sharing the pieces they have, thus quickly distributing the file across the network.

Seeder

Seeder is a peer in the network that has all the pieces of the file and does not need to download anything. So, if any leecher needs any piece that is not available with any other leecher, it can obtain from the seeder.

A leecher, after completing the download of the entire file, becomes the seeder and continues to participate in the network.


Arpit Bhayani

Arpit's Newsletter

CS newsletter for the curious engineers

❤️ by 21000+ readers

If you like what you read subscribe you can always subscribe to my newsletter and get the post delivered straight to your inbox. I write essays on various engineering topics and share it through my weekly newsletter.




Other essays that you might like


Exploiting and stealing from the BitTorrent network

476 views 20 likes 2022-08-19

Stealing is bad, but in a P2P network, it is a cakewalk. In this 7th video of the BitTorrent Internals series, we take ...

Kademlia - a Distributed Hash Table implementation to power the overlay network of BitTorrent

983 views 51 likes 2022-08-17

Kademlia is a Distributed Hash Table implementation and it is used as an overlay network for BitTorrent. Instead of talk...

The Piece Selection algorithm that makes BitTorrent fault tolerant

575 views 28 likes 2022-08-15

Performance of the BitTorrent network relies heavily on the order in which the pieces are requested by the peers. In th...

The Choke Algorithm that powers BitTorrent

762 views 30 likes 2022-08-12

One of the most important algorithm that powers BitTorrent is The Choke Algorithm In this 4th video of the BitTorrent I...


Be a better engineer

A set of courses designed to make you a better engineer and excel at your career; no-fluff, pure engineering.


Paid Courses

System Design Masterclass

A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.

1000+ learners

Details →

Redis Internals

Learn internals of Redis by re-implementing some of the core features in Golang.

28+ learners

Details →

Free Courses

Designing Microservices

A free playlist to help you understand Microservices and their high-level patterns in depth.

17+ learners

Details →

GitHub Outage Dissections

A free playlist to help you learn core engineering from outages that happened at GitHub.

67+ learners

Details →

Hash Table Internals

A free playlist to help you understand the internal workings and construction of Hash Tables.

25+ learners

Details →

BitTorrent Internals

A free playlist to help you understand the algorithms and strategies that power P2P networks and BitTorrent.

42+ learners

Details →

Topics I talk about

Being a passionate engineer, I love to talk about a wide range of topics, but these are my personal favourites.





  • v13.7.5
  • © Arpit Bhayani, 2022

Powered by this tech stack.