Page 1

On Efficient Clock Drift Prediction Means and

Their Applicability to IEEE 802.15.4

Marcin Brzozowski, Hendrik Salomon and Peter Langendoerfer

IHP

Im Technologiepark 25

15236 Frankfurt (Oder), Germany

{brzozowski, salomon, langendoerfer}@ihp-microelectronics.com

Abstract—Sensor nodes compensate clock drift with guard

times (GT), which results in idle listening. By applying prediction

methods nodes can limit drift uncertainty for upcoming frames

and shorten GT. However, a common solution based on linear

regression requires floating-point arithmetic, i.e. large compu-

tation and memory overhead. We present an approach for drift

prediction based on moving average, which works well with basic

mathematical operations. It achieves similar accuracy to linear

regression in indoor environments (the standard deviation of the

drift prediction is less than a clock tick for 1-minute period) and

even better results on some nodes outdoors. Moreover, it needs

only 3 previous drift samples for accurate drift estimations.

Our two-week drift experiments revealed that in outdoor

scenarios nodes received 99% of frames with GT 8x shorter

than the worst case. We exploit the idea of deliberately giving

up the reception of approx. 1% of frames in order to use very

short GT and to reduce idle listening. After applying our drift

prediction approach we shortened GT by 95%. It results in 10%

lifetime gain for IEEE 802.15.4.

I. INTRODUCTION

In general, sensor nodes use crystal oscillators to derive the

time. The oscillators frequency is a time variable, referred to

as clock drift. Changes of temperature, air pressure or electric

supply voltage cause short-term variations of the oscillator

frequency.Long-term variations are caused by oscillator aging.

Moreover, the same oscillator type may run with different

frequencies on various nodes. Thus, clocks of sensor nodes

run at different speeds.

Due to clock drift a sensor node may wake up too soon

or too late to receive a message in low duty cycle (LDC)

protocols, e.g. it misses a beacon in IEEE 802.15.4 [8]. To

counter this threat, sensor nodes wake up earlier by a guard

time, and also stay awake longer. A common solution to

guard times considers worst drift. However, as run-time drift

is a few times smaller than the worst one, such a solution

causes unnecessary long idle listening and wastes energy.

During indoor and outdoor experiments we discovered that

nodes can compensate drift of most messages (99%) within a

small guard time window, i.e. 30x smaller than the worst-case

guard time for indoors and 8x smaller for outdoors. Thus, if

nodes deliberately use shorter guard times, they reduce idle

listening significantly and miss only a few frames due to not

compensated drift.

Sensor nodes achieve further idle-listening reduction by

applying drift prediction approaches. As clock drift is assumed

to be stable over a short time [10], [7], nodes may predict

future drift to the neighbours, according to previous drift

observations. Some time synchronization protocols predict

future drift by adapting linear regression (LR) on previous

drift samples, e.g. ordinary least squares (OLS). Moreover,

using OLS nodes can estimate the probability that predicted

drift is bounded within certain limits. It allows the calculation

of guard times, which are shorter by approx. 95% than the

worst case. However, LR has the following drawbacks when

implemented on sensor nodes. Firstly, it requires floating-

point arithmetic, which causes large computation overhead,

e.g. LR may take 120ms on a sensor node [7]. Moreover,

nodes need additional memory for the floating-point module

and for large floating-point variables. Secondly, as LR requires

several previous samples to accurately predict future drift,

nodes must use the worst-case guard times for some frames to

collect enough drift samples. Clearly, it results in additional

idle listening and wastes the gain obtained from shorter guard

times of LR. Thus, we extended LR so that nodes do not

need to use worst-case guard times apart from the initialization

phase. We adapted LR approach for IEEE 802.15.4 standard

and use it for comparison purposes.

To overcomethe drawbacks of LR we present a new solution

for drift prediction. We discovered that a moving average filter

achieves very similar results to approaches based on LR, i.e.

the standard deviation of the prediction is 1-2 clock ticks for

a 1-minute sleep period (1 clock tick = 30.5 µs). Moreover,

moving average achieved higher prediction accuracy on some

nodes in the outdoor environment. However, moving average

works well without floating-point operations and therefore fits

better to sensor nodes than LR.

The paper is organized as follows. Section 2 gives an

overview about the scientific efforts related to LDC protocols

and clock drift. Section 3 introduces IEEE 802.15.4. In next

sections we present drift compensation approaches, OLS in

