0% found this document useful (0 votes)
480 views35 pages

Understanding the Bittorrent Protocol

The document discusses the BitTorrent peer-to-peer file sharing protocol. It begins with an overview of what BitTorrent is and how it works. The key parts that make up the BitTorrent protocol are then explained in more detail, including torrent files, trackers, peer wire protocol, and algorithms. Limitations of the protocol and some extensions are also briefly described. The document provides technical details on the internals and mechanics of the BitTorrent protocol.

Uploaded by

Jay Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
480 views35 pages

Understanding the Bittorrent Protocol

The document discusses the BitTorrent peer-to-peer file sharing protocol. It begins with an overview of what BitTorrent is and how it works. The key parts that make up the BitTorrent protocol are then explained in more detail, including torrent files, trackers, peer wire protocol, and algorithms. Limitations of the protocol and some extensions are also briefly described. The document provides technical details on the internals and mechanics of the BitTorrent protocol.

Uploaded by

Jay Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

TM

Bittorrent
A peer to peer file sharing
protocol
So what’s the plan?

 Introduction: A Brief overview of what Bittorrent is,


how it works, its adoption and its impact on the network
 Internals: In depth survey of the parts that make up the
Bittorrent protocol. Including bencoding, torrent file,
tracker protocol, peer-wire protocol and algorithms.
 Extensions: Brief description of official and unofficial
extensions of the Bittorrent protocol.
 Conclusion
So what is Bittorrent?

 Definition: Bittorrent is a peer to peer network protocol


for sharing files over the web.
 Peer-to-peer: Users consume and provide resources
directly to other users in the network without the need of
a central entity.
 Application layer: Works on top of the TCP layer
 Advantages: Concurrent download of different parts of
the file. Share files with large number of downloaders
with minimal increase in load.
Can I see?
How does it work?

1. The file provider(seed) makes the file available


on the network
2. Peers make requests for the file.
3. Peers get pieces of the file on a rarest first basis.
4. Peers make pieces that were already downloaded
available to other peers while downloading
missing pieces
5. Once a peer has all the parts that make the file if
will become a seed
Can I see?

* The image is taken for study purpose : [Link]


What are its parts?

 Client: Piece of computer software that


implements the Bittorrent protocol. Peers are
nothing but computers running a Bittorrent client
 Tracker: Server that articulatesthe
communication between peers in the Bittorrent
network
 Torrent Files: Text file with a ”.torrent”
extension that contains metadata about a file
available on the network
 Torrent Indexes: Web service that aggregates
torrent files
How do I use it?

1. Download and install a Bittorrent Client such as:


Bittorrent, Azureus, uTorrent
2. Use a Torrent Index to find and download the Torrent
file for the desired file, such as:
 [Link]
 [Link]
 [Link]
3. Open the Torrent File with the client and start
downloading
4. Once the file is complete you may want to seed it for
a while
Who else uses it?
 Bittorrent's adoption is incredibly widespread. Its users are not
only individuals looking to download files but also organizations
that use Bittorrent in order to reduce hosting expenses.
What the network impact?

 CableLabs estimates that 18% of all broadband


traffic happens through the Bittorrent Protocol.
 CacheLogic did a study in 2004 where it concluded
that as much as 35% of all internet traffic was
carried using the Bittorrent protocol.
 The protocol also offers a challenge for network
routers that use Network Address Translation
(NAT). Most routers keep a 2000 records table
while Bittorrent client can easily make 300-500
requests per second.
Jay Patel
HTTP vs Bittorrent

 FileTransfer – single stream vs random parts


 Streaming – specific order vs random
 Uplink – depends on server bandwidth vs seeder b/w.
 Redundancy – not redundant vs can survive SPOF.
 Server Load – Complete load vs Distributed load.
 Encryption – HTTPS vs Message Stream Encryption
Bencoding

Way to specify and organize data in a tensed format.

Byte strings <string length>:<string data>


eg: 4:spam
Integers i<integer encoded in base ten ASCII>e
eg: i3e
Lists l<bencoded values>e
eg: l4:spam4:eggse == [ "spam", "eggs" ]
Dictionaries d<bencoded string><bencoded element>e
eg: d3:cow3:moo4:spam4:eggse == { "cow" => "moo", "spam" => "eggs" }
Metainfo File

To exchange files, a
Bittorrent client needs some
information about the
exchanged file(s).

This information is
contained within a file
named the “metainfo” file.

