SLTP: Scalable Lightweight Time Synchronization Protocol for ...

15 downloads 4452 Views 3MB Size Report
In this paper, we propose SLTP, a Scalable Lightweight Time-synchr- ... linear regression SLTP can reduce the energy consumption of network nodes and.
SLTP: Scalable Lightweight Time Synchronization Protocol for Wireless Sensor Network Sepideh Nazemi Gelyan1, Arash Nasiri Eghbali2, Laleh Roustapoor2, Seyed Amir Yahyavi Firouz Abadi3, and Mehdi Dehghan2 1

Dept. Of Computer Engineering, Islamic Azad University, Firouzkooh Branch 2 Computer Engineering Department, Amirkabir University of Technology 3 Electrical & Computer Engineering Department, University of Tehran [email protected], {eghbali, roustapoor, dehghan}@aut.ac.ir, [email protected]

Abstract. In wireless sensor networks, time synchronization is a critical problem. In this paper, we propose SLTP, a Scalable Lightweight Time-synchronization Protocol for wireless sensor networks. By using passive clustering and linear regression SLTP can reduce the energy consumption of network nodes and also decrease the overhead of creating and maintaining the clusters. Moreover SLTP uses linear regression to compute the time. Therefore, it can calculate the clock skew and offset between each node and its cluster head in order to estimate the local time of remote nodes in the future or the past. Simulation results show that by this we can gain considerable improvements in power consumption, accuracy and scalability in comparison to similar algorithms.

1 Introduction Recently a new kind of wireless networks has emerged, one that has cheaper and smaller nodes [1]. These nodes are sensors which gather and process information from the physical and real world. They are used for geophysical monitoring and observing the special environments such as war zones, wild life, etc. Special and strategic applications of these networks in inaccessible and dangerous environments can cause some restrictions for network managers. For instance, the managers are unable to access nodes for recharging, reconfiguring and reprogramming. So when the nodes are damaged or their batteries are discharged, they are neither recyclable nor reprogrammable [8]. In sensor networks, the main reason for nodes failure is the discharge of batteries. Energy efficiency is a critical issue in wireless sensor networks [12]; therefore, using energy efficient programs and algorithms on these nodes is of great significance [12]. One of the most important problems in computer networks, including wireless sensor networks, is time synchronization among nodes. In view of the fact that wireless sensor networks are used for monitoring strategic environments, the accuracy of the information gathered is crucial. Information accuracy highly depends on time [8]; as a result, time synchronization plays an important role. Traditional time synchronization H. Zhang et al. (Eds.): MSN 2007, LNCS 4864, pp. 536–547, 2007. © Springer-Verlag Berlin Heidelberg 2007

SLTP: Scalable Lightweight Time Synchronization Protocol for WSN

537

protocols are not suitable for sensor networks [12, 8]. For example NTP consumes too much energy in order to exchange the required messages and requires using GPS which is costly for sensor nodes [8]. Over the past few years, many time synchronization algorithms have been suggested. The main goals of these algorithms were to increase the time synchronization accuracy and to decrease the power consumption. RBS [1] is one of the most cited protocols in this field. It synchronizes a set of receivers by using linear regression; in other words, RBS presents a way that enables nodes to calculate local time of remote nodes in proportion to their local times. This protocol is not scalable and in case of increase in the number of nodes its efficiency decreases significantly. Although RBS presents a solution for increasing the accuracy, it extremely suffers the network collisions. Some algorithms such as TPSN and LTS [3, 2] use tree construction. In general, in these algorithms, increase in the depth of the tree results in higher error rates. Also the creation and maintenance of the tree causes high overhead. In addition, tree-scanning algorithms require having some global information about the network which is inconsistent with distribution concept; indeed, wireless sensor networks are distributed systems that do not have access to such information [12, 2]. Some algorithms like PCHTS [6] and PCTS [5] use clustering techniques. PCHTS suffers high overhead due to costly creation and maintenance of the clusters. PCTS uses the passive clustering concept, which results in efficient energy consumption; on the other hand, it frequently has to set the node’s clock to calculated values which leads to high-energy consumption by CPU. These values are calculated using the averaging technique. By using passive clustering, our proposed protocol not only decreases the nodes energy consumption but also reduces the overhead of creation and maintenance of the clusters. Moreover, we use linear regression for computing skew and offset for clock of each node in proportion to its cluster head. This helps nodes to estimate the local time of remote nodes in the future or the past. We used NS2 for simulating and evaluating our model. The organization of this paper is as follows: We first review related works in Section 2. In Section 3, first we discuss passive clustering (3.1) as a basis for our method; afterwards we will describe our protocol in detail. In section 3.4, we demonstrate the theoretical analysis of our method. Error analysis is discussed in section 3.5. Section 4 presents our simulations’ setup and results. Protocol overhead is discussed in section 4.3.2. Finally, we offer our conclusions and describe our plans for future work in section 5.

