What is BitTorrent

BitTorrent is a protocol for distributing files. It identifies content by URL and is designed to integrate seamlessly with the web. Its advantage over plain HTTP is that when multiple downloads of the same file happen concurrently, the downloaders upload to each other, making it possible for the file source to support very large numbers of downloaders with only a modest increase in its load.

https://youtu.be/EkkFT1bRCT0

https://youtu.be/shVvFVFiZcs

How-BitTorrent-works.png

A BitTorrent file distribution consists of these entities

There are ideally many end users for a single file.

To start serving,

a host goes through the following steps

  1. Start running a tracker (or, more likely, have one running already).
  2. Start running an ordinary web server.
  3. Associate the extension .torrent with mimetype application/x-bittorrent on their web server (or have done so already).
  4. Generate a metainfo (.torrent) file using the complete file to be served and the URL of the tracker.
  5. Put the metainfo file on the web server.
  6. Link to the metainfo (.torrent) file from some other web page.
  7. Start a downloader which already has the complete file (the 'origin').

To start downloading, a user does the following:

  1. Install BitTorrent (or have done so already).
  2. Surf the web.
  3. Click on a link to a .torrent file.
  4. Select where to save the file locally, or select a partial download to resume.
  5. Wait for download to complete.
  6. Tell downloader to exit (it keeps uploading until this happens).

B-encoding

Metainfo File

Meta-info files (also known as .torrent files) are bencoded dictionaries with the following keys:

All strings in a .torrent file that contains text must be UTF-8 encoded.

<aside>

.torrent file is NOT:

In real use, the meta info file has no \n and consists of stream input in single line, this is for visualization.