fixed a bug in nbr policy and DAO retransmission handling and added new wismote simulation

This commit is contained in:
Joakim Eriksson 2016-02-18 22:40:30 +01:00
parent ee97dc4bcd
commit 12ac02650b
3 changed files with 751 additions and 27 deletions

View file

@ -976,6 +976,25 @@ dao_output(rpl_parent_t *parent, uint8_t lifetime)
return;
}
#if RPL_WITH_DAO_ACK
/* set up the state since this will be the first transmission of DAO */
/* retransmissions will call directly to dao_output_target_seq */
/* keep track of my own sending of DAO for handling ack and loss of ack */
if(lifetime != RPL_ZERO_LIFETIME) {
rpl_instance_t *instance;
instance = parent->dag->instance;
instance->my_dao_seqno = dao_sequence;
instance->my_dao_transmissions = 1;
ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT,
handle_dao_retransmission, parent);
}
#else
/* We know that we have tried to register so now we are assuming
that we have a down-link - unless this is a zero lifetime one */
rpl_set_downward_link(lifetime != RPL_ZERO_LIFETIME);
#endif /* RPL_WITH_DAO_ACK */
/* Sending a DAO with own prefix as target */
dao_output_target(parent, &prefix, lifetime);
}
@ -1074,19 +1093,6 @@ dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix,
if(rpl_get_parent_ipaddr(parent) != NULL) {
uip_icmp6_send(rpl_get_parent_ipaddr(parent), ICMP6_RPL, RPL_CODE_DAO, pos);
#if RPL_WITH_DAO_ACK
if(lifetime != RPL_ZERO_LIFETIME) {
/* keep track of my own sending of DAO for handling ack and loss of ack */
instance->my_dao_seqno = dao_sequence;
instance->my_dao_transmissions = 1;
ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT,
handle_dao_retransmission, parent);
}
#else /* RPL_WITH_DAO_ACK */
/* We know that we have tried to register so now we are assuming
that we have a down-link - unless this is a zero lifetime one */
rpl_set_downward_link(lifetime != RPL_ZERO_LIFETIME);
#endif /* RPL_WITH_DAO_ACK */
}
}
/*---------------------------------------------------------------------------*/

View file

@ -111,36 +111,33 @@ update_nbr(void)
linkaddr_t *lladdr = nbr_table_get_lladdr(ds6_neighbors, nbr);
is_used = 0;
/* Check if this neighbor is used as nexthop and therefor being a
RPL child. */
if(uip_ds6_route_is_nexthop((uip_lladdr_t *)lladdr) != 0) {
is_used++;
num_children++;
}
parent = rpl_get_parent((uip_lladdr_t *)lladdr);
if(parent != NULL) {
num_parents++;
is_used++;
if(parent->dag != NULL && parent->dag->preferred_parent == parent) {
/* This is the preferred parent for the DAG and must not be removed */
/* Note: this assumes that only RPL adds default routes. */
} else if(worst_rank < INFINITE_RANK &&
} else if(is_used == 0 && worst_rank < INFINITE_RANK &&
parent->rank > 0 &&
parent->dag != NULL &&
parent->dag->instance != NULL &&
(rank = parent->dag->instance->of->calculate_rank(parent, 0)) > worst_rank) {
/* This is the worst-rank neighbor - this is a good candidate for removal */
if(uip_ds6_route_is_nexthop((uip_lladdr_t *)lladdr) == 0) {
worst_rank = rank;
worst_rank_nbr = lladdr;
} else {
printf("*** Can not use this as worst rank as it is a next hop\n");
}
worst_rank = rank;
worst_rank_nbr = lladdr;
}
}
/* Check if this neighbor is used as nexthop and therefor being a
RPL child. */
if(uip_ds6_route_is_nexthop((uip_lladdr_t *)lladdr) != 0) {
/* add to is_used after evaluation of is_used above */
is_used++;
num_children++;
}
if(is_used == 0) {