From 86dc3d9a63c45e3515af81057b40fca959ab1615 Mon Sep 17 00:00:00 2001 From: gnawali Date: Mon, 28 Apr 2008 04:28:36 +0000 Subject: [PATCH] properly use Trickle to control beacon rates --- tos/lib/net/ctp/CtpForwardingEngineP.nc | 7 +++--- tos/lib/net/ctp/CtpP.nc | 3 ++- tos/lib/net/ctp/CtpRoutingEngineP.nc | 33 ++++++------------------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/tos/lib/net/ctp/CtpForwardingEngineP.nc b/tos/lib/net/ctp/CtpForwardingEngineP.nc index 38dfc106..f3f2c578 100644 --- a/tos/lib/net/ctp/CtpForwardingEngineP.nc +++ b/tos/lib/net/ctp/CtpForwardingEngineP.nc @@ -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)] diff --git a/tos/lib/net/ctp/CtpP.nc b/tos/lib/net/ctp/CtpP.nc index 7cf98717..79e6aecc 100644 --- a/tos/lib/net/ctp/CtpP.nc +++ b/tos/lib/net/ctp/CtpP.nc @@ -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; diff --git a/tos/lib/net/ctp/CtpRoutingEngineP.nc b/tos/lib/net/ctp/CtpRoutingEngineP.nc index ef3857ad..120396ea 100644 --- a/tos/lib/net/ctp/CtpRoutingEngineP.nc +++ b/tos/lib/net/ctp/CtpRoutingEngineP.nc @@ -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) { -- 2.39.2