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