/kademlia

Java implementation of Kademlia DHT's routing algorithm.

Primary LanguageJavaGNU Lesser General Public License v3.0LGPL-3.0

Kademlia

This project is a faithful 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 contact
  • stale() whenever a node has failed to come in contact / keep-alive
  • find() 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.