Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ad Hoc and Sensor Networks – Roger Wattenhofer –9/1Ad Hoc and Sensor Networks – Roger Wattenhofer – Time Synchronization Chapter 9 TexPoint fonts used.

Similar presentations


Presentation on theme: "Ad Hoc and Sensor Networks – Roger Wattenhofer –9/1Ad Hoc and Sensor Networks – Roger Wattenhofer – Time Synchronization Chapter 9 TexPoint fonts used."— Presentation transcript:

1 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/1Ad Hoc and Sensor Networks – Roger Wattenhofer – Time Synchronization Chapter 9 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAA A

2 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/2 Rating Area maturity Practical importance Theoretical importance First steps Text book No apps Mission critical Not really Must have

3 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/3 Motivation Clock Sources Reference-Broadcast Synchronization (RBS) Time-sync Protocol for Sensor Networks (TPSN) Gradient Clock Synchronization Overview

4 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/4Ad Hoc and Sensor Networks – Roger Wattenhofer – 2. Time Synchronization in Distributed Systems

5 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/5Ad Hoc and Sensor Networks – Roger Wattenhofer – 5 Assumptions Process can perform three kinds of atomic actions/events –Local computation –Send a single message to a single process –Receive a single message from a single process Communication model –Point-to-point –Error-free, infinite buffer –Potentially out of order

6 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/6Ad Hoc and Sensor Networks – Roger Wattenhofer – 6 Motivation Many protocols need to impose an ordering among events –If two players open the same treasure chest “almost” at the same time, who should get the treasure? Physical clocks: –Seems to completely solve the problem –But what about theory of relativity? –Even without theory of relativity – efficiency problems

7 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/7Ad Hoc and Sensor Networks – Roger Wattenhofer – 7 Physical Clock Synchronization The relation between clock time and UTC when clocks tick at different rates.

8 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/8 8 Classification Types of Synchronization External Synchronization : Keep as close to UTC as possible Internal Synchronization : Mutual synchronization is important Phase Synchronization Types of clocks Unbounded 0, 1, 2, 3,... Bounded 0,1, 2,... M-1, 0, 1,... Unbounded clocks are not realistic, but are easier to deal with in algorithms. Real clocks are always bounded.

9 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/9 9 Terminology Drift rate  : Max rate two clocks can differ, < 10^-6 for Xtal clocks Clock skew  : Max. Allowed drift Resynchronization interval R : Depends on clock skew Challenges (Drift is unavoidable) Accounting for propagation delay Accounting for processing delay Faulty clocks

10 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/10 10 Internal synchronization A simple averaging algorithm Assume n clocks, at most t are faulty Step 1. Read every clock in the system. Step 2. Discard outliers and substitute them by the value of the local clock. Step 3. Update the clock using the average of these values. Some clocks may be faulty. Exhibits 2-faced behavior

11 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/11 11 Network Time Protocol (NTP) Tiered architecture Broadcast mode - least accurate Procedure call - medium accuracy Peer-to-peer mode - upper level servers use this for max accuracy Time server The tree can reconfigure itself if some node fails. Level 1 Level 0 Level 2

12 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/12 12 P2P mode of NTP Let Q’s time be ahead of P’s time by . Then T2 = T1 + T PQ +  T4 = T3 + T QP -  y = T PQ + T QP = T2 +T4 -T1 -T3 (RTT)  = (T2 -T4 -T1 +T3) / 2 - (T PQ - T QP ) / 2 So, x- y/2 ≤  ≤ x+ y T2 T1T4 T3 Q P Ping several times, and obtain the smallest value of y. Use it to calculate  x Between y/2 and -y/2

13 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/13Ad Hoc and Sensor Networks – Roger Wattenhofer – 13 Cristian’s Algorithm 1. Client gets data from a time server. 2. It computes the round trip time (RTT), and compensates for this delay while adjusting its own clock

14 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/14Ad Hoc and Sensor Networks – Roger Wattenhofer – 14 Berkeley Time Protocol (FromTanenbaum 2007) a) The time daemon asks all the other machines for their clockvalues. b) The machines answer The time daemon tells everyone how to adjust their clock.

