Methods & Tools Peer-to-Peer Jakob Jenkov
Peer-to-Peer (P2P) Definition(s) Potential Routing and Locating Proxy through firewalls and NAT Searching Security
Pure P2P There is no central server or router. Peers act as equals, as both clients, servers, and routers. Peers run autonomously, and may join or leave the network at any time.
Hybrid P2P A combination of pure P2P and Client/Server There may be one or more central servers that aid the P2P network. E.g. Authentication server or Index / Search server
Pure P2P
Hybrid P2P
P2P Potential Resource Sharing CPU, Storage, Data Communication Chat, VoIP, Video Conferencing / Streaming Collaboration Mail, Calendar, Projects, Forums, Polls etc.
P2P Routing & Locating How do you get a message from A to B or C? A B C
P2P Routing & Locating 1) Assign each peer a GUID 1 A 2 5 4 B 8 7 3 6 9 C
P2P Routing & Locating 2) Organize the peers into a circle 1 2 9 C A 3 8 B 4 7 5 6
P2P Routing & Locating 3) Let each peer reference its successor 1 2 9 3 8 4 7 5 6
P2P Routing & Locating 1 Peer joining the network 1 2 9 To 2: I m joining. Your successor is? 3 8 4 7 5 6
P2P Routing & Locating 1 Peer leaving the network 1 2 9 To 2: I m leaving. My successor is 4 3 8 4 7 5 6
P2P Routing & Locating 2 Peers leaving the network simultanously 9 1 2 To 2: I m leaving. My successor is 4 3 8 4 7 5 6
P2P Routing & Locating 1 Peer crashes 1 2 9 3 8 4 7 5 6
P2P Routing & Locating 3) Let each peer reference its X successors 1 2 9 3 8 4 7 5 6
P2P Routing & Locating Stabilization after changes 1 2 9 3 8 4 7 6 5
P2P Routing & Locating Ring routing doesn t scale 1 2 9 8 3 4 1.000.000 Peers Message Speed: 1.000 peers / sec Message ETA: 1.000 seconds = 16.66 minutes 7 5 6
P2P Routing & Locating 5) Add Shortcut references 1 2 9 3 8 4 7 5 6
P2P Routing & Locating 5) Add Shortcut references But which? 1 2 9 3 8 4 7 5 6
P2P Routing & Locating Chord: n = bit-size of GUID space (eg. 8 bit) n = number of references distance(n1, n2) = (GUID(n) GUID(p) + 2 n ) mod 2 n E.g. (4 123 + 256) mod 256 = 137)
P2P Routing & Locating Chord:... Peer GUID references n closest successors of: GUID + 2 0 mod 2 n GUID + 2 1 mod 2 n GUID + 2 mod 256 GUID + 2 2 mod 2 n GUID + 4 mod 256 GUID + 2 3 mod 2 n GUID + 2 n-1 mod 2 n GUID + 1 mod 256 GUID + 8 mod 256 GUID + 128 mod 256
P2P Routing & Locating 5) Add shortcut references 1 2 n = 4 9 3 1 + 1 mod 16 = 2 1 + 2 mod 16 = 3 1 + 4 mod 16 = 5 1 + 8 mod 16 = 9 8 4 7 5 6
P2P Routing & Locating 5) Add shortcut references 1 2 n = 4 9 3 6 + 1 mod 16 = 7 6 + 2 mod 16 = 8 6 + 4 mod 16 = 12 6 + 8 mod 16 = 14 8 4 7 5 6
P2P Routing & Locating Example: 6 sends a message to 4 1 2 n = 4 9 3 1 + 1 mod 16 = 2 1 + 2 mod 16 = 3 1 + 4 mod 16 = 5 1 + 8 mod 16 = 9 8 7 5 4 n = 4 6 + 1 mod 16 = 7 6 + 2 mod 16 = 8 6 + 4 mod 16 = 12 6 + 8 mod 16 = 14 6
P2P Routing & Locating Stabilization of shortcut references 1 2 n = 4 9 1 + 1 mod 16 = 2 1 + 2 mod 16 = 3 1 + 4 mod 16 = 5 1 + 8 mod 16 = 9 8 7 5 n = 4 6 + 1 mod 16 = 7 6 + 2 mod 16 = 8 6 + 4 mod 16 = 12 6 + 8 mod 16 = 14 6
P2P Routing & Locating Chord: n = bit-size of GUID space (eg. 8 bit) n = number of references N = max number of peers ( = 2 n ) Routing : O(log(N)) 128 bit GUID space = 2 128 possible nodes log(2 128 ) - 1 = 127 references needed Routing in ~127 hops
P2P Routing & Locating P2P routing algorithms: Chord Pastry Kademlia (MIT) (Microsoft Research) (New York University)
P2P Routing & Locating Routing: All messages are routed by intermediate peers, from A to B. Locating: Once a peer s IP is located, the peers communicate directly via TCP/IP
P2P Distributed Hash Table Capable of: Storing (key, value) pairs in the network Locating (key, value) pairs in the network
P2P Distributed Hash Table Storing Data: 1) Assign X keys to the data (file name, author etc.) 2) Compute GUID-size hash value from each key. 3) Store each (key, value) at peer with GUID closest to hash value ( distance(guid, hash value) ). 4) When leaving the network a peer will transfer its (key, value) pairs to the peer with second-closest GUID.
P2P Distributed Hash Table Locating Data: 1) Determine keys to search for, e.g. keywords, artist, title etc. 2) Compute a hash value from each key, with the same bit-size as the GUID. 128 bit GUID = 128 bit hash value. 3) Locate the peer with the GUID closest to each hash value. 4) Request keys + data for hash values from located peer.
P2P Distributed Hash Table Example: 3 stores a document 1 p2p : doc 2 Data: document 8 9 3 4 Keys: p2p, networks distributed systems Hash: hash(p2p) hash(networks) = 5 hash(distributed) = 7 7 5 networks : doc distributed : doc 6
P2P Distributed Hash Table Example: 4 searches for a document 1 p2p : doc 2 Keys: p2p 9 3 Hash: hash(p2p) 8 4 7 5 networks : doc distributed : doc 6
P2P Proxies How to communicate with a peer behind a firewall or NAT? Public Peers Firewall / NAT Private Peers
P2P Proxies 1) Private peers connect to a proxy peer Public Peers Proxy Peer Firewall / NAT Private Peers
P2P Proxies Closest GUID is proxy 1 2 9 3 Firewall / NAT 8 4 4.5 7 5 6
P2P Proxies Example: 8 sends a message to 4.5 1 2 9 3 Firewall / NAT 8 4 4.5 7 5 6
P2P Proxies Publish (GUID, proxyguid) as (key, value) pair 1 2 Firewall / NAT 9 3 4.5 8 4 ( 4.5, 2 ) 7 5 6
P2P Proxies Realistic Scenario: 4 48 8 7 Private Peer 33 Private Peer 31 10 Public Peers
P2P Proxies Special Case: 1 public peer = client/server Firewall / NAT Firewall / NAT 2 Private Peer 4 7 Public Peer Private Peer
P2P Security Security Challenges: Denial of Service Sniffing, Modification, Fabrication Identity Anonymity
P2P Security Denial of Service: Sending lots of messages to a peer. Sending a huge message to a peer. Not forwarding messages to a peer.
P2P Security Sniffing, Modification, Fabrication SSL
P2P Security Sniffing, Modification, Fabrication Clear Text SSL SSL Private Peer Proxy Peer Private Peer
P2P Security Sniffing, Modification, Fabrication SSL SSL Private Peer Proxy Peer Private Peer Tunnel SSL Negotiation to which peer?
P2P Security Sniffing, Modification, Fabrication SSL Virtual Host 1: SSL Certificate Virtual Host 2: SSL Certificate Client Web Server Virtual Host 3: SSL Certificate SSL Negotiation using which certificate?
P2P Security Identity How to prevent multiple peers from using the same GUID? How do I make sure that a peer represents the person I want to communicate with? (PKI)
P2P Security Anonymity in searching Publicly searchable keys cannot be encrypted Malicious peers can store the keys searched for by other peers, thereby profiling peers.
P2P Security Anonymity in communication Malicious peers can profile a peer on what other peers it communicates with.
P2P Security Onion Routing: Anonymous Routing R1 R2 R3 PK-R1 PK-R2 PK-R3 Data
P2P Resources www.wikipedia.org (search for P2P, Chord, Pastry etc.) Distributed Systems: Concepts and Design (book) The Chord Project http://pdos.csail.mit.edu/chord/ Pastry http://research.microsoft.com/~antr/pastry/ Kademlia Search Google or Wikipedia.
Remember! Enter the evaluation form and be a part of making Øredev even better. You will automatically be part of the evening lottery