]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/net/ctp/CtpForwardingEngineP.nc
<= will detect loops in which all the nodes have the same metric to the root
[tinyos-2.x.git] / tos / lib / net / ctp / CtpForwardingEngineP.nc
index e7cb53cee2fd75c785d2da1b8f0d07a6f5c5fa5e..eac244e8822948bdb8653586b9a376accdfc6e5b 100644 (file)
@@ -440,6 +440,10 @@ implementation {
       if (call SentCache.lookup(qe->msg)) {
         call CollectionDebug.logEvent(NET_C_FE_DUPLICATE_CACHE_AT_SEND);
         call SendQueue.dequeue();
+       if (call MessagePool.put(qe->msg) != SUCCESS)
+         call CollectionDebug.logEvent(NET_C_FE_PUT_MSGPOOL_ERR);
+       if (call QEntryPool.put(qe) != SUCCESS)
+         call CollectionDebug.logEvent(NET_C_FE_PUT_QEPOOL_ERR);
         post sendTask();
         return;
       }
@@ -680,9 +684,11 @@ implementation {
         // Loop-detection code:
         if (call CtpInfo.getEtx(&gradient) == SUCCESS) {
           // We only check for loops if we know our own metric
-          if (call CtpPacket.getEtx(m) < gradient) {
-            // The incoming packet's metric (gradient) is less than our
-            // own gradient.  Trigger a route update and backoff.
+          if (call CtpPacket.getEtx(m) <= gradient) {
+            // If our etx metric is less than or equal to the etx value
+           // on the packet (etx of the previous hop node), then we believe
+           // we are in a loop.
+           // Trigger a route update and backoff.
             call CtpInfo.triggerImmediateRouteUpdate();
             startRetxmitTimer(LOOPY_WINDOW, LOOPY_OFFSET);
             call CollectionDebug.logEventMsg(NET_C_FE_LOOP_DETECTED,
@@ -744,7 +750,7 @@ implementation {
     call CollectionDebug.logEventMsg(NET_C_FE_RCV_MSG,
                                         call CollectionPacket.getSequenceNumber(msg), 
                                         call CollectionPacket.getOrigin(msg), 
-                                         call AMPacket.destination(msg));
+                                    thl--);
     if (len > call SubSend.maxPayloadLength()) {
       return msg;
     }