[Tinyos-help] TOSSIM Mica1, Mica2 Radios bug?
Vinai Sundaram
vinaisundaram at gmail.com
Wed Jul 5 17:52:26 PDT 2006
Hi all,
I found that TOSSIM Mica1 and Mica2 radios lose packets in a particular
scenario even when there is no lossy model used. The scenario is one
mote broadcasts a request message and all the receivers sends a reply
message to the sender. In this scenario, some of the reply messages sent
by the receivers are lost in the network even though sendDone() gets
called for all senders. I have attached a sample program and makefile
that demonstrates the bug. In mica1 radio the number of motes required
to cause message loss is 21 while in mica2 radio, it is only 15 motes.
In real program that we implemented where there several other events, as
small as 7 motes can cause the same problem for both radios.
I traced the bug in Mica2 radio to two motes sending at the same time
and as a result, the messages gets garbled. However, sendDone() gets
called for both the senders with result 1(success) even though no motes
received that message.
Anyone knows a solution or work around for this bug?
Thank you,
Vinai.
-------------- next part --------------
COMPONENT=MsgLoss
# To use Mica2 Radio, uncomment next line
PFLAGS += -I%T/platform/pc/CC1000Radio
# To use Packet-level Radio, uncomment next line
#PFLAGS+= -I%T/platform/pc/packet
include ../Makerules
-------------- next part --------------
/**
File: MsgLoss.nc
Author: Vinai Sundaram ( vsundar at purdue dot edu )
Description:
The goal of this application is to determine the message loss \
when several motes send message to the same receiver in TOSSIM \
using mica, and mica2 radios.
Note: Packet-level radio doesn't experience packet loss.
*/
configuration MsgLoss {
}
implementation {
components Main, GenericComm as Comm, MsgLossM, SysTimeC ;
Main.StdControl -> Comm;
Main.StdControl -> MsgLossM;
MsgLossM.CommSend -> Comm.SendMsg[1];
MsgLossM.CommReceive -> Comm.ReceiveMsg[1];
MsgLossM.SysTime -> SysTimeC;
}
-------------- next part --------------
/**
File: MsgLossM.nc
Author: Vinai Sundaram ( vsundar at purdue dot edu )
Description:
This file describes the MsgLossM module.
*/
module MsgLossM {
provides {
interface StdControl;
}
uses {
interface SendMsg as CommSend;
interface ReceiveMsg as CommReceive;
interface SysTime;
}
}
implementation {
uint8_t count;
uint16_t dstAddr;
TOS_Msg sendBuf; // for sending out messages
struct SampleMsg {
uint8_t senderID;
uint32_t sendTime;
uint32_t recvTime;
};
command result_t StdControl.init( ) {
count = 0;
dstAddr = TOS_BCAST_ADDR;
return SUCCESS;
}
command result_t StdControl.start( ) {
struct SampleMsg* msg1;
// Only node 0 sends a message
if ( TOS_LOCAL_ADDRESS == 0 ) {
msg1 = (struct SampleMsg *) sendBuf.data;
msg1->senderID = TOS_LOCAL_ADDRESS;
msg1->sendTime = call SysTime.getTime32();
if ( call CommSend.send( dstAddr , sizeof( struct SampleMsg), &sendBuf ) == FAIL ) {
dbg( DBG_USR1, "Control.start: send failed\n" );
}
}
return SUCCESS;
}
command result_t StdControl.stop( ) {
return SUCCESS;
}
event result_t CommSend.sendDone( TOS_MsgPtr m, result_t res ) {
dbg( DBG_USR1, "sendDone: called with result = %i and count: %i \n", (int)res, (int)count );
return SUCCESS;
}
task void sendAckTask( ) {
struct SampleMsg *ackMsg = (struct SampleMsg*) sendBuf.data;
ackMsg->senderID = TOS_LOCAL_ADDRESS;
ackMsg->sendTime = call SysTime.getTime32();
if ( call CommSend.send( dstAddr , sizeof( struct SampleMsg), &sendBuf ) == FAIL ) {
dbg( DBG_USR1, "send failed when sending recv Ack\n" );
}
dbg( DBG_USR1, "send posted successfully \n");
}
event TOS_MsgPtr CommReceive.receive( TOS_MsgPtr m ) {
struct SampleMsg* msg1 = (struct SampleMsg*) m->data;
msg1->recvTime = call SysTime.getTime32( );
dstAddr = msg1->senderID;
dbg( DBG_USR1, "Msg received: addressed to:%x length:%i senderID:%i sendTime:%ld recvTime:%d\n",m->addr, m->length, msg1->senderID, msg1->sendTime, msg1->recvTime );
if ( TOS_LOCAL_ADDRESS != 0 ) {
post sendAckTask( );
}
return m;
}
}
-------------- next part --------------
To compile and execute the files, follow these simple steps:
1. Create a directory called MsgLoss under your tinyos-1.x/apps/ directory.
2. Copy the files there.
3. Issue command: $ make pc
4. To try mica2 radio or packet radio, uncomment the appropriate line in Makefile and do step 3
5. To exceute, turn on the DBG mode usr1. Issue command $build/pc/main.exe
Sample command to run for 21 motes is
$ export DBG=usr1; build/pc/main.exe -b=0 -seed=1 -t=1 21
6. For questions, contact me at vsundar at purdue dot edu
More information about the Tinyos-help
mailing list