]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
properly use Trickle to control beacon rates
authorgnawali <gnawali>
Mon, 28 Apr 2008 04:28:36 +0000 (04:28 +0000)
committergnawali <gnawali>
Mon, 28 Apr 2008 04:28:36 +0000 (04:28 +0000)
tos/lib/net/ctp/CtpForwardingEngineP.nc
tos/lib/net/ctp/CtpP.nc
tos/lib/net/ctp/CtpRoutingEngineP.nc

index 38dfc10672dcb9ac948015d8c9b4113a9bf14796..f3f2c5782c7a54cf2140d9dec460d63e013bf1f7 100644 (file)
@@ -716,9 +716,9 @@ implementation {
     }
 
     // NB: at this point, we have a resource acquistion problem.
-    // Trigger an immediate route update, log the event, and drop the
+    // Log the event, and drop the
     // packet on the floor.
-    call CtpInfo.triggerImmediateRouteUpdate();
+
     call CollectionDebug.logEvent(NET_C_FE_SEND_QUEUE_FULL);
     return m;
   }
@@ -801,8 +801,9 @@ implementation {
 
     // Check for the pull bit (P) [TEP123] and act accordingly.  This
     // check is made for all packets, not just ones addressed to us.
-    if (call CtpPacket.option(msg, CTP_OPT_PULL))
+    if (call CtpPacket.option(msg, CTP_OPT_PULL)) {
       call CtpInfo.triggerRouteUpdate();
+    }
 
     call CtpInfo.setNeighborCongested(proximalSrc, call CtpPacket.option(msg, CTP_OPT_ECN));
     return signal Snoop.receive[call CtpPacket.getType(msg)] 
index 7cf98717b77d515284845d6171a43a7788d865fb..79e6aeccb9aa45472decfd72523a812c16fc1124 100644 (file)
@@ -131,7 +131,8 @@ implementation {
   components new AMReceiverC(AM_CTP_DATA);
   components new AMSnooperC(AM_CTP_DATA);
 
-  components new CtpRoutingEngineP(TREE_ROUTING_TABLE_SIZE, 10, 1024) as Router;
+  components new CtpRoutingEngineP(TREE_ROUTING_TABLE_SIZE, 128, 512000) as Router;
+
   StdControl = Router;
   StdControl = Estimator;
   RootControl = Router;
index ef3857ad8dfb4fbe3135b41c30d3ec17d1f5f5bd..120396ea75e89ffbc55ff983c5c0f618b401de2a 100644 (file)
@@ -93,7 +93,7 @@
  *  @see Net2-WG
  */
 
-generic module CtpRoutingEngineP(uint8_t routingTableSize, uint16_t minInterval, uint16_t maxInterval) {
+generic module CtpRoutingEngineP(uint8_t routingTableSize, uint32_t minInterval, uint32_t maxInterval) {
     provides {
         interface UnicastNameFreeRouting as Routing;
         interface RootControl;
@@ -164,13 +164,13 @@ implementation {
     error_t routingTableUpdateEntry(am_addr_t, am_addr_t , uint16_t);
     error_t routingTableEvict(am_addr_t neighbor);
 
-    uint16_t currentInterval = minInterval;
+    uint32_t currentInterval = minInterval;
     uint32_t t; 
     bool tHasPassed;
 
     void chooseAdvertiseTime() {
        t = currentInterval;
-       t *= 512; // * 1024 / 2
+       t /= 2;
        t += call Random.rand32() % t;
        tHasPassed = FALSE;
        call BeaconTimer.stop();
@@ -183,21 +183,18 @@ implementation {
     }
 
     void decayInterval() {
-      if (!state_is_root) {
         currentInterval *= 2;
         if (currentInterval > maxInterval) {
           currentInterval = maxInterval;
         }
-      }
       chooseAdvertiseTime();
     }
 
     void remainingInterval() {
        uint32_t remaining = currentInterval;
-       remaining *= 1024;
        remaining -= t;
        tHasPassed = TRUE;
-       call BeaconTimer.startPeriodic(t);
+       call BeaconTimer.startOneShot(remaining);
     }
 
     command error_t Init.init() {
@@ -351,9 +348,9 @@ implementation {
                 // we need it: i. when choosing a parent (here); 
                 //            ii. when choosing a next hop
                 parentChanges++;
-                resetInterval();
+
                 dbg("TreeRouting","Changed parent. from %d to %d\n", routeInfo.parent, best->neighbor);
-                call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, best->neighbor, 0, best->info.etx); 
+                call CollectionDebug.logEventDbg(NET_C_TREE_NEW_PARENT, best->neighbor, best->info.etx, minEtx);
                 call LinkEstimator.unpinNeighbor(routeInfo.parent);
                 call LinkEstimator.pinNeighbor(best->neighbor);
                 call LinkEstimator.clearDLQ(best->neighbor);
@@ -507,7 +504,6 @@ implementation {
         if (call CtpRoutingPacket.getOption(msg, CTP_OPT_PULL)) {
               resetInterval();
         }
-        //post updateRouteTask();
         return msg;
     }
 
@@ -562,24 +558,11 @@ implementation {
     }
 
     command void CtpInfo.triggerRouteUpdate() {
-      // Random time in interval 64-127ms
-      uint16_t beaconDelay = call Random.rand16();
-      beaconDelay &= 0x3f; 
-      beaconDelay += 64;
-      if (call BeaconTimer.gett0() + call BeaconTimer.getdt() -
-                                     call BeaconTimer.getNow() >= beaconDelay) {
-         call BeaconTimer.stop();
-         call BeaconTimer.startOneShot(beaconDelay);
-        }
+      resetInterval();
      }
 
     command void CtpInfo.triggerImmediateRouteUpdate() {
-      // Random time in interval 4-11ms
-      uint16_t beaconDelay = call Random.rand16();
-      beaconDelay &= 0x7; 
-      beaconDelay += 4;
-      call BeaconTimer.stop();
-      call BeaconTimer.startOneShot(beaconDelay);
+      resetInterval();
     }
 
     command void CtpInfo.setNeighborCongested(am_addr_t n, bool congested) {