2 Related Works RBS [1] synchronizes a set of receivers by using the available broadcasting channel in the network physical layer. The reference node broadcasts a predefined number of synchronization packets to its neighbors and these packets are received approximately at the same time. At this time receivers record their local times. After that, they exchange the received times with their neighbors. Next, they use linear regression for computing clock offset and skew corresponding to their neighbors. RBS does not readjust the clock. Also it does not consider the nondeterministic errors such as send time delay and access time delay, since broadcasting creates the same

538

S.N. Gelyan et al.

amount of these errors for all nodes. The most important disadvantage of RBS is that it is not scalable. In other words, by increasing the number of nodes, synchronization accuracy falls and the number of exchanged messages for synchronization increases. LTS [2] creates a low-depth spanning tree composed of the nodes in the network, and uses a pair-wise synchronization algorithm for each one of the two nodes on the same edge of the tree [2, 3]. Reference node starts time synchronization and it continues until all leaves are synchronized. LTS uses Breadth-first-search algorithm which has higher communication overhead compared to other tree-construction algorithms. Also executing BFS in distributed systems is difficult. TPSN [3] has two phases. At the first phase, level discovery phase, a tree is created. At the second phase, the synchronization phase, each node in ith level synchronies itself with the node in (i-1)th level by using a pair-wise synchronization algorithm. TSYNC [4] uses Multi channel nodes. This attribute results in lower collision rates. Each node has two channels, control and clock channel. All nodes use the same control channel but clock channel is unique for each node. Algorithm has two protocols. One of them is HRTS which is used for synchronizing the whole network and the other one is ITR which lets each node to synchronize itself on-demand. Each node that wants to be synchronized sends an ITR request message to its parent and this is repeated until the request message reaches the base station. The base station returns its clock though the clock channel to the requesting node. TSYNC uses broadcasting like RBS, but it has less overhead than RBS. Disadvantage of this algorithm is that we made an assumption about having multi channel sensor nodes which is not always the case. CHTS [6] uses clustering technique and nodes are able to change their radio ranges. Network is not homogenous, some nodes are high performance, and some are low performance. Cluster heads are selected from high performance nodes. CHTS has three sub algorithms; cluster head tree construction, cluster member tree construction, and the synchronization algorithm. CHTS makes too many assumptions in order to select cluster heads and cluster members. Moreover, algorithm extremely suffers from collisions, if the number of nodes increases. PCTS [5] uses passive clustering and overhearing in time synchronization phase. It has two phases. At first cluster heads collect clock information from members of their clusters. Next, they calculate the average value and send the calculated clock to members of their clusters. Some nodes that are members of more than one cluster have to calculate the average clock of all of their cluster heads and send the calculated clock to them. This algorithm has to set clock continuously which results in more power consumption and in order to do this it has to send lots of time synchronization packets which in turn causes a lot of collisions, during the time synchronization phase.

3 Protocol Description 3.1 Review on Passive Clustering Passive clustering is a method for creating clusters with less overhead than other methods [14]. Its setup time is very short and clustering the network is fast. The most eager node to become “cluster head” starts this procedure [15]. In our implementation this node broadcasts a special packet with a flag. Flag’s value can be either ø or 1 and

SLTP: Scalable Lightweight Time Synchronization Protocol for WSN

539

