From ce7b4e8d571680f9aca097275fbee3eac5a22227 Mon Sep 17 00:00:00 2001 From: gnawali Date: Thu, 4 Feb 2010 07:31:46 +0000 Subject: [PATCH] get rid of +5 for rounding, change arg name in functions in CtpInfo to match the arg names in the implementation, fix bug reported by Faisal Aslam - VERY_LARGE_EETX was set to 0xff --- tos/lib/net/4bitle/LinkEstimatorP.nc | 18 +++++++++--------- tos/lib/net/ctp/CtpInfo.nc | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tos/lib/net/4bitle/LinkEstimatorP.nc b/tos/lib/net/4bitle/LinkEstimatorP.nc index c82c24fa..d1cb1af8 100644 --- a/tos/lib/net/4bitle/LinkEstimatorP.nc +++ b/tos/lib/net/4bitle/LinkEstimatorP.nc @@ -67,7 +67,7 @@ implementation { INVALID_NEIGHBOR_ADDR = 0xff, // if we don't know the link quality, we need to return a value so // large that it will not be used to form paths - VERY_LARGE_ETX_VALUE = 0xff, + VERY_LARGE_ETX_VALUE = 0xffff, // decay the link estimate using this alpha // we use a denominator of 10, so this corresponds to 0.2 ALPHA = 9, @@ -273,7 +273,7 @@ implementation { // called when new beacon estimate is done // also called when new DEETX estimate is done void updateETX(neighbor_table_entry_t *ne, uint16_t newEst) { - ne->etx = (ALPHA * ne->etx + (10 - ALPHA) * newEst + 5)/10; + ne->etx = (ALPHA * ne->etx + (10 - ALPHA) * newEst)/10; } @@ -287,7 +287,7 @@ implementation { // transmissions estETX = ne->data_total * 10; } else { - estETX = (10 * ne->data_total + 5) / ne->data_success; + estETX = (10 * ne->data_total) / ne->data_success; ne->data_success = 0; ne->data_total = 0; } @@ -295,9 +295,9 @@ implementation { } - // ETX (Extra Expected number of Transmission) + // ETX (Expected number of Transmission) // computeETX returns ETX*10 - uint8_t computeETX(uint8_t q1) { + uint16_t computeETX(uint8_t q1) { uint16_t q; if (q1 > 0) { q = 2500 / q1; @@ -332,11 +332,11 @@ implementation { totalPkt = minPkt; } if (totalPkt == 0) { - ne->inquality = (ALPHA * ne->inquality + 5) / 10; + ne->inquality = (ALPHA * ne->inquality) / 10; } else { - newEst = (250UL * ne->rcvcnt + 5) / totalPkt; - dbg("LI,LITest", " %hu: %hhu -> %hhu", ne->ll_addr, ne->inquality, (ALPHA * ne->inquality + (10-ALPHA) * newEst + 5)/10); - ne->inquality = (ALPHA * ne->inquality + (10-ALPHA) * newEst + 5)/10; + newEst = (250UL * ne->rcvcnt) / totalPkt; + dbg("LI,LITest", " %hu: %hhu -> %hhu", ne->ll_addr, ne->inquality, (ALPHA * ne->inquality + (10-ALPHA) * newEst)/10); + ne->inquality = (ALPHA * ne->inquality + (10-ALPHA) * newEst)/10; } ne->rcvcnt = 0; ne->failcnt = 0; diff --git a/tos/lib/net/ctp/CtpInfo.nc b/tos/lib/net/ctp/CtpInfo.nc index ad0687e2..7e865495 100644 --- a/tos/lib/net/ctp/CtpInfo.nc +++ b/tos/lib/net/ctp/CtpInfo.nc @@ -81,7 +81,7 @@ interface CtpInfo { command bool isNeighborCongested(am_addr_t n); command uint8_t numNeighbors(); - command uint16_t getNeighborLinkQuality(uint8_t neighbor); - command uint16_t getNeighborRouteQuality(uint8_t neighbor); - command am_addr_t getNeighborAddr(uint8_t neighbor); + command uint16_t getNeighborLinkQuality(uint8_t n); + command uint16_t getNeighborRouteQuality(uint8_t n); + command am_addr_t getNeighborAddr(uint8_t n); } -- 2.39.2