Every time you download a torrent, your client has to find the peers who hold the pieces you want — without any central server to ask. The network can have millions of nodes. Yet your client locates the right peers in a handful of messages. The algorithm that makes this possible is Kademlia, introduced by Petar Maymounkov and David Mazières in 2002.
The core insight is a peculiar definition of distance between nodes. Instead of geographic or network distance, Kademlia uses the bitwise XOR of two node IDs. This arithmetic distance has a remarkable property: it organises the network into a binary prefix tree, so that each hop towards a target cuts the remaining distance in half — and the lookup terminates in at most steps no matter how large the network grows.
Kademlia is not just a theoretical curiosity. It is the live routing substrate of BitTorrent's DHT (the system that tracks who has what without a tracker), the peer discovery layer of Ethereum, and the backbone of IPFS. Understanding Kademlia means understanding how decentralised systems find anything without anyone in charge.
Comments
Loading comments...