Title: CPSC 689: Discrete Algorithms for Mobile and Wireless Systems
1CPSC 689 Discrete Algorithms for Mobile and
Wireless Systems
- Spring 2009
- Prof. Jennifer Welch
2Lecture 15
- Topic
- Link Reversal
- Sources
- Gafni Bertsekas
- Busch et al.
- Charron-Bost et al.
- Park Corson
- MIT 6.885 Fall 2008 slides
3Motivation 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.
4Outline
- 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.
5Motivation 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
- dont require flooding
- rely only on local information
6Abstract 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.
7Full 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
8Full Reversal Algorithm Example
9Implementation of Full Reversal Agorithm The
Pair Algorithm
- Each node i keeps a pair (a,i), where a 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 a to 1 greater than the maximum
a-value of all of is neighbors at the previous
iteration.
10Pair Algorithm Example
11Partial 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
12Partial Reversal Algorithm Example
13"Implementation" of Partial Reversal Algorithm
The Triple Algorithm
- Use a triple (a,b,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 a to 1 greater than the minimum a-value of
any neighbor - set b to 1 less than the smallest b-value of all
neighbors with the new a-value (if no such
neighbor then dont change b) - Why does this implement partial reversal?
14Triple Algorithm Example
15Analysis 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.
16GB 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
17General 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) gt vi and depends only on heights in v of
node i and i's neighbors - some unbounded increase condition for gi (A3)
18Why 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
19Correctness 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
20Complexity 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?
21BST, BT Complexity Results
Worst case bounds
algorithm time work
pair algorithm Q(n2) Q(n2)
triple algorithm Q(n a n2) Q(n a n2)
better
- time number of iterations with maximum
concurrency - work number of link reversals
- n number of nodes with no path to destination
- a max a min a in initial state
22Counting 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
23Upper 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)
24Lower Bounds for Pair Algorithm
Bad graph for work
node i does i reversals gt W(n2) reversals
Bad graph for time
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 gt W(n2) time.
25Lower Bounds for Triple Algorithm
Bad graph for work (links alternate direction)
BST prove node i reverses Q(a i) times gt
W(n a n2) reversals
Bad graph for time
BST prove each node in the red oval reverses
W(a n) times. These reversals must be
sequential since neighbors cannot be sinks
simultaneously gt W(n a n2) time.
26Some 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?
27CGWW
- 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
28LR 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 links
- flip the labels on all incident links
- else // all of v's incident links are marked
- reverse all incident links // leave them marked
LR1
LR2
29LR Example
30Special 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
31PR Example with LR
32Basic 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
33LR Terminates
- Theorem 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.
finite number of steps
infinite number of steps
Case 1 After u's last step, link is directed
toward u.
v cannot become a sink again, contradiction.
34LR Terminates
Case 2 After u's last step, link is directed
toward v.
Case 2.1 After v's next step, link is directed
toward u.
v cannot become a sink again, contradiction.
35LR Terminates
Case 2 After u's last step, link is directed
toward v.
Case 2.2 After v's next step, link is still
directed toward v. Then it must be labeled 0.
After v's next step, link is directed toward u
(labeled 1).
v cannot become a sink again, contradiction.
36LR Preserves Acyclicity
- Theorem 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.
37Comparing Initializations
38What 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 nodes
- and time
- total number of rounds, assuming maximum
concurrency for sinks reversing - of 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.
39BST,BT Bounds Again
Worst case bounds
algorithm time work
pair Q(n2) Q(n2)
triple Q(n a n2) Q(n a n2)
- time number of iterations
- work number of node reversals
- n number of nodes with no path to destination
- a max a min a in initial state
40CGWW 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
41Work 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
42Work Complexity Pattern for FR
Number 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.
43Work 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
44Work 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 (k1)/2
N k/2
O k
45Work Complexity of FR
- Corollary 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(n1)/2
46Work Complexity of PR
- Corollary 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/41 (for even n)
47Discussion 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
48Open 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)?
49Effect of Partitions
- The full and partial reversal algorithms work if
nodes are not partitioned from the destination. - What happens if they are?
- Full reversal
50Park 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.
51TORA 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
52TORA 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.
53Heights in TORA
reference level
delta
t , oid , r , d , i
54Maintaining Routes in TORA
- If 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 dont have same ref level (Case Propagate)
- adopt max ref level and set d to effect a partial
reversal - nbrs have same ref level with r 0 (Case
Reflect) - adopt new ref level, set r to 1, set d to 0 (full
reversal) - nbrs have same ref level with r 1 and oid i
(Case Detect) - Partition! Start process of erasing routes.
55TORA Example Partition
56TORA Example in Detail
(0,0,0,0,6)
(0,0,0,2,5)
Link (3,6) fails at time 8
5
6
4
1
2
3
(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)
Node 3 generates new ref level (8,3,0), bcasts
new height to all neighbors
57TORA Example in Detail
(0,0,0,0,6)
(0,0,0,2,5)
5
6
4
1
2
3
(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)
Nodes 2 and 4 propagate ref level (8,3,0), bcast
new height to all neighbors
58TORA Example in Detail
(8,3,1,0,5)
(0,0,0,0,6)
(0,0,0,2,5)
5
6
4
1
2
3
(8,3,0,0,3)
(8,3,0,1,2)
(0,0,0,3,1)
(8,3,0,1,4)
(8,3,1,0,1)
Nodes 1 and 5 reflect ref level (8,3,1), bcast
new height to all neighbors
59TORA Example in Detail
(0,0,0,0,6)
(8,3,1,0,5)
5
6
4
1
2
3
(8,3,0,0,3)
(8,3,0,1,2)
(8,3,1,0,1)
(8,3,0,1,4)
(8,3,1,1,4)
(8,3,1,1,2)
Nodes 2 and 4 propagate ref level (8,3,1), bcast
new height to all neighbors
60TORA Example in Detail
(0,0,0,0,6)
(8,3,1,0,5)
5
6
4
1
2
3
(8,3,1,1,4)
(8,3,0,0,3)
(8,3,1,1,2)
(8,3,1,0,1)
Node 3 detects partition from destination 6
61Effects 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.
62Conclusion
- 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.