Dear sir
I am a student of BE in computer sc. I am doing my project in TinyOS using
TOSSIM. I am in bit confusion. First i ll briefly explain the project please
guide me how to do it.
We follow Clustered WSN where in base station sends encrypted packets to
cluster
heads in turn cluster head sends packets to sensor nodes. For encryption we use
RC5 and hashing we use SHA1.
But the problem is that i am facing problem in creating the CLUSTER. i could
able to send message to cluster head as and when timer fires but when cluster
heads recieves the msg i need to broad cast the msg so that sensornodes belongs
to that cluster only proceesos it. how can i achieve it.
one more problem is that for sendMsg interface i need to send TOS_MSG messages
but how can i append the hashed value?
I have attached my module code here please check out. in this i considered all
nodes multiples of 10 as cluster heads.
and inform me whether there is anything that i can broadcast messages to only
nodes belong to some range.
please help me regarding this.
Thank you
Yogesh BG
includes RingMessage;
module RingM
{
provides interface StdControl;
uses interface SendMsg;
uses interface ReceiveMsg;
uses interface Random;
uses interface Timer;
}
implementation{
TOS_Msg tos_msg_buf;
TosMsg* send_buf;
TosMsg msg_buf;
uint8_t dest;
uint8_t NODE1;
int r;
uint8_t a;
int hop;
task void BSendCMsg()
{
send_buf = (TosMsg*)tos_msg_buf.data;
send_buf->src = msg_buf.src;
send_buf->seqNo = msg_buf.seqNo;
dbg(DBG_USR1,"destttttttttt %d",dest);
if((call
SendMsg.send(dest, sizeof(TosMsg), &tos_msg_buf)) != SUCCESS)
{
dbg(DBG_USR1,
"SEND MSG FAIL in 0\n");
}
dest=dest+10;
if(dest>NODE1)
{
hop++;
//call Timer.stop();
// call Timer.start(TIMER_REPEAT, 500);
}
}
task void BcastMsg()
{
send_buf = (TosMsg*)tos_msg_buf.data;
send_buf->src = msg_buf.src;
send_buf->seqNo = msg_buf.seqNo;
if(TOS_LOCAL_ADDRESS==1 ||
TOS_LOCAL_ADDRESS==11 ||TOS_LOCAL_ADDRESS==21)
{
if((call
SendMsg.send(TOS_BCAST_ADDR, sizeof(TosMsg), &tos_msg_buf)) != SUCCESS)
{
dbg(DBG_USR1,
"SEND MSG FAIL in 0\n");
}
}
}
command result_t StdControl.init()
{
NODE1=30;
dest=1;
hop=0;
return SUCCESS;
}
command result_t StdControl.start()
{
call Timer.start(TIMER_REPEAT, 500);
return SUCCESS;
}
command result_t StdControl.stop()
{
// call Timer.stop();
return SUCCESS;
}
event result_t Timer.fired()
{
if(hop==0)
{
msg_buf.src = TOS_LOCAL_ADDRESS;
if(TOS_LOCAL_ADDRESS==0)
{
msg_buf.src=TOS_LOCAL_ADDRESS;
post BSendCMsg();
}
}
return SUCCESS;
}
event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success)
{
//call StdControl.stop();
dbg(DBG_USR1,"SENDING DONE\n");
return SUCCESS;
}
event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr m)
{
TosMsg* data_buf = (TosMsg*)m->data;
msg_buf.src = data_buf->src;
msg_buf.seqNo = data_buf->seqNo;
//post BcastMsg();
atomic{
if(msg_buf.src!=0)
{
a=TOS_LOCAL_ADDRESS;
r=a % 10;
a=a - r;
a++;
if(msg_buf.src== a) dbg(DBG_USR1,"I RECIEVED SUCCESSFULLY from
%d\n",a);
}
}
return m;
}
}_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help