Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Algorithms Broadcast and spanning tree.

Similar presentations


Presentation on theme: "Distributed Algorithms Broadcast and spanning tree."— Presentation transcript:

1 Distributed Algorithms Broadcast and spanning tree

2 Model  Node Information:  Adjacent links  Neighboring nodes.  Unique identity.  Graph model: undirected graph.  Nodes V  Edges E  Diameter D

3 Model Definition  Synchronous Model:  There is a global clock.  Packet can be sent only at clock ticks.  Packet sent at time t is received by t+1.  Asynchronous model:  Packet sent is eventually received.

4 Complexity Measures  Message complexity:  Number of messages sent (worst case).  Usually assume “small messages”.  Time complexity  Synchronous Model: number of clock ticks  Asynchronous Model: Assign delay to each message in (0,1]. Worse case over possible delays

5 Problems  Broadcast - Single initiator:  The initiator has an information.  At the end of the protocol all nodes receive the information  Example : Topology update.  Spanning Tree:  Single/Many initiators.  On termination there is a spanning tree.  BFS tree:  A minimum distance tree with respect to the originator.

6 Basic Flooding: Algorithm  Initiator:  Initially send a packet p(info) to all neighbors.  Every node:  When receiving a packet p(info): Sends a packet p(info) to all neighbors.

7 Basic Flooding: Example

8 Basic Flooding: Correctness  Correctness Proof:  By induction on the distance d from initiator. Basis d=0 trivial.  Induction step: Consider a node v at distance d. Its neighbor u of distance d-1 received the info. Therefore u sends a packet p(info) to all neighbors (including v). Eventually v receives p(info).

9 Basic Flooding: Complexity  Time Complexity  Synchronous (and asynchronous): Node at distance d receives the info by time d.  Message complexity:  There is no termination!  Message complexity is unbounded!  How can we correct this?

10 Basic Flooding: Improved  Each node v has a bit sent[v], initially sent[v]=FALSE.  Initiator:  Initially: Send packet p(info) to all neighbors and set sent[initiator]=TRUE.  Every node v:  When receiving a packet p(info) from u: IF sent[v]=FALSE THEN Send packet p(info) to all neighbors.

11 Basic Flooding: Improved  Message Complexity:  Each node sends once on each edge!  Number of messages equals to 2|E|.  Time complexity:  Diameter D.  Drawbacks  Termination detection

12 Spanning tree  Goal:  At the end of the protocol have a spanning tree  Motivation for building spanning tree:  Construction costs O(|E|).  Broadcast on tree: only |V|-1 messages.

13 Spanning tree: Algorithm  Data Structure:  Add to each node v a variable father[v].  Initially: father[v] = null.  Each node v:  When receiving packet p(info) from u and father[v]= null  THEN Set father [v]=u.

14 Spanning Tree : Example

15 Spanning tree Algorithm: Correctness  Correctness Proof:  Every node v (except the initiator) sets father[v].  There are no cycles.  Is it a shortest path tree?  Synchronous  Asynchronous

16 Flood with Termination  Motivation: Inform Initiator of termination.  Initiator:  Initially: Send packet p(info) to all neighbors and set set[initiator]=True  Non-Initiator node w :  When receiving a packet p(info) from u: IF sent[w]=FALSE –THEN father[w]=u ; send packet p(info) to all neighbors (except u). –ELSE Send Ack to u.  After receiving Ack from all neighbors except father[w]: Send Ack to father[w].

17 Flood with Termination: Correctness  Tree Construction: Proof as before.  Termination:  By induction on the distance from the leaves of the tree.  Basis d=0 (v is a leaf). Receives immediately Ack on all packets (except father[v] ). Sends Ack packet to father[v].  Induction step: All nodes at distance d-1 received and sent Ack. Nodes at distance d will eventually receive Ack, and eventually will send Ack.

18 DFS Tree  Data Structure in node v:  Edge-status[v,u] for each neighbor u.  Possible values are {NEW,SENT, Done}. Initially status[v,u]=NEW.  Node-status[v].  Possible Values {New, Visited, Terminated} Initially: Node-Status[v]=NEW (except the Initiator which have Node-Status[initiator]=Visited).  Parent[v]: Initially Parent[v]=Null  Packets type:  Token : traversing edges.

