1 P2P Overview Centralized Database Napster Napster Swarming BitTorrent BitTorrent Hierarchical...

49
1 P2P Overview Centralized Database Napster Swarming BitTorrent Hierarchical Query Flooding KaZaA Skype (VOIP)

Transcript of 1 P2P Overview Centralized Database Napster Napster Swarming BitTorrent BitTorrent Hierarchical...

Page 1: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

1

P2P

Overview

Centralized Database Napster

Swarming BitTorrent

Hierarchical Query Flooding KaZaA Skype (VOIP)

Page 2: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

2

P2P

P2P: centralized directoryoriginal “Napster” design

(1999, S. Fanning)

1) when peer connects, it informs central server: IP address content

2) Alice queries directory server for “file A”

3) Alice requests file from Bob

centralizeddirectory server

peers

Alice

Bob

1

1

1

12

3

Problems? Single point of failure Performance

bottleneck Copyright infringement

Page 3: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

3

P2P

Napster: Publish

I have X, Y, and Z!

Publish

insert(X, 123.2.21.23)...

123.2.21.23

Page 4: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

4

P2P

Napster: Search

Where is file A?

Query Reply

search(A)-->123.2.0.18Fetch

123.2.0.18

Page 5: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

5

P2P

Napster: Discussion

Pros:SimpleSearch scope is O(1)Controllable (pro or con?)

Cons:Server maintains O(N) StateServer does all processingSingle point of failure

Page 6: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

6

BitTorrent: History In 2002, B. Cohen debuted BitTorrent

Workshop on Economics of Peer-to-Peer Systems, 2003

Key Motivation: Popularity exhibits temporal locality

Now New file releases

Linux ISO 檔 , 魔獸世界更新檔 , etc.

Network TV(PPstream) also borrows the idea from BT

Focused on Efficient Fetching, not Searching Does not include a search mechanism, but rather, it relies on central-

directory based search facilities as provided by Web sites such as suprnova.org

Has some “real” publishers: Blizzard Entertainment using it to distribute games

Page 7: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

Something you may know

種子擁有檔案的人File is partitioned into several pieces

.torrent 與 tracker紀錄檔案片段全部名稱下載成員名單與網路位置

斷種

7

Page 8: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

8

BitTorrent-Characteristic

Fast download speedReduce the load of file publisherFairness

Choke/unchoke

Page 9: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

Policies

Relay on .torrent file to know the file pieces and members

Rarest First PolicyChoking PolicyOptimistic Unchoking

9

Page 10: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

10

P2P

BitTorrent: Overview

Swarming:Join: contact centralized “tracker” server, get a

list of peers.Publish: Run a tracker server. Create .torrent

file.Search: Out-of-band. E.g., use Google to find a

torrent for the file you want.Fetch: Download pieces of the file from your

peers. Upload pieces you have to them.

Page 11: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

11

Components Peers

Seed (file owner) Leech (downloader)

Data divided into 256KB pieces 利用 hash 檢查檔案正確性

Metainfo File (.torrent file) Data 資訊和各個 pieces 的 hash value Tracker 的 url Etc…

Tracker HTTP/HTTPS services 維護 torrent 中各個 peers 的資訊 幫助 peers 追蹤其他 peers 的途徑

BT client BitComet Torrent Etc…

Page 12: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

12

2: Application Layer

File distribution: BitTorrent

tracker: tracks peers participating in torrent

torrent: group of peers exchanging

chunks of a file

obtain listof peers

trading chunks

peer

P2P file distribution

Page 13: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

13

BitTorrent - Algorithms

Two components in BitTorrent downloading algorithm:

Peer Selection – determines from whom to download the piece?

Piece Selection – determines which piece to download?

Page 14: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

14

Tit for Tat

"tip for tat", an agent using this strategy will respond in kind to a previous opponent's action.

If the opponent previously was cooperative, the agent is cooperative. If not, the agent is not.

This strategy is dependent on the following conditions : 1. Unless provoked, the agent will always cooperate 2. If provoked, the agent will retaliate 3. The agent is quick to forgive

Page 15: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

15

BitTorrent - Peer selection

Choke AlgorithmChoking is a temporal refusal to uploadEach peer unchokes a fixed number of peers

(default = 4)3 peers on tit-for-tat basis1 peer on optimistic unchoke basis

Page 16: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

16

BitTorrent - Peer selection (cont’d)

Tit-for-tat peer selectionSelect the 3 peers from which you downloaded

most and that are interested in your chunksPeer selection is done every 10 seconds,

