Leader Election in Rings - PowerPoint PPT Presentation

1 / 95
About This Presentation
Title:

Leader Election in Rings

Description:

Anonymous Ring. Eponymous Ring. The size of the network is known ... declaring itself as the 'leader of the ring' 22. 1. 2. 3. 4. 5. 6. 7. 8. leader. Time complexity: ... – PowerPoint PPT presentation

Number of Views:94
Avg rating:3.0/5.0
Slides: 96
Provided by: costas
Category:
Tags: election | leader | ring | rings | the

less

Transcript and Presenter's Notes

Title: Leader Election in Rings


1
Leader Election in Rings

2
A Ring Network
3
Sense of direction
left
2
1
1
right
2
2
1
1
2
2
1
1
2
2
1
1
2
4
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
5
Anonymous Ring
2
1
1
2
2
1
1
2
2
1
1
2
2
1
1
2
6
Eponymous (non-anonymous) Ring
7
Leader Election
Initial state
Final state
leader
8
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
9
Synchronous Anonymous Rings
Every processor runs the same algorithm
Every processor does exactly the same execution
10
Initial state
Final state
leader
If one node is elected a leader, then every node
is elected a leader
11
Final state
Conclusion 1
Leader election cannot be solved in
synchronous anonymous rings
leader
12
Final state
Conclusion 2
Leader election cannot be solved in
asynchronous anonymous rings either
leader
Why?
The asynchronous ring may behave Like the
synchronous ring
13
Asynchronous Eponymous Rings
The maximum id node is elected leader
8
1
2
5
6
3
4
7
14
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
15
If message received id current node id
Then forward message
5
8
1
2
8
5
6
7
3
4
7
6
16
If message received id current node id
Then forward message
8
1
7
2
5
6
8
3
4
7
17
If message received id current node id
Then forward message
7
8
1
2
5
6
3
4
7
8
18
If message received id current node id
Then forward message
8
1
2
5
6
3
4
8
7
19
If a node receives its own message
Then it elects itself a leader
8
8
1
2
5
6
3
4
7
20
If a node receives its own message
Then it elects itself a leader
8
1
leader
2
5
6
3
4
7
21
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
22
nodes
Time complexity
8
1
leader
2
5
6
3
4
7
23
Message complexity
nodes
worst case scenario
n
1
n-1
2
n-2
n-3
24
Message complexity
nodes
n
1
messages
n-1
2
n-2
n-3
25
Message complexity
nodes
n
1
messages
n-1
2
n-2
n-3
26
Message complexity
nodes
n
1
messages
n-1
2
n-2
n-3
27
Message complexity
nodes
Total messages
n
1
n-1
2
n-2
n-3
28
Notes
does not need to be known to the algorithm
The algorithm can be converted to asynchronous
29
An O(n log n) Mess. Algorithm
Again, the maximum id node is elected leader
8
1
2
5
6
3
4
7
30
nodes
8
nodes
1
2
5
6
3
4
7
31
Phase 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
32
If received id current id Then send
a reply
8
1
2
5
6
3
4
7
33
If a node receives both replies Then it
becomes a temporal leader
8
1
2
5
6
3
4
7
34
Phase 2 send id to 2-neighborhood
8
8
1
8
2
5
5
6
6
5
6
3
7
4
7
7
35
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
36
At second step
If received id current id Then send
a reply
8
1
2
5
6
3
4
7
37
If a node receives both replies Then it
becomes a temporal leader
8
1
2
5
6
3
4
7
38
Phase 3 send id to -neighborhood
8
1
8
2
5
8
7
7
6
3
4
7
39
If received id current id Then
forward the message
8
1
8
2
5
8
7
7
6
3
4
7
40
At the step
If received id current id Then send
a reply
8
1
2
5
6
3
4
7
41
If a node receives both replies Then it
becomes the leader
8
1
2
5
6
3
4
7
42
8
1
leader
2
5
6
3
4
7
43
In general
nodes
phases
8
1
leader
2
5
6
44
Phase i send id to -neighborhood
8
1
leader
2
5
6
45
Time complexity
The leader spends time in
Phase 1 2 Phase 2 4 Phase i Phase log n
Total time
46
Message complexity
Messages per leader
Max leaders
Phase 1 4 Phase 2 8 Phase i Phase log n
47
Messages per leader
Max leaders
Phase 1 4 Phase 2 8 Phase i Phase log n
Total messages
48
Notes
The algorithm does not need to know
It can be converted to an asynchronous algorithm
49
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

