SlideShare a Scribd company logo
Introduction to the BitTorrent Protocol Tommy Montgomery // March 2, 2010
What is BitTorrent?
What is BitTorrent? NOT illegal
What is BitTorrent? NOT illegal Peer-to-peer (P2P) file transfer
What is BitTorrent? NOT illegal Peer-to-peer (P2P) file transfer Awesome
What is BitTorrent? NOT illegal Peer-to-peer (P2P) file transfer Awesome
Poppycock! BitTorrent historically has a bad reputation, due to its decentralized method of file transfer This makes it difficult to “remove” a download, such as one that is illegal BitTorrent is not inherently evil People are inherently evil I like bullet points
How does it work?
How does it work:  Consumer Download torrent:  lots-o-cool-stuff-n-things.lulz.torrent Open it in your favorite client:
How does it work Files are downloaded piecemeal, from many different places instead of just one Trackers are the central hub of control for each torrent Each tracker manages your “peers”, which are other people who are trying to download the same file
Glossary
Glossary Seeder
Glossary Seeder Someone who has finished downloading and is only uploading
Glossary Seeder Someone who has finished downloading and is only uploading Leecher
Glossary Seeder Someone who has finished downloading and is only uploading Leecher Someone who is downloading
Glossary Seeder Someone who has finished downloading and is only uploading Leecher Someone who is downloading Peer
Glossary Seeder Someone who has finished downloading and is only uploading Leecher Someone who is downloading Peer The collective term for seeders and leechers
What is a torrent file? A Bencoded metadata file containing information about one or more files Name/size/date of each file # of “pieces” of each file SHA1 hash of each piece Trackers for the torrent
What is a “piece”? Torrents are made up of many small pieces You never download all the pieces from one place (unless there’s only one seed) Pieces are usually less than a couple megabytes each
Bencoding Dictionaries Prefixed with “d”, end with “e” Lists Prefixed with “l”, end with “e” Integers Prefixed with “i”, end with “e” Strings Prefixed with string length + “:”
Bencoding d3:foo3:bar4:lulzi8el5:hello5:worldee
Bencoding d3:foo3:bar4:lulzi8el5:hello5:worldee ,[object Object],[object Object]
String,[object Object]
String
Integer,[object Object]
String
Integer
List,[object Object]
Trackers HTTP service that responds to GET requests Response is text/plain Bencoded dictionary Usually listens on port 6969
Tracker Announce Request Usually has a billion GET params: info_hash peer_id port uploaded downloaded left compact no_peer_id event ip numwant key trackerid
Tracker Announce Request Important GET params: info_hash the SHA1 hash of the piece to download peer_id unique identifier of the person doing the downloading ip/port the IP address and port of the peer uploaded/downloaded/left used for calculating “share ratio”, i.e. how much the tracker likes them
Tracker Announce Response A Bencoded dictionary with these keys: complete incomplete tracker id (yes, that is a space) peers warning message failure reason (only if an error occurred) interval min interval
Tracker Announce Response The relevant parts: peers Dictionary containing each peer’s IP address and port Or, if the client wants it compact, a binary string of each peer’s IP address and port interval/min interval the interval in seconds which the client is allowed to make a request complete/incomplete number of seeders/leechers
Tracker Implementation PHP/MySQL/Apache Why not?
First, of course… We need a Bencoding library. Let’s roll our own.
yay.
It’s tracker time We need a way to keep track of peers, and who’s downloaded what and stuff Let’s use MySQL
It’s tracker time Request is pretty boring, as it’s just a glorified array with error handling
It’s tracker time Response is a Bencoded dictionary, and is also a glorified array
It’s tracker time Now we can set up an exception handler that will send a proper response back in the event of a catastrophe
It’s tracker time Now we can make the tracker announce the peers
Set up the torrent Now, stuff your tracker on a server somewhere, listen on port 6969 Then add your tracker’s announce URL to a torrent e.g. http://likeaboss.biz:6969/announce
Other stuff Trackers are also facilitators and the supreme overlords over the torrents they track The list of peers that gets sent back to the client determines who downloads from whom They will use download/upload statistics to determine who isn’t uploading/seeding, and punish them by giving them crappy peers
Open source trackers OpenTracker (used by what’s left of The Pirate Bay) XBT Tracker – implemented using UDP instead of HTTP for ultimate efficiency MonoTorrent – cross-platform C# implementation (client as well) PeerTracker – PHP 5 implementation

More Related Content

What's hot