section 4 and moving average in section 5. The results of

our drift experiments are presented in section 6. We evaluate

solutions to drift compensation in section 7 and conclude the

paper thereafter.

II. RELATED WORK

Although LDC protocols suffer from clock drift, the prob-

lem was often neglected (e.g. SMAC [15], WiseMAC [5],

Page 2

2

DMAC [9]). To counter the clock drift problem, several

approaches (e.g. Dozer [3], DLDC-MAC [1]) use guard times

based on worst-case drift. However, the authors derive worst-

case drift only from oscillator drift parameter neglecting other

factors, e.g. the time of radio power up/down is not constant.

Moreover, as run-time drift is smaller than the worst case,

such solutions may waste energy due to unnecessary long idle

listening.

Ref. [12] addresses the problem of clock drift and LDC. The

authors combine hardware and software solutions to achieve

very accurate times. Their sensor nodes equipped with two

oscillators derive a very precise local time, +/- 1.2 parts

per million (ppm) frequency stability. However, the approach

requires hardware modifications (2 oscillators) and the initial

calibration of both oscillators. Moreover, the software part

occupies 3kB memory (6% of available program memory on

tmote sky [11] sensor node).

The authors in [7] present Rate Adaptive Time Synchroniza-

tion (RATS) and combine it with B-MAC in order to prolong

the lifetime of LDC. RATS extends LR (linear regression)

drift prediction by the empirical estimation of confidence

intervals in indoor and outdoor scenarios. These intervals are

a good basis for the guard time calculation, as they define the

probability that future drift will be within certain limits. In

general, B-MAC uses long preambles to compensate worst

time uncertainty between a sender and a receiver. B-MAC

combined with RATS lowers time uncertainty and in that way

shortens preambles, resulting in the idle listening reduction.

However, from time to time RATS sends time-synchronization

frames with the worst case preamble to ensure proper working

of OLS, causing unnecessary idle listening. Additionally, this

solution decreases idle listening but for the cost of additional

memory needed for a complex time synchronization protocol.

Moreover, RATS with B-MAC is tailored for protocols where

a sender is responsible for drift compensation, for example

by sending longer preambles. As IEEE 802.15.4 does not

permit longer preambles, receivers compensate drift. Hence,

it is unclear how to adapt RATS to IEEE 802.15.4.

Several time synchronization protocols address the drift pre-

diction problem. Although they do not refer to LDC explicitly,

their drift prediction methods can be used for lifetime pro-

longation of LDC protocols. Flooding Time Synchronization

Protocol (FTSP) [10] introduces the drift prediction based on

LR to increase synchronization accuracy. We already stated

the main problems of LR applied to sensor nodes. Symmetric

Clock Synchronization [14] estimates the relative drift to the

reference clock with the weighted moving average filter. The

authors use the drift estimation mainly to increase accuracy of

the time synchronization protocol. It resembles slightly the

approach we use for drift prediction based on the moving

average. However, there are many open issues when adapting

the approach [14] to LDC, mainly the calculation of prediction

uncertainty required for the guard times estimation. Sensor

nodes using Gradient Clock Synchronization [13] protocol

repeatedly collect drift samples from their neighbours. Then,

each node updates its logical clock according to the received

drift samples. In that way, all nodes converge to a common

clock and can predict future drift of this clock. However, this

Fig. 1. Superframe structure of IEEE 802.15.4 in beacon mode

approach assumes that nodes receive repeatedly frames from

neighbours, whereas in IEEE 802.15.4 (beacon mode) only the

coordinator sends beacons. Moreover, energy consumption of

additional neighbour frames cannot be neglected.

Several research works provide empirical drift data of

sensor nodes. An indoor 3-minute experiment of Berkeley

Motes shows the drift distribution appears Gaussian [6]. Ref.

[14] provides empirical data of clock drift of TinyNode [4]

hardware platform in an indoor environment only. Ref. [7]

evaluates empirically clock drift in indoor and outdoor sce-

narios. However, the longest outdoor scenario lasted 26 hours

only and the temperature varies from 17 to 27 degree Celsius.

As these experiments do not provide long-term drift data, we

carried out 2-week experiments with constant and changing

temperature, up to 50 °C.

III. IEEE 802.15.4

A. Architecture

In this paper we coupled drift compensation approaches

with IEEE 802.15.4 MAC protocol. In general, IEEE 802.15.4

works in 2 modes: with and without beacons. We considered

