BitTorrent protocol
P2P file distribution: BitTorrent
Copyright By PowCoder代写 加微信 powcoder
authored by (2001), initially in Python, then in C++
The key to scalable and robust distribution is cooperation among users.
File sharing is greatly enhanced using a simple strategy: while a file is being downloaded, it is also being uploaded to others at the same time
The more you give to others, the more that you will receive. (“Give and ye shall receive!”)
Each new participant brings not only demand, but also supply. Consequently, this brings limitless scalability for a nearly fixed cost.
Protocol Definition: http://www.bittorrent.org/beps/bep_0000.html
P2P file distribution: BitTorrent
General idea: allow downloading of the same file from multiple sources
file divided into equal-size chunks
peers in torrent send/receive file chunks
Typically 256Kb chunk
torrent: group of peers exchanging chunks of a particular file
Large File
Application Layer 2-3
1. Find a torrent of interest from the web, download it, then open using a BitTorrent client.
2. The torrent file contains the URL of the tracker(s), cryptographic hash codes, list of files, other meta data.
3. Connect to tracker(s), then obtain a subset of active peers (IP addresses) sharing the file.
4. Connect concurrently to active peers, request for a list of chunks, then start downloading chunks.
256Kb chunk
torrent: group of peers participating in the distribution of a particular file.
An SHA-1 hash code for each chunk is stored in a torrent file. This is used for integrity verification.
Application Layer 2-4
P2P file distribution: BitTorrent
What happens when a new peer joins a torrent?
tracker: tracks peers participating in torrent
torrent: group of peers exchanging chunks of a file
Alice arrives …
Peers periodically informs the tracker of their presence.
registers with tracker
… obtains list
of peers from tracker
…connects (concurrent TCP) to subset of peers (“neighbors”)
… and begins exchanging file chunks with peers in torrent
P2P file distribution: BitTorrent
peer joining torrent:
Initially, has no chunks, but will accumulate them over time from other peers
while downloading, peer uploads chunks to other peers
peer may change peers with whom it exchanges chunks
churn: peers may come and go
once peer has entire file, it may (selfishly) leave or (altruistically) remain in torrent
Application Layer 2-6
BitTorrent: requesting file chunks
requesting chunks:
at any given time, different peers have different subsets of file chunks
periodically, Alice asks each peer for list of chunks that they have
256Kb chunk
Alice requests missing chunks from peers, rarest first. Using this approach, the rarest chunks gets redistributed quickly, equalising the number of copies of each chunk in the torrent.
BitTorrent: requesting, sending file chunks
requesting chunks:
sending chunks: tit-for-tat trading algorithm
at any given time, different peers have different subsets of file chunks
Alice sends chunks to those four peers currently sending her chunks at highest rate
periodically, Alice asks each peer for list of chunks that they have
other peers are choked by Alice (do not receive chunks from her)
Alice requests missing chunks from peers, rarest first. Using this approach, the rarest chunks gets redistributed quickly, equalising the number of copies of each chunk in the torrent.
every10 secs, re-evaluate top 4
every 30 secs: randomly select another additional peer, starts sending chunks
“optimistically unchoke” this peer newly chosen peer may join top 4
Application Layer 2-8
BitTorrent: tit-for-tat trading
(1) Alice “optimistically unchokes” Bob
(2) Alice becomes one of Bob’s top-four providers; Bob reciprocates (3) Bob becomes one of Alice’s top-four providers
higher upload rate: find better trading partners, get file faster !
(“Give and ye shall receive!”) Application Layer 2-9
Distribution time for P2P and client-server architectures
Assumption: all peers have the same upload rate Server transmission rate is 10 times the peer upload rate
Application Layer
Privacy Issues
• BitTorrent does not offer its users anonymity nor security.
• It is possible to obtain the IP addresses of all current and possibly previous participants in a swarm from the tracker.
OneSwarm – privacy-preserving P2P data sharing http://www.oneswarm.org/about.html
I2P (the invisible internet project) – is an anonymous overlay network (end-to-end encryption); used by many people who care about their privacy: activists, oppressed people, journalists and whistleblowers, as well as the average person.
-packets goes through a volunteer-run network of roughly 55,000 computers distributed around the world https://geti2p.net/en/
2: Application Layer 12
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com