]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Instrumented.
authorscipio <scipio>
Fri, 13 Apr 2007 00:10:48 +0000 (00:10 +0000)
committerscipio <scipio>
Fri, 13 Apr 2007 00:10:48 +0000 (00:10 +0000)
tos/lib/net/lqi/CollectionC.nc
tos/lib/net/lqi/LqiForwardingEngineP.nc
tos/lib/net/lqi/LqiRoutingEngineP.nc
tos/lib/net/lqi/MultiHopLqi.h
tos/lib/net/lqi/MultiHopLqiP.nc

index 88667c399cd650d5e6b95eb2c4fae8495bd72c5a..2dcf9c83c6379aa36c9cffc8f2e08f4ddad3ec79 100644 (file)
@@ -48,6 +48,8 @@ configuration CollectionC {
     interface CollectionPacket;
     interface RootControl;
   }
+  uses interface CollectionDebug;
+  
 }
 
 implementation {
@@ -65,4 +67,6 @@ implementation {
   Snoop =       Router.Snoop;
   Intercept =   Router.Intercept;
   CollectionPacket = Router;
+
+  Router.CollectionDebug = CollectionDebug;
 }
index 17a15be40b9060b24d052a73b96d488e715ffbc7..2029bb9672203d4454650d0024ebf337db6914a1 100644 (file)
@@ -78,6 +78,7 @@
 
 #include "AM.h"
 #include "MultiHopLqi.h"
+#include "CollectionDebugMsg.h"
 
 module LqiForwardingEngineP {
   provides {
@@ -103,6 +104,7 @@ module LqiForwardingEngineP {
     interface RootControl;
     interface Random;
     interface PacketAcknowledgements;
+    interface CollectionDebug;
   }
 }
 
@@ -155,17 +157,14 @@ implementation {
   command error_t Send.send(message_t* pMsg, uint8_t len) {
     len += sizeof(lqi_header_t);
     if (len > call SubPacket.maxPayloadLength()) {
-      call Leds.led0On();
       return ESIZE;
     }
     if (call RootControl.isRoot()) {
-      call Leds.led1On();
       return FAIL;
     }
     call RouteSelect.initializeFields(pMsg);
     
     if (call RouteSelect.selectRoute(pMsg, 0) != SUCCESS) {
-      call Leds.led2On();
       return FAIL;
     }
     call PacketAcknowledgements.requestAck(pMsg);
@@ -204,24 +203,29 @@ implementation {
   }
 
   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
   }
 
   static void forward(message_t* msg);
   
   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__);
+      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;
     }
@@ -257,11 +261,11 @@ implementation {
     len -= sizeof(lqi_header_t);
 
     if (call RootControl.isRoot()) {
-      dbg("LQI", "LQI Root is receiving packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
+      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", "LQI fwd is forwarding packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
+      dbg("LQI,LQIDeliver", "LQI fwd is forwarding packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
       return mForward(msg);
     }
     else {
@@ -293,17 +297,33 @@ implementation {
                            msg,
                            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_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));
     }
     
     fail_count = 0;
@@ -332,13 +352,35 @@ implementation {
                            msg,
                            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 c19bed0e29a2b6197171a49da50d45526a15636d..4d99095792832422b037bbf35ba0732b3bab17a4 100644 (file)
@@ -37,6 +37,7 @@
 
 
 #include "MultiHopLqi.h"
+#include "CollectionDebugMsg.h"
 
 module LqiRoutingEngineP {
 
@@ -58,6 +59,7 @@ module LqiRoutingEngineP {
     interface LqiRouteStats;
     interface CC2420Packet;
     interface Leds;
+    interface CollectionDebug;
   }
 }
 
@@ -149,6 +151,7 @@ implementation {
     
     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);
     }
   }
 
@@ -195,6 +198,7 @@ implementation {
 
   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;
   }
@@ -235,6 +239,7 @@ implementation {
       for (i = 0; i < MHOP_HISTORY_SIZE; i++) {
         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;
         }
@@ -323,18 +328,22 @@ implementation {
 
 
   event void Timer.fired() {
+    call Leds.led0Toggle();
     post TimerTask();
-    call Timer.startOneShot(1024 * gUpdateInterval + 1);
+    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 {
-      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) {
        // try to prevent cycles
@@ -372,6 +381,7 @@ implementation {
          gbCurrentParentCost = bMsg->cost;
          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");
        }
        else {
index a7d1e82a0d673bc2295949f780752baadd459b1c..48b64460d46f50fc905d85984d1c1b95e9cab25b 100644 (file)
@@ -92,6 +92,7 @@
 enum {
   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 1f58f4b555db1b6b2b38c8d6ce1bbe90fb14dc87..5291973000b28fe1d4f6b3068353fe8570fbee88 100644 (file)
@@ -78,6 +78,8 @@ configuration MultiHopLqiP {
     interface CollectionPacket;
   }
 
+  uses interface CollectionDebug;
+
 }
 
 implementation {
@@ -99,7 +101,7 @@ implementation {
   MainC.SoftwareInit -> Router;
   
   components CC2420ActiveMessageC as CC2420;
-
+  
   StdControl = Router.StdControl;
   
   Receive = Forwarder.Receive;
@@ -111,7 +113,9 @@ implementation {
   Packet = Forwarder;
   CollectionPacket = Forwarder;
   RootControl = Router;
+
+  //CC2420.SubPacket -> DataSender;
+  
   Forwarder.RouteSelectCntl -> Router.RouteControl;
   Forwarder.RouteSelect -> Router;
   Forwarder.SubSend -> DataSender;
@@ -123,6 +127,7 @@ implementation {
   Forwarder.PacketAcknowledgements -> ActiveMessageC;
   Forwarder.RootControl -> Router;
   Forwarder.Random -> RandomC;
+  Forwarder.CollectionDebug = CollectionDebug;
   
   Router.AMSend -> BeaconSender;
   Router.Receive -> BeaconReceiver;
@@ -133,4 +138,5 @@ implementation {
   Router.AMPacket -> ActiveMessageC;
   Router.Packet -> ActiveMessageC;
   Router.Leds -> NoLedsC;
+  Router.CollectionDebug = CollectionDebug;
 }