950 likes | 987 Views
Explore synchronous and asynchronous leader election algorithms in ring networks. Understand how network size affects algorithm outcomes and examine message complexities. Compare anonymous and eponymous ring scenarios and discover the maximum ID node leader election strategy.
E N D
Sense of direction left 2 1 1 right 2 2 1 1 2 2 1 1 2 2 1 1 2
Links are bi-directional for messages At most one message in each direction 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2
Anonymous Ring 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2
2 8 1 1 1 2 2 2 1 1 5 2 2 6 1 1 3 2 2 4 7 1 1 2 Eponymous (non-anonymous) Ring
Leader Election Initial state Final state leader
Leader election algorithms are affected by: Anonymous Ring Eponymous Ring The size of the network is known The size of the network is not known Synchronous Algorithm Asynchronous Algorithm
Synchronous Anonymous Rings Every processor runs the same algorithm Every processor does exactly the same execution
Initial state Final state leader If one node is elected a leader, then every node is elected a leader
Conclusion 1: Final state Leader election cannot be solved in synchronous anonymous rings leader
Conclusion 2: Final state Leader election cannot be solved in asynchronous anonymous rings either leader Why? The asynchronous ring may behave Like the synchronous ring
Asynchronous Eponymous Rings The maximum id node is elected leader 8 1 2 5 6 3 4 7
Each node sends a message with its id to the left neighbor 1 8 8 1 5 2 2 5 6 3 6 3 4 7 7 4
If: message received id current node id Then: forward message 5 8 1 2 8 5 6 7 3 4 7 6
If: message received id current node id Then: forward message 8 1 7 2 5 6 8 3 4 7
If: message received id current node id Then: forward message 7 8 1 2 5 6 3 4 7 8
If: message received id current node id Then: forward message 8 1 2 5 6 3 4 8 7
If: a node receives its own message Then: it elects itself a leader 8 8 1 2 5 6 3 4 7
If: a node receives its own message Then: it elects itself a leader 8 1 leader 2 5 6 3 4 7
The leader sends a message in the network declaring itself as the “leader of the ring” 8 1 leader 2 5 6 3 4 7
nodes Time complexity: 8 1 leader 2 5 6 3 4 7
Message complexity: nodes worst case scenario: n 1 n-1 2 n-2 n-3
Message complexity: nodes n 1 messages n-1 2 n-2 n-3
Message complexity: nodes n 1 messages n-1 2 n-2 n-3
Message complexity: nodes n 1 messages n-1 2 n-2 n-3
Message complexity: nodes Total messages: n 1 n-1 2 n-2 n-3
Notes: does not need to be known to the algorithm The algorithm can be converted to asynchronous
An O(n log n) Mess. Algorithm Again, the maximum id node is elected leader 8 1 2 5 6 3 4 7
nodes 8 nodes 1 2 5 6 3 4 7
Phase 1: send id to 1-neighborhood 1 8 8 1 8 5 2 2 1 2 5 6 5 6 3 4 6 3 3 7 4 7 7 4
If: received id current id Then: send a reply 8 1 2 5 6 3 4 7
If: a node receives both replies Then: it becomes a temporal leader 8 1 2 5 6 3 4 7
Phase 2: send id to 2-neighborhood 8 8 1 8 2 5 5 6 5 6 6 3 7 4 7 7
If: received id current id Then: forward the message 8 6 1 8 5 2 5 8 6 7 3 7 6 4 5 7
At second step: If: received id current id Then: send a reply 8 1 2 5 6 3 4 7
If: a node receives both replies Then: it becomes a temporal leader 8 1 2 5 6 3 4 7
Phase 3: send id to -neighborhood 8 1 8 2 5 8 7 7 6 3 4 7
If: received id current id Then: forward the message 8 1 8 2 5 8 7 7 6 3 4 7
At the step: If: received id current id Then: send a reply 8 1 2 5 6 3 4 7
If: a node receives both replies Then: it becomes the leader 8 1 2 5 6 3 4 7
8 1 leader 2 5 6 3 4 7
In general: nodes phases 8 1 leader 2 5 6
Phase i: send id to -neighborhood 8 1 leader 2 5 6
Time complexity The leader spends time in Phase 1:2 Phase 2:4 … Phase i: … Phase log n: Total time:
Message complexity Messages per leader Max #leaders Phase 1:4 Phase 2:8 … Phase i: … Phase log n:
Messages per leader Max #leaders Phase 1:4 Phase 2:8 … Phase i: … Phase log n: Total messages:
Notes: The algorithm does not need to know It can be converted to an asynchronous algorithm
An Mess. Synchronous Algorithm is known The node with smallest id is elected leader There are rounds: • If in round there is a node with id • this is the new leader • the algorithm terminates
Round 1 ( time steps): no message sent 48 9 22 15 nodes 16 33 24 57