mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
Improvements to local repair and DAO handling.
This commit is contained in:
parent
f882901bf6
commit
c5d1c3ea27
@ -32,7 +32,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-dag.c,v 1.6 2010/05/10 13:46:35 nifi Exp $
|
||||
* $Id: rpl-dag.c,v 1.7 2010/05/24 16:38:56 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -523,6 +523,11 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
if(RPL_PARENT_COUNT(dag) > 1) {
|
||||
/* Since we have alternative parents, we can simply drop this one. */
|
||||
rpl_remove_neighbor(dag, n);
|
||||
n = rpl_find_best_parent(dag);
|
||||
if(n != NULL) {
|
||||
rpl_set_default_route(dag, &n->addr);
|
||||
}
|
||||
return;
|
||||
} else if(dag->of->increment_rank(dio->dag_rank, n) <= dag->min_rank + dag->max_rankinc) {
|
||||
dag->rank = dag->of->increment_rank(dio->dag_rank, n);
|
||||
PRINTF("RPL: New rank is %hu, max is %hu\n",
|
||||
|
@ -33,7 +33,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-icmp6.c,v 1.8 2010/05/19 16:16:57 joxe Exp $
|
||||
* $Id: rpl-icmp6.c,v 1.9 2010/05/24 16:38:56 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -374,18 +374,19 @@ dao_input(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if(rank < dag->rank) {
|
||||
PRINTF("RPL: Incoming DAO rank is %u, my rank is %u\n",
|
||||
(unsigned)rank, (unsigned)dag->rank);
|
||||
if(rank < dag->rank) {
|
||||
return;
|
||||
}
|
||||
|
||||
PRINTF("RPL: DAO rank: %u, lifetime: %lu, prefix length: %u\n",
|
||||
(unsigned)rank, (unsigned long)lifetime, (unsigned)prefixlen);
|
||||
|
||||
memset(&prefix, 0, sizeof(prefix));
|
||||
memcpy(&prefix, buffer + pos, prefixlen / CHAR_BIT);
|
||||
|
||||
PRINTF("RPL: DAO rank: %u, lifetime: %lu, prefix length: %u",
|
||||
(unsigned)rank, (unsigned long)lifetime, (unsigned)prefixlen);
|
||||
PRINTF("\n");
|
||||
|
||||
if(lifetime == ZERO_LIFETIME) {
|
||||
/* No-DAO received; invoke the route purging routine. */
|
||||
rep = uip_ds6_route_lookup(&prefix);
|
||||
|
@ -32,7 +32,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-timers.c,v 1.4 2010/05/09 19:12:47 joxe Exp $
|
||||
* $Id: rpl-timers.c,v 1.5 2010/05/24 16:38:56 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -101,9 +101,10 @@ new_dio_interval(rpl_dag_t *dag)
|
||||
/* keep some stats */
|
||||
dag->dio_totint++;
|
||||
dag->dio_totrecv += dag->dio_counter;
|
||||
ANNOTATE("#A rank=%d,ints=%d,snd=%d,rcv=%d,cint=%d\n", dag->rank,
|
||||
ANNOTATE("#A rank=%d,stats=%d %d %d %d,color=%s\n", dag->rank,
|
||||
dag->dio_totint, dag->dio_totsend,
|
||||
dag->dio_totrecv,dag->dio_intcurrent);
|
||||
dag->dio_totrecv,dag->dio_intcurrent,
|
||||
dag->rank == ROOT_RANK ? "BLUE" : "ORANGE");
|
||||
#endif /* RPL_CONF_STATS */
|
||||
|
||||
/* reset the redundancy counter */
|
||||
@ -184,7 +185,7 @@ handle_dao_timer(void *ptr)
|
||||
dag = (rpl_dag_t *)ptr;
|
||||
|
||||
if (!dio_send_ok && uip_ds6_get_link_local(ADDR_PREFERRED) == NULL) {
|
||||
PRINTF("RPL: postpone DAO transmission... \n");
|
||||
PRINTF("RPL: Postpone DAO transmission... \n");
|
||||
ctimer_set(&dag->dao_timer, CLOCK_SECOND, handle_dao_timer, dag);
|
||||
return;
|
||||
}
|
||||
@ -196,7 +197,7 @@ handle_dao_timer(void *ptr)
|
||||
PRINTF("RPL: handle_dao_timer - sending DAO\n");
|
||||
dao_output(n, DEFAULT_ROUTE_LIFETIME);
|
||||
} else {
|
||||
PRINTF("RPL: could not find any best parent.. \n");
|
||||
PRINTF("RPL: Could not find a parent to send a DAO to \n");
|
||||
}
|
||||
ctimer_stop(&dag->dao_timer);
|
||||
}
|
||||
@ -205,6 +206,7 @@ void
|
||||
rpl_schedule_dao(rpl_dag_t *dag)
|
||||
{
|
||||
clock_time_t expiration_time;
|
||||
|
||||
expiration_time = etimer_expiration_time(&dag->dao_timer.etimer);
|
||||
|
||||
if(!etimer_expired(&dag->dao_timer.etimer) &&
|
||||
|
@ -32,7 +32,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl.c,v 1.2 2010/05/18 16:43:56 nvt-se Exp $
|
||||
* $Id: rpl.c,v 1.3 2010/05/24 16:38:56 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -84,13 +84,20 @@ rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix, int prefix_len,
|
||||
{
|
||||
uip_ds6_route_t *rep;
|
||||
|
||||
if((rep = uip_ds6_route_lookup(prefix)) == NULL) {
|
||||
|
||||
rep = uip_ds6_route_lookup(prefix);
|
||||
if(rep == NULL) {
|
||||
if((rep = uip_ds6_route_add(prefix, prefix_len, next_hop, 0)) == NULL) {
|
||||
PRINTF("RPL: No space for more route entries\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} else {
|
||||
PRINTF("RPL: Updated the next hop for prefix ");
|
||||
PRINT6ADDR(prefix);
|
||||
PRINTF(" to ");
|
||||
PRINT6ADDR(next_hop);
|
||||
PRINTF("\n");
|
||||
uip_ipaddr_copy(&rep->nexthop, next_hop);
|
||||
}
|
||||
rep->state.dag = dag;
|
||||
rep->state.lifetime = DEFAULT_ROUTE_LIFETIME;
|
||||
rep->state.learned_from = RPL_ROUTE_FROM_INTERNAL;
|
||||
@ -100,7 +107,7 @@ rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix, int prefix_len,
|
||||
PRINTF("/%d via ", prefix_len);
|
||||
PRINT6ADDR(next_hop);
|
||||
PRINTF("\n");
|
||||
}
|
||||
|
||||
return rep;
|
||||
}
|
||||
/************************************************************************/
|
||||
@ -110,7 +117,6 @@ neighbor_callback(const rimeaddr_t *addr, int known, int etx)
|
||||
uip_ipaddr_t ipaddr;
|
||||
rpl_dag_t *dag;
|
||||
rpl_neighbor_t *parent;
|
||||
uip_ds6_route_t *rep;
|
||||
|
||||
uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0);
|
||||
uip_ds6_set_addr_iid(&ipaddr, (uip_lladdr_t *)addr);
|
||||
@ -119,22 +125,11 @@ neighbor_callback(const rimeaddr_t *addr, int known, int etx)
|
||||
PRINTF(" is %sknown. ETX = %d\n", known ? "" : "no longer ", etx);
|
||||
|
||||
dag = rpl_get_dag(RPL_DEFAULT_INSTANCE);
|
||||
if(dag == NULL) {
|
||||
if(dag == NULL || (parent = rpl_find_neighbor(dag, &ipaddr)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent = rpl_find_neighbor(dag, &ipaddr);
|
||||
if(parent == NULL) {
|
||||
rep = uip_ds6_route_lookup(&ipaddr);
|
||||
if(rep != NULL) {
|
||||
if(!known) {
|
||||
rep->state.lifetime = DAO_EXPIRATION_TIMEOUT;
|
||||
rep->state.saved_lifetime = rep->state.lifetime;
|
||||
} else {
|
||||
rep->state.lifetime = rep->state.saved_lifetime;
|
||||
}
|
||||
}
|
||||
} else if(!known) {
|
||||
PRINTF("RPL: Removing parent ");
|
||||
PRINT6ADDR(&parent->addr);
|
||||
PRINTF(" because of bad connectivity (ETX %d)\n", etx);
|
||||
|
Loading…
Reference in New Issue
Block a user