15 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/15Ad Hoc and Sensor Networks – Roger Wattenhofer – 15 Software “Clocks” Software “clocks” can incur much lower overhead than maintaining (sufficiently accurate) physical clocks Allows a protocol to infer ordering among events Goal of software “clocks”: Capture event ordering that are visible to users –But what orderings are visible to users without physical clocks?

16 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/16Ad Hoc and Sensor Networks – Roger Wattenhofer – 16 Visible Ordering to Users A  B (process order) B  C (send-receive order) A  C (transitivity) user1 (process1) user2 (process2) user3 (process3) A B C D A ? D B ? D C ? D

17 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/17Ad Hoc and Sensor Networks – Roger Wattenhofer – 17 “Happened-Before” Relation “Happened-before” relation captures the ordering that is visible to users when there is no physical clock –A partial order among events –Process-order, send-receive order, transitivity First introduced by Lamport – Considered to be the first fundamental result in distributed computing Goal of software “clock” is to capture the above “happened-before” relation. Formally, a logical clock C is a map from the set of events E to N (the set of natural numbers) with the following constraint:

18 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/18Ad Hoc and Sensor Networks – Roger Wattenhofer – 18 1: Logical Clocks Each event has a single integer as its logical clock value –Each process has a local counter C –Increment C at each “local computation” and “send” event –When sending a message, logical clock value V is attached to the message. At each “receive” event, C = max(C, V) + 1 user1 (process1) user2 (process2) user3 (process3) 1234 1 3 = max(1,2)+1 45 12 5 3 4 = max(3,3)+1

19 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/19Ad Hoc and Sensor Networks – Roger Wattenhofer – 19 Logical Clock Properties Theorem: –Event s happens before t  the logical clock value of s is smaller than the logical clock value of t. The reverse may not be true user1 (process1) user2 (process2) user3 (process3) 1234 145 12 5 3

20 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/20Ad Hoc and Sensor Networks – Roger Wattenhofer – 20 Lamport’s Logical Clock Algorithm

21 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/21Ad Hoc and Sensor Networks – Roger Wattenhofer – 21 2: Vector Clocks Logical clock: Vector clock: –Event s happens before event t  the vector clock value of s is “smaller” than the vector clock value of t. Each event has a vector of n integers as its vector clock value –v1 = v2 if all n fields same –v1  v2 if every field in v1 is less than or equal to the corresponding field in v2 –v1 < v2 if v1  v2 and v1 ≠ v2 Relation “<“ here is not a total order

22 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/22Ad Hoc and Sensor Networks – Roger Wattenhofer – 22 Vector Clock Protocol Each process i has a local vector C Increment C[i] at each “local computation” and “send” event When sending a message, vector clock value V is attached to the message. At each “receive” event, C = pairwise-max(C, V); C[i]++; user1 (process1) user2 (process2) user3 (process3) (1,0,0)(2,0,0)(3,0,0) (0,0,2) (0,2,2) (0,1,0) (0,0,1) (2,3,2) (2,3,3) C = (0,1,0), V = (0,0,2) pairwise-max(C, V) = (0,1,2)

23 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/23Ad Hoc and Sensor Networks – Roger Wattenhofer – 23 Vector Clock Properties Event s happens before t  vector clock value of s < vector clock value of t: There must be a chain from s to t Event s happens before t  vector clock value of s < vector clock value of t –If s and t on same process, done –If s is on p and t is on q, let VS be s’s vector clock and VT be t’s –VS < VT  VS[p] ≤ VT[p]  Must be a sequence of message from p to q after s and before t q s t p

24 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/24Ad Hoc and Sensor Networks – Roger Wattenhofer – 24 Example Application of Vector Clock Each user has an order placed by a customer –Want all users to know all orders Each order has a vector clock value user1 (process1) user2 (process2) user3 (process3) D1, (1,0,0)(2,0,0)(3,0,0) (0,0,2) (0,2,2) D2, (0,1,0) D3, (0,0,1) (2,3,2) (2,3,3) D1 D3 D1, D2, D3 I have seen all orders whose vector clock is smaller than (2,3,2): I can avoid linear search for existence testing

25 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/25Ad Hoc and Sensor Networks – Roger Wattenhofer – 25 Vector Clock Algorithm

26 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/26Ad Hoc and Sensor Networks – Roger Wattenhofer – 26 A sample execution of the vector clock algorithm

