Tutorial 4

Tutorial 4
DISTRIBUTED HASH TABLES (DHTS)
TASK A: PEER CHURN – LEAVING PEER
In the circular DHT illustrated in the following figure, suppose that peer 3 learns that
peer 5 has left.
How does peer 3 update its successor state information? Which peer is now its first
successor? Which peer is its second successor?
SOLUTION
Peer 3 learns that peer 5 has just left the system, so Peer 3 asks its first successor
(Peer 4) for the identifier of its immediate successor (peer 8). Peer 3 will then make
peer 8 its second successor.
TASK B: PEER CHURN – JOINING PEER
Refer to the same figure as in task A, and suppose that a new peer 6 wants to join the
DHT and peer 6 initially only knows peer 15’s IP address.
What steps are taken?
SOLUTION
Peer 6 would first send peer 15 a message, saying “what will be peer 6’s predecessor
and successor?” This message gets forwarded through the DHT until it reaches peer
5, who realizes that it will be 6’s predecessor and that its current successor, peer 8,
will become 6’s successor. Next, peer 5 sends this predecessor and successor
information back to 6. Peer 6 can now join the DHT by making peer 8 its successor and
by notifying peer 5 that it should change its immediate successor to 6.
TASK B: DISTRIBUTED HASH TABLES (DHTS)
Because an integer in [0, – 1] can be expressed as an n-bit binary number in a
DHT, each key can be expressed as k = ( , , …,
) and each peer can be
expressed as p = ( , , …,
) Let’s now define the XOR distance between a
key k and peer p as j
d (k, p) = ∑
Describe how this metric can be used to assign (key, value) pairs to peers.
SOLUTION
For each key, we first calculate the distances using d (k, p) between itself and all
peers, and then store the key in the peer that is closest to the key (that is, with the
smallest distance value).