A sample torrent file


* The sample code: [Link]
Metainfo File
Peer wire Protocol
A client must maintain state information for each
connection with a remote peer.
 Choking
 Interested

• am_choking: this client is choking the peer

• am_interested: this client is interested in the peer

• peer_choking: peer is choking this client

• peer_interested: peer is interested in this client


Peer wire Protocol
Peer wire Protocol
 Handshake
 <pstrlen><pstr><reserved><info_hash><peer_id>

 Pstrlen: String length of <pstr>


 Pstr: String identifier of the protocol
 Reserved: Reserved for future expansion
 Info_hash: Info Key of metainfo(.torrent) file.
 Peer_id: Unique id for the peer.
Peer wire Protocol
 Messages
 keep-alive: <len=0000>
 choke: <len=0001><id=0>
 unchoke: <len=0001><id=1>
 interested: <len=0001><id=2>
 not interested: <len=0001><id=3>
 have: <len=0005><id=4><piece index>
 bitfield: <len=0001+X><id=5><bitfield>
 request: <len=0013><id=6><index><begin><length>
 piece: <len=0009+X><id=7><index><begin><block>
 cancel: <len=0013><id=8><index><begin><length>
 port: <len=0003><id=9><listen-port>
Torrent Download Process
Devang Shah
Limitations

Despite the wonderful success of BTP, It suffers from some


fundamental problems which called as limitations of BTP

 Content Unavaibility
 Leech Problem
 Single Point of Failure
Content Unavaibility

 BTP is Less useful for


Unpopular Content
 Consider: Publisher A
Publishing TV Shows
 Suddenly Publisher goes
offline at Some Point
 Peers Comes after initial
rush have to wait for the
content
Leech Problem

 Leech Definition: The Peer downloading as well


as Uploading
 Problem: Bit Torrent users leaves the swarm after
downloading all the require pieces.
 If all the users do like that then swarm die out,
which results into lower possibility of content
available.
Single Point of Failure

 Whole process control by the central server called


tracker
 If tracker fails whole the process goes down.
 Only those peers can exchanges the pieces which
are previously connected,
 No new peers can join the swarm or no any peer
can connect to any other peer
Algorithm

 PWP comes in the picture after the connection


established between peers
 Aim of PWP is to facilitate the communication
between the peers
 PWP does not force any standard algorithm for
that
Algorithm

 Itshould not be constructed with goal in mind to


reduce the amount of data uploaded compare to
downloaded
 Should not be strict to the Tit-For-Tat strategy
 Should be good use of both upload & download
bandwidth
 Should be cooperate with peers that implements
different algorithm
Pipelining
• When transferring data over TCP, it is critical to always
have several requests pending at once, to avoid a delay
between pieces being sent
• BitTorrent breaks pieces into sub-pieces
• At any point in time, some number, typically 5, are
requested simultaneously
• Every time a sub-piece arrives, a new request is sent
Piece Selection

 The order in which pieces are selected by different


peers is critical for good performance
 If a bad algorithm is used, we could end up in a
situation where every peer has all the pieces that
are currently available and none of the missing
ones
 If the original seed is taken down, the file cannot
be completely downloaded!
Random First Piece

 Initially,
a peer has nothing to trade
 Important to get a complete piece ASAP
 Rare pieces are typically available at fewer peers,
so downloading a rare piece initially is not a good
idea
 Policy: Select a random piece of the file and
download it
Rarest Piece First

 Policy: Determine the pieces that are most rare


among your peers and download those first
 This ensures that the most common pieces are left
till the end to download
 Rarest first also ensures that a large variety of
pieces are downloaded from the seed
Endgame Mode

 Near the end, missing pieces are requested from


every peer containing them. When the piece
arrives, the pending requests for that piece are
cancelled.
 This ensures that a download is not prevented
from completion due to a single peer with a slow
transfer rate.
 Some bandwidth is wasted, but in practice, this is
not too much.
Official Extension

 Fast Peer Extension


(i)HaveAll/HaveNone
(ii)Suggest the Pieces
(iii)Interested/Not Interested
(iv)Reject the Request
 Distributed Hash Table
Unofficial Protocol

 Azereus Messaging Protocol


 Extension Protocol
 Extension Negotiation Protocol
 Bit Torrent Location -Aware Protocol
Conclusion

 BTP may be The Next Version of Downloading


Methodology
 Works on Concept of Distributing data Load over
the Users instead of

You might also like