Sie sind auf Seite 1von 30

Leader of the Ring K-neighborhood

Bar-Ilan Shmuel Goldklang 2007

Ring Network
Each node is connect to up to 2 other nodes. The kind of network can help to create a scalable and robust system.

Problem description
Algorithms that select a leader in a ring. Will DFS algorithms works? Sure, why not. But since the topology to the network is know, we can find algorithms that can yield better result.

Problem description
They are 3 dimensions to this problem. 1) Anonymous ring Vs Eponymous ring 2) Asynchronous ring Vs synchronous ring 3) Unknown node number Vs known node number.

Solution
K-Neighborhood Each time, each node is sending message to his 2 K-neighbor. Only if the node got 2 responses, it can continue to the next round. K is grow exponent

Algorithm
Initially asleep = true 1: 2: 3: 4: upon receiving no message: if asleep then asleep := false; send<probe,id,o,1> to left and right

Init procedure

5: upon receiving <probe,j,k,d> from left (resp, right): 6: if j = id the terminate as the leader 7: if j > id and d < 2^k then 8: send<probe,j,k,d+1> to right (resp, left) 9: if j > id and d >= 2^k then 10: send<reply,j,k> to the left (resp, right) 11: upon receiving <reply,j,k> from left (resp, right) 12: if j != id then 13: send<reply,j,k> to right (reps, left) 14: else 15 if already received<reply,j,k> from right (resp, left) then 16: send<probe,id,k+1,1) to left and right

Algorithm
Initially asleep = true 1: 2: 3: 4: upon receiving no message: if asleep then asleep := false; send<probe,id,o,1> to left and right

5: upon receiving <probe,j,k,d> from left (resp, right): 6: if j = id the terminate as the leader 7: if j > id and d < 2^k then 8: send<probe,j,k,d+1> to right (resp, left) 9: if j > id and d >= 2^k then 10: send<reply,j,k> to the left (resp, right)

Handle probe message

11: upon receiving <reply,j,k> from left (resp, right) 12: if j != id then 13: send<reply,j,k> to right (reps, left) 14: else 15 if already received<reply,j,k> from right (resp, left) then 16: send<probe,id,k+1,1) to left and right

Algorithm
Initially asleep = true 1: 2: 3: 4: upon receiving no message: if asleep then asleep := false; send<probe,id,o,1> to left and right

5: upon receiving <probe,j,k,d> from left (resp, right): 6: if j = id the terminate as the leader 7: if j > id and d < 2^k then 8: send<probe,j,k,d+1> to right (resp, left) 9: if j > id and d >= 2^k then 10: send<reply,j,k> to the left (resp, right) 11: upon receiving <reply,j,k> from left (resp, right) 12: if j != id then 13: send<reply,j,k> to right (reps, left) 14: else 15 if already received<reply,j,k> from right (resp, left) then 16: send<probe,id,k+1,1) to left and right

Handle reply message

Example
5 1 3

2 6

Example
5 1 3

2 6

K=0; HOP = 1

Example
5 1 3

2 6

K=0; HOP = 1

Example
5 1 3

2 6

K=1; HOP = 1

Example
5 1 3

2 6

K=1; HOP = 2

Example
5 1 3

2 6

K=1; HOP = 2

Example
5 1 3

2 6

K=1; HOP = 1

Example
5 1 3

2 6

K=2; HOP = 1

Example
5 1 3

2 6

K=2; HOP = 2

Example
5 1 3

2 6

K=2; HOP = 3

Example
5 1 3

2 6

K=2; HOP = 4

Example
5 1 3

2 6

K=2; HOP = 4

Example
5 1 3

2 6

K=2; HOP = 3

Example
5 1 3

2 6

K=2; HOP = 2

Example
5 1 3

2 6

K=2; HOP = 1

Example
5 1 3

2 6

K=3; HOP = 1

Example
5 1 3

2 6

K=3; HOP = 2

Example
5 1 3

2 6

K=3; HOP = 3

Example
5 1 3

2 6

K=3; HOP = 4

Example
5 1 3

2 6

K=3; HOP = 5

Example
5 1 3

2 6

K=3; HOP = 6

Example
5 1 3

2 6

K=3; HOP = 6

Das könnte Ihnen auch gefallen