Skip to content

Commit 427743f

Browse files
author
Juha Heiskanen
committed
ETX and Source route validation update
RPL downward route link capable limit from 8.0 to 4.0. This will fix broken link at SRC route. Return 0 if real is unknow. RPL parent changes and ETX changes use same dynamic timer start for new neighbour or better ETX. Change-Id: I9b7d22a45a96d100f9695184896e636f17804fbf
1 parent 7b6bcca commit 427743f

File tree

13 files changed

+40
-122
lines changed

13 files changed

+40
-122
lines changed

source/6LoWPAN/adaptation_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ int8_t lowpan_adaptation_interface_tx_confirm(protocol_interface_info_entry_t *c
12601260
}
12611261

12621262
#ifdef HAVE_RPL
1263-
if (confirm->status == MLME_TX_NO_ACK) {
1263+
if (confirm->status == MLME_TX_NO_ACK || confirm->status == MLME_UNAVAILABLE_KEY) {
12641264
if (buf->route && rpl_data_is_rpl_parent_route(buf->route->route_info.source)) {
12651265
protocol_stats_update(STATS_RPL_PARENT_TX_FAIL, 1);
12661266
}

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ static void ws_bootstrap_ll_address_validate(struct protocol_interface_info_entr
648648
uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr_type, const uint8_t *addr_ptr)
649649
{
650650

651-
uint16_t etx;
652651
if (!addr_ptr || !interface) {
653652
return 0;
654653
}
@@ -667,13 +666,7 @@ uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr
667666
return 0xffff;
668667
}
669668

670-
etx = etx_local_etx_read(interface->id, attribute_index);
671-
if (etx == 0) {
672-
return 0xffff;
673-
}
674-
675-
//tr_debug("ws_etx_read etx:%d", etx);
676-
return etx;
669+
return etx_local_etx_read(interface->id, attribute_index);;
677670
}
678671
bool ws_bootstrap_nd_ns_transmit(protocol_interface_info_entry_t *cur, ipv6_neighbour_t *entry, bool unicast, uint8_t seq)
679672
{
@@ -2564,10 +2557,11 @@ static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entr
25642557

25652558
uint16_t etx = etx_local_etx_read(cur->id, mac_neighbor->index);
25662559
if (etx == 0) {
2567-
etx = 0xffff;
2560+
etx = WS_ETX_MAX; //SET maxium value here if ETX is unknown
2561+
} else {
2562+
//Scale to 128 based ETX (local read retur 0x100 - 0xffff
2563+
etx = etx >> 1;
25682564
}
2569-
//Scale to 128 based ETX (local read retur 0x100 - 0xffff
2570-
etx = etx >> 1;
25712565

25722566
return ws_neighbor->routing_cost + etx;
25732567
}

source/RPL/rpl_control.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,19 +376,24 @@ static void rpl_control_addr_notifier(struct protocol_interface_info_entry *inte
376376

377377
static void rpl_control_etx_change_callback(int8_t nwk_id, uint16_t previous_etx, uint16_t current_etx, uint8_t attribute_index)
378378
{
379-
(void)previous_etx;
380-
(void)current_etx;
381379

382380
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(nwk_id);
383381
if (!cur || !cur->rpl_domain) {
384382
return;
385383
}
384+
// ETX is "better" if now lower, or previous was "unknown" and new isn't infinite
385+
bool better = current_etx < previous_etx || (previous_etx == 0 && current_etx != 0xffff);
386+
386387
rpl_domain_t *domain = cur->rpl_domain;
387388
uint16_t delay = rpl_policy_etx_change_parent_selection_delay(domain);
388-
tr_debug("Triggering parent selection due to ETX change on neigh index %u, etx %u", attribute_index, current_etx);
389+
tr_debug("Triggering parent selection due to ETX %s on neigh index %u, etx %u", better ? "better" : "worse", attribute_index, current_etx);
390+
rpl_dodag_t *dodag = NULL;
389391

390392
ns_list_foreach(rpl_instance_t, instance, &domain->instances) {
391-
rpl_instance_trigger_parent_selection(instance, delay);
393+
if (better) {
394+
dodag = rpl_instance_current_dodag(instance);
395+
}
396+
rpl_instance_trigger_parent_selection(instance, delay, dodag);
392397
if (rpl_instance_am_root(instance)) {
393398
rpl_downward_paths_invalidate(instance);
394399
}

source/RPL/rpl_policy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int8_t rpl_policy_dao_retry_count()
147147
/* Given the next-hop address from a source routing header, which interface,
148148
* if any, should we assume that next hop is on?
149149
*/
150-
#define ETX_SRH_THRESHOLD 0x800 /* 8.8 fixed-point, so 4 */
150+
#define ETX_SRH_THRESHOLD 0x400 /* 8.8 fixed-point, so 4 */
151151
int8_t rpl_policy_srh_next_hop_interface(rpl_domain_t *domain, int8_t if_id, const uint8_t *next_hop)
152152
{
153153
if (domain->non_storing_downstream_interface != -1) {

source/RPL/rpl_upward.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,16 @@ void rpl_instance_force_leaf(rpl_instance_t *instance)
352352
instance->current_rank = RPL_RANK_INFINITE;
353353
}
354354

355-
void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t delay)
355+
void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t delay, rpl_dodag_t *dodag)
356356
{
357+
/* When "improving", let us have a minimum trigger time based on Imin, for large networks */
358+
if (dodag) {
359+
//Convert imin 100ms tick to seconds
360+
uint16_t i_min_delay = dodag->dio_timer_params.Imin / 10;
361+
if (i_min_delay > delay) {
362+
delay = i_min_delay;
363+
}
364+
}
357365
if (instance->parent_selection_timer == 0 || instance->parent_selection_timer > delay) {
358366
instance->parent_selection_timer = randLIB_randomise_base(delay, 0x8000, 0x999A) /* Random between delay * 1.0-1.2 */;
359367
tr_debug("Timed parent triggered %u", instance->parent_selection_timer);
@@ -585,7 +593,7 @@ void rpl_delete_dodag_version(rpl_dodag_version_t *version)
585593
// triggering poison immediately.
586594
// Give parent selection a chance to select another version (but will it have any info on-hand?)
587595
instance->current_dodag_version = NULL;
588-
rpl_instance_trigger_parent_selection(instance, 5);
596+
rpl_instance_trigger_parent_selection(instance, 5, NULL);
589597
}
590598

591599
ns_list_foreach_safe(rpl_neighbour_t, neighbour, &instance->candidate_neighbours) {
@@ -1278,18 +1286,12 @@ bool rpl_instance_purge(rpl_instance_t *instance)
12781286
return false;
12791287
}
12801288

1281-
void rpl_instance_neighbours_changed(rpl_instance_t *instance, const rpl_dodag_t *dodag)
1289+
void rpl_instance_neighbours_changed(rpl_instance_t *instance, rpl_dodag_t *dodag)
12821290
{
12831291
instance->neighbours_changed = true;
12841292
uint16_t delay = rpl_policy_dio_parent_selection_delay(instance->domain);
1285-
if (dodag) {
1286-
//Convert imin 100ms tick to seconds
1287-
uint16_t i_min_delay = dodag->dio_timer_params.Imin / 10;
1288-
if (i_min_delay > delay) {
1289-
delay = i_min_delay;
1290-
}
1291-
}
1292-
rpl_instance_trigger_parent_selection(instance, delay);
1293+
1294+
rpl_instance_trigger_parent_selection(instance, delay, dodag);
12931295
}
12941296

12951297
static void rpl_instance_remove_parents(rpl_instance_t *instance)

source/RPL/rpl_upward.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void rpl_instance_increment_dtsn(rpl_instance_t *instance);
7878
void rpl_dodag_set_pref(rpl_dodag_t *dodag, uint8_t pref);
7979
void rpl_instance_poison(rpl_instance_t *instance, uint8_t count);
8080
void rpl_instance_force_leaf(rpl_instance_t *instance);
81-
void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t delay);
81+
void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t delay, rpl_dodag_t *dodag);
8282
void rpl_instance_remove_interface(rpl_instance_t *instance, int8_t if_id);
8383
void rpl_instance_dio_trigger(rpl_instance_t *instance, struct protocol_interface_info_entry *cur, const uint8_t *addr);
8484
void rpl_instance_set_local_repair(rpl_instance_t *instance, bool repair);
@@ -147,7 +147,7 @@ bool rpl_neighbour_update_dtsn(rpl_neighbour_t *neighbour, uint8_t dtsn);
147147
rpl_instance_t *rpl_neighbour_instance(const rpl_neighbour_t *neighbour);
148148

149149

150-
void rpl_instance_neighbours_changed(rpl_instance_t *instance, const rpl_dodag_t *dodag);
150+
void rpl_instance_neighbours_changed(rpl_instance_t *instance, rpl_dodag_t *dodag);
151151
void rpl_instance_run_parent_selection(rpl_instance_t *instance);
152152

153153
void rpl_upward_print_instance(rpl_instance_t *instance, route_print_fn_t *print_fn);

source/Service_Libs/etx/etx.c

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ uint16_t etx_local_etx_read(int8_t interface_id, uint8_t attribute_index)
394394

395395
if (etx_info.cache_sample_requested && entry->etx_samples < etx_info.init_etx_sample_count) {
396396
if (!entry->etx_samples) {
397-
//Return configured MAX value
398-
return etx_info.max_etx >> 4;
397+
return 0;
399398
}
400399
}
401400

@@ -455,7 +454,12 @@ uint16_t etx_lqi_dbm_update(int8_t interface_id, uint8_t lqi, int8_t dbm, uint8_
455454
if (!entry->etx) {
456455
etx = etx_dbm_lqi_calc(lqi, dbm);
457456
entry->etx = etx;
457+
entry->stored_diff_etx = etx;
458458
entry->tmp_etx = true;
459+
if (etx_info.callback_ptr) {
460+
etx_info.callback_ptr(etx_info.interface_id, 0, entry->etx >> 4,
461+
attribute_index);
462+
}
459463
}
460464
// If local ETX has been calculated without remote incoming IDR and
461465
// remote incoming IDR is available update it by remote incoming IDR value
@@ -470,11 +474,7 @@ uint16_t etx_lqi_dbm_update(int8_t interface_id, uint8_t lqi, int8_t dbm, uint8_
470474
entry->etx = etx >> 12;
471475

472476
local_incoming_idr >>= 4;
473-
}
474-
475-
// If local ETX has been calculated indicates new neighbor
476-
if (etx) {
477-
etx_neighbor_add(interface_id, attribute_index);
477+
etx_value_change_callback_needed_check(entry->etx, &(entry->stored_diff_etx), entry->accumulated_failures, attribute_index);
478478
}
479479
}
480480

@@ -808,35 +808,6 @@ void etx_neighbor_remove(int8_t interface_id, uint8_t attribute_index)
808808
}
809809
}
810810

