+-- Returns whether the current node is in the ring.
+function has_joined()
+
+ return my_node.fingers[1] ~= nil
+end
+
+-- Creates a new Chord ring.
+function create()
+ my_node.predecessor = nil
+ my_node.fingers[1] = my_node.id
+end
+
+-- Attemps to join the Chord ring.
+-- - known_id: id of a node already in the ring
+-- - return value: true if the join was successful
+function join(known_id)
+
+ simgrid.info("Joining the ring with id " .. my_node.id .. ", knowing node " .. known_id)
+
+ local successor = remote_find_successor(known_id, my_node.id)
+ if successor == nil then
+ simgrid.info("Cannot join the ring.")
+ return false
+ end
+
+ my_node.predecessor = nil
+ my_node.fingers[1] = successor
+ return true
+end
+