the beacon mode here. There are two device types in IEEE

802.15.4: full-function device (FFD) and reduced-function

device (RFD). The latter ones does not provide some features,

e.g. RFD cannot operate as a coordinator.

A single IEEE 802.15.4 network, called personal area

network (PAN), forms a star topology of a coordinator in

the center and a few sensor nodes around. Typically the

coordinator has larger energy resources than sensor nodes,

as it periodically sends beacons. The coordinator defines in

each beacon the following communication period, i.e. the

contention period length and the time slot allocation. Upon

the beacon reception nodes can access the channel, either in

contention phase or in time slots, see Figure 1. Nodes can form

more complex topologies, e.g. a tree, by connecting several

PANs. In this case, some nodes serve as gateways between

different PANs.

B. Low duty cycle

To keep the duty cycle at a low level, each node sleeps

most of the time, the inactive phase in Figure 1, and wakes

up at tnextto receive the next beacon and to send/receive data

thereafter:

tnext

=

tlast+ Tbeacon

(1)

where tlast is the reception time of the last beacon and

Tbeaconthe beacon period (protocol parameter).

Page 3

3

number of trials [%]

0

10

20

30

40

50

-20-10010

clock drift [ticks/minute]

0

1

2

-20 -10010

node A

0

10

20

30

-10

clock drift [ticks/minute]

0 1020

0

1

2

-1001020

node B

0

10

20

30

-30-20-100

clock drift [ticks/minute]

0

1

2

-30 -20 -100

node C

number of trials [%]

0

10

20

30

-20 -10010

clock drift [ticks/minute]

0

1

2

-20 -10010

node D

0

10

20

30

-30-20-100

clock drift [ticks/minute]

0

1

2

-30 -20 -100

node E

Fig. 2.Indoor scenario: drift distribution among all examined nodes; magnification in the right upper corners; 1 clock tick = 30.5 µs

number of trials [%]

0

10

20

30

01020 30

clock drift [ticks/minute]

0

1

2

01020 30

node A

0

10

20

30

-20 -10010

clock drift [ticks/minute]

0

1

2

-20 -10010

node B

0

10

20

30

-100 1020

clock drift [ticks/minute]

0

1

2

-1001020

node C

number of trials [%]

0

10

20

30

010 2030

clock drift [ticks/minute]

0

1

2

0 102030

node D

0

10

20

30

0 10 2030

clock drift [ticks/minute]

0

1

2

0102030

node E

Fig. 3.Outdoor scenario: drift distribution among all examined nodes; magnification in the right upper corners

The standard mentions that MAC layer needs to deal with

clock drift, but does not provide any solution. However, as

coordinators (senders) must use fixed-size preambles and rigid

beacon times, they cannot compensate drift. Therefore, sensor

nodes (receivers) compensate drift by waking up earlier or

later in order not to miss beacons.

IV. OLS DRIFT COMPENSATION

As clock drift is assumed to be stable over a short time [10],

[7], nodes predict the reception time of the next beacon by

applying linear regression, e.g. ordinary least squares (OLS)

method, on previous drift observations. Thus, each node stores

n previous samples < b,rx >; b is the beacon sequence

number (contained in the beacon) and rx the beacon reception

time. According to OLS each node estimates the reception

time of the next beacon as:

tnext= β1· b + β0

(2)

where b is the expected beacon sequence number1and β1, β0

OLS parameters:

n?n

n?n

β0

=¯ rx − β1¯b

β1

=

i=1birxi−?n

i=1b2

i=1bi

?n

i=1rxi

i− (?n

i=1bi)2

(3)

(4)

1As the sequence number is only 8-bit value, a special care must be taken

when the value overlaps

Page 4

4

where¯b, ¯ rx are the average values of the beacon sequence

numbers and the corresponding rx times of previous n obser-

vations.

Clearly, the predicted next wake up time may not be

accurate enough, causing the node to miss the beacon. Thus,

ref. [7] introduces confidence bands (guard times) around

tnext:

tnext± [∆ · SE(tnext)]

(5)

where SE(tnext) is the standard error of the predicted value

and ∆ the scaling factor obtained empirically, e.g. during an

initialization phase, to compensate prediction and estimation

errors.

We extend the mentioned OLS approach and redefine ∆ as

the factor needed to compensate drift of predefined amount

of frames, referred to as rx rate. The rationale behind this

is the fact that the majority of frames (approx. 99%) are

