All about BitTorrent

From Helpedia
Revision as of 12:32, 22 June 2013 by Mariush (talk | contribs) (Created page with "__TOC__ ==Introduction== Every day, you are downloading files from the internet, sometimes without even knowing. While downloading a document from the Internet is easy, most...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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...