Skip to content

Commit 3608153

Browse files
author
Juha Heiskanen
committed
DIO prefix handler update
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
1 parent 332735b commit 3608153

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

source/RPL/rpl_control.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,13 +686,12 @@ static void rpl_control_process_prefix_options(protocol_interface_info_entry_t *
686686
uint32_t preferred = common_read_32_bit(ptr + 8);
687687
const uint8_t *prefix = ptr + 16;
688688

689-
if (!pref_parent || neighbour == pref_parent) {
689+
if (rpl_upward_accept_prefix_update(dodag, neighbour, pref_parent)) {
690690

691691
/* Store prefixes for possible forwarding */
692692
/* XXX if leaf - don't bother? Or do we want to remember them for
693693
* when we switch DODAG, as mentioned above?
694694
*/
695-
696695
prefix_entry_t *prefix_entry = rpl_dodag_update_dio_prefix(dodag, prefix, prefix_len, flags, valid, preferred, false, true);
697696
if (prefix_entry && pref_parent) {
698697
rpl_control_process_prefix_option(prefix_entry, cur);

source/RPL/rpl_upward.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,4 +1845,26 @@ bool rpl_upward_read_dodag_info(const rpl_instance_t *instance, rpl_dodag_info_t
18451845
return true;
18461846
}
18471847

1848+
bool rpl_upward_accept_prefix_update(const rpl_dodag_t *dodag_info, const rpl_neighbour_t *neighbour, const rpl_neighbour_t *pref_parent)
1849+
{
1850+
//Accept allways from Pref parent or before it is selected
1851+
if (!pref_parent || neighbour == pref_parent) {
1852+
return true;
1853+
}
1854+
1855+
//Accept only same or higher version number
1856+
if (rpl_dodag_version_compare(neighbour->dodag_version, pref_parent->dodag_version) & (RPL_CMP_EQUAL | RPL_CMP_GREATER)) {
1857+
//Calculate Time between from last dio from parent and this neighbour
1858+
//neighbour dio_timestamp >= pref_parent's, because it's a newly-received message
1859+
uint32_t time_between_parent = neighbour->dio_timestamp - pref_parent->dio_timestamp;
1860+
uint32_t accepted_time = (uint32_t)dodag_info->dio_timer_params.Imax * 2;
1861+
//Accept prefix Update If Time from last DIO is more than 2 x Max
1862+
if (accepted_time < time_between_parent) {
1863+
return true;
1864+
}
1865+
}
1866+
1867+
return false;
1868+
}
1869+
18481870
#endif /* HAVE_RPL */

source/RPL/rpl_upward.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,6 @@ void rpl_instance_run_parent_selection(rpl_instance_t *instance);
145145
void rpl_upward_print_instance(rpl_instance_t *instance, route_print_fn_t *print_fn);
146146

147147
bool rpl_upward_read_dodag_info(const rpl_instance_t *instance, struct rpl_dodag_info_t *dodag_info);
148+
bool rpl_upward_accept_prefix_update(const rpl_dodag_t *dodag_info, const rpl_neighbour_t *neighbour, const rpl_neighbour_t *pref_parent);
148149
uint16_t rpl_upward_read_dao_target_list_size(const rpl_instance_t *instance, const uint8_t *target_prefix);
149150
#endif /* RPL_UPWARD_H_ */

test/nanostack/unittest/stub/rpl_upward_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ bool rpl_upward_read_dodag_info(const rpl_instance_t *instance, rpl_dodag_info_t
456456
return false;
457457
}
458458

459+
bool rpl_upward_accept_prefix_update(const rpl_dodag_t *dodag_info, const rpl_neighbour_t *neighbour, const rpl_neighbour_t *pref_parent)
460+
{
461+
return false;
462+
}
463+
459464
uint16_t rpl_upward_read_dao_target_list_size(const rpl_instance_t *instance, const uint8_t *target_prefix)
460465
{
461466
return 0;

0 commit comments

Comments
 (0)