Theory behind torrent downloads

BitTorrent well they are known as  peer to peer file sharing protocol which are used for distributing large amounts of data,these are one of the most common protocols used for transferring large files,and these are estimated that it accounts for roughly 25-60% of all Internet traffic these values varies depending on geographical location.It was designed by a programmer from UNITED STATES name Bram Cohen in April 2001 and released a first implementation on 2 JULY 2001.

This protocol  initially works when a file provider make his file or groups of files available to the network which are known as SEED and the other as PEERS, the work of SEED and PEERS  are such that SEED allows to connect to the file and PEERS helps in downloading the file.Each PEERS who download a part of data makes it available to other PEERS to download. After the file is successfully downloaded by a peer,may continue to make the data available,becoming additional SEED.This distributed nature leads to a viral spreading of file throughout peers.


 The peer distributing a data file treats the file as a number of identically sized pieces, usually with byte which sizes a power of 2,and it lies typically between 32 KB  and 4 MB each. These peer creates a hash(A hash function is any well defined procedure or mathematical function that converts a large, possibly variable-sized amount of data into a small datum, usually a single integer that may serve as an index to an array.) for each single piece by using SHA-1(cryptographic hash function) hash function which helps to record it in torrent file.The pieces which are greater thn 512 KB will help in reducing the size of a torrent file for a very lagre payload,but is claimed to reduce the efficiency of the protocol. When another peer later receives a particular piece, the hash of the piece is compared to the recorded hash to test that the piece is error-free.

The correct and exact information contained in the torrent file depends on the version used in the BIT TORRENT protocol.The torrent files has the extension as .torrent. Torrent files have an "announce" section, which specifies the URL of the tracker, and an "info" section, containing (suggested) names for the files, their lengths, the piece length used, and a SHA-1 hash code for each piece, all of which are used by clients to verify the integrity of the data they receive.

For publishing a torrent files we need to have a web site and we must have to register it with atleast one tracker.The tracker keeps the record of the client participating in torrent.

Downloading torrents and sharing files:

Users browse the web to find a torrent of interest, download it, and open it with a BitTorrent client. The client connects to the tracker(s) specified in the torrent file, from which it receives a list of peers currently transferring pieces of the file(s) specified in the torrent. The client connects to those peers to obtain the various pieces. If the swarm contains only the initial seeder, the client connects directly to it and begins to request pieces.

Clients incorporate mechanisms to optimize their download and upload rates; for example they download pieces in a random order to increase the opportunity to exchange data, which is only possible if two peers have different pieces of the file. The effectiveness of this data exchange depends largely on the policies that clients use to determine to whom to send data. Clients may prefer to send data to peers that send data back to them  which encourages fair trading. But strict policies often result in suboptimal situations, such as when newly joined peers are unable to receive any data because they don't have any pieces yet to trade themselves or when two peers with a good connection between them do not exchange data simply because neither of them takes the initiative. To counter these effects, the official BitTorrent client program uses a mechanism called “optimistic unchoking”, whereby the client reserves a portion of its available bandwidth for sending pieces to random peers (not necessarily known good partners, so called preferred peers) in hopes of discovering even better partners and to ensure that newcomers get a chance to join the swarm.
The community of BitTorrent users frowns upon the practice of disconnecting from the network immediately upon success of a file download, and encourages remaining as another seed for as long as practical, which may be days – especially when there are a lot of downloading peers and when the ratio of seeders to downloading peers is low.

Author :Swastik Upadhyay