0

I was looking at Kademlia's paper, and I had a problem I couldn't understand.

In a fully-populated binary tree of 160-bit IDs, the magnitude of the distance between two IDs is the height of the smallest subtree containing them both.

enter image description here

d(101,010) = 5 ^ 2 = 7
but Lowest Common Ancestor height is 4:Count from one or 3:Count from zero (root)

This result is obviously wrong, and I must have something wrong, so how should I interpret this sentence I am looking forward to your reply. Thank you

Pseudo Reliable Broadcast in the Kademlia P2P System

Kademlia, in turn, organizes its nodes to a binary tree. (For an in-depth discussion of the internal mechanisms of Kademlia, please refer to [2].) Distance between nodes is calculated using the XOR (exclusive or) function, which essentially captures the idea of the binary tree topology. For any nodes A and B, the magnitude of their distance d(A,B)=AB, e.g. the most significant nonzero bit of d is the height of the smallest subtree containing both of them.

Kademlia: A Peer-to-peer Information System Based on the XOR Metric

We next note that XOR captures the notion of distance implicit in our binarytree-based sketch of the system. In a fully-populated binary tree of 160-bit IDs, the magnitude of the distance between two IDs is the height of the smallest subtree containing them both. When a tree is not fully populated, the closest leaf to an ID x is the leaf whose ID shares the longest common prefix of x. If there are empty branches in the tree, there might be more than one leaf with the longest common prefix. In that case, the closest leaf to x will be the closest leaf to ID x˜ produced by flipping the bits in x corresponding to the empty branches of the tree.

kingmeng
  • 43
  • 6

1 Answers1

1

That sentence is talking about the magnitude of the distance, not the exact distance. The exact distance is simply the XOR between both addresses.

In the particular case of 101 and 010 the distance is 111, the maximal possible distance, thus they share no common subtree other than the whole tree itself and thus the magnitude is 3 bits (assuming a 3bit-keyspace) which is also the maximal height. The equivalent in CIDR subnetting would be the /0 mask, i.e. 0 shared prefix bits.

the8472
  • 40,999
  • 5
  • 70
  • 122