A DHT lookup algorithm is the foundation of all structured peer-to-peer systems. It provides support for one operation: given a key, it maps the key onto a node. Your goal is to design a scalable lookup algorithm and implement it in the given simulator.
Your main reference should be chord, which provides a relatively simple lookup algorithm. It has the provable scalable property: A lookup only traverses O(log N) nodes. Your design is suggested to be based on chord.
Even with such a reference, a real DHT implementation could be complicated: The nodes can join and leave simultaneously or fail silently; The network could be partitioned. In general, handling byzantine faults is hard. In this project, you do not have to deal with those ``churning'' effects. In particular, you only have to handle sequential node join and leave. When a node leaves the DHT, it will have the opportunity to notify other relevant nodes about the event.
You can download our implementation of the simulator from here: chord505-0.3.tar.gz or chord505-0.3.zip.
The tarball contains two packages, algorithm and simulator. Your main focus is to implement a Chord505 class that implements the interface algorithm.Protocol. The algorithm.Protocol has following methods:
There is already a working implementation of a DHT, algorithm.Ring. It is an example of implementing the DHT and using the whole simulator. The algorithm is extremely simple: each node maintains a pointer to its successor in the virtual ring. If the node does not have the responsibility to the key, it will point to its successor for further lookup. The lookup complexity is O(N) in the virtual network. simulator.SimpleTest contains an example of using the Ring implementation and the simulator. The real get and put hash table interfaces are implemented by the class simulator.Node. It will call the underlying lookup protocol to find the correct node and get/put key, value pairs. Please read the doc and the source code for details.
An elegant Chord505 basic implementation do not have to modify the existing source code (much). Subclassing algorithm.Protocol and simulator.TestCase should suffice.
You should have a look at the Chord paper for the full details of the protocol.
The version of the protocol you should implement should be the following:
for(int i = 0;i<id.size;i++) { finger[i] = findSuccessor(n + 2^i) }