In your Tossiom code. %%%%%%%%%%%%%%% ........ for i in range(0, 3): t.getNode(i).addNoiseTraceReading(val)
for i in range(0, 3): print "Creating noise model for ",i; t.getNode(i).createNoiseModel() for i in range(0, noOfnode): ....... %%%%%%%%%%%%%% the range of i should be (1, 4), then you will get three node 1, 2 and 3. Because your topology file describes wireless link between node 1, 2 and 3. When you create three node 0, 1 and 2, node 0 is actually out of the network, thus its packets will not be received by any of the other nodes. 2 solutions: 1, modify the topology file to contain node 0, 1 and 2 2. modify the module, to let node 1 send packets instead of node 0. On Thu, Sep 6, 2012 at 8:17 PM, wasif masood <rwmas...@gmail.com> wrote: > > try to debug it on lower layers, may be its the issue of AM_ID type. > > > On Wed, Sep 5, 2012 at 4:04 PM, rajesh mukherjee < > rajeshmukherjee....@gmail.com> wrote: > >> Hi all, >> I just simply written a code to send multiple msg & receive multiple ms >> usin AMSender & AMReceiver, in tossim simulation msg send successfully by >> Node 0 but the event receive canot happened. plz help me. >> >> he file FloodC.nc contain >> >> #include<Timer.h> >> #include"Flood.h" >> module FloodC{ >> uses interface Boot; >> uses interface Timer<TMilli> as Timer0; >> >> uses interface Packet as ReqPacket; >> uses interface Packet as ParPacket; >> uses interface Packet as RejPacket; >> uses interface AMSend as SendRequest; >> uses interface Receive as ReceiveRequest; >> uses interface Receive as ReceiveParent; >> uses interface AMSend as SendParent; >> uses interface Receive as ReceiveReject; >> uses interface AMSend as SendReject; >> uses interface AMPacket as ReqAMPacket; >> uses interface AMPacket as ParAMPacket; >> uses interface AMPacket as RejAMPacket; >> uses interface SplitControl as AMControl; >> } >> implementation { >> uint16_t parent = 0xFFFF; >> uint16_t children[50]; >> uint16_t child_count= 0; >> message_t request_pkt; >> message_t parent_pkt; >> message_t reject_pkt; >> bool busy = FALSE; >> >> event void Boot.booted(){ >> child_count=0; >> dbg("Flood","Application Booted.\n"); >> if (TOS_NODE_ID ==0){ >> parent=0; >> } >> call AMControl.start(); >> } >> >> >> event void AMControl.startDone(error_t err){ >> >> >> if (err == SUCCESS) { >> dbg("Flood","AMControl started.\n"); >> if (TOS_NODE_ID ==0){ >> call Timer0.startOneShot(2000); >> } >> } >> else { >> call AMControl.start(); >> } >> >> } >> >> >> event void AMControl.stopDone(error_t err){ >> //call Timer0.stop(); >> } >> >> >> event void Timer0.fired() { >> dbg("Flood","Timer is started"); >> if(!busy){ >> >> RequestMsg* rm = >> (RequestMsg*) (call ReqPacket.getPayload(&request_pkt, >> NULL)); >> rm -> sourceaddr = TOS_NODE_ID; >> dbg("Flood","Sending..\n"); >> if(call SendRequest.send(AM_BROADCAST_ADDR, &request_pkt, >> sizeof(RequestMsg)) == SUCCESS){ >> busy= TRUE; >> } >> } >> } >> >> >> event void SendRequest.sendDone(message_t* msg, error_t err){ >> if(&request_pkt == msg){ >> busy = FALSE; >> dbg("Flood","SendRequest done successfully.\n"); >> if(TOS_NODE_ID != 0){ >> ParentMsg* p = (ParentMsg*) (call >> ParPacket.getPayload(&parent_pkt, NULL)); >> p -> sourceaddr = TOS_NODE_ID; >> if(call SendParent.send(parent, &parent_pkt, >> sizeof(ParentMsg)) == SUCCESS){ >> busy=TRUE; >> } >> } >> } >> } >> >> >> event void SendParent.sendDone(message_t* msg, error_t err){ >> if(&parent_pkt == msg){ >> busy = FALSE; >> dbg("Flood","Parent Message successfully done"); >> } >> >> } >> >> >> event void SendReject.sendDone(message_t* msg, error_t err){ >> if(&reject_pkt == msg){ >> busy = FALSE; >> dbg("Flood","Send Reject message deliver"); >> } >> } >> >> >> event message_t* ReceiveRequest.receive(message_t* msg, void* >> payload, uint8_t len){ >> >> if ( len == sizeof(RequestMsg)){ >> >> RequestMsg* a = (RequestMsg*)payload; >> dbg("Flood","Message receive"); >> if(TOS_NODE_ID != 0){ >> if(parent == 0xFFFF){ >> parent = a->sourceaddr; >> dbg("Flood","Node: %d Parent: %d \n",TOS_NODE_ID, >> parent); >> if(!busy){ >> RequestMsg* b = >> (RequestMsg*) (call >> ReqPacket.getPayload(&request_pkt, NULL)); >> b->sourceaddr = TOS_NODE_ID; >> if(call SendRequest.send(AM_BROADCAST_ADDR, >> &request_pkt, sizeof(RequestMsg)) == SUCCESS){ >> busy = TRUE; >> } >> } >> } >> else{ >> if(!busy){ >> RejectMsg* r = (RejectMsg*) (call >> RejPacket.getPayload(&reject_pkt, NULL)); >> r -> sourceaddr = TOS_NODE_ID; >> if(call SendReject.send(AM_BROADCAST_ADDR, >> &reject_pkt, sizeof(RejectMsg)) == SUCCESS){ >> busy = TRUE; >> } >> } >> } >> } >> } >> return msg; >> } >> >> >> >> event message_t* ReceiveParent.receive(message_t* msg, void* payload, >> uint8_t len){ >> if( len == sizeof(ParentMsg)){ >> ParentMsg *p = (ParentMsg *) payload; >> int i = 0; >> children[child_count++] = p->sourceaddr; >> dbg("Flood", "Node %d's children are: \n", TOS_NODE_ID); >> for(i = 0; i < child_count; i++){ >> dbg("Flood", " %d \n", children[i]); >> } >> } >> return msg; >> } >> >> >> event message_t* ReceiveReject.receive(message_t* msg, void* payload, >> uint8_t len){ >> if( len == sizeof(RejectMsg)){ >> } >> return msg; >> } >> } >> * >> FloodAppC contain* >> >> #include <Timer.h> >> #include "Flood.h" >> >> configuration FloodAppC { >> } >> implementation { >> components MainC; >> components FloodC; >> components new TimerMilliC() as Timer0; >> components ActiveMessageC; >> components new AMSenderC(AM_REQUEST) as RequestSender; >> components new AMReceiverC(AM_REQUEST) as RequestReceiver; >> >> components new AMSenderC(AM_PARENT) as ParentSender; >> components new AMReceiverC(AM_PARENT) as ParentReceiver; >> >> components new AMSenderC(AM_REJECT) as RejectSender; >> components new AMReceiverC(AM_REJECT) as RejectReceiver; >> >> FloodC.Boot -> MainC; >> FloodC.Timer0 -> Timer0; >> >> >> FloodC.ReqPacket -> RequestSender; >> FloodC.ReqPacket -> RequestReceiver; >> FloodC.ParPacket -> ParentSender; >> FloodC.RejPacket -> RejectSender; >> >> FloodC.ReqAMPacket -> RequestSender; >> FloodC.ParAMPacket -> ParentSender; >> FloodC.RejAMPacket -> RejectSender; >> >> FloodC.AMControl -> ActiveMessageC; >> >> FloodC.SendRequest -> RequestSender; >> FloodC.SendParent -> ParentSender; >> FloodC.SendReject -> RejectSender; >> >> FloodC.ReceiveRequest -> RequestReceiver; >> FloodC.ReceiveParent -> ParentReceiver; >> FloodC.ReceiveReject -> RejectReceiver; >> } >> >> *Flood.h* >> >> #ifndef BLINKTORADIO_H >> #define BLINKTORADIO_H >> enum { >> AM_REQUEST = 4, >> AM_PARENT = 5, >> AM_REJECT = 7, >> }; >> typedef nx_struct RequestMsg { >> /* The 16-bit source node address. */ >> nx_uint16_t sourceaddr; >> } RequestMsg; >> typedef nx_struct ParentMsg { >> /* The 16-bit source node address. */ >> nx_uint16_t sourceaddr; >> } ParentMsg; >> typedef nx_struct RejectMsg{ >> nx_uint16_t sourceaddr; >> } RejectMsg; >> #endif >> * >> python code* >> >> #! /usr/bin/python >> from TOSSIM import * >> import sys >> >> t = Tossim([]) >> r = t.radio() >> f = open("topo.txt", "r") >> noOfnode =3; >> startTime =1; >> duration =6000000000000; >> >> for line in f: >> s = line.split() >> if s: >> print " ", s[0], " ", s[1], " ", s[2]; >> r.add(int(s[0]), int(s[1]), float(s[2])) >> >> >> t.addChannel("Flood", sys.stdout) >> >> noise = open("meyer-heavy.txt", "r") >> for line in noise: >> str1 = line.strip() >> if str1: >> val = int(str1) >> for i in range(0, 3): >> t.getNode(i).addNoiseTraceReading(val) >> >> for i in range(0, 3): >> print "Creating noise model for ",i; >> t.getNode(i).createNoiseModel() >> >> for i in range(0, noOfnode): >> m=t.getNode(i) >> m.bootAtTime(startTime*t.ticksPerSecond()); >> time=t.time() >> >> for i in range(0, 200000): >> t.runNextEvent(); >> >> *giving output >> *$ python test.py >> 1 2 -100.0 >> 2 1 -100.0 >> 1 3 -100.0 >> 3 1 -100.0 >> 2 3 -100.0 >> 3 2 -100.0 >> Creating noise model for 0 >> Creating noise model for 1 >> Creating noise model for 2 >> DEBUG (0): Application Booted. >> DEBUG (2): Application Booted. >> DEBUG (1): Application Booted. >> DEBUG (2): AMControl started. >> DEBUG (0): AMControl started. >> DEBUG (1): AMControl started. >> DEBUG (0): Timer is startedDEBUG (0): Sending >> DEBUG (0): SendRequest done successfully. >> >> why?? really i dont understand why receive request not occuring. >> >> Thanks in advance. >> >> >> >> >> _______________________________________________ >> Tinyos-help mailing list >> Tinyos-help@millennium.berkeley.edu >> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >> > > > > -- > Wasif Masood > > > _______________________________________________ > Tinyos-help mailing list > Tinyos-help@millennium.berkeley.edu > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >
_______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help