1 / 43

Leader in a clique in O(nlog(n)) messages

Leader in a clique in O(nlog(n)) messages. By Pierre A. Humblet and the help of Miki Asa. Rules of the game. Initialization : Each node has {1 . . N-1} edges + edge (–1) to itself. master(id) = id, state = active. Node attempt to capture other nodes (increase the size of their domain).

nitza
Download Presentation

Leader in a clique in O(nlog(n)) messages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Leader in a clique in O(nlog(n)) messages By Pierre A. Humblet and the help of Miki Asa

  2. Rules of the game • Initialization : • Each node has {1 . . N-1} edges + edge (–1) to itself. • master(id) = id, state = active. • Node attempt to capture other nodes (increase the size of their domain). • A node that has been captured stop capturing and it’s state = stopped. • Node can be captured by many other nodes but has only one master the last one that captured it. • Node that captured all the nodes leader

  3. How it’s done 2 messages • TEST(size,id) • An attempt to capture other node. • A TEST from a node I didn’t captured  forward to my master. • A TEST from a node I captured  answer it with WINNER(id). • WINNER(id) • The result of the fight  id won the fight. • Determined by who got bigger domain (if equal bigger id)

  4. A B State = active Master = A State = active Master = B

  5. B wins Waiting A B B wins AB : TEST(size(A),id(A)) BB : TEST(size(A),id(A)) BB : WINNER(B)

  6. B wins A B State = active Master = A State = active Master = B B wins AB : TEST(size(A),id(A)) BB : TEST(size(A),id(A)) BB : WINNER(B)

  7. A wins A B A wins AB : TEST(size(A),id(A)) BB : TEST(size(A),id(A)) BB : WINNER(A) BA : WINNER(A)

  8. A wins A B State = active Master = A State = stop Master = A A wins AB : TEST(size(A),id(A)) BB : TEST(size(A),id(A)) BB : WINNER(A) BA : WINNER(A)

  9. State = active Master = A A C B State = active Master = C State = stop Master = A

  10. A wins A Waiting C B A wins CB : TEST(size(C),id(C)) BA : TEST(size(C),id(C)) AB : WINNER(A)

  11. A wins State = active Master = A A C B State = stop Master = A State = active Master = C A wins CB : TEST(size(C),id(C)) BA : TEST(size(C),id(C)) AB : WINNER(A)

  12. C wins A C B C wins CB : TEST(size(C),id(C)) BA : TEST(size(C),id(C)) AB : WINNER(C) BC : WINNER(C)

  13. C wins State = stop Master = A A C B State = stop Master = C State = active Master = C C wins CB : TEST(size(C),id(C)) BA : TEST(size(C),id(C)) AB : WINNER(C) BC : WINNER(C)

  14. Variables STATE : active – won all the fights stopped – lost a fight  won’t be a leader SIZE : number of nodes I captured (send me winner (ID)) including me (size of my domain). MASTER : the id of my master. EDGE(id) : the edge leading to node id Dealing with messages PENDING_SET : messages waiting to be forward to the master PENDING : number of messages in PENDING_SET Initialization Each awaken node with ID receive winner(ID) on edge > 0.

  15. Receiving WINNER(id) on edge e If (id = ID) // I won the fight { if (e > 0 & state = active) // fight that I initiated { SIZE ++ if SIZE = N // I capture all the nodes stop // announce elected else send TEST(SIZE,ID) on edge SIZE //continue } else // I didn’t initiate the fight do nothing }

  16. Receiving WINNER(id) (cont.) Else // id != ID { if (MASTER != id) // my master lost { MASTER = id // change the master Send WINNER(id) on EDGE(id) // inform the new master } Else // my master won { do nothing } PENDING - - // continue as a slave if PENDING > 0 send from PENDING_SET on EDGE(MASTER) }

  17. Receiving TEST(size,id) on edge e If e < SIZE // message from my domain { if (size,id) > (SIZE,ID) // I lost this fight { STATE = stopped // out of the game send WINNER(id) on EDGE e // inform the new master } else // I won send WINNER(ID) on EDGE e // inform my slave that I won } Else // not from my domain { EDGE(id) = e // update my data-base PENDING ++ // send TEST to the master If PENDING = 1 send TEST(size,id) on EDGE (MASTER) else put TEST(size,id) on EDGE (MASTER) on PENDING_SET }

  18. state Size Master active 1 2 2 active 1 3 active 1 1 1 3 6 4 active 1 4 active 1 6 5 active 1 5

  19. state Size Master active 1 2 2 active 2 3 stop 1 3 1 3 6 4 active 1 4 active 1 6 5 active 1 5

  20. state Size Master active 1 2 2 active 2 4 active 2 3 stop 1 4 stop 1 3 1 1 3 4 Waiting 8 6 4 active 1 4 active 1 6 5 active 1 5

  21. state Size Master active 1 2 2 active 2 3 stop 1 3 1 3 Waiting 6 4 active 1 4 active 1 6 5 active 1 5

  22. state Size Master active 1 2 2 active 2 3 stop 1 3 1 3 Waiting 6 4 stop 1 6 active 2 6 5 active 1 5

  23. state Size Master active 1 2 2 active 2 3 stop 1 3 1 3 Waiting Waiting 6 4 stop 1 6 active 2 6 5 active 1 5

  24. state Size Master active 1 2 2 active 2 3 stop 1 3 1 3 Waiting Waiting 6 4 stop 1 6 active 2 6 5 active 1 5

  25. state Size Master active 1 2 2 stop 2 3 stop 1 6 1 3 Waiting Waiting 6 4 stop 1 6 active 3 6 5 active 1 5

  26. state Size Master active 1 2 2 stop 2 3 stop 1 6 1 3 Waiting Waiting 6 4 stop 1 6 active 3 6 5 active 1 5

  27. state Size Master active 1 2 2 stop 2 3 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 3 6 5 stop 1 3

  28. state Size Master active 1 2 2 stop 2 3 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 3 6 5 stop 1 3

  29. state Size Master active 1 2 2 stop 2 6 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 4 6 5 stop 1 3

  30. state Size Master active 1 2 Waiting 2 stop 2 6 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 4 6 5 stop 1 3

  31. state Size Master active 1 2 Waiting 2 stop 2 6 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 4 6 5 stop 1 3

  32. state Size Master active 1 6 Waiting 2 stop 2 6 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 5 6 5 stop 1 3

  33. state Size Master active 1 6 Waiting 2 stop 2 6 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 5 6 5 stop 1 3

  34. state Size Master active 1 6 Waiting 2 stop 2 6 stop 1 6 1 3 Waiting 6 4 stop 1 6 active 6 6 5 stop 1 6

  35. Termination • Each node can’t send more then N-1 TEST. • Each TEST cause at the most 3 more messages.

  36. Correctness Lemma 1 At the end of the algorithm there will be a node with size = N. Proof • Size only grows with time. • For each TEST sent • size++ or • Node is “Waiting” • Therefore Enough to prove there is no deadlock

  37. Liveness • Suppose there is a deadlock • Lets take the node with the biggest (size,ID)  it’s active. • Eventually it will get an answer for the last test it initiated. Winner(ID). • Once he’ll get that answer  size++ • Size = N  leader • Send TEST for the next node

  38. complexity My domain: the nodes from which I received winner(ID) while I was active + myself. Lemma 1 SIZE = size of my domain. If (id = ID) // I won the fight { if (e > 0 & state = active) // fight that I initiated { SIZE ++ • Got winner(ID) from other node & state = active  all conditions fulfill  size++ • Size++  all conditions fulfill  Got winner(ID) from other node & state = active

  39. Lemma 2 If SIZE(A) at time Ta = SIZE(B) at time Tb then the domains at Ta & Tb are disjoint. Proof: Assume domain(A) & domain(B) are joint at Ta or Tb  They are joint at max(Ta,Tb)  There is a Tm < max(Ta,Tb) s.t. At Tm a node from domain(A) join domain(B)  After Tm domain(A) doesn’t grow  At Tm Size(A) >= SIZE  Tm > Ta After Tm domain(B) > domain(A) >= SIZE  Tm > Tb Contradiction

  40. Lemma 3 Rank the nodes in decreasing order by their SIZE at termination. S1, S2, S3, . . . , Sn-1, Sn Then Sk <= N/k Proof S1 – Sk-1 had once the size of Sk there all disjoint (lemma 2) conclusion There is only one node with SIZE=N  one leader

  41. Number of TEST sent If (id = ID) // I won the fight { if (e > 0 & state = active) // fight that I initiated { SIZE ++ if SIZE = N // I capture all the nodes stop // announce elected else send TEST(SIZE,ID) on EDGE(SIZE) //continue } For each TEST sent  SIZE++ Each TEST cause at the most 3 more messages

  42. Total number of messages is no more then 4*(N/1 + N/2 + N/3 + . . . + N/K) = O(N log(K)) K = the number of nodes awake.

  43. Improvements • The bound for the number of messages can be tightened by noticing that the first TEST received by a generates at the most one more message. • The algorithm can stop as soon as SIZE = N/2 (then announce elected).

More Related