27 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/27Ad Hoc and Sensor Networks – Roger Wattenhofer – 27 Summary Goal : Define “time” in a distributed system Logical clock –“happened before”  smaller clock value Vector clock –“happened before”  smaller clock value Matrix clock –Gives a process knowledge about what other processes know

28 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/28 Motivation Time synchronization is essential for many applications –Coordination of wake-up and sleeping times (energy efficiency) –TDMA schedules –Ordering of collected sensor data/events –Co-operation of multiple sensor nodes –Estimation of position information (e.g. shooter detection) Goals of clock synchronization –Compensate offset between clocks –Compensate drift between clocks

29 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/29 Properties of Synchronization Algorithms External versus internal synchronization –External sync: Nodes synchronize with an external clock source (UTC) –Internal sync: Nodes synchronize to a common time –to a leader, to an averaged time, or to anything else Instant versus periodic synchronization –Periodic synchronization required to compensate clock drift A-priori versus a-posteriori –A-posteriori clock synchronization triggered by an event Local versus global synchronization

30 Clock Sources Radio Clock Signal: –Clock signal from a reference source (atomic clock) is transmitted over a longwave radio signal –DCF77 station near Frankfurt, Germany transmits at 77.5 kHz with a transmission range of up to 2000 km –Accuracy limited by the distance to the sender, Frankfurt-Zurich is about 1ms. –Special antenna/receiver hardware required Global Positioning System (GPS): –Satellites continuously transmit own position and time code –Line of sight between satellite and receiver required –Special antenna/receiver hardware required

31 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/31 Clock Devices in Sensor Nodes Structure –External oscillator with a nominal frequency (e.g. 32 kHz) –Counter register which is incremented with oscillator pulses –Works also when CPU is in sleep state Accuracy –Clock drift: random deviation from the nominal rate dependent on power supply, temperature, etc. –E.g. TinyNodes have a maximum drift of 30-50 ppm at room temperature Oscillator This is a drift of up to 50 μs per second or 0.18s per hour

32 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/32 Sender/Receiver Synchronization Round-Trip Time (RTT) based synchronization Receiver synchronizes to the sender‘s clock Propagation delay  and clock offset  can be calculated

33 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/33 Disturbing Influences on Packet Latency Influences –Sending Time S (up to 100ms) –Medium Access Time A(up to 500ms) –Transmission Time T(tens of milliseconds, depending on size) –Propagation Time P A,B (microseconds, depending on distance) –Reception Time R(up to 100ms) Asymmetric packet delays due to non-determinism Solution: timestamp packets at MAC Layer S A T R P A,B Critical path Timestamp T A Timestamp T B

34 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/34 Reference-Broadcast Synchronization (RBS) A sender synchronizes a set of receivers with one another Point of reference: beacon’s arrival time Only sensitive to the difference in propagation and reception time Time stamping at the interrupt time when a beacon is received After a beacon is sent, all receivers exchange their reception times to calculate their clock offset A B S Post-synchronization possible Least-square linear regression to tackle clock drifts

35 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/35 Time-sync Protocol for Sensor Networks (TPSN) Traditional sender-receiver synchronization (RTT-based) Initialization phase: Breadth-first-search flooding –Root node at level 0 sends out a level discovery packet –Receiving nodes which have not yet an assigned level set their level to +1 and start a random timer –After the timer is expired, a new level discovery packet will be sent –When a new node is deployed, it sends out a level request packet after a random timeout 1 2 0 1 2 2 1 2

36 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/36Ad Hoc and Sensor Networks – Roger Wattenhofer – Time-sync Protocol for Sensor Networks (TPSN) Synchronization phase –Root node issues a time sync packet which triggers a random timer at all level 1 nodes –After the timer is expired, the node asks its parent for synchronization using a synchronization pulse –The parent node answers with an acknowledgement –Thus, the requesting node knows the round trip time and can calculate its clock offset –Child nodes receiving a synchronization pulse also start a random timer themselves to trigger their own synchronization 1 A 0 1 2 2 B 2 Time Sync ACK Sync pulse

37 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/37 Time-sync Protocol for Sensor Networks (TPSN) Time stamping packets at the MAC layer In contrast to RBS, the signal propagation time might be negligible Authors claim that it is “about two times” better than RBS Again, clock drifts are taken into account using periodical synchronization messages Problem: What happens in a non-tree topology (e.g. ring)?!? –Two neighbors may have exceptionally bad synchronization 1 A 0 1 2 2 B 2

