2. Outline
Introduction
Origin of the protocol
Common Terminologies
Usages
How to practically use it?
Protocol Formats
Security/Performance issues.
Conclusion and References
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 2 / 25
3. Introduction
❖ BitTorrent is a communication protocol.
❖ Used for peer-to-peer(P2P) file sharing.
❖ Responsible for moving a significant percentage of the world’s
Internet traffic each day.
❖ Best way to share large or popular files.
❆ e.g. Movies, games, etc.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 3 / 25
4. Origin of The Protocol
❂ BitTorrent was created and released in 2001 by Bram Cohen.
❂ An American computer programmer who was frustrated by the long
download times that he experienced using applications such as FTP.
❂ It was first written in Python, and was free software.
❂ The first release of the BitTorrent client had no search engine and no
peer exchange.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 4 / 25
6. Swarm
Together, all peers (including seeds) sharing a torrent are called a
swarm.
BitTorrent may sometimes display a swarm number that has no
relation to the number of seeds and peers you are connected to or
who are available.
E.g. it may show 5 out of 10 connected peers, 20 out of 100 connected
seeds, and a swarm of 3.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 6 / 25
7. Peers
Peer is someone who is both downloading and uploading the file in
the swarm.
Files are downloaded in pieces. When a user downloads some pieces,
he then automatically starts uploading it.
A file will be downloaded faster if more people are involved in the
swarm.
A peer becomes a ”seed” when he has completed 100% of the file
and wishes to continue uploading.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 7 / 25
8. Seeds
A seed is a user who has 100% of a file and is sharing it for other
users to download.
After a torrent job finishes downloading, if you leave the torrent job
seeding, it uploads the file(s) to other peers.
It is recommended that we should share the file(s) until the amount
of data you upload reaches at least the same as the amount of data
that you have download, also known as reaching a 1.0 ratio
Peers who leave the swarm before even getting close to this ratio are
called ”leechers”.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 8 / 25
9. Leechers
Leechers only download the parts of file they don’t have.
They don’t upload anything that they have already downloaded.
They also put an upload limit on their torrent clients preventing other
peers from downloading anything from their ”clients”.
The term leech also refers to a peer (or peers) that has a negative
effect on the swarm by having a very poor share ratio.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 9 / 25
10. Clients
It is a desktop application that initiates, truncates and manages the
downloading and uploading of data using BitTorrent file-sharing
protocol.
A BitTorrent client is any program that implements the BitTorrent
protocol.
Each client is capable of preparing, requesting and transmitting any
type of computer file over the internet, using this protocol.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 10 / 25
11. Torrent
Torrent refers to a computer file that contains metadata holding
various information.
A torrent file normally comes with the extension ”.torrent”.
It does not contain the actual contents to be distributed.
This file will then be used by a BitTorrent software such as uTorrent,
or BitTorrent which essentially allows for users to easily download
torrent files to their personal computers.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 11 / 25
12. Trackers
A BitTorrent tracker is a special type of server that assists in the
communication between peers using the BitTorrent protocol.
The ”tracker” server keeps track of where file copies reside on peer
machines, Which ones are available at time of the client request.
Helps in coordinating the efficient transmission and reassembly of the
copied file.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 12 / 25
13. Protocol Formats
Tracker GET requests have the following keys:-
info-hash
The info-hash must be the hash of the encoded form as found in the
.torrent file, which is identical to bdecoding the metainfo file,
extracting the info dictionary and encoding it if and only if the
bdecoder fully validated the input.
Clients must either reject invalid metainfo files or extract the substring
directly. They must not perform a decode-encode roundtrip on invalid
data.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 13 / 25
14. Contd..
peer-id
A string of length 20 which this downloader uses as its id. Each
downloader generates its own id at random at the start of a new
download. This value will also almost certainly have to be escaped.
ip
An optional parameter giving the IP (or dns name) which this peer is
at. Generally used for the origin if it’s on the same machine as the
tracker.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 14 / 25
15. Contd..
port
The port number this peer is listening on. Common behavior is for a
downloader to try to listen on port 6881 and if that port is taken try
6882, then 6883, etc. and give up after 6889.
uploaded
The total amount uploaded so far, encoded in base ten ascii.
downloaded
The total amount downloaded so far, encoded in base ten ascii.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 15 / 25
16. Contd..
left
The number of bytes this peer still has to download, encoded in base
ten ascii.
This data can’t be computed from downloaded and the file length since
it might be a resume, and there’s a chance that some of the
downloaded data failed an integrity check and had to be re-downloaded.
event
This is an optional key which maps to started, completed, or stopped.
If not present, this is one of the announcements done at regular
intervals.
An announcement using started is sent when a download first begins,
and one using completed is sent when the download is complete.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 16 / 25
17. Usage
Distributing Any Large Data.
Facebook and Twitter both use BitTorrent internally to move files
around.
Downloading Speed is directly proportional to the number of
seeds/peers.
In 2010, the UK government released several large data sets showing
how public money was being spent, via BitTorrent.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 17 / 25
18. How to practically use it ?
To start serving, a host goes through the following steps:
Start running a tracker.
Start running an ordinary web server, such as apache, or have one
already.
Associate the extension ”.torrent” with mimetype
application/x-bittorrent on their web server.
Generate a metainfo (.torrent) file using the complete file to be
served and the URL of the tracker.
Put the metainfo file on the web server.
Link to the metainfo (.torrent) file from some other web page.
Start a downloader which already has the complete file.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 18 / 25
19. Contd..
To start downloading, a user does the following:
Install BitTorrent.
Surf the web.
Click on a link to a .torrent file.
Select where to save the file locally, or select a partial download to
resume.
Wait for download to complete.
Tell downloader to exit after you are done seeding.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 19 / 25
20. Security/Performance Issues
Attacks on BitTorrent :-
✼ Pollution Attack
The peers receive the peer list from the tracker.
One peer contacts the attacker for a chunk of the file.
The attacker sends back a false chunk.
Attacker requests all chunks from swarm and wastes their upload
bandwidth.
Solution:-
✼ Blacklisting:-
Achieved using software such as Peer Guardian or moBlock.
Blocks connections from blacklisted IPs which are downloaded from an
online database.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 20 / 25
22. Security/Performance Issues
✼ DDOS Attack:-
The attacker downloads a large number of torrent files from a web
server.
Attacker spoofs IP address and port with that of victim and notifies the
tracker.
Tracker directs peers towards victim
Victim will be flooded with requests from other peers
✼ Solution:-
Spoofing needs to be avoided in the first place.
This can be done by using filters
Make the tracker validate a peer whether it has the torrent or not
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 22 / 25
23. Security/Performance Issues
✼ Bandwidth Shaping:-
This is done by user’s ISP
Unencrypted BitTorrent packets are easily identified and filtered.
Sophisticated filtering software can detect BitTorrent like behavior
Comcast has recently admitted to filtering BitTorrent traffic.
✼ Solution:-
Encryption:-
Most BitTorrent clients can encrypt the packets they send.
Simple filters which simply look at the contents of the packet can easily
be traversed
Tunneling:-
Using VPN software to connect to an unfiltered network.
Such tunnels which are free from filters provide easy path to BitTorrent
packets
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 23 / 25
24. Conclusion
BitTorrent is a popular P2P technology deployed across the Internet.
The protocol has found a niche as a preferred method for the
decentralized distribution of large files.
It provides data integrity which ensures that the data will always be
genuine and free from flaws.
BitTorrent uses tit for tat exchange to increase cooperation among
peers and has developed a reputation for being efficient, scalable, and
robust.
Ishan Kathpal (CURAJ) BitTorrent April 11, 2022 24 / 25