Skip to content

Commit 7e47889

Browse files
Mika TervonenMika Tervonen
Mika Tervonen
authored and
Mika Tervonen
committed
support filtering of EAPOL parents based device-min-sens configuration
Filter EAPOL parents with DEVICE_MIN_SENS with CAND_PARENT_THRESHOLD and CAND_PARENT_HYSTERESIS configuration. Only neighbours that have THRESHOLD + HYSTERESIS are accepted for EAPOL candidates. If candidate signal level drops below the THRESHOLD - HYSTERESIS it is removed. Change Parent list handling to be more consistent between functions
1 parent 618a191 commit 7e47889

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

CHANGELOG.md

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

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

88
### Changes
99
*

nanostack/ws_management_api.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,10 @@ int ws_neighbor_info_get(
857857
*
858858
* Setting a value that is not suitable for Radio might prevent the device joining to the network.
859859
*
860-
* NOTE: Currently lower EAPOL parents are accepted if there is no parents higher than
861-
* DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERESIS
860+
* This configuration limits the EAPOL parents accepted for Authentication and device must hear signal
861+
* level higher than device_min_sens + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERESIS
862+
* to start authentication.
863+
*
862864
* NOTE: Currently not using this value to limit parents as it is only RECOMENDED in specification.
863865
*
864866
* \param interface_id Network interface ID.

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,12 @@ static void ws_bootstrap_candidate_parent_store(parent_info_t *parent, const str
13871387
parent->signal_dbm = data->signal_dbm;
13881388
memcpy(parent->addr, data->SrcAddr, 8);
13891389

1390+
if (ws_neighbor_class_rsl_from_dbm_calculate(parent->signal_dbm) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
1391+
parent->link_acceptable = true;
1392+
}
1393+
if (ws_neighbor_class_rsl_from_dbm_calculate(parent->signal_dbm) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD - CAND_PARENT_HYSTERISIS)) {
1394+
parent->link_acceptable = false;
1395+
}
13901396
parent->age = protocol_core_monotonic_time;
13911397
}
13921398

@@ -1421,6 +1427,7 @@ static parent_info_t *ws_bootstrap_candidate_parent_allocate(protocol_interface_
14211427
}
14221428
if (entry) {
14231429
entry->tx_fail = 0;
1430+
entry->link_acceptable = false;
14241431
}
14251432
return entry;
14261433
}
@@ -1442,13 +1449,11 @@ static void ws_bootstrap_candidate_parent_mark_failure(protocol_interface_info_e
14421449
{
14431450
parent_info_t *entry = ws_bootstrap_candidate_parent_get(cur, addr, false);
14441451
if (entry) {
1445-
ns_list_remove(&cur->ws_info->parent_list_reserved, entry);
14461452
if (entry->tx_fail >= 2) {
1453+
ns_list_remove(&cur->ws_info->parent_list_reserved, entry);
14471454
ns_list_add_to_end(&cur->ws_info->parent_list_free, entry);
14481455
} else {
14491456
entry->tx_fail++;
1450-
//New last
1451-
ns_list_add_to_end(&cur->ws_info->parent_list_reserved, entry);
14521457
ws_bootstrap_candidate_parent_sort(cur, entry);
14531458
}
14541459

@@ -1466,14 +1471,12 @@ static bool ws_bootstrap_candidate_parent_compare(parent_info_t *p1, parent_info
14661471
return false;
14671472
}
14681473

1469-
if (ws_neighbor_class_rsl_from_dbm_calculate(p1->signal_dbm) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
1470-
ws_neighbor_class_rsl_from_dbm_calculate(p2->signal_dbm) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
1471-
// above threshold is always better than not.
1474+
if (p1->link_acceptable && !p2->link_acceptable) {
1475+
// Link acceptable is always better than not
14721476
return true;
14731477
}
1474-
if (ws_neighbor_class_rsl_from_dbm_calculate(p2->signal_dbm) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
1475-
ws_neighbor_class_rsl_from_dbm_calculate(p1->signal_dbm) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
1476-
// P2 is less than threshold and P1 is larger so P1 is always better.
1478+
if (!p1->link_acceptable && p2->link_acceptable) {
1479+
// Link acceptable is always better than not
14771480
return false;
14781481
}
14791482

@@ -1498,6 +1501,7 @@ static void ws_bootstrap_candidate_list_clean(struct protocol_interface_info_ent
14981501
int pan_count = 0;
14991502

15001503
ns_list_foreach_safe(parent_info_t, entry, &cur->ws_info->parent_list_reserved) {
1504+
15011505
if ((current_time - entry->age) > WS_PARENT_LIST_MAX_AGE) {
15021506
ns_list_remove(&cur->ws_info->parent_list_reserved, entry);
15031507
ns_list_add_to_end(&cur->ws_info->parent_list_free, entry);
@@ -1534,6 +1538,9 @@ static void ws_bootstrap_candidate_parent_sort(struct protocol_interface_info_en
15341538
return;
15351539
}
15361540
}
1541+
// This is the last entry
1542+
ns_list_remove(&cur->ws_info->parent_list_reserved, new_entry);
1543+
ns_list_add_to_end(&cur->ws_info->parent_list_reserved, new_entry);
15371544
}
15381545

15391546
static void ws_bootstrap_pan_information_store(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, ws_utt_ie_t *ws_utt, ws_us_ie_t *ws_us, ws_pan_information_t *pan_information)
@@ -1560,6 +1567,14 @@ static void ws_bootstrap_pan_information_store(struct protocol_interface_info_en
15601567
}
15611568
// Safe the information
15621569
ws_bootstrap_candidate_parent_store(new_entry, data, ws_utt, ws_us, pan_information);
1570+
if (!new_entry->link_acceptable) {
1571+
// This entry is either poor quality or changed to poor quality link so we will remove this
1572+
// Todo in future possibility to try poor link parents if we have not found any good link parents
1573+
tr_info("neighbour not accepted: addr:%s panid:%x rsl:%d device_min_sens: %d", trace_array(new_entry->addr, 8), new_entry->pan_id, ws_neighbor_class_rsl_from_dbm_calculate(new_entry->signal_dbm), DEVICE_MIN_SENS);
1574+
ns_list_remove(&cur->ws_info->parent_list_reserved, new_entry);
1575+
ns_list_add_to_end(&cur->ws_info->parent_list_free, new_entry);
1576+
return;
1577+
}
15631578
// set to the correct place in list
15641579
ws_bootstrap_candidate_parent_sort(cur, new_entry);
15651580

source/6LoWPAN/ws/ws_common.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ typedef struct parent_info_s {
4747
ws_pan_information_t pan_information;
4848
ws_utt_ie_t ws_utt;
4949
ws_us_ie_t ws_us;
50-
uint32_t timestamp; /**< Timestamp when packet was received */
51-
uint32_t age; /**< Age of entry in 100ms ticks */
52-
uint8_t excluded_channel_data[32]; //Channel mask Max length and it accept 8 different range
50+
uint32_t timestamp; /**< Timestamp when packet was received */
51+
uint32_t age; /**< Age of entry in 100ms ticks */
52+
uint8_t excluded_channel_data[32]; /**< Channel mask Max length and it accept 8 different range*/
53+
bool link_acceptable: 1; /**< True when Link quality is in acceptable level*/
5354
ns_list_link_t link;
5455
} parent_info_t;
5556

0 commit comments

Comments
 (0)