Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

BitTorrent Protocol


Published on

Here are some slides on bittorrent protocol.. hope it helps..

Published in: Education, Technology

BitTorrent Protocol

  1. 1. <ul><li>Peer to Peer file transfer protocol </li></ul><ul><li>Transfer of large files </li></ul><ul><li>Files are shared by many users </li></ul><ul><li>Active participation of all users </li></ul><ul><li>Huge success in the file sharing domain </li></ul><ul><li>35% of internet traffic </li></ul>Introduction
  2. 2. Striking Characteristics <ul><li>Not dependent on a single source </li></ul><ul><li>A central server is not needed </li></ul><ul><li>No single point of failure </li></ul><ul><li>More the number of users, greater will be the transfer rate </li></ul><ul><li>Data available in pieces, not as a single large file </li></ul><ul><li>Tit for tat strategy </li></ul>
  3. 3. Terminology <ul><li>Torrent </li></ul><ul><li>Peer </li></ul><ul><li>Seed </li></ul><ul><li>Leecher </li></ul><ul><li>Swarm </li></ul><ul><li>Reseed </li></ul><ul><li>Tracker </li></ul><ul><li>Share Ratio </li></ul>
  4. 4. Architecture of BitTorrent
  5. 5. <ul><li>HTTP Peer – Tracker </li></ul><ul><li>TCP Peer – Peer </li></ul><ul><li>Components of BitTorrent System </li></ul><ul><li>Metainfo File </li></ul><ul><li>Data </li></ul><ul><li>Tracker </li></ul><ul><li>Peers </li></ul><ul><li>Client </li></ul>
  6. 6. Metainfo File <ul><li>Contains all information about a torrent </li></ul><ul><li>File with a .torrent extension </li></ul><ul><li>It has the following keys </li></ul><ul><ul><li>info </li></ul></ul><ul><ul><li>announce </li></ul></ul><ul><ul><li>creation date </li></ul></ul><ul><ul><li>comment </li></ul></ul><ul><ul><li>created by </li></ul></ul><ul><li>Keys are encoded before they are sent </li></ul>
  7. 7. <ul><li>Encoding scheme used by BitTorrent is called as Bencoding </li></ul><ul><li>Hash of all the pieces are present in info field of metainfo file </li></ul><ul><li>File Distribution </li></ul><ul><li>Files are uploaded in public sites by seeds </li></ul><ul><li>Users download this file via HTTP and can participate in the torrent transfer </li></ul>
  8. 8. Data <ul><ul><li>Data can be a single file or multiple files contained in a directory </li></ul></ul><ul><ul><li>Data is split into many pieces of equal size </li></ul></ul><ul><ul><li>Each piece is further divided into many blocks </li></ul></ul><ul><ul><li>A piece will have a hash, needed for data integrity check </li></ul></ul><ul><ul><li>Common piece sizes are 256kb, 512kb and 1mb </li></ul></ul>
  9. 9. Tracker <ul><ul><li>Manages users participating in a torrent </li></ul></ul><ul><ul><li>Helps peers find each other </li></ul></ul><ul><ul><li>It is a HTTP service that works on port 6969 </li></ul></ul><ul><ul><li>Peers request tracker for other peers having the required pieces </li></ul></ul><ul><ul><li>Tracker responds with a list of peers that have the requested piece </li></ul></ul><ul><ul><li>A tracker can manage many torrents </li></ul></ul>
  10. 11. <ul><ul><li>HTTP GET message from a peer to a tracker has the following parameters </li></ul></ul><ul><ul><ul><li>info_hash </li></ul></ul></ul><ul><ul><ul><li>peer_id </li></ul></ul></ul><ul><ul><ul><li>uploaded </li></ul></ul></ul><ul><ul><ul><li>downloaded </li></ul></ul></ul><ul><ul><ul><li>left </li></ul></ul></ul><ul><ul><ul><li>port </li></ul></ul></ul><ul><ul><li>Response message from tracker has the following keys </li></ul></ul><ul><ul><ul><li>interval </li></ul></ul></ul><ul><ul><ul><li>tracker_id </li></ul></ul></ul><ul><ul><ul><li>peers </li></ul></ul></ul>
  11. 12. <ul><ul><li>Scraping </li></ul></ul><ul><ul><li>Querying the state of a given torrent </li></ul></ul><ul><ul><li>Tracker responds with a scrape page </li></ul></ul><ul><ul><li>Announce URL : </li></ul></ul><ul><ul><li>Scrape URL : </li></ul></ul><ul><ul><li>Scrape page has the following keys </li></ul></ul><ul><ul><ul><li>complete </li></ul></ul></ul><ul><ul><ul><li>incomplete </li></ul></ul></ul><ul><ul><ul><li>downloaded </li></ul></ul></ul>
  12. 13. Peers <ul><ul><li>Ports 6881 – 6889 are used by peers </li></ul></ul><ul><ul><li>Peers speak TCP </li></ul></ul><ul><ul><li>Following are the key strategies used by peers while sharing files </li></ul></ul><ul><ul><ul><li>Random First Piece </li></ul></ul></ul><ul><ul><ul><li>Rarest First </li></ul></ul></ul><ul><ul><ul><li>Endgame Mode </li></ul></ul></ul><ul><ul><ul><li>Peer Distribution </li></ul></ul></ul><ul><ul><ul><li>Choking </li></ul></ul></ul><ul><ul><ul><li>Optimistic Unchoking </li></ul></ul></ul>
  13. 14. <ul><ul><li>Peers perform a handshake to start the communication </li></ul></ul><ul><ul><li>Handshaking involves these messages </li></ul></ul><ul><ul><ul><li>Character 19 followed by ‘BitTorrent Protocol’ </li></ul></ul></ul><ul><ul><ul><li>20 bytes hash of the info field from metainfo file </li></ul></ul></ul><ul><ul><ul><li>20 bytes peer id </li></ul></ul></ul><ul><ul><li>Peers start talking to each other </li></ul></ul><ul><ul><li>They pass a number of messages between them to send data and control the interactions </li></ul></ul>
  14. 15. Client <ul><ul><li>Executable program running on user’s machine </li></ul></ul><ul><ul><li>Co ordinates with OS to perform read write operations </li></ul></ul><ul><ul><li>A .torrent file must be opened by the client </li></ul></ul><ul><ul><li>Peers with same client perform better </li></ul></ul>
  15. 16. Sub Protocols <ul><ul><li>Tracker HTTP Protocol (THP) </li></ul></ul><ul><ul><ul><li>Client sends GET request to tracker URL </li></ul></ul></ul><ul><ul><ul><li>Tracker responds with a dictionary having all the information </li></ul></ul></ul><ul><ul><ul><li>Client sends requests at regular intervals </li></ul></ul></ul><ul><ul><li>Peer Wire Protocol (PWP) </li></ul></ul><ul><ul><ul><li>Peers keep track of each others state </li></ul></ul></ul><ul><ul><ul><li>A state has two values, interested and choking </li></ul></ul></ul>
  16. 17. Working of BitTorrent <ul><li>1. Seeder generates a torrent file and uploads torrent to a web server. </li></ul><ul><li>2. The seeder notifies the tracker that it is sharing the file described in the torrent file. </li></ul>
  17. 18. <ul><li>3. A leecher downloads the torrent file from the web server. </li></ul><ul><li>4. The leecher connects to the tracker specified in the torrent file. </li></ul>
  18. 19. <ul><li>5. The leecher connects to its peers to retrieve pieces of the files. </li></ul>
  19. 20. Attacks on BitTorrent <ul><li>Pollution Attack </li></ul><ul><li>The peers receive the peer list from the tracker. </li></ul><ul><li>One peer contacts the attacker for a chunk of the file. </li></ul><ul><li>The attacker sends back a false chunk. </li></ul><ul><li>Attacker requests all chunks from swarm and wastes their upload bandwidth. </li></ul>
  20. 22. <ul><li>DDOS Attack </li></ul><ul><li>The attacker downloads a large number of torrent files from a web server. </li></ul><ul><li>Attacker spoofs IP address and port with that of victim and notifies the tracker </li></ul><ul><li>Tracker directs peers towards victim </li></ul><ul><li>Victim will be flooded with requests from other peers </li></ul>
  21. 24. <ul><li>Bandwidth Shaping </li></ul><ul><li>This is done by user’s ISP </li></ul><ul><li>Unencrypted BitTorrent packets are easily identified and filtered. </li></ul><ul><li>Sophisticated filtering software can detect BitTorrent like behavior. </li></ul><ul><li>Comcast has recently admitted to filtering BitTorrent traffic. </li></ul>
  22. 25. Current Solutions <ul><li>Pollution Attack </li></ul><ul><li>Blacklisting </li></ul><ul><ul><li>Achieved using software such as Peer Guardian or moBlock. </li></ul></ul><ul><ul><li>Blocks connections from blacklisted IPs which are downloaded from an online database. </li></ul></ul>
  23. 26. <ul><li>DDOS Attack </li></ul><ul><li>Spoofing needs to be avoided in the first place </li></ul><ul><li>This can be done by using filters </li></ul><ul><li>Make the tracker validate a peer whether it has the torrent or not </li></ul>
  24. 27. <ul><li>Bandwidth Shaping </li></ul><ul><li>Encryption </li></ul><ul><ul><li>Most BitTorrent clients can encrypt the packets they send. </li></ul></ul><ul><ul><li>Simple filters which simply look at the contents of the packet can easily be traversed </li></ul></ul><ul><li>Tunneling </li></ul><ul><ul><li>Using VPN software to connect to an unfiltered network. </li></ul></ul><ul><ul><li>Such tunnels which are free from filters provide easy path to BitTorrent packets </li></ul></ul>
  25. 28. Other File Transfer Methods <ul><li>Typical HTTP file transfer </li></ul><ul><li>Download Accelerator Plus (DAP) </li></ul><ul><li>Other Peer to Peer systems </li></ul><ul><ul><li>Kazaa, eDonkey, Direct Connect …. </li></ul></ul>
  26. 29. Conclusion <ul><li>BitTorrent is a popular P2P technology deployed across the Internet. </li></ul><ul><li>The protocol has found a niche as a preferred method for the decentralized distribution of large files. </li></ul><ul><li>It provides data integrity which ensures that the data will always be genuine and free from flaws. </li></ul><ul><li>BitTorrent uses tit for tat exchange to increase cooperation among peers and has developed a reputation for being efficient, scalable, and robust. </li></ul>