# Firefly Clock Synchronization in an 802.15.4 Wireless Network

- Robert Leidenfrost
^{1}Email author and - Wilfried Elmenreich
^{2}

**2009**:186406

https://doi.org/10.1155/2009/186406

© R. Leidenfrost and W. Elmenreich. 2009

**Received: **2 September 2008

**Accepted: **30 March 2009

**Published: **1 July 2009

## Abstract

This paper describes the design and implementation of a distributed self-stabilizing clock synchronization algorithm based on the biological example of Asian Fireflies. Huge swarms of these fireflies use the principle of pulse coupled oscillators in order to synchronously emit light flashes to attract mating partners. When applying this algorithm to real sensor networks, typically, nodes cannot receive messages while transmitting, which prevents the networked nodes from reaching synchronization. In order to counteract this deafness problem, we adopt a variant of the Reachback Firefly Algorithm to distribute the timing of light flashes in a given time window without affecting the quality of the synchronization. A case study implemented on 802.15.4 Zigbee nodes presents the application of this approach for a time-triggered communication scheduling and coordinated duty cycling in order to enhance the battery lifetime of the nodes.

## Keywords

## 1. Introduction

In South-East Asia, huge swarms of fireflies synchronously emit light flashes to attract mating partners [1]. This paper describes the adaption of the underlying biological principle for a robust self-stabilizing distributed synchronization in wireless sensor networks.

An ensemble of nodes is synchronized in order to execute a collision-free communication schedule following a time-triggered paradigm [2]. The basic element of a time-triggered system is a global timebase that is distributed among the nodes through clock synchronization. In order to provide a common timebase we propose the application of Reachback Firefly Algorithm (RFA), which is a Firefly-inspired algorithm that works despite the limitations of current radio controllers, which are deaf to incoming transmissions while in sending mode. This deafness problem is mitigated by distributing the timing of light flashes in a given time window. Using the global timebase, communication activities are scheduled according to a predefined, periodic scheme. This simple but robust scheme enables the design of dependable distributed systems and simplifies system verification and diagnosis. Furthermore, the global synchronicity is used to enable synchronized sleep schedules in a wireless network cluster which can save a considerable amount of energy at each node. This is especially useful in situations with low duty-cycles, for example, a sensor network that is utilizing only a fraction of its available bandwidth. Due to the a priori known message schedule, the synchronized nodes are then able to predict the timing of incoming messages and can turn off their receivers when no transmissions of interest are scheduled. Since listening on the channel is a significant energy consumer of a typical wireless sensor node, the overall consumer power can thus be reduced in favor of battery lifetime. The global time can also support the application in tasks like timestamping, synchronous measurements, and timely coordinated distributed actions.

As a proof of concept, the algorithm has been evaluated by simulation and in a case study consisting of a network of battery-powered low-cost nodes based on an off-the-shelf IEEE 802.15.4 MAC layer. The evaluation results in this paper give realistic figures for the precision of the clock synchronization and the achievable savings in power consumption.

The rest of the paper is structured as follows. Section 2 describes the basic features and operation of the RFA. Section 3 presents the design of our approach consisting of clock synchronization, a modified RFA and an energy saving scheme. Sections 4 and 5 describe the evaluation of a case study implementation by simulation and on real hardware. Results are discussed in Section 6. Related work is treated in Section 7. The paper is concluded in Section 8.

## 2. Reachback Firefly Algorithm

The RFA was introduced in [3] and supports scalability, graceful degradation, and a simple calculation. The algorithm can be classified as a self-stabilizing distributed push-based clock synchronization algorithm. The advantage is that it naturally provides self-stabilization, that is, in any initial configuration, the clocks eventually become synchronized. The concept is based on the Pulse-Coupled Biological Oscillators (PCO) phase advance synchronization model [4], but with the difference that it is more appropriate for the practical implementation in wireless networks. For instance, the following assumptions from the original PCO model make a practical application very difficult. The oscillators have identical dynamics. Nodes can instantaneously fire. Every firing event must be observed immediately. All computations are performed perfectly and instantaneously.

However, in the case all clocks are synchronized, they will indicate the clock event at the same time. Using a broadcast communication medium, this causes message collisions, and a "deafness" problem in many wireless systems, since standard wireless transmitters cannot receive messages while being in transmission mode.

The problem can be bypassed by sending the synchronization messages with a random offset, while transmitting the particular offset with the message. The receiver can then reconstruct the intended synchronization instant and perform a clock adjustment with respect to the received offset values. Obviously, this random offset results in an out-of-order reception of synchronization messages which causes a problem in the case of the simple synchronization approach. A solution to this problem is to gather all synchronization events until reaching the period end and then react to the received time information from the last period. This idea was introduced in [3] and is called *reachback response*. However, a reachback response variant of the mentioned simple synchronization approach then equals the below described RFA algorithm with
and is proven in Lemma 3.7 to be unfeasible for clock synchronization.

*phase variable*. This variable is characterized by (i) , where denotes the cycle period and (ii) at the beginning of a cycle. Let denote the

*state variable*corresponding to the charge of a firefly. The authors of the PCO model have proven that the

*state function*must be a smooth, monotonically increasing, and concave down function in order to achieve synchronicity. In [4], Mirollo and Strogatz have stated a general state function as shown in (1) whereas the form of the curve depends on a parameter named

*dissipation factor*, denoted by , and measures the extent to which is concave down. Figure 1 visualizes the state function for different dissipation factors,

*firing function*and depends on the state function and the

*pulse strength*, where denotes the inverse state function

*phase advance*to define the increase in the phase domain, denoted by . Due to the concave down state function, a constant addition in the state-domain results in a variable increase in the phase-domain where a phase advance in the beginning of a cycle is smaller than later in the cycle.

