Skip to content

Commit 8a8b407

Browse files
Mika TervonenMika Tervonen
authored andcommitted
Add RSL check for ETX Calculation for RPL parent selection
Separate Wi-SUN ETX function so that all ETX checks have same validation Remove all direct calls to etx_local_etx_read function and replace with Wi-SUN version. Remove check for 0 ack from etx_local_etx_read as it is ok to run the ETX Calculation through even if first probe fails
1 parent c05e1da commit 8a8b407

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Release vXX.X.X
44

55
### Features
6+
* Filter RPL parents based on DEVICE_MIN_SENS configuration with Threshold and Hysteresis.
67
* Filter EAPOL parents based on DEVICE_MIN_SENS configuration with Threshold and Hysteresis to prevent EAPOL failures caused by bad signal levels
78

89
### Changes

nanostack/ws_management_api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,9 @@ int ws_neighbor_info_get(
861861
* level higher than device_min_sens + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERESIS
862862
* to start authentication.
863863
*
864-
* NOTE: Currently not using this value to limit parents as it is only RECOMENDED in specification.
864+
* ETX Calculation gives a maximum ETX if two way EWMA RSL is less than
865+
* device_min_sens + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERESIS to
866+
* prevent selecting parents with poor signal quality
865867
*
866868
* \param interface_id Network interface ID.
867869
* \param device_min_sens value used in the parent selections.

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -909,17 +909,17 @@ static void ws_bootstrap_ll_address_validate(struct protocol_interface_info_entr
909909
* \return 0x0000 address unknown or other error
910910
* \return 0x0001 no ETX statistics on this interface
911911
*/
912-
uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr_type, const uint8_t *addr_ptr)
912+
uint16_t ws_local_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr_type, const uint8_t *mac_adddress)
913913
{
914914
uint16_t etx;
915915

916-
if (!addr_ptr || !interface) {
916+
if (!mac_adddress || !interface) {
917917
return 0;
918918
}
919919

920920
uint8_t attribute_index;
921921

922-
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), addr_ptr + PAN_ID_LEN, addr_type);
922+
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), mac_adddress, addr_type);
923923
if (!mac_neighbor) {
924924
return 0xffff;
925925
}
@@ -933,6 +933,12 @@ uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr
933933

934934
etx = etx_local_etx_read(interface->id, attribute_index);
935935

936+
// if we have a measurement ready then we will check the RSL validity
937+
if (etx != 0xffff && !ws_neighbour->candidate_parent) {
938+
// RSL value measured is lower than acceptable ETX will be given as MAX
939+
return WS_ETX_MAX << 1; // We use 8 bit fraction and ETX is usually 7 bit fraction
940+
}
941+
936942
// If we dont have valid ETX for children we assume good ETX.
937943
// After enough packets is sent to children real calculated ETX is given.
938944
// This might result in ICMP source route errors returned to Border router causing secondary route uses
@@ -942,6 +948,15 @@ uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr
942948

943949
return etx;
944950
}
951+
952+
uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr_type, const uint8_t *addr_ptr)
953+
{
954+
if (!addr_ptr || !interface) {
955+
return 0;
956+
}
957+
return ws_local_etx_read(interface, addr_type, addr_ptr + PAN_ID_LEN);
958+
}
959+
945960
bool ws_bootstrap_nd_ns_transmit(protocol_interface_info_entry_t *cur, ipv6_neighbour_t *entry, bool unicast, uint8_t seq)
946961
{
947962
(void)cur;
@@ -3001,17 +3016,17 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
30013016
return false;
30023017
}
30033018
// +2 Is for PAN ID space
3004-
memcpy(mac64 + 2, replacing + 8, 8);
3005-
mac64[2] ^= 2;
3019+
memcpy(mac64, replacing + 8, 8);
3020+
mac64[0] ^= 2;
30063021

3007-
if (ws_etx_read(cur, ADDR_802_15_4_LONG, mac64) == 0xffff) {
3008-
//Not proped yet because ETX is 0xffff
3022+
if (ws_local_etx_read(cur, ADDR_802_15_4_LONG, mac64) == 0xffff) {
3023+
//Not probed yet because ETX is 0xffff
30093024
return false;
30103025
}
30113026

30123027
uint16_t etx = 0;
30133028
if (neigh_buffer.neighbor) {
3014-
etx = etx_local_etx_read(cur->id, neigh_buffer.neighbor->index);
3029+
etx = ws_local_etx_read(cur, ADDR_802_15_4_LONG, neigh_buffer.neighbor->mac64);
30153030
}
30163031

30173032
// Accept now only better one's when max candidates selected and max candidate list size is reached
@@ -3554,7 +3569,7 @@ static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entr
35543569
return 0xffff;
35553570
}
35563571

3557-
uint16_t etx = etx_local_etx_read(cur->id, mac_neighbor->index);
3572+
uint16_t etx = ws_local_etx_read(cur, ADDR_802_15_4_LONG, mac_neighbor->mac64);
35583573
if (etx == 0) {
35593574
etx = WS_ETX_MAX; //SET maximum value here if ETX is unknown
35603575
} else {
@@ -4254,7 +4269,7 @@ int ws_bootstrap_neighbor_info_get(protocol_interface_info_entry_t *cur, ws_neig
42544269
neighbor_ptr[count].rsl_out = ws_neighbor_class_rsl_out_get(ws_neighbor);
42554270

42564271
// ETX is shown calculated as 8 bit integer, but more common way is to use 7 bit such that 128 means ETX:1.0
4257-
neighbor_ptr[count].etx = etx_local_etx_read(cur->id, mac_entry->index);
4272+
neighbor_ptr[count].etx = ws_local_etx_read(cur, ADDR_802_15_4_LONG, mac_entry->mac64);
42584273
if (neighbor_ptr[count].etx != 0xffff) {
42594274
neighbor_ptr[count].etx = neighbor_ptr[count].etx >> 1;
42604275
}

source/Service_Libs/etx/etx.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,6 @@ uint16_t etx_local_etx_read(int8_t interface_id, uint8_t attribute_index)
439439
}
440440

441441
if (etx_info.cache_sample_requested && entry->etx_samples < etx_info.init_etx_sample_count) {
442-
etx_sample_storage_t *storage = etx_info.etx_cache_storage_list + attribute_index;
443-
if (storage->received_acks == 0 && storage->attempts_count) {
444-
//No ack so return max value
445-
return etx_info.max_etx;
446-
}
447442
//Not ready yet
448443
return 0xffff;
449444
}

0 commit comments

Comments
 (0)