Saturday, July 29, 2006

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 pieces. The BitTorrent protocol breaks down files into a number of much smaller pieces, typically a quarter of a megabyte (256 KB) in size. Larger file sizes typically have larger pieces. For example, a 4.37 GB file may have a piece size of 4 MB (4096 KB). Pieces 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 pieces with one another, instead of downloading directly from the seeder. Clients incorporate mechanisms to optimize their download and upload rates, for example using a tit for tat scheme. Peers download pieces in a random order, to increase the opportunity to exchange data, which is only possible if two peers have a different subset of the file.

The effectiveness of the peer-to-peer data exchange depends largely on the policies used by clients to determine whom to send data to. Clients will prefer to send data to peers that send data back to them, which encourages fair sharing, but strict policies often result in suboptimal situations, where newly joined peers are unable to receive any data (because they don't have any pieces yet to share themselves) and two peers with a good connection between them do not exchange data simply because neither of them wants to take the initiative.

To counter these effects, the official BitTorrent client uses a mechanism called “optimistic unchoking”, where the client will reserve a portion of its available bandwidth for sending pieces to random peers (not necessarily known-good partners, so called prefered peers), in hopes of discovering even better partners and to ensure newcomers get a chance to join the swarm.

0 Comments:

Post a Comment

<< Home