To combat the assumption problems of the PCO model in wireless networks, the RFA additionally uses the notion of a *reachback response* and *pre-emptive message staggering*. *Pre-emptive message staggering* means that a node broadcasts its synchronization message with some random time offset before it reaches the period end and thus is able to gather the time information of all other nodes during a period with a lower probability of message collisions.

*reachback response*records the timestamps of all received firing events and calculates an overall phase jump once at the end of each period which is then applied at the beginning of the next cycle. Thus, if a node reaches the period end, it "reaches back in time" and reacts to the firing events of the past period. This principle is visualized in Figure 2.

A further problem in the PCO model occurs in the case of an already synchronized network comprising several nodes. If so, all nodes will trigger the transmission event for the synchronization message at the same time. As a result, the messages will collide and the collision avoidance mechanism of the CSMA/CA scheme takes effect. The resulting delay jitter then can be avoided by using MAC timestamping. However, the backoff scheme of the IEEE 802.15.4 standard [5] allows to backoff a message at most
times which results in a maximum backoff time of at most 36.48 milliseconds (at 2.4 GHz). Since the serialization delay of a full message is at most 4.256 milliseconds (133 bytes at 250 kbps), there can be at most
active wireless nodes without losing messages in the best case. Therefore, a bigger network comprising more than
nodes in the same broadcast domain requires an additional message staggering delay at an upper layer. A second reason for the additional message staggering is that the original IEEE 802.15.4 standard does not provide an MAC timestamping mechanism and thus does not allow to reduce the delay jitter due to the backoff scheme. The only way to reduce the delay jitter then was to modify the default values of some MAC specific attributes in order to switch off the backoff mechanism. To avoid the resulting higher probability of transmission failures, the *pre-emptive message staggering* explicitly adds a timestamped random transmission delay to the firing messages at the application layer.

## 3. Applying RFA to Wireless Sensor Networks

*receiving slot*, a

*sending slot*, an

*execution slot*, or an

*idle slot*. Concerning the energy awareness, the most important slots are the receiving slots since they determine how much energy is spent on listening and receiving. In the diagram, the first and the second slot are assigned to be receiving slots. Note that the active time for the receiver unit differs between these slots. This comes from the automatic deactivation after the receiver has recognized the end of a transmission. The parameter denotes the

*synchronization window*and guarantees that the receiver module is enabled some time prior before any transmission takes place.

The time-triggered approach requires the notion of a *global time* which is provided by the RFA clock synchronization algorithm. Note that the algorithm can only approximate the global time. The best achievable precision
in an ensemble of clocks is lower bounded to the *convergence function*
of the synchronization algorithm and the maximum *drift offset*
, where
denotes the maximum drift rate of all clocks in that ensemble. This is also known as the *synchronization condition*
. In our approach, the convergence function is defined by the RFA and heavily depends on the maximum delay jitter
which is the maximum absolute deviation of the delay a message encounters during the communication.

In order to get promising results, the global time must be approximated with a very high precision. One way is to minimize the drift offset. This can either be done by using high quality crystal oscillators or a more frequent resynchronization. Both approaches have their drawbacks, because in mass production, crystal oscillators would be expensive compared to the cheap internal RC-oscillators in low-cost nodes. Secondly, a shorter period time results in the exchange of more synchronization messages in the same time and thus would affect the energy consumption. Alternatively, the reduction of the maximum drift rate
can also be achieved by a *rate correction algorithm*. In our approach, this algorithm is performed in the digital domain and makes use of the concept of virtual clocks. A *virtual clock* abstracts the physical clock by the use of macroticks. A macrotick comprises several microticks which are generated by a physical clock. The principle of this concept is to change the number of microticks representing a macrotick in order to adjust the granularity and frequency of the virtual clock. In the current implementation a macrotick corresponds to a complete cycle length. Thus, the duration of the periods can easily be changed by adjusting the threshold value of the physical timer/counter.

### 3.1. Clock State Correction

As a result, we have a linear Phase Response Curve (PRC), where the *coupling factor*
specifies the strength of coupling between the oscillators and depends on the product of the dissipation factor
and the pulse strength
. This result is similar to the simplified firing function described in [3].

In contrast to the original RFA algorithm, our approach achieves a better synchronization precision and a faster convergence time by indirectly performing a clustering of the received synchronization events. This is done by ignoring all events which are within the phase advance of the last event to which a node reacted. In fact, this corresponds to the introduction of a short refractory period. Additionally, we do not allow a node to react to firing events which would originally occur after the node reached the period end. This ensures that in the case of synchronized nodes, the fastest node then does not advance its phase anymore resulting in a better precision. The algorithm is formally analyzed in more detail and guarantees network synchronization as long as the bounds for several parameters are maintained. Algorithm 1 explains the behavior of this extended RFA (E-RFA) algorithm with the use of pseudocode. The refractory period is implemented by the condition in Line 9. The variable *eventset* contains the correct phase of all received firing messages and
denotes the random amount for the preponed transmission with at most the maximum, respectively, minimum message staggering delay
, respectively,
.

Since the purpose of this work should demonstrate that such a synchronization approach works with an off-the-shelf communication stack without MAC-timestamping, we have to expect a delay jitter in the order of milliseconds due to the uncertainty in the application and MAC layer. It should be mentioned that Lundelius and Lynch have shown in [6] that in the presence of a *maximum delay jitter*
, an assemble of
clocks cannot be synchronized to a precision better than
.

Lower Bound for the Coupling Factor