based on the download rates are of the last 30 seconds.

Page 17: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

17

BitTorrent - Peer selection (cont’d)

Optimistic unchoke peer selectionSelect one peer at random that is interested in

your chunks, regardless of the current download rate from it

Rotates every 30 seconds.

Reason:To discover currently unused connections that

are better than the ones being used

Page 18: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

18

2: Application Layer

BitTorrent: Tit-for-tat(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

With higher upload rate, can find better trading

partners & get file faster!

Page 19: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

19

P2P

BitTorrent: Sharing Strategy

“Tit-for-tat” sharing strategy“I’ll share with you if you share with me”Be optimistic: occasionally let freeloaders download

Otherwise no one would ever start!Also allows you to discover better peers to download from

when they reciprocate

Page 20: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

20

BitTorrent - Piece selectionRandom first piece

Only applies if leecher has downloaded less than 4 pieces (chunks)

Choose randomly the next piece to download

Local rarest first policyDetermine the pieces that are most rare among your

peers and download those firstEnsures that the most common pieces are left till the

end to downloadRarest first also ensures that a large variety of pieces

are downloaded from the seed

Page 21: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

Mathematic model(Markov Chain)Four cities

A city : the men not join BTB city : Leeches (downloaders) in BTC city : Seeds (file owners) in BTD city : the men finish the downloading and leave BT

ParametersA->B : λC->D : B->C :

How many peers in BTAverage bandwidth

21

Page 22: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

We want to find in a static stateX’: How many peers live in B city ( 下載者人數 )Y’: How many peers live in C city (seeds 人數 )T: Average moving speed from B to C ( 下載時間 )

X’= /((1+/))Y’=/((1+/))Remind

: 完成下載後離開的比例 : 中途取消下載的比例

受分享頻寬、檔案分享效率與種子離開率影響的一個變數22

Page 23: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

We know X’ and Y’, by queuing theoryT=1/(+)

Properties平均下載時間與人潮湧進的速度無關檔案分享的效率越高,下載時間越短種子離開系統的速率會影響下載時間

23

Page 24: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

Another Property

多數人下載慢,少數人下載速度超快下載速度仍比 ftp 快

上傳頻寬最大的族群會優先獲得檔案,當這個族群的下載速度已經快到不能再快的時候,多出來的上傳頻寬會分享給第二快的族群,然後依此類推…。

只要每個族群的人數到達一定的數量,就會達到人人有檔抓、速度都不慢的平衡點。

24

Page 25: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

How many bandwidth can free rider get? Assume only one free rider in the systemParameters

N (總人數)μ (每人平均上傳頻寬)n ( 當下有上傳關係的人數)

N**(1/(N-n))*(1/(n+1))N* 總總總總總1/(N-n) : free rider 被選到的機率1/(n+1) : optimistic unchoking 分到的頻寬比例

N>>nμ/ ( n+1 )

25

Page 26: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

26

BitTorrent - Summary

Efficient file download thanks to simple incentive mechanismsLocal rarest first

High piece entropyTit-for-tat

Avoids free-ridingOptimizes resource utilization

Page 27: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

27

BitTorrent References

Section inspired by:“Rarest First and Choke Algorithms are

Enough”, Arnaud Legout, G. Urvoy-Keller, P. Michiardi, IMC 2006.

“The Bittorrent P2P File-sharing System: Measurements and Analysis”, J.A Pouwelse, P. Garbacki, D.H.J Epema, H.J. Sips, IPTPS 05, February 2005.

“Incentives Build Robustness in BitTorrent”, Bram Cohen, First Workshop on Economics of Peer-to-peer Systems, June 2003.

Page 28: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

28

2: Application Layer

BTW: File Distribution: Server-Client vs P2PQuestion : How much time to distribute file

from one server to N peers?

us

u2d1 d2

u1

uN

dN

Server

Network (with abundant bandwidth)

File, size F

us: server upload bandwidth

ui: peer i upload bandwidth

di: peer i download bandwidth

Page 29: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

29

2: Application Layer

BTW: File distribution time: server-client

us

u2d1 d2u1

uN

dN

Server

Network (with abundant bandwidth)

F

server sequentially sends N copies:NF/us time

client i takes F/di

time to download

increases linearly in N(for large N)

= dcs = max { NF/us, F/min(di) }i

Time to distribute F to N clients using

client/server approach

Page 30: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

30

2: Application Layer

BTW: File distribution time: P2P

us

u2d1 d2u1

uN

dN

Server

Network (with abundant bandwidth)

F

server must send one copy: F/us time

client i takes F/di time to download

NF bits must be downloaded (aggregate)

fastest possible upload rate: us + ui

dP2P = max { F/us, F/min(di) , NF/(us + ui) }i

Page 31: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

31

2: Application Layer

0

0.5

1

1.5

2

2.5

3

3.5

0 5 10 15 20 25 30 35

N

Min

imu

m D

istr

ibut

ion

Tim

e P2P

Client-Server

Server-client vs. P2P: example

Client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us

Page 32: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

32

P2P

All Peers Equal?

56kbps Modem

10Mbps LAN

1.5Mbps DSL

56kbps Modem56kbps Modem

1.5Mbps DSL

1.5Mbps DSL

1.5Mbps DSL

Page 33: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

33

P2P

KaZaA: History

In 2001, KaZaA created by Dutch company Kazaa BV

Popular file sharing network with >10 million users (number varies)

Page 34: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

34

P2P

KaZaA: Overview

“Smart” Query Flooding:Join: on startup, client contacts a “supernode” ... may at

some point become one itselfPublish: send list of files to supernodeSearch: send query to supernode, supernodes flood

query amongst themselves.Fetch: get the file directly from peer(s);

Page 35: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

35

P2P

KaZaA: Network Design

“ Super Nodes”

Page 36: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

36

P2P

KaZaA: File Insert

I have X!

Publish

insert(X, 123.2.21.23)...

123.2.21.23

Page 37: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

37

P2P

KaZaA: File Search

Where is file A?

Query

search(A)-->123.2.0.18

search(A)-->123.2.22.50

Replies

123.2.0.18

123.2.22.50

Page 38: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

38

P2P

KaZaA: Discussion

Pros: Tries to take into account node heterogeneity:

BandwidthHost Computational ResourcesHost Availability

Cons: Mechanisms easy to circumvent Still no real guarantees on search scope or search time

P2P architecture used by Skype

Page 39: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

39

Skype Overlay

Protocol not fully understood todayContent and control messages are encrypted

Builds upon an unstructured overlayTwo tier hierarchy

Super Nodes (SN)Ordinary Nodes (ON)

Page 40: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

40

Skype Overlay (cont’d)

Super Nodes (SN)Connect to each other, building a flat unstructured

overlay (similar to the Gnutella overlay)

Ordinary Nodes (ON)Connect to Super Nodes

Skype login serverOnly central componentStores and verifies usernames and passwords

Page 41: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

41

Skype Overlay (cont’d)

Skype login

server

Neighbor relationshipSN ON

Message exchange during

login for authentication

Page 42: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

42

How is the overlay constructed? - Super Node Lists

Each node keeps a host cache(HC) with a list of Super Nodes IP-addresses and port pairsUp to 200 entriesCache in the windows registry

Page 43: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

43

How is the overlay constructed? - LoginContact login server and authenticateAdvertise your presence to other peers

Contact a Super NodeContact your buddies (through Super Node),

and notify your presence

Page 44: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

44

Login process-contact a super node

Page 45: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

45

Super Nodes – Index servers

Super Nodes are index serversI.e. index of locally connected Skype users (and

their IP addresses)

If buddy is not found in local index of a Super NodeSpread node search to neighboring Super

NodesNot clear how this is implemented

Possibly flood the request similar to Gnutella

Page 46: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

46

Super Nodes – Relay nodes

Bob

Alice

Super nodes also act as relay nodesEnables NAT traversals

Alice would like to call Bob (or inversely)

Page 47: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

47

Super Nodes – Relay nodes

Skype relay node

Alice

Bob

Alice would like to call Bob (or inversely)

Contact Relay NodeCall

Page 48: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

48

Super Node election

When does an ordinary node becomes a super node?High bandwidth, Public IP address, but details

not clear

Page 49: 1 P2P Overview Centralized Database  Napster Napster Swarming  BitTorrent BitTorrent Hierarchical Query Flooding  KaZaA KaZaA  Skype (VOIP) Skype.

49

Skype References

Section inspired by:“An Analysis of the Skype Peer-to-Peer Internet

Telephony Protocol”, S.A. Baset and H.G. Schulzrinne, Infocom 2006, April 2006.

“An Experimental Study of the Skype Peer-to-Peer VoIP System”, Saikat Guha, Neil Daswani, Ravi Jain, IPTPS’06, February 2006.

“Characterizing and Detecting Skype-Relayed Traffic”, K. Suh, D. R. Figueiredo, J. Kurose, D. Towsley, Infocom 2006, April 2006.