diff --git a/core/net/link-stats.c b/core/net/link-stats.c index 2312f5b23..37e764458 100644 --- a/core/net/link-stats.c +++ b/core/net/link-stats.c @@ -55,13 +55,13 @@ /* EWMA (exponential moving average) used to maintain statistics over time */ #define EWMA_SCALE 100 -#define EWMA_ALPHA 10 +#define EWMA_ALPHA 15 #define EWMA_BOOTSTRAP_ALPHA 30 /* ETX fixed point divisor. 128 is the value used by RPL (RFC 6551 and RFC 6719) */ #define ETX_DIVISOR LINK_STATS_ETX_DIVISOR /* Number of Tx used to update the ETX EWMA in case of no-ACK */ -#define ETX_NOACK_PENALTY 16 +#define ETX_NOACK_PENALTY 10 /* Initial ETX value */ #define ETX_INIT 2 diff --git a/core/net/rpl/rpl-mrhof.c b/core/net/rpl/rpl-mrhof.c index fde280110..a3f4d2b87 100644 --- a/core/net/rpl/rpl-mrhof.c +++ b/core/net/rpl/rpl-mrhof.c @@ -71,8 +71,8 @@ #endif /* RPL_MRHOF_CONF_SQUARED_ETX */ /* Configuration parameters of RFC6719. Reject parents that have a higher - * link metric than the following. We use the default values from the RFC. */ -#define MAX_LINK_METRIC 512 /* Eq ETX of 4 */ + * link metric than the following. The default value is 512 but we use 1024. */ +#define MAX_LINK_METRIC 1024 /* Eq ETX of 8 */ /* Reject parents that have a higher path cost than the following. */ #define MAX_PATH_COST 32768 /* Eq path ETX of 256 */ /* Hysteresis of MRHOF: the rank must differ more than PARENT_SWITCH_THRESHOLD_DIV @@ -187,19 +187,14 @@ best_parent(rpl_parent_t *p1, rpl_parent_t *p2) int p1_is_acceptable; int p2_is_acceptable; - if(p1 == NULL || p2 == NULL) { - /* Return non-null parent if any */ - return p1 == NULL ? p2 : p1; - } + p1_is_acceptable = p1 != NULL && parent_is_acceptable(p1); + p2_is_acceptable = p2 != NULL && parent_is_acceptable(p2); - p1_is_acceptable = parent_is_acceptable(p1); - p2_is_acceptable = parent_is_acceptable(p2); - /* Is only one parent is acceptable, select it. If both are acceptable, or - * both non-acceptable, proceed to traditional parent comparison. This is a - * slight departure from the standard but allows to keep connectivity even - * all neighbors appear to have a bad link. */ - if(p1_is_acceptable != p2_is_acceptable) { - return p1_is_acceptable ? p1 : p2; + if(!p1_is_acceptable) { + return p2_is_acceptable ? p2 : NULL; + } + if(!p2_is_acceptable) { + return p1_is_acceptable ? p1 : NULL; } dag = p1->dag; /* Both parents are in the same DAG. */ diff --git a/core/net/rpl/rpl-of0.c b/core/net/rpl/rpl-of0.c index 2fcb17a07..84b14d1ba 100644 --- a/core/net/rpl/rpl-of0.c +++ b/core/net/rpl/rpl-of0.c @@ -145,19 +145,14 @@ best_parent(rpl_parent_t *p1, rpl_parent_t *p2) int p1_is_acceptable; int p2_is_acceptable; - if(p1 == NULL || p2 == NULL) { - /* Return non-null parent if any */ - return p1 == NULL ? p2 : p1; - } + p1_is_acceptable = p1 != NULL && parent_is_acceptable(p1); + p2_is_acceptable = p2 != NULL && parent_is_acceptable(p2); - p1_is_acceptable = parent_is_acceptable(p1); - p2_is_acceptable = parent_is_acceptable(p2); - /* Is only one parent is acceptable, select it. If both are acceptable, or - * both non-acceptable, proceed to traditional parent comparison. This is a - * slight departure from the standard but allows to keep connectivity even - * all neighbors appear to have a bad link. */ - if(p1_is_acceptable != p2_is_acceptable) { - return p1_is_acceptable ? p1 : p2; + if(!p1_is_acceptable) { + return p2_is_acceptable ? p2 : NULL; + } + if(!p2_is_acceptable) { + return p1_is_acceptable ? p1 : NULL; } dag = p1->dag; /* Both parents are in the same DAG. */