compensated with short guard times, i.e. with small ∆. On

the contrary, drift compensation of all frames requires very

long guard times and increases idle listening. Therefore, nodes

using OLS can deliberately give up the reception of 1% frames

but use very short guard times and decrease idle listening.

Our experiments revealed that ∆ does not vary among sensor

nodes and can be either discovered during the initialization

phase or estimated before deploying the nodes. For example,

in the outdoor scenario ∆ of 99% rx rate varied from 2.7 to

3.1 among 5 evaluated nodes.

In general, to achieve a high OLS accuracy nodes collect

previous drift samples and must not miss any beacon. Thus,

they use the worst-case guard times for some beacons, causing

idle-listening. However, we found out that OLS still predicts

future drift very accurately (i.e. the standard deviation of

drift prediction was even 1 clock tick / minute indoors), if

it uses short guard times and misses some beacons (1% in our

experiment).

Although the adapted OLS shortens guard times consider-

ably, see evaluation results later, it causes several problems

when implemented on sensor nodes. OLS requires an emu-

lation of floating-point arithmetic on microcontrollers. When

using single precision the truncation error can vary from +/-

17us to +/- 17.7 ms according to [7]. When using more

accurate, i.e. double-precision operations, OLS may take even

120ms [7]. Moreover, floating-point module and operations

need additional memory, which is very limited on sensor

nodes.

V. MOVING AVERAGE DRIFT COMPENSATION (MADC)

A. Drift compensation

Similarly to OLS, nodes using MADC estimate future drift

and its uncertainty in order to calculate guard times for the

following beacon.

Firstly, each node predicts future drift δavg to the coordi-

nator by applying the moving average filter to the previous n

beacon rx times rxi:

δavg=

?n

i=1(rxi+1− rxi)

n · Tbeacon

(6)

where i denotes the sample index starting from the oldest

one. On sensor nodes we approximate Eq. 6 using 16-bit

integers only, which is accurate enough for MADC. Then,

nodes estimate the next wake up time tnext to receive a

beacon:

tnext

=

tlast+ Tbeacon· δavg

(7)

As run-time drift may vary from the predicted value δavg,

nodes compensate it by using guard times based on the drift

jitter κ (expressed in ppm) as:

tnext± (m + 1) · κ · Tbeacon

(8)

where m is the number of consecutive missed beacons. Ac-

cording to Eq. 8 nodes use longer guard times upon missing

a beacon.

B. Initialization phase

If the drift jitter κ does not vary among nodes, as in

our experiment, nodes can use the value estimated before

deploying. Otherwise nodes must discover empirically the

jitter needed to receive predefined amount of frames, e.g.

during the initialization phase. We introduce an algorithm for

the jitter discovery that does not need storing previous drift

samples. It consists of the following steps:

1) Γ-array contains rx counters for predefined jitter values

from κminto κmax; each node fills the array with zeros

at the beginning.

2) Nodes use the worst-case guard time to receive as many

beacons as possible. Upon receiving a beacon nodes

increment the counter for all jitters κ that compensated

current drift according to Eq. 8., i.e. Γ[κ]++

3) after receiving the predefined number of beacons Φ each

node finds min(κ) :Γ[κ]

where ψ is the desired rx rate.

Φ≥ ψ,

VI. EXPERIMENT

We examined relative drift between sensor nodes and a

sink, which includes all factors affecting time uncertainty

(e.g. the time needed to power up the transceiver that may

be not completely constant; similar reasoning holds true for

software execution). As clock drift depends on environmental

conditions, e.g. temperature, pressure, we carried out two

experiments: one with constant and one with changing tem-

perature. We deployed 5 tmote sky [11] sensor nodes in our

office environment, referred to as indoor experiment. After

that, we started another experiment with 5 tmote sky sensor

nodes exposed to sunlight and varying temperature. However,

the sink temperature was constant throughout the experiment.

In this way, we obtained drift measurements for various

temperature differences between the sensor nodes and the sink.

We refer to this experiment as outdoor.

A. Description

Each node sent a beacon incl. the current temperature every

60 seconds. We connected one node - the sink - to a logging

computer. Upon receiving a beacon the sink recorded the

Page 5

5

80

85

90

95

100

05 10 1520

received messages [%]

drift window [ticks]

node A

node B

node C

node D

node E

80

85

90

95

100

051015

drift window [ticks]

2025 3035 40