the initial value is ø. The nodes that receive this packet will become “cluster members” and change the flag to 1, and then rebroadcast it. Adjacent nodes that receive it in turn will become “cluster head” and change the flag to ø and then broadcast too. This procedure is repeated until the whole network is scanned. During this procedure, some nodes receive packets from two or more cluster heads. These nodes change their status to “gateway” [5, 15]. We will discuss passive clustering in more detail in section 3.3.1. 3.2 Assumptions Time synchronization is done between cluster members and their cluster heads based on the assumption that cluster members do not need to exchange messages with each other, because analyzing data and query processing is done by cluster heads. However, time synchronization among cluster members of the same cluster or different clusters is possible. The nodes have the same abilities such as power level, radio range, etc. Nodes are able to change their status to “cluster head”, “cluster member” or “gateway”. Our algorithm does not require nodes to readjust their clocks. The use of linear regression for calculating drift between nodes’ clocks enables them to estimate the time of one another. This method has two advantages [12]: 1. Clock oscillators all tick at different rates resulting in different clock disciplines. We let each clock to work with its discipline. 2. Clocks do not require continuous readjustments by CPU which is important for efficient energy consumption. We do not employ a global time in our algorithm since having only local times is sufficient and more suitable for sensor networks applications [1, 13]. However, using a global time like UTC is also possible. 3.3 Scalable Lightweight Time Synchronization Protocol Our Algorithm has two phases: configuration phase and synchronization phase. We will describe them below. 3.3.1 Configuration Phase The intent of this phase is to determine the cluster heads. The procedure for selecting cluster heads influences on network's lifetime [10]. There are many ways to select cluster heads [11]. We use a method close to passive clustering with a little modification so that it fits our needs. Configuration phase is divided into two parts based on network being static or dynamic. Static mode: The most eager node to become cluster head changes its status to “cluster head” and broadcasts a packet with a Boolean flag. Flag’s value is set to ø. Every node that receives this packet changes its status to “cluster member” and sets the packet’s flag to 1 and rebroadcasts it. Nodes that have received this packet change their status to “cluster head”. They set the packet's flag to ø and broadcast it again. This is repeated until the whole network is covered. Each node stores its cluster head address. Nodes that receive this packet from 2 or more cluster heads will become

540

S.N. Gelyan et al.

“gateway”. Gateways must send an ACK message to introduce themselves to their cluster heads. This ACK message contains the list of their cluster heads. Sending an ACK message enables cluster head to select one gateway between clusters. Having one gateway simplifies the routing. We used the following four rules in our implementation of passive clustering: 1. If a cluster member receives the packet from another cluster member, it must not rebroadcast the packet. 2. If a cluster head receives the packet from another cluster head, it must change its status to “cluster member” and rebroadcast the message with flag value 1. 3. If a cluster member receives the packet from another cluster’s head or vice versa, it will not rebroadcast the packet. 4. If a node does not receive any packets for a specified amount of time, it must set its status to “cluster head” and broadcasts a message with flag value ø. Dynamic mode: In dynamic mode, only the selection of the cluster heads is done. Cluster members and gateways are determined in synchronization phase. Because of the network dynamics, a node that was a gateway in the past may not be one now and a node that belonged to cluster i may now belong to cluster j. We believe, our algorithm performs relatively well in dynamic networks. In case of applications that the rate of change in network structure is faster than configuration phase’s speed, our algorithm may not work well. In dynamic networks configuration procedure must be executed before doing time synchronization. This procedure helps in uniform distribution of cluster heads. 3.3.2 Synchronization Phase After configuration phase is finished and cluster heads are selected, synchronization phase starts. During a defined time period which we call “setup time” cluster heads start broadcasting some packets in random intervals. These packets contain local times of cluster heads. When one of these packets is received by a cluster member, the cluster member records its own local time. In dynamic mode by receiving a packet, cluster members can figure out which cluster they belong to. By using linear regression method each cluster member can calculate its clock offset and clock skew in proportion to its cluster head. In dynamic mode, if a node receives packets from two or more cluster heads, it will become gateway. In general, gateway’s task is to convert local time of cluster heads to each other. In static mode, time synchronization is repeatedly done in specific time intervals. If a node needs to synchronize itself with another node during this period, it can broadcast an independent time synchronization request message. The first cluster head that receives this message starts synchronization procedure and broadcasts synchronization packets. In dynamic mode as mentioned before, we have to execute configuration phase before each synchronization phase, in order to have a uniform distribution of cluster heads. If during synchronization phase a node does not receive any packets, node changes its status to “cluster head” and starts broadcasting synchronization packets with its local time. If the network's distribution is uniform, we may hope that this node will be able to connect through one gateway to the network.

