370 likes | 585 Views
BitTorrent. Overview. P2P VOD Workshop Spring 2011 Hanoch Levy Based on presentations by Evgeny Vainer 2009, Alexey Zagalsky 2010. Based on. The Delicate Tradeoffs in BitTorrent-Like File Sharing Protocol Design [by Bin Fan, Dah-Ming Chiu, John C.S. Lui] Wikipedia
E N D
BitTorrent Overview P2P VOD Workshop Spring 2011 Hanoch Levy Based on presentations by Evgeny Vainer 2009, Alexey Zagalsky 2010
Based on • The Delicate Tradeoffs in BitTorrent-Like File Sharing Protocol Design [by Bin Fan, Dah-Ming Chiu, John C.S. Lui] • Wikipedia • slides from “Introduction to BitTorent” by Arvid Norberg • Internet
Agenda • P2P • what and why • BitTorrent • how does it work • Peer Selection • speed vs fairness • network load issues
Client Server File sharing • one server provides the service • many clients consuming it • problems: • server’s resources • single point of failure • legality
Peer to Peer File sharing • many clients consume the service • each client also provides a little part of the service • one server that coordinates the peers • overlay network
Peer to Peer File sharing advantages: • more peers in network, the better the service they receive (?) • robustness • scalability • has no owner
Peer to Peer File sharing disadvantages: • clients are small and not efficient (upload cap) • coordinating the clients • selfishness and leeching
BitTorrent • free P2P protocol • created by Bram Cohenat 2001 [www.bittorrent.org] • tens of client applications • millions of users • terabytes of data • about 20% of today’s Internet traffic • 80% of internat traffic is P2P….
BitTorrent the main entities defined by the protocol are: • peer– instance of a BitTorrent client to which other clients connect and transfer data • tracker – the server which coordinates the communication between the peers • torrent– metadata file describing some downloadable content. It also contains the address of a tracker • swarm - all the peers sharing the sametorrent • chunk – a piece of data a transferred file is divided to • Terms: • Leecher – did not complete download • Seeder – completed its download. Serves as a server (“altruist”)
How It Works The file to be distributed is split up in pieces and a SHA-1 hash is calculated for each piece
How It Works • A metadata file (.torrent) is distributed to all peers • Usually via Web, Email, etc… • The metadata contains: • SHA-1 hashes of all pieces • Tracker reference (URL) • Piece Length: usually 256KB • is it better smaller or bigger pieces ?
How It Works The user makes the file itself available through a BitTorrent node acting as a seed The Tracker is a central server keeping a list of all peers participating in the swarm A swarm is the set of peers that are participating in distributing the same file A peer joins a swarm by asking the tracker for a peer list and connects to those peers
Terminology • A downloader is any peer that does not have the entire file and is downloading the file • A leecher is: (ambiguity in definition…) • A peer who has a negative effect on the swarm by having a very poor share ratio • A downloader • A seeder is a peer that has an entire copy of the torrent and offers it for upload
Goals • Efficiency • Ability to download from many peers yields fast downloads • Minimize piece overlap among peers • Download random pieces • Rarest Firstalgorithm • Reliability • Tolerant to dropping peers • Ability to verify data integrity (SHA-1 hashes)
How it works: Trading • Exactly like Kid’s card trading • Two major factors in trading: • What I want to get (from whom) • To whom I want to give?
What I want to take: Rarest First The piece picking algorithm used in BitTorrent is called Rarest First Serves me: 1) have a rare piece (hard to get), 2) everyone will want me… Serves the community: maximizes the distributed copies, maximizes the availability of the rarest pieces Picks a random piece from the set of rarest pieces No peer has global knowledge of piece availability, it is approximated by the availability among neighbors
To whom to give: Incentive to Share Policies to determine to whom to send data: • Tit-for-Tat • Upload to whoever uploads the most to you • "Survival of the fittest“ • Theoretically increases performance by encouraging fast peers to upload to you and giving them even more pieces to upload to others • May result in suboptimal situations • Optimistic Unchoking • In hope of discovering better partners • To ensure that newcomers get a chance to join the swarm
Tit-for-tat as Incentive to Upload • Want to encourage all peers to contribute • Peer A is said to choke peer B if it (A) decides not to upload to B • Each peer (say A) unchokes at most 4 interested peers at any time • The three with the largest upload rates to A • Where the tit-for-tat comes in • Another randomly chosen (Optimistic Unchoke) • To periodically look for better choices
BitTorrent No problema. The peers p1, .. pn are in your swarm I want to join the swarm of file hash1
BitTorrent I have chunk 1 Hey, what chunks of hash1 do you have I have chunk 3
BitTorrent Here it is 10… Give me the 1st chunk Give me the 3rd chunk Here it is 11…
BitTorrent Hey, I now have the 3rd chunk
BitTorrent • client exchanges data with tracker sending its download statistics and receiving new peers • the only way for client to discover new peers is to query the tracker • some recent modifications tries to solve this problem by using: • PEX – peer exchange extension • DHT – distributed hash table
BitTorrent from the point of view of some particular peer (client) other peers can be: • interested – peer who wants to download some chunks from the client • choked – peer to whom the client refuses to send the chunks
BitTorrent • each peer stores some data for all the other peer in the swarm • data transfer happens if some peer is interested && unchoked
BitTorrent • tit – for – tat strategy • each 10 seconds four interested peers with the best rate are unchoked • INCREASE NETWORK THROUGHPUT (performance) • optimistic unchoking strategy • each 30 seconds one random interested peer is unchocked • GIVE SOME DATA TO SOME OTHER CLIENTS (FAIRNESS)
Video on Demand (Vod) • Suppose all cients want to download a VoD movie • In general – want to download a file (“same” like bittorrent..) • However – wants to watch the file ASAP • So: Want to get the pieces “in order” , or “get earliest first” • STRICT IN ORDER Policy: Client downloads the pieces according to order • This may slowdown the whole torrent …
Video on Demand (2) • Mixed Policy: • Combine Rarest First with Strict in Order • Allows getting ordered pieces (Vod) while giving some advantage to rare (Bandwidht)
Breaking the politeness: Selfishness • Client is not “polite” or “honest” • Want to get a big share from the system without contributing much • (“tit for nothing”) • Don’t be altruist and pray others do • Live in environment where you cannot contribute much • (e.g poor country with low upload capacity, or prevent bittorrent upload legaly) • Your ISP charges you on upload capacity 41
Breaking the politeness: Selfishness • Can one get better download than others? • Can one get good download without upload? 42
Breaking the politeness: Selfishness • Can one get better download than others? • Can one get good download without upload? • Bitthief: “A free riding bittorrent client” • ETH Zurich • Get good download without uploading • http://www.dcg.ethz.ch/projects/bitthief/ • Bittyrant: • University of Washington and University of Massachusetts Amherst • Increase your download capacity (on the account of non bittyrant clients) • As a strategic client, it has demonstrated an average increase in download speed by 70% over a standard BitTorrent client. Non-BitTyrant leechers in the swarm generally receive a decrease in download speed. 43