received messages [%]

node A

node B

node C

node D

node E

Fig. 4.Amount of received frames in various drift windows, i.e. with guard times of various length; indoors (left) and outdoors (right)

reception time using its local hardware clock to obtain precise

results. The sink forwarded the reception time together with

the address of the beacon sender and the node temperature to

the logging computer.

The sink was constantly powered on and we deployed all

nodes in a close vicinity of the sink (i.e. one-hop network).

In this way the sink received beacons of all nodes. Since the

sink forwarded all reception times to the computer, we did

not have problems with limited storage capacity and recorded

measurements for two weeks with a high frequency. The sink

recorded drift samples with a frequency once a minute for

each node, resulting in total of approx. 200,000 drift samples

for both experiments. We use these drift samples to evaluate

various drift compensation approaches in the next section.

B. Results

Tmote sky uses a crystal oscillator of 32.768 kHz frequency

with drift of +/- 20 ppm. Thus, theoretically nodes need a

guard time of approx. 80 ticks (2.4 ms) to compensate worst

drift of a 1-minute period. However, we discovered that some

frames (less than 1%) were received with drift few times worse

(more than 300 ticks) than the theoretical worst case. It shows

that not only the inaccuracy of crystal oscillator affects relative

drift, but also other factors (e.g. jitter in times needed to power

up radio, software execution time, etc.).

Our indoor experiment confirmed that the drift distribution

appears Gaussian, see Figure 2. However, it does not hold

true for outdoor environments, see Figure 3. The reason for

that is the influence of the changing temperature on clock

drift. In the indoor experiment the nodes temperature was

constant, about 25 °C. However, in the outdoor experiment

the temperature changed from about 20 °C (during nights)

to more than 50 °C (during daytime). As the sink was not

exposed to sunlight, its temperature was constant, about 25 °C.

Due to temperature variation, drift among the nodes and the

sink changed. Therefore, the drift distribution outdoors is

not symmetric and wider than the distribution of the indoor

environment, compare Figures 2 and 3.

As already stated, the sink received all frames within a

very large window, i.e. even 300 ticks/minute. However, the

analysis of the drift distribution revealed that most messages

were received within a very small drift window, i.e. less than

10 ticks in the indoor experiment (30x smaller than the worst

case), see Figure 4. We discovered that this holds true also

for outdoor environments with changing temperature. In that

case sink received 99% messages within a drift window of 40

ticks outdoors, i.e. 8x smaller that the worst case, see Figure

4. However, to receive the remaining frames (less than 1%)

nodes needed much longer guard times, i.e. more than 300

ticks.

VII. EVALUATION

We based the evaluation on the relative drift samples col-

lected during our indoor and outdoor experiments. In this way,

we considered all factors that influence drift (e.g. latencies

in transceiver power up/down, software execution, oscillator

drift).

A. MADC vs. OLS

To examine how accurate both approaches - MADC and

OLS - predict future drift, we estimated the standard deviation

σ of drift prediction, i.e. the difference from real drift to the

predicted one.

In the indoor environment we observed very small differ-

ences between MADC and OLS, see Figure 5. On nodes A,

C and D both approaches achieved very similar results. OLS

predicted drift more accurate on node E, whereas MADC was

better on node C. However, these differences are negligible,

i.e. σ difference was smaller than a clock tick.

In general, for small sample windows MADC and OLS

achieved similar results in the outdoor environment, see Figure

6. However, on 3 out of 5 nodes we noticed that accuracy

of OLS prediction got worse with the increasing number of

considered drift samples. For example, σ on node E with

7 previous samples was 2 ticks. Changing the number of

previous samples to 20 resulted in almost 5 ticks σ! We explain

it as follows. As clock drift is assumed to be stable over a

short time [10], [7], nodes can predict it very precisely using

linear regression. In other words, linear regression achieves

precise results, if drift was stable in the past. However, as

on some nodes (A, D, E) in the outdoor scenario drift was

not stable over long periods (10 minutes and more), OLS

did not predict drift precisely in these cases. On the contrary,

the moving average filter does not suffer from this problem.

Therefore, MADC achieved high prediction accuracy on all

examined nodes indoors and outdoors. Moreover, on some

nodes outdoors the prediction of MADC was more accurate

that the OLS. For example, on node D σ of MADC was

approx. a tick (more that 17 samples considered), whereas

σ of OLS was 3 ticks and more, see Figure 6.