[Tinyos-devel] purpose of the Packet.clear() function

Philip Levis pal at cs.stanford.edu
Mon Oct 8 11:54:12 PDT 2007


On Oct 7, 2007, at 6:57 PM, Razvan Musaloiu-E. wrote:

> Hi!
>
> Is there a strong argument for the existence of the Packet.clear()?  
> The function is implemented by CC1000, XE1205 and TDA5250 but it is  
> only used in the PacketParrot application.
>

When I wrote the interface, it seemed pretty obvious that you might  
need to be able to clear out a packet, e.g., so you don't get strange  
metadata flow-over. That being said, this hasn't yet emerged as a big  
deal, so the command never received much attention and nobody thought  
deeply about it. I think the direction this discussion is going  
sounds right: currently, clear() is problematic as it clears the  
payload: rather than a deep clean, it should only apply to headers,  
footers, and metadata for the called layer and those below. That is,  
clear works like this:

<---cleared---| payload |---cleared--->

Note that you want to call this on the *outgoing* layer, not the  
incoming one. That way, you can do a

void* inPayload, outPayload;

memcpy(outPayload, inPayload, sizeof(payload));
call OutPacket.clear(msg);

There is one issue with this, though: a component may not know if it  
bridges to separate layers. All it sees are Send, AMSend, and  
Receive. Properly handling network interface bridging requires you  
always do this, unless you are operating at the AM layer, where you  
can just do the clear and don't need to do the memcpy/clear. You  
can't make clear() part of every send because you might have pre-send  
configuration (e.g., tx power, etc.).

Phil




More information about the Tinyos-devel mailing list