[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/lqi CollectionC.nc, 1.2, 1.3 LqiForwardingEngineP.nc, 1.2, 1.3 LqiRoutingEngineP.nc, 1.2, 1.3 MultiHopLqi.h, 1.1, 1.2 MultiHopLqiP.nc, 1.2, 1.3

Phil Levis scipio at users.sourceforge.net
Thu Apr 12 17:10:50 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/lqi
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32062

Modified Files:
	CollectionC.nc LqiForwardingEngineP.nc LqiRoutingEngineP.nc 
	MultiHopLqi.h MultiHopLqiP.nc 
Log Message:
Instrumented.


Index: CollectionC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/lqi/CollectionC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CollectionC.nc	7 Apr 2007 01:58:05 -0000	1.2
--- CollectionC.nc	13 Apr 2007 00:10:48 -0000	1.3
***************
*** 49,52 ****
--- 49,54 ----
      interface RootControl;
    }
+   uses interface CollectionDebug;
+   
  }
  
***************
*** 66,68 ****
--- 68,72 ----
    Intercept =   Router.Intercept;
    CollectionPacket = Router;
+ 
+   Router.CollectionDebug = CollectionDebug;
  }

Index: LqiForwardingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/lqi/LqiForwardingEngineP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LqiForwardingEngineP.nc	12 Apr 2007 22:42:02 -0000	1.2
--- LqiForwardingEngineP.nc	13 Apr 2007 00:10:48 -0000	1.3
***************
*** 79,82 ****
--- 79,83 ----
  #include "AM.h"
  #include "MultiHopLqi.h"
+ #include "CollectionDebugMsg.h"
  
  module LqiForwardingEngineP {
***************
*** 104,107 ****
--- 105,109 ----
      interface Random;
      interface PacketAcknowledgements;
+     interface CollectionDebug;
    }
  }
***************
*** 156,164 ****
      len += sizeof(lqi_header_t);
      if (len > call SubPacket.maxPayloadLength()) {
-       call Leds.led0On();
        return ESIZE;
      }
      if (call RootControl.isRoot()) {
-       call Leds.led1On();
        return FAIL;
      }
--- 158,164 ----
***************
*** 166,170 ****
      
      if (call RouteSelect.selectRoute(pMsg, 0) != SUCCESS) {
-       call Leds.led2On();
        return FAIL;
      }
--- 166,169 ----
***************
*** 205,212 ****
--- 204,215 ----
  
    static char* fields(message_t* msg) {
+ #ifdef TOSSIM
      static char mbuf[1024];
      lqi_header_t* hdr = getHeader(msg);
      sprintf(mbuf, "origin = %hu, seqno = %hu, oseqno = %hu, hopcount =%hu", hdr->originaddr, hdr->seqno, hdr->originseqno, hdr->hopcount);
      return mbuf;
+ #else
+     return NULL;
+ #endif
    }
  
