All about BitTorrent

From Helpedia
Jump to: navigation, search
Icon exclamation.png
This guide was originally published in August 2005 and is considered outdated.

Since this guide was written, the Bittorrent protocol had suffered some minor improvements but the information below should still be reasonably correct and give readers an overall view of the technology.

In addition, nowadays there are now much better freeware and open source applications available, such as μTorrent, Deluge or Azureus, so the software used in this guide is no longer recommended and the images probably no longer correspond to the software's interface.


Contents

Introduction

Every day, you are downloading files from the internet, sometimes without even knowing.

While downloading a document from the Internet is easy, most Internet browsers supporting downloads, it was not always easy to share files with other people. Usually, someone had to create a web site or a FTP and store the files there, just so that people had access to them.

File sharing programs like Napster and Audiogalaxy have simplified this whole process by allowing you to share your music with your friends or with other people. Other file sharing applications have appeared allowing you to share any kind of documents with other users of the application.

Everything was fine back then, downloading a MP3 file of some pictures was no problem, even if it was slow. Most users had only dial up connection or a cable modem, everyone considered the average speeds of 5-50 KB/second more than acceptable. As the world evolved, Internet connections have increased in speed but also the size of files a user would share also increased. It is now more and more common to see large files being offered for download on the Internet, for example the complete open source FreeBSD operating system, 2 x 700 MB CD images in total.

There was a need for a better and smarter file sharing application, one that would shorten the time a file was delivered to a user, one that would take advantage of the modern Internet connections and computers.

BitTorrent is the new kid on the block.

In this guide, you will find everything you need to know about the BitTorrent protocol and information regarding the installation and configuration of a BitTorrent client titled Bitcomet.

First, a quick note about how BitTorrent works.

The Traditional Way

When you usually download a file from the internet, the download program connects to a remote server, sends your request and then the remote server sends you the file.

This transfer method, used by the HTTP and FTP protocols, is called client-server model, because the central server keeps the file prepared for others to download it, there is a permanent dialog and connection between the client and the server. The method is very good when downloading small files but you really get to see its negative site when you try to download a large, popular file, requested by lots of people.

For example, if you start downloading a recently released CD image of a Linux operating system you will get a reasonable speed at the start, but, as time goes by and more users request that file from the central server, the speed drops because the central server has to divide its attention and its Internet connection with all the users - in rare cases it can even crash under the load. Also, as all people are downloading from the central server, if there is a networking problem or a hardware failure, all 300 people would remain with partial downloads because they all rely on this server to send them the file. This is partially solved with download mirrors but this is often not a viable solution due to the high costs in network connectivity, hosting and equipment.

The central server (in the middle) sends the file to each computer (client-server model)

The central server (in the middle) sends the file to each computer (client-server model)

Most people don't think about how much bandwidth is used by this central server. In most countries, companies do not pay by the minutes the computer is online (as in dial-up), they are charged for the data that is sent through the line (usually fiber optics). For a large company, 1.4 GB (2 CD Images) times 300 (users downloading the images) may not be much but for a small company or a simple person, this is very hard to swallow.

The Modern Way

The BitTorrent protocol was designed in such a way that it eliminates almost all the negative points of the method previously described.

Unlike the previous method, BitTorrent uses a central server just to keep track of the users downloading the files, therefore it can scale to a very large number of users downloading the files (even thousands) and that actual files can even be stored on other server.

The BitTorrent central server (also called "tracker") simply sends a small file called "torrent file" (after the file extension, ".torrent") to each user, a file that contains just the list of files distributed and a small packet of data containing informations about the files (size, error correction checksums). After the initial download of this torrent file, the users' download program connects to the server to receive a list of users that are downloading or have downloaded the content described in the torrent file. From time to time, the download program reports back to the tracker telling what parts of the files they managed to download already and in return they obtain information about other users that have started downloading the files since the last time a connection was established with the tracker.

As you see in the picture below, the central server sends information about the files to the users (in the picture below just two users receive information from the tracker). Users learn about each other this way and, as soon as someone completes a small part of a file (called "chunk"), it offers the chunk to the other users.

The central server's only purpuse is to keep the users informed about each other

The central server's only purpuse is to keep the users informed about each other

As time passes, more and more users have at least one chunk of the torrent completed and will start exchanging the chunks between them, using the error correction information in the torrent file downloaded from the central server to check the chunks for errors during transfer.

If you check the picture, you will see that the central server only sends data to 2 computers in the group of users ("swarm"). Each download program only has to connect to the tracker once, to obtain the torrent file and the initial list of users downloading that particular torrent. This is great because if there are network problems or the tracker is no longer available, you can obtain all the files from the people in your swarm. You don't have to connect to the tracker again, although it is best to do it (and most BitTorrent programs do it for you) because it refreshes the list of users that are downloading the files and you have more users to connect which in turn results in increased download speeds.

