On Jan 4, 2005, at 11:30 PM, Yogesh Iyer wrote:

Hi,

I was able to implement end-to-end acknowledgements in TOSSIM by making the following changes in the ReceiveMsg.receive() function of the MultiHopEngineM.nc routing module. Guess I wont be needing BCast or Drip now. Thanks for your time and suggestions.

if (pMsg->addr == TOS_LOCAL_ADDRESS) { // Addressed to all nodes
����if ((signal Intercept.intercept[id](pMsg,&pMHMsg->data[0],PayloadLen)) == SUCCESS) {
���������if ((TOS_LOCAL_ADDRESS != 0) && (pMHMsg->sourceaddr != 0)) { // All nodes except node 0 forward�packets�and only when the source address is not node 0
���������������pMsg = mForward(pMsg,id);
���������}
���������else if (TOS_LOCAL_ADDRESS == 0) { // If packet is received�by node 0, it will call the SendMsg.send() function with the source node�as the destination address
�������������� pMHMsg->sourceaddr�= TOS_LOCAL_ADDRESS;
���������������if (call SendMsg.send[id](pMHMsg->originaddr, pMsg->length,pMsg) !=SUCCESS) {
�������� ����������� return FAIL;
������������ � }
�������� }
����}
}



This may seem to work in simple cases, but is very fragile and buggy. Drip is a much better approach. Three problems:


1) Calling SendMsg.send assumes that the node you wish to send the ACK to is a single hop away (SendMsg is a single-hop AM send). Therefore, while it's technically end-to-end, it's only so when you're talking about a single hop path.

2) Returning FAIL when the signaler expects a TOS_MsgPtr is a recipe for disaster. You're passing a null pointer. The first time the SendMsg.send fails, bad things will happen.

3) More generally, calling SendMsg.send in a receive handler is an insidious bug. The issue is that the buffer you're passing to send is also the buffer you're returning to the radio stack to receive the next packet in. This means that if the node receives a new packet before it sends (e.g., the channel was busy with the next packet so the MAC backed off), then the reception will overwrite the buffer you want to send. You'll send what you just received, rather than what you want to send.

Phil




-------

"We shall not cease from exploration
And the end of all our exploring
Will be to arrive where we started
And know the place for the first time."

- T. S. Eliot,  'Little Gidding'

_______________________________________________
Tinyos-users mailing list
[email protected]
http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-users

Reply via email to