Skip to content

Commit fa20fb9

Browse files
author
Mika Leppänen
authored
Added calculation of LLC and LLC EAPOL message queue average (#2582)
Adaptation, LLC and LLC EAPOL average queues are summed and authentication init/reject propability is calculated based on that.
1 parent 7f7c01a commit fa20fb9

File tree

5 files changed

+63
-10
lines changed

5 files changed

+63
-10
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static void ws_bootstrap_nw_frame_counter_read(protocol_interface_info_entry_t *
105105
static void ws_bootstrap_nw_info_updated(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, uint16_t pan_version, char *network_name);
106106
static void ws_bootstrap_authentication_completed(protocol_interface_info_entry_t *cur, auth_result_e result, uint8_t *target_eui_64);
107107
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);
108-
static bool ws_bootstrap_congestion_get(protocol_interface_info_entry_t *interface_ptr, uint16_t active_supp);
108+
static bool ws_bootstrap_eapol_congestion_get(protocol_interface_info_entry_t *interface_ptr, uint16_t active_supp);
109109
static void ws_bootstrap_pan_version_increment(protocol_interface_info_entry_t *cur);
110110
static ws_nud_table_entry_t *ws_nud_entry_discover(protocol_interface_info_entry_t *cur, void *neighbor);
111111
static void ws_nud_entry_remove(protocol_interface_info_entry_t *cur, mac_neighbor_table_entry_t *entry_ptr);
@@ -2332,7 +2332,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
23322332
ret_val = -4;
23332333
goto init_fail;
23342334
}
2335-
if (ws_pae_controller_cb_register(cur, &ws_bootstrap_authentication_completed, &ws_bootstrap_authentication_next_target, &ws_bootstrap_nw_key_set, &ws_bootstrap_nw_key_clear, &ws_bootstrap_nw_key_index_set, &ws_bootstrap_nw_frame_counter_set, &ws_bootstrap_nw_frame_counter_read, &ws_bootstrap_pan_version_increment, &ws_bootstrap_nw_info_updated, &ws_bootstrap_congestion_get) < 0) {
2335+
if (ws_pae_controller_cb_register(cur, &ws_bootstrap_authentication_completed, &ws_bootstrap_authentication_next_target, &ws_bootstrap_nw_key_set, &ws_bootstrap_nw_key_clear, &ws_bootstrap_nw_key_index_set, &ws_bootstrap_nw_frame_counter_set, &ws_bootstrap_nw_frame_counter_read, &ws_bootstrap_pan_version_increment, &ws_bootstrap_nw_info_updated, &ws_bootstrap_eapol_congestion_get) < 0) {
23362336
ret_val = -4;
23372337
goto init_fail;
23382338
}
@@ -3215,15 +3215,41 @@ static const uint8_t *ws_bootstrap_authentication_next_target(protocol_interface
32153215
return previous_eui_64;
32163216
}
32173217

3218-
static bool ws_bootstrap_congestion_get(protocol_interface_info_entry_t *interface_ptr, uint16_t active_supp)
3218+
static void ws_bootstrap_eapol_congestion_init(protocol_interface_info_entry_t *cur)
32193219
{
3220-
if (interface_ptr == NULL || interface_ptr->random_early_detection == NULL) {
3220+
random_early_detection_free(cur->llc_random_early_detection);
3221+
cur->llc_random_early_detection = NULL;
3222+
3223+
if (cur->llc_random_early_detection == NULL) {
3224+
cur->llc_random_early_detection = random_early_detection_create(
3225+
cur->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_min,
3226+
cur->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_max,
3227+
100, RED_AVERAGE_WEIGHT_EIGHTH);
3228+
}
3229+
3230+
random_early_detection_free(cur->llc_eapol_random_early_detection);
3231+
cur->llc_eapol_random_early_detection = NULL;
3232+
3233+
if (cur->llc_eapol_random_early_detection == NULL) {
3234+
cur->llc_eapol_random_early_detection = random_early_detection_create(
3235+
cur->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_min,
3236+
cur->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_max,
3237+
100, RED_AVERAGE_WEIGHT_EIGHTH);
3238+
}
3239+
}
3240+
3241+
static bool ws_bootstrap_eapol_congestion_get(protocol_interface_info_entry_t *cur, uint16_t active_supp)
3242+
{
3243+
if (cur == NULL || cur->random_early_detection == NULL || cur->llc_random_early_detection == NULL || cur->llc_eapol_random_early_detection == NULL) {
32213244
return false;
32223245
}
32233246

32243247
bool return_value = false;
32253248
static struct red_info_s *red_info = NULL;
3226-
uint16_t average = 0;
3249+
uint16_t adaptation_average = 0;
3250+
uint16_t llc_average = 0;
3251+
uint16_t llc_eapol_average = 0;
3252+
uint16_t average_sum = 0;
32273253
uint8_t active_max = 0;
32283254

32293255
//TODO implement API for HEAP info request
@@ -3248,6 +3274,13 @@ static bool ws_bootstrap_congestion_get(protocol_interface_info_entry_t *interfa
32483274
active_max = 50;
32493275
}
32503276

3277+
// Read the values for adaptation and LLC queues
3278+
adaptation_average = random_early_detetction_aq_read(cur->random_early_detection);
3279+
llc_average = random_early_detetction_aq_read(cur->llc_random_early_detection);
3280+
llc_eapol_average = random_early_detetction_aq_read(cur->llc_eapol_random_early_detection);
3281+
// Calculate combined average
3282+
average_sum = adaptation_average + llc_average + llc_eapol_average;
3283+
32513284
// Maximum for active supplicants based on memory reached, fail
32523285
if (active_supp >= active_max) {
32533286
return_value = true;
@@ -3261,20 +3294,20 @@ static bool ws_bootstrap_congestion_get(protocol_interface_info_entry_t *interfa
32613294

32623295
if (red_info == NULL) {
32633296
red_info = random_early_detection_create(
3264-
interface_ptr->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_min,
3265-
interface_ptr->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_max,
3297+
cur->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_min,
3298+
cur->ws_info->cfg->sec_prot.max_simult_sec_neg_tx_queue_max,
32663299
100, RED_AVERAGE_WEIGHT_DISABLED);
32673300
}
32683301
if (red_info == NULL) {
32693302
goto congestion_get_end;
32703303
}
32713304

3272-
average = random_early_detetction_aq_read(interface_ptr->random_early_detection);
3273-
average = random_early_detetction_aq_calc(red_info, average);
3305+
// Check drop probability
3306+
average_sum = random_early_detetction_aq_calc(red_info, average_sum);
32743307
return_value = random_early_detection_congestion_check(red_info);
32753308

32763309
congestion_get_end:
3277-
tr_info("Active supplicant limit, active: %i max: %i averageQ: %i drop: %s", active_supp, active_max, average, return_value ? "T" : "F");
3310+
tr_info("Active supplicant limit, active: %i max: %i summed averageQ: %i adapt averageQ: %i LLC averageQ: %i LLC EAPOL averageQ: %i drop: %s", active_supp, active_max, average_sum, adaptation_average, llc_average, llc_eapol_average, return_value ? "T" : "F");
32783311

32793312
return return_value;
32803313
}
@@ -3628,6 +3661,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
36283661
// Set PAE port to 10254 and authenticator relay to 10253 (and to own ll address)
36293662
ws_pae_controller_authenticator_start(cur, PAE_AUTH_SOCKET_PORT, ll_addr, EAPOL_RELAY_SOCKET_PORT);
36303663

3664+
// Initialize eapol congestion tracking
3665+
ws_bootstrap_eapol_congestion_init(cur);
3666+
36313667
// Set retry configuration for bootstrap ready state
36323668
ws_bootstrap_configure_max_retries(cur, WS_MAX_FRAME_RETRIES, WS_NUMBER_OF_CHANNEL_RETRIES);
36333669

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "Security/eapol/eapol_helper.h"
4242
#include "Service_Libs/etx/etx.h"
4343
#include "fhss_ws_extension.h"
44+
#include "Service_Libs/random_early_detection/random_early_detection_api.h"
4445

4546
#ifdef HAVE_WS
4647

@@ -109,6 +110,7 @@ typedef struct {
109110
ws_neighbor_temp_list_t active_eapol_temp_neigh;
110111
ws_neighbor_temp_list_t free_temp_neigh;
111112
llc_message_list_t llc_eap_pending_list; /**< Active Message list */
113+
uint16_t llc_eap_pending_list_size; /**< EAPOL active Message list size */
112114
bool active_eapol_session: 1; /**< Indicating active EAPOL message */
113115
} temp_entriest_t;
114116

@@ -245,6 +247,7 @@ static void llc_message_free(llc_message_t *message, llc_data_base_t *llc_base)
245247
ns_list_remove(&llc_base->llc_message_list, message);
246248
ns_dyn_mem_free(message);
247249
llc_base->llc_message_list_size--;
250+
random_early_detetction_aq_calc(llc_base->interface_ptr->llc_random_early_detection, llc_base->llc_message_list_size);
248251
}
249252

250253
static void llc_message_id_allocate(llc_message_t *message, llc_data_base_t *llc_base, bool mpx_user)
@@ -534,6 +537,8 @@ static void ws_llc_mac_confirm_cb(const mac_api_t *api, const mcps_data_conf_t *
534537
if (message) {
535538
//Start A pending EAPOL
536539
ns_list_remove(&base->temp_entries->llc_eap_pending_list, message);
540+
base->temp_entries->llc_eap_pending_list_size--;
541+
random_early_detetction_aq_calc(base->interface_ptr->llc_eapol_random_early_detection, base->temp_entries->llc_eap_pending_list_size);
537542
ws_llc_mpx_eapol_send(base, message);
538543
}
539544
} else {
@@ -1020,6 +1025,7 @@ static void ws_llc_lowpan_mpx_data_request(llc_data_base_t *base, mpx_user_t *us
10201025
//Add To active list
10211026
llc_message_id_allocate(message, base, true);
10221027
base->llc_message_list_size++;
1028+
random_early_detetction_aq_calc(base->interface_ptr->llc_random_early_detection, base->llc_message_list_size);
10231029
ns_list_add_to_end(&base->llc_message_list, message);
10241030

10251031
mcps_data_req_t data_req;
@@ -1147,6 +1153,7 @@ static void ws_llc_mpx_eapol_send(llc_data_base_t *base, llc_message_t *message)
11471153
mcps_data_req_t data_req;
11481154
llc_message_id_allocate(message, base, true);
11491155
base->llc_message_list_size++;
1156+
random_early_detetction_aq_calc(base->interface_ptr->llc_random_early_detection, base->llc_message_list_size);
11501157
ns_list_add_to_end(&base->llc_message_list, message);
11511158
message->eapol_temporary = ws_llc_eapol_temp_entry_set(base, message->dst_address);
11521159
ws_llc_eapol_data_req_init(&data_req, message);
@@ -1240,6 +1247,8 @@ static void ws_llc_mpx_eapol_request(llc_data_base_t *base, mpx_user_t *user_cb,
12401247
if (base->temp_entries->active_eapol_session) {
12411248
//Move to pending list
12421249
ns_list_add_to_end(&base->temp_entries->llc_eap_pending_list, message);
1250+
base->temp_entries->llc_eap_pending_list_size++;
1251+
random_early_detetction_aq_calc(base->interface_ptr->llc_eapol_random_early_detection, base->temp_entries->llc_eap_pending_list_size);
12431252
} else {
12441253
ws_llc_mpx_eapol_send(base, message);
12451254
}
@@ -1351,6 +1360,7 @@ static void ws_llc_clean(llc_data_base_t *base)
13511360
ns_list_remove(&base->temp_entries->llc_eap_pending_list, message);
13521361
ns_dyn_mem_free(message);
13531362
}
1363+
base->temp_entries->llc_eap_pending_list_size = 0;
13541364
base->temp_entries->active_eapol_session = false;
13551365
memset(&base->ie_params, 0, sizeof(llc_ie_params_t));
13561366

@@ -1683,6 +1693,7 @@ int8_t ws_llc_asynch_request(struct protocol_interface_info_entry *interface, as
16831693
//Add To active list
16841694
llc_message_id_allocate(message, base, false);
16851695
base->llc_message_list_size++;
1696+
random_early_detetction_aq_calc(base->interface_ptr->llc_random_early_detection, base->llc_message_list_size);
16861697
ns_list_add_to_end(&base->llc_message_list, message);
16871698
message->messsage_type = request->message_type;
16881699

source/NWK_INTERFACE/Include/protocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ struct protocol_interface_info_entry {
448448
br_info_t *border_router_setup;
449449
struct load_balance_api *lb_api;
450450
struct red_info_s *random_early_detection;
451+
struct red_info_s *llc_random_early_detection;
452+
struct red_info_s *llc_eapol_random_early_detection;
451453
neigh_cache_s neigh_cache;
452454
pan_blaclist_cache_s pan_blaclist_cache;
453455
pan_coordinator_blaclist_cache_s pan_cordinator_black_list;

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ TEST_SRC_FILES = \
3636
../../stub/iphc_decompress_stub.c \
3737
../../stub/fhss_config_stub.c \
3838
../../stub/eapol_helper_stub.c \
39+
../../random_early_detection_stub.c \
3940

4041

4142
include ../../MakefileWorker.mk

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/test_ws_llc_data_service.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "6LoWPAN/ws/ws_neighbor_class.h"
3636
#include "6LoWPAN/ws/ws_common.h"
3737
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
38+
#include "Service_Libs/random_early_detection/random_early_detection_api.h"
39+
#include "Service_Libs/random_early_detection/random_early_detection.h"
3840
#include "nsdynmemLIB_stub.h"
3941
#include "mac_ie_lib_stub.h"
4042
#include "ws_mpx_header_stub.h"
@@ -43,6 +45,7 @@
4345
#include "ws_neighbour_class_stub.h"
4446
#include "ws_ie_lib_stub.h"
4547
#include "address_stub.h"
48+
#include "random_early_detection_stub.h"
4649
#include "fhss_ws_extension.h"
4750

4851
static mcps_data_indication_ext *data_indication_cb;

0 commit comments

Comments
 (0)