Peer to peer INF 123 – Software Architecture 1
Outline Some theory Napster Gnutella/torrents Skype Sensor networks I won’t talk about – NAT punching/Firewall (ICE, STUN, TURN) – Distributed system algorithms/graph walks 2
SOME THEORY 3
Peer to peer Identical components running independently on different networked hosts Similar to distributed systems – The topology can change – Many paths from A to B Each peer is client and server to other peers Each peer provides resources: data, code, CPU, … 4
Peer 1 Peer 4Peer 2 Peer 3 Peer 4Peer 2 Peer 3 now later 5
Pros and cons Pros – Scaling: each node provides CPU and storage – Robust if one node fails Cons – Complex protocols for resource discovery – Security, trust management 6
Examples Skype Sensor networks (house, environment, …) DNS caching File sharing 7
NAPSTER: HYBRID CS AND P2P 8
Napster Open source Resource location – Client-server – Custom protocol on top of TCP Resource retrieval – P2P – HTTP GET 9
Communication diagram 10 Peer APeer B Content Directory 1) I have Gangnam Style 2) Who has Gangnam Style? 3) A has Gangnam Style 4) Give me Gangnam Style 5) Here is Gangnam Style
Behind Firewall? Sequence diagram 11
Protocol: I have a song “filename”, md5, size (B), bitrate (kbps), frequency (Hz), time (s) “C:\music\OMGPSY\gangnam.mp3” 9e107d9d372bb6826bd81d3542a419d To class: why md5? 12
Protocol: Search query [FILENAME CONTAINS "artist name"] MAX_RESULTS [FILENAME CONTAINS "song"] [LINESPEED ] [BITRATE " "] [FREQ " "] [WMA-FILE] [LOCAL_ONLY] MAX_RESULTS 100 FILENAME CONTAINS “Gangnam Style” BITRATE “AT LEAST” “128” MAX_RESULTS # browse To class: query for songs from Psy? 13
Achilles’ heel Server = bottleneck Swamped with requests for the location of a popular song – Answer location requests slowly Heavy load if the only owner is behind a Firewall – Cap number of simultaneous transfers 14
Achilles’ heel #2 Server = single point of failure Without it, the peers are blind and useless Shutdown mandated by court order 15
GNUTELLA: FULL P2P 16
Gnutella Open source Resource retrieval – P2P – HTTP GET Resource location, peer discovery, … – P2P! – Custom over TCP Purely distributed/decentralized search engine Peer also called servent (server + client) 17
Flooding 18
Flood prevention Every message has a Time to Live flag (TTL) Decreased by 1 every hop When 0, don’t forward 19
Peer discovery Send ping When receiving ping – Send pong where it came from – And forward the ping to other nodes 20
Search query Query message payload Response: QueryHit message payload 21
Query hit 22
Seeds How do I find peers when I join for the first time? – Aka bootstrapping, seeding Need a reliable list of nodes/seeds – Same idea as web page seeds for web crawlers Ship the list in the software Also: IRC, mailing lists, websites with seeds 23
SKYPE: OVERLAY P2P 24
25
Skype supernodes Promote “strong” peers to supernodes – Based on topology, bandwidth, … – Trade secret Directory distributed and replicated in supernodes – Robust and scalable directory 26
Privacy and security Calls relayed through supernodes – Proprietary protocol – Encrypted for privacy Closed-source client – Very hard to inspect the code – Even harder to hack it – Therefore: no malicious peers
SENSOR NETWORKS 28
Basic idea 29
Constraints Each node can – Sense – Compute – Communicate with its neighbors Non-functional properties – Low energy consumption – Fault-tolerance – Scalability – Low latency 30
Usage Home automation Army communication Forest fire, tsunami, or tornado detection Airport weather conditions … 31
London Heathrow Airport 32
33 Base Station (aka sink or gateway) Analog-Digital Converter Deployment architecture System architecture
Communication: routing Flat Hierarchical (super nodes) Location-based Depends on network topology 34
Communication: protocol Multipath – Send data through multiple paths – Good fault-tolerance, but high energy cost Query-based – The gateway sends a query to the network – A node with the data answers the query Quality of Service-based – Balance energy consumption and data quality 35
Read more -of-sensors/article-view/-/blogs/advanced- sensor-networks-developed-for-heathrow- airport -of-sensors/article-view/-/blogs/advanced- sensor-networks-developed-for-heathrow- airport Routing Techniques in Wireless Sensor Networks: A Survey, Al-Karaki et al.,