Bit Torrent presentation
Bit Torrent presentationBit Torrent presentation
Bit Torrent presentationAvula Jagadeesh
 
Bit torrent-technology
Bit torrent-technologyBit torrent-technology
Bit torrent-technology
abhipesit
 
Bit torrent protocol by milan varia
Bit torrent protocol by milan variaBit torrent protocol by milan varia
Bit torrent protocol by milan varia
Milan Varia
 
Bit torrent Technology ppt
Bit torrent Technology pptBit torrent Technology ppt
Bit torrent Technology ppt
Akshay K Sajan
 
Torrent
TorrentTorrent
UNRAVEILING BIT-TORRENT
UNRAVEILING BIT-TORRENTUNRAVEILING BIT-TORRENT
UNRAVEILING BIT-TORRENT
Sudhansu Dash
 
Bit Torrent
Bit Torrent Bit Torrent
Bit Torrent
Ashish Kumar
 
Bit torrent
Bit torrentBit torrent
Bit torrent
Sonja Kristiansen
 
Torrent Protocol
Torrent ProtocolTorrent Protocol
Torrent ProtocolHarsht2888
 
Bittorrent
BittorrentBittorrent
Bittorrent
sonangrai
 
Bit torrent protocol
Bit torrent protocolBit torrent protocol
Bit torrent protocol
Karwan Jacksi
 
Bit torrent seminar
Bit torrent seminarBit torrent seminar
Bit torrent seminarbalu0503
 
Bit Torrent Protocol Report
Bit Torrent Protocol ReportBit Torrent Protocol Report
Bit Torrent Protocol Report
SridharBR
 
Torrent technology
Torrent technologyTorrent technology
Torrent technology
Harsh Malpani
 
Bittorrent final seminar
Bittorrent final seminarBittorrent final seminar
Bittorrent final seminar
Chirodeep Das
 
Bit torrent documentation
Bit torrent documentationBit torrent documentation
Bit torrent documentationAvula Jagadeesh
 
Torrent Seminar inc.- working, terms, details
Torrent Seminar inc.- working, terms, detailsTorrent Seminar inc.- working, terms, details
Torrent Seminar inc.- working, terms, details
Mayur Kathale
 
BitTorrent Seminar Report
BitTorrent Seminar ReportBitTorrent Seminar Report
BitTorrent Seminar Report
Masood Alam Shaikh
 
Torrents
TorrentsTorrents
Torrents
Ahmad0Muhammad
 

What's hot (20)

Bit Torrent presentation
Bit Torrent presentationBit Torrent presentation
Bit Torrent presentation
 
Bit torrent-technology
Bit torrent-technologyBit torrent-technology
Bit torrent-technology
 
Bit torrent protocol by milan varia
Bit torrent protocol by milan variaBit torrent protocol by milan varia
Bit torrent protocol by milan varia
 
Bit torrent Technology ppt
Bit torrent Technology pptBit torrent Technology ppt
Bit torrent Technology ppt
 
Torrent
TorrentTorrent
Torrent
 
UNRAVEILING BIT-TORRENT
UNRAVEILING BIT-TORRENTUNRAVEILING BIT-TORRENT
UNRAVEILING BIT-TORRENT
 
Bit Torrent
Bit Torrent Bit Torrent
Bit Torrent
 
Bit torrent
Bit torrentBit torrent
Bit torrent
 
Torrent Protocol
Torrent ProtocolTorrent Protocol
Torrent Protocol
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bit torrent protocol
Bit torrent protocolBit torrent protocol
Bit torrent protocol
 
Bit torrent seminar
Bit torrent seminarBit torrent seminar
Bit torrent seminar
 
Bit Torrent Protocol Report
Bit Torrent Protocol ReportBit Torrent Protocol Report
Bit Torrent Protocol Report
 
Torrent technology
Torrent technologyTorrent technology
Torrent technology
 
Bittorrent final seminar
Bittorrent final seminarBittorrent final seminar
Bittorrent final seminar
 
Bit torrent documentation
Bit torrent documentationBit torrent documentation
Bit torrent documentation
 
Torrent Seminar inc.- working, terms, details
Torrent Seminar inc.- working, terms, detailsTorrent Seminar inc.- working, terms, details
Torrent Seminar inc.- working, terms, details
 
BitTorrent Seminar Report
BitTorrent Seminar ReportBitTorrent Seminar Report
BitTorrent Seminar Report
 
Torrents
TorrentsTorrents
Torrents
 

Similar to Introduction to the Bittorrent Protocol

The big book of bit torrent
The big book of bit torrentThe big book of bit torrent
The big book of bit torrentgkmv
 
