You are on page 1of 42

Leader Election in Rings

Continued

An

( n log n) Lower Bound

Assume we have algorithms in which: the maximum identifier is elected leader all the nodes must know the leader the size of the network We will prove: at least

n is not known

( n log n) messages are needed


2

1 5

8 2 6

3 7

open edge

No message is delivered on an open edge Messages may be kept on the adjacent nodes
3

The concept of the Proof


We will show that there exist admissible execution in which ( n log n) messages are sent we paste together two different rings of size n/2 and force additional messages to be received this relies on the fact that the processors dont know the size of the ring
4

We will show, that there is an execution with n nodes such that: there is an open edge at least where

M (n) messages are received M ( 2) = 1 n + n M ( n) = 2 M 2 4

Proof by induction The case

n=2

If

x > y then x is the leader

y should know about this


Therefore:

M ( 2) = 1
6

The case

n=2
x

open edge y

If

x > y then x is the leader M ( 2) = 1


7

y should know about this


Therefore:

The case

n>2

From induction hypothesis we have:

n nodes 2

open edge

n messages M 2
8

The case

n>2

From induction hypothesis we have:

n nodes 2
n M 2

open edges

n nodes 2
n M 2
9

messages

The case

n>2

max id

R1

R2

All nodes in

R2 should learn about x


10

The case

n>2
Possibility 1

max id

open edge

R1

n nodes 2

n 2

Messages are sent


11

The case

n>2
Possibility 2

max id

R1
open edge

n nodes 2

n 2

Messages are sent


12

The case

n>2
Worst case scenario
open edge?

max id

R1

n nodes 2

n 2

Messages are sent


13

The case

n>2
Worst case scenario

max id

open edge

R1

n nodes 2

n At least messages are sent 4

14

The case

n>2
Worst case scenario

max id

open edge

n M 2

n M 2

n + Mn + n Total messages: M 2 2 4

15

The case

n>2
Worst case scenario

max id

open edge

n M 2

n M 2

n + n Total messages: M ( n) = 2 M 2 4

16

The case

n>2
Worst case scenario

max id

open edge

n M 2

n M 2

Total messages:

M (n) = (n log n)
17

We can complete an execution by letting messages traverse an open edge

max id

open edge

18

We can complete an execution by letting messages traverse an open edge

max id

Total messages:

M (n) = (n log n)
19

Synchronous Rings
Asynchronous Ring- delaying messages for arbitrarily long periods Synchronous Model- message delay is fixed Information can be obtained not only by receiving a message but also by not receiving a message in a certain round
20

An O (n) Synchronous Algorithm

n is known
The node with smallest id is elected leader

There are rounds: If in round i there is a node with id this is the new leader the algorithm terminates

21

Round 1 (

n time steps): no message sent


9 48 22

15

n nodes
16

33 57 24
22

Round 2 ( n time steps): 48

no message sent

9 15

22

n nodes
16

33 57 24
23

Round 9 new leader 9 15 48 22

n nodes
16

33 57 24
24

Round 9 (

n time steps):
48

n messages sent

new leader 9 15

22

n nodes
16

33 57 24
25

Round 9 (

n time steps):
48

n messages sent

new leader 9 15

22

n nodes
16

33 57 Algorithm Terminates 24
26

Round 9 (

n time steps):
48

n messages sent

new leader 9 15

22

n nodes
16

33 57 24

Total number of messages:

27

Another O (n) Synchronous Algorithm

n is not known
The node with smallest id is elected leader

28

The algorithm: Each node injects a message at time 0 Message with id with rate

i is transferred

Nodes which have seen smaller id absorb higher id messages


29

Time 1 4 5 6 3 7 1
30

Time 2 4 5 0 2
0

6 3 7 1
1
31

Time 3 4 5 6 3 7 1
1
32

0 2

Time 4 4 5 6 3
1

0 2

1
0
33

Time 5 4 5 6 3
0

0 2

1
34

Time 6 4 5
0

0 2

6 3 7 1
35

Time 8
0

4 5

0 2

6 3 7 1
36

Time 8
0

New leader 0 2

4 5

6 3 7 1
37

Message complexity Assume leader has id

i n2
i

Total time of algorithm:

38

Take the node with immediately higher id

k >i
Total number of messages:

total time of algorithm n2 n = k < message delay on each edge 2 2


39

Take the node with immediately higher id

l >k >i
Total number of messages:

n2

n < l 4 2
40

id lower

messages

i
k

n
n/2 n/4

higher

KK
41

n n n + + + L 2n 2 4
Total number of messages:

O ( n)

42

You might also like