50
Round 1 ( time steps) no message sent
48
9
22
15
nodes
16
33
24
57
51
Round 2 ( time steps) no message sent
48
9
22
15
nodes
16
33
24
57
52
Round 9
new leader
48
9
22
15
nodes
16
33
24
57
53
Round 9 ( time steps) messages sent
new leader
48
9
22
15
nodes
16
33
24
57
54
Round 9 ( time steps) messages sent
new leader
48
9
22
15
nodes
16
33
24
57
Algorithm Terminates
55
Round 9 ( time steps) messages sent
new leader
48
9
22
15
nodes
16
33
24
57
Total number of messages
56
Another Synchronous Algorithm
is not known
The node with smallest id is elected leader
57
The 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

58
Time 1
Transfer rate
0
0
4
2
5
6
3
1
7
59
Time 2
0
4
2
rate
5
0
6
3
1
7
1
60
Time 3
0
4
2
5
6
3
0
1
7
1
61
Time 4
0
4
2
5
6
3
1
1
7
0
62
Time 5
0
4
2
5
6
3
1
0
7
63
Time 6
0
4
2
5
6
0
3
1
7
64
Time 8
0
0
4
2
5
6
3
1
7
65
Time 8
New leader
0
0
4
2
5
6
3
1
7
66
Message complexity
Assume leader has (smallest) id
Total time of algorithm
Note that if then algorithm is
exponentially slow
67
Take the node with immediately higher id
Total number of messages
68
Take the node with immediately higher id
Total number of messages
69
messages
id
lower
higher
Total messages
70
An 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
71
Messages 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
72
Messages 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
73
Messages 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)
74
Time t
Suppose that the edge closes
This may cause a propagation of messages until
the algorithm terminates
75
Time t1
This may cause a propagation of messages until
the algorithm terminates
76
Time t2
This may cause a propagation of messages until
the algorithm terminates
77
Time tk
k
k
After k time steps the affected radius is k
78
Time tx
Eventually, the ring stabilizes with a leader
79
We will show, that there is an execution with
nodes such that
  • there is an open edge
  • at least messages are received

where
80
Proof by induction
basis case
x
y
If then is the leader
Therefore a message is sent
81
open edge
x
y
The message can be sent on one edge
82
The case
From induction hypothesis, we have an execution
open edge
nodes
Messages sent
83
The case
From induction hypothesis, we have an execution
open edges
nodes
nodes
Messages sent
84
If no message is sent along
Observation
then ring cannot distinguish the
two scenarios
(similarly for ring )
85
Therefore, the same number of messages have to be
sent in sub-rings
True open edge
nodes
nodes
True open edge
Messages sent
86
All nodes in should learn about
open edge
max id
open edge
(assume that max id is in )
87
All 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
88
Suppose edges close at time
max id
At least one message is sent
89
time
max id
At least one message is sent
90
time
max id
At least messages have been sent since
91
time
radius
max id
At least messages have been sent since
92
time
radius
max id
Independent areas
At least messages have been sent since
93
Messages
time
radius
max id
Independent areas
At least messages have been sent in one area
94
Messages
time
radius
max id
open edge
Since areas are independent, we could have closed
only one edge
95
Messages
time
radius
max id
open edge
Total Messages
Induction Hypothesis
Write a Comment
User Comments (0)
About PowerShow.com