RPL Lite: make sure no more than one probe gets in queue at any given time

This commit is contained in:
Simon Duquennoy 2018-05-09 14:38:59 -07:00
parent 46e1633c19
commit a2d9093cef
4 changed files with 24 additions and 9 deletions

View File

@ -368,6 +368,8 @@ rpl_neighbor_select_best(void)
#if RPL_WITH_PROBING
if(best != NULL) {
if(rpl_neighbor_is_fresh(best)) {
/* Unschedule any already scheduled urgent probing */
curr_instance.dag.urgent_probing_target = NULL;
/* Return best if it is fresh */
return best;
} else {
@ -380,7 +382,7 @@ rpl_neighbor_select_best(void)
LOG_WARN_6ADDR(rpl_neighbor_get_ipaddr(best));
LOG_WARN_("\n");
curr_instance.dag.urgent_probing_target = best;
rpl_schedule_probing();
rpl_schedule_probing_now();
}
/* The best is our preferred parent. It is not fresh but used to be,

View File

@ -342,13 +342,7 @@ handle_dao_ack_timer(void *ptr)
clock_time_t
get_probing_delay(void)
{
if(curr_instance.used && curr_instance.dag.urgent_probing_target != NULL) {
/* Urgent probing needed (to find out if a neighbor may become preferred parent) */
return random_rand() % (CLOCK_SECOND * 4);
} else {
/* Else, use normal probing interval */
return ((RPL_PROBING_INTERVAL) / 2) + random_rand() % (RPL_PROBING_INTERVAL);
}
return ((RPL_PROBING_INTERVAL) / 2) + random_rand() % (RPL_PROBING_INTERVAL);
}
/*---------------------------------------------------------------------------*/
rpl_nbr_t *
@ -440,7 +434,7 @@ 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;
/* urgent_probing_target will be NULLed in the packet_sent callback */
} else {
LOG_INFO("no neighbor needs probing\n");
}
@ -457,6 +451,15 @@ rpl_schedule_probing(void)
handle_probing_timer, NULL);
}
}
/*---------------------------------------------------------------------------*/
void
rpl_schedule_probing_now(void)
{
if(curr_instance.used) {
ctimer_set(&curr_instance.dag.probing_timer,
random_rand() % (CLOCK_SECOND * 4), handle_probing_timer, NULL);
}
}
#endif /* RPL_WITH_PROBING */
/*---------------------------------------------------------------------------*/
/*------------------------------- Leaving-- -------------------------------- */

View File

@ -104,6 +104,11 @@ void rpl_timers_schedule_dao_ack(uip_ipaddr_t *target, uint16_t sequence);
*/
void rpl_schedule_probing(void);
/**
* Schedule probing within a few seconds
*/
void rpl_schedule_probing_now(void);
/**
* Schedule a state update ASAP. Useful to force an update from a context
* where updating directly would be unsafe.

View File

@ -99,6 +99,11 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx)
if(curr_instance.used == 1 ) {
rpl_nbr_t *nbr = rpl_neighbor_get_from_lladdr((uip_lladdr_t *)addr);
if(nbr != NULL) {
/* If this is the neighbor we were probing urgently, mark urgent
probing as done */
if(curr_instance.dag.urgent_probing_target == nbr) {
curr_instance.dag.urgent_probing_target = NULL;
}
/* Link stats were updated, and we need to update our internal state.
Updating from here is unsafe; postpone */
LOG_INFO("packet sent to ");