We assume that every processor
consists of a hardware clock
which generates the phase
. This clock stays within a *linear envelope* of the real time. Note that whereas the hardware clock continuously increases, the phase is periodically reset to
with respect to
where
denotes a dynamic offset value which changes due to the state correction algorithm.
represents the granularity of the hardware clock which corresponds to the synchronization period
. We therefore assume that there exists a positive constant
(*maximum drift rate*) such that
. Note that this definition of the bounded drift simplifies the calculation of the precision and may differ from literature. We further assume a fully connected network in which the message delay
is always in the range
, where
denotes the constant part and
the *maximum delay jitter* of the communication delay in real time. The lower bound for
in an ensemble of nodes in a fully connected network then depends on the maximum drift rate
, the message staggering delay
, and the communication delay
. Note that all parameters with a preceding
are defined with respect to
. However, for simplifaction we now always assume that
is normalized to
. Let
, respectively,
denote the maximum, respectively, minimum relative message staggering delay
and
. We now show that in the case of two clocks, the modified RFA provides a bounded precision
. Therefore,
for
denotes the maximum time difference among all nodes
in real time units between the time
reached
and the time
reached
.

Lemma 3.1.

Proof.

Assume the clocks are initially synchronized to . W.l.o.g. let be the faster node. We further use as the reference for the precision , where denotes the real time when 's phase reached . We further assume that the next time reaches the threshold is at time . Let be the corresponding precision at . For we then have and . Let respectively, denote the relative message staggering delay the node , respectively, has calculated for the last transmission. If the last fire event of was at , then with respect to the communication delay received the phase at and consequently adds the offset leading to . Similarly, a fire event from with offset is received by at phase . Let be the minimum, respectively, maximum possible phases of the calculated firing events. If , then it is guaranteed that , respectively, . Since , we have as stated.

Based on the current precision and the phase advance of and at time labeled by and , we are able to calculate the precision the next time reaches the threshold. That is, . However, we have to distinguish between three cases depending on . In detail, if , then and , or if , then also and , or finally if , then due to Line 4 of Algorithm 1 we have and . Note that the overlapping of and is volitional, because if , then both cases can occur and hence must be considered. Further note that the bound of ensures that the interception point of the phase of both nodes is within the last period. In order to keep the clocks within the precision, the inequality must be valid for all three cases. From the first case we get and . From the third case it follows and . Note that is always valid due to the definition of . From the second case, it can be derived that and . Again, ensures that is valid. The worst case precision with respect to these three cases then equals .

Note that the correctness of the proof requires that a node advances its phase at most once per period. However, if , then may initiate a firing event after already passed the threshold. Simply setting avoids this effect.

In order to get the worst case precision, we further have to incorporate the precision (I) and (II) for all three mentioned cases. In detail, for we additionally have to analyze for case if the equation holds and for case , if and are valid. Similarly for it must be ensured that . From these equations we can derive the following additional bounds: , and . Therefore, if we want bounded between , then must hold. Furthermore, in the case of , we have to adapt the worst case precision to which now equals the worst case upper bound, since all possible cases were considered.

Finally, it should be mentioned that the maximum relative message staggering delay must be smaller than . Otherwise, assume the case where both nodes are initially apart. Then both nodes will never perform a phase advance due to Line 4 of the algorithm.

Note that in the case of a fully connected network comprising more than two nodes, all nodes synchronize to the fastest one due to Line 4 and Line 9 of Algorithm 1. Especially the condition in Line 9 ensures if a node advances its phase due to some received firing event , then all events immediately following some short time after are ignored. This condition is necessary. Otherwise, assume nodes are perfectly synchronized. Consequently, a node would perform times a phase advance, which results in a mutual excitation in the case is very large.

Theorem 3.2.

Corollary 3.3.

If a fully connected network comprises only of perfect clocks ( ) and the communication network suffers from no delay jitter ( ), then the network keeps synchronized with a precision of , if .

Note that Corollary 3.3 states that it is sufficient that the network is connected.

Corollary 3.4.

If a fully connected network comprises only of perfect clocks ( ) and the communication network suffers only from delay jitter ( , ), then the network keeps synchronized with a precision of , if .

Corollary 3.5.

If a fully connected network comprises of clocks with a maximum drift rate of and the network suffers from no communication delay ( ) and , then the network keeps synchronized with a precision of , if .

Upper Bound for the Coupling Factor

One may ask why not setting such that a node immediately adjusts its phase to a neighboring clock every time receiving a firing message from this clock. However, the following lemmata shows that there exists a basic upper bound which holds for every network.

Definition 3.6.

A firing configuration
of a fully connected network
comprising
nodes is defined to be the concatenation of the phase
of node
at the time
when
just reached the threshold for the
th time and consequently applied the phase advance
*.*

Lemma 3.7.

In a fully connected network comprising of perfect clocks, if the coupling factor , then the nodes may never become synchronized.

Proof.

The proof is based on the fact that if is too large, then the nodes will infinitely often enter the same firing configuration. Let and be the two participating processors where is the first node reaching the threshold. The initial firing configuration then is with . Next, reaches the threshold leading to with and . The next time reaches the threshold is at with and . Finally again reaches the threshold at with and .

If we assume that , then the phase advance can be reduced to . The same applies to and . Thus, if all three conditions are true, can be redefined to . In other words, the nodes will infinitely often enter the initial firing configuration. We now have to find the lowest where the inequation is valid. Equalizing all three conditions yields and . Thus we get .

Since the algorithm ignores all firing events immediately following some short time after a previous firing event due to Line 9, a node may realize a set of nodes as a single node and therefore Lemma 3.7 also applies to networks comprising more than two nodes. We now exploit the intuition behind Lemma 3.7 and extend this problem to a general network comprising nodes.

Definition 3.8.

is called to be an infeasible firing configuration, if there exists a positive integer such that and the network is not synchronized.

Lemma 3.9.

The maximum phase advance a node can perform in a fully connected network comprising nodes equals .

Proof.

The maximum phase advance occurs if the firing events are at close quarters such that no event is ignored due to Line 9 of Algorithm 1. In detail, assume a node received the firing event at the phases . The first phase advance then equals , where . Due to Line 9 of Algorithm 1, the earliest next time the node performs a phase advance can only be at and equals . Generally, and for . Solving the recursion leads to and thus . Solving the equation for then yields . The overall phase advance thus equals . Since the maximum occurs when , we finally get .

