Title: Leader Election in Rings
1Leader Election in Rings
2A Ring Network
3Sense of direction
left
2
1
1
right
2
2
1
1
2
2
1
1
2
2
1
1
2
4Links 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
5Anonymous Ring
2
1
1
2
2
1
1
2
2
1
1
2
2
1
1
2
6Eponymous (non-anonymous) Ring
7Leader Election
Initial state
Final state
leader
8Leader 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
9Synchronous Anonymous Rings
Every processor runs the same algorithm
Every processor does exactly the same execution
10Initial state
Final state
leader
If one node is elected a leader, then every node
is elected a leader
11Final state
Conclusion 1
Leader election cannot be solved in
synchronous anonymous rings
leader
12Final state
Conclusion 2
Leader election cannot be solved in
asynchronous anonymous rings either
leader
Why?
The asynchronous ring may behave Like the
synchronous ring
13Asynchronous Eponymous Rings
The maximum id node is elected leader
8
1
2
5
6
3
4
7
14Each 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
15If message received id current node id
Then forward message
5
8
1
2
8
5
6
7
3
4
7
6
16If message received id current node id
Then forward message
8
1
7
2
5
6
8
3
4
7
17If message received id current node id
Then forward message
7
8
1
2
5
6
3
4
7
8
18If message received id current node id
Then forward message
8
1
2
5
6
3
4
8
7
19If a node receives its own message
Then it elects itself a leader
8
8
1
2
5
6
3
4
7
20If a node receives its own message
Then it elects itself a leader
8
1
leader
2
5
6
3
4
7
21The leader sends a message in the
network declaring itself as the leader of the
ring
8
1
leader
2
5
6
3
4
7
22nodes
Time complexity
8
1
leader
2
5
6
3
4
7
23Message complexity
nodes
worst case scenario
n
1
n-1
2
n-2
n-3
24Message complexity
nodes
n
1
messages
n-1
2
n-2
n-3
25Message complexity
nodes
n
1
messages
n-1
2
n-2
n-3
26Message complexity
nodes
n
1
messages
n-1
2
n-2
n-3
27Message complexity
nodes
Total messages
n
1
n-1
2
n-2
n-3
28Notes
does not need to be known to the algorithm
The algorithm can be converted to asynchronous
29An O(n log n) Mess. Algorithm
Again, the maximum id node is elected leader
8
1
2
5
6
3
4
7
30nodes
8
nodes
1
2
5
6
3
4
7
31Phase 1 send id to 1-neighborhood
1
8
8
1
8
5
2
2
1
2
5
6
6
5
3
4
6
3
3
7
4
7
7
4
32If received id current id Then send
a reply
8
1
2
5
6
3
4
7
33If a node receives both replies Then it
becomes a temporal leader
8
1
2
5
6
3
4
7
34Phase 2 send id to 2-neighborhood
8
8
1
8
2
5
5
6
6
5
6
3
7
4
7
7
35If received id current id Then
forward the message
8
6
1
8
5
2
5
8
6
7
3
7
6
4
5
7
36At second step
If received id current id Then send
a reply
8
1
2
5
6
3
4
7
37If a node receives both replies Then it
becomes a temporal leader
8
1
2
5
6
3
4
7
38Phase 3 send id to -neighborhood
8
1
8
2
5
8
7
7
6
3
4
7
39If received id current id Then
forward the message
8
1
8
2
5
8
7
7
6
3
4
7
40At the step
If received id current id Then send
a reply
8
1
2
5
6
3
4
7
41If a node receives both replies Then it
becomes the leader
8
1
2
5
6
3
4
7
428
1
leader
2
5
6
3
4
7
43In general
nodes
phases
8
1
leader
2
5
6
44Phase i send id to -neighborhood
8
1
leader
2
5
6
45Time complexity
The leader spends time in
Phase 1 2 Phase 2 4 Phase i Phase log n
Total time
46Message complexity
Messages per leader
Max leaders
Phase 1 4 Phase 2 8 Phase i Phase log n
47Messages per leader
Max leaders
Phase 1 4 Phase 2 8 Phase i Phase log n
Total messages
48Notes
The algorithm does not need to know
It can be converted to an asynchronous algorithm
49An 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
50Round 1 ( time steps) no message sent
48
9
22
15
nodes
16
33
24
57
51Round 2 ( time steps) no message sent
48
9
22
15
nodes
16
33
24
57
52Round 9
new leader
48
9
22
15
nodes
16
33
24
57
53Round 9 ( time steps) messages sent
new leader
48
9
22
15
nodes
16
33
24
57
54Round 9 ( time steps) messages sent
new leader
48
9
22
15
nodes
16
33
24
57
Algorithm Terminates
55Round 9 ( time steps) messages sent
new leader
48
9
22
15
nodes
16
33
24
57
Total number of messages
56Another Synchronous Algorithm
is not known
The node with smallest id is elected leader
57The algorithm
- Each node injects a message with its id
- Message with id is injected and
- transferred with rate
- Nodes which have seen smaller id
- absorb higher id messages
58Time 1
Transfer rate
0
0
4
2
5
6
3
1
7
59Time 2
0
4
2
rate
5
0
6
3
1
7
1
60Time 3
0
4
2
5
6
3
0
1
7
1
61Time 4
0
4
2
5
6
3
1
1
7
0
62Time 5
0
4
2
5
6
3
1
0
7
63Time 6
0
4
2
5
6
0
3
1
7
64Time 8
0
0
4
2
5
6
3
1
7
65Time 8
New leader
0
0
4
2
5
6
3
1
7
66Message complexity
Assume leader has (smallest) id
Total time of algorithm
Note that if then algorithm is
exponentially slow
67Take the node with immediately higher id
Total number of messages
68Take the node with immediately higher id
Total number of messages
69messages
id
lower
higher
Total messages
70An Lower Bound
Assume we have algorithms in which
- the network is asynchronous
- the maximum identifier is elected leader
- all the nodes must know the leader
- the size of the network is not known
We will prove
at least messages are needed
to elect a leader
71Messages may be pending to cross open edge
open edge
no messages cross it
(i.e. a very slow edge)
There is a possible asynchronous execution with
an open edge
72Messages pending to cross open edge
open edge
Quiescent State
If the edge remains open, then the execution will
eventually reach a quiescent state where not more
messages cross the ring
73Messages pending to cross open edge
open edge
Quiescent State
In the quiescent state, a node can send a
message only after it receives a message (thus no
messages cross the ring)
74Time t
Suppose that the edge closes
This may cause a propagation of messages until
the algorithm terminates
75Time t1
This may cause a propagation of messages until
the algorithm terminates
76Time t2
This may cause a propagation of messages until
the algorithm terminates
77Time tk
k
k
After k time steps the affected radius is k
78Time tx
Eventually, the ring stabilizes with a leader
79We will show, that there is an execution with
nodes such that
- at least messages are received
where
80Proof by induction
basis case
x
y
If then is the leader
Therefore a message is sent
81open edge
x
y
The message can be sent on one edge
82The case
From induction hypothesis, we have an execution
open edge
nodes
Messages sent
83The case
From induction hypothesis, we have an execution
open edges
nodes
nodes
Messages sent
84If no message is sent along
Observation
then ring cannot distinguish the
two scenarios
(similarly for ring )
85Therefore, the same number of messages have to be
sent in sub-rings
True open edge
nodes
nodes
True open edge
Messages sent
86All nodes in should learn about
open edge
max id
open edge
(assume that max id is in )
87All nodes in should learn about
max id
(At least one of these is sent)
Thus, after the open edges close, at least
messages are sent
88Suppose edges close at time
max id
At least one message is sent
89time
max id
At least one message is sent
90time
max id
At least messages have been sent since
91time
radius
max id
At least messages have been sent since
92time
radius
max id
Independent areas
At least messages have been sent since
93Messages
time
radius
max id
Independent areas
At least messages have been sent in one area
94Messages
time
radius
max id
open edge
Since areas are independent, we could have closed
only one edge
95Messages
time
radius
max id
open edge
Total Messages
Induction Hypothesis