38 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/38 Theoretical Bounds for Clock Synchronization Network Model: –Each node i has a local clock L i (t) –Network with n nodes, diameter D. –Reliable point-to-point communication with minimal delay µ –Jitter ε is the uncertainty in message delay Two neighboring nodes u, v cannot distinguish whether message is faster from u to v and slower from v to u, or vice versa. Hence clocks of neighboring nodes can be up to  off. Hence, two nodes at distance D may have clocks which are  D off. This can be achieved by a simple flooding algorithm: Whenever a node receives a new minimum value, it sets its clock to the new value and forwards its new clock value to all its neighbors. 01230123 µ µ +  01230123 µ u v u v

39 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/39 1.Global property: Minimize clock skew between any two nodes 2.Local (gradient) property: Small clock skew between two nodes if the distance between the nodes is small. 3.Clock should not be allowed to jump backwards  You don’t want new events to be registered earlier than older events. Example: Ring topology Gradient Clock Synchronization 1 0 1 2 3 2 3 4 Small clock skew Large clock skew Root node

40 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/40 1.Global property: Minimize clock skew between any two nodes 2.Local (gradient) property: Small clock skew between two nodes if the distance between the nodes is small. 3.Clock should not be allowed to jump backwards To prevent trivial solution, we need a fourth constraint: 4.Clock should always to move forward. Sometimes faster, sometimes slower is OK. But there should be a minimum and a maximum speed. Trivial Solution: Let t = 0 at all nodes and times

41 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/41 Gradient Clock Synchronization Model – Each node has a hardware clock H i (∙) with a clock rate where 0 < L < U and U ≥ 1 – The time of node i at time t is – Each node has a logical clock L i (∙) which increases at the rate of H i (∙) – Employ a synchronization algorithm A to update the local clock with fresh clock values from neighboring nodes (clock cannot run backwards) – Nodes inform their neighboring nodes when local clock is updated Time is 140 Time is 150 Time is 142 Time is 152 ???

42 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/42Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 42 Goals of this chaper Understand the importance of time synchronization in WSNs Understand typical strategies for time synchronization and how they are applied in WSNs

43 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/43Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 43 Overview The time synchronization problem Protocols based on sender/receiver synchronization Protocols based on receiver/receiver synchronization Summary

44 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/44Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 44 Overview The time synchronization problem Protocols based on sender/receiver synchronization Protocols based on receiver/receiver synchronization Summary

45 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/45 SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 45 Example Goal: estimate angle of arrival of a very distant sound event using an array of acoustic sensors From the figure,  can be estimated when x and d are known: d is known a priori, x must be estimated from differences in time of arrival –x = C  t where C is the speed of sound –For d=1 m and  t =0.001 we get  = 0.336 radians –When  t is estimated with 500  s error, the  estimates can vary between 0.166 and 0.518 Morale: a seemingly small error in time synch can lead to significantly different angle estimates

46 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/46Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 46 The role of time in WSNs Time synchronization algorithms can be used to better synchronize clocks of sensor nodes Time synchronization is needed for WSN applications and protocols: –Applications: AOA estimation, beamforming –Protocols: TDMA, protocols with coordinated wakeup,... –Distributed debugging: timestamping of distributed events is needed to figure out their correct order of appearance WSN have a direct coupling to the physical world, hence their notion of time should be related to physical time: –physical time = wall clock time, real-time, i.e. one second of a WSN clock should be close to one second of real time –Commonly agreed time scale for real time is UTC, generated from atomic clocks and modified by insertion of leap seconds to keep in synch with astronomical timescales (one rotation of earth) –Other concept: logical time (Lamport), where only the relative ordering of events counts but not their relation to real time

47 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/47Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 47 Clocks in WSN nodes Often, a hardware clock is present: –An oscillator generates pulses at a fixed nominal frequency –A counter register is incremented after a fixed number of pulses –Only register content is available to software –Register change rate gives achievable time resolution –Node i’s register value at real time t is H i (t) –Convention: small letters (like t, t’) denote real physical times, capital letters denote timestamps or anything else visible to nodes A (node-local) software clock is usually derived as follows: –L i (t) =  i H i (t) +  i (not considering overruns of the counter-register) –  i is the (drift) rate,  i the phase shift –Time synchronization algorithms modify  i and  i, but not the counter register

