Merge pull request #608 from nvt/rpl-fixes

Minor RPL improvements
This commit is contained in:
Nicolas Tsiftes 2014-04-07 11:13:38 +02:00
commit a7dbf46b8e
7 changed files with 34 additions and 28 deletions

View file

@ -987,7 +987,7 @@ rpl_add_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
instance->dio_redundancy != dio->dag_redund || instance->dio_redundancy != dio->dag_redund ||
instance->default_lifetime != dio->default_lifetime || instance->default_lifetime != dio->default_lifetime ||
instance->lifetime_unit != dio->lifetime_unit) { instance->lifetime_unit != dio->lifetime_unit) {
PRINTF("RPL: DIO for DAG instance %u uncompatible with previos DIO\n", PRINTF("RPL: DIO for DAG instance %u incompatible with previous DIO\n",
dio->instance_id); dio->instance_id);
rpl_remove_parent(p); rpl_remove_parent(p);
dag->used = 0; dag->used = 0;
@ -1171,7 +1171,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
RPL_LOLLIPOP_INCREMENT(dag->version); RPL_LOLLIPOP_INCREMENT(dag->version);
rpl_reset_dio_timer(instance); rpl_reset_dio_timer(instance);
} else { } else {
PRINTF("RPL: Global Repair\n"); PRINTF("RPL: Global repair\n");
if(dio->prefix_info.length != 0) { if(dio->prefix_info.length != 0) {
if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) { if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {
PRINTF("RPL : Prefix announced in DIO\n"); PRINTF("RPL : Prefix announced in DIO\n");

View file

@ -176,12 +176,14 @@ dis_output(uip_ipaddr_t *addr)
unsigned char *buffer; unsigned char *buffer;
uip_ipaddr_t tmpaddr; uip_ipaddr_t tmpaddr;
/* DAG Information Solicitation - 2 bytes reserved */ /*
/* 0 1 2 */ * DAG Information Solicitation - 2 bytes reserved
/* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 */ * 0 1 2
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
/* | Flags | Reserved | Option(s)... */ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ * | Flags | Reserved | Option(s)...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
buffer = UIP_ICMP_PAYLOAD; buffer = UIP_ICMP_PAYLOAD;
buffer[0] = buffer[1] = 0; buffer[0] = buffer[1] = 0;
@ -241,7 +243,7 @@ dio_input(void)
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER)); PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n"); PRINTF("\n");
} else { } else {
PRINTF("RPL: Out of Memory, dropping DIO from "); PRINTF("RPL: Out of memory, dropping DIO from ");
PRINT6ADDR(&from); PRINT6ADDR(&from);
PRINTF(", "); PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER)); PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
@ -383,7 +385,7 @@ dio_input(void)
break; break;
case RPL_OPTION_PREFIX_INFO: case RPL_OPTION_PREFIX_INFO:
if(len != 32) { if(len != 32) {
PRINTF("RPL: DAG prefix info not ok, len != 32\n"); PRINTF("RPL: Invalid DAG prefix info, len != 32\n");
RPL_STAT(rpl_stats.malformed_msgs++); RPL_STAT(rpl_stats.malformed_msgs++);
return; return;
} }
@ -420,7 +422,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
#endif /* !RPL_LEAF_ONLY */ #endif /* !RPL_LEAF_ONLY */
#if RPL_LEAF_ONLY #if RPL_LEAF_ONLY
/* In leaf mode, we send DIO message only as unicasts in response to /* In leaf mode, we only send DIO messages as unicasts in response to
unicast DIS messages. */ unicast DIS messages. */
if(uc_addr == NULL) { if(uc_addr == NULL) {
PRINTF("RPL: LEAF ONLY have multicast addr: skip dio_output\n"); PRINTF("RPL: LEAF ONLY have multicast addr: skip dio_output\n");
@ -583,10 +585,11 @@ dao_input(void)
int len; int len;
int i; int i;
int learned_from; int learned_from;
rpl_parent_t *p; rpl_parent_t *parent;
uip_ds6_nbr_t *nbr; uip_ds6_nbr_t *nbr;
prefixlen = 0; prefixlen = 0;
parent = NULL;
uip_ipaddr_copy(&dao_sender_addr, &UIP_IP_BUF->srcipaddr); uip_ipaddr_copy(&dao_sender_addr, &UIP_IP_BUF->srcipaddr);
@ -623,8 +626,6 @@ dao_input(void)
return; return;
} }
pos += 16; pos += 16;
} else {
/* Perhaps, there are verification to do but ... */
} }
learned_from = uip_is_addr_mcast(&dao_sender_addr) ? learned_from = uip_is_addr_mcast(&dao_sender_addr) ?
@ -634,23 +635,23 @@ dao_input(void)
learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast"); learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast");
if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) { if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) {
/* Check whether this is a DAO forwarding loop. */ /* Check whether this is a DAO forwarding loop. */
p = rpl_find_parent(dag, &dao_sender_addr); parent = rpl_find_parent(dag, &dao_sender_addr);
/* check if this is a new DAO registration with an "illegal" rank */ /* check if this is a new DAO registration with an "illegal" rank */
/* if we already route to this node it is likely */ /* if we already route to this node it is likely */
if(p != NULL && if(parent != NULL &&
DAG_RANK(p->rank, instance) < DAG_RANK(dag->rank, instance)) { DAG_RANK(parent->rank, instance) < DAG_RANK(dag->rank, instance)) {
PRINTF("RPL: Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n", PRINTF("RPL: Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n",
DAG_RANK(p->rank, instance), DAG_RANK(dag->rank, instance)); DAG_RANK(parent->rank, instance), DAG_RANK(dag->rank, instance));
p->rank = INFINITE_RANK; parent->rank = INFINITE_RANK;
p->updated = 1; parent->updated = 1;
return; return;
} }
/* If we get the DAO from our parent, we also have a loop. */ /* If we get the DAO from our parent, we also have a loop. */
if(p != NULL && p == dag->preferred_parent) { if(parent != NULL && parent == dag->preferred_parent) {
PRINTF("RPL: Loop detected when receiving a unicast DAO from our parent\n"); PRINTF("RPL: Loop detected when receiving a unicast DAO from our parent\n");
p->rank = INFINITE_RANK; parent->rank = INFINITE_RANK;
p->updated = 1; parent->updated = 1;
return; return;
} }
} }
@ -756,7 +757,7 @@ dao_input(void)
PRINTF("RPL: Neighbor already in neighbor cache\n"); PRINTF("RPL: Neighbor already in neighbor cache\n");
} }
rpl_lock_parent(p); rpl_lock_parent(parent);
rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr); rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr);
if(rep == NULL) { if(rep == NULL) {

View file

@ -104,7 +104,7 @@ calculate_path_metric(rpl_parent_t *p)
} }
static void static void
reset(rpl_dag_t *sag) reset(rpl_dag_t *dag)
{ {
PRINTF("RPL: Reset MRHOF\n"); PRINTF("RPL: Reset MRHOF\n");
} }

