Improved DAO management.

This commit is contained in:
nvt-se 2010-12-17 15:24:25 +00:00
parent 79329573a0
commit 8f76c82433
4 changed files with 17 additions and 12 deletions

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-dag.c,v 1.41 2010/12/13 10:59:37 joxe Exp $
* $Id: rpl-dag.c,v 1.42 2010/12/17 15:24:25 nvt-se Exp $
*/
/**
* \file
@ -117,8 +117,7 @@ remove_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
static int
should_send_dao(rpl_dag_t *dag, rpl_dio_t *dio, rpl_parent_t *p)
{
return 1;
/* return dio->dtsn > p->dtsn && p == dag->preferred_parent;*/
return dio->dtsn > p->dtsn && p == dag->preferred_parent;
}
/************************************************************************/
static int
@ -237,6 +236,8 @@ rpl_alloc_dag(uint8_t instance_id)
return dag;
}
}
RPL_STAT(rpl_stats.mem_overflows++);
return NULL;
}
/************************************************************************/
@ -372,6 +373,7 @@ rpl_dag_t *
rpl_get_dag(int instance_id)
{
int i;
for(i = 0; i < RPL_MAX_DAG_ENTRIES; i++) {
if(dag_table[i].joined && (instance_id == RPL_ANY_INSTANCE ||
dag_table[i].instance_id == instance_id)) {

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-icmp6.c,v 1.33 2010/12/15 19:57:40 nvt-se Exp $
* $Id: rpl-icmp6.c,v 1.34 2010/12/17 15:24:25 nvt-se Exp $
*/
/**
* \file
@ -484,7 +484,7 @@ dao_input(void)
PRINTF("\n");
if(lifetime == ZERO_LIFETIME) {
/* No-DAO received; invoke the route purging routine. */
/* No-Path DAO received; invoke the route purging routine. */
rep = uip_ds6_route_lookup(&prefix);
if(rep != NULL && rep->state.saved_lifetime == 0) {
PRINTF("RPL: Setting expiration timer for prefix ");
@ -515,6 +515,7 @@ dao_input(void)
rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr);
if(rep == NULL) {
RPL_STAT(rpl_stats.memory_overflows++);
PRINTF("RPL: Could not add a route after receiving a DAO\n");
return;
} else {

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-timers.c,v 1.15 2010/12/15 12:12:27 nvt-se Exp $
* $Id: rpl-timers.c,v 1.16 2010/12/17 15:24:25 nvt-se Exp $
*/
/**
* \file
@ -224,10 +224,11 @@ rpl_schedule_dao(rpl_dag_t *dag)
if(!etimer_expired(&dag->dao_timer.etimer)) {
PRINTF("RPL: DAO timer already scheduled\n");
} else {
PRINTF("RPL: Scheduling DAO timer %u ticks in the future (%u %u)\n",
(unsigned)DEFAULT_DAO_LATENCY / dag->rank,
(unsigned)DEFAULT_DAO_LATENCY, (unsigned)dag->rank);
ctimer_set(&dag->dao_timer, DEFAULT_DAO_LATENCY,
expiration_time = DEFAULT_DAO_LATENCY / 2 +
(random_rand() % (DEFAULT_DAO_LATENCY));
PRINTF("RPL: Scheduling DAO timer %u ticks in the future\n",
(unsigned)expiration_time);
ctimer_set(&dag->dao_timer, expiration_time,
handle_dao_timer, dag);
}
}

View file

@ -30,7 +30,7 @@
*
* Author: Joakim Eriksson, Nicolas Tsiftes
*
* $Id: rpl.h,v 1.27 2010/12/15 13:37:34 nvt-se Exp $
* $Id: rpl.h,v 1.28 2010/12/17 15:24:25 nvt-se Exp $
*/
#ifndef RPL_H
@ -85,7 +85,8 @@
/*---------------------------------------------------------------------------*/
/* Default values for RPL constants and variables. */
#define DEFAULT_DAO_LATENCY (CLOCK_SECOND * (1 + (random_rand() & 0xf)))
/* The default value for the DAO timer. */
#define DEFAULT_DAO_LATENCY (CLOCK_SECOND * 8)
/* Special value indicating immediate removal. */
#define ZERO_LIFETIME 0