Jaap-Henk Hoepman
Digital Security (DS) Radboud University Nijmegen, the Netherlands
@xotoxot // * jhh@cs.ru.nl // 8 www.cs.ru.nl/~jhh
Advanced Network Security
- 2. Distributed Algorithms:
Leader Election
Advanced Network Security 2. Distributed Algorithms: Leader - - PowerPoint PPT Presentation
Advanced Network Security 2. Distributed Algorithms: Leader Election Jaap-Henk Hoepman Digital Security (DS) Radboud University Nijmegen, the Netherlands @xotoxot // * jhh@cs.ru.nl // 8 www.cs.ru.nl/~jhh Leader election: motivation n IBM token
Jaap-Henk Hoepman
Digital Security (DS) Radboud University Nijmegen, the Netherlands
@xotoxot // * jhh@cs.ru.nl // 8 www.cs.ru.nl/~jhh
Advanced Network Security
Leader Election
Jaap-Henk Hoepman // Radboud University Nijmegen //
Leader election: motivation
n IBM token ring (1970)
to send
n How to
«0 tokens
«>1 tokens
02-03-2020 // Distributed algorithms - Leader Election 2
Jaap-Henk Hoepman // Radboud University Nijmegen //
Leader election (1)
n Given a graph ! = ($, &) of nodes, design a protocol that will elect a single node as leader n Output stored in local variable ( ) . +,-.,/
n Assumptions
ring network here
«E.g. a MAC address «Note that nodes do NOT know V (i.e. the set of identities in the graph)
02-03-2020 // Distributed algorithms - Leader Election 3
Jaap-Henk Hoepman // Radboud University Nijmegen //
Leader election (2)
n Requirements
elected).
n Leader election used, for example to
02-03-2020 // Distributed algorithms - Leader Election 4
" Safety
" " livenest
"
Jaap-Henk Hoepman // Radboud University Nijmegen //
How would/could you solve this?
02-03-2020 // Distributed algorithms - Leader Election 5
pint
message
passing
"
i
→
's
FIFO :#
k
^
✓
←
n
km )
Jaap-Henk Hoepman // Radboud University Nijmegen //
Jaap-Henk Hoepman // Radboud University Nijmegen //
Some non-solutions
n Node ) with ( ) . ). = 0 becomes leader
n Consider the following protocol for node )
the ring, this is not necessarily the case
02-03-2020 // Distributed algorithms - Leader Election 6
Send clockwise (right) ( ) . ). Receive counterclockwise (left) ). ( ) . +,-.,/ = (( ) . ). < ).)
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann’s protocol: leader election on a ring
n Assumption
n Protocol for node )
02-03-2020 // Distributed algorithms - Leader Election 7
9: = ∅ ( ) . +,-.,/ = 5-+6, send right ( ) . ). while ( ) . ). ∉ 9: do receive left ). 9: = 9: ∪ {).} send right ). ( ) . +,-.,/ = (( ) . ). = min
C
2 ∈ 9:) Election point
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann
n Why does this work? n What is the message / round complexity? n What if message passing is not FIFO?
02-03-2020 // Distributed algorithms - Leader Election 8
9 = ∅ ( ) . +,-.,/ = 5-+6, send right ( ) . ). while ( ) . ). ∉ 9 do receive left ). 9 = 9 ∪ {).} send right ). ( ) . +,-.,/ = (( ) . ). = min
C
2 ∈ 9)
has constant
size
.01N) for
a single node
⇒
total
message complexit
is
0 ( N')
Jaap-Henk Hoepman // Radboud University Nijmegen //
Le Lann
n Why does this work?
02-03-2020 // Distributed algorithms - Leader Election 9
9 = ∅ ( ) . +,-.,/ = 5-+6, send right ( ) . ). while ( ) . ). ∉ 9 do receive left ). 9 = 9 ∪ {).} send right ). ( ) . +,-.,/ = (( ) . ). = min
C
2 ∈ 9)
i
FIFO !
, →
40k
also
/
Identificeer
\
Jaap-Henk Hoepman // Radboud University Nijmegen //
Le Lann
n What is the message / round complexity?
02-03-2020 // Distributed algorithms - Leader Election 10
9 = ∅ ( ) . +,-.,/ = 5-+6, send right ( ) . ). while ( ) . ). ∉ 9 do receive left ). 9 = 9 ∪ {).} send right ). ( ) . +,-.,/ = (( ) . ). = min
C
2 ∈ 9)
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann
n Why does this work?
n What is the message / round complexity?
n What if message passing is not FIFO?
02-03-2020 // Distributed algorithms - Leader Election 11
9 = ∅ ( ) . +,-.,/ = 5-+6, send right ( ) . ). while ( ) . ). ∉ 9 do receive left ). 9 = 9 ∪ {).} send right ). ( ) . +,-.,/ = (( ) . ). = min
C
2 ∈ 9)
Jaap-Henk Hoepman // Radboud University Nijmegen //
Le Lann: proof
n Proof obligations
02-03-2020 // Distributed algorithms - Leader Election 12
9 = ∅ ( ) . +,-.,/ = 5-+6, send right ( ) . ). while ( ) . ). ∉ 9 do receive left ). 9 = 9 ∪ {).} send right ). ( ) . +,-.,/ = (( ) . ). = min
C
2 ∈ 9)
election ⇒
⑧
pour
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann proof of correctness (1)
n Correctness: at most one leader is elected (and once elected stays elected).
we have 9: = 9
identifiers.
C = ( G . ). G ∈ 0, D − 1
(nodes are numbered clockwise around the ring, and D is the number of nodes – which is unknown to the number of nodes!)
were received (instead of a set).
02-03-2020 // Distributed algorithms - Leader Election 13
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann proof of correctness (1)
n [correctness proof continued]
fact we show that when node ) receives the /-th message, it actually received 9: = (( ) − 1 mod D . )., … , ( ) − / mod D . ).) in that order.
messages have been received so far and 9: = ()
02-03-2020 // Distributed algorithms - Leader Election 14
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann proof of correctness (2)
n [correctness proof continued]
«All message received by node ) by round /L = / + 1 must have been sent by its left hand neighbour 2 = ) − 1 mod D in or before round /. «At the end of round / node 2 has sent all values in 9
C to ), in the same order,
but first sent out ( 2 . ). «Because of the FIFO property node ) receives these in the same order «Using the induction hypothesis 9
C = ( 2 − 1 mod D . )., … , ([2 − / mod D] in that
«Then ) receives ( 2 . )., … , ( 2 − r mod D = ( ) − 1 mod D . )., … , ( ) − /L . ). in that order as required.
02-03-2020 // Distributed algorithms - Leader Election 15
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann proof of correctness (3)
n [correctness proof continued]
message ( G . ). with G = ) − / mod D , equals ( ) . ). .
hence, 9: = (( ) − 1 mod D . )., … , ( ) − D mod D . ).)
02-03-2020 // Distributed algorithms - Leader Election 16
Jaap-Henk Hoepman // Radboud University Nijmegen //
LeLann proof of correctness (3)
n Progress: eventually a leader is elected.
node will eventually receive it) or received by the node (meaning it will be sent out to the right by that node)
stops
:
) ∈ 9) and hence becomes leader as required
02-03-2020 // Distributed algorithms - Leader Election 17
Jaap-Henk Hoepman // Radboud University Nijmegen //
What if nodes do not have unique identifiers?
02-03-2020 // Distributed algorithms - Leader Election 18
µ
leider
Jaap-Henk Hoepman // Radboud University Nijmegen //
What if nodes do not have unique identifiers?
n Then there exists a symmetric configuration (
n Starting in ( let all nodes take a step (the same) in turn, then
nodes)
n Therefore the resulting configuration (L is again symmetric n We can repeat this forever, never reaching a state where there is exactly one leader n This is called a symmetry argument
02-03-2020 // Distributed algorithms - Leader Election 19
Jaap-Henk Hoepman // Radboud University Nijmegen //
Peterson’s protocol: leader election on a ring
n Bidirectional communication
n Idea: algorithm proceeds in rounds
be eliminated (and become passive)
end of the round
02-03-2020 // Distributed algorithms - Leader Election 20
start with
N
modes :
Yom are garant eed
to
find
a
leader in
log ( N)
rounds
Jaap-Henk Hoepman // Radboud University Nijmegen //
Peterson’s protocol: leader election on a ring
n The protocol for node )
02-03-2020 // Distributed algorithms - Leader Election 21
( ) . -S0)T, = 0/1, ( ) . +,-.,/ = 5-+6, while 0/1, /* new round */ do if ( ) . -S0)T, == 0/1, ∧ ( ) . +,-.,/ == 5-+6, send left ( ) . ). send right ( ) . ). receive right /)Vℎ0). receive left +,50). if (( ) . ). == +,50).) ∧ (( ) . ). == /)Vℎ0).) ( ) . +,-.,/ = 0/1, else if (( ) . ). < +,50).) ∨ (( ) . ). < /)Vℎ0).) ( ) . -S0)T, = 5-+6, else /* passive or leader */ receive right ). ; send left ). receive left ). ; send right ).
Jaap-Henk Hoepman // Radboud University Nijmegen //
Peterson’s protocol
n Why does it work? n What is the message / round complexity? n What if message passing is not FIFO?
02-03-2020 // Distributed algorithms - Leader Election 22
( ) . -S0)T, = 0/1, ( ) . +,-.,/ = 5-+6, while 0/1, /* new round */ do if ( ) . -S0)T, == 0/1, ∧ ( ) . +,-.,/ == 5-+6, send left ( ) . ). send right ( ) . ). receive right /)Vℎ0). receive left +,50). if (( ) . ). == +,50).) ∧ (( ) . ). == /)Vℎ0).) ( ) . +,-.,/ = 0/1, else if (( ) . ). < +,50).) ∨ (( ) . ). < /)Vℎ0).) ( ) . -S0)T, = 5-+6, else /* passive or leader */ receive right ). ; send left ). receive left ). ; send right ).
Jaap-Henk Hoepman // Radboud University Nijmegen //
Peterson
02-03-2020 // Distributed algorithms - Leader Election 23
( ) . -S0)T, = 0/1, ( ) . +,-.,/ = 5-+6, while 0/1, /* new round */ do if ( ) . -S0)T, == 0/1, ∧ ( ) . +,-.,/ == 5-+6, send left ( ) . ). send right ( ) . ). receive right /)Vℎ0). receive left +,50). if (( ) . ). == +,50).) ∧ (( ) . ). == /)Vℎ0).) ( ) . +,-.,/ = 0/1, else if (( ) . ). < +,50).) ∨ (( ) . ). < /)Vℎ0).) ( ) . -S0)T, = 5-+6, else /* passive or leader */ receive right ). ; send left ). receive left ). ; send right ).
Jaap-Henk Hoepman // Radboud University Nijmegen //
Peterson’s protocol: leader election on a ring
n There are at most log D rounds
both its left and right active neighbour are smaller
survive
n In every round 2D messages are sent
messages in each round
n So: message complexity is at most 2D log D
02-03-2020 // Distributed algorithms - Leader Election 24
( ) . -S0)T, = 0/1, ( ) . +,-.,/ = 5-+6, while 0/1, /* new round */ do if ( ) . -S0)T, == 0/1, ∧ ( ) . +,-.,/ == 5-+6, send left ( ) . ). send right ( ) . ). receive right /)Vℎ0). receive left +,50). if (( ) . ). == +,50).) ∧ (( ) . ). == /)Vℎ0).) ( ) . +,-.,/ = 0/1, else if (( ) . ). < +,50).) ∨ (( ) . ). < /)Vℎ0).) ( ) . -S0)T, = 5-+6, else /* passive or leader */ receive right ). ; send left ). receive left ). ; send right ).
Jaap-Henk Hoepman // Radboud University Nijmegen //
i
Jaap-Henk Hoepman // Radboud University Nijmegen //
Peterson’s protocol: leader election on a ring
n There are at most log D rounds
both its left and right active neighbour are smaller
survive
n In every round 2D messages are sent
messages in each round
n So: message complexity is at most 2D log D
02-03-2020 // Distributed algorithms - Leader Election 24
( ) . -S0)T, = 0/1, ( ) . +,-.,/ = 5-+6, while 0/1, /* new round */ do if ( ) . -S0)T, == 0/1, ∧ ( ) . +,-.,/ == 5-+6, send left ( ) . ). send right ( ) . ). receive right /)Vℎ0). receive left +,50). if (( ) . ). == +,50).) ∧ (( ) . ). == /)Vℎ0).) ( ) . +,-.,/ = 0/1, else if (( ) . ). < +,50).) ∨ (( ) . ). < /)Vℎ0).) ( ) . -S0)T, = 5-+6, else /* passive or leader */ receive right ). ; send left ). receive left ). ; send right ).