***************
*** 215,226 ****
    static message_t* mForward(message_t* msg) {
      int8_t buf = get_buff();
-     call Leds.led2Toggle();
      dbg("LQI", " Asked to forward packet @%s:\t%s\n", sim_time_string(), fields(msg));
      if (buf == -1) {
        dbg("LQI", "%s Dropped packet due to no space in queue.\n", __FUNCTION__);
        return msg;
      }
      if ((call RouteSelect.selectRoute(msg, 0)) != SUCCESS) {
        FwdBufBusy[(uint8_t)buf] = 0;
        dbg("LQI", "%s Dropped packet due to no route.\n", __FUNCTION__);
        return msg;
--- 218,230 ----
    static message_t* mForward(message_t* msg) {
      int8_t buf = get_buff();
      dbg("LQI", " Asked to forward packet @%s:\t%s\n", sim_time_string(), fields(msg));
      if (buf == -1) {
        dbg("LQI", "%s Dropped packet due to no space in queue.\n", __FUNCTION__);
+       call CollectionDebug.logEvent(NET_C_FE_SEND_QUEUE_FULL);
        return msg;
      }
      if ((call RouteSelect.selectRoute(msg, 0)) != SUCCESS) {
        FwdBufBusy[(uint8_t)buf] = 0;
+       call CollectionDebug.logEvent(NET_C_FE_NO_ROUTE);
        dbg("LQI", "%s Dropped packet due to no route.\n", __FUNCTION__);
        return msg;
***************
*** 258,266 ****
  
      if (call RootControl.isRoot()) {
!       dbg("LQI", "LQI Root is receiving packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
        return signal Receive.receive[id](msg, payload, len);
      }
      else if (signal Intercept.forward[id](msg, payload, len)) {
!       dbg("LQI", "LQI fwd is forwarding packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
        return mForward(msg);
      }
--- 262,270 ----
  
      if (call RootControl.isRoot()) {
!       dbg("LQI,LQIDeliver", "LQI Root is receiving packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
        return signal Receive.receive[id](msg, payload, len);
      }
      else if (signal Intercept.forward[id](msg, payload, len)) {
!       dbg("LQI,LQIDeliver", "LQI fwd is forwarding packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
        return mForward(msg);
      }
***************
*** 294,299 ****
--- 298,311 ----
  			    call SubPacket.payloadLength(msg)) == SUCCESS) {
  	dbg("LQI", "Packet not acked, retransmit:\t%s\n", fields(msg));
+         call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_WAITACK, 
+ 					 call CollectionPacket.getSequenceNumber(msg), 
+ 					 call CollectionPacket.getOrigin(msg), 
+                                          call AMPacket.destination(msg));
  	fail_count ++;
        } else {
+ 	call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL, 
+ 					 call CollectionPacket.getSequenceNumber(msg), 
+ 					 call CollectionPacket.getOrigin(msg), 
+                                          call AMPacket.destination(msg));
  	dbg("LQI", "Packet not acked, retransmit fail:\t%s\n", fields(msg));
  	sendFailures++;
***************
*** 301,308 ****
--- 313,328 ----
      }
      else if (fail_count >= 5) {
+       call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL_ACK_FWD, 
+ 				       call CollectionPacket.getSequenceNumber(msg), 
+ 				       call CollectionPacket.getOrigin(msg), 
+ 				       call AMPacket.destination(msg));
        dbg("LQI", "Packet failed:\t%s\n", fields(msg));
      }
      else if (call PacketAcknowledgements.wasAcked(msg)) {
        dbg("LQI", "Packet acked:\t%s\n", fields(msg));
+       call CollectionDebug.logEventMsg(NET_C_FE_FWD_MSG, 
+ 				       call CollectionPacket.getSequenceNumber(msg), 
+ 				       call CollectionPacket.getOrigin(msg), 
+ 				       call AMPacket.destination(msg));
      }
      
***************
*** 333,343 ****
  			    call SubPacket.payloadLength(msg)) == SUCCESS) {
  	dbg("LQI", "Packet not acked, retransmit:\t%s\n", fields(msg));
  	fail_count ++;
        } else {
  	dbg("LQI", "Packet not acked, retransmit fail:\t%s\n", fields(msg));
  	sendFailures++;
        }
      }
!     
      fail_count = 0;
      signal Send.sendDone(msg, success);
--- 353,385 ----
  			    call SubPacket.payloadLength(msg)) == SUCCESS) {
  	dbg("LQI", "Packet not acked, retransmit:\t%s\n", fields(msg));
+ 	call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_WAITACK, 
+ 					 call CollectionPacket.getSequenceNumber(msg), 
+ 					 call CollectionPacket.getOrigin(msg), 
+                                          call AMPacket.destination(msg));
  	fail_count ++;
        } else {
+ 	call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL, 
+ 					 call CollectionPacket.getSequenceNumber(msg), 
+ 					 call CollectionPacket.getOrigin(msg), 
+                                          call AMPacket.destination(msg));
  	dbg("LQI", "Packet not acked, retransmit fail:\t%s\n", fields(msg));
  	sendFailures++;
        }
      }
!     else if (fail_count >= 5) {
!       call CollectionDebug.logEventMsg(NET_C_FE_SENDDONE_FAIL_ACK_SEND, 
! 				       call CollectionPacket.getSequenceNumber(msg), 
! 				       call CollectionPacket.getOrigin(msg), 
! 				       call AMPacket.destination(msg));
!       dbg("LQI", "Packet failed:\t%s\n", fields(msg));
!     }
!     else if (call PacketAcknowledgements.wasAcked(msg)) {
!       dbg("LQI", "Packet acked:\t%s\n", fields(msg));
!       call CollectionDebug.logEventMsg(NET_C_FE_SENT_MSG, 
! 				       call CollectionPacket.getSequenceNumber(msg), 
! 				       call CollectionPacket.getOrigin(msg), 
! 				       call AMPacket.destination(msg));
!     }
! 
      fail_count = 0;
      signal Send.sendDone(msg, success);

Index: LqiRoutingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/lqi/LqiRoutingEngineP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LqiRoutingEngineP.nc	12 Apr 2007 22:42:02 -0000	1.2
--- LqiRoutingEngineP.nc	13 Apr 2007 00:10:48 -0000	1.3
***************
*** 38,41 ****
--- 38,42 ----
  
  #include "MultiHopLqi.h"
+ #include "CollectionDebugMsg.h"
  
  module LqiRoutingEngineP {
***************
*** 59,62 ****
--- 60,64 ----
      interface CC2420Packet;
      interface Leds;
+     interface CollectionDebug;
    }
  }
***************
*** 150,153 ****
--- 152,156 ----
      if (call AMSend.send(TOS_BCAST_ADDR, &msgBuf, length) == SUCCESS) {
        msgBufBusy = TRUE;
+       call CollectionDebug.logEventRoute(NET_C_TREE_SENT_BEACON, bMsg->parent, 0, bMsg->cost);
      }
    }