Bit torrent protocol seminar by Sanjay R
Bit torrent protocol seminar by Sanjay RBit torrent protocol seminar by Sanjay R
Bit torrent protocol seminar by Sanjay RSanjay Ravishankar
 
Aditya Pathak
Aditya PathakAditya Pathak
Aditya Pathak
Aditya Pathak
 
P2P: Grid-oriented Distribution Systems
P2P: Grid-oriented Distribution SystemsP2P: Grid-oriented Distribution Systems
P2P: Grid-oriented Distribution SystemsLorin Olsen
 
Bittorrent_project_Srikanth_Vanama
Bittorrent_project_Srikanth_VanamaBittorrent_project_Srikanth_Vanama
Bittorrent_project_Srikanth_Vanama
Srikanth Vanama
 
(130316) #fitalk bit torrent protocol
(130316) #fitalk   bit torrent protocol(130316) #fitalk   bit torrent protocol
(130316) #fitalk bit torrent protocol
INSIGHT FORENSIC
 
Bit torrent protocol
Bit torrent protocolBit torrent protocol
Bit torrent protocol
D bipul lomga
 
Bittorrent
BittorrentBittorrent
Bittorrent
Renuka Raj
 
Bittorrent
BittorrentBittorrent
Bittorrent
Renuka Raj
 
Bittorrent
BittorrentBittorrent
Bittorrent
suman2010
 
Bit torrent and tracker
Bit torrent and trackerBit torrent and tracker
Bit torrent and tracker
Dikshant Patodia
 
P2P Seminar
P2P SeminarP2P Seminar
P2P SeminarCoRehab
 
Bittorrent
BittorrentBittorrent
Bittorrent
Anush Shenoy
 
Bit torrent
Bit torrentBit torrent
Bit torrent by SANDA SOLUTIONS
Bit torrent by SANDA SOLUTIONSBit torrent by SANDA SOLUTIONS
Bit torrent by SANDA SOLUTIONSssanda3
 
BitTorrent.pdf
BitTorrent.pdfBitTorrent.pdf
BitTorrent.pdf
IshanKathpal
 
Bit Torrent Protocol
Bit Torrent ProtocolBit Torrent Protocol
Bit Torrent ProtocolAli Habeeb
 

Similar to Introduction to the Bittorrent Protocol (20)

The big book of bit torrent
The big book of bit torrentThe big book of bit torrent
The big book of bit torrent
 
Bit torrent protocol seminar by Sanjay R
Bit torrent protocol seminar by Sanjay RBit torrent protocol seminar by Sanjay R
Bit torrent protocol seminar by Sanjay R
 
Aditya Pathak
Aditya PathakAditya Pathak
Aditya Pathak
 
P2P: Grid-oriented Distribution Systems
P2P: Grid-oriented Distribution SystemsP2P: Grid-oriented Distribution Systems
P2P: Grid-oriented Distribution Systems
 
Bittorrent_project_Srikanth_Vanama
Bittorrent_project_Srikanth_VanamaBittorrent_project_Srikanth_Vanama
Bittorrent_project_Srikanth_Vanama
 
(130316) #fitalk bit torrent protocol
(130316) #fitalk   bit torrent protocol(130316) #fitalk   bit torrent protocol
(130316) #fitalk bit torrent protocol
 
Bit torrent protocol
Bit torrent protocolBit torrent protocol
Bit torrent protocol
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bit torrent and tracker
Bit torrent and trackerBit torrent and tracker
Bit torrent and tracker
 
P2P Seminar
P2P SeminarP2P Seminar
P2P Seminar
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bit torrent
Bit torrentBit torrent
Bit torrent
 
Bittorrent
BittorrentBittorrent
Bittorrent
 
Bit torrent by SANDA SOLUTIONS
Bit torrent by SANDA SOLUTIONSBit torrent by SANDA SOLUTIONS
Bit torrent by SANDA SOLUTIONS
 
Peer to Peer networks and piracy
Peer to Peer networks and piracyPeer to Peer networks and piracy
Peer to Peer networks and piracy
 
BitTorrent.pdf
BitTorrent.pdfBitTorrent.pdf
BitTorrent.pdf
 
Bit Torrent Protocol
Bit Torrent ProtocolBit Torrent Protocol
Bit Torrent Protocol
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

