S˜ao sugeridas, como extens˜oes deste trabalho, trˆes modifica¸c˜oes dos programas base- ados neste e o estudo de seus impactos durante a opera¸c˜ao:
1. Adi¸c˜ao seguran¸ca `a conex˜ao. A adi¸c˜ao de seguran¸ca tem como consequˆencia maior necessidade de processamento, n˜ao necessariamente h´a aumento na quantidade de dados transmitida, mas depende dos m´etodos utilizados. Uma extens˜ao de segu- ran¸ca para o PTP ´e descrito por (IEC, 2009) no Apˆendice K, mas criptografia do canal de comunica¸c˜ao em si ´e, provavelmente, mais desej´avel que simplesmente se- guran¸ca no protocolo de distribui¸c˜ao de tempo, quando poss´ıvel.
2. Modifica¸c˜ao da mensagem de resposta `a requisi¸c˜ao de atraso para incluir estampa de tempo. No caso espec´ıfico do uso do PTP com P2P, seguindo a especifica¸c˜ao da norma, o dispositivo solicitante inicia a troca de mensagens com o dispositivo aten- dente e com a troca de mensagens, calcula e armazena o atraso de uma mensagem enviada de um dispositivo para outro.
Por´em, se o solicitante vai sincronizar seu rel´ogio com o do atendente, ele deve aguardar a pr´oxima mensagem que contenha uma estampa de tempo precisa para poder fazer isto. Visto que a rede proposta ´e mesh, as caracter´ısticas da transmiss˜ao podem mudar, assim sendo, quando a pr´oxima mensagem chega, a medida utilizada pode estar desatualizada.
Se a mensagem de resposta incluir uma estampa de tempo precisa, o dispositivo solicitante pode sincronizar o seu rel´ogio com o do atendente assim que termina o c´alculo do atraso das mensagens, reduzindo, assim, o impacto do dinamismo da rede.
3. Adi¸c˜ao de uma detec¸c˜ao de latˆencia de envio, caracter´ıstica do ZigBee, como imple- mentada por Luiz (2012). Como o software j´a utiliza quase toda a mem´oria RAM e o tamanho do programa est´a pr´oximo do limite do compilador, pode ser necess´ario suprimir outras partes/fun¸c˜oes para acomodar os recursos necess´arios.
REFERˆENCIAS BIBLIOGR ´AFICAS
ATMEL CORPORATION. 8051 Microcontroller Instruction Set. San Jose, CA, USA, 2006. Dispon´ıvel em: hhttp://www.atmel.com/Images/doc0509.pdfi. Acesso em: 2014-03-19.
ATMEL CORPORATION. AT89S8253 Data Sheet. San Jose, CA, USA, 2010. Dispon´ıvel em: hhttp://www.atmel.com/Images/doc3286.pdfi. Acesso em: 2014-03-19.
AZBELL, B. Porting ZASA code to CCE. 2009. Postagem em f´orum em 2009-01-03. Dispon´ıvel em: hhttp://e2e.ti.com/support/low power rf/f/156/p/17010/65851.aspx# 65851i. Acesso em: 2014-03-19.
BUREAU INTERNATIONAL DES POIDS ET MESURES. LEAP SECONDS IN UTC UNTIL 30 JUNE 2015. [S.l.], 2014. Dispon´ıvel em: hftp://ftp2.bipm.org/pub/tai/ publication/leaptab/leaptab.pdfi. Acesso em: 2014-07-28.
CHO, H. et al. Implementation of a ptp bridge to extend ieee 1588 to zigbee networks. In: IEEE. Computer and Information Technology (CIT), 2010 IEEE 10th International Conference on. [S.l.], 2010. p. 2604–2611.
DU, Z.; LU, Y.; JI, Y. An enhanced end-to-end transparent clock mechanism with a fixed delay ratio. Communications Letters, IEEE, IEEE, v. 15, n. 8, p. 872–874, 2011. FILHO, K. de S. O.; SARAIVA, M. de F. O. Medidas de Tempo. 2012. Dispon´ıvel em: hhttp://astro.if.ufrgs.br/tempo/i. Acesso em: 2014-03-19.
IEC. IEEE Standard for a precision clock synchronization protocol for networked measurement and control systems. 2009. C1-274 p. IEC 61588:2009(E). Dispon´ıvel em: hhttp://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=4839002i. Acesso em: 2014-03-19.
JOHNSON, M. et al. A comparative review of wireless sensor network mote technologies. In: Sensors, 2009 IEEE. [s.n.], 2009. p. 1439–1442. ISSN 1930-0395. Dispon´ıvel em: hhttp://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5398442i. Acesso em: 2014-03-19.
JONES, A. Calendrica ii: Date equations from the reign of augustus. Zeitschrift f¨ur Papyrologie und Epigraphik, Bonn Rudolf Habelt GmbH, n. 129, p. 159–166, 2000. Dispon´ıvel em: hhttp://www.uni-koeln.de/phil-fak/ifa/zpe/downloads/2000/129pdf/ 129159.pdfi. Acesso em: 2014-03-19.
LEE, S.; LEE, S.; HONG, C. An accuracy enhanced ieee 1588 synchronization protocol for dynamically changing and asymmetric wireless links. Communications Letters, IEEE, IEEE, v. 16, n. 2, p. 190–192, 2012.
LIXIA, M. et al. Synchrophasors measurement in a gps-ieee 1588 hybrid system. European Transactions on Electrical Power, Wiley Online Library, v. 21, n. 4, p. 1509–1520, 2011.
LUIZ, F. da C. SISTEMA DE CALIBRAC¸ ˜AO DE ENERGIA SEM FIO USANDO ZIGBEE. Tese (Doutorado) — Universidade Federal do Rio de Janeiro, Rio de Janeiro, 2012.
LV, S.; LU, Y.; JI, Y. An enhanced ieee 1588 time synchronization for asymmetric communication link in packet transport network. Communications Letters, IEEE, IEEE, v. 14, n. 8, p. 764–766, 2010.
MILLS, D. et al. Network Time Protocol Version 4: Protocol and Algorithms Specification. 2010. Request for Comments: 5905. Dispon´ıvel em: hhttps://tools.ietf.org/html/rfc5905i. Acesso em: 2014-03-19.
NASCIMENTO, F. B. Simple ZigBee Sensor, PTP and Monitoring Program. S˜ao Paulo: [s.n.], 2014. Dispon´ıvel em: hhttp://www.biazi.eng.br/mack/mestrado/2014/szs/i. Acesso em: 2014-06-26.
NASCIMENTO, F. B.; LOPES, P. B. Clock synchronization between wireless low power devices. In: The 22nd International Conference on Software, Telecommunications and Computer Networks (SoftCOM 2014). Split, Croatia: [s.n.], 2014.
NØRBY, T. The perpetual calendar: A helpful tool to postal historians. Tradu¸c˜ao para o inglˆes, pelo pr´oprio autor, de parte de do artigo The Danish Parpetual Calendar de 1985, sofreu atualiza¸c˜oes e corre¸c˜oes, 16a vers˜ao desde 1995. 2000. Dispon´ıvel em: hhttp://norbyhus.dk/calendar.phpi. Acesso em: 2014-03-19.
OBSERVAT ´ORIO NACIONAL. O Tempo. 2014. Dispon´ıvel em: hhttp://ntp.br/NTP/ MenuNTPTempoi. Acesso em: 2014-03-19.
TEXAS INSTRUMENTS INCORPORATED. Efficient Multiplication and Division Using MSP430. Dallas, Texas, 2006. SLAA329. Dispon´ıvel em: hhttp://www.ti.com/lit/ an/slaa329/slaa329.pdfi. Acesso em: 2014-06-24.
TEXAS INSTRUMENTS NORWAY AS. CC2480 Developer’s Guide. Oslo, Norway, 2008. SWRA176. Dispon´ıvel em: hhttp://www.ti.com/lit/an/swra176/swra176.pdfi. Acesso em: 2014-03-19.
ZIGBEE ALLIANCE. ZigBee Specification Overview. c 2014. Dispon´ıvel em:
APˆENDICE A — ARTIGO: CLOCK SYNCHRONIZATION BETWEEN WI- RELESS LOW POWER DEVICES
Clock Synchronization between
Wireless Low Power Devices
F. B. Nascimento
Programa de P´os-Graduac¸˜ao em Engenharia El´etrica Universidade Presbiteriana Mackenzie
Rua da Consolac¸˜ao, 896, 01302-907, S˜ao Paulo - SP, Brazil Email: [email protected]
P. B. Lopes
Programa de P´os-Graduac¸˜ao em Engenharia El´etrica Universidade Presbiteriana Mackenzie
Rua da Consolac¸˜ao, 896, 01302-907, S˜ao Paulo - SP, Brazil Email: [email protected]
Abstract—This article deals with the implementation of a time distribution protocol among limited resources wireless sensor devices. This type of protocol aims to distribute the same time reference among two or more devices within a network. Timestamps on measurements help to relate them on causality studies. The PTP protocol defined in IEEE 1588-2008 is used, with little adaptations, to synchronize and tune software clocks running on the target boards of the Texas Instruments R
ZigBee kit ez430-RF2480. Initially only synchronization was done, but there were need to implement the tuning. The devices clocks are synchronized and tuned, even in heavily limited resources devices.
I. INTRODUCTION
Wireless sensor devices can be used in many applications. When measurements can or must be related and time ordered, the time stamps are needed, and a distribution of a unique time reference within a network is fundamental to establish a causality relationship from measurements obtained by different sensors. As the time stamps need to be more precise, the time distribution must be enhanced.
Wireless devices are built having low-power in mind, with severe restrictions in processing and data storage resources. Therefore time distribution protocols must be carefully devised in order to be implemented in such devices.
This work consists of an implementation of a time distri- bution protocol based on the PTP (Precision Time Protocol), defined by [1], on limited resources target boards. As an example, the ez430-2480 Development Kit described in [2], by Texas Instruments R, is used. The board details can be seen
in [3]–[6].
The proposed model maintains a software clock on each device and synchronize them, eliminating the need of a discrete RTC (Real Time Clock), in contrast with [7], in which the author uses an external RTC to handle timing.
A. Justificative
With the development of Smart-grids and the Internet of Things, the use of wireless sensors is becoming more widespread. However, in order to collect meaningful infor- mation in a distributed system using different sensors, it is necessary to establish cause and effect relationship among different events occurring in different points and moments from data sent by sensors. Hence, the need to have the sensors
synchronized to the same time reference, regardless of the network topology. A good example for this requirement is an electricity distribution net, monitored through smart-grid concept. Any sequence of events must be reported by the sensors in order to make possible an overall diagnostic of the grid.
New wireless sensor technologies rely on precise synchro- nization [8], which can be achieved with the use of the PTP protocol defined in the IEEE 1588 Standard.
This work’s motivation is to make networked wireless sensors that can be used to monitor a distributed system, with precise time stamp referred to a unique time reference. B. Objective
The main focus of this work is to implement an algorithm of time distribution in severe limited resources low-power wireless devices. The algorithm can be readily adapted to be used on most embedded devices.
II. BACKGROUND
Several studies have been performed on PTP over wireless networks. Moreover, as the standard does not impose limits on the precision of the devices or latency of the network, it is possible to expand its application to wireless sensor networks. The problems of such implementations arise from the stability level, far inferior in comparison to the characteristics of cable connected networks. Some comments about the studies so far are in order at this point:
PTP was used in [7] to synchronize energy meter clocks using an end-to-end mechanism, but using a RTC on each node. It also has appended a latency detection algorithm to his implementation of the protocol, specific for ZigBee networks. This implementation involves additional hardware and consequently builds up the cost of bill of materials.
An enhancement to take asymmetries in the path delays of the network into account is proposed in [9]. After a normal synchronization, the authors propose a second round of synchronization with similar messages, to detect and correct for possible asymmetries in the propagation time of messages. The intent is the application of this technique in 3G cellular networks in which the synchronized devices have plenty of resources.
A bridge to extend the time distribution between ZigBee and Ethernet networks is implemented in [10]. The time reference can be either on the ZigBee or on the cabled sides. Nonetheless, to support the algorithm, the authors use a 32 bit RISC processor in the wireless nodes with consequent increase in costs.
On [11], a technique to compensate the effect of different clock rates in the nodes to be synchronized is presented. However, the proposed algorithm is not fully compatible with the IEEE1588 recommendation.
A hybrid system was implemented by [12], that makes time acquisition by GPS and distribution by PTP, to produce mea- surements of synchrophasors in a power distribution system. The implementation was done in a laboratory environment with off-the shelf equipment. There was no report on the difficulties of a wireless application.
The present work follows a novel approach in the sense that it addresses wireless network applications with minimal hard- ware resources. This restriction precludes the use of additional circuitry such as RTCs or FGPAs in the WSN nodes. Also, the common PTP mechanism used on previous case studies is the end-to-end, on which the master issue commands to initiate the synchronization on each slave device. This work, in contrast, employs the pear-to-pear, on which each device controls the timing of its own synchronization.
III. DEVELOPMENT
The PTP is a set of rules to distribute a time reference, as are the Daytime Protocol in [13], Time Protocol in [14] and the NTP (Network Time Protocol) in [15]. Its objective is to distribute the time with the best achievable precision yet with minimal resource usage. The field values of the IEEE 1588 Standard messages allow a precision better than 1ns.
The time distribution process consists of several steps, starting at the network formation, then creation of logic ports that will be used to PTP messages, decisions on the mas- ter/slave topology, measurement of mean path delay between devices, time synchronization and finally frequency tuning, to reduce or ideally eliminate further synchronization values.
All the programs explained on this section can be obtained from [16] as source code or already compiled.
A. Sensor Reading Software
Initially a software was developed to run on the devices, to replace the factory original that is called ZASA. ZASA makes reading of temperature and voltage sensors and sends the measurements to the coordinator device periodically.
The developed program is called SZS (Simplified ZigBee Sensor), keeps a software clock, reads temperature, voltage and luminosity sensors, each one with a separate time stamp, sends to a device on the network configured as a data sink and keeps a list of known devices with direct communication. Any device may be configured to receive data, but once configured, it must be reset to be reconfigured again.
Table I shows the differences of the programs ZASA and SZS.
TABLE I. COMPARATION BETWEEN PROGRAMSZASAANDSZS.
ZASA SZS
Device type on network
Manual at device power-on Automatic
Serial port monitoring
Coordinator only Any device
Sensor reading Voltage and temperature Voltage, temperature and luminosity
Time stamps No On each sensor reading Internal clock
(software)
No Yes, adjusted by serial port command
Configure allow new devices
Yes, by the button No
Configure device type
At power-on By the button or serial port command
Device modes Coordinator, router or end- device
Coordinator or router
Reset types Power-off the source By button, serial port com- mand or power-off the source
The software clock, the main component that was added, has increments (ticks) of 250µs, a value calculated from the nominal value of the oscillator frequency and the timer configuration that was applied.
These ticks are added to the time at a constant rate, and the values can be adjusted to tune the clock to a time reference. As an example, if the microcontroller frequency is 1 % below the correct value from a trusted source, the tick can be adjusted to 252.5µs so that the time is always within one tick of the trusted source, if properly synchronized. The accepted precision to the value of the tick is 1ns.
The clock can be adjusted with commands through serial port, controlling the synchronism (changes current time) and tuning (changes the tick value).
B. Time Synchronization
The distribution time protocol was added to the SZS, based on the IEEE-1588/2008 standard, that defines the PTP, and the resulting program was then called SZSPTP.
In accordance to the rules, the PTP permits synchronization with accuracies better than 1ns among the clocks of two or more network-connected devices. This accuracy is limited by the devices itself and the network.
Although PTP claims to use as few resources as possible to execute its tasks, the size of the binary file of the SZSPTP is nearly twice the size of the SZS, and the RAM memory becomes almost full. This fact illustrates the difficulty of implementing time stamping on limited resources embedded devices.
The step of establishing the network and the logic ports to be used by the applications was already done by SZS, with configuration of the transceiver and detection of other devices by heartbeat messages.
Inside each heartbeat message the sending device puts a list of known devices, so that the receiving one knows if the sender recognizes it and what is its index in the sender.
Following the recognition, the time distribution creates a master/slave hierarchy to set up a unique time reference and
Fig. 1. SZSM, timing measurements
each slave adjusts its clock according to the proper master. The adjustments take the trip delay of the messages between the slave and the master into consideration.
The amount of possible known neighbors has direct impact on the use of RAM memory. On the test case, with 3 possible neighbors, and considering the size reserved to the call stack that cannot be used by variables, only 34 bytes of memory are left unused, from 1024 available on the micro-controller.
Each additional possible neighbor takes 62 or 64 bytes of memory, depending of the memory alignment, as most of the variables have to be stored in an even memory address.
A good value to the size of the stack was found to be 168 bytes. With this value there was no stack overflow and there was room to fit all the necessary program data. In order to verify the stack overflow, the memory was filled by a constant pattern and after some hours with the program running, the memory was verified for modifications.
C. Monitoring
To verify the working of SZS and SZSPTP a computer program was developed, called SZSM (Simplified ZigBee Sensor Monitor), in Pascal programming language with the Lazarus IDE, which allows one to easily port this program to a different OS such as Windows, Linux, etc. For this study, the program was only tested on Windows and MacOS X. This software made possible to analyze sensor readings as well as the time adjustments performed on each device within a ZigBee network.
A screen capture of this program depicting time adjust- ments is shown in Figure 1. It is also possible to save the data for posterior analysis and export the tables to CSV files.
IV. TESTS
The tests were performed with two and three devices on a network. Data was collected and saved with the SZSM
program. The last four digits of the MAC address identify the devices.
In all experiments, device 3D9B was connected to the computer and its clock was synchronized to the computer clock through the serial port. This device became the grand- master of the network and was used to receive data from three devices: itself, 3C36 and 3D7E. Initially all three devices were connected in a ZigBee network. Subsequently, the 3D7E was disconnected to evaluate the performance with only two devices. The synchronization data was collected for the devices 3C36 and 3D7E.
A. Results
The synchronization data is represented in histogram graphics to visually verify the average value and the variance of time parameters. Figure 2 shows the number of occurrences of the registered values of mean path delay with the master (left) and adjustments done on the device’s clock.
The records with adjustment values larger than 100ms, in advance or delay, were excluded from the graphics to a better representation.
The dataset of the device 3C36 with three devices network had 203 records. The path delay has mean 17.62ms, median 17.54ms and standard deviation 1.20ms, and the clock ad- justments have mean 14.64ms, median 0.51ms and standard deviation 198.86ms. The largest negative adjustment value is -483.17ms, and the largest positive value is 1,612.65ms.
After exclusion of 14 records with adjustments larger than 100ms, the delays have mean 17.66ms, median 17.53ms and standard deviation 1.14ms, and the adjustments with mean 0.83ms, median 0.51ms and standard deviation 24.61ms.
The dataset of the device 3D7E with three devices net- work has 289 records. The path delay has mean 18.52ms, median 17.54ms and standard deviation 2.55ms, and the clock adjustments have mean 3.22ms, median 0.59ms and standard
20 12 14 16 18 22 24 0 20 10 30 5 15 25 Values Incidence
3C36 − Mean path delay to the master (ms)
0 −100 −50 50 100 0 20 10 30 5 15 25 Values Incidence 3C36 − Clock adjusts (ms) 20 30 15 25 0 20 10 30 Values Incidence
3D7E − Mean path delay to the master (ms)
0 −100 −50 50 100 0 20 10 30 5 15 25 Values Incidence
3D7E − Clock adjusts (ms)
Fig. 2. Delays to the master and clock adjusts on the network with three devices.