Homeβ–ΈDistributed & Parallel Computingβ–ΈKademlia DHT: XOR-Distance Radar (2D)

Kademlia DHT: XOR-Distance Radar (2D)

2D Kademlia lab: a radar view of the real XOR-distance identifier space, target key at the center, live iterative lookup spiraling inward hop by hop, with a working k-bucket-size control.

Distributed & Parallel Computing2DModerate60 FPSπŸ“± Mobile-adapted⇄ 3D version
2d-kademlia-dht-lab β†— Open standalone

This 2D companion runs the identical Kademlia routing logic as the 3D version β€” random 16-bit node IDs, real XOR-distance k-buckets capped at a configurable bucket size, and a genuine iterative lookup that always queries the closest unqueried candidate β€” but lays the identifier space out as a radar centered on the target key instead of a scattered 3D scene. Every node's ring is its true bit-length XOR distance to the target, so the highlighted lookup path visibly spirals inward hop by hop, and dragging the k-bucket-size slider measurably changes how many hops it takes to converge because each query then reveals a different number of real candidate neighbors.

βš™ Under the hood

Nodes get random 16-bit ids; distance is a plain a XOR b, and a contact's bucket index is the position of that distance's highest set bit. Each node's own k-buckets are built from every other node, capped at the k-bucket-size control. The lookup starts from the querier and, at each hop, picks the closest unqueried candidate found so far, "queries" it by revealing its real known neighbors as new candidates, and stops once no unqueried candidate can beat the current closest distance β€” a real, deterministic convergence, not a fixed animation length.

kademliadhtxor metrick-bucketspeer-to-peerdistributed hash table

2D Β· HTML5 Canvas 2D Β· 60 FPS target Β· runs fully client-side, no install