48 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/48Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 48 Synchronization accuracy / agreement External synchronization: –synchronization with external real time scale like UTC –Nodes i=1,..., n are accurate at time t within bound  when |L i (t) – t|<  for all i –Hence, at least one node must have access to the external time scale Internal synchronization –No external timescale, nodes must agree on common time –Nodes i=1,..., n agree on time within bound  when |L i (t) – L j (t)|<  for all i,j

49 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/49Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 49 Sources of inaccuracies Nodes are switched on at random times, phases θ i hence can be random Actual oscillators have random deviations from nominal frequency (drift, skew) –Deviations are specified in ppm (pulses per million), the ppm value counts the additional pulses or lost pulses over the time of one million pulses at nominal rate –The cheaper the oscillators, the larger the average deviation –For sensor nodes values between 1 ppm (one second every 11 days) and 100 ppm (one second every 2.8 hours) are assumed, Berkeley motes have an average drift of 40 ppm Oscillator frequency depends on time (oscillator aging) and environment (temperature, pressure, supply voltage,...) –Especially the time-dependent drift rates call for frequent re- synchronization, as one-time synchronization is not sufficient –However, stability over tens of minutes is often a reasonable assumption

50 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/50Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 50 General properties of time synchronization algorithms Physical time vs. logical time External vs. internal synchronization Global vs. local algorithms –Keep all nodes of a WSN synchronized or only a local neighbourhood? Absolute vs. relative time Hardware vs. software-based mechanisms –A GPS receiver would be a hardware solution, but often too heavyweight/costly/energy-consuming in WSN nodes, and in addition a line-of-sight to at least four satellites is required A-priori vs. a-posteriori synchronization –Is time synchronization achieved before or after an interesting event?  Post-facto synchronization Deterministic vs. stochastic precision bounds Local clock update discipline –Should backward jumps of local clocks be avoided? (Users of make say yes here....) –Avoid sudden jumps?

51 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/51Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 51 Performance metrics and fundamental structure Metrics: –Precision: maximum synchronization error for deterministic algorithms, error mean / stddev / quantiles for stochastic ones –Energy costs, e.g. # of exchanged packets, computational costs –Memory requirements –Fault tolerance: what happens when nodes die? Fundamental building blocks of time synchronization algorithms: –Resynchronization event detection block: when to trigger a time synchronization round? Periodically? After external event? –Remote clock estimation block: figuring out the other nodes clocks with the help of exchanging packets –Clock correction block: compute adjustments for own local clock based on estimated clocks of other nodes –Synchronization mesh setup block: figure out which node synchronizes with which other nodes

52 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/52Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 52 Constraints for Time Synchronization in WSNs An algorithm should scale to large networks of unreliable nodes Quite diverse precision requirements, from ms to tens of seconds Use of extra hardware (like GPS receivers) is mostly not an option low mobility Often there are no fixed upper bounds on packet delivery times (due to MAC delays, buffering,...) Negligible propagation delay between neighboring nodes Manual node configuration is not an option

53 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/53Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 53 Post-facto synchronization Basic idea: –Keeping nodes synchronized all the time incurs substantial energy costs due to need for frequent resynchronization –Especially true for networks which become active only rarely –When a node observes an external event at time t, it stores its local timestamp L i (t), achieves synchronization with neighbor node / sink node and converts L i (t) accordingly Can be implemented in different ways, to be discussed later

54 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/54Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 54 Overview The time synchronization problem Protocols based on sender/receiver synchronization Protocols based on receiver/receiver synchronization Summary

55 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/55Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 55 Protocols based on sender/receiver synchronization In this kind of protocols, a receiver synchronizes to the clock of a sender We have to consider two steps: –Pairwise synchronization: how does a single receiver synchronize to a single sender? –Networkwide synchronization: how to figure out who synchronizes with whom to keep the whole network / parts of it synchronized? The classical NTP protocol [Mills, RFC 1305] belongs to this class