In conclusion, using the BitTorrent protocol, people help each other download the files in the torrent by exchanging chunks of data between them as soon as those chunks are completed. The central server just keeps track of the swarm and helps users complete the torrent in a shorter amount of time by telling users what chunks are worst spread in the swarm and on what parts they should focus on.

Introducing Bitcomet

There are plenty of BitTorrent clients out there, most are modifications of the original BitTorrent client, created by the protocol's inventor, Briam Cohen. However, in this guide, I'm going to teach you how to use a popular BitTorrent client, called BitComet.

If you wonder why I will do that and not use the original BitTorrent implementation, it is because the original BitTorrent client is not really user friendly and there really isn't any good reason to not use better, alternative clients.

The original BitTorrent implementation is programmed in Python, a somewhat unknown but good programming language. In the Windows version of the application, the application uses some libraries (DLL files) that convert the programming code into code that can be run on the operating system. Because of this, the BitTorrent original client takes a bit more memory and cpu cycles to do the same things other clients do. Like this client, the open source Azureus client relies on Java to work.

So, in this guide, BitComet is the star, a client programmed in Visual C++. It is one of the fastest BitTorrent clients and contains a lot of useful functions to make things easier for the person using it.

The client is not open-source but it is free and a lot of people are using it all the time. Let's move on and install it...

Installing Bitcomet

BitComet can be downloaded from one of the mirrors listed on the BitComet Download Page. The installation process is straight forward.

After you select the language, you will see a welcome page, than a license agreement which you have to accept if you wish to install the software. After these three windows, you will get the following dialog:

Choosing Components

You may uncheck the shortcuts if you wish to do so. You should leave the last option checked because you will be able to open torrent files directly from the Internet browser this way.

Choosing the installation folder


Leave the default setting to save in the Program Files folder or choose another location, then click Next. You will see the files being copied and the final screen will appear:

Completed

You are now ready to start BitComet, check the first option to start it directly from the setup wizard, then click Finish.

BitComet Preferences - Connection and Proxy

Connection

Global Max Download Rate and Global Max Upload Rate represent the maximum download and upload speed that you allow BitComet to achieve. You should always remember that the speed of your downloads depends directly on your upload speed. If your client uploads a chunk of data to another user's computer, that other user will reward you and will try to give you more speed. If you limit the speed, so will the other user's computer, it will not be so happy to send you data. However, as mentioned in the dialog box , you should limit your upload speed in some cases, if you have a DSL or Cable connection, to just a bit under your maximum connection speed.

The Max Simultaneous Download Tasks option specifies how many torrent files BitComet should start processing at a time. This means that if the number of torrent files open in BitComet is more than the number listed there, the additional torrents will be placed on hold, until the previous torrent number decreases below the number you mention.

If you have a poor connection, for example Cable, it is wise to allow at most 4-5 torrents at a time. Each torrent may have even hundreds of connections to other user, if you have small bandwidth, this would be split among all those connections and everything would be very slow.

The Listen Port is used by BitComet to allow other users to connect directly to you and transfer files faster. If this works, it means you are connectable. The port number can be any value between 1 and 65535 but it is highly recommended to be higher than 1024.

By default, the BitTorrent protocol suggests you use a port between 6881 and 6889 but this is highly not recommended because your ISP may block or slow down the traffic on those ports. It may even have a policy against the BitTorrent protocol so you should really change it to some random number.

You should always read the Frequently Asked Questions of any site that stores torrent files, they may mention even other port ranges that you should not use. Ports that usually belong to other P2P networks, for example Direct Connect (411-413), Kazaa (1214), eDonkey (4662) or Gnutella (6346-6347) are usually not allowed.

Proxy

In this panel you can configure the Proxy Type, entry the proxy server ip and proxy port, if you have one. Optionally, you can also enter the username and password for the proxy, if needed.

BitComet Preferences - Task

Task

The Default Download Path option specifies the default location where BitComet will save the contents of the torrent files.

If you check the Allocate disk space before downloading, BitComet will create in advance the files, full with 0's. This is good if you want to be sure all torrents files will have space to download but also bad because, for example, if you are downloading a CD image at a slow speed, the space will be reserved for hours or days and you may wish to use it and free space just before BitComet needs it.

The Hash-check again when the download is finished should always be checked, it checks again all the downloaded content for errors. During transfers of large files it is possible that chunks of data to be damaged, these chunks will be discarded and BitComet will download only these chunks again after transfer.

You can hash-check a torrent any time by stopping it and selecting the option in the right click menu, in the BitComet interface.

BitComet Preferences - Appearance, Chatting

Appearance

These options are self-explanatory, the only one in particular that I feel it needs to be mentioned is Avoid system entering suspend mode when a task is running.

