Navigation:

Search



Our Friends

Articles BitTorrent
 

BitTorrent

A description of the BitTorrent P2P protocol

This was written by Benjamin J McMillan and given on Wed Oct 13 2004.

Table of Contents


1. Basics
1.1. What is BitTorrent?

Simply, BitTorrent is a filesharing protocol, much like P2P (Peer-to-Peer), designed by Bram Cohen circa 2001 (I think).

1.2. How is it different than Kazaa, et al?

Older P2P clients only allow downloading from one host - the host offering the file (and thus has the entire file). The host's client would make available a list of everything it has to offer, and peers can download from it. Newer clients offer the ability to download from multiple hosts if multiple hosts have that same exact file (some go by a hash, or something, instead of just the filename). However, BitTorrent is much more distributed by design. Another big difference is BitTorrent is an open protocol, not a company, so it cannot be sued. Finally, BitTorrent offers no searching mechanism, like that of Kazaa or Gnutella and family.

1.3. What are some clients for Linux?

Azureus is a nice java client, and thus can be used on windows and *nix. This is what I use and offers many plugins for stats and more. There's also Bram Cohen's own implementation from his site, as well as BitTornado by TheShad0w, ABC, and others.

1.4. Where can I find torrents?

There are many sites on the net devoted to releasing torrents. Google is your friend. Also - many companies, especially linux distributions, will offer torrents instead of the actual ISOs, since this will reduce their bandwidth costs. So try their sites.

2. How Does It Work?
2.1. Trackers

A tracker is a service that tells peers where to find other peers. This is really all it is responsible for. Peers will ask the tracker for some peers, and it will give them a list. The selection of peers can be and usually is random, especially for a newly connected peer. It can be more complicated, but it isn't required to be, since Cohen mentions the randomness algorithm is nicely robust. Peers can also check in on trackers, mostly for stats or whatnot.

2.2. Peers

Peers are those who are downloading and uploading pieces. Peers' clients are responsible for choosing which pieces to download and from where. When starting, a piece is wanted quickly so it can start uploading ASAP, so it chooses randomly until a complete piece is assembled. After that, it chooses pieces based on rarety (Rarest First). More common pieces are left for later, since the likelihood of that piece being lost is much lower than that of a rare piece. The protocol tries to use a tit-for-tat policy, so that upload and download speeds are usually the same. Of course, this can be bypassed by choking peers (restricting uploading). However in my experience, you can still get great download speeds (>= 200 KBps) even if your upload speed isn't so great. At the end of the download, when the peer needs the last piece or so, it will send requests to all peers for the sub-pieces (piece is usually .5 MB, while a subpiece is ~16K). As the sub-pieces are completed, the client sends cancels for those completed sub-pieces to limit bandwidth (so it won't download them again). This is to prevent the common problem of the endgame download delay.

2.3. Seeds

Seeds are those who have already completed downloading the file (or are the original publisher), and only upload. If a seed has considerably less bandwidth than that of its peers, the peers will get different pieces of the file from the seed to reduce redundancy and thus reduce the seed's overhead. This makes sure the file gets into the swarm as quickly as possible, so peers can start downloading it as soon and as quickly as possible.

3. How Can I Make a Torrent?
3.1. Get a tracker

There are many trackers already available, so try using one of those. If you want to run your own tracker, make sure your server and connection is reliable. Although you won't need much bandwidth, if a peer can't connect, then it cannot retrieve a list of related peers, and all is futile. ByteMonsoon and mod_bt are some examples of trackers, as well as the one that ships with Cohen's tarball (written in Python). A lot of times, if you're going to publish to a popular torrent site, they will offer their own tracker.

3.2. Make the torrent (a metafile)

Azureus provides its own torrent creation mechanism, so just use that. If you are using another client that doesn't offer one, try Krypt's maketorrent.

3.3. Publish the torrent

Put your torrent on the web somewhere - your site, or a popular torrent site.

3.4. Seed

Open up your client with the torrent you created, and start seeding. This will put the file you wish to share into the swarm of peers (once there are peers). You could stop when you see there are multiple seeds, but please dont.

4. Final Thoughts

BitTorrent etiquette is to leave open your download as long as possible, even after its done, to keep the swarm alive. Don't be a bastard and close it as soon as its done. Some trackers will even keep track of this and ban you.


This article has external documents! Click here.