811-
/**
812-
* \brief A function to add ETX neighbor
813-
*
814-
* Notifies ETX module that neighbor has been added. Calls ETX value change callback
815-
* if that is set.
816-
*
817-
* \param mac64_addr_ptr long MAC address
818-
*
819-
*/
820-
void etx_neighbor_add(int8_t interface_id, uint8_t attribute_index)
821-
{
822-
823-
//tr_debug("Add attribute %u", attribute_index);
824-
uint16_t stored_diff_etx;
825-
etx_storage_t *entry = etx_storage_entry_get(interface_id, attribute_index);
826-
if (entry && etx_info.callback_ptr) {
827-
// Gets table entry
828-
829-
if (entry->etx) {
830-
stored_diff_etx = entry->stored_diff_etx;
831-
if (!stored_diff_etx) {
832-
stored_diff_etx = entry->etx;
833-
}
834-
etx_info.callback_ptr(etx_info.interface_id, stored_diff_etx >> 4, entry->etx >> 4,
835-
attribute_index);
836-
}
837-
}
838-
}
839-
840811
void etx_cache_timer(int8_t interface_id, uint16_t seconds_update)
841812
{
842813
if (!etx_info.cache_sample_requested) {

source/Service_Libs/etx/etx.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,6 @@ uint8_t etx_accum_failures_callback_register(nwk_interface_id nwk_id, int8_t int
236236
*/
237237
void etx_neighbor_remove(int8_t interface_id, uint8_t attribute_index);
238238

239-
/**
240-
* \brief A function to add ETX neighbor
241-
*
242-
* Notifies ETX module that neighbor has been added. Calls ETX value change callback
243-
* if that is set.
244-
*
245-
* \param attribute_index Neighbour attribute index
246-
*
247-
*/
248-
void etx_neighbor_add(int8_t interface_id, uint8_t attribute_index);
249-
250239
/**
251240
* \brief A function for update cached ETX calculation
252241
*

test/nanostack/unittest/service_libs/etx/etxtest.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,3 @@ TEST(ETX, test_ETX_etx_neighbor_remove_1)
111111
CHECK(test_ETX_etx_neighbor_remove_1());
112112
}
113113

114-
TEST(ETX, test_ETX_etx_neighbor_add_1)
115-
{
116-
CHECK(test_ETX_etx_neighbor_add_1());
117-
}

test/nanostack/unittest/service_libs/etx/test_etx.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -754,36 +754,3 @@ bool test_ETX_etx_neighbor_remove_1()
754754
etx_storage_list_allocate(0, 0);
755755
return true;
756756
}
757-
758-
bool test_ETX_etx_neighbor_add_1()
759-
{
760-
test_etx_set_protocol();
761-
nsdynmemlib_stub.returnCounter = 1;
762-
etx_storage_list_allocate(0, 10);
763-
etx_storage_t *test_entry = etx_storage_entry_get(0, 0);
764-
uint8_t i;
765-
uint8_t attempts;
766-
bool success;
767-
double etx = 1;
768-
double output_etx;
769-
test_entry->etx = 1 << 12;
770-
771-
memset(change_ind_handler_values, 0, sizeof(change_ind_handler_values));
772-
change_ind_handler_index = 0;
773-
774-
// 3/1 ETX
775-
attempts = 3;
776-
success = 1;
777-
778-
(void) etx_value_change_callback_register(IF_6LoWPAN, 0, 128, etx_value_change_ind_handler);
779-
780-
etx_neighbor_add(0, 0);
781-
782-
if ((change_ind_handler_values[0].current_etx != 0x0100) ||
783-
(change_ind_handler_values[0].previous_etx != 0x0100)) {
784-
return false;
785-
}
786-
787-
etx_storage_list_allocate(0, 0);
788-
return true;
789-
}

test/nanostack/unittest/service_libs/etx/test_etx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ bool test_ETX_etx_lqi_dbm_update_2();
4040
bool test_ETX_etx_value_change_callback_register_1();
4141
bool test_ETX_etx_accum_failures_callback_register_1();
4242
bool test_ETX_etx_neighbor_remove_1();
43-
bool test_ETX_etx_neighbor_add_1();
4443

4544
#ifdef __cplusplus
4645
}

test/nanostack/unittest/stub/etx_stub.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ void etx_neighbor_remove(int8_t interface_id, uint8_t attribute_index)
6767
{
6868
}
6969

70-
void etx_neighbor_add(int8_t interface_id, uint8_t attribute_index)
71-
{
72-
73-
}
74-
7570
bool etx_storage_list_allocate(int8_t interface_id, uint8_t etx_storage_size)
7671
{
7772
return true;

test/nanostack/unittest/stub/rpl_upward_stub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void rpl_instance_force_leaf(rpl_instance_t *instance)
169169
{
170170
}
171171

172-
void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t delay)
172+
void rpl_instance_trigger_parent_selection(rpl_instance_t *instance, uint16_t delay, rpl_dodag_t *dodag)
173173
{
174174
}
175175

@@ -393,7 +393,7 @@ bool rpl_instance_purge(rpl_instance_t *instance)
393393
return false;
394394
}
395395

396-
void rpl_instance_neighbours_changed(rpl_instance_t *instance, const rpl_dodag_t *dodag)
396+
void rpl_instance_neighbours_changed(rpl_instance_t *instance, rpl_dodag_t *dodag)
397397
{
398398
}
399399

0 commit comments

Comments
 (0)