Kademlia: A DHT in Python

Posted 14 Feb 2014 to python, kademlia, dht and has Comments

A distributed hash table (DHT) is a decentralized dictionary that is comprised of many nodes that each store a portion of a key/value lookup table. Any participating node can write to and read from the entire hash table.

The Kademlia distributed hash table is one of the better known DHT descriptions, and it’s used by BitTorrent for trackerless torrents and by the Gnutella network (originally “LimeWire”).

I couldn’t find a good implementation in Python (that followed the paper and wasn’t buggy), so I wrote one. Naturally, it uses Twisted to provide asynchronous communication. The nodes communicate using RPC over UDP to communiate, meaning that it is capable of working behind a NAT.

The library aims to be as close to a reference implementation of the Kademlia paper as possible.

Check out the code and examples here - github.com/bmuller/kademlia.