RPL: if the best parent is not fresh, use the best fresh instead and utilize urgent probing to update link estimates

This commit is contained in:
Simon Duquennoy 2016-04-23 00:13:59 +02:00 committed by Simon Duquennoy
parent b42b12d7c8
commit 43b01b3236

View File

@ -832,7 +832,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
}
/*---------------------------------------------------------------------------*/
static rpl_parent_t *
best_parent(rpl_dag_t *dag)
best_parent(rpl_dag_t *dag, int fresh_only)
{
rpl_parent_t *p;
rpl_of_t *of;
@ -851,6 +851,11 @@ best_parent(rpl_dag_t *dag)
continue;
}
if(fresh_only && !rpl_parent_is_fresh(p)) {
/* Filter out non-fresh parents if fresh_only is set */
continue;
}
#ifndef UIP_CONF_ND6_SEND_NA
{
uip_ds6_nbr_t *nbr = rpl_get_nbr(p);
@ -871,13 +876,23 @@ best_parent(rpl_dag_t *dag)
rpl_parent_t *
rpl_select_parent(rpl_dag_t *dag)
{
rpl_parent_t *best = best_parent(dag);
/* Look for best parent (regardless of freshness) */
rpl_parent_t *best = best_parent(dag, 0);
if(best != NULL) {
if(rpl_parent_is_fresh(best)) {
rpl_set_preferred_parent(dag, best);
dag->rank = rpl_rank_via_parent(dag->preferred_parent);
} else {
/* The best is not fresh. Look for the best fresh now. */
rpl_parent_t *best_fresh = best_parent(dag, 1);
if(best_fresh == NULL) {
/* No fresh parent around, use best (non-fresh) */
rpl_set_preferred_parent(dag, best);
} else {
/* Use best fresh */
rpl_set_preferred_parent(dag, best_fresh);
}
#if RPL_WITH_PROBING
/* Probe the new best parent shortly in order to get a fresh estimate */
dag->instance->urgent_probing_target = best;