From 832a4d3e01349458a48a585e2e1af72ec6be0411 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 May 2015 13:19:56 +0200 Subject: [PATCH] Make probing expiration time configurable --- core/net/rpl/rpl-conf.h | 9 +++++++++ core/net/rpl/rpl-timers.c | 11 ++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/net/rpl/rpl-conf.h b/core/net/rpl/rpl-conf.h index 11d2cdbd0..a2c0e6dd2 100644 --- a/core/net/rpl/rpl-conf.h +++ b/core/net/rpl/rpl-conf.h @@ -226,6 +226,15 @@ #define RPL_PROBING_INTERVAL (120 * CLOCK_SECOND) #endif +/* + * RPL probing expiration time. + * */ +#ifdef RPL_CONF_PROBING_EXPIRATION_TIME +#define RPL_PROBING_EXPIRATION_TIME RPL_CONF_PROBING_EXPIRATION_TIME +#else +#define RPL_PROBING_EXPIRATION_TIME (10 * 60 * CLOCK_SECOND) +#endif + /* * Function used to select the next parent to be probed. * */ diff --git a/core/net/rpl/rpl-timers.c b/core/net/rpl/rpl-timers.c index fac19ee4f..def1ff404 100644 --- a/core/net/rpl/rpl-timers.c +++ b/core/net/rpl/rpl-timers.c @@ -332,18 +332,19 @@ static rpl_parent_t * get_probing_target(rpl_dag_t *dag) { /* Returns the next probing target. The current implementation probes the current - * preferred parent if we have not updated its link for 2 * RPL_PROBING_INTERVAL. + * preferred parent if we have not updated its link for RPL_PROBING_EXPIRATION_TIME. * Otherwise, it picks at random between: - * (1) selecting the best parent not updated for 2 * RPL_PROBING_INTERVAL + * (1) selecting the best parent not updated for RPL_PROBING_EXPIRATION_TIME * (2) selecting the least recently updated parent */ rpl_parent_t *p; rpl_parent_t *probing_target = NULL; rpl_rank_t probing_target_rank = INFINITE_RANK; - /* min_last_tx is the clock time (2 * RPL_PROBING_INTERVAL) in the past */ + /* min_last_tx is the clock time RPL_PROBING_EXPIRATION_TIME in the past */ clock_time_t min_last_tx = clock_time(); - min_last_tx = min_last_tx > 2 * RPL_PROBING_INTERVAL ? min_last_tx - 2 * RPL_PROBING_INTERVAL : 1; + min_last_tx = min_last_tx > 2 * RPL_PROBING_EXPIRATION_TIME + ? min_last_tx - RPL_PROBING_EXPIRATION_TIME : 1; if(dag == NULL || dag->instance == NULL || @@ -357,7 +358,7 @@ get_probing_target(rpl_dag_t *dag) } if((random_rand() % 2) == 0) { - /* With 1/2 probability: probe best parent not updated for 2 * RPL_PROBING_INTERVAL */ + /* With 1/2 probability: probe best parent not updated for RPL_PROBING_EXPIRATION_TIME */ p = nbr_table_head(rpl_parents); while(p != NULL) { if(p->dag == dag && p->last_tx_time < min_last_tx) {