Post on 12-Jan-2016
A P2P IRC Network Built on Top of the Kademlia Distributed Hash Table
Overview
History Distributed Hash Tables
IRC
Design
Demo
Distributed Hash Tables (DHTs)
Operations get(key) put(key, value)
How do you find information in a p2p network?
How do peers locate eachother?
Who’s responsible for what?
Generally decentralized
Fault tolerance is important
Must scale well
DHTs– What are they good for?
Web caching and CDNs
Distributed file systems
DNS
Instant messaging
P2P file sharing
History of DHTs - Centralized
Napster
Peers sent local files upon join
Central point of failure
Can only grow as much as central server can
History of DHTs - Gnutella
Flooding
Avoided central point of failure
O(n) look up
Inefficient Extensive modification by devs made it much more
efficient
History of DHTs - Chord
Peers and keys share 160-bit key-space (SHA-1)
Logical ring of keys and peers
successor(k) indicates node responsible for a key k
Each node keeps track of nodes ahead of you in the ring O(n) look up
Finger table improves look up speed Peers keep table of m other peers ith entry contains successor((n+2^(i-1)) mod2^m) O(logn) look up
Kademlia
Peers and keys share 160-bit key-space (SHA-1)
Use XOR to determine distance between peers/keys Symmetric distance measure Satisfies triangle inequality Hashes with long shared prefixes considered close
If local lookup fails, ask peers with IDs closer to key by XOR
O(logn) look up
Kademlia
Peers keep up to 160 buckets of peers called k-buckets Initially one bucket Buckets split into two once they contain k peers
Peers ping peers in k-buckets and remove stale peers to make room for new peers
How do new peers find out about others? Bootstrap nodes
Kademlia
KRPC protocol ping(node_id) find_node(node_id)
If node_id isn’t in your local list, find nodes closer to it than you are (if any) and send find_node(node_id) to them.
get(key) Keep track of peers already queried. Stop the query once
the value is found or no nodes closer to the value is found put(key,value)
Similar to get(key)
IRC
Internet Relay Chat
Servers host channels
Clients connect to servers, join channels and send eachother messages
RFC 2810,2811,2812,2813
RFC 1459