[Tinyos-devel] Re: [Tinyos Core WG] time sync interfaces
Philip Levis
pal at cs.stanford.edu
Thu Dec 13 10:38:04 PST 2007
On Dec 13, 2007, at 10:29 AM, David Gay wrote:
>>
>
> This also has the disadvantage that the corresponding 1.x interface
> had: excessive processing in a lastTouch implementation can break the
> radio stack, i.e. on some radio stacks the place where lastTouch would
> be called is very timing sensitive. "Excessive processing" may not be
> much processing btw (I think the example from 1.x involved a few
> 32-bit arithmetic operations).
>
> An alternate proposal would be:
>
> interface PacketTimeSync
> {
> async event int8_t isTimeSyncPacket();
> }
>
> which would be:
> - offered as a parameterized-by-amid interface (like PacketLastTouch)
> - called from the radio stack at the "last possible moment"
> - if isTimeSyncPacket returns -1, nothing happens
> - if isTimeSyncPacket returns X (>= 0), a time stamp is stuffed in the
> packet at offset X
>
> The idea is:
> - to make it easy to only put time stamps in some packets, with no
> header overhead
> - to discourage users from doing anything fancy within a critical part
> of a radio stack - normally they should just do something like return
> a constant (or maybe a variable's value) from isTimeSyncPacket - this
> is why there's no message_t parameter...
>
> There's a few obvious issues:
> - what's the width/precision/etc of the timestamp (maybe
> PacketTimeSync should be a generic interface, with appropriate type
> parameters, presumably matching the radio stack's PacketTimeStamping
> interface)
> - how do you get the right offset in isTimeSyncPacket?
> - isTimeSyncPacket could be split into two events (one for the
> question, the other for the offset)
>
This is getting closer, I think, but it embedding the timestamp at an
arbitrary offset is not feasible for many packet-based radios. That
is, if you have to spool the packet to the radio prior to
transmission, it's often easy to append a few bytes, but changing
bytes early in the packet could be problematic. So if it were
interface PacketTimeSync {
async event bool isTimeSyncPacket();
}
that might work better.
All of David's comments on arbitrary event handlers are well taken;
Sam beat his head against this problem for a week in TinyDB (shifting
from a 16-bit to 32-bit timestamp caused the stack to fail), and
Jeongyeup Paek re-encountered the exact same problem recently (Nov 4.
to -help).
Phil
More information about the Tinyos-devel
mailing list