Hi Phil,
Gil gave me a brief explanation of Drip and If I am correct, Drip is used to efficiently disseminate packets from the Base station to the entire network. But, I want the Base station to transmit an ACK only to the source node from which it received a packet.
So, I made a some changes to the MultiHopEngineM.nc module. I now call SendMsg.send() for the ACK packet from mForward() rather than the receive handler. Also, the SendMsg.send() for the ACK packets is similar to the SendMsg.send() for data packets i.e. it does not return FAIL.
I hope I have taken care of the 2nd and 3rd problems you described. Can you please have a look and let me know if I am correct. Thanks a lot.
static TOS_MsgPtr mForward(TOS_MsgPtr pMsg, uint8_t id) {
TOS_MsgPtr pNewBuf = pMsg;
if (((iFwdBufHead + 1) % FWD_QUEUE_SIZE) == iFwdBufTail)
return pNewBuf;
if (TOS_LOCAL_ADDRESS !=0) {
if ((call RouteSelect.selectRoute(pMsg,id)) != SUCCESS) {
return pNewBuf;
}
}
if (TOS_LOCAL_ADDRESS !=0) {
if (call SendMsg.send[id](pMsg->addr,pMsg->length,pMsg) == SUCCESS) {
pNewBuf = FwdBufList[iFwdBufHead];
FwdBufList[iFwdBufHead] = pMsg;
iFwdBufHead++; iFwdBufHead %= FWD_QUEUE_SIZE;
}
}
else if (TOS_LOCAL_ADDRESS == 0) {
if (call SendMsg.send[id](pMsg->addr, pMsg->length, pMsg) == SUCCESS) {
pNewBuf = FwdBufList[iFwdBufHead];
FwdBufList[iFwdBufHead] = pMsg;
iFwdBufHead++; iFwdBufHead %= FWD_QUEUE_SIZE;
}
return pNewBuf;
TOS_MsgPtr pNewBuf = pMsg;
if (((iFwdBufHead + 1) % FWD_QUEUE_SIZE) == iFwdBufTail)
return pNewBuf;
if (TOS_LOCAL_ADDRESS !=0) {
if ((call RouteSelect.selectRoute(pMsg,id)) != SUCCESS) {
return pNewBuf;
}
}
if (TOS_LOCAL_ADDRESS !=0) {
if (call SendMsg.send[id](pMsg->addr,pMsg->length,pMsg) == SUCCESS) {
pNewBuf = FwdBufList[iFwdBufHead];
FwdBufList[iFwdBufHead] = pMsg;
iFwdBufHead++; iFwdBufHead %= FWD_QUEUE_SIZE;
}
}
else if (TOS_LOCAL_ADDRESS == 0) {
if (call SendMsg.send[id](pMsg->addr, pMsg->length, pMsg) == SUCCESS) {
pNewBuf = FwdBufList[iFwdBufHead];
FwdBufList[iFwdBufHead] = pMsg;
iFwdBufHead++; iFwdBufHead %= FWD_QUEUE_SIZE;
}
return pNewBuf;
}
---------------------------------------------------------------------------------------------------------------------------------------
event TOS_MsgPtr ReceiveMsg.receive[uint8_t id](TOS_MsgPtr pMsg) {
TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)pMsg->data;
uint16_t PayloadLen = pMsg->length - offsetof(TOS_MHopMsg,data);
TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)pMsg->data;
uint16_t PayloadLen = pMsg->length - offsetof(TOS_MHopMsg,data);
// Ordinary message requiring forwarding
if (pMsg->addr == TOS_LOCAL_ADDRESS) { // Addressed to local node
if ((signal Intercept.intercept[id](pMsg,&pMHMsg->data[0],PayloadLen)) == SUCCESS) {
if ((TOS_LOCAL_ADDRESS != 0) && (pMHMsg->originaddr != TOS_LOCAL_ADDRESS)) {
pMsg = mForward(pMsg,id);
}
else if (TOS_LOCAL_ADDRESS == 0) {
pMHMsg->sourceaddr = TOS_LOCAL_ADDRESS;
pMsg->addr = pMHMsg->originaddr;
pMsg = mForward(pMsg,id);
}
}
}
else {
// Snoop the packet for permiscuous applications
// dbg(DBG_ROUTE,"MHop: Snooping :)");
signal Snoop.intercept[id](pMsg,&pMHMsg->data[0],PayloadLen);
}
return pMsg;
if (pMsg->addr == TOS_LOCAL_ADDRESS) { // Addressed to local node
if ((signal Intercept.intercept[id](pMsg,&pMHMsg->data[0],PayloadLen)) == SUCCESS) {
if ((TOS_LOCAL_ADDRESS != 0) && (pMHMsg->originaddr != TOS_LOCAL_ADDRESS)) {
pMsg = mForward(pMsg,id);
}
else if (TOS_LOCAL_ADDRESS == 0) {
pMHMsg->sourceaddr = TOS_LOCAL_ADDRESS;
pMsg->addr = pMHMsg->originaddr;
pMsg = mForward(pMsg,id);
}
}
}
else {
// Snoop the packet for permiscuous applications
// dbg(DBG_ROUTE,"MHop: Snooping :)");
signal Snoop.intercept[id](pMsg,&pMHMsg->data[0],PayloadLen);
}
return pMsg;
}
I am now working towards implementing a multi-hop propogation for the ACK packet. Since, I have static routes in my network, I may be able to take advantage of it. Can you please let me know if the 2nd and 3rd problem you described has been resolved with the changes I made.
Thanks,
Yogesh.
Philip Levis <[EMAIL PROTECTED]> wrote:
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'
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
_______________________________________________ Tinyos-users mailing list [email protected] http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-users
