[Tinyos-devel] purpose of the Packet.clear() function
koepke at tkn.tu-berlin.de
Mon Oct 8 02:23:48 PDT 2007
Miklos Maroti wrote:
>>In the meta data of the packet, there is no other way. I just change the
>> ack field to WAS_(NOT_)ACKED when I pass the packet up. The PacketAck
>>interface changes this to (NO_)ACK_REQUESTED. The Mac can now detect
>>when a user forgot to set the ack field and assumes ACK_REQUESTED.
> Then if the user uses a packet that came from the serial interface
> whose metadata layout is completely different from yours, then what do
> you do? You cannot trust the metadata when the AMSend.send() is
> called, so you get unpredicted results! Forexample the user does not
> know about acks, never needed to set them because you smart MAC is
> always doing it for him, then he will be suprised if somehow he gets
> to own a message buffer that is ill formated, i.e. it appears that
> acks were not requested. See my point? People should call Packet.clear
> every time they send a message!
How many protocols and function calls did you design? In how many cases
were you safe to rely on (other!) users to ensure your preconditions,
especially when you did not express them? Because that is the case here.
AMSend does express preconditions, but mentions no meta data that the
user must set properly. So the protocol stack must make sure that it
works and gives reliable results even if the fields in the meta data
The result may be different from what the user intended. But that is
something different from "unpredictable". Once the user stops to think
about what he intended, he can express it. It is a pretty hard job to
make sure that computers always do what the user might have intended,
computers usually do what the user told them to do. If these two things
are not the same we call it a bug.
More information about the Tinyos-devel