This project is a faithfully implementation of the Kademlia distributed hash table (DHT) routing algorithm. This is an implementation of the strict version of the algorithm. The code is readable, documented, well tested, and fills in all of the missing pieces from the algorithm presented in the original paper.
The Kademlia algorithm is the backbone of many massive-scale decentralized applications, including...
To use this implementation, construct an instance of the Router
class. You can specify the main parameters of the routing algorithm here, specifically...
- node ID bit length
- number of branches to generate whenever a k-bucket splits
- maximum number of nodes allowed in each k-bucket
- maximum number of cache nodes allowed in each k-bucket
Once you have a Router
instance, you can call...
touch()
whenever a node comes in contactstale()
whenever a node has failed to come in contact / keep-alivefind()
to find the closest nodes in the routing table to some ID
If you need usage examples, check out the RouterTest.java
class in the test sources.