A weak upper bound results from the fact that we do not want a node to perform a phase advance which is greater than and directly follows from Lemma 3.9.

Corollary 3.10.

In a fully connected network comprising of perfect clocks, if the coupling factor , then in every feasible execution a node will never perform a phase advance which is greater than .

Note that even if the weak bound is maintained, it can be shown that there exist infeasible firing configurations. However, due to imprecisions in calculations, the varying short-term drift, the delay jitter, and due to several other indeterministic environmental effects, this bound is generally applicable. A stronger bound results from empirical studies which have shown that infeasible firing configurations do not exist, if the maximum phase advance . The resulting bound for again can be deduced from Lemma 3.9.

Theorem 3.11.

In a fully connected network comprising of perfect clocks, if the coupling factor , then the nodes will never enter an infeasible firing configuration.

Rate of Synchronization

Theorem 3.15 analyzes the time to sync for the case of two oscillators. The authors of [4] have also analyzed the case of oscillators. However, considering a multihop topology requires a more sophisticated solution. For the following proofs, let and denote the initial phase difference between the clocks and with in network .

Lemma 3.12.

The infeasible firing configuration with and is a unique fixpoint and has a phase difference of .

Proof.

If we set , we get and and thus and .

Lemma 3.13.

where , , , , , , and from Lemma 3.12.

Proof.

Let be the initial firing configuration with where and . The phase difference when reached the threshold for the th time is . From Lemma 3.7 we know that with and . If we substitute for and consider the phase difference of , we get and which yields for . The dissolving of the recursion is left to the reader and leads to the solution as stated.

Lemma 3.14.

There exists a unique initial phase difference where the network eventually enters the fixpoint of Lemma 3.12 and equals with from Lemma 3.13.

Proof.

If the network enters the fixpoint in at some , then we have a phase difference of for with from Lemma 3.12. Using (8) then yields . Since we get and thus . Using and from Lemma 3.13 results in . The initial phase difference then has to be as stated.

Theorem 3.15.

Proof.

Note that either converges to or ) as visualized in Figure 4. Therefore, we simply equate (8) with if or with if . Since for and the multiplicative factor is smaller than , the term with respect to does not influence the rate of sync for larger and hence can be neglected. This leads to the equation as stated.

### 3.2. Clock Rate Calibration

The concept of clock rate calibration combats the problem of frequency deviations due to the high clock drift of the RC-oscillators usually used in low-cost devices. This approach should allow a longer resynchronization interval with the same synchronization precision. Note that the rate correction can be performed completely independent from the clock state correction scheme.

The core concept of our rate calibration algorithm is that a processor
implements a virtual clock
which abstracts the hardware clock
. The algorithm implemented on
then only reads the time from the
. We further denote the ticks from the
by *microticks* and that from the
by *ticks*. One tick of
comprises several microticks which we denote by
. By adjusting
, the time duration of one tick can be increased or decreased. Let
be the nominal threshold level and
the *absolute adjustment value* s.t.
. Note that the corresponding *relative adjustment value* for
equals
. In order to perform the rate calibration, every processor
periodically broadcasts a synchronization messages
. Let
, respectively,
denote the timestamps of
when
transmitted
and
, respectively,
the timestamps of
when
received
from
. Let
be the
th message
received from
and
the
th message
broadcasted. We further assume that
is not received at some
before
is received for
. The dependency between the virtual and the hardware clock with respect to some message
is characterized as
. Note that we assume that the hardware clock is a linear function of real time within a sufficient long period of time. In contrast, the virtual clock is periodically reset with respect to the resynchronization interval. This assumption is required in order to realize a pulse synchronization scheme.

*common-mode drift*. A better approach is to implement a parametrized adjustment by the use of a smoothing factor as shown in (12) which ensures that the virtual clocks smoothly converge to the overall average interval,

In our implementation we have chosen . However, it seems that the common-mode drift cannot be avoided but the effect can be minimized by carefully choosing with respect to the delay jitter. For this reason we have introduced bounds for the relative adjustment value, that is, . Furthermore, if the bound is exceeded, respectively, under-run, we decrease, respectively, increase by some small value before calculating .

### 3.3. Energy Awareness

The energy consumption is an important quality characteristic of each communication protocol used in sensor networks. Often more than 50 percent of energy is used for idle listening [7]. Therefore, it is necessary to reduce the major energy sources. Some Media Access Control (MAC) protocols have already incorporated such a concept (e.g., S-MAC, T-MAC, etc.). However, we assume that the underlying MAC layer is only responsible for the medium access control and not for energy improvements. For this reason, we assign the tasks for energy reduction to the upper layers.

A usual approach in reducing the consumed power is to periodically turn off the transceiver module if it is not required. A protocol using such a scheme is called a *duty-cycle protocol*. The *duty-cycle* is determined to be the ratio between the duration used for listening on synchronization messages to the medium and the duration of the complete period. As already mentioned, the bounded synchronization precision necessitates that the receiver module must be enabled some time prior, before any transmission takes place. This safety margin equals the synchronization window
and should be greater than the upper bound of the synchronization precision. A node considers itself to be synchronized, if the maximum absolute deviation to all neighboring nodes is smaller than the specified synchronization window. With respect to the relative message staggering delays
, respectively,
and the period length
, the duty-cycle equals
. Note that after a number of periods, each node has to listen to the medium for a full period in order to avoid clique building.

## 4. Evaluation by Simulation