SLTP: Scalable Lightweight Time Synchronization Protocol for WSN

541

Below is the pseudo-code of our algorithm: CH: Cluster Header; CM: Cluster Member G: Gateway; hi: local time of node i Program timesync (output); Begin Configuration (base station); {in this part CHs and CMs are selected by our Passive Clustering algorithm} For each ni in CH set do broadcast (ID, hi); For each ni in CM set do Begin Receive (ID, hi); Store (ID, hi); Compute regression (hi, hj); Co=clock offset (hi, hj); Cs=clock skew (hi, hj) End; If (nk is in the CM set) and (nk has received from more than one CH) Then Begin {add nk to gateways set} nk.Status:= G; For each i that has sent packet to same nk do Compute regression (hi, hk) {i is the member of CH that has sent a packet to the same nk} End; If there is nm that does not receive any packet from CH then Broadcast (ID, hm); End.

3.4 Analysis by Example To describe our analysis clearly we use some examples. After execution of our algorithm, each node except for the cluster heads calculates the following equation: hchi= αhcmi+ β.

(1)

Which α is the clock skew and β is the clock offset between cluster head and cluster member. Assume that CM1 at its local time hcml sees an object in location (X1, Y1). It calculates the local time of its cluster head, in proportion to its own local time of the object’s observation. CM1 sends this time and the location of the object to its cluster head. This procedure is repeated by CM2. CM2 sees the object in its local time hcm2 in (X2, Y2). Therefore cluster head can calculate the speed and direction of the moving object (figure 1-a).

Fig. 1. CH1 receives the observation time of the object from CM1 and CM2, (b) CM1 and CM2 are synchronizing their clocks

542

S.N. Gelyan et al.

If two nodes in the same cluster want to exchange information, calculating their own α and β is sufficient. By the following equation, they can calculate time of each other (figure 1-b).

(1) CM1 : h CH1 = α1h CM1 + β1 (2) CM 2 : h CH1 = α 2 h CM 2 + β 2 ∴ h CM1

(2)

⎛β −β ⎞ α = 2 h CM 2 + ⎜⎜ 2 1 ⎟⎟ α1 ⎝ α1 ⎠

In general we can formulate the relation between local time of two nodes as follows. CM2 can convert its local time to CM1’s local time by using equation 2 (figure 2). In spite of the fact that this calculations have error, if α and β are calculated accurately in each hop, they would remove each other’s effect (Equation 3). As result, we will have fairly constant error amount in multi-hop time synchronization algorithm. In our Implementation it is not necessary for CM1 to have all of parameters (α and β) along the path from CM1 to CM2. The calculation is done in each node in the path until the packet reaches its destination.

Fig. 2. Two nodes from different clusters are synchronizing their clocks i −1

n

hCM1 =

∏α

2i

i =1 n

∏α i =1

2i −1

⎛ β − β 2i −1 ⎞ ⎟ hCM2 + ∑ ⎜⎜ 2i α 2i −1 ⎟⎠ i =1 ⎝ n/2

∏α j =1

2j

i −1

∏α j =1

2 j −1

(3)

0

Π =1 j =1

n: Number of nodes in the path between source & destination

3.5 Error Analysis By broadcasting we can ignore some sources of error in time synchronization [1] such as send time and access time delay. These errors depend on parameters that we cannot control; for instance, the load on the sender's CPU or network’s load. By broadcasting, these delays become similar for the whole network and as a result we can ignore them [8, 1]. In addition, the speed of electro-magnetic signal in air is almost C (Light speed) [1] and propagation delay is calculated by this equation: T= x/v, v =c.

SLTP: Scalable Lightweight Time Synchronization Protocol for WSN

