Made DIO interval processing a little easier to follow. Explicitly state that the delay is handled as clock timer ticks.
This commit is contained in:
parent
8538aaf655
commit
2396f9b8ea
@ -81,25 +81,24 @@ static void
|
|||||||
new_dio_interval(rpl_instance_t *instance)
|
new_dio_interval(rpl_instance_t *instance)
|
||||||
{
|
{
|
||||||
uint32_t time;
|
uint32_t time;
|
||||||
|
clock_time_t ticks;
|
||||||
|
|
||||||
/* TODO: too small timer intervals for many cases */
|
/* TODO: too small timer intervals for many cases */
|
||||||
time = 1UL << instance->dio_intcurrent;
|
time = 1UL << instance->dio_intcurrent;
|
||||||
|
|
||||||
/* Convert from milliseconds to CLOCK_TICKS. */
|
/* Convert from milliseconds to CLOCK_TICKS. */
|
||||||
time = (time * CLOCK_SECOND) / 1000;
|
ticks = (time * CLOCK_SECOND) / 1000;
|
||||||
|
instance->dio_next_delay = ticks;
|
||||||
instance->dio_next_delay = time;
|
|
||||||
|
|
||||||
/* random number between I/2 and I */
|
/* random number between I/2 and I */
|
||||||
time = time >> 1;
|
ticks = ticks / 2 + (ticks / 2 * (uint32_t)random_rand()) / RANDOM_RAND_MAX;
|
||||||
time += (time * random_rand()) / RANDOM_RAND_MAX;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The intervals must be equally long among the nodes for Trickle to
|
* The intervals must be equally long among the nodes for Trickle to
|
||||||
* operate efficiently. Therefore we need to calculate the delay between
|
* operate efficiently. Therefore we need to calculate the delay between
|
||||||
* the randomized time and the start time of the next interval.
|
* the randomized time and the start time of the next interval.
|
||||||
*/
|
*/
|
||||||
instance->dio_next_delay -= time;
|
instance->dio_next_delay -= ticks;
|
||||||
instance->dio_send = 1;
|
instance->dio_send = 1;
|
||||||
|
|
||||||
#if RPL_CONF_STATS
|
#if RPL_CONF_STATS
|
||||||
@ -119,8 +118,8 @@ new_dio_interval(rpl_instance_t *instance)
|
|||||||
instance->dio_counter = 0;
|
instance->dio_counter = 0;
|
||||||
|
|
||||||
/* schedule the timer */
|
/* schedule the timer */
|
||||||
PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", time);
|
PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", ticks);
|
||||||
ctimer_set(&instance->dio_timer, time, &handle_dio_timer, instance);
|
ctimer_set(&instance->dio_timer, ticks, &handle_dio_timer, instance);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
@ -221,7 +221,7 @@ struct rpl_instance {
|
|||||||
uint16_t dio_totsend;
|
uint16_t dio_totsend;
|
||||||
uint16_t dio_totrecv;
|
uint16_t dio_totrecv;
|
||||||
#endif /* RPL_CONF_STATS */
|
#endif /* RPL_CONF_STATS */
|
||||||
uint32_t dio_next_delay; /* delay for completion of dio interval */
|
clock_time_t dio_next_delay; /* delay for completion of dio interval */
|
||||||
struct ctimer dio_timer;
|
struct ctimer dio_timer;
|
||||||
struct ctimer dao_timer;
|
struct ctimer dao_timer;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user