This article is excerpted from the newly published book A Practical Guide to Linux Commands, Editors, and Shell Programming .
Unlike protocols such as FTP, BitTorrent groups multiple files into a single package called a torrent. For example, you can typically download several installation ISO images as a single torrent.
Like other P2P systems, BitTorrent does not use a dedicated server. Instead, the functions of a server are performed by the tracker, peers, and seeds. The tracker allows clients to communicate with each other. A client -- called a peer when it has downloaded part of the torrent and a seed once it has downloaded the entire torrent -- acts as an additional source for the torrent. As with a P2P network, each peer and seed that downloads a torrent uploads to other clients the sections of the torrent it already has. There is nothing special about a seed: It can be removed at any time once the torrent is available for download from other seeds.
After you download and install BitTorrent, the first step in downloading a torrent using BitTorrent is to locate or acquire a .torrent file. A .torrent file contains the information about the torrent, such as its size and the location of the tracker. You can use a .torrent file using its URI or you can acquire it via the Web, an email attachment, or other means. The next step is for the BitTorrent client to connect to the tracker to learn the locations of other clients that it can download the torrent from.
Once you have downloaded a torrent, it is good manners to allow BitTorrent to continue to run so other clients can upload at least as much information as you have downloaded.
PrerequisitesIf no BitTorrent RPM file exists for your version of Linux, use an RPM file for a similar version. Because BitTorrent is written in Python and runs on any platform with a Python interpreter, it is not dependent on system architecture. The "noarch" in the name of the RPM file stands for no architecture.
To run, BitTorrent requires Python, which is installed as /usr/bin/python on many systems. Python is available in the python RPM package.
How BitTorrent worksThe official BitTorrent distribution includes three client applications. You can use any of these applications to download BitTorrent files:
In addition to the official clients, several other clients provide extra features.
Using BitTorrentTo use BitTorrent, first locate the .torrent file for the torrent you want to download. You can copy the .torrent file to the working directory (the first format shown below) or specify it with a --url option (second format). The simplest BitTorrent command lines have the following formats:
$ btdownloadheadless.py --responsefile tfile.torrent [--saveas savefile]
or
$ btdownloadheadless.py --url http://domain/tfile.torrent [--saveas savefile]
where tfile.torrent is the name of, or http://domain/tfile.torrent is the URI for, the .torrent file, and savefile is the location to save the torrent in. In the case of torrents containing a single file, the file is saved as savefile. For torrents containing multiple files, the files are saved in a directory named savefile. If you omit the --saveas argument, the files are saved in the name specified in the .torrent file. Because each of the btdownload*.py applications takes the same arguments, the preceding formats work for all three applications.
The next example shows how to download Fedora Core 3 ISO images. These large files take considerable time to download. To start the download, give the following command:
$ btdownloadheadless.py --max_upload_rate 8 --url http://torrent.dulug.duke.edu/heidelberg-binary-i386.torrent
This command uses a URI to specify a .torrent file and saves the downloaded files in a directory named heidelberg (the name of the Fedora release) as specified by the .torrent file.
The --max_upload_rate 8 option prevents BitTorrent from using more than 8 kilobytes per second of upstream bandwidth. BitTorrent usually gives higher download rates to clients that upload more, so feel free to increase this value if you have spare bandwidth. You need to leave enough free upstream bandwidth for the acknowledgment packets from your download to get through or your download will be very slow. By default the client uploads to a maximum of seven other clients at once. You can change this value by specifying the --max_uploads argument, followed by the maximum number of concurrent uploads you wish to permit. The default value of 7 is usually appropriate for typical broadband connections.
After you give the preceding command, the screen quickly fills with output that looks similar to the following:
saving: heidelberg-binary-i386 percent done: 0.0 time left: finishing in 27:09:04 download to: /home/max/heidelberg-binary-i386 download rate: 32.9 KB/s upload rate: 0.0 KB/s share rating: 0.000 (0.0 MB up / 1.2 MB down) seed status: 30 seen now, plus 1 distributed copies (2:81.5%, 3:23.0%, 4:2.1%) peer status: 5 seen now
The file size is that of all the files you are downloading: four ISO images and several smaller files. To abort the download, press Ctrl-C. The download will automatically resume from where it left off when you download the same torrent to the same location again.
Use the following command to perform the same download as in the previous example, this time throttling the rate and number of uploads to values sensible for modem users.
$ btdownloadcurses.py --max_upload_rate 3 --max_uploads 2 --url http://torrent.dulug.duke.edu/heidelberg-binary-i386.torrent
The preceding command displays output similar to the following:
file: heidelberg-binary-i386 size: 2,467,681,047 (2 GiB) dest: /home/max/heidelberg-binary-i386 progress: _________________________________________ status: finishing in 6:40:42 (1.0%) dl speed: 285.6 KB/s ul speed: 2.6 KB/s sharing: 0.009 (0.1 MB up / 15.1 MB down) seeds: 29 seen now, plus 0 distributed copies (1:0.8%, 2:0.0%, 3:0.0%) peers: 1 seen now
Note: Comments are owned by the poster. We are not responsible for their content.
I tried for days to get the new suse or slackware<nobr> <wbr></nobr>....avg speed, 39kb. My ftp is much faster.
Now, many people will stick up for Bittorrent and say that it is not the fault of Bittorrent but rather the fault of the broadband provider. I say that this is disingenuous because Bittorrent is specifically targeted at broadband users, the people that are most likely to have asynchronous connections so, Bittorrent is intentionally designed to penalize its target audience.
Well said! All I was able to come up with was "it sucks!"
OTOH, myself included along with many, many others have nothing but disdain for BT. This is after enduring endless amounts of, "it works great for me", "open ports x y z", etc. A good many people fight with this application, doing all sorts of dances, ample sprinking of hocus pokus incantations, blessings of the almighty correct port configuration that if we get it to work. All our efforts are rewarded with download speeds that hardly classify as dail-up.
You can justify all you like about how it might save on ftp/http resources, etal and you can pump it up till your blue in the face but IMO BT is one disappointing application.
This is after enduring endless amounts of, "it works great for me", "open ports x y z", etc.
Phhhttt!
Posted by: Anonymous Coward on September 14, 2005 05:06 AMOn paper this statement is true but, in the real world the truth is far different. The truth is that Bittorrent offers more to those that offer more upload bandwidth. You could also say that Bittorrent penalizes those that restrict upload bandwidth.
The problem is that most broadband connections are asynchronous, meaning that the download bandwidth is higher than the upload bandwidth. This means that because of the cap on your broadband upload speed Bittorrent will max out at around 384Kbps down. Compared to a good FTP site that might offer 3Mbps download speeds, Bittorrent pales in comparison.
Now, many people will stick up for Bittorrent and say that it is not the fault of Bittorrent but rather the fault of the broadband provider. I say that this is disingenuous because Bittorrent is specifically targeted at broadband users, the people that are most likely to have asynchronous connections so, Bittorrent is intentionally designed to penalize its target audience.
#