Leader election in synchronous ring

A network graph of nodes 1 to n clock wise, Nodes do not need to know about their or neighbors numbers, But they are able to distinguish about clock wise and anti clock wise neighbors

Problem is selecting unique leader among themselves

Types of problems

  • Ring can be uni-directional or bi-directional
  • Number of nodes(n) can be known or unknown
  • Processes can be identical or can be distinguished by UID

Identical Processes

Theorem : Let AA be a system of nn processes, n>1n > 1, arranged in a bidirectional ring. If all the processes in AA are identical, then AA does not solve the leader-election problem.

Intuition : By symmetry, what one does, so do the others

Cannot find leader in identical process because of symmetry, To break symmetry, one solution is UID's

LCR Algorithm

  • Assumes only unidirectional ring
  • Does not rely on knowing the size of the ring
  • Only the leader performs output
  • Uses comparisons on UIDs (uu)

Each process sends its identifier around the ring. When a process receives an incoming identifier, it compares that identifier to its own.

  1. If the incoming identifier is greater than its own, it keeps passing the identifier.
  2. If it is less than its own, it discards the incoming identifier.
  3. If it is equal to its own, the process declares itself the leader.

Fromally

MM = set of UIDs

statesistates_i

  • sendM{null}send \in M \cup \{null\}, initially uu
  • status{unknown,leader}status \in \{unknown, leader\}, initially unknownunknown

startistart_i consists of the single state defined by the given initializations.

msgsimsgs_i send the current value of send to i+1i+1

transitrans_i

send := null
if the incoming messsage is v, then
    v > u: send := v
    v = u: status := leader
    v < u: do nothing

Output after nn rounds

  • Process imaxi_max outputs leader by the end of round nn.

Halting

We can modify above algorithm by allowing the elected leader to initiate a special report message to be sent around the ring. Any process that receives the report message can halt, after passing it on and set itself as non-leader

Complexity analysis

Time complexity - O(n)O(n) Communication complexity - O(n2)O(n^2)

HS Algorithm

  • Assumes bidirectional ring
  • Does not rely on knowing the size of the ring
  • Only the leader performs output
  • Uses comparisons on UIDs (uu)

Processes operate in phases 0,1,2,...0, 1, 2, .... In each phase, processes send token with UID in both directions. Tokens in phase ll intend to travel 2l2^l and turn back to sender

  1. If a received UID is greater than self UID, it is relayed on
  2. If it is smaller, it is discarded
  3. If it is equal, the process outputs leader

Formally

MM is the set of triples consisting of a UID, a flag value in {out,in}\{out, in\}, and a positive integer hopcounthop-count.

statesistates_i

  • uu of type UID, initially ii's UID
  • send+M{null}send+ \in M \cup \{null\}, initially ii's UID, out, 1
  • sendM{null}send- \in M \cup \{null\}, initially ii's UID, out, 1
  • status{unknown,leader}status \in \{unknown, leader\}, initially unknownunknown
  • phasephase non negative integer, initially 0

startistart_i consists of the single state defined by the given initializations.

msgsimsgs_i

  • send the current value of send+send+ to i+1i+1
  • send the current value of sendsend- to i1i-1

transitrans_i

send+ := null
send- := null
if the message from i-1 is (v, out, h) then
    v > u and h > 1: send+ := (v, out, h-1)
    v > u and h = 1: send- := (v, in, 1)
    v = u: status := leader
if the message from i+1 is (v, out, h) then
    v > u and h > 1: send- := (v, out, h-1)
    v > u and h = 1: send+ := (v, in, 1)
    v = u: status := leader
if the message from i-1 is (v, in, 1) and  v != u then
    send+ := (v, in, 1)
if the message from i-1 is (v, in, 1) and  v != u then
    send- := (v, in, 1)
if the messages from i-1 or i+1 is (u, in, 1) then
    phase := phase + 1
    send+ := (u, out, 2**phase)
    send- := (u, out, 2**phase)

Complexity analysis

Check out the book provided below

Correctness

  • A process with UID uu only outputs leader when a message started at uu travels the whole ring and arrives back at uu.
  • At most one process can become leader: the one with the maximum UID.

results matching ""

    No results matching ""