Chord
From a high-level perspective, the processes that constitute a peer-to-peer system are all equal. This means that the functions that need to be carried out are represented by every process that constitutes the distributed system.
Two types of overlay networks exist: those that are structured and those that are not.
Structured peer-to-peer systems
As its name suggests, in a structured peer-to-peer system the nodes (i.e., processes) are organized in an overlay that adheres to a specific, deterministic topology: a ring, a binary tree, a grid, etc. This topology is used to efficiently look up data. Characteristic for structured peer-to-peer systems, is that they are generally based on using a so-called semantic-free index. What this means is that each data item that is to be maintained by the system, is uniquely associated with a key, and that this key is subsequently used as an index.
The peer-to-peer system as a whole is now responsible for storing (key,value) pairs. To this end, each node is assigned an identifier from the same set of all possible hash values, and each node is made responsible for storing data associated with a specific subset of keys. In essence, the system is thus seen to implement a distributed hash table, generally abbreviated to a DHT [Balakrishnan et al., 2003].
Following this approach now reduces the essence of structured peer-topeer systems to being able to look up a data item by means of its key. That is, the system provides an efficient implementation of a function lookup that maps a key to an existing node.
This is where the topology of a structured peer-to-peer system plays a crucial role. Any node can be asked to look up a given key, which then boils down to efficiently routing that lookup request to the node responsible for storing the data associated with the given key.
Get Miguel’s stories in your inbox
Join Medium for free to get updates from this writer.
In the Chord system [Stoica et al., 2003] the nodes are logically organized in a ring such that a data item with an m-bit key k is mapped to the node with the smallest (again, also m bit) identifier id ≥ k. This node is referred to as the successor of key k and denoted as succ(k). Keys and identifiers are typically 128 or 160 bits long.
The successor of key 7 is equal to 9. Likewise, succ(5) = 9, but also succ(9) = 9. Likewise, succ(5) = 9, but also succ(9) = 9. In Chord, each node maintains shortcuts to other nodes. A shortcut appears as a directed edge from one node to another.
To look up a key, a node will try to forward the request “as far as possible,” but without passing it beyond the node responsible for that key. To clarify, suppose that in our example Chord ring, node 9 is asked to look up the node responsible for key 3 (which is node 4). Node 9 has four shortcuts: to nodes 11, 14, 18, and 28, respectively. As node 28 is the farthest node 9 knows about and still preceding the one responsible for key 3, it will get the lookup request. Node 28 has three shortcuts: to nodes 1, 4, and 14, respectively. Note that node 28 has no knowledge about the existence of nodes between nodes 1 and 4. For this reason, the best what it can do is forward the request to node 1. The latter knows that its successor in the ring is node 4, and thus that this is the node responsible for key 3, to which it will subsequently forward the request.
Now suppose that a node, with the unique identifier u, wants to join a Chord overlay. To that end, it contacts an arbitrary node and requests it to look up u, that is, return the value v= succ(u). At that point, node u will simply need to insert itself between the predecessor of v and v itself, thus becoming the new predecessor of v. During this process, shortcuts from u to other nodes will be established, but also some existing ones previously directed toward v will now be adjusted to point to u (again, details are deferred until later chapters). Obviously, any data item with key k stored at v but for which succ(k) is now equal to u is transferred from v to u.
For example, node24 wants to join the chord, so we have u=24, succ(24) = v=28. Suppose the node contacts node1. Node1 will forward the request to node21 because it is the farthest node node1 knows about and still preceding the one responsible for key 24. Node21 knows that its successor in the ring is node 24, and thus that this is the node responsible for key 24, to which it will subsequently forward the request.
Leaving is just as simple: node u informs its departure to its predecessor and successor, and transfers its data items to succ(u).
How these shortcuts are constructed? When new nodes join, shortcuts from u to other nodes will be established, but also some existing ones previously directed toward v will now be adjusted to point to u.










