From 5a65e3cc8b285d17d627c8061bc27e3b3542a03f Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Tue, 21 Feb 2012 19:06:58 +0100 Subject: [PATCH] tuned RPL parameters and improved calculation of path etx --- core/net/rpl/rpl-of-etx.c | 13 ++++++------- core/net/rpl/rpl-private.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/net/rpl/rpl-of-etx.c b/core/net/rpl/rpl-of-etx.c index 466d86ca6..05a521c83 100644 --- a/core/net/rpl/rpl-of-etx.c +++ b/core/net/rpl/rpl-of-etx.c @@ -66,11 +66,6 @@ rpl_of_t rpl_of_etx = { 1 }; -#define NI_ETX_TO_RPL_ETX(etx) \ - ((etx) * (RPL_DAG_MC_ETX_DIVISOR / NEIGHBOR_INFO_ETX_DIVISOR)) -#define RPL_ETX_TO_NI_ETX(etx) \ - ((etx) / (RPL_DAG_MC_ETX_DIVISOR / NEIGHBOR_INFO_ETX_DIVISOR)) - /* Reject parents that have a higher link metric than the following. */ #define MAX_LINK_METRIC 10 @@ -90,8 +85,11 @@ calculate_path_metric(rpl_parent_t *p) { if(p == NULL || (p->mc.obj.etx == 0 && p->rank > ROOT_RANK(p->dag->instance))) { return MAX_PATH_COST * RPL_DAG_MC_ETX_DIVISOR; + } else { + long etx = p->link_metric; + etx = (etx * RPL_DAG_MC_ETX_DIVISOR) / NEIGHBOR_INFO_ETX_DIVISOR; + return p->mc.obj.etx + (uint16_t) etx; } - return p->mc.obj.etx + NI_ETX_TO_RPL_ETX(p->link_metric); } static void @@ -116,7 +114,8 @@ calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank) } rank_increase = NEIGHBOR_INFO_FIX2ETX(INITIAL_LINK_METRIC) * DEFAULT_MIN_HOPRANKINC; } else { - rank_increase = NEIGHBOR_INFO_FIX2ETX(p->link_metric) * p->dag->instance->min_hoprankinc; + /* multiply first, then scale down to avoid truncation effects */ + rank_increase = NEIGHBOR_INFO_FIX2ETX(p->link_metric * p->dag->instance->min_hoprankinc); if(base_rank == 0) { base_rank = p->rank; } diff --git a/core/net/rpl/rpl-private.h b/core/net/rpl/rpl-private.h index a4fb43b83..94eaec0d8 100644 --- a/core/net/rpl/rpl-private.h +++ b/core/net/rpl/rpl-private.h @@ -129,7 +129,7 @@ #else #define DEFAULT_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC #endif -#define DEFAULT_MAX_RANKINC (3 * DEFAULT_MIN_HOPRANKINC) +#define DEFAULT_MAX_RANKINC (7 * DEFAULT_MIN_HOPRANKINC) #define DAG_RANK(fixpt_rank, instance) ((fixpt_rank) / (instance)->min_hoprankinc)