View file

@ -203,7 +203,7 @@
* whose integer part can be obtained by dividing the value by * whose integer part can be obtained by dividing the value by
* RPL_DAG_MC_ETX_DIVISOR. * RPL_DAG_MC_ETX_DIVISOR.
*/ */
#define RPL_DAG_MC_ETX_DIVISOR 128 #define RPL_DAG_MC_ETX_DIVISOR 256
/* DIS related */ /* DIS related */
#define RPL_DIS_SEND 1 #define RPL_DIS_SEND 1

View file

@ -70,7 +70,7 @@ handle_periodic_timer(void *ptr)
rpl_recalculate_ranks(); rpl_recalculate_ranks();
/* handle DIS */ /* handle DIS */
#ifdef RPL_DIS_SEND #if RPL_DIS_SEND
next_dis++; next_dis++;
if(rpl_get_any_dag() == NULL && next_dis >= RPL_DIS_INTERVAL) { if(rpl_get_any_dag() == NULL && next_dis >= RPL_DIS_INTERVAL) {
next_dis = 0; next_dis = 0;

View file

@ -308,6 +308,8 @@ rpl_init(void)
#if RPL_CONF_STATS #if RPL_CONF_STATS
memset(&rpl_stats, 0, sizeof(rpl_stats)); memset(&rpl_stats, 0, sizeof(rpl_stats));
#endif #endif
RPL_OF.reset(NULL);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#endif /* UIP_CONF_IPV6 */ #endif /* UIP_CONF_IPV6 */

View file

@ -189,6 +189,9 @@ struct rpl_of {
rpl_ocp_t ocp; rpl_ocp_t ocp;
}; };
typedef struct rpl_of rpl_of_t; typedef struct rpl_of rpl_of_t;
/* Declare the selected objective function. */
extern rpl_of_t RPL_OF;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Instance */ /* Instance */
struct rpl_instance { struct rpl_instance {