Lecture15-RealP2P

Download Report

Transcript Lecture15-RealP2P

Lecture XV: Real P2P Systems
CMPT 401 Summer 2007
Dr. Alexandra Fedorova
Outline
• Skype
• BitTorrent
CMPT 401 Summer 2007 © A. Fedorova
2
Skype
• IP telephony system
• Allows users to make phone calls
– to Skype users
– to regular phone users
• Calls are routed via Skype nodes
• Central login server
• Super-nodes
– Nodes that know about location of other nodes
CMPT 401 Summer 2007 © A. Fedorova
3
Skype P2P Network
• Super-nodes are nodes
with powerful CPU and
network bandwidth
• One has to qualify to
become a super-node
• Super-nodes know about
locations of other nodes
• Ordinary nodes contact
super-nodes to place calls
CMPT 401 Summer 2007 © A. Fedorova
4
Skype Components
• Skype client – the client program used to make phone
calls
• Host cache – list of other known Skype users, maintained
at each Skype client
• Skype login server – a centralized component. Processes
account information, authentication
CMPT 401 Summer 2007 © A. Fedorova
5
Skype Bootstrap Procedure
• Skype client depends on host cache to find other users
• How does a new Skype client populate its host cache?
• There is a list of bootstrap supernodes hard-coded into
the Skype client
• Skype client contacts them to
– Find the login server
– Find names of other Skype peers
• Skype client continues maintaining and refreshing its host
cache throughput its lifetime
– It’s a good idea to let Skype running for a while before making a
phone call!
CMPT 401 Summer 2007 © A. Fedorova
6
Skype User Search Procedure
• A Skype client making a phone call needs to find other
users
• It contacts super-nodes from its host cache, asking them
to help find the user
• Super-nodes return a list of nodes to contact
• The client contacts those nodes
• If unsuccessful, the client asks for more nodes
• Guarantees to find any user that has logged in within the
last 72 hours
• Not much specific information on Skype protocol is
available…
CMPT 401 Summer 2007 © A. Fedorova
7
Outline
• Skype
• BitTorrent
CMPT 401 Summer 2007 © A. Fedorova
8
CMPT 401 Summer 2007 © A. Fedorova
9
BitTorrent Overview
• Website allowing peers to share music, video and other media files
• Central server helps users find initial set of peers that have pieces of
the file
• Tracker server keeps track of peers possessing content of individual
files
• Users download the file by participating in exchange:
– They exchange pieces that they have
– for pieces that they don’t have
• Therefore, for the system to work, users must have incentive to give
• Users who just get, but do not give are called free riders
• Protocol must discourage free riding
CMPT 401 Summer 2007 © A. Fedorova
10
BitTorrent Download Mechanism
• Peers download pieces they
need and upload pieces
they have
• Keep track of download
rates from all links
• Keep those with highest
rate
• Keep uploading to those
peers
• Choke the others (stop
upload)
CMPT 401 Summer 2007 © A. Fedorova
fatter link =
higher rate
11
Selective Unchoking
• Once in a while selectively unchoke one of the links
• Allow some time (30 sec.) to see if the download rate will
increase
• If the download rate becomes greater than the rate at one
of the existing links, chop the slowest of the existing links
CMPT 401 Summer 2007 © A. Fedorova
12
Game Theory on Exchange
• Two traders A and B simultaneously exchange goods
• They have to decide whether to participate in the exchange
without knowing the other person’s decision
• If a trader makes the exchange, he co-operates
• If a trader does not make the exchange, he defects
• Possible outcomes:
– A co-operates, B co-operates – both benefit from receiving the
other trader’s good
– A co-operates, B defects – B benefits by receiving A’s good, by not
giving away his own good
– A defects, B defects – none receives the other trader’s good, but
each gets to keep his own good
CMPT 401 Summer 2007 © A. Fedorova
13
Incentives
• P – payoff
• P(C) – payoff to co-operating player
• P(D) – payoff to defecting player
Cooperate
Defect
Cooperate
P(C) = 3, P(C) = 3
P(C) = 0, P(D) = 5
Defect
P(D) = 5, P(C) = 0
P(D) = 1, P(D) = 1
CMPT 401 Summer 2007 © A. Fedorova
14
Strategies Encouraged By Incentives
Cooperate
Defect
Cooperate
P(C) = 3, P(C) = 3
P(C) = 0, P(D) = 5
Defect
P(D) = 5, P(C) = 0
P(D) = 1, P(D) = 1
• Best individual strategy is to defect
• But if both traders defect they are worse off than if they
both co-operated
• So the best strategy is to co-operate, but only if the other
player co-operates
CMPT 401 Summer 2007 © A. Fedorova
15
Winning the Exchange Game: TIT-FOR-TAT
• The exchange game:
– Repeat rounds of exchanges with other players
– Remember what other players did in previous rounds
– Goal: maximize personal payoff
• The winning strategy: TIT-FOR-TAT
– Co-operate in the first round
– In subsequent rounds do the same what the other player did
• Properties of the winning player:
– Nice – he begins by co-operating
– Retaliatory – he won’t co-operate with players that do not
themselves co-operate
– Forgiving – will co-operate again if bad players fix their behavior
– Clear – clearly communicates his intentions
CMPT 401 Summer 2007 © A. Fedorova
16
Analogy With BitTorrent
• Goods exchange: exchange the piece of file that you have
for the piece that you don’t have
• Co-operate: upload the piece you have in exchange for
downloading the piece you need
• Defect: download the piece you need, but don’t upload
(choke)
• Payoff:
– The piece you download
– minus the cost of uploading the file
CMPT 401 Summer 2007 © A. Fedorova
17
Is BitTorrent Using the Winning Strategy?
• Is BitTorrent player NICE?
– No, it may choke an existing link upon finding a faster one
• Is BitTorrent player RETALIATORY?
– No, it uses optimistic unchoking
• Is BitTorrent player FORGIVING?
– Not necessarily – unchoked links are chosen arbitrarily
• Is BitTorrent player CLEAR?
• No, unchoked links are chosen arbitrarily
CMPT 401 Summer 2007 © A. Fedorova
18
Improved Incentive Mechanism
• For each link, maintain:
– Download amount d
– Upload amount u
• Upload to the peer as long as:
u–d≤f*c
– c – the fragment size
– f – some constant
• If u – d is large, the other peer
is not co-operating
– So you stop co-operating
in return
CMPT 401 Summer 2007 © A. Fedorova
d
u
19
Comparison of the Mechanisms
• Old mechanism: everyone experiences the same download time,
regardless of the upload rate they provide
• New mechanism: nodes that upload more enjoy faster completion
time
CMPT 401 Summer 2007 © A. Fedorova
20
Comparison of the Mechanisms (cont.)
• FO – free riders + old players
• FN – free riders + new players
• FNO – free riders + new players + old players
CMPT 401 Summer 2007 © A. Fedorova
21
Summary
• Skype
– IP telephony system
– Relies on super-nodes, recorded in host cache
– Skype client learns about initial super-nodes from bootstrap
super-nodes
– Centralized login server
• BitTorrent
– Media sharing network
– File location is found in a centralized fashion (central server +
tracker)
– File download is P2P
– System must encourage co-operation, discourage free riding
– The right incentive mechanism is key
CMPT 401 Summer 2007 © A. Fedorova
22