BitComet has an advanced cache system that can even store in memory incoming data for seconds, not accessing the hard drive and causing the system to believe it can go in suspend mode. If checked, BitComet will not allow a computer to enter the suspend mode, which is good because on a desktop, it prevents the shut down of the drive and its restart. The only time you should uncheck it is if you have a laptop running on batteries.

Chat

Chat

The chat feature is very rarely used, you will not lose anything if it remains unchecked.

BitComet Preferences - Advanced Settings

Advanced

The Set hash check thread to low priority sets BitComet at a lower priority while checking the already downloaded data for errors.

The next option, Add DHT Network as a backup tracker , if checked, gives permission to BitComet to tell other users what you are downloading and to ask them what they are downloading. You will basically exchange information about what you download with other users, on other torrent sites, in the hope that a user on another site may download the same file you are downloading from your site.

This is very good because it helps keep a torrent alive if the tracker server fails but, if you are on a private site that counts the data you transfer (I'll mention these later) this is bad. It is also a security risk because, if you happen to download something not quite legal, other users that have no connection to the private site you are on, may find out about you.

BitComet Preferences - Connection, IP Rules, Disk Cache

The BitTorrent Preferences Panel - Connection

The things I have mentioned in the previous page about DHT apply here to, in my opinion it is best to leave the Enable DHT network option unchecked.

The Maximum Connections per task specifies the number of computers your client can connect to, for one torrent file. If you have a high speed connection set is as high as you like, otherwise is should not exceed 200. Some operating systems are sensitive about the number of connections, if you experience problems, set the default option or even lower the value.

IP Rules

The Enable reporting LAN IP to Tracker is very useful if you are inside a local network, it provides the tracker with one method of differentiating you from the rest of the people in your network. Nowadays, a better method is used, passkeys, but this option can be left checked, in case the tracker does not support passkeys.

If you check the Enable IP filter file : ipfilter.dat (compatible with eMule) option, BitComet will look in its folder for a ipfilter.dat file, which contains rules that prevent or allow access of other computers to your computer. If, for example, you have a very poor connection outside your country and you prefer to only allow people from your country to receive files from you, you can add rules in that file that will block those people. The rules are beyond the scope of this guide, you will have to read about this somewhere else (the eMule documentation is a good start).

Disk Cache


BitComet uses a disk cache to temporarily keep frequently used data and to reduce the number of disk accesses.

Due to the fact that when downloading a torrent file you are usually downloading and uploading from lots of people at a time, you would be often faced with the problem of seeing the drive spinning and moving its heads all over the surface trying to write all the data it receives or trying to read what should be sent to other people.

The disk cache stores a lot of downloaded data and sends it to the drive in small bursts, reducing the disk access. It also loads in advance parts of files that need to be sent to others. It should be set as high as possible but you should not exceed 300 MB. Also, note that this amount is taken out of you computer memory (RAM), if you don't have at least 512 MB of RAM, the recommended setting would be between 50 and 150 MB.

BitTorrent Terms

During the small history of BitTorrent and the configuration of BitComet I have introduced a lot of new terms that may sound strange to you. I'll try to explain all those terms in more detail on this page.

A tracker is the software on a web server that keeps track of the users that are downloading something from a site. It's purpose is only this, to help users talk to each other. The tracker does not send you files, it only created the connection between you and the person that offers the files and the other users that are already downloading the files.

The set of files that are being offered are defined as a torrent, you get information about this set of files through a torrent file, a text file that contains the list of file names, their sizes and some error correction information. The torrent file does not contain parts of the files in the torrent.

In a torrent file, files are split in even size pieces called chunks, each chunk has an error correction code which is stored in the torrent file. This helps you a lot, if a chunk is detected as bad, you only have to download that chunk again and not a whole file or the whole torrent. Chunks are usually between 256 KB and 4 MB. The whole torrent file has another signature called hash which makes it different and unique. This also is stored in the torrent file.

After you download the torrent file, BitComet connects to the tracker and receives a list of other people that are also downloading the torrent. You and the rest of the people are from this moment considered a swarm, a group of people helping each other download the torrent faster.

In a swarm there are two types of users, seeders and lechers. The original user that offered the torrent is called seeder because he only uploads the files in the torrent to others. While you download files, even if you are also uploading parts to other users, you are called a leecher. As soon as you complete the torrent and start to only upload the torrent to other users, you are called just like the original users, a seeder.

There is a special type of leecher, a user that does not upload at all, for various reasons, because he doesn't like to share or because he is behind a firewall or for lots of other reasons. BitTorrent is based around the idea that users help each other by exchanging parts and has a lot of tweaks and algorithms to discourage you if you don't upload. The download speed increases a lot if you upload chunks to other users, this is why you must do the best you can to be able to upload to others.

There are a lot of Internet sites that offer torrent files for download and most have their own tracker to track the torrents files. Some sites do not require any registration and you are free to download anything at your own pace. In change, other sites try to form small communities and because of this they are private, you have to register to have access or you have to be invited by an already user of that site.

Because these small communities often have very interesting torrent files (while not alwas 100% legal), they are faced with the problem of many users downloading the hot torrent files and not helping other users in the community. This type of user downloads the torrent very fast and doesn't stay and help other users download the torrent when download is complete.

In order to encourage these leechers to stay and help other users by uploading files to them, the private sites have some restrictions or advantages, depending on the ratio you have, the ratio being the number of bytes uploaded / number of bytes downloaded. You should always have a ratio over 1, this means you upload more than you download. The disadvantages of having a low ratio can very from forcing you to wait 1-2 days before downloading anything new to allowing you to only download one torrent at a time. On some very private communities, if your ratio drops below a certain amount, for example 0.2, you are not even allowed to download, the only thing you can do is to upload what you have already downloaded.

If you are in a local network with other users that are using a tracker, that tracker can be confused and not count the ratio properly. This is why in almost all trackers that require registration and count the ratio a code called passkey is implemented. This code is unique to each user and is stored in each torrent file you download from that site. You should never share your torrent files with other users. If they're smart, they can extract the passkey from the torrent file and use it in such a way that the tracker will think you have downloaded what they download and you ratio will be affected. If you share your passkey or somebody finds it, you should change it as soon as you can (from your account's settings) or you should contact an administrator of that site to change it for you.

