310 likes | 432 Views
CPSC 689: Discrete Algorithms for Mobile and Wireless Systems. Spring 2009 Prof. Jennifer Welch. Lecture 28. Topic: Distributed Primitives Using Link Reversal Sources: Walter, Welch & Vaidya Malpani, Welch & Vaidya Ingram, Shields, Walter & Welch MIT 6.885 Fall 2008 slides.
E N D
CPSC 689: Discrete Algorithms for Mobile and Wireless Systems Spring 2009 Prof. Jennifer Welch
Lecture 28 • Topic: • Distributed Primitives Using Link Reversal • Sources: • Walter, Welch & Vaidya • Malpani, Welch & Vaidya • Ingram, Shields, Walter & Welch • MIT 6.885 Fall 2008 slides Discrete Algs for Mobile Wireless Sys
Mutual Exclusion in MANETs [WWV] • Problem statement: • Assume a single connected component • No two nodes are ever in the critical section (CS) simultaneously • If topology changes eventually cease, then every request to enter the CS is eventually granted. Discrete Algs for Mobile Wireless Sys
Mutual Exclusion • Raymond's (1989) ME algorithm: • unique token that traverses the network over a spanning tree • node with token can enter CS • nodes that want to enter CS send requests toward the token holder • What happens if links disappear? • Give a logical direction to all the links, not just those in a spanning tree, to get more redundancy • Use link reversal ideas with a twist: token-holder is destination (of request messages), but different nodes are token-holder at different times Discrete Algs for Mobile Wireless Sys
ME Algorithm [WWV] • Heights are triples (partial reversal, as in [GB]) • Each node keeps a queue of ids of neighbors that have sent it requests • Each node identifies one of its outgoing links as its next link. • node 1 requests 1 3 3 0 • node 3 requests • node 2 requests 3 2 • node 0 leaves the CS, forwards the token to 3, and sends a req. to 3 on behalf of 2. When 3 gets the token, it lowers its height… 1 2 1 2 Discrete Algs for Mobile Wireless Sys
1 3 0 3 3 0 0 3 0 2 2 2 1 2 1 1 2 1 3 2 3 0 3 0 3 0 2 2 2 1 2 1 2 2 ME Algorithm with No Link Failures node 3 forwards token to 1, follows it with a request node 1 enters CS since it is at head of queue; when done, forwards token to 3 node 3 enters CS since it is at head of queue; when done, forwards token to 0 node 0 forwards token to 2, etc. Discrete Algs for Mobile Wireless Sys
1 3 3 3 0 3 0 3 2 2 2 1 2 1 1 2 1 3 2 3 3 0 2 2 1 1 3 2 1 ME Algorithm with Failures 0 removes 3 from queue; 3 raises ht., purges queue, sends req. on new next to 1 1 raises ht., sends req. on new next to 2 A node that loses its last outgoing link either due to link failure or due to nbr’s height change does a partial reversal to raise its height. Queues must be adjusted. Discrete Algs for Mobile Wireless Sys
Correctness of ME Algorithm • Safety: There is never more than one node in the CS at a time. • The unique token ensures this. • Liveness: Eventually every request to enter the CS is granted. • To prove this, we use a "variant function" argument… Discrete Algs for Mobile Wireless Sys
1 3 3 0 3 2 1 2 1 2 p1 p2 p3 pm , , , , pos. of p1 in p1’s queue pos. of p1 in p2’s queue pos. of p2 in p3’s queue pos. of pm-1 in pm’s queue Request Chain and Variant Function In this state, node 1’s request chain is: node 1, node 3, node 0. I.e., the red path. Node 1’s variant function is [1,1,1]. Node 2’s variant function is [1,2]. Node 3’s variant function is [2,1]. Given a node p1’s request chain, define a variant function: If a request message is in transit from pm, then append n+1. Discrete Algs for Mobile Wireless Sys
Correctness of ME Algorithm • finite number of calls to RaiseHt • eventually DAG is token-oriented and stays that way • eventually node i’s request chain includes the token holder • variant function for a particular request keeps decreasing, since nodes don’t stay in CS forever and thus token is sent and received • eventually variant function reaches [1] and request is granted Assume finite number of link changes. Discrete Algs for Mobile Wireless Sys
Leader Election in MANETs • Problem Statement: • Any connected component whose topology is static sufficiently long eventually contains a unique leader • [MWV] paper modified TORA: • Key observation: when a node detects a partition from the destination (current leader), instead of initiating procedure to quiesce, it elects itself • Add a 6th component to the height tuple of TORA • But resulting algorithm does not handle concurrent topology changes • [ISWW] uses a 7-tuple for height… Discrete Algs for Mobile Wireless Sys
LE Algorithm: Height Data Structure • reference level (RL): • tau: either 0 or time when current search for alternative path to leader was initiated • oid: either 0 or id of node that started current search • r: either 0 (nonreflected) or 1 (reflected) • delta: integer to ensure links are directed appropriately to neighbors with same RL • leader pair (LP): • nlts: negative of time when current leader was elected • lid: id of current leader • id: node's unique identifier Discrete Algs for Mobile Wireless Sys
LE Algorithm: Topology Changes • When link to j goes down: • if no neighbors then elect self • else if sink then • start new RL • send new height to all neighbors • When link to j comes up: • send height to j Discrete Algs for Mobile Wireless Sys
LE Algorithm: Response to New Height Message • if LP is same then • if sink then • if all neighbors have same RL then • if common RL has r = 0 then reflect RL • else if common RL has r = 1 and oid= i then elect self • else start new RL • else propagate largest RL • else // LPs are not same • adopt LP if priority • send new height to all neighbors Discrete Algs for Mobile Wireless Sys
LE Algorithm: Subroutines • elect self: • set height to ((0,0,0),0,(-t,i),i), where t is current time • reflect RL: • set r to 1 and delta to 0 • propagate largest RL (partial reversal): • set RL to largest neighboring RL, set delta to 1 less than smallest neighboring delta associated with the new RL • start new RL: • set RL to (t,id,0) and delta to 0, where t is current time • adopt LP if priority: • if new LP has newer time or (equal time and smaller lid) then set RL to new RL, delta to one larger than new delta, and LP to new LP Discrete Algs for Mobile Wireless Sys
G F A B C D E H Example Execution ((0,0,0),4,(-1,H),A) ((0,0,0),3,(-1,H),B) ((0,0,0),3,(-1,H),C) ((0,0,0),2,(-1,H),D) ((0,0,0),2,(-1,H),E) ((0,0,0),2,(-1,H),F) ((0,0,0),0,(-1,H),H) ((0,0,0),1,(-1,H),G) at time 5 Discrete Algs for Mobile Wireless Sys
G A B C D E F H Example Execution: Start New RL ((0,0,0),4,(-1,H),A) ((0,0,0),3,(-1,H),B) ((0,0,0),3,(-1,H),C) ((0,0,0),2,(-1,H),D) ((0,0,0),2,(-1,H),E) ((0,0,0),2,(-1,H),F) ((0,0,0),0,(-1,H),H) ((5,G,0),0,(-1,H),G) Discrete Algs for Mobile Wireless Sys
G A B C D E F H Example Execution: Propagate Largest RL ((0,0,0),4,(-1,H),A) ((0,0,0),3,(-1,H),B) ((0,0,0),3,(-1,H),C) ((5,G,0),-1,(-1,H),D) ((5,G,0),-1,(-1,H),E) ((5,G,0),-1,(-1,H),F) ((0,0,0),0,(-1,H),H) ((5,G,0),0,(-1,H),G) Discrete Algs for Mobile Wireless Sys
G A B C D E F H Example Execution: Propagate Largest RL ((0,0,0),4,(-1,H),A) ((5,G,0),-2,(-1,H),B) ((5,G,0),-2,(-1,H),C) ((5,G,0),-1,(-1,H),D) ((5,G,0),-1,(-1,H),E) ((5,G,0),-1,(-1,H),F) ((0,0,0),0,(-1,H),H) ((5,G,0),0,(-1,H),G) Discrete Algs for Mobile Wireless Sys
G A B C D E F H Example Execution: Reflect RL ((5,G,1),0,(-1,H),A) ((5,G,0),-2,(-1,H),B) ((5,G,0),-2,(-1,H),C) ((5,G,0),-1,(-1,H),D) ((5,G,0),-1,(-1,H),E) ((5,G,0),-1,(-1,H),F) ((0,0,0),0,(-1,H),H) ((5,G,0),0,(-1,H),G) Discrete Algs for Mobile Wireless Sys
G A B C D E F H Example Execution: Propagate Largest RL ((5,G,1),0,(-1,H),A) ((5,G,1),-1,(-1,H),B) ((5,G,1),-1,(-1,H),C) ((5,G,0),-1,(-1,H),D) ((5,G,0),-1,(-1,H),E) ((5,G,0),-1,(-1,H),F) ((0,0,0),0,(-1,H),H) ((5,G,0),0,(-1,H),G) Discrete Algs for Mobile Wireless Sys
G A B C D E F H Example Execution: Propagate Largest RL ((5,G,1),0,(-1,H),A) ((5,G,1),-1,(-1,H),B) ((5,G,1),-1,(-1,H),C) ((5,G,1),-2,(-1,H),D) ((5,G,1),-2,(-1,H),E) ((5,G,1),-2,(-1,H),F) ((0,0,0),0,(-1,H),H) ((5,G,0),0,(-1,H),G) Discrete Algs for Mobile Wireless Sys
F A B C D E G H Example Execution: Elect Self ((5,G,1),0,(-1,H),A) ((5,G,1),-1,(-1,H),B) ((5,G,1),-1,(-1,H),C) ((5,G,1),-2,(-1,H),D) ((5,G,1),-2,(-1,H),E) ((5,G,1),-2,(-1,H),F) ((0,0,0),0,(-1,H),H) ((0,0,0),0,(-14,G),G) at time 14 Discrete Algs for Mobile Wireless Sys
A B C D E F G H Example Execution: Adopt New LP ((0,0,0),3,(-14,G),A) ((0,0,0),2,(-14,G),B) ((0,0,0),2,(-14,G),C) ((0,0,0),1,(-14,G),D) ((0,0,0),1,(-14,G),E) ((0,0,0),1,(-14,G),F) ((0,0,0),0,(-1,H),H) ((0,0,0),0,(-14,G),G) Discrete Algs for Mobile Wireless Sys
Correctness Proof • Relies on several invariant predicates: • properties of the global state of the system that are always true • Show that if topology changes cease, then eventually a leader-oriented DAG is obtained in each connected component • Show that a new leader is not elected "unnecessarily": • if a component is a leader-oriented DAG and one topology change occurs, then no node remaining in same component as the old leader elects itself Discrete Algs for Mobile Wireless Sys
Leader-Oriented DAG • Lemma 1: Any node that adopts a LP with timestamp after the last topology change never subsequently becomes a sink. • Lemma 2: Any node that elects itself after the last topology change never subsequently becomes a sink. • Lemma 3: No node elects itself more than once after the last topology change. • Lemma 4: Every node starts a finite number of new RLs after the last topology change. Discrete Algs for Mobile Wireless Sys
Leader-Oriented DAG • Lemma 5: Eventually every node in the component has the same LP. • Lemma 6: Eventually no messages are in transit. • Lemma 7: Eventually every node has an accurate view of its neighbors' heights. Discrete Algs for Mobile Wireless Sys
Leader-Oriented DAG • Theorem 8: Eventually the component is a leader-oriented DAG. • Proof Sketch: • Eventually all nodes have same LP (-s,L). • Eventually every node has an accurate view of its neighbors' heights. • Properties tell us that • Node L must be in the component. • L and only L has RL (0,0,0) and 0 delta • no node has a negative RL • L has smallest height, so no outgoing links • every node other than L has an outgoing link • Since cycles are impossible, L-oriented DAG. Discrete Algs for Mobile Wireless Sys
Leader Stability • Theorem 9: Suppose G' is an L-oriented DAG with no messages in transit and a link goes down at time t. Let resulting component containing L be G. Then, as long as no further topology changes occur, no node in G elects itself. • Proof Sketch: Suppose node u becomes a sink at time t and starts new RL (t,u,0). Discrete Algs for Mobile Wireless Sys
Leader Stability • Suppose in contradiction some node elects itself at time te. • Claim 2: No new RL prefix (oid and timestamp) is started between t and te. • Thus the node elected at te must be u. • Let A be nodes in G with a directed path to L at time t (after the link goes down) and B be the remaining nodes. • L is in A and u is in B. • Claim 3: No node in A becomes a sink between t and te. Discrete Algs for Mobile Wireless Sys
Leader Stability • At te, all neighbors of u have RL (t,u,1). • By a property, there are no "height tokens" in the system at te with RL (t,u,0) • a node cannot have an unreflected RL while one of its ancestors is reflected • By another property, every node with RL (t,u,1) has all its neighbors with RL (t,u,1). • But then some node with RL (t,u,1) is a neighbor of some node in A, which cannot have RL (t,u,1) since it never becomes a sink. Contradiction. Discrete Algs for Mobile Wireless Sys