From 2d0e86aa45c17e850727ff3eb2c76fb4e45cd63b Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Thu, 29 Jun 2017 16:08:06 +0200 Subject: [PATCH] rpl-lite: less aggressive probing function: only probe non-fresh neighbors. Default period set to 90s" --- core/net/rpl-lite/rpl-conf.h | 2 +- core/net/rpl-lite/rpl-timers.c | 38 +++++++++++-------- .../14-rpl-lite/09-rpl-probing.csc | 2 +- regression-tests/15-rpl/09-rpl-probing.csc | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/core/net/rpl-lite/rpl-conf.h b/core/net/rpl-lite/rpl-conf.h index 0f955ed31..82759b543 100644 --- a/core/net/rpl-lite/rpl-conf.h +++ b/core/net/rpl-lite/rpl-conf.h @@ -270,7 +270,7 @@ #ifdef RPL_CONF_PROBING_INTERVAL #define RPL_PROBING_INTERVAL RPL_CONF_PROBING_INTERVAL #else -#define RPL_PROBING_INTERVAL (60 * CLOCK_SECOND) +#define RPL_PROBING_INTERVAL (90 * CLOCK_SECOND) #endif /* diff --git a/core/net/rpl-lite/rpl-timers.c b/core/net/rpl-lite/rpl-timers.c index 7482b015e..36a5b6267 100644 --- a/core/net/rpl-lite/rpl-timers.c +++ b/core/net/rpl-lite/rpl-timers.c @@ -380,33 +380,37 @@ get_probing_target(void) return curr_instance.dag.preferred_parent; } - /* With 50% probability: probe best non-fresh neighbor */ - if(random_rand() % 2 == 0) { + /* Now consider probing other non-fresh neighbors. With 2/3 proabability, + pick the best non-fresh. Otherwise, pick the lest recently updated non-fresh. */ + + if(random_rand() % 3 != 0) { + /* Look for best non-fresh */ nbr = nbr_table_head(rpl_neighbors); while(nbr != NULL) { if(!rpl_neighbor_is_fresh(nbr)) { - /* p is in our dag and needs probing */ - rpl_rank_t p_rank = rpl_neighbor_rank_via_nbr(nbr); + /* nbr needs probing */ + rpl_rank_t nbr_rank = rpl_neighbor_rank_via_nbr(nbr); if(probing_target == NULL - || p_rank < probing_target_rank) { + || nbr_rank < probing_target_rank) { probing_target = nbr; - probing_target_rank = p_rank; + probing_target_rank = nbr_rank; } } nbr = nbr_table_next(rpl_neighbors, nbr); } - } - - /* If we still do not have a probing target: pick the least recently updated neighbor */ - if(probing_target == NULL) { + } else { + /* Look for least recently updated non-fresh */ nbr = nbr_table_head(rpl_neighbors); while(nbr != NULL) { - const struct link_stats *stats =rpl_neighbor_get_link_stats(nbr); - if(stats != NULL) { - if(probing_target == NULL - || clock_now - stats->last_tx_time > probing_target_age) { - probing_target = nbr; - probing_target_age = clock_now - stats->last_tx_time; + if(!rpl_neighbor_is_fresh(nbr)) { + /* nbr needs probing */ + const struct link_stats *stats = rpl_neighbor_get_link_stats(nbr); + if(stats != NULL) { + if(probing_target == NULL + || clock_now - stats->last_tx_time > probing_target_age) { + probing_target = nbr; + probing_target_age = clock_now - stats->last_tx_time; + } } } nbr = nbr_table_next(rpl_neighbors, nbr); @@ -436,6 +440,8 @@ handle_probing_timer(void *ptr) /* Send probe, e.g. unicast DIO or DIS */ RPL_PROBING_SEND_FUNC(target_ipaddr); curr_instance.dag.urgent_probing_target = NULL; + } else { + LOG_INFO("no neighbor needs probing\n"); } /* Schedule next probing */ diff --git a/regression-tests/14-rpl-lite/09-rpl-probing.csc b/regression-tests/14-rpl-lite/09-rpl-probing.csc index f7d9c0290..7e5ef727a 100644 --- a/regression-tests/14-rpl-lite/09-rpl-probing.csc +++ b/regression-tests/14-rpl-lite/09-rpl-probing.csc @@ -204,7 +204,7 @@ GENERATE_MSG(1500000, "moving root back"); lostMsgs = 0; -TIMEOUT(6000000, if(lastMsg != -1 && lastMsgHops == 1 && lostMsgs <= 2 && num > 20) { log.testOK(); } ); +TIMEOUT(10000000, if(lastMsg != -1 && lastMsgHops == 1 && lostMsgs <= 2 && num > 20) { log.testOK(); } ); lastMsg = -1; packets = "_________"; diff --git a/regression-tests/15-rpl/09-rpl-probing.csc b/regression-tests/15-rpl/09-rpl-probing.csc index f7d9c0290..7e5ef727a 100644 --- a/regression-tests/15-rpl/09-rpl-probing.csc +++ b/regression-tests/15-rpl/09-rpl-probing.csc @@ -204,7 +204,7 @@ GENERATE_MSG(1500000, "moving root back"); lostMsgs = 0; -TIMEOUT(6000000, if(lastMsg != -1 && lastMsgHops == 1 && lostMsgs <= 2 && num > 20) { log.testOK(); } ); +TIMEOUT(10000000, if(lastMsg != -1 && lastMsgHops == 1 && lostMsgs <= 2 && num > 20) { log.testOK(); } ); lastMsg = -1; packets = "_________";