19 DFS: Algorithm  Token arrives at a node v from u:  Node_Status[v]=Visited & Edge_Status[v,u]=NEW Edge_Status[v,u]=Done ; Send token to u.  Node_Status[v]=Visited & Edge_Status[v,u]=Sent Edge_Status[v,u]=Done. (*) IF for some w: Edge_Status[v,w]=New THEN –Edge_Status[v,w]=Sent ; Send token to w. –ELSE Node_Status=Terminated ; send token to parent[v]. [If v is the initiator then DFS terminates]  Node_Status[v]=New Parent[v]=u; Node_Status[v]=Visited; Edge_Status[u,v]=Sent [Same as Node_Status[v]=Visited from (*)]

20 DFS : Example

21 DFS Tree: Performance  Correctness:  There is only one packet in transit at any time.  On each edge one packet is sent in each direction.  The parent relationship creates a DFS tree.  Complexity:  Messages: 2|E|  Time: 2|E|  How can we improve the time to O(|V|).

22 Spanning Tree: BFS  Synchronous model: have seen.  Asynchronous model:  Distributed Bellman-Ford  Distributed Dijkstra

23 BFS: Bellman-Ford  Data structure:  Each node v has a variable level[v].  Initially level[initiator]=0 at the initiator and level[v]=  at any other node v.  Variable parent, initialized at every node v to parent[v] = null.  Packet types:  layer(d) : there is a path of length at most d to the initiator.

24 BFS: Bellman-Ford Algorithm  Initiator:  Send packet layer(0) to all neighbors.  Every node v:  When receiving packet layer(d) from w  IF d+1 < level[v] THEN Parent[v]=w Level[v]=d+1 Send layer(d+1) to all neighbors (except w).

25 BFS: Bellman-Ford Correctness  Correctness Proof:  Termination: Each node u updates level[u] at most |V| times.  Relationship parent creates a tree  After termination: if parent[u]=w then level[u]=level[w]+1 [BSF Tree]  Complexity  Time: O(Diameter)  Messages: O(Diameter*|E|)

26 BFS: Bellman-Ford Example

27 Bellman Ford: Multiple initiators  Set distance (id-initiator,d).  Use Lexicographic ordering.  Each node can change level at most  Number of initiators * |V|  At most |V| 2

28 BSF: Dijkstra Illustrated 1k k+1

29 BFS: Dijkstra  Asynchronous model:  Advance one level at a time.  Go back to root after adding each level.  Time = O( D 2 )  Messages = O( |E| + D * |V| ) D=Diameter

30 BFS: Dijkstra  Data Structures:  Father[v]: the identity of the father of v.  Child[v,u]: u is a child of v in the tree.  Up[v,u]: u is closer to the initiator than v.  Packets  Pulse  forward  Father  Ack.

31 BFS: Dijkstra  In phase k:  Initiator sends a packet Pulse to its children.  Every node of the tree that receives a packet Pulse sends a packet Pulse to its children.  Every leaf v of the tree: Sends a packet forward to all neighbors w s.t. up[v,w]=FALSE. When receiving packet father[u] from u set child[v,u]=TRUE. When receiving either Ack or father[w] from all neighbors w with up[v,w]=FALSE : send Ack to father[v].  Every internal node v that receives Ack from all its children send Ack to its father father[v].

32 BFS: Dijkstra  A node u that receives a forward packet (from v):  First forward packet: Sets father[u]=v Sends father[u] to node v.  second (or more) forward packet: Send Ack to v.

33 BFS: Dijkstra  End of phase k:  Initiator receives Ack from all its children.  Initiator start phase k+1.  Termination:  If no new node is reached in last phase.

34 BFS: Dijkstra  Correctness:  Induction on the phases  Asynchronous model.  Time = O( D 2 )  Messages = O( |E| + D * |V| )  D=Diameter

35 Conclusion  Broadcast:  Flooding  Flooding with termination  Spanning tree  Unstructured spanning tree (using flooding)  DFS Tree  BFS Tree


Download ppt "Distributed Algorithms Broadcast and spanning tree."

Similar presentations


Ads by Google