CPSC 689: Discrete Algorithms for Mobile and Wireless Systems
description
Transcript of CPSC 689: Discrete Algorithms for Mobile and Wireless Systems
CPSC 689: Discrete Algorithms for Mobile and Wireless Systems
Spring 2009Prof. Jennifer Welch
Discrete Algs for Mobile Wireless Sys 2
Lecture 15 Topic:
Link Reversal Sources:
Gafni & Bertsekas Busch et al. Charron-Bost et al. Park & Corson MIT 6.885 Fall 2008 slides
Discrete Algs for Mobile Wireless Sys 3
directed spanning tree direct all the links red node is sink reverse red link
Motivation for Link Reversal Assume communication channels in the system can be
modeled as an undirected graph (i.e., bidirectional links) Link reversal algorithms impose logical directions on the
edges (or links) of the graph; at certain times the directions on some edges are reversed to achieve some goal.
Example: Suppose goal is to send info to a distinguished node D.
Discrete Algs for Mobile Wireless Sys 4
Outline Gafni & Bertsekas (1981) introduced “link reversal”
algorithms for constructing and maintaining paths to a destination node and proved their correctness.
Busch, Surapaneni & Tirthapura (2003) analyzed the complexity of the GB link reversal algorithms --- worst-case time and work.
Charron-Bost, Gaillard, Welch & Widder (2008) gave a more fine-grained analysis of work complexity for a more general algorithm.
Park & Corson (1997) modified the GB “partial reversal” algorithm to detect when nodes are partitioned from the destination --- result is the Temporally Ordered Routing Algorithm (TORA) for MANETs.
Discrete Algs for Mobile Wireless Sys 5
Motivation [GB] Network contains a distinguished “central
station”. Central station collects information from
other nodes via “contingency routes”. Construct contingency routes that
provide redundant routes to station are loop-free don’t require flooding rely only on local information
Discrete Algs for Mobile Wireless Sys 6
Abstract Graph Problem
Definition: a directed acyclic graph (DAG) with a distinguished node D is destination-oriented if D is the one and only sink in the graph.
Problem statement: Given a DAG with distinguished node D that is not destination-oriented, convert it into a destination-oriented DAG by reversing the directions of some of the links.
D
1 2
D
1 2
Discrete Algs for Mobile Wireless Sys 7
Full Reversal Algorithm
Whenever a node is a sink (but not the destination), reverse all its incident links, i.e., all its incident links become outgoing
Assuming perfect knowledge of state of the link and ability to instantaneously change it some other algorithms relax this assumption
Discrete Algs for Mobile Wireless Sys 8
Full Reversal Algorithm ExampleD
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
Discrete Algs for Mobile Wireless Sys 9
Implementation of Full Reversal Agorithm: The Pair Algorithm Each node i keeps a pair (,i), where is an
integer; pair is called height Link between two nodes is considered to be
directed from node with higher height to node with lower height
At each iteration, if a node i has no outgoing links, then set to 1 greater than the maximum -value of all of i’s neighbors at the previous iteration.
Discrete Algs for Mobile Wireless Sys 10
Pair Algorithm Example
(0,3)
D
1 2 3
4 5 6
(0,0)
(0,1) (0,2)
(0,4) (0,5) (0,6)
D
1 2 3
4 5 6
(0,0)
(0,1) (0,2) (0,3)
(0,6)(0,5)(0,4) (0,6)
D
1 2 3
4 5 6
(0,0)
(0,1) (0,2) (1,3)
(0,5)(0,4)
(2,6)
D
1 2 3
4 5 6
(0,0)
(0,1) (2,2) (1,3)
(0,5)
(0,4)
D
1 2 3
4 5 6
(0,0)
(0,1) (2,2) (3,3)
(2,6)(3,5)(0,4)
D
1 2 3
4 5 6
(0,0)
(0,1) (2,2) (3,3)
(4,4) (3,5) (4,6)
Discrete Algs for Mobile Wireless Sys 11
Partial Reversal Algorithm Try to reduce the number of link reversals by
having a sink node reverse only some of its incident links.
Whenever a node is a sink (but not the destination):
reverse all incoming links that have not been reversed since last time this node did a reversal
Discrete Algs for Mobile Wireless Sys 12
Partial Reversal Algorithm Example
D
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
D
1 2 3
4 5 6
Discrete Algs for Mobile Wireless Sys 13
"Implementation" of Partial Reversal Algorithm: The Triple Algorithm Use a triple (,,i) for the height. At each iteration, if a node i has no
outgoing links, then, using the neighbors’ heights from the previous iteration, set to 1 greater than the minimum -value
of any neighbor set to 1 less than the smallest -value of all
neighbors with the new -value (if no such neighbor then don’t change )
Why does this implement partial reversal?
Discrete Algs for Mobile Wireless Sys 14
Triple Algorithm Example
D
1 2 3
4 5 6
(0,0,0)
(0,5,1)
(0,2,2)
(0,1,3)
(0,4,4) (0,3,5) (0,2,6)
D
1 2 3
4 5 6
(0,0,0)
(0,5,1) (0,2,2) (0,1,3)
(0,4,4) (0,3,5) (0,2,6)
D
1 2 3
4 5 6
(0,0,0)
(0,5,1) (0,2,2) (1,1,3)
(0,4,4) (0,3,5) (0,2,6)
D
1 2 3
4 5 6
(0,0,0)
(0,5,1) (1,0,2) (1,1,3)
(0,4,4) (0,3,5) (1,0,6)
D
1 2 3
4 5 6
(0,0,0)
(0,5,1) (1,0,2) (1,1,3)
(0,4,4) (1,-1,5) (1,0,6)
D
1 2 3
4 5 6
(0,0,0)
(0,5,1) (1,0,2) (1,1,3)
(1,-2,4) (1,-1,5) (1,0,6)
Discrete Algs for Mobile Wireless Sys 15
Analysis of Link Reversal Algorithms
[GB] proved correctness of a general class of algorithms that includes the full and partial reversal algorithms: Every algorithm in the class terminates in a finite number of iterations with a destination-oriented DAG.
Discrete Algs for Mobile Wireless Sys 16
[GB] Correctness Proof Define an abstraction of the heights: taken from a
set A that is countable infinite totally ordered partitioned into n disjoint subsets, one per node (other
than D), s.t. each subset is countably infinite and unbounded there is an operator on each subset under which it is
an Abelian group Link (i,j) is considered to be directed from node i
to node j if ai is larger than aj in the total order
Discrete Algs for Mobile Wireless Sys 17
General Algorithm [GB] Given a vector v = (v1, v2, …, vn), where vi is the
(generalized) height of node i, algorithm M has these properties: M(v) is a set of vectors (nondeterministic) if no sinks in v, then M(v) is empty for each v' in M(v):
either v'i = vi
or v'i = gi(vi) (only allowed if node i is a sink in v) gi(vi) > vi and depends only on heights in v of node i
and i's neighbors some unbounded increase condition for gi (A3)
Discrete Algs for Mobile Wireless Sys 18
Why Nondeterminism? Execution of algorithm is a sequence of vectors,
starting with some initial assignments of heights, where each vector v' in the sequence is contained in M(v), where v is the preceding vector
If there is one or more sinks in the graph, then at each step, one or more of the sinks can take a step timing and order of steps is immaterial captures asynchronous execution
Discrete Algs for Mobile Wireless Sys 19
Correctness of General Algorithm Acyclic: follows because the heights are
totally ordered Proposition 1: algorithm terminates in a
finite number of iterations (no sinks, other than the destination D) since acyclic and no sinks, every node has a
directed path to D Proposition 2: once a node has a directed
path to D, it is never is a sink
Discrete Algs for Mobile Wireless Sys 20
Complexity of Link Reversal Algorithms [GB] proved correctness of a general class
of algorithms that includes the full and partial reversal algorithms: Every algorithm in the class terminates in a finite number of iterations with a destination-oriented DAG.
But how many iterations? I.e., what is the complexity?
Discrete Algs for Mobile Wireless Sys 21
[BST, BT] Complexity Results
algorithm time work
pair algorithm (n2) (n2)
triple algorithm (n a* + n2) (n a* + n2)
time = number of iterations with maximum concurrency work = number of link reversals n = number of nodes with no path to destination a* = max – min in initial state
Worst case bounds
Discrete Algs for Mobile Wireless Sys 22
Counting Reversals Both examples had all sink nodes reversing in
parallel at each iteration. [GB], and [BST,BT], show that the order in which
reversals are done is immaterial -- resulting DAG is always the same.
[BST,BT] proof uses notion of a dependency graph of reversals: number of node reversals is number of vertices in
dependency graph time is at least the depth of the dependency graph
Discrete Algs for Mobile Wireless Sys 23
Upper Bounds Pair algorithm: [BST,BT] prove that each
node reverses at most n times, implying O(n2) reversals taking O(n2) time (if sequential)
Triple algorithm: [BST,BT] prove that each node reverses at most a* + n times, so O(n a* + n2) reversals taking O(n a* + n2) time (if sequential)
Discrete Algs for Mobile Wireless Sys 24
Lower Bounds for Pair AlgorithmBad graph for work:
D 1 2 n -1 n
Bad graph for time:
D 1 2 n/2 n/2+1 n/2+2 n -1 n
[BST,BT] prove each node in right half of chain reverses n/2 times. These reversals must be sequential since neighbors cannot be sinks simultaneously (n2) time.
node i does i reversals => (n2) reversals
Discrete Algs for Mobile Wireless Sys 25
Lower Bounds for Triple AlgorithmBad graph for work (links alternate direction):
D 1 2 n -1 n
Bad graph for time:
[BST] prove each node in the red oval reverses (a* + n) times. These reversals must be sequential since neighbors cannot be sinks simultaneously (n a* + n2) time.
[BST] prove node i reverses (a* + i) times => (n a* + n2) reversals
n/2+1
D 1 2 n/2
n -1
n
n -2
n/2+2
Discrete Algs for Mobile Wireless Sys 26
Some Additional Questions What about the original, abstract, full and partial reversal
algorithms? not hard to show that the pair algorithm implements full
reversal not at all straightforward to see that the triple algorithm
implements partial reversal Are unbounded counters necessary for doing link reversal? Is the generalized height approach useful for developing
alternative algorithms, or would some other formalism be better?
Can we find the exact expression for the time and work complexity of link reversal algorithms for any node and in any graph?
Discrete Algs for Mobile Wireless Sys 27
[CGWW] New formulation of FR and PR using only binary
labels on the links Simple distributed algorithm for finding routes in
acyclic graphs Identify sufficient conditions on initial labeling for
correctness FR and PR are special cases Easy to state new algorithms (use different initial
labelings) Much simpler proof of correctness
first known proof that PR preserves acyclicity
Discrete Algs for Mobile Wireless Sys 28
LR Algorithm Schema Input is a directed acyclic graph G* with
distinguished node D each link labeled with 0 ("unmarked) or 1 ("marked")
while there exists a sink v ≠ D do:if v has an incident unmarked link then
reverse all incident unmarked linksflip the labels on all incident links
else // all of v's incident links are markedreverse all incident links // leave them marked
LR1:
LR2:
Discrete Algs for Mobile Wireless Sys 29
LR Example
LR2
LR1
1 1 0D
LR2
LR1
1 1 0D
1 0 1D
1 0 1D
1 1 0D
Discrete Algs for Mobile Wireless Sys 30
Special Cases of LR Algorithm
Full Reversal: Initially all labels are 1 Only ever execute LR2 step All labels are always 1
Partial Reversal: Initially all labels are 0 Execute both LR1 and LR2 Labels change
Discrete Algs for Mobile Wireless Sys 31
PR Example with LRD
1 2 3
4 5 6
D
1 2 3
4 5 6
0
0
0 0
0
00
0
D
1 2 3
4 5 6
0
0
0 1
10
0 0
D
1 2 3
4 5 6
1
1
1
0
0
0
0
0
D
1 2 3
4 5 6
0
0
0
0
1
0
01
D
1 2 3
4 5 6
00
0
0
1
11
0
Discrete Algs for Mobile Wireless Sys 32
Basic Definitions Given undirected graph G: G* is a directed version of G a chain in G* corresponds to an (undirected)
path in G; might not have all links directed the same way
a circuit in G* corresponds to an (undirected) cycle in G; might not form a directed cycle
Discrete Algs for Mobile Wireless Sys 33
LR TerminatesTheorem: LR terminates.Proof: At least one node takes a finite number of
steps (D). Suppose in contradiction at least one node takes an infinite number of steps.
u v
finite number
of steps
infinite number
of stepsCase 1: After u's last step,
link is directed toward u.
Discrete Algs for Mobile Wireless Sys 34
LR TerminatesCase 2: After u's last step, link is directed toward v.
u v
finite number
of steps
infinite number
of steps
Case 2.1: After v's next step, link is directed toward u.
u v
finite number
of steps
infinite number
of steps
Discrete Algs for Mobile Wireless Sys 35
LR Terminates
Case 2: After u's last step, link is
directed toward v.u v
finite number
of steps
infinite number
of steps
Case 2.2: After v's next step, link is
still directed toward v.
Then it must be labeled 0.u v
0
After v's next step, link is directed
toward u (labeled 1). u v1
Discrete Algs for Mobile Wireless Sys 36
LR Preserves AcyclicityTheorem: If LR input is a DAG in which every circuit
satisfies a certain condition AC, then every step maintains acyclicity.
Theorem: If every node of a DAG has the same label on all its incoming links (a "uniform" labeling), then every circuit satisfies condition AC.
Discrete Algs for Mobile Wireless Sys 37
Comparing Initializations
all 1's
(FR)
all 0's
(PR)
uniform labeling
satisfy condition AC
maintain acyclicity
all binary link labelings
Discrete Algs for Mobile Wireless Sys 38
What about Complexity of LR? No systematic study until work of Busch, Surapaneni, and
Tirthapura (2003) They studied work
total number of reversals done by all nodesand time total number of rounds, assuming maximum concurrency for
sinks reversingof [GB]'s pair and triple algorithms
Results were of this form: for every n, there exists a graph with n nodes in which (f(n)) reversals are done / (f(n)) rounds are executed.
Discrete Algs for Mobile Wireless Sys 39
[BST,BT] Bounds Again
algorithm time work
pair (n2) (n2)
triple (n a* + n2) (n a* + n2)
time = number of iterations work = number of node reversals n = number of nodes with no path to destination a* = max – min in initial state
Worst case bounds
Discrete Algs for Mobile Wireless Sys 40
[CGWW] Contributions Expression for the exact number of steps (work)
taken by any node in any graph during the generic algorithm
Expression depends only on the input graph Has simple formulas when specialized to FR and
PR Exact formula helps in finding best and worst
topologies
Discrete Algs for Mobile Wireless Sys 41
Work Complexity Overview For any node v, define a nonnegative
quantity Every time v takes a step, decreases by
either 1 or 2 When other nodes take steps, is
unchanged Once v has a directed path to D, = 0
Discrete Algs for Mobile Wireless Sys 42
Work Complexity Pattern for FRNumber of
reversals by
node v equals
number of
links directed
away
from D in the
chain to v.
Quantity
decreases
by 1 when v
takes a step.
D
D
D
D
D
D
D
D1 1 2 2 3 4
Discrete Algs for Mobile Wireless Sys 43
Work Complexity Overview Break into 2 pieces: = - Show never changes Show increases by either 1 or 2 when
v takes a step Increment depends on a classification of
v into one of 3 groups (S, N, or O) Thus decreases by either 1 or 2
whenever v takes a step
Discrete Algs for Mobile Wireless Sys 44
Work Complexity Overview Consider any execution of LR starting with
a graph whose circuits all satisfy condition AC.
Let k be initial value of for node v.
initial group of v number of reversals by v
S (k+1)/2N k/2O k
Discrete Algs for Mobile Wireless Sys 45
Work Complexity of FRCorollary: Number of steps taken by v in FR
is min, over all chains between v and D, of number of links directed away from D.
Worst case graph is chain with all edges directed away from D: total work complexity is n(n+1)/2
Discrete Algs for Mobile Wireless Sys 46
Work Complexity of PRCorollary: Number of steps taken by v in PR is min, over all chains b/w v and D, of number of nodes
on the chain with two incoming unmarked chain links, if v is a sink or a source (plus 1 in some cases)
If v is neither a sink nor a source, then the number of steps is twice the above quantity
Worst-case graph is chain with links that alternate direction: total work complexity is n2/4+1 (for even n)
Discrete Algs for Mobile Wireless Sys 47
Discussion of [CGWW] Fresh approach to specify and analyze link
reversal algorithms of [GB] Developed a generalization of the algorithms
bounded space complexity Exact expression for work complexity of any node
in any graph for general algorithm [BST,BT] work was exact for pair algorithm but not exact
for triple algorithm
Discrete Algs for Mobile Wireless Sys 48
Open Question Time complexity: can we come up with a
formula for the last round at which a given node takes a step (assuming all sinks take steps simultaneously at each round)?
Discrete Algs for Mobile Wireless Sys 49
Effect of Partitions The full and partial reversal algorithms work if
nodes are not partitioned from the destination. What happens if they are? Full reversal:
D 1
2 3
D 1
2 3D 1
2 3D 1
2 3
Discrete Algs for Mobile Wireless Sys 50
Park & Corson, 1997 (TORA) Temporally Ordered Routing Algorithm Modify GB partial reversal algorithm for routing
messages in mobile ad hoc networks Use n copies of the link reversal algorithm, one
for each possible destination node. Detect when a node has been partitioned from a
destination and stop trying to sending messages to it
Height is a 5-tuple.
Discrete Algs for Mobile Wireless Sys 51
TORA System Assumptions Undirected communication graph G Nodes have unique ids. Bidirectional communication on all edges. Set of links changes with time. Nodes may also fail. Nodes know their neighbors (because of some lower
level protocol). Nodes communicate through message broadcast
with all neighbors. Transmitted packets are received correctly and in
order of transmission, but with some delay Different than the previous papers
Discrete Algs for Mobile Wireless Sys 52
TORA Overview Creating routes:
A node initiates establishment of a route to destination only if all its adjacent links are undirected.
Route creation essentially assigns directions to undirected links.
Maintaining routes: When directed portions of the graph deviate from being
destination oriented, perform reversals to try to restore this property.
Erasing routes: Detect partitions, and accommodate, by “clearing" all the
links in the portion disconnected from the destination, that is, making them undirected again.
Discrete Algs for Mobile Wireless Sys 53
Heights in TORA
[ , oid , r , , i ]reference level delta
time this ref. levelwas started(from synch’dclocks orlogical clocks)
id of nodeoriginatingthis ref.level
reflectionbit
ordersnodes withsame ref.level
id of node,breaks ties
Discrete Algs for Mobile Wireless Sys 54
Maintaining Routes in TORAIf node i loses last outgoing link: due to a link failure (Case Generate):
set ref level to (current time, i, 0), a full reversal due to a height change and
nbrs don’t have same ref level (Case Propagate): adopt max ref level and set to effect a partial reversal
nbrs have same ref level with r = 0 (Case Reflect): adopt new ref level, set r to 1, set to 0 (full reversal)
nbrs have same ref level with r = 1 and oid = i (Case Detect):
Partition! Start process of erasing routes.
Discrete Algs for Mobile Wireless Sys 55
TORA Example – Partition6
1 2 3 4
5
Generate
6
1 2 3 4
5
Propagate Propagate
6
1 2 3 4
5Reflect
Reflect
6
1 2 3 4
5
PropagatePropagate
6
1 2 3 4
5
Detect
Discrete Algs for Mobile Wireless Sys 56
TORA Example in Detail
6
1 2 3 4
5
Node 3 generates new ref level (8,3,0),bcasts new height to all neighbors
(0,0,0,0,6) (0,0,0,2,5)
(0,0,0,2,4)(0,0,0,1,3)(0,0,0,2,2)(0,0,0,3,1)(8,3,0,0,3)
Link (3,6) failsat time 8
Discrete Algs for Mobile Wireless Sys 57
TORA Example in Detail
6
1 2 3 4
5
Nodes 2 and 4 propagate ref level (8,3,0),bcast new height to all neighbors
(0,0,0,0,6) (0,0,0,2,5)
(0,0,0,2,4)(8,3,0,0,3)(0,0,0,2,2)(0,0,0,3,1)(8,3,0,–1,4)(8,3,0,–1,2)
Discrete Algs for Mobile Wireless Sys 58
TORA Example in Detail
6
1 2 3 4
5
Nodes 1 and 5 reflect ref level (8,3,1),bcast new height to all neighbors
(0,0,0,0,6) (0,0,0,2,5)
(8,3,0,0,3)(8,3,0,–1,2)(0,0,0,3,1)
(8,3,1,0,5)
(8,3,1,0,1)(8,3,0,–1,4)
Discrete Algs for Mobile Wireless Sys 59
TORA Example in Detail
6
1 2 3 4
5
Nodes 2 and 4 propagate ref level (8,3,1),bcast new height to all neighbors
(0,0,0,0,6) (8,3,1,0,5)
(8,3,0,0,3)(8,3,0,–1,2)(8,3,1,0,1)(8,3,1,–1,4)(8,3,1,–1,2)
(8,3,0,–1,4)
Discrete Algs for Mobile Wireless Sys 60
(8,3,1,–1,4)
TORA Example in Detail
6
1 2 3 4
5
Node 3 detects partition from destination 6
(0,0,0,0,6) (8,3,1,0,5)
(8,3,0,0,3)(8,3,1,–1,2)(8,3,1,0,1)
Discrete Algs for Mobile Wireless Sys 61
Effects of Time Errors Clocks are used to establish temporal order of the
link loss events. Logical clocks could also be used to establish this
order. What happens if the logical time order isn't the
same as the real time order? They claim that the resulting algorithm is still in the
BG general class. They conclude that it's good to use clocks that are
sufficiently synchronized so that the time between failures is much greater than the clock error.
Discrete Algs for Mobile Wireless Sys 62
Conclusion No simulation results. But, they do have a table of claimed
worst-case complexity of many algorithms. Possible improvements:
Over time, the DAG may become less optimally directed than it was initially.
They claim that initially, the s give the minimum distance (in hops) to d, but this can degrade with changes.
We could enhance the protocol by periodically propagating refresh packets outwards from d, to reset the reference level to 0 (?) and restore the meaning of the s to be the shortest distances Such a strategy could also support correction of corrupted state
information. Refreshes should occur at a low rate, in the background.