Why should I be connectable ?

If you are in a local network or behind a router or a firewall, the tracker and the other users usually can not connect to you. This means that the tracker can not send you updated information and other users can not request parts of the torrent from you, your download speed is slower because also your upload speed is smaller.

You should do everything in your powers to become connectable, that is to make it possible for other users to connect to you. However, you must be careful because this also implies a lot of risks, you should always have an antivirus running and perhaps a well configured firewall.

First thing you need to know in order to become connectable is if you have a static IP or a dynamic IP. A dynamic IP is assigned to your computer for example when you use a dial-up service to connect to the Internet or on very large networks, with hundreds of computers (because the IP's are managed by the server). The dynamic IP is dynamic because as soon as you turn of your computer, the IP is free and can be set to another computer and as soon as you turn on the computer you receive another IP. A static IP is set once in the control panel and it's yours, nobody can take it.

You can find your IP by accessing the site called What Is My IP.

If you are in a local network or behind a router, the IP shown on the site may not be yours, it may be the router's IP or the local network server's IP.

In Windows, you see the IP in the TCP/IP Properties Panel of your network card or modem :

Finding your IP

or by clicking the Start button, selecting run, opening a console by typing cmd and then typing there:

ipconfig -all

As you see in the picture, my local IP is 172.28.1.1 but the IP visible on the Internet is the router's IP, 193.220.17.1.

In this case, a port must be forwarded, this process is called port forwarding. You will have to ask the administrator of your network server in a very nice way to forward a port. If you have a router, you have to do it yourself but don't worry, you can find a lot of help on this following site: Port-Forward.com - lots of routers and configurations

If you still have problems making yourself connectable, you should talk to the administrators or the users of the site you are on, they will usually help you out if you ask nicely.

Other things you should know...

Occasionally, more frequently with old torrents, you may see that the torrent you have started to download is no longer downloading anything. This often occurs because there is no user offering data to you and the only solution to this is to be patient and wait for someone to help you out. If time goes by and no help appears you could ask around (in the site forums for example) for someone to help you out, usually people are nice and glad to help you.

On other occasions, you may notice that you upload a lot but you are almost not downloading anything. This sometimes happens because there is no room in the upload channel to send to other users, confirming that you have received the previous chunk of the torrent and asking him to send you another chunk. If this happens, the only solution is to limit the maximum upload speed to a few kilobytes under the maximum upload speed you have.

Legal issues

The BitTorrent protocol was designed from the start to help people download very large files in short time and with no thought about each user's security. The protocol did not need to be burdened with encryption and protection for users, yet it is flexible enough to work even if several seeders or leechers send bad data in the network.

The point is you should know that you are not completely safe on the Internet, if you are downloading something illegal or copyrighted in your country, people can find your IP address and possibly even threat your ISP to find information about you.

While the BitTorrent protocol is legal in every way possible (no files are stored on the tracker, the torrent file is only a text file with information about the files), it is your responsibility, you have to judge what is legal and what is not and take the appropriate actions.

Conclusion

In this guide, I have only guided through the steps of installing and configuring a BitTorrent client and I have explained the protocol a bit, you have to decide for yourself if you use it to download an open source operating system , video trailers , freeware applications or pirated material.