peer-to-peer networks slides largely adopted from ion stoica’s lecture at ucb
Post on 22-Dec-2015
214 views
TRANSCRIPT
![Page 1: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/1.jpg)
Peer-to-Peer Networks
Slides largely adopted from Ion Stoica’s lecture at UCB
![Page 2: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/2.jpg)
2
How Did it Start?
A killer application: Naptser- Free music over the Internet
Key idea: share the storage and bandwidth of individual (home) users
Internet
![Page 3: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/3.jpg)
3
Model
Each user stores a subset of files Each user has access (can download) files from
all users in the system
![Page 4: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/4.jpg)
4
Main Challenge
Find where a particular file is stored- Note: problem similar to finding a particular page in web
caching (what are the differences?)
AB
C
D
E
F
E?
![Page 5: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/5.jpg)
5
Other Challenges
Scale: up to hundred of thousands or millions of machines
Dynamicity: machines can come and go any time
![Page 6: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/6.jpg)
6
Napster
Assume a centralized index system that maps files (songs) to machines that are alive
How to find a file (song)- Query the index system return a machine that stores
the required file• Ideally this is the closest/least-loaded machine
- ftp the file Advantages:
- Simplicity, easy to implement sophisticated search engines on top of the index system
Disadvantages:- Robustness, scalability (?)
![Page 7: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/7.jpg)
7
Napster: Example
AB
C
D
E
F
m1m2
m3
m4
m5
m6
m1 Am2 Bm3 Cm4 Dm5 Em6 F
E?m5
E? E
![Page 8: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/8.jpg)
8
Gnutella
Distribute file location Idea: multicast the request Hot to find a file:
- Send request to all neighbors- Neighbors recursively multicast the request- Eventually a machine that has the file receives the request,
and it sends back the answer Advantages:
- Totally decentralized, highly robust Disadvantages:
- Not scalable; the entire network can be swamped with request (to alleviate this problem, each request has a TTL)
![Page 9: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/9.jpg)
9
Gnutella: Example
Assume: m1’s neighbors are m2 and m3; m3’s neighbors are m4 and m5;…
AB
C
D
E
F
m1m2
m3
m4
m5
m6
E?
E?
E?E?
E
![Page 10: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/10.jpg)
10
Freenet
Addition goals to file location:- Provide publisher anonymity, security
- Resistant to attacks – a third party shouldn’t be able to deny the access to a particular file (data item, object), even if it compromises a large fraction of machines
Architecture:- Each file is identified by a unique identifier
- Each machine stores a set of files, and maintains a “routing table” to route the individual requests
![Page 11: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/11.jpg)
11
Data Structure
Each node maintains a common stack
- id – file identifier
- next_hop – another node that store the file id
- file – file identified by id being stored on the local node
Forwarding: - Each message contains the file id it is
referring to
- If file id stored locally, then stop;
- If not, search for the “closest” id in the stack, and forward the message to the corresponding next_hop
id next_hop file
……
![Page 12: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/12.jpg)
12
Query
API: file = query(id); Upon receiving a query for document id
- Check whether the queried file is stored locally
• If yes, return it
• If not, forward the query message
Notes:- Each query is associated a TTL that is decremented each time the
query message is forwarded; to obscure distance to originator:
• TTL can be initiated to a random value within some bounds
• When TTL=1, the query is forwarded with a finite probability
- Each node maintains the state for all outstanding queries that have traversed it help to avoid cycles
- When file is returned it is cached along the reverse path
![Page 13: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/13.jpg)
13
Query Example
Note: doesn’t show file caching on the reverse path
4 n1 f412 n2 f12 5 n3
9 n3 f9
3 n1 f314 n4 f14 5 n3
14 n5 f1413 n2 f13 3 n6
n1 n2
n3
n4
4 n1 f410 n5 f10 8 n6
n5
query(10)
1
2
3
4
4’
5
![Page 14: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/14.jpg)
14
Insert
API: insert(id, file); Two steps
- Search for the file to be inserted
• If found, report collision
• If number of nodes exhausted report failure
- If not found, insert the file
![Page 15: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/15.jpg)
15
Insert
Searching: like query, but nodes maintain state after a collision is detected and the reply is sent back to the originator
Insertion- Follow the forward path; insert the file at all nodes along
the path
- A node probabilistically replace the originator with itself; obscure the true originator
![Page 16: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/16.jpg)
16
Insert Example
Assume query returned failure along “gray” path; insert f10
4 n1 f412 n2 f12 5 n3
9 n3 f9
3 n1 f314 n4 f14 5 n3
14 n5 f1413 n2 f13 3 n6
n1 n2
n3
n4
4 n1 f411 n5 f11 8 n6
n5
insert(10, f10)
![Page 17: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/17.jpg)
17
Insert Example
10 n1 f10 4 n1 f412 n2
3 n1 f314 n4 f14 5 n3
14 n5 f1413 n2 f13 3 n6
n1
n3
n4
4 n1 f411 n5 f11 8 n6
n5
insert(10, f10)
9 n3 f9
n2orig=n1
![Page 18: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/18.jpg)
18
Insert Example
n2 replaces the originator (n1) with itself
10 n1 f10 4 n1 f412 n2
10 n1 f10 9 n3 f9
10 n2 10 3 n1 f314 n4
14 n5 f1413 n2 f13 3 n6
n1 n2
n3
n4
4 n1 f411 n5 f11 8 n6
n5
insert(10, f10)
orig=n2
![Page 19: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/19.jpg)
19
Insert Example
n2 replaces the originator (n1) with itself
10 n1 f10 4 n1 f412 n2
10 n1 f10 9 n3 f9
10 n2 10 3 n1 f314 n4
10 n2 f1014 n5 f1413 n2
n1 n2
n3
n4
10 n4 f10 4 n1 f411 n5
n5
Insert(10, f10)
![Page 20: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/20.jpg)
20
Freenet Properties
Newly queried/inserted files are stored on nodes with similar ids, why?
New nodes can announce themselves by inserting files
Attempts to replace or discover existing files will just spread the files
![Page 21: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/21.jpg)
21
Freenet Summary
Advantages- Provides publisher anonymity
- Totally decentralize architecture robust and scalable
- Resistant against malicious file deletion
Disadvantages- Does not always guarantee that a file is found, even if
the file is in the network
![Page 22: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/22.jpg)
22
Other Solutions to the Location Problem
Goal: make sure that an item (file) identified is always found Abstraction: a distributed hash-table data structure
- insert(id, item);- item = query(id);- Note: item can be anything: a data object, document, file, pointer to a file…
Proposals (Structured P2P Networks)- CAN (ACIRI/Berkeley)- Chord (MIT/Berkeley)- Pastry (Rice)- Tapestry (Berkeley)
Typically using Distributed Hash Table (DHT) to provide a structured name space with ability to do efficient/scalable search.
Two components:- How to connect/structured participating nodes/peers?- How to map contents among nodes?
![Page 23: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/23.jpg)
23
Content Addressable Network (CAN)
Associate to each node and item a unique id in an d-dimensional space
Properties - Routing table size O(d) (independent of group size)
- Guarantees that a file is found in at most d*n1/d steps, where n is the total number of nodes
![Page 24: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/24.jpg)
24
CAN Example: Two Dimensional Space
Space divided between nodes All nodes cover the entire space Each node covers either a square or a rectangular area of ratios 1:2 or 2:1 Example:
- Assume space size (8 x 8)- Node n1:(1, 2) first node that joins cover the entire space
1 2 3 4 5 6 70
1
2
3
4
5
6
7
0
n1
![Page 25: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/25.jpg)
25
CAN Example: Two Dimensional Space
Node n2:(4, 2) joins space is divided between n1 and n2
1 2 3 4 5 6 70
1
2
3
4
5
6
7
0
n1 n2
![Page 26: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/26.jpg)
26
CAN Example: Two Dimensional Space
1 2 3 4 5 6 70
1
2
3
4
5
6
7
0
n1 n2
n3
Node n3:(3, 5) joins n1’s space is divided between n1 and n3
![Page 27: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/27.jpg)
27
CAN Example: Two Dimensional Space
Nodes n4:(5, 5) and n5:(6,6) join
1 2 3 4 5 6 70
1
2
3
4
5
6
7
0
n1 n2
n3 n4n5
![Page 28: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/28.jpg)
28
CAN Example: Two Dimensional Space
Nodes: n1:(1, 2); n2:(4,2); n3:(3, 5); n4:(5,5);n5:(6,6)
Items: f1:(2,3); f2:(5,1); f3:(2,1); f4:(7,5);
1 2 3 4 5 6 70
1
2
3
4
5
6
7
0
n1 n2
n3 n4n5
f1
f2
f3
f4
![Page 29: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/29.jpg)
29
CAN Example: Two Dimensional Space
Each item is stored by the node who owns its mapping in the space
1 2 3 4 5 6 70
1
2
3
4
5
6
7
0
n1 n2
n3 n4n5
f1
f2
f3
f4
![Page 30: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/30.jpg)
30
CAN: Query Example
Each node knows its neighbors in the d-space Forward query to the neighbor that is closest to the query id Example: assume n1 queries f4 Some Issues:
- Even distribution of space vs load balancing- Topology-aware structure- Robustness to peer departure- What else?
1 2 3 4 5 6 70
1
2
3
4
5
6
7
0
n1 n2
n3 n4n5
f1
f2
f3
f4
![Page 31: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/31.jpg)
31
Chord
Associate to each node and item a unique id in an uni-dimensional space
Properties - Routing table size O(log(N)) , where N is the total
number of nodes
- Guarantees that a file is found in O(log(N)) steps
![Page 32: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/32.jpg)
32
Data Structure
Assume identifier space is 0..2m
Each node maintains- Finger table
• Entry i in the finger table of n is the first node that succeeds or equals n + 2i
- Predecessor node
An item identified by id is stored on the successor node of id (>=id)
![Page 33: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/33.jpg)
33
Chord Example
Assume an identifier space 0..8 Node n1:(1) joinsall entries in
its finger table are initialized to itself
01
2
34
5
6
7
i id+2i succ0 2 11 3 12 5 1
Succ. Table
![Page 34: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/34.jpg)
34
Chord Example
Node n2:(2) joins
01
2
34
5
6
7
i id+2i succ0 2 21 3 12 5 1
Succ. Table
i id+2i succ0 3 11 4 12 6 1
Succ. Table
![Page 35: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/35.jpg)
35
Chord Example
Nodes n3:(0), n4:(6) join
01
2
34
5
6
7
i id+2i succ0 2 21 3 62 5 6
Succ. Table
i id+2i succ0 3 61 4 62 6 6
Succ. Table
i id+2i succ0 1 11 2 22 4 0
Succ. Table
i id+2i succ0 7 01 0 02 2 2
Succ. Table
![Page 36: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/36.jpg)
36
Chord Examples
Nodes: n1:(1), n2(3), n3(0), n4(6) Items: f1:(7), f2:(1)
01
2
34
5
6
7 i id+2i succ0 2 21 3 62 5 6
Succ. Table
i id+2i succ0 3 61 4 62 6 6
Succ. Table
i id+2i succ0 1 11 2 22 4 0
Succ. Table
7
Items 1
Items
i id+2i succ0 7 01 0 02 2 2
Succ. Table
![Page 37: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/37.jpg)
37
Query Upon receiving a query for item id, a node Check whether stores the item locally If not, forwards the query to the largest node in its successor table
that does not exceed id
01
2
34
5
6
7 i id+2i succ0 2 21 3 62 5 6
Succ. Table
i id+2i succ0 3 61 4 62 6 6
Succ. Table
i id+2i succ0 1 11 2 22 4 0
Succ. Table
7
Items 1
Items
i id+2i succ0 7 01 0 02 2 2
Succ. Table
query(7)
![Page 38: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/38.jpg)
38
Discussion
Query can be implemented- Iteratively
- Recursively
Performance: routing in the overlay network can be more expensive than in the underlying network
- Because usually there is no correlation between node ids and their locality; a query can repeatedly jump from Europe to North America, though both the initiator and the node that store the item are in Europe!
- Solutions: Tapestry takes care of this implicitly; CAN and Chord maintain multiple copies for each entry in their routing tables and choose the closest in terms of network distance
![Page 39: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/39.jpg)
39
Discussion
Robustness - Maintain multiple copies associated to each entry in the routing
tables
- Replicate an item on nodes with close ids in the identifier space
Security- Can be build on top of CAN, Chord, Tapestry, and Pastry
![Page 40: Peer-to-Peer Networks Slides largely adopted from Ion Stoica’s lecture at UCB](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d795503460f94a5d1b7/html5/thumbnails/40.jpg)
40
Conclusions
The key challenge of building wide area P2P systems is a scalable and robust location service
Solutions covered in this lecture- Naptser: centralized location service
- Gnutella: broadcast-based decentralized location service
- Freenet: intelligent-routing decentralized solution (but correctness not guaranteed; queries for existing items may fail)
- CAN, Chord, Tapestry, Pastry: intelligent-routing decentralized solution
• Guarantee correctness
• Tapestry (Pastry ?) provide efficient routing, but more complex