Introduction to the Bittorrent Protocol

  • 1. Introduction to the BitTorrent Protocol Tommy Montgomery // March 2, 2010
  • 3. What is BitTorrent? NOT illegal
  • 4. What is BitTorrent? NOT illegal Peer-to-peer (P2P) file transfer
  • 5. What is BitTorrent? NOT illegal Peer-to-peer (P2P) file transfer Awesome
  • 6. What is BitTorrent? NOT illegal Peer-to-peer (P2P) file transfer Awesome
  • 7. Poppycock! BitTorrent historically has a bad reputation, due to its decentralized method of file transfer This makes it difficult to “remove” a download, such as one that is illegal BitTorrent is not inherently evil People are inherently evil I like bullet points
  • 8. How does it work?
  • 9. How does it work: Consumer Download torrent: lots-o-cool-stuff-n-things.lulz.torrent Open it in your favorite client:
  • 10. How does it work Files are downloaded piecemeal, from many different places instead of just one Trackers are the central hub of control for each torrent Each tracker manages your “peers”, which are other people who are trying to download the same file
  • 13. Glossary Seeder Someone who has finished downloading and is only uploading
  • 14. Glossary Seeder Someone who has finished downloading and is only uploading Leecher
  • 15. Glossary Seeder Someone who has finished downloading and is only uploading Leecher Someone who is downloading
  • 16. Glossary Seeder Someone who has finished downloading and is only uploading Leecher Someone who is downloading Peer
  • 17. Glossary Seeder Someone who has finished downloading and is only uploading Leecher Someone who is downloading Peer The collective term for seeders and leechers
  • 18. What is a torrent file? A Bencoded metadata file containing information about one or more files Name/size/date of each file # of “pieces” of each file SHA1 hash of each piece Trackers for the torrent
  • 19. What is a “piece”? Torrents are made up of many small pieces You never download all the pieces from one place (unless there’s only one seed) Pieces are usually less than a couple megabytes each
  • 20. Bencoding Dictionaries Prefixed with “d”, end with “e” Lists Prefixed with “l”, end with “e” Integers Prefixed with “i”, end with “e” Strings Prefixed with string length + “:”
  • 22.
  • 23.
  • 25.
  • 28.
  • 29. Trackers HTTP service that responds to GET requests Response is text/plain Bencoded dictionary Usually listens on port 6969
  • 30. Tracker Announce Request Usually has a billion GET params: info_hash peer_id port uploaded downloaded left compact no_peer_id event ip numwant key trackerid
  • 31. Tracker Announce Request Important GET params: info_hash the SHA1 hash of the piece to download peer_id unique identifier of the person doing the downloading ip/port the IP address and port of the peer uploaded/downloaded/left used for calculating “share ratio”, i.e. how much the tracker likes them
  • 32. Tracker Announce Response A Bencoded dictionary with these keys: complete incomplete tracker id (yes, that is a space) peers warning message failure reason (only if an error occurred) interval min interval
  • 33. Tracker Announce Response The relevant parts: peers Dictionary containing each peer’s IP address and port Or, if the client wants it compact, a binary string of each peer’s IP address and port interval/min interval the interval in seconds which the client is allowed to make a request complete/incomplete number of seeders/leechers
  • 35. First, of course… We need a Bencoding library. Let’s roll our own.
  • 36.
  • 37. yay.
  • 38. It’s tracker time We need a way to keep track of peers, and who’s downloaded what and stuff Let’s use MySQL
  • 39.
  • 40. It’s tracker time Request is pretty boring, as it’s just a glorified array with error handling
  • 41. It’s tracker time Response is a Bencoded dictionary, and is also a glorified array
  • 42.
  • 43. It’s tracker time Now we can set up an exception handler that will send a proper response back in the event of a catastrophe
  • 44. It’s tracker time Now we can make the tracker announce the peers
  • 45.
  • 46.
  • 47. Set up the torrent Now, stuff your tracker on a server somewhere, listen on port 6969 Then add your tracker’s announce URL to a torrent e.g. http://likeaboss.biz:6969/announce
  • 48. Other stuff Trackers are also facilitators and the supreme overlords over the torrents they track The list of peers that gets sent back to the client determines who downloads from whom They will use download/upload statistics to determine who isn’t uploading/seeding, and punish them by giving them crappy peers
  • 49. Open source trackers OpenTracker (used by what’s left of The Pirate Bay) XBT Tracker – implemented using UDP instead of HTTP for ultimate efficiency MonoTorrent – cross-platform C# implementation (client as well) PeerTracker – PHP 5 implementation
  • 50. In short… Unless you want to implement some weird rules for who gets to download stuff, don’t write your own. I only did it for fun. Because it’s fun.