From d6e4bc62926324801eee6ea48783dce663d5b6b2 Mon Sep 17 00:00:00 2001 From: scipio Date: Fri, 15 Aug 2008 21:57:31 +0000 Subject: [PATCH] Make timing the optimal values. Include commented out code for trickle reset in routing engine. --- tos/lib/net/ctp/CtpForwardingEngine.h | 22 +++++++++++----------- tos/lib/net/ctp/CtpForwardingEngineP.nc | 4 ++-- tos/lib/net/ctp/CtpRoutingEngineP.nc | 13 ++++++++++--- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tos/lib/net/ctp/CtpForwardingEngine.h b/tos/lib/net/ctp/CtpForwardingEngine.h index 92f72fda..e45d0231 100644 --- a/tos/lib/net/ctp/CtpForwardingEngine.h +++ b/tos/lib/net/ctp/CtpForwardingEngine.h @@ -58,24 +58,24 @@ */ enum { -#if PLATFORM_MICAZ || PLATFORM_TELOSA || PLATFORM_TELOSB || PLATFORM_TMOTE || PLATFORM_INTELMOTE2 - FORWARD_PACKET_TIME = 4, +#if PLATFORM_MICAZ || PLATFORM_TELOSA || PLATFORM_TELOSB || PLATFORM_TMOTE || PLATFORM_INTELMOTE2 || PLATFORM_SHIMMER || PLATFORM_IRIS + FORWARD_PACKET_TIME = 7, #else FORWARD_PACKET_TIME = 32, #endif }; enum { - SENDDONE_FAIL_OFFSET = 512, - SENDDONE_NOACK_OFFSET = FORWARD_PACKET_TIME << 2, - SENDDONE_OK_OFFSET = FORWARD_PACKET_TIME << 2, - LOOPY_OFFSET = FORWARD_PACKET_TIME << 4, - SENDDONE_FAIL_WINDOW = SENDDONE_FAIL_OFFSET - 1, - LOOPY_WINDOW = LOOPY_OFFSET - 1, - SENDDONE_NOACK_WINDOW = SENDDONE_NOACK_OFFSET - 1, - SENDDONE_OK_WINDOW = SENDDONE_OK_OFFSET - 1, + SENDDONE_OK_OFFSET = FORWARD_PACKET_TIME, + SENDDONE_OK_WINDOW = FORWARD_PACKET_TIME, + SENDDONE_NOACK_OFFSET = FORWARD_PACKET_TIME, + SENDDONE_NOACK_WINDOW = FORWARD_PACKET_TIME, + SENDDONE_FAIL_OFFSET = FORWARD_PACKET_TIME << 2, + SENDDONE_FAIL_WINDOW = SENDDONE_FAIL_OFFSET, + LOOPY_OFFSET = FORWARD_PACKET_TIME << 2, + LOOPY_WINDOW = LOOPY_OFFSET, CONGESTED_WAIT_OFFSET = FORWARD_PACKET_TIME << 2, - CONGESTED_WAIT_WINDOW = CONGESTED_WAIT_OFFSET - 1, + CONGESTED_WAIT_WINDOW = CONGESTED_WAIT_OFFSET, NO_ROUTE_RETRY = 10000 }; diff --git a/tos/lib/net/ctp/CtpForwardingEngineP.nc b/tos/lib/net/ctp/CtpForwardingEngineP.nc index 65fe7008..df59dfbb 100644 --- a/tos/lib/net/ctp/CtpForwardingEngineP.nc +++ b/tos/lib/net/ctp/CtpForwardingEngineP.nc @@ -274,9 +274,9 @@ implementation { } } - static void startRetxmitTimer(uint16_t mask, uint16_t offset) { + static void startRetxmitTimer(uint16_t window, uint16_t offset) { uint16_t r = call Random.rand16(); - r &= mask; + r %= window; r += offset; call RetxmitTimer.startOneShot(r); dbg("Forwarder", "Rexmit timer will fire in %hu ms\n", r); diff --git a/tos/lib/net/ctp/CtpRoutingEngineP.nc b/tos/lib/net/ctp/CtpRoutingEngineP.nc index 342f2f53..f0ef1f60 100644 --- a/tos/lib/net/ctp/CtpRoutingEngineP.nc +++ b/tos/lib/net/ctp/CtpRoutingEngineP.nc @@ -297,8 +297,8 @@ implementation { /* Compute this neighbor's path metric */ linkEtx = evaluateEtx(call LinkEstimator.getLinkQuality(entry->neighbor)); dbg("TreeRouting", - "routingTable[%d]: neighbor: [id: %d parent: %d etx: %d]\n", - i, entry->neighbor, entry->info.parent, linkEtx); + "routingTable[%d]: neighbor: [id: %d parent: %d etx: %d retx: %d]\n", + i, entry->neighbor, entry->info.parent, linkEtx, entry->info.etx); pathEtx = linkEtx + entry->info.etx; /* Operations specific to the current parent */ if (entry->neighbor == routeInfo.parent) { @@ -321,6 +321,7 @@ implementation { } if (pathEtx < minEtx) { + dbg("TreeRouting", " best is %d, setting to %d\n", pathEtx, entry->neighbor); minEtx = pathEtx; best = entry; } @@ -354,11 +355,17 @@ implementation { call LinkEstimator.unpinNeighbor(routeInfo.parent); call LinkEstimator.pinNeighbor(best->neighbor); call LinkEstimator.clearDLQ(best->neighbor); - atomic { + + atomic { routeInfo.parent = best->neighbor; routeInfo.etx = best->info.etx; routeInfo.congested = best->info.congested; } + /* If we follow the CTP paper this should be in here. + if (currentEtx - minEtx > 20) { + call CtpInfo.triggerRouteUpdate(); + } + */ } } -- 2.39.2