From 95ab192e88625ec8fe53d061b202b1590205f732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dawans?= Date: Fri, 1 Feb 2013 08:59:31 +0100 Subject: [PATCH] Makes RPL Initial Link Metric configurable --- core/net/rpl/rpl-conf.h | 9 +++++++++ core/net/rpl/rpl-dag.c | 2 +- core/net/rpl/rpl-of-etx.c | 2 +- core/net/rpl/rpl-private.h | 2 -- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/net/rpl/rpl-conf.h b/core/net/rpl/rpl-conf.h index aef97356b..39379ba8c 100644 --- a/core/net/rpl/rpl-conf.h +++ b/core/net/rpl/rpl-conf.h @@ -154,4 +154,13 @@ #define RPL_DIO_REDUNDANCY 10 #endif +/* + * Initial metric attributed to a link when the ETX is unknown + */ +#ifndef RPL_CONF_INIT_LINK_METRIC +#define RPL_INIT_LINK_METRIC NEIGHBOR_INFO_ETX2FIX(5) +#else +#define RPL_INIT_LINK_METRIC NEIGHBOR_INFO_ETX2FIX(RPL_CONF_INIT_LINK_METRIC) +#endif + #endif /* RPL_CONF_H */ diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 9cca22b12..2f92498a7 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -505,7 +505,7 @@ rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr) p->dag = dag; p->rank = dio->rank; p->dtsn = dio->dtsn; - p->link_metric = INITIAL_LINK_METRIC; + p->link_metric = RPL_INIT_LINK_METRIC; memcpy(&p->mc, &dio->mc, sizeof(p->mc)); list_add(dag->parents, p); return p; diff --git a/core/net/rpl/rpl-of-etx.c b/core/net/rpl/rpl-of-etx.c index a7c0e4429..abbc229b7 100644 --- a/core/net/rpl/rpl-of-etx.c +++ b/core/net/rpl/rpl-of-etx.c @@ -112,7 +112,7 @@ calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank) if(base_rank == 0) { return INFINITE_RANK; } - rank_increase = NEIGHBOR_INFO_FIX2ETX(INITIAL_LINK_METRIC) * RPL_MIN_HOPRANKINC; + rank_increase = NEIGHBOR_INFO_FIX2ETX(RPL_INIT_LINK_METRIC) * RPL_MIN_HOPRANKINC; } else { /* multiply first, then scale down to avoid truncation effects */ rank_increase = NEIGHBOR_INFO_FIX2ETX(p->link_metric * p->dag->instance->min_hoprankinc); diff --git a/core/net/rpl/rpl-private.h b/core/net/rpl/rpl-private.h index 9dfd91927..7da222b71 100644 --- a/core/net/rpl/rpl-private.h +++ b/core/net/rpl/rpl-private.h @@ -139,8 +139,6 @@ #define INFINITE_RANK 0xffff -#define INITIAL_LINK_METRIC NEIGHBOR_INFO_ETX2FIX(5) - /* Represents 2^n ms. */ /* Default value according to the specification is 3 which means 8 milliseconds, but that is an unreasonable value if