Skip to content

Commit

Permalink
DIO prefix handler update
Browse files Browse the repository at this point in the history
Accept prefix update if dio version number is same or higher than parent and time between last DIO from parent is more than 2xIMAX time.

Change-Id: I1336b604f864e11add5d2e85d8724f565f67da5b
  • Loading branch information
Juha Heiskanen committed May 28, 2019
1 parent 332735b commit 3608153
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 1 addition & 2 deletions source/RPL/rpl_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,12 @@ static void rpl_control_process_prefix_options(protocol_interface_info_entry_t *
uint32_t preferred = common_read_32_bit(ptr + 8);
const uint8_t *prefix = ptr + 16;

if (!pref_parent || neighbour == pref_parent) {
if (rpl_upward_accept_prefix_update(dodag, neighbour, pref_parent)) {

/* Store prefixes for possible forwarding */
/* XXX if leaf - don't bother? Or do we want to remember them for
* when we switch DODAG, as mentioned above?
*/

prefix_entry_t *prefix_entry = rpl_dodag_update_dio_prefix(dodag, prefix, prefix_len, flags, valid, preferred, false, true);
if (prefix_entry && pref_parent) {
rpl_control_process_prefix_option(prefix_entry, cur);
Expand Down
22 changes: 22 additions & 0 deletions source/RPL/rpl_upward.c
Original file line number Diff line number Diff line change
Expand Up @@ -1845,4 +1845,26 @@ bool rpl_upward_read_dodag_info(const rpl_instance_t *instance, rpl_dodag_info_t
return true;
}

bool rpl_upward_accept_prefix_update(const rpl_dodag_t *dodag_info, const rpl_neighbour_t *neighbour, const rpl_neighbour_t *pref_parent)
{
//Accept allways from Pref parent or before it is selected
if (!pref_parent || neighbour == pref_parent) {
return true;
}

//Accept only same or higher version number
if (rpl_dodag_version_compare(neighbour->dodag_version, pref_parent->dodag_version) & (RPL_CMP_EQUAL | RPL_CMP_GREATER)) {
//Calculate Time between from last dio from parent and this neighbour
//neighbour dio_timestamp >= pref_parent's, because it's a newly-received message
uint32_t time_between_parent = neighbour->dio_timestamp - pref_parent->dio_timestamp;
uint32_t accepted_time = (uint32_t)dodag_info->dio_timer_params.Imax * 2;
//Accept prefix Update If Time from last DIO is more than 2 x Max
if (accepted_time < time_between_parent) {
return true;
}
}

return false;
}

#endif /* HAVE_RPL */
1 change: 1 addition & 0 deletions source/RPL/rpl_upward.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@ void rpl_instance_run_parent_selection(rpl_instance_t *instance);
void rpl_upward_print_instance(rpl_instance_t *instance, route_print_fn_t *print_fn);

bool rpl_upward_read_dodag_info(const rpl_instance_t *instance, struct rpl_dodag_info_t *dodag_info);
bool rpl_upward_accept_prefix_update(const rpl_dodag_t *dodag_info, const rpl_neighbour_t *neighbour, const rpl_neighbour_t *pref_parent);
uint16_t rpl_upward_read_dao_target_list_size(const rpl_instance_t *instance, const uint8_t *target_prefix);
#endif /* RPL_UPWARD_H_ */
5 changes: 5 additions & 0 deletions test/nanostack/unittest/stub/rpl_upward_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ bool rpl_upward_read_dodag_info(const rpl_instance_t *instance, rpl_dodag_info_t
return false;
}

bool rpl_upward_accept_prefix_update(const rpl_dodag_t *dodag_info, const rpl_neighbour_t *neighbour, const rpl_neighbour_t *pref_parent)
{
return false;
}

uint16_t rpl_upward_read_dao_target_list_size(const rpl_instance_t *instance, const uint8_t *target_prefix)
{
return 0;
Expand Down

0 comments on commit 3608153

Please sign in to comment.