fixed a minor bug causing too low rank during global repair
This commit is contained in:
parent
941443878b
commit
62abed8347
@ -32,7 +32,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-dag.c,v 1.14 2010/06/02 16:23:08 joxe Exp $
|
||||
* $Id: rpl-dag.c,v 1.15 2010/06/02 16:54:59 joxe Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -243,7 +243,7 @@ rpl_free_dag(rpl_dag_t *dag)
|
||||
}
|
||||
/************************************************************************/
|
||||
rpl_parent_t *
|
||||
rpl_add_parent(rpl_dag_t *dag, uip_ipaddr_t *addr)
|
||||
rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
|
||||
{
|
||||
rpl_parent_t *p;
|
||||
|
||||
@ -255,6 +255,7 @@ rpl_add_parent(rpl_dag_t *dag, uip_ipaddr_t *addr)
|
||||
memcpy(&p->addr, addr, sizeof(p->addr));
|
||||
p->local_confidence = 0;
|
||||
p->dag = dag;
|
||||
p->rank = dio->dag_rank;
|
||||
|
||||
list_add(dag->parents, p);
|
||||
|
||||
@ -387,7 +388,7 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
return;
|
||||
}
|
||||
|
||||
p = rpl_add_parent(dag, from);
|
||||
p = rpl_add_parent(dag, dio, from);
|
||||
PRINTF("RPL: Adding ");
|
||||
PRINT6ADDR(from);
|
||||
PRINTF(" as a parent: ");
|
||||
@ -398,7 +399,6 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
PRINTF("succeeded\n");
|
||||
|
||||
p->local_confidence = 0; /* The lowest confidence for new parents. */
|
||||
p->rank = dio->dag_rank;
|
||||
|
||||
/* Determine the objective function by using the
|
||||
objective code point of the DIO. */
|
||||
@ -452,12 +452,12 @@ global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio)
|
||||
|
||||
poison_routes(dag, NULL);
|
||||
dag->version = dio->version;
|
||||
if((p = rpl_add_parent(dag, from)) == NULL) {
|
||||
dag->of->reset(dag);
|
||||
if((p = rpl_add_parent(dag, dio, from)) == NULL) {
|
||||
PRINTF("RPL: Failed to add a parent during the global repair\n");
|
||||
dag->rank = INFINITE_RANK;
|
||||
} else {
|
||||
rpl_set_default_route(dag, from);
|
||||
dag->of->reset(dag);
|
||||
dag->rank = dag->of->increment_rank(dio->dag_rank, p);
|
||||
rpl_reset_dio_timer(dag, 1);
|
||||
}
|
||||
@ -519,6 +519,11 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
global_repair(from, dag, dio);
|
||||
}
|
||||
return;
|
||||
} else if(dio->version < dag->version) {
|
||||
/* Inconsistency detected - someone is still on old version */
|
||||
PRINTF("RPL: old version received => inconsistency detected\n");
|
||||
rpl_reset_dio_timer(dag, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* This DIO pertains to a DAG that we are already part of. */
|
||||
@ -575,13 +580,12 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
}
|
||||
new_parent = 0;
|
||||
if(p == NULL) {
|
||||
p = rpl_add_parent(dag, from);
|
||||
p = rpl_add_parent(dag, dio, from);
|
||||
if(p == NULL) {
|
||||
PRINTF("RPL: Could not add parent\n");
|
||||
return;
|
||||
}
|
||||
|
||||
p->rank = dio->dag_rank;
|
||||
PRINTF("RPL: New parent with rank %hu ", p->rank);
|
||||
PRINT6ADDR(from);
|
||||
PRINTF("\n");
|
||||
|
@ -32,7 +32,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-timers.c,v 1.7 2010/05/29 22:23:21 nvt-se Exp $
|
||||
* $Id: rpl-timers.c,v 1.8 2010/06/02 16:55:00 joxe Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -101,7 +101,8 @@ new_dio_interval(rpl_dag_t *dag)
|
||||
/* keep some stats */
|
||||
dag->dio_totint++;
|
||||
dag->dio_totrecv += dag->dio_counter;
|
||||
ANNOTATE("#A rank=%d,stats=%d %d %d %d,color=%s\n", dag->rank,
|
||||
ANNOTATE("#A rank=%d(%d),stats=%d %d %d %d,color=%s\n", dag->rank,
|
||||
dag->version,
|
||||
dag->dio_totint, dag->dio_totsend,
|
||||
dag->dio_totrecv,dag->dio_intcurrent,
|
||||
dag->rank == ROOT_RANK ? "BLUE" : "ORANGE");
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* Author: Joakim Eriksson, Nicolas Tsiftes
|
||||
*
|
||||
* $Id: rpl.h,v 1.9 2010/06/02 16:23:12 joxe Exp $
|
||||
* $Id: rpl.h,v 1.10 2010/06/02 16:55:00 joxe Exp $
|
||||
*/
|
||||
|
||||
#ifndef RPL_H
|
||||
@ -274,7 +274,7 @@ rpl_dag_t *rpl_alloc_dag(void);
|
||||
void rpl_free_dag(rpl_dag_t *);
|
||||
|
||||
/* DAG parent management function. */
|
||||
rpl_parent_t *rpl_add_parent(rpl_dag_t *, uip_ipaddr_t *);
|
||||
rpl_parent_t *rpl_add_parent(rpl_dag_t *, rpl_dio_t *dio, uip_ipaddr_t *);
|
||||
rpl_parent_t *rpl_find_parent(rpl_dag_t *, uip_ipaddr_t *);
|
||||
int rpl_remove_parent(rpl_dag_t *, rpl_parent_t *);
|
||||
rpl_parent_t *rpl_preferred_parent(rpl_dag_t *dag);
|
||||
|
Loading…
Reference in New Issue
Block a user