Various bug fixes and adjustments for rpl-11

This commit is contained in:
nvt-se 2010-09-15 13:22:22 +00:00
parent 11d5a3eb28
commit adf6961a85
5 changed files with 56 additions and 45 deletions

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-dag.c,v 1.31 2010/07/03 23:52:02 nvt-se Exp $
* $Id: rpl-dag.c,v 1.32 2010/09/15 13:22:22 nvt-se Exp $
*/
/**
* \file
@ -103,12 +103,12 @@ remove_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
{
rpl_parent_t *p, *p2;
PRINTF("RPL: Removing parents (minimum rank %u, poisoning routes %d\n",
minimum_rank, poison_routes);
PRINTF("RPL: Removing parents (minimum rank %u)\n",
minimum_rank);
for(p = list_head(dag->parents); p != NULL; p = p2) {
p2 = p->next;
if(p->rank >= minimum_rank) {
if(DAG_RANK(p->rank, dag) >= minimum_rank) {
rpl_remove_parent(dag, p);
}
}
@ -125,7 +125,8 @@ should_send_dao(rpl_dag_t *dag, rpl_dio_t *dio, rpl_parent_t *p)
static int
acceptable_rank(rpl_dag_t *dag, rpl_rank_t rank)
{
return rank != INFINITE_RANK && rank <= dag->min_rank + dag->max_rankinc;
return rank != INFINITE_RANK &&
DAG_RANK(rank, dag) <= DAG_RANK(dag->min_rank + dag->max_rankinc, dag);
}
/************************************************************************/
rpl_dag_t *
@ -445,8 +446,10 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
dag->preference = dio->preference;
dag->grounded = dio->grounded;
dag->instance_id = dio->instance_id;
dag->rank = dag->of->calculate_rank(NULL, dio->rank);
dag->min_rank = dag->rank; /* So far this is the lowest rank we know */
dag->max_rankinc = dio->dag_max_rankinc;
dag->min_hoprankinc = dio->dag_min_hoprankinc;
dag->version = dio->version;
dag->preferred_parent = p;
ANNOTATE("#L %u 1\n", p->addr.u8[sizeof(p->addr) - 1]);
@ -455,9 +458,6 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
dag->dio_intmin = dio->dag_intmin;
dag->dio_redundancy = dio->dag_redund;
dag->max_rankinc = dio->dag_max_rankinc;
dag->min_hoprankinc = dio->dag_min_hoprankinc;
memcpy(&dag->dag_id, &dio->dag_id, sizeof(dio->dag_id));
/* copy prefix information into the dag */
@ -468,6 +468,9 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
dag->rank = dag->of->calculate_rank(NULL, dio->rank);
dag->min_rank = dag->rank; /* So far this is the lowest rank we know */
rpl_reset_dio_timer(dag, 1);
rpl_set_default_route(dag, from);
@ -562,7 +565,7 @@ rpl_process_parent_event(rpl_dag_t *dag, rpl_parent_t *p)
return 1;
}
if(old_rank != dag->rank) {
if(DAG_RANK(old_rank, dag) != DAG_RANK(dag->rank, dag)) {
if(dag->rank < dag->min_rank) {
dag->min_rank = dag->rank;
}
@ -645,7 +648,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
if(p == NULL) {
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS) {
/* Try to make room for a new parent. */
remove_parents(dag, dio->rank);
remove_parents(dag, DAG_RANK(dio->rank, dag));
}
/* Add the DIO sender as a candidate parent. */
@ -660,12 +663,12 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else if(p->rank == dio->rank) {
} else if(DAG_RANK(p->rank, dag) == DAG_RANK(dio->rank, dag)) {
PRINTF("RPL: Received consistent DIO\n");
dag->dio_counter++;
}
/* We have an allocated candidate parent, process the DIO further. */
/* We have allocated a candidate parent; process the DIO further. */
p->rank = dio->rank;
if(rpl_process_parent_event(dag, p) == 0) {
@ -676,6 +679,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
if(should_send_dao(dag, dio, p)) {
rpl_schedule_dao(dag);
}
p->dtsn = dio->dtsn;
}
/************************************************************************/

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-icmp6.c,v 1.22 2010/06/14 19:19:17 adamdunkels Exp $
* $Id: rpl-icmp6.c,v 1.23 2010/09/15 13:22:23 nvt-se Exp $
*/
/**
* \file
@ -211,7 +211,7 @@ dio_input(void)
dio.instance_id = buffer[i++];
dio.version = buffer[i++];
dio.rank = (buffer[i] << 8) + buffer[i + 1];
dio.rank = (buffer[i] << 8) | buffer[i + 1];
i += 2;
PRINTF("RPL: Incoming DIO rank %u\n", (unsigned)dio.rank);

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-of-etx.c,v 1.5 2010/06/14 12:44:37 nvt-se Exp $
* $Id: rpl-of-etx.c,v 1.6 2010/09/15 13:22:23 nvt-se Exp $
*/
/**
* \file
@ -61,7 +61,7 @@ rpl_of_t rpl_of_etx = {
#define LINK_ETX_MIN 1
#define LINK_ETX_MAX 10
#define LINK_ETX_GUESS (LINK_ETX_MAX - 1)
#define LINK_ETX_GUESS 3
#define PATH_ETX_MIN 1
#define PATH_ETX_MAX 200
#define PARENT_SWITCH_ETX_THRESHOLD 0.5
@ -98,20 +98,25 @@ calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank)
rpl_rank_t new_rank;
rpl_rank_t rank_increase;
PRINTF("RPL: OF1 calculate rank\n");
dag = (rpl_dag_t *)p->dag;
rank_increase = p == NULL ? LINK_ETX_GUESS : p->local_confidence;
rank_increase += dag->min_hoprankinc;
if(base_rank == 0) {
if(p == NULL) {
if(p == NULL) {
if(base_rank == 0) {
return INFINITE_RANK;
}
base_rank = p->rank;
rank_increase = LINK_ETX_GUESS * DEFAULT_MIN_HOPRANKINC;
} else {
dag = (rpl_dag_t *)p->dag;
if(p->local_confidence == 0) {
p->local_confidence = LINK_ETX_GUESS;
}
rank_increase = p->local_confidence * dag->min_hoprankinc;
if(base_rank == 0) {
base_rank = p->rank;
}
}
PRINTF("RPL: OF1 calculate rank, base rank = %u, rank_increase = %u\n",
(unsigned)base_rank, rank_increase);
if(base_rank < min_path_etx) {
min_path_etx = base_rank;
PRINTF("RPL: min_path_etx updated to %u\n", min_path_etx);
@ -138,12 +143,13 @@ best_parent(rpl_parent_t *p1, rpl_parent_t *p2)
rpl_rank_t p1_rank;
rpl_rank_t p2_rank;
p1_rank = calculate_rank(p1, 0);
p2_rank = calculate_rank(p2, 0);
dag = (rpl_dag_t *)p1->dag; /* Both parents must be in the same DAG. */
p1_rank = DAG_RANK(calculate_rank(p1, 0), dag);
p2_rank = DAG_RANK(calculate_rank(p2, 0), dag);
/* Maintain stability of the preferred parent in case of similar ranks. */
if(p1_rank == p2_rank) {
dag = (rpl_dag_t *)p1->dag;
if(p1 == dag->preferred_parent) {
return p1;
} else if(p2 == dag->preferred_parent) {

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-timers.c,v 1.10 2010/06/14 12:44:37 nvt-se Exp $
* $Id: rpl-timers.c,v 1.11 2010/09/15 13:22:23 nvt-se Exp $
*/
/**
* \file
@ -102,7 +102,8 @@ new_dio_interval(rpl_dag_t *dag)
/* keep some stats */
dag->dio_totint++;
dag->dio_totrecv += dag->dio_counter;
ANNOTATE("#A rank=%d(%d),stats=%d %d %d %d,color=%s\n", dag->rank,
ANNOTATE("#A rank=%u(%u),stats=%d %d %d %d,color=%s\n",
DAG_RANK(dag->rank, dag),
dag->version,
dag->dio_totint, dag->dio_totsend,
dag->dio_totrecv,dag->dio_intcurrent,

View file

@ -30,7 +30,7 @@
*
* Author: Joakim Eriksson, Nicolas Tsiftes
*
* $Id: rpl.h,v 1.19 2010/06/14 12:44:37 nvt-se Exp $
* $Id: rpl.h,v 1.20 2010/09/15 13:22:23 nvt-se Exp $
*/
#ifndef RPL_H
@ -96,11 +96,16 @@
/* Default route lifetime in seconds. */
#define DEFAULT_ROUTE_LIFETIME INFINITE_LIFETIME
#define DEFAULT_MIN_HOPRANKINC 256
#define DEFAULT_MAX_RANKINC 3*DEFAULT_MIN_HOPRANKINC
#define DAG_RANK(fixpt_rank, dag) ((fixpt_rank) / dag->min_hoprankinc)
/* Rank of a node outside the LLN. */
#define BASE_RANK 0
/* Rank of a root node. */
#define ROOT_RANK 1
#define ROOT_RANK DEFAULT_MIN_HOPRANKINC
#define INFINITE_RANK 0xffff
@ -109,10 +114,6 @@
#define RPL_DEFAULT_OCP 1
/* TODO: pick these from OCP later? */
#define DEFAULT_MAX_RANKINC 10
#define DEFAULT_MIN_HOPRANKINC 4
/* Represents 2^n ms. */
#define DEFAULT_DIO_INTERVAL_MIN 12
@ -120,7 +121,7 @@
#define DEFAULT_DIO_INTERVAL_DOUBLINGS 8
/* Desired DIO redundancy. */
#define DEFAULT_DIO_REDUNDANCY 5
#define DEFAULT_DIO_REDUNDANCY 10
/* Expire DAOs from neighbors that do not respond in this time. (seconds) */
#define DAO_EXPIRATION_TIMEOUT 60
@ -225,8 +226,8 @@ struct rpl_dio {
uint8_t dag_intdoubl;
uint8_t dag_intmin;
uint8_t dag_redund;
uint8_t dag_max_rankinc;
uint8_t dag_min_hoprankinc;
rpl_rank_t dag_max_rankinc;
rpl_rank_t dag_min_hoprankinc;
rpl_prefix_t destination_prefix;
rpl_prefix_t prefix_info;
};
@ -250,10 +251,9 @@ struct rpl_dag {
uint8_t dio_intdoubl;
uint8_t dio_intmin;
uint8_t dio_redundancy;
uint8_t max_rankinc;
uint8_t min_hoprankinc;
rpl_rank_t max_rankinc;
rpl_rank_t min_hoprankinc;
uint8_t used;
/* live data for the DAG */
uint8_t joined;
uint8_t dio_intcurrent;