543

As a result, since sensors have limited range, propagation delay is very small and can be neglected. The remaining error is received time delay, according to [6] we can receive and process the packet in an interrupt. Calculating α and β in each hop has computational error as was mentioned in section 3.4. Therefore, as the path between source and destination node increases the error grows higher.

4 Performance Evaluation For performance evaluation we used NS 2.31. We selected PC_Avg [5] and RBS [1] for performance comparison and created the same test conditions for all of them during the simulation time. We compare SLTP to PC_Avg in terms of accuracy and scalability. Also, we compare it to RBS for overhead and scalability. 4.1 Simulation Setup Simulation and evaluation of different algorithms that require different clock configurations on one system are very difficult. To create different clock behavior for each node, we use a different clock drift and offset. The values are selected randomly and each node's clock works according to these parameters. As mentioned in [1], typically two nodes’ clock will drift 1-100µsecond per second. Also we assume that maximum clock offset is 1 second. This pessimistic offset should cover for the propagation delay. All nodes have a range of 100 meters and are located in 1000*1000 square meters area. Network topology is grid. Default number of nodes is 140 and default simulation time is 10450s. We run the synchronization algorithm every 1000 seconds. Each cluster head sends 10 initial synchronization packets (which contain its local time) with a 1 second delay between each transmission. 4.2 Time Routing When a node wants to be synchronized with another one, it has to broadcast a request message. If this node is a cluster member or a gateway, it must send this request to its cluster head(s). The cluster head broadcasts this message to its cluster and saves the address of requesting node as the last hop of this message. Each gateway in this cluster, after receiving this packet, sends it to its entire cluster heads except the one that sent this packet in the first place. Cluster heads that receive this packet will save the gateway’s address as the last hop of this message. This procedure is repeated until the packet reaches the destination node. A path is made between requesting node and destination node. In the reverse path in each hop the clock of destination node is converted until it reaches requesting node. 4.3 Simulation Results Since in each run, different paths between source and destination are selected we decided to run the algorithm 10 times for each different situation and calculate the average of error for each run. If gateways with small clock drifts and skew are chosen along the path, average of error will be smaller.

544

S.N. Gelyan et al.

4.3.1 Time Synchronization Results Figure 3 shows the average of error versus simulation time. It is clear that as time passes, error of SLTP increases gradually, while in case of PC_Avg this increase is dramatic. Since clock of each node works with a different drift and offset, and the difference among clusters’ clock can be significant, PC_Avg algorithm will not be able to appropriately synchronize different clusters. Because SLTP uses linear regression, it is able to manage this problem. Figure 4, shows the influence of number of hops increase on the error. As indicated, SLTP's error in all situations was significantly less than PC_Avg's. Besides, as the number of hops increases, error ratio of PC_Avg goes up dramatically but in case of SLTP this increase is gradual. Average of error in SLTP in one hop is 0.13± 0.06s. Increasing the number of hops has a little effect on SLTP’s error. The reason for this is mentioned in section 3.4. Figure 5 compares the scalability of SLTP versus PC_Avg. We can observe that error of SLTP is almost stable and SLTP’s error seems independent of the number of nodes. Figure 6 shows the two algorithms' tolerance under different drifts.

Fig. 3. Comparison of SLTP’s and PC_Avg’s error versus simulation time

Fig. 4. Comparison of SLTP’s and PC_Avg’s error versus number of hops

SLTP: Scalable Lightweight Time Synchronization Protocol for WSN

545

Fig. 5. Comparison of SLTP and PC_Avg in scalability

Fig. 6. Comparison of SLTP’s and PC_Avg’s tolerance under different drift

4.3.2 Overhead By using passive clustering and linear regression we decreased the number of exchanged messages in SLTP. Table 1 shows the number of messages used to synchronize the whole network for SLTP and two similar algorithms. Table 1. Number of transmitted messages for the following algorithms Number of messages

Algorithm

C*m

SLTP

C*(2 + K)

PC_Avg

N2 * m

RBS

C: Number of Cluster Heads K: Number of Cluster Members N: Number of Nodes m: Number of Synchronization Packets C