Skip to content

Commit

Permalink
Pendig address registration will move DAO send.
Browse files Browse the repository at this point in the history
Wi-sun node must wait min 5 seconds negative ARO before send DAO.

Change-Id: Ib4fb1050403bbbdfe438a269f6d1e489a3a7028d
  • Loading branch information
Juha Heiskanen committed Jun 13, 2019
1 parent f54ea6b commit 9ce41f1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
39 changes: 39 additions & 0 deletions source/RPL/rpl_downward.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ bool rpl_instance_address_registration_done(protocol_interface_info_entry_t *int
addr->addr_reg_done |= neighbour->dao_path_control;
/* State_timer is 1/10 s. Set renewal to 75-85% of lifetime */
addr->state_timer = (addr->preferred_lifetime * randLIB_get_random_in_range(75, 85) / 10);
neighbour->dao_wait_after_registration = 6;
} else {
tr_error("Address registration failed");
rpl_delete_neighbour(instance, neighbour);
Expand All @@ -640,6 +641,30 @@ bool rpl_instance_address_registration_done(protocol_interface_info_entry_t *int
return false;
}

static bool rpl_instance_dao_address_reg_pending_check(rpl_instance_t *instance)
{
//Validate that there is no pending address at list
rpl_neighbour_t *neighbour = ns_list_get_first(&instance->candidate_neighbours);
if (!neighbour) {
return true;
}
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(neighbour->interface_id);
if (!cur) {
return true;
}

ns_list_foreach(if_address_entry_t, addr, &cur->ip_addresses) {

/* Optimize, ll addresses are not registered anyway.. */
if (!addr_is_ipv6_link_local(addr->address) && addr->addr_reg_pend) {
return true;
}
}

return false;
}


/* We are optimised for sending updates to existing targets to current parents;
* we track the state of what information DAO parents have, and manage the
* updates together with message coalescing and ack tracking.
Expand Down Expand Up @@ -673,6 +698,20 @@ void rpl_instance_send_dao_update(rpl_instance_t *instance)
return;
}

//Verify that no pending address registartion to parent
if (rpl_instance_dao_address_reg_pending_check(instance)) {
rpl_instance_dao_trigger(instance, 6 * 10);
return;
}

//Verify that no pending dao wait time
ns_list_foreach_safe(rpl_neighbour_t, n, &instance->candidate_neighbours) {
if (n->dodag_parent && n->dao_wait_after_registration) {
rpl_instance_dao_trigger(instance, n->dao_wait_after_registration * 10);
return;
}
}

if (instance->dao_in_transit) {
// Force current DAO timeout to be cut short, then
// when it times out, it will re-evaluate the situation,
Expand Down
1 change: 1 addition & 0 deletions source/RPL/rpl_structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct rpl_neighbour {
bool have_global_address: 1; // Global address known
bool considered: 1; // Have considered at least once for parent selection
unsigned dodag_pref: 4; // Preference indication for DODAG parents (0=best)
uint8_t dao_wait_after_registration;
uint8_t dao_path_control; // Path control bit assignments for DAO parent
uint8_t old_dao_path_control;
int8_t interface_id;
Expand Down
18 changes: 18 additions & 0 deletions source/RPL/rpl_upward.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,25 @@ void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t de
}
}

static void rpl_instance_parent_address_reg_timer_update(rpl_instance_t *instance, uint16_t seconds)
{
ns_list_foreach_safe(rpl_neighbour_t, n, &instance->candidate_neighbours) {
if (!n->dodag_parent || n->dao_wait_after_registration == 0) {
continue;
}
uint16_t wait_time = n->dao_wait_after_registration;
if (seconds >= wait_time) {
n->dao_wait_after_registration = 0;
} else {
n->dao_wait_after_registration -= seconds;
}
}
}

static void rpl_instance_parent_selection_timer(rpl_instance_t *instance, uint16_t seconds)
{
rpl_instance_parent_address_reg_timer_update(instance, seconds);

if (instance->parent_selection_timer > seconds) {
instance->parent_selection_timer -= seconds;
} else if (instance->parent_selection_timer != 0) {
Expand Down Expand Up @@ -405,6 +422,7 @@ rpl_neighbour_t *rpl_create_neighbour(rpl_dodag_version_t *version, const uint8_
neighbour->g_mop_prf = g_mop_prf;
neighbour->dtsn = dtsn;
neighbour->dao_path_control = 0;
neighbour->dao_wait_after_registration = 0;

/* Need to limit number of neighbours here - chucking worst neighbour */

Expand Down

0 comments on commit 9ce41f1

Please sign in to comment.