56 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/56Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 56 LTS – Lightweight Time Synchronization Overall goal: synchronize the clocks of all sensor nodes / of a subset of nodes to one reference clock (e.g. equipped with GPS receivers) It allows to synchronize the whole network, parts of it and it also supports post-facto synchronization It considers only phase shifts and does not try to correct different drift rates Two components: –pairwise synchronization: based on sender/receiver technique –networkwide synchronization: minimum spanning tree construction with reference node as root

57 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/57Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 57 LTS – Pairwise Synchronization

58 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/58Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 58 LTS – Pairwise Synchronization Node i wants to synchronize its clock to node j’s clock Timeline: –Node i triggers resynchronization at time t 0, formats packet, timestamps it at t 1 with L i (t 1 ) and hands it over to transmission (with L i (t 1 ) as payload) –At t 2 the first bit appears on the channel, at t 3 the receiver receives last bit, packet reception is signaled at t 4, and at t 5 node j timestamps it with L j (t 5 ) –Node j formats answer packet, timestamps it at time t 6 with L j (t 6 ) and hands it over for transmission – as payload the timestamps L i (t 1 ), L j (t 5 ) and L j (t 6 ) are included –The arrival of the answer packet is signaled at time t 7 to node i, and i timestamps it afterwards with L i (t 8 ) After time t 8, node i possesses four values: L i (t 1 ), L j (t 5 ), L j (t 6 ) and L i (t 8 ) and wants to estimate its clock offset to node j – but how?

59 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/59Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 59 LTS – Pairwise Synchronization Assumptions: –Node i’s original aim is to estimate the true offset O=  (t 1 )=L i (t 1 ) – L j (t 1 ) –During the whole process the drift is negligible  the algorithm in fact estimates  (t 5 ) and assumes  (t 5 ) =  (t 1 ) –Propagation delay  the same in both directions, request and answer packets have duration t p, both parameters are known to i Approach: –Node i estimates  (t 5 )=L i (t 5 )-L j (t 5 ) and therefore needs to estimate L j (t 5 ), which is generated “somewhere” between t 1 and t 8 –When t 8 – t 1 is very small, we might be willing to approximate O ¼ L i (t 1 ) – L j (t 5 ) or as ¼ L i (t 8 ) – L j (t 5 ) But we can reduce uncertainty: –after t 1 we have at least one propagation delay and packet transmission time (for the request packet) –before t 8 we have another propagation delay and packet transmission time (for the response packet) –There passes also time between L j (t 5 ) and L j (t 6 ), and L i (t 5 ) must be before this interval

60 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/60Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 60 LTS – Pairwise Synchronization Under the assumption that the remaining uncertainty is allocated equally to both i and j, node i can estimate L j (t 5 ) as This means:

