BitTorrent

BitTorrent is the name of a peer-to-peer (P2P) file distribution client application and also of its related file sharing protocol, both of which were created by programmer Bram Cohen. BitTorrent is designed to distribute large amounts of data widely without incurring the corresponding consumption in costly server and bandwidth resources. The original BitTorrent application was written in Python.
BitTorrent clients are programs which implement the BitTorrent protocol. Each BitTorrent client is capable of preparing, requesting, and transmitting any type of computer file over a network using the BitTorrent protocol. This includes text, audio, video, encrypted content, and other types of digital information.
Creating and publishing torrents
To share a file or group of files through BitTorrent, clients first create a “torrent”. Each torrent contains meta information about the file to be shared, and about the host computer that provides the initial copy of the file. The exact information contained in the tracker file depends on the version of the BitTorrent protocol. However, a torrent file always has the extension .torrent. Torrent files contain an “announce” section, which specifies the URL of the tracker, and an “info” section which contains a suggested name for the file, fragment size, a key length, file length, and a pass. A single torrent can contain information on one or more files. Clients who have finished downloading the file may also choose to act as seeders, providing a complete copy of the file. After the torrent file is created, a link to it is placed on a website, and it is registered with a tracker. BitTorrent trackers maintain lists of the clients currently downloading the file. The computer with the initial copy of the file is referred to as the initial seeder.
Downloading torrents and sharing files
Using a web browser, users navigate to the site listing the torrent, download it, and open it in a BitTorrent client. After opening the torrent, the BitTorrent client connects to the tracker, which provides it with a list of clients currently downloading the file or files. A group of peers on a BitTorrent or P2P connected with each other to share a particular torrent is generally referred to as a swarm.
Initially, there may be no other peers in the swarm, in which case the client connects directly to the initial seeder and begins to request fragments. The BitTorrent protocol breaks down files into a number of small fragments, typically a quarter of a megabyte (256 KB) in size. Larger file sizes typically have larger fragments. For example, a 4.37 GB file will often have a fragment size of up to 4 MB (4096 KB). File fragments are checked as they are received using a hash algorithm to ensure that they are error free.
As peers enter the swarm, they begin sharing fragments with one another. Because clients share fragments with one another, instead of directly from the seeder, BitTorrent networks easily scale to large numbers of clients. The protocol incorporates mechanisms so that clients choose peers with the best network connections for the fragment they are requesting. One major innovation that adds to the scalability of BitTorrent is the concept of “rare fragments.” The BitTorrent protocol specifies that clients should always request fragments that are the rarest, meaning they are held by the fewest number of clients in the swarm. By requesting the rarest fragments, the BitTorrent protocol ensures that one machine will not be swamped with requests, eliminating potential network bottlenecks.