260 likes | 271 Views
CPSC 689: Discrete Algorithms for Mobile and Wireless Systems. Spring 2009 Prof. Jennifer Welch. Lecture 7. Topics: Time Synchronization Lower Bounds Sources: Attiya et al. paper MIT 6.885 Fall 2008 slides. Attiya, Hay & Welch. Theoretical study External clock synchronization
E N D
CPSC 689: Discrete Algorithms for Mobile and Wireless Systems Spring 2009 Prof. Jennifer Welch
Lecture 7 • Topics: • Time Synchronization Lower Bounds • Sources: • Attiya et al. paper • MIT 6.885 Fall 2008 slides Discrete Algs for Mobile Wireless Sys
Attiya, Hay & Welch • Theoretical study • External clock synchronization • Wireless communication but static nodes • Motivating issue: • To save energy, use short hops (small transmission radius) • energy cost is super-linear in distance • To reduce skew, have fewer hops • uncertainty accumulates with each hop and skew is proportional to uncertainty • Contradictory goals! Discrete Algs for Mobile Wireless Sys
x x x Power vs. Uncertainty power 3x2 uncertainty 3u A B 3x power 9x2 uncertainty u A B Discrete Algs for Mobile Wireless Sys
Overview • Relate energy costs to optimal skew that can be obtained • Each node has a maximum transmission range, based on its "energy budget" • results in an arbitrary communication topology • Compute optimal skew as a function of uncertainty • Algorithm and matching lower bound Discrete Algs for Mobile Wireless Sys
Environment • Energy constraints induce a communication topology graph TG • TG is assumed to be connected, bidirectional links • Each link e in TG has message delays in the range [de – ue, de + ue] • same range in each direction, but can be different for different links • ue is the uncertainty of link e • uimin is minimum weight of any path in TG from vi to any source (sum uncertainties of all links on the path) Discrete Algs for Mobile Wireless Sys
Problem Statement • Every source node in the network has the same clock time, ST(t), at every time t • Assume no clock drift => one-shot problem • Each node vi should compute an adjustment adji to add to its hardware clock HCi to obtain logical clock LCi. • For all times t after termination time tf, |ST(t) – LCi(t)| should be at most (skew). • Want to be small Discrete Algs for Mobile Wireless Sys
Algorithm with Precomputed Spanning Forest • Assume there is a spanning forest of TG with each source as the root of a separate tree in the forest • Each source sends its clock value to its children, which then propagate the information down the tree • When a node gets the clock value, it adopts it after adding the sum of the median delays along the path the message has traveled so far Discrete Algs for Mobile Wireless Sys
Skew of Algorithm with Spanning Forest • Largest error occurs when messages take either maximum or minimum time over each edge • error per edge is then the uncertainty • Error accumulates linearly as message propagates down the tree • Best case is when spanning forest is shallow: maximum depth (w.r.t. sum of uncertainties) over all the trees is minimized • In this case, worst-case skew of each node viis at most uimin Discrete Algs for Mobile Wireless Sys
Precomputing a Shallow Spanning Forest • Centralized algorithm: given TG and weights, run a generalization of Dijkstra's algorithm (to handle the multiple sources) • Distributed algorithm: • each node computes its neighbors in TG by doing a bcast and waiting for acks • invoke known distributed algs for finding a BFS forest rooted at multiple sources Discrete Algs for Mobile Wireless Sys
Computing Shallow Spanning Forest on the Fly • Combine computing a shallow spanning forest with doing (the first) synchronization • Local var. uncertainty keeps track of smallest uncertainty to a source discovered so far • Local var. parent keepts track of which neighbor is its parent in path to source corresponding to uncertainty var. • Each msg contains local time when sent, id of sender, value of sender's uncertainty var. Discrete Algs for Mobile Wireless Sys
Computing Shallow Spanning Forest on the Fly • Each source bcasts a message • When a node receives a message (T,j,u) over link e: • if uncertainty > u + ue then • adj := (T + de) – HC • uncertainty := u + ue • parent := j • bcast a message according to some heuristic (simple rule is whenever you update your vars) Discrete Algs for Mobile Wireless Sys
Analysis of On-The-Fly Algorithm • Lemma 1: If uncertainty at node vi is defined, then it is the uncertainty along a path to some source, and vi's clock skew is at most that amount. • Proof is by induction on the sequence of events in the execution • Lemma 2: Eventually uncertainty at node viequals uimin (min. uncertainty of any path to any source). • Proof is by induction on the length (w.r.t. number of hops) of minimum-uncertainty paths to sources Discrete Algs for Mobile Wireless Sys
Lower Bound • Show that the skew achieved by the simple shallow spanning forest (SSF) algorithm is optimal. • Not necessarily obvious, since SSF algorithm uses only point-to-point communication and ignores extra information that nodes get by overhearing broadcasts not intended for them Discrete Algs for Mobile Wireless Sys
Lower Bound Strategy To prove lower bounds on skew: • Start with a (carefully chosen) execution • Modify the times when events happen at the nodes (in a carefully chosen way) • Check that resulting execution is "legal" (message delays w/in bounds) • Use info about the original and the new execution, together with some algebra, to show that the skew cannot be too small Shifting Discrete Algs for Mobile Wireless Sys
Shifting Executions • Given execution and real numbers x0, x1, …, xn-1, shift(,(x0, x1, …, xn-1)) is created by adding xi to the real time of each event by node vi Discrete Algs for Mobile Wireless Sys
h/w clock times HCi(t) = T t real times shift by positive amount HCi(t+x) = T h/w clock times t + x real times HCi(t+x) = T h/w clock times shift by negative amount t + x real times Shifting Examples Discrete Algs for Mobile Wireless Sys
Facts About Shifted Executions • Result of shifting might not be reasonable: could shift receipt of a message earlier than its sending, for example, or exceed delay bounds. • But these facts hold (shifting lemma): • New hardware clock HC'isatisfies: HC'i(t) = HCi(t – xi) = HCi(t) – xi • Delay of a msg from pi to pj goes from to –xi + xjsince msg is sent xilater and received xjlater Discrete Algs for Mobile Wireless Sys
pi pj Changes to Message Delays pi xi – xi + xj pj xj Discrete Algs for Mobile Wireless Sys
Reference Execution and Shifted Execution • Assume an arbitrary external clock synch algorithm for the given model. • Consider execution in which every message delay is the median (de on link e). • Pick any node vi and suppose vi's logical clock at the end is equal to or behind source time. • Shift to obtain ': • vjis shifted by ujmin (min uncertainty of any path from vj to a source) Discrete Algs for Mobile Wireless Sys
Intuition for Shifted Execution • Suppose all uncertainties are the same, u • Neighbors of sources are shifted by u • Nodes 2 hops from a source are shifted by 2u, etc. • Smooth gradient of shift amounts • Boundaries between different trees (for different sources) are also smooth Discrete Algs for Mobile Wireless Sys
Shifted Execution is Legal • If shifted execution does not obey system assumptions, nothing that we conclude about the algorithm in this execution is relevant • So we must show that in shifted execution, all message delays are within stated bounds • If sender and receiver of a message are shifted by same amount, then message delay in ' is same as in -- still within bounds Discrete Algs for Mobile Wireless Sys
vk Shifted Execution is Legal • Suppose sender vj is shifted by less than receiver vk. • In , delay is de. • In ', delay is de – ujmin + ukmin ≤ de + ue. • legal! vj link e ujmin ukmin ≤ ujmin + ue Discrete Algs for Mobile Wireless Sys
Shifted Execution is Legal • Case when sender is shifted by more than receiver is similar. • Thus the shifted execution is legal and the algorithm is supposed to be correct and obey desired bounds in it. Discrete Algs for Mobile Wireless Sys
Skew Must Be Large • What happens to vi's skew in ' ? • By shifting lemma, vi's logical clock in ' is uimin behind what it is in . • Since in , vi's logical clock is 0 or more behind source time, in ', vi's logical clock is uimin or more behind source time. • Thus vi's skew is at least uimin. • (If vi's logical clock is ahead of source time at the end of , then shift by negative amts) Discrete Algs for Mobile Wireless Sys
Discussion • What about handling clock drift? • periodically redo the algorithm? • This paper studied optimizing worst-case skew; what about optimizing expected skew? • experimental results indicate that shallow energy-contrained spanning forests are optimal under this measure as well • What about optimizing skew on a per-execution basis? • What about fixing desired skew and finding minimal-energy algorithm to achieve this skew? • What about mobile nodes? • Compare simplicity of lower bound for external synch to complicated analysis for internal synch (Halpern et al.) Discrete Algs for Mobile Wireless Sys