We evaluated our approach with a probabilistic wireless sensor network simulator called JProwler (available at http://www.isis.vanderbilt.edu/Projects/nest/jprowler). JProwler has been developed by the Institute of Software Integrated Systems at the University of Vanderbilt and is basically configured to simulate the behavior of the Berkeley Mica Motes running TinyOS with the B-MAC protocol. It is a Java version of the Prowler [8] network simulator which is used for verifying and analyzing communication protocols of adhoc wireless sensor networks. Note that B-MAC is very similar to the IEEE 802.15.4 standard, because both implement the same CSMA/CA mechanism. Therefore, by modifying the MAC layer specific constants, the simulator can be used for the ZigBee nodes.

For instance, the transmission time is based on the amount of transmitted data. In our case, the synchronization frame contains the frame identifier (8 bit), the synchronization state (8 bit), the nominal phase offset (16 bit), the phase adjustment value (16 bit), the sender timestamp (32 bit), the tick-number (16 bit), and a checksum (8 bit). In sum, the application needs 13 byte for one synchronization message. The real amount of transmitted data is greater due to the payload of the MAC and the physical layer. According to the 802.15.4 MAC standard [5], the complete payload is about 15 byte (9 byte from the MAC layer and 6 byte from the physical layer). Assuming that the system works in the 2.4 GHz ISM band, the bit rate is 250 kbps. As a result the serialization delay
equals
and therefore is assumed to be about one millisecond. Note that the propagation delay is negligible. Let
be the worst case constant software dependent time of the sender and receiver (including interrupt and buffer handling) used for the transmission, then the worst case constant transmission time is about 2 milliseconds. These parameters are reflected in JProwler's specific MAC constants by the *minimum waiting time* and the *transmission time* of a sync-message. Both parameters were modified to 1 milliseconds. To be more realistic, we have set the *random waiting time* to 2 milliseconds which corresponds to the delay jitter we have observed in several experiments. Note that we do not guarantee the correctness of these values. Similarly to the implementation in the real hardware, the backoff scheme was deactivated in order to reduce the additional resulting delay jitter. The graphical user interface was enhanced by several new dialogs which enables the user to modify various parameters during the simulation. We further extended the simulator by an oscillator model. Thus, every virtual node is based on an oscillator, for example, RC-oscillator or several crystal cuts. This allows the simulation of clock drift and its influence on the clock synchronization. Due to the fact that the frequency of an oscillator heavily depends on the supply voltage and the ambient temperature, the enhanced JProwler also contains the simulation of the ambient temperature. Other new features consider the adjustment of the simulation speed and enabling/disabling nodes during the simulation.

### 4.1. Experiments and Results

The simulation results discussed in this chapter should give an overview of the achievable quality of our synchronization approach. For this reason, several network topologies have been developed and simulated. The results are compared with respect to different parameter choices, that is, the coupling factor and the number of nodes in the network.

In order to compare the simulation results with the outcomes from [3], the evaluation metrics are similar. Therefore, the two important parameters are the amount of time until the system achieves synchronicity and the quality of precision. The *time to sync* defines the time until all nodes have entered the synchronization state and is determined by two parameters. These are the synchronization window
and the number of required periods a node has to keep within this window. In the following we call the amount of required periods *synchronization periods* and is set to
. A node only enters the sync-state, if the maximum absolute deviation with respect to the other nodes is within the synchronization window for
out of the last
firing iterations. The definition of the *50th and 90th Percentile Group Spread* differs from that one defined in [3], because we only refer to one firing group. Therefore, the group spread in the simulation is defined to be the maximum absolute time difference between any two nodes in the network and thus cannot be greater than half the synchronization interval. We characterize the group spread distribution with the 50th and 90th percentile.

Incorrect results due to settling effects during the startup phase are avoided by postponing the start of the group spread measurement against the time to sync ( ) and the time the experiment ends ( ). On this account, the group spread measurement is performed only during the interval .

#### 4.1.1. Parameter Settings

The general parameter choice used in all simulator experiments.

Parameter | Value |
---|---|

Oscillator technology | RC-oscillator |

Evaluation end [periods] |

#### 4.1.2. Simulation Results

The next paragraphs discuss the simulation results in dependence of several network topologies and parameter choices. Every configuration was simulated over periods.

The All-to-All Topology

The all-to-all communication topology is mainly used to measure the quality of the synchronization in dependence of the number of nodes and the coupling factor . Therein, every node is in the transmission range of each other.

If we assume that the rate calibration scheme reduces the worst case drift to , then based on the parameters from Table 2 and Theorem 3.2, the worst case precision for equals . Note that without the rate calibration scheme, we would have . The group spread diagram complies with our theoretical result that the precision does not depend on if maintains the lower bound. Note that the simulations are based on a realistic radio model considering message collisions and transmission strength as well as the backoff scheme of the MAC layer. Therefore, the results show that if all network parameters (e.g., transmission delay, maximum drift rate, etc.) are correctly defined, then the worst case precision is maintained most of the time. However, there may exist outliers in the case of an omission failure of the fastest node, because this algorithm does not allow a node to adjust its clock backward.

The Multihop Topology

*network diameter*. Such a network with a big network diameter is often very problematic to synchronize, because every hop involves a communication delay which degrades the overall synchronization precision. Therefore, an estimation for the achievable precision with respect to Theorem 3.2 in a network with the network diameter is about . Our solution is based on

*grouped multihop*networks. Therein, the nodes are replaced with groups comprising several nodes in all-to-all topology which all have a bidirectional communication link to all nodes in the immediate neighboring groups. Figure 6 is a snapshot of a running simulation regarding the grouped multihop topology with JProwler. Therein, a dot represents a node and an arrow visualizes that a node is currently transmitting data. The gray scale visualizes the deviation. Note that all grouped multihop topologies treated in our experiments have the same network diameter of 10 hops but vary in the group size.

## 5. Evaluation on Real Hardware

The simulation results provide a good basis for several parameter estimations in order to optimize the synchronization precision for different network topologies. However, the simulator does not support information about power consumption and further never fully reflects the real world scenario. For this reason, we implemented and evaluated our distributed algorithm in combination with the time-triggered approach on real hardware.

### 5.1. Testbed Description

The testbed is based on Atmel's demonstration kit ATAVRRZ200 [9]. The kit features two component boards: The Display Board and the Remote Controller Board (RCB)s. The Display Board is based on an Atmega128 controller and features an LCD-module. This board also works as a docking station for programming the RCBs. The RCBs therefore are based on an Atmega1281 controller and contain an AT86RF230 (2450 MHz band) radio transceiver. The implementation of our approach is done with the AVR Z- 802.15.4/ZigBee nodes. The information about the synchronization precision is gathered via the established TDMA scheme. Therefore, beside energy savings, the time-triggered approach also serves as an evaluation protocol. For this, we used a modified version of the TTP/A protocol [10].

The synchronization algorithm was implemented analogously to the implementation in JProwler. A simple RC-oscillator-based 16-bit timer was used to generate the synchronization interval with a duration of one second. The only differences with respect to the parameter choices in Table 2 are a higher granularity of the virtual clock (31250 ticks/period) and a higher transmission delay of 896 microseconds.

We modified the initial settings of the MAC sublayer, that is, the minimum backoff exponent, to reduce the transmission delay. We further assumed that it is better to omit a message than to transmit postponed synchronization data since the underlying MAC layer does not support MAC timestamping. However, several measurements have shown that regardless of this configuration, some messages are still transmitted with a high delay. Therefore the tradeoff between the probability of an omission failure and a high delay jitter with respect to the precision degradation has to be chosen. In detail, whereas high delay jitter only degrades the deterministic worst case precision, omission failures may mostly provide a better precision, though it is more indeterministic and therefore results in a worse worst case precision. Note that omission failures are especially a problem in the case they occur at the fastest node and may degrade the worst case precision by at about , where denotes the maximum number of consecutive omission failures at the same node. In our implementation, every node is configured as a Full-Function Device (FFD) and no association process is required. This necessitates the use of individual predefined 16-bit short addresses for each node.

### 5.2. Experiments and Results

The evaluation metrics for the testbed experiments are similar to the one used for the simulation experiments. In order to observe the relative deviations over all nodes in a network, we decided that every node transmits its own maximum absolute deviation of the last period to a central evaluation node, which then calculates the maximum over all received deviations. These values over several minutes are then taken to compute the 50th and the 90th percentile group spread.

To be able to compare the testbed results with the simulator results, the parameter configuration has to be the same as used in the simulator experiments. Since in reality it is not possible to speedup the time, we reduced the experiment time to 720 periods.

#### 5.2.1. Testbed Results

The All-to-All Topology

For the all-to-all topology experiment, we again measured the group spread in dependence of several coupling factors.

Comparison of several parameters in dependence of different coupling factors. The values between the brackets correspond to the simulation results with the same all-to-all network configuration comprising 5 nodes.

Parameter choice | Time to sync | 50th percentile | 90th percentile | Maximum deviation | Standard deviation |
---|---|---|---|---|---|

(periods) | |||||

105 (152) | 672 (1000) | 2005 (1300) | 3456 (2200) | 538 (257) | |

79 (57) | 704 (900) | 1632 (1300) | 2592 (2000) | 410 (250) | |

24 (35) | 704 (900) | 1973 (1300) | 3040 (1900) | 501 (262) | |

33 (20) | 672 (1000) | 1723 (1400) | 3104 (2000) | 451 (267) | |

14 (20) | 732 (900) | 1965 (1300) | 3776 (1800) | 565 (250) |

The Multihop Topology

The results from the multihop experiments are important in order to get an overview about the limits of our synchronization approach. The first scenario was made up of 5 nodes ordered in a chain, where a node can only communicate with the immediate neighbors. The only difference between the simulation and the testbed environment is that the testbed environment does not have an omniscient observer, which is able to continuously measure the synchronization deviation among all nodes. For this reason, we decided to measure the time difference between the edge nodes with the aid of an oscilloscope, whereas each node periodically sets an output pin at the same phase state for a short time. Unfortunately, these measurements cannot be gathered automatically over several periods. Therefore, we manually made snapshots over several minutes and took those diagrams, which display the biggest time deviation. To simulate the multihop network, we have simply implemented a message filter.

The results show that the precision of a realistic multihop network with 4 hops is about 3 milliseconds and even maintains the calculated worst case precision of a fully connected network multiplied by . Interestingly, the simulation of the same network with a configured delay jitter of 1250 microseconds leads to the same result. To get an overview of the precision degradation with respect to the network diameter, another multihop experiment with 9 nodes was performed. The measurement setup is similar to the previous multihop network. The measurement results show a maximum deviation between the edge nodes of up to 14 milliseconds and is better than we have observed during the simulation where synchronicity was sometimes not achieved at all. Note that the measured worst case precision is again maintained by the calculated worst case precsion for a fully connected network multiplied by . However, such a high deviation was measured very seldom. In summary, the worst case precision of our synchronization algorithm degrades by at most the worst case precision for the corresponding fully connected network with each hop. Note that with respect to [3], the results can be compared with the simulation results regarding a regular grid topology containing nodes. Therein, they have measured a 90th percentile group spread of about 10 milliseconds. Compared to their results, our worst case deviation of 14 milliseconds is not so digressive.

#### 5.2.2. Energy Measurements

The energy consumption plays an important role for the device lifetime in battery-powered wireless networks, especially if no infrastructure is available. All RCBs are battery-powered with two 1.5 V AAA-batteries and thus have a voltage supply of 3 Volt. In order to get the device lifetime, the average power consumption is compared with the electrical energy of the batteries, which we assume to be about . The lifetime in hours is the ratio and can be reduced to the equivalent formula , where corresponds to the battery charge, denoted in mAh. If so, then the formula determines the device lifetime in hours and defines the average current consumption.

For further energy calculations, the current consumption during a complete period can be classified into four parts and were measured by the use of an oscilloscope and a current shunt resistor. These are the firing time, idle time, execution time, and transmission time.

The *firing time* results from the message staggering delay and corresponds to the interval where the transceiver is enabled and the nodes are allowed to transmit their synchronization messages. In our test application, this interval is also called part 1 of the firing time and equals the duration of 50 milliseconds. The consumed current during this time is about 20 mA. Note that there exists an interval between the end of the firing time and the period end which acts as a safety margin in the case a node starts a transmission exactly at the end of the firing time. If so, the transceiver must be enabled as long as the transmission continuous. This safety margin is further named part 2 of the firing time and consumes a current of 24 mA.

The *idle time* is the part, where the current drops to a minimum. The reason for the small current lies in the fact that the device is dormant, that is, the transceiver is disabled. With our ZigBee nodes, we measured a current of about 6.2 mA.

The *execution time* is the time where the RCB device executes some code. This is always the case at the end of each period, where the device has to execute the RFA. Other execution tasks must be configured in the RODL file. In the test application used for the energy measurement, the RODL file only contains one execution slot in each period. This task is responsible for data preparation. We measured a current of about 11 mA for a duration of 1 milliseconds. This energy part mainly depends on the amount of code of the executed tasks.

The *transmission time* corresponds to the time, where the device is transmitting data. Normally, this is always the case when the RCB wants to broadcast its synchronization message during the firing time. Other transmissions during the period must be registered in the RODL file. We further measure the energy consumption of a registered transmission slot, which is used to broadcast test data. We measured a current consumption of about
over a time of
. Note that this duration does not equal the real transmission time of about
. This comes from the fact, that the transceiver requires some time for the startup phase and that the Carrier Sense Multiple Access with Colission Avoidance (CSMA/CA) scheme at the MAC layer may also cause some delay although the backoff scheme was disabled.

Listing of the major energy consumers and their corresponding battery discharge. The energy calculation assumes a working voltage of 3 Volt.

To follow up on our special energy example, we further want to calculate the improvement of the lifetime with respect to the lifetime as if no synchronization approach would be established, that is, the duty-cycle equals 100%. In that case, the average current consumption equals 23.752 mA. Consequently, a duty-cycle of 100% corresponds to a lifetime of about 50.5 hours. A comparison among the lifetime with a duty-cycle of 100% and the achieved lifetime with our configured duty-cycle of about 7% shows that the synchronization approach improves the lifetime by at least a factor of three.

## 6. Discussion

The simulator and testbed results have shown that the simulator provides promising results which are mostly similar to the testbed results. Several experiments have shown that the rate calibration works well in the presence of high delay jitter and transmission delay. However, the results from the multihop topology experiments in the testbed system are worse compared to the simulation results. This comes from the fact that our testbed environment suffers from an unexpected delay jitter and further an additional communication delay which was not regarded in the state correction algorithm.

These conditions and the presence of asynchronous communication patterns in realistic sensor networks regarding highly multihop scenarios with high requirements on availability and dependability makes the employment with low-cost nodes in such an environment usually improper. Otherwise, the proposed grouped multihop topology with a small network diameter allows the forwarding more reliable than it would be in a standard adhoc network. For instance, the nodes in such a single group could be statically configured via the RODL file such that they all forward the same message to the neighboring groups in different slots, but within the same period. In other words, such a group comprises several nodes which have the same functionality (e.g., sensor measurement, relaying, sensor fusion, computation, actuator control in combination with Triple Modular Redundancy (TMR). If so, then a single node failure has no impact on the network behavior, since there exist no dedicated nodes. Thus, graceful degradation is the main advantage of this protocol.

The time-triggered approach a priori requires a static communication plan (the RODL file) for each node in the network. Therefore, the network and possible multihop scenarios must be analyzed before the RODL file can be created. This requires additional work and expenses compared to other protocols. However, the inherent advantage is that the deployed communication schedule can be perfectly adapted to the current known static network topology. Therefore, multihop routing algorithms are no longer necessary, since the routing is done implicitly during the configuration process of the RODL files. Though, a change in the network topology may also involve a reconfiguration of all RODL files.

We have shown that our approach provides a duty-cycle of about 7% and thus reduces the energy consumption in a simple network by at least a factor of three. Note that the duty-cycle heavily depends on the synchronization precision. Since we consider the implementation on low-cost nodes by the use of an off-the-shelf MAC layer which does not support MAC timestamping, our synchronization precision is limited to the MAC specific delay jitter. Other established protocols such as S-MAC or the slotted variant of IEEE 802.15.4 use an alternative or more sophisticated clock synchronization approach and thus usually achieve a duty-cycle of lower than 1%. However, such protocols usually demand a dedicated master node (and maybe additional backup nodes) which represents a single point of failure. In contrast, our approach has the inherent advantage that it does not require any dedicated nodes. Furthermore, a higher synchronization precision and thus a lower duty-cycle can indeed be achieved by more accurate but also more expensive external crystal oscillators. As a result, the tradeoff lies between the costs of a node and the power consumption.

## 7. Related Work

Literature on biologically inspired Firefly synchronization can be categorized into papers about the biological/mathemathical models of the Firefly approach [1, 4, 11], work that treats the biologically inspired Firefly synchronization model for realizing the communication in sensor networks [3, 12] and architectures and evaluations that apply the Firefly synchronization model to establish a time-triggered service [13].

Werner-Allen et al. [3] present the Reachback Firefly Algorithm, which is well-suited for the implementation in sensor networks. The algorithm was simulated with TOSSIM over several parameter choices (e.g., different node topologies, coupling strength, and network diameters). values, and network diameter.

In [14], the authors introduce a time advance strategy based on the PCO model, which takes the delays in wireless systems into account. Similarly to [3], they incorporate the fact that a node cannot transmit and receive at the same time. The time advance strategy presented in this paper compensates the delay, which is responsible for the lower bound of the accuracy. This delay depends on the dominant transmission and decoding delay. The compensation is done by delaying the transmission of the synchronization messages.

## 8. Conclusion and Outlook

An alternative synchronization algorithm based on the synchronous flashing of fireflies was introduced in order to establish a global timebase that supports the implementation of a time-triggered approach based on the off-the-shelf MAC layer IEEE 802.15.4. This allows a collision-free communication and a reduction of power consumption by at least a factor of 3. The synchronization is based on a self-organized principle with a simple calculation and provides complete scalability and graceful degradation. This is beneficial for the use in sensor networks. This has the inherent advantage, that no dedicated synchronization node is required and thus there exist no single point of failure. Furthermore, the additional rate calibration scheme allows a longer resynchronization interval and the use of cheap oscillators with high drift rates, which are usually featured in low-cost nodes.

The approach has been evaluated by simulation and an implementation in a real testbed environment. Several experiments based on an all-to-all topology have shown that it is possible to achieve a synchronization precision which is lower than 1 milliseconds. Unfortunately, the testbed system suffered from an unexpected delay jitter and an additional communication delay. For this reason, the testbed results considering highly multihop topologies were worse compared to the simulation results with a low delay jitter.

Future work will rely on the improvement of the synchronization precision by the use of an alternative MAC-Stack supporting MAC timestamping. Furthermore, we want to extend the algorithm in order to be resilient to compromised nodes which may behave as an adversary trying to destroy the synchronization. Last but not least, we want to compare the results of our approach with other synchronization schmes designed for wireless networks.

**Algorithm 1:** E-RFA: code for
,
.

**upon event**
**do**
preopened transmission of sync-message

**trigger**
broadcast current phase to all neighbors

**upon event**
*from*
**do**
received sync-message

**if**
**then**
check if real firing-event is within the period

**upon event**
**do**
threshold reached

**for each**
*event*
*eventset in increasing order*
**do**

## Declarations

### Acknowledgments

This work was supported by the Austrian FWF project TTCAR under contract no. P18060-N04. The authors would like to thank Johannes Klinglmayr for constructive comments on an earlier version of this paper.

## Authors’ Affiliations

## References

- Buck J:
**Synchronous rhythmic flashing of fireflies. II.***The Quarterly Review of Biology*1988,**63**(3):265-289. 10.1086/415929MathSciNetView ArticleGoogle Scholar - Elmenreich W, Bauer G, Kopetz H:
**The time-triggered paradigm.***Proceedings of the Workshop on Time-Triggered and Real-Time Communication, December 2003, Manno, Switzerland*Google Scholar - Werner-Allen G, Tewari G, Patel A, Welsh M, Nagpal R:
**Firefly-inspired sensor network synchronicity with realistic radio effects.***Proceedings of the 3rd International Conference on Embedded Networked Sensor Systems (SenSys '05), November 2005, San Diego, Calif, USA*142-153.View ArticleGoogle Scholar - Mirollo RE, Strogatz SH:
**Synchronization of pulse-coupled biological oscillators.***SIAM Journal on Applied Mathematics*1990,**50**(6):1645-1662. 10.1137/0150098MATHMathSciNetView ArticleGoogle Scholar - IEEE Computer Society : IEEE Standard for Information technology—telecommunication and information exchange between systems—local and metropolitan area networks—specific requirements—part 15.4: Wireless Medium Access Control (MAC) and Physical Layer (PHY) Specifications for Low-Rate Wireless Personal Area Networks (LR-WPANs). Institute of Electrical and Electronics Engineers, September 2003Google Scholar
- Lundelius J, Lynch N:
**An upper and lower bound for clock synchronization.***Information and Control*1984,**62**(1):190-204.MATHMathSciNetView ArticleGoogle Scholar - Ye W, Heidemann J, Estrin D:
**Medium access control with coordinated adaptive sleeping for wireless sensor networks.***IEEE/ACM Transactions on Networking*2004,**12**(3):493-506. 10.1109/TNET.2004.828953View ArticleGoogle Scholar - Simon G, Volgyesi P, Maroti M, Ledeczi A:
**Simulation-based optimization of communication protocols for large-scale wireless sensor networks.***Proceedings of the IEEE Aerospace Conference, March 2003, Big Sky, Mont, USA***3:**1339-1346.Google Scholar - Atmel Corporation : ATAVRRZ200 Demonstration Kit AT86RF230 (2450 MHz band) Radio Transceiver User Guide. Document No. 5183AZIGB12/07/06, July 2006Google Scholar
- Eberle S, Ebner C, Elmenreich W,
*et al*.:**Specification of the TTP/A protocol.**In*Research Report*. Institut für Technische Informatik, Technische Universität Wien, Vienna, Austria; 2002. Version 2.00Google Scholar - Buck J, Buck E:
**Synchronous fireflies.***Scientific American*1976,**234**(5):74-85. 10.1038/scientificamerican0576-74View ArticleGoogle Scholar - Tyrell A, Auer G, Bettstetter C:
**Biologically inspired synchronization for wireless networks.**In*Studies in Computational Intelligence*.*Volume 69*. Edited by: Dressler F, Carreras I. Springer, Berlin, Germany; 2007:47-62. 10.1007/978-3-540-72693-7_3Google Scholar - Leidenfrost R, Elmenreich W:
**Establishing wireless time-triggered communication using a firefly clock synchronization approach.***Proceedings of the 6th International Workshop on Intelligent Solutions in Embedded Systems (WISES '08), July 2008, Regensburg, Germany*1-18.Google Scholar - Tyrrell A, Auer G, Bettstetter C:
**Firefly synchronization in ad hoc networks.***Proceedings of the MiNEMA Workshop, February 2006, Leuven, Belgium*Google Scholar

## Copyright

This article is published under license to BioMed Central Ltd. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.