[Tinyos-devel] Re: [Tinyos Core WG] time sync interfaces

Philip Levis pal at cs.stanford.edu
Wed Dec 12 11:09:09 PST 2007


On Nov 4, 2007, at 2:24 PM, Miklos Maroti wrote:

> Dear All,
>
> I put together a proposal for the time sync interface for T2....
>
>
> interface PacketTimeStamp<precision_tag, size_type> {
>   async command bool isSet(message_t* msg);
>   async command size_type get(message_t* msg);
>   async command void clear(message_t* msg);
>   async command void set(message_t* msg, size_type value);
> }
>
> interface PacketTimeSynch<precision_tag, size_type> {
>   async command void set(message_t* msg, size_type eventTime);
>   async command bool isSet(message_t* msg);
>   async command size_type get(message_t* msg);
> }
>


(Please note I've removed most of Miklos' commentary and the comments  
from the interfaces for the sake of brevity. The complete message was  
sent to the core WG list on November 4th[1].)

PacketTimeStamp seems pretty reasonable. It's going to require  
size_type + 1 bits of information in the message_metadata_t  
structure. As long as we pack the bit in a current metadata field,  
that's OK. Also, the bit is only necessary for radio stack  
implementations that cannot assure a timestamp due to hardware issues  
(e.g., RF230). For chips that can assure timestamps, all you need are  
the metadata fields. The isSet is also useful because radio stacks  
that can't get timestamps (or don't want to) and always just return  
FALSE. Furthermore, as this value is completely local, it's an OS/ 
system thing and not a networking issue.

PacketTimeSynch is a bit tougher, as it actually embeds a sender  
timestamp in a packet. This has two basic issues:

   1) How do you tell if the packet has a timestamp?
   2) How do nodes running different applications agree on the  
timestamp precision?

The simplest answer to 1) is to say *all* packets have timestamps in  
them. But this introduces a cost for every packet. If most packets  
don't want timestamps, it's wasteful. Otherwise, we need a header  
field that denotes whether there is a timestamp embedded in the  
footer. If most packets don't need timestamps, then the cost of this  
header is less than the cost of putting the time stamp in every  
packet. Adding this header byte would require changing active message  
implementations.

The issue with 2) is that you might have 2 different TinyOS apps/ 
platforms, one of which puts 32kHz timestamps, the other puts 1kHz  
timestamps. There are a couple of solutions here:

   1) Define the precision and width for standard AM packets.
   2) Make a packet header describe the timestamp (e.g., bits for  
width, bits for precision)
   3) Define the standard width and leave the precision to an out-of- 
band mechanism

By 3, I mean that nodes send timestamps of a given standard width  
back and forth, but to find out what the precision time unit is, a  
node needs to exchange a separate time stamp discovery packet with  
another. E.g., query it for what the precision is. The exact workings  
of that protocol aren't too relevant here.

Phil




[1] http://mail.millennium.berkeley.edu/pipermail/tinyos-2.0wg/2007- 
November/003172.html


More information about the Tinyos-devel mailing list