***************
*** 196,199 ****
--- 199,203 ----
    command error_t RootControl.setRoot() {
      call Leds.led2On();
+     call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, TOS_NODE_ID, 0, 0);
      isRoot = TRUE;
      return SUCCESS;
***************
*** 236,239 ****
--- 240,244 ----
          if ((gRecentPacketSender[i] == call AMPacket.source(msg)) &&
              (gRecentPacketSeqNo[i] == hdr->seqno)) {
+ 	  call CollectionDebug.logEvent(NET_C_FE_DUPLICATE_CACHE_AT_SEND);
  	  dbg("LQI", "%s no route as this is a duplicate!\n", __FUNCTION__);
            return FAIL;
***************
*** 324,339 ****
  
    event void Timer.fired() {
      post TimerTask();
!     call Timer.startOneShot(1024 * gUpdateInterval + 1);
    }
  
    event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) {
      if (isRoot) {
        return msg;
      }
      else {
-       lqi_beacon_msg_t* bMsg = (lqi_beacon_msg_t*)payload;
-       am_addr_t source = call AMPacket.source(msg);
-       uint8_t lqi = call CC2420Packet.getLqi(msg);
        dbg("LQI,LQIRoute", "LQI receiving routing beacon from %hu with LQI %hhu that advertises %hu.\n", source, lqi, bMsg->cost);
        if (source == gbCurrentParent) {
--- 329,348 ----
  
    event void Timer.fired() {
+     call Leds.led0Toggle();
      post TimerTask();
!     call Timer.startPeriodic(1024 * gUpdateInterval + 1);
    }
  
    event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) {
+     lqi_beacon_msg_t* bMsg = (lqi_beacon_msg_t*)payload;
+     am_addr_t source = call AMPacket.source(msg);
+     uint8_t lqi = call CC2420Packet.getLqi(msg);
+     
+     call CollectionDebug.logEventRoute(NET_C_TREE_RCV_BEACON, source, 0, bMsg->cost);
+     
      if (isRoot) {
        return msg;
      }
      else {
        dbg("LQI,LQIRoute", "LQI receiving routing beacon from %hu with LQI %hhu that advertises %hu.\n", source, lqi, bMsg->cost);
        if (source == gbCurrentParent) {
***************
*** 373,376 ****
--- 382,386 ----
  	  gbCurrentLinkEst = adjustLQI(lqi);	
  	  gbCurrentHopCount = bMsg->hopcount + 1;
+ 	  call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, gbCurrentParent, 0, gbCurrentParentCost + gbCurrentLinkEst);
  	  dbg("LQI,LQIRoute", "  -- Not a cycle.\n");
  	}

Index: MultiHopLqi.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/lqi/MultiHopLqi.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MultiHopLqi.h	7 Apr 2007 01:58:05 -0000	1.1
--- MultiHopLqi.h	13 Apr 2007 00:10:48 -0000	1.2
***************
*** 93,96 ****
--- 93,97 ----
    AM_LQI_BEACON_MSG = 250,
    AM_LQI_DATA_MSG = 251,
+   AM_LQI_DEBUG = 22,
    AM_LQI_DEBUG_PACKET = 3,
    NUM_LQI_CLIENTS = uniqueCount(UQ_LQI_CLIENT),

Index: MultiHopLqiP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/lqi/MultiHopLqiP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MultiHopLqiP.nc	12 Apr 2007 22:42:02 -0000	1.2
--- MultiHopLqiP.nc	13 Apr 2007 00:10:48 -0000	1.3
***************
*** 79,82 ****
--- 79,84 ----
    }
  
+   uses interface CollectionDebug;
+ 
  }
  
***************
*** 100,104 ****
    
    components CC2420ActiveMessageC as CC2420;
! 
    StdControl = Router.StdControl;
    
--- 102,106 ----
    
    components CC2420ActiveMessageC as CC2420;
!   
    StdControl = Router.StdControl;
    
***************
*** 112,116 ****
    CollectionPacket = Forwarder;
    RootControl = Router;
!  
    Forwarder.RouteSelectCntl -> Router.RouteControl;
    Forwarder.RouteSelect -> Router;
--- 114,120 ----
    CollectionPacket = Forwarder;
    RootControl = Router;
! 
!   //CC2420.SubPacket -> DataSender;
!   
    Forwarder.RouteSelectCntl -> Router.RouteControl;
    Forwarder.RouteSelect -> Router;
***************
*** 124,127 ****
--- 128,132 ----
    Forwarder.RootControl -> Router;
    Forwarder.Random -> RandomC;
+   Forwarder.CollectionDebug = CollectionDebug;
    
    Router.AMSend -> BeaconSender;
***************
*** 134,136 ****
--- 139,142 ----
    Router.Packet -> ActiveMessageC;
    Router.Leds -> NoLedsC;
+   Router.CollectionDebug = CollectionDebug;
  }



More information about the Tinyos-2-commits mailing list