This article will explain how to use bittorrent to share files.
Introduction to bittorrent
bittorrent (bt) is a centralized peer to peer (p2p) protocol to share big files efficiently between a lot of users. bt is centralized because it uses a so called tracker in order to connect the peer to peer clients to each other. It is a peer to peer protocol because the actual exchange of the content data is done solely on a p2p basis. The protocol is described at http://www.bittorrent.org/protocol.html
How does bittorrent work?
First of all the data that should be distributed via bittorrent must be torrified. That means that a torrent file of the data (that should be distributed) is generated. Such a torrent file holds meta information about the associated data.. This torrent file also contains a tracker address, the size of the associated data, a date when it was generated and some more information. After Data was torrified you need at least one seeder that has the torrent as well as the associated data belonging to that torrent file. With the data and the torrent file you start a bt client software in order to connect to the tracker and start distributing. Make sure your the ports your bt-client is listening on are reachable from the outside world (aka internet). After that you can just pass on the torrent file to some friends. Your friend can take the torrent file, load it into his bt-client software and start downloading the associated data.
This works as follows: The bt-client of your friend is decoding the torrent and talks to the tracker is listed in the torrent file. the bt-client then tells the tracker what info hash it is interested in, what ID it has, on what IP and ports it is awaiting connections,…. The tracker keeps track (hence the name) of all the torrents and all the clients that are interested in the same torrent. If a new client connects to the tracker the tracker looks up if it knows any other clients for that torrent and if so, it sends back the connection information (IP, Port) for those clients that do already have the data or a part thereof. Then the bt-clients are connect to each other to request parts of the data and send it to each other. When having a lot of clients interested in the same torrent a single client can download six different parts of the data from six different sources, while uploading 4 other parts of the data to other clients that still miss those parts of the data.
torrify your data
First of all somebody (you) needs to torrify any data in order to be able to distribute the data using bittorrent. In this process a so called torrent file is generated. A torrent file represents certain data (a file or a structure of files) and holds some meta data about it. A torrent file is encoded in a format called bencode.
Here is an example of a torrent files content:
META INFO Announce: udp://tracker.0x41414141.de:6969 Created On: Fri Feb 1 00:22:49 2008 Piece length: 262144 FILES INFO <1> Einmannhubschrauber.wmv  Total: 18 MB
In ordert to torrify some data you can use the offical bittorrent client on windows or ctorrent on Linux. With ctorrent it works like this:
ctorrent -t -u udp://tracker.0x41414141.de:6969 -s my_data.torrent my_data.zip
Overview to bittorrent clients
In order to use bt you need to have a program that speaks bittorrent and acts as your interface to bt. Those programs are usually called clients. Due to its dual nature (centralized vs. p2p) a bt client is actually also a server. Nevertheless its called client ;-). Like for most protocols there are different implementations for different platforms out there. The following parts of the document will introduce you to some of them.
Clients for Windows
For Windows i just use the official bittorrent client software, it has a nice GUI, it supports most of the features and it just works. But if you have other alternatives use the comment function on this page to tell me.
official bittorrent client
The official bittorrent client can be downloaded from the official bittorrent webpage at bittorrent.com. The client has a nice, more or less self explaining GUI and always supports recent versions of the protocol.
Clients for Linux
For Linux i ended up to use ctorrent and rtorrent. ctorrent is very simplistic and can be scripted easily. ctorrent also supports the generation of torrent files on Linux with i use it most for. Copmpared to ctorrent rtorrent has a little more comfortable interface, supports loading more than one torrent at a time, supports throtteling of up- and downloads, shows a lot’s of details about the downloads, etc… To say it in one sentence: rtorrent is my favorite console bt client.
ctorrent does exist in two versions, the older one is not maintained and supported anymore, but the is a brance (so called enhanced ctorrent) which is still supported and actively maintained. I would recommend using the later one out of objective reasons.
rtorrent can be download from http://libtorrent.rakshasa.no/. In a lot of unix distributions it is already available via a package or port, like in debian linux, ubuntu linux, FreeBSD, and possibly others. Please have a look into your distribution packages / ports in order to find out if your distribution is already offering an easy and elegant way to install rtorrent.
someone who is (mostly) uploading data via bittorrent. Note that in bittorrent you are almost never just a leecher or a seeder, you are both at the same time. As soon as you client holds some part of the requested data it also starts uploading that parts to other peers.
someone who is (mostly) downloading data via bittorrent. Note that in bittorrent you are almost never just a leecher or a seeder, you are both at the same time. As soon as you client holds some part of the requested data it also starts uploading that parts to other peers.
a server that provides connectivity information about info_hashes to clients. Traditionally trackers do run via http, newer versions also run on udp since http is producing a lot of protocol overhead and there for is less efficient than udp. Not that a tracker does not offer or hold any data, it just holds connection data associated to info_hashes. What kind of data is behind an certain info_hash (and there for torrent file) can not be revelaed by the tracker. So in the end the tracker is just infrastructure that tells clients where to go. Sharing and holding the data is solely done by clients.
In order to make bittorrent more robust against the take down of all trackers, newer versions of bittorrent implementations do allow to run in a so called tracker less mode. In this mode ther is no central tracker any more, instead the client takes over most of the tracker functionality it self and is exchanging information about other clients with other clients by using distributed hash tables (DHT).