Make probing expiration time configurable

This commit is contained in:
Simon Duquennoy 2015-05-10 13:19:56 +02:00
parent d1ec313081
commit 832a4d3e01
2 changed files with 15 additions and 5 deletions

View file

@ -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.
* */

View file

@ -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) {