Torrent – distributed file sharing system

What is a torrent network?

  1. Torrent network is a design to support P2P file sharing.
  2. The elements in a torrent networks are clients and a tracker server (tracker).
  3. Clients can download and upload files in the network.
  4. The tracker connects a client that wants to download a file with other clients that have the file or parts of it.

Requirements

1) Fast sharing of large files between nodes.

2) Support parallel transfer of files chunks from many end points (sources) to a single end point (the downloader). Parallelizing increase download speed. This is more significant in the case of torrent where all files are stored on personal hosts as many ISP’s provide slow upload bandwidth – which limits the peer to peer bandwidth.

3) Support composing file chunks to a single whole file.

Design

  1. How does a client share a file?
    A client is responsible for creating a torrent file (.torrent) for the shared file.
    The torrent file is small size file that contains the file name, hash value of its entire content for identification, chunk size, and list of chunks numbers with their hash values.
    The torrent file also contains the tracker URL.
    The client only sends the torrent file to the tracker i.e. not the content of the original file or its chunks- they are stored by the client.
  2. How does a client knows which other clients have the file?
    First, the client need to get the .torrent file for the desired file.
    The torrent network does not provide a way to find a desired file but assume a client has a torrent file.
    A client can get a torrent file by using a search service from out side the torrent network.
    The client sends request to the tracker using the URL inside the torrent file.
    The tracker replies with a list of clients (named ‘swarns’) that have all chunks of the file (named ‘seeds’) or some of the chunks of the file (named ‘peers’).
    The client connects to the swarns clients and downloads different chunks from each client in parallel. The tracker know which client by first registering the client that uploaded the torrent, then each client that requested the file is also registered as a swarn for that file.
  3. How does the tracker knows what chunks each client store?
    When a chunk was downloaded successfully to a client(from another client), the downloader client will update the tracker (becoming a swarn) which chunks he now store and when the entire file was downloaded it will notify again become a seed for that file.
    By tracking which client is connected to the torrent network-the tracker can update clients on available peers for downloading a file.