61 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/61Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 61 LTS – Pairwise Synchronization -- Discussion Node i can figure out the offset to node j based on the known values L i (t 1 ), L j (t 5 ), L j (t 6 ), L i (t 8 ) This exchange takes two packets – if node j should also learn about the offset, a third packet is needed from i to j carrying O The uncertainty is in the interval I = [L i (t 1 )+  +t p, L i (t 8 ) -  – t p – (L j (t 6 ) – L j (t 5 )], and by picking the mid-point of the interval as L i (t 5 ), the maximum uncertainty is |I|/2

62 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/62Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 62 LTS – Pairwise Synchronization -- Discussion Sources of inaccuracies: –MAC delay –interrupt latencies upon receiving packets –Delays between packet interrupts and timestamping operation –Delay in operating system and protocol stack Improvements: –Let i timestamp its packet after the MAC delay, immediately before transmitting the first bit –This would remove the uncertainty due to i’s operating system / protocol stack and the MAC delay!! –Let j timestamp receive packets as early as possible, e.g. in the interrupt routine –this removes the delay between packet interrupts and timestamping from the uncertainty, and leaves only interrupt latencies  these things are hard to do when COTS hardware is used, but easy when full source code of MAC and direct access to hardware are available

63 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/63 SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 63 LTS – Pairwise Synchronization – Error Analysis Elson et al measured pairwise differences in timestamping times at a set of receivers when timestamping happens in the interrupt routine (Berkeley motes) Estimated distribution: –normal random variable (rv) with zero mean/stddev of 11.1  s Additional assumption: uncer- tainty on the transmitter side has same distrib. and is independent Hence: –total uncertainty is a zero-mean normal rv with variance 4  2 –For a normal rv 99% of all outcomes have maximum distance of 2.3  to mean  the maximum synchronization error is with 99% probability smaller than 2.3 * 2 * 

64 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/64Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 64 LTS – Networkwide Synchronization We are given one reference node R, to which all other nodes / a subset of nodes want to synchronize –R’s direct neighbors (level-1 neighbors) synchronize with R –Two-hop (level-2) neighbors synchronize with level-1 neighbors –.... This way a spanning tree is created But one should not allow arbitrary spanning trees: –Consider a node i with hop distance h i to the root node –Assume that: –all synchronization errors are independent –all synch errors are identically normally distributed with zero mean and variance 4  2 –Then node i’s synchronization error is a zero-mean normal rv with variance h i 4  2 –Hence, a minimum spanning tree minimizes synchronization errors

65 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/65Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 65 LTS – Centralized Multihop LTS Reference node R triggers construction of a spanning tree, it first synchronizes its neighbors, then the first-level neighbors synchronize second-level neighbors and so on Different distributed algorithms for construction of spanning tree can be used, e.g. DDFS, Echo algorithm Communication costs: –Costs for construction of spanning tree –Synchronizing two nodes costs 3 packets, synchronizing n nodes costs 3n packets

66 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/66Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 66 LTS – Distributed Multihop LTS No explicit construction of spanning tree needed, but each node knows identity of reference node(s) and routes to them When node 1 wants to synchronize with R, an appropriate request travels to R – following this, 4 synchronizes to R, 3 synchronizes to 4, 2 synchronizes to 3, 1 synchronizes to 2 –By-product: nodes 2, 3, and 4 are synchronized with R Minimum spanning tree constructed implicitly: node 1 should know shortest route to the closest reference node

67 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/67Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 67 LTS – Distributed Multihop LTS -- Variations When node 5 wants to synchronize with R, it can: –issue its own synchronization request using route over 3, 4 and put additional synchronization burden on them –ask in its local neighborhood whether someone is synchronized or has an ongoing synchronization request and benefit from that later on –Enforce usage of path over 7, 8 (path diversification) to also synchronize these nodes Discussion: –Simulation shows that distributed multihop LTS needs more packets (between 40% and 100%) when all nodes have to be synchronized, even with optimizations –Distributed multihop LTS allows to synchronize only the minimally required set of nodes  post-facto synchronization

68 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/68Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 68 Other Sender-/Receiver-based Protocols These protocols work similar to LTS, with some differences in: –Method of spanning tree construction –How and when to take timestamps –How to achieve post-facto synchronization One variant: TPSN (Timing-Sync Protocol for Sensor Nets) –Pairwise-protocol similar to LTS, but timestamping at node i happens immediately before first bit appears on the medium, and timestamping at node j happens in interrupt routine –Spanning tree construction based on level-discovery protocol: –root issues level_discovery packet with level 0 –neighbors assign themselves level 1 + level value from level_discovery –neighbors wait for some random time before they issue level_discovery packets indicating their own level –Nodes missing level_discovery packets for long time ask their neighborhood

69 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/69Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 69 Overview The time synchronization problem Protocols based on sender/receiver synchronization Protocols based on receiver/receiver synchronization Summary

70 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/70Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 70 Overview The time synchronization problem Protocols based on sender/receiver synchronization Protocols based on receiver/receiver synchronization Summary

71 Ad Hoc and Sensor Networks – Roger Wattenhofer –9/71Ad Hoc and Sensor Networks – Roger Wattenhofer – SS 05 Ad hoc & sensor networs - Ch 8: Time Synchronization 71 Summary Time synchronization is important for both WSN applications and protocols Using hardware like GPS receivers is typically not an option, so extra protocols are needed Post-facto synchronization allows for time-synchronization on demand, otherwise clock drifts would require frequent re- synchronization and thus a constant energy drain Some of the presented protocols take significant advantage of WSN peculiarities like: –small propagation delays –the ability to influence the node firmware to timestamp outgoing packets late, incoming packets early Of course, there are many, many more schemes....


Download ppt "Ad Hoc and Sensor Networks – Roger Wattenhofer –9/1Ad Hoc and Sensor Networks – Roger Wattenhofer – Time Synchronization Chapter 9 TexPoint fonts used."

Similar presentations


Ads by Google