Skip to content

Commit 5373de2

Browse files
author
Juha Heiskanen
committed
EAPOL parent TX feilure is reorder candidate list.
1 parent 6b0e264 commit 5373de2

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static int8_t ws_bootstrap_neighbor_set(protocol_interface_info_entry_t *cur, pa
110110

111111
static void ws_bootstrap_candidate_table_reset(protocol_interface_info_entry_t *cur);
112112
static parent_info_t *ws_bootstrap_candidate_parent_get(struct protocol_interface_info_entry *cur, const uint8_t *addr, bool create);
113+
static void ws_bootstrap_candidate_parent_sort(struct protocol_interface_info_entry *cur, parent_info_t *new_entry);
113114

114115
typedef enum {
115116
WS_PARENT_SOFT_SYNCH = 0, /**< let FHSS make decision if synchronization is needed*/
@@ -1165,7 +1166,7 @@ static void ws_bootstrap_pan_advertisement_analyse_active(struct protocol_interf
11651166
static parent_info_t *ws_bootstrap_candidate_parent_get_best(protocol_interface_info_entry_t *cur)
11661167
{
11671168
ns_list_foreach_safe(parent_info_t, entry, &cur->ws_info->parent_list_reserved) {
1168-
tr_info("candidate list a:%s panid:%x cost:%d size:%d rssi:%d age:%"PRIu32, trace_array(entry->addr, 8), entry->pan_id, entry->pan_information.routing_cost, entry->pan_information.pan_size, entry->signal_dbm, protocol_core_monotonic_time - entry->age);
1169+
tr_info("candidate list a:%s panid:%x cost:%d size:%d rssi:%d txFailure:%u age:%"PRIu32, trace_array(entry->addr, 8), entry->pan_id, entry->pan_information.routing_cost, entry->pan_information.pan_size, entry->signal_dbm, entry->tx_fail, protocol_core_monotonic_time - entry->age);
11691170
}
11701171

11711172
return ns_list_get_first(&cur->ws_info->parent_list_reserved);
@@ -1263,19 +1264,12 @@ static parent_info_t *ws_bootstrap_candidate_parent_allocate(protocol_interface_
12631264
} else {
12641265
// If there is no free entries always allocate the last one of reserved as it is the worst
12651266
entry = ns_list_get_last(&cur->ws_info->parent_list_reserved);
1266-
}
1267-
return entry;
1268-
}
12691267

1270-
static void ws_bootstrap_candidate_parent_free(protocol_interface_info_entry_t *cur, const uint8_t *addr)
1271-
{
1272-
ns_list_foreach_safe(parent_info_t, entry, &cur->ws_info->parent_list_reserved) {
1273-
if (memcmp(entry->addr, addr, 8) == 0) {
1274-
ns_list_remove(&cur->ws_info->parent_list_reserved, entry);
1275-
ns_list_add_to_end(&cur->ws_info->parent_list_free, entry);
1276-
return;
1277-
}
12781268
}
1269+
if (entry) {
1270+
entry->tx_fail = 0;
1271+
}
1272+
return entry;
12791273
}
12801274

12811275
static parent_info_t *ws_bootstrap_candidate_parent_get(struct protocol_interface_info_entry *cur, const uint8_t *addr, bool create)
@@ -1291,13 +1285,34 @@ static parent_info_t *ws_bootstrap_candidate_parent_get(struct protocol_interfac
12911285
return NULL;
12921286
}
12931287

1288+
static void ws_bootstrap_candidate_parent_mark_failure(protocol_interface_info_entry_t *cur, const uint8_t *addr)
1289+
{
1290+
parent_info_t *entry = ws_bootstrap_candidate_parent_get(cur, addr, false);
1291+
if (entry) {
1292+
ns_list_remove(&cur->ws_info->parent_list_reserved, entry);
1293+
if (entry->tx_fail >= 2) {
1294+
ns_list_add_to_end(&cur->ws_info->parent_list_free, entry);
1295+
} else {
1296+
entry->tx_fail++;
1297+
//New last
1298+
ns_list_add_to_end(&cur->ws_info->parent_list_reserved, entry);
1299+
ws_bootstrap_candidate_parent_sort(cur, entry);
1300+
}
1301+
1302+
}
1303+
}
1304+
12941305
static bool ws_bootstrap_candidate_parent_compare(parent_info_t *p1, parent_info_t *p2)
12951306
{
12961307
// Return true if P2 is better
12971308
// signal lower than threshold for both
12981309
// pan_cost
12991310
// signal quality
13001311

1312+
if (p2->tx_fail > p1->tx_fail) {
1313+
return false;
1314+
}
1315+
13011316
if (ws_neighbor_class_rsl_from_dbm_calculate(p1->signal_dbm) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
13021317
ws_neighbor_class_rsl_from_dbm_calculate(p2->signal_dbm) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
13031318
// above threshold is always better than not.
@@ -1349,11 +1364,15 @@ static void ws_bootstrap_candidate_list_clean(struct protocol_interface_info_ent
13491364

13501365
static void ws_bootstrap_candidate_parent_sort(struct protocol_interface_info_entry *cur, parent_info_t *new_entry)
13511366
{
1367+
//Remove from the list
1368+
13521369
ns_list_foreach_safe(parent_info_t, entry, &cur->ws_info->parent_list_reserved) {
1370+
13531371
if (entry == new_entry) {
13541372
// own entry skip it
13551373
continue;
13561374
}
1375+
13571376
if (ws_bootstrap_candidate_parent_compare(entry, new_entry)) {
13581377
// New entry is better
13591378
//tr_debug("candidate list new is better");
@@ -2912,7 +2931,7 @@ static void ws_bootstrap_authentication_completed(protocol_interface_info_entry_
29122931
// eapol parent selected is not working
29132932
tr_debug("authentication TX failed");
29142933

2915-
ws_bootstrap_candidate_parent_free(cur, target_eui_64);
2934+
ws_bootstrap_candidate_parent_mark_failure(cur, target_eui_64);
29162935
// Go back for network scanning
29172936
ws_bootstrap_state_change(cur, ER_ACTIVE_SCAN);
29182937

@@ -2934,7 +2953,7 @@ static void ws_bootstrap_authentication_completed(protocol_interface_info_entry_
29342953

29352954
static const uint8_t *ws_bootstrap_authentication_next_target(protocol_interface_info_entry_t *cur, const uint8_t *previous_eui_64, uint16_t *pan_id)
29362955
{
2937-
ws_bootstrap_candidate_parent_free(cur, previous_eui_64);
2956+
ws_bootstrap_candidate_parent_mark_failure(cur, previous_eui_64);
29382957

29392958
// Gets best target
29402959
parent_info_t *parent_info = ws_bootstrap_candidate_parent_get_best(cur);

source/6LoWPAN/ws/ws_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ typedef struct parent_info_s {
4242
uint16_t pan_id; /**< PAN ID */
4343
uint8_t addr[8]; /**< address */
4444
uint8_t link_quality; /**< LQI value measured during reception of the MPDU */
45+
uint8_t tx_fail;
4546
int8_t signal_dbm; /**< This extension for normal IEEE 802.15.4 Data indication */
4647
ws_pan_information_t pan_information;
4748
ws_utt_ie_t ws_utt;

0 commit comments

Comments
 (0)