Presentation is loading. Please wait.

Presentation is loading. Please wait.

Angelo Sapello University of Delaware

Similar presentations


Presentation on theme: "Angelo Sapello University of Delaware"— Presentation transcript:

1 Angelo Sapello University of Delaware sapello@udel.edu
BitTorrent Angelo Sapello University of Delaware

2 Server vs. P2P Standard client/server model – all clients connect to a single server Peer to peer (P2P) – clients get the data they need from one or more other clients P2P may still require a server, but with a greatly reduced load

3 BitTorrent Terminology
Torrent file – the meta-data file indicating what tracker to connect to and what the file should look like Tracker – an HTTP server that keeps track of the swarm Swarm – the group of peers downloading/uploading the file Seeder – A peer that has all the pieces of the file Leecher – A peer that only downloads

4 BitTorrent model User downloads a meta-data “torrent” file
Peer connects to tracker server to get peer information Peer connects to other peers in the swarm Peer downloads pieces in a rarest first fashion Peer simultaneously uploads pieces to other peers Model defined by Bram Cohen

5 BitTorrent Transport Layer
BitTorrent is a three part application layer protocol TCP provides all transport layer services Reliable: No need for ACKs by client Connection oriented: Minimal client handshakes Down-side: Multiple connections cause “fairness” issues Multiple port usage causes NAT/firewall clogging

6 Initial Seeder/Web Server: 142.178.26.3:62189
Sally: :53182 Bobbi (Leecher): :52516 Allen: :53182 Angelo: :55103 Linda (Seeder): :57812 Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Initial Seeder/Web Server: :62189

7 Initial Seeder/Web Server: 142.178.26.3:62189 Uninterested Choked
Sally: :53182 Uninterested Choked Bobbi (Leecher): :52516 Uninterested Choked Allen: :53182 Uninterested Choked Angelo: :55103 Uninterested Choked Linda (Seeder): :57812 Uninterested Choked Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Angelo: :55103 Initial Seeder/Web Server: :62189 Uninterested Choked

8 Initial Seeder/Web Server: 142.178.26.3:62189 Uninterested Choked
Sally: :53182 Uninterested Unchoked Bobbi (Leecher): :52516 Uninterested Choked Allen: :53182 Uninterested Unchoked Angelo: :55103 Interested Choked Linda (Seeder): :57812 Uninterested Unchoked Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Angelo: :55103 Initial Seeder/Web Server: :62189 Uninterested Choked

9 Initial Seeder/Web Server: 142.178.26.3:62189 Uninterested Choked
Sally: :53182 Interested Unchoked Bobbi (Leecher): :52516 Uninterested Choked Allen: :53182 Uninterested Unchoked Angelo: :55103 Interested Unchoked Linda (Seeder): :57812 Uninterested Unchoked Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Angelo: :55103 Initial Seeder/Web Server: :62189 Uninterested Choked

10 Initial Seeder/Web Server: 142.178.26.3:62189 Uninterested Choked
Sally: :53182 Interested Unchoked Bobbi (Leecher): :52516 Uninterested Choked Allen: :53182 Uninterested Unchoked Angelo: :55103 Interested Unchoked Linda (Seeder): :57812 Uninterested Unchoked Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Angelo: :55103 Initial Seeder/Web Server: :62189 Uninterested Choked

11 Initial Seeder/Web Server: 142.178.26.3:62189 Uninterested Choked
Sally: :53182 Interested Unchoked Bobbi (Leecher): :52516 Uninterested Choked Allen: :53182 Uninterested Unchoked Angelo: :55103 Uninterested Unchoked Linda (Seeder): :57812 Uninterested Unchoked Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Angelo: :55103 Initial Seeder/Web Server: :62189 Uninterested Choked

12 Initial Seeder/Web Server: 142.178.26.3:62189
Sally: :53182 Bobbi (Leecher): :52516 Allen: :53182 Angelo: :55103 Linda (Seeder): :57812 Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Angelo: :55103 Initial Seeder/Web Server: :62189

13 Initial Seeder/Web Server: 142.178.26.3:62189
Sally: :53182 Bobbi (Leecher): :52516 Allen: :53182 Angelo: :55103 Linda (Seeder): :57812 Tracker: /mytorrent: Linda: :57812 Bobbi: :52516 Mandriva: :62189 Sally: :53182 Allen: :49552 Initial Seeder/Web Server: :62189

14 Meta-data format Information bencoded
String “#:” ; any array of characters Integer “i” - “e” ; a signed integer Dictionary “d” - “e” ; key-value pairs List “l” - “e” ; an array of the above types Announce section – tracker information Info section – file and pieces information Pieces – a list of SHA-1 hash values of data chunks in the files

15 Meta-data file (cont'd)
Multiple files are ordered and concatenated to download like a single file Example: d8:announce96: 4133c0cb8a59ca4bb2d203be13:creation datei e4:infod5:filesld6:lengthi341985e4:pathl35:mandriva-linux-free i586.idxeed6:lengthi e4:pathl35:mandriva-linux-free i586.isoeed6:lengthi70e4:pathl39:mandriva-linux-free i586.iso.md5eed6:lengthi78e4:pathl40:mandriva-linux-free i586.iso.sha1eee4:name31:mandriva-linux-free i58612:piece lengthi262144e6:pieces349160: To {“announce”:” 133c0cb8a59ca4bb2d203be”,”creation date”: , “info”:{“files”:[{“length”:341985,”path”:[“mandriva-linux-free i586.idx”]}, {“length”: ,”path”:[“mandriva-linux-free i586.iso”]}, {“length”:70,”path”:[“mandriva-linux-free i586.iso.md5”]}, {“length”:78,”path”:[“mandriva-linux-free i586.iso.sha1”]}], “name”:”mandriva-linux-free i586”,”piece length”:262144,”pieces”: Binary array of 20 byte SHA-1 hash codes of each 256KB data chunk }}

16 Peace of mind How do you ensure that a peer has not tainted the piece?
SHA-1 hash algorithm proposed by NSA requires 2^80 hash operations to find a match pair by brute force. Mathematically broken in 2^63 operations. Poisoned pieces are rejected and peer is no longer recognized as part of the swarm

17 Tracker protocol Standard HTTP GET request/response Example:
GET /announce/Mandrivalinux/282cb77c390627c44133c0cb8a59ca4bb2d203be?info_hash=%06g%e0g%98%a f%beN%f2%f6%40E%ad%0a%23U%dd%5d%d4%ba&peer_id=M %afF%3bE%b8%c9%2b%94%f1%ac%bf%93&port=57917&uploaded=0&downloaded=0&left= &corr upt=0&key=66D4D19D&event=started&numwant=200&compact=1&no_peer_id=1&ipv6=2002%3a80af%3ae e1e%3a%3a80af%3aee1e HTTP/1.1 Host: torrent.mandriva.com:6969 User-Agent: BitTorrent/6400(18095) Accept-Encoding: gzip HTTP/ OK Content-Length: 1230 Content-Type: text/plain Pragma: no-cache d8:intervali1800e5:peers1200: Binary encoded IP address, port number pairs for the entire (or subset of the) swarm or beconded dictionary or Peer ID, IP address, port triplets

18 BitTorrent protocol BitTorrent Handshake All other messages
Protocol Name Length (1-byte = 19) Protocol Name (“BitTorrent protocol”) 64-bit reserved word Info dictionary hash (SHA1 20-bytes) Peer ID (20 bytes) All other messages Message length (32-bits/4-bytes) Message ID (8-bits/1-byte) Payload (Message length – 1 bytes)

19 BitTorrent Message IDs
None (len = 0): Keep Alive 0: Choke = Not willing to send data 1: Unchoke = Willing to send data 2: Interested = Would like data 3: Not interested = Would not like data 4: Have = I have just downloaded this piece 5: Bitfield = I have these pieces 6: Request = I would like this block – index (piece), begin(offset) and length 7: Piece = Here is a block – index (piece), begin(offset) and block (actual data) 8: Cancel = I no longer want this block – index, begin, length

20 Wireshark Example

21 Other issues Leeching Firewall/NAT crashing
Connection throttling (Comcast) Copyright protection

22 Questions? Additional resources BitTorrent Specification:
BitTorrent Unofficial Explanation:


Download ppt "Angelo Sapello University of Delaware"

Similar presentations


Ads by Google