From 0b6caa32b0815bac1961fa257cca9ff262447d9d Mon Sep 17 00:00:00 2001 From: Mika Tervonen Date: Mon, 8 Mar 2021 11:15:29 +0200 Subject: [PATCH] Wi-SUN network timing parameter tuning Small network Configuration to have 30 min PAN timeout same as in certification testing Modified network sizes a bit larger sizes with faster settings Modified Large network Key retries to 3 Pan discovery Imin for large settings changed to 120 seconds --- source/6LoWPAN/ws/ws_cfg_settings.c | 89 ++++++++++--------- source/6LoWPAN/ws/ws_config.h | 6 +- .../ws_cfg_settings/test_ws_cfg_settings.c | 35 ++++---- 3 files changed, 69 insertions(+), 61 deletions(-) diff --git a/source/6LoWPAN/ws/ws_cfg_settings.c b/source/6LoWPAN/ws/ws_cfg_settings.c index 54b9ce540931..1aa30ff0b447 100644 --- a/source/6LoWPAN/ws/ws_cfg_settings.c +++ b/source/6LoWPAN/ws/ws_cfg_settings.c @@ -98,10 +98,10 @@ typedef struct cfg_devices_in_config { * */ const cfg_devices_in_config_t devices_by_datarate[] = { - { 1, 4, 10, 25}, // Configuration for 50 -100kbs - { 1, 8, 15, 25}, // Configuration for 150kbs - 200kbs - { 2, 15, 25, 50}, // Configuration for 300kbs - { 3, 20, 40, 100}, // Configuration for 600kbs - 2400kbs + { 1, 5, 10, 25}, // Configuration for 50 -100kbs + { 1, 10, 20, 40}, // Configuration for 150kbs - 200kbs + { 1, 15, 30, 60}, // Configuration for 300kbs + { 2, 20, 50, 100}, // Configuration for 600kbs - 2400kbs }; @@ -344,6 +344,39 @@ int8_t ws_cfg_network_size_set(protocol_interface_info_entry_t *cur, ws_gen_cfg_ return CFG_SETTINGS_OK; } +static uint8_t ws_cfg_config_get_by_size(protocol_interface_info_entry_t *cur, uint8_t network_size) +{ + (void)cur; + + ws_phy_cfg_t phy_cfg; + if (ws_cfg_phy_get(&phy_cfg, NULL) < 0) { + return CONFIG_SMALL; + } + uint32_t data_rate = ws_common_datarate_get_from_phy_mode(phy_cfg.phy_mode_id, phy_cfg.operating_mode); + + uint8_t index; + if (data_rate < 150000) { + index = 0; + } else if (data_rate < 300000) { + index = 1; + } else if (data_rate < 600000) { + index = 2; + } else { + index = 3; + } + + if (network_size == NETWORK_SIZE_CERTIFICATE) { + return CONFIG_CERTIFICATE; + } else if (network_size <= devices_by_datarate[index].max_for_small) { + return CONFIG_SMALL; + } else if (network_size <= devices_by_datarate[index].max_for_medium) { + return CONFIG_MEDIUM; + } else if (network_size <= devices_by_datarate[index].max_for_large) { + return CONFIG_LARGE; + } + return CONFIG_XLARGE; +} + int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint16_t network_size) { // Read settings that are affected by network size @@ -364,18 +397,18 @@ int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint1 memcpy(nw_size_external_cfg, &new_nw_size_cfg, sizeof(ws_cfg_nw_size_t)); } - // Small - if (network_size < 100) { - // Automatic + network_size = network_size / 100; + if (network_size == 0) { + network_size = 1; + } + + if (ws_cfg_config_get_by_size(cur, network_size) == CONFIG_SMALL) { ws_cfg_network_size_config_set_small(&new_nw_size_cfg); - } else if (network_size < 800) { - // Medium + } else if (ws_cfg_config_get_by_size(cur, network_size) == CONFIG_MEDIUM) { ws_cfg_network_size_config_set_medium(&new_nw_size_cfg); - } else if (network_size < 1500) { - // Medium + } else if (ws_cfg_config_get_by_size(cur, network_size) == CONFIG_LARGE) { ws_cfg_network_size_config_set_large(&new_nw_size_cfg); } else { - // Large ws_cfg_network_size_config_set_xlarge(&new_nw_size_cfg); } @@ -400,34 +433,8 @@ cfg_network_size_type_e ws_cfg_network_config_get(protocol_interface_info_entry_ if (ws_cfg_gen_get(&cfg, NULL) < 0) { return CONFIG_SMALL; } - ws_phy_cfg_t phy_cfg; - if (ws_cfg_phy_get(&phy_cfg, NULL) < 0) { - return CONFIG_SMALL; - } - uint32_t data_rate = ws_common_datarate_get_from_phy_mode(phy_cfg.phy_mode_id, phy_cfg.operating_mode); - - uint8_t index; - if (data_rate < 150000) { - index = 0; - } else if (data_rate < 300000) { - index = 1; - } else if (data_rate < 600000) { - index = 2; - } else { - index = 3; - } - - if (cfg.network_size == NETWORK_SIZE_CERTIFICATE) { - return CONFIG_CERTIFICATE; - } else if (cfg.network_size <= devices_by_datarate[index].max_for_small) { - return CONFIG_SMALL; - } else if (cfg.network_size <= devices_by_datarate[index].max_for_medium) { - return CONFIG_MEDIUM; - } else if (cfg.network_size <= devices_by_datarate[index].max_for_large) { - return CONFIG_LARGE; - } - return CONFIG_XLARGE; + return ws_cfg_config_get_by_size(cur, cfg.network_size); } @@ -523,7 +530,7 @@ static void ws_cfg_network_size_config_set_large(ws_cfg_nw_size_t *cfg) cfg->gen.rpl_selected_parent_max = WS_RPL_SELECTED_PARENT_MAX; // Configure the Wi-SUN timing trickle parameters - cfg->timing.disc_trickle_imin = TRICKLE_IMIN_60_SECS << 2; // 240 seconds + cfg->timing.disc_trickle_imin = TRICKLE_IMIN_60_SECS << 1; // 120 seconds cfg->timing.disc_trickle_imax = 1536; // 1536 seconds; 25 minutes cfg->timing.disc_trickle_k = 1; cfg->timing.pan_timeout = PAN_VERSION_LARGE_NETWORK_TIMEOUT; @@ -531,7 +538,7 @@ static void ws_cfg_network_size_config_set_large(ws_cfg_nw_size_t *cfg) cfg->timing.temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_LARGE_TIMEOUT; // RPL configuration - cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_LARGE; // 18; 262s, 4.5min + cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_LARGE; // 18; 256s, 4.5min cfg->bbr.dio_interval_doublings = WS_RPL_DIO_DOUBLING_LARGE; // 3; 2048s, 34min cfg->bbr.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_LARGE; // 10 cfg->bbr.dag_max_rank_increase = WS_RPL_MAX_HOP_RANK_INCREASE; diff --git a/source/6LoWPAN/ws/ws_config.h b/source/6LoWPAN/ws/ws_config.h index ce1e1217b03f..fb2e23ca2750 100644 --- a/source/6LoWPAN/ws/ws_config.h +++ b/source/6LoWPAN/ws/ws_config.h @@ -95,9 +95,9 @@ * */ -#define PAN_VERSION_SMALL_NETWORK_TIMEOUT 32*60 +#define PAN_VERSION_SMALL_NETWORK_TIMEOUT 30*60 -#define PAN_VERSION_MEDIUM_NETWORK_TIMEOUT 64*60 +#define PAN_VERSION_MEDIUM_NETWORK_TIMEOUT 60*60 #define PAN_VERSION_LARGE_NETWORK_TIMEOUT 90*60 @@ -290,7 +290,7 @@ extern uint8_t DEVICE_MIN_SENS; // Large network trickle values for sending of initial EAPOL-key #define LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS 600 /* 10 to 20 minutes */ #define LARGE_NW_INITIAL_KEY_TRICKLE_IMAX_SECS 1200 -#define LARGE_NW_INITIAL_KEY_RETRY_COUNT 4 +#define LARGE_NW_INITIAL_KEY_RETRY_COUNT 3 // Very slow network values for sending of initial EAPOL-key #define EXTRA_LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS 600 /* 10 to 20 minutes */ diff --git a/test/nanostack/unittest/6LoWPAN/ws_cfg_settings/test_ws_cfg_settings.c b/test/nanostack/unittest/6LoWPAN/ws_cfg_settings/test_ws_cfg_settings.c index c2077ebd5bac..d654fea4bb1a 100644 --- a/test/nanostack/unittest/6LoWPAN/ws_cfg_settings/test_ws_cfg_settings.c +++ b/test/nanostack/unittest/6LoWPAN/ws_cfg_settings/test_ws_cfg_settings.c @@ -99,7 +99,7 @@ static const ws_cfg_t ws_cfg_defaults_medium = { .timing.disc_trickle_imin = 60, // network size affects .timing.disc_trickle_imax = 960, // network size affects .timing.disc_trickle_k = 1, // network size affects - .timing.pan_timeout = 3840, // network size affects + .timing.pan_timeout = 3600, // network size affects .timing.temp_link_min_timeout = 260, // network size affects .timing.temp_eapol_min_timeout = 330, @@ -172,7 +172,7 @@ static const ws_cfg_t ws_cfg_defaults_small = { .timing.disc_trickle_imin = 15, // network size affects .timing.disc_trickle_imax = 60, // network size affects .timing.disc_trickle_k = 1, // network size affects - .timing.pan_timeout = 1920, // network size affects + .timing.pan_timeout = 1800, // network size affects .timing.temp_link_min_timeout = 260, // network size affects .timing.temp_eapol_min_timeout = 330, @@ -242,7 +242,7 @@ static const ws_cfg_t ws_cfg_defaults_large = { .phy.phy_mode_id = 255, .phy.channel_plan_id = 255, - .timing.disc_trickle_imin = 240, // network size affects + .timing.disc_trickle_imin = 120, // network size affects .timing.disc_trickle_imax = 1536, // network size affects .timing.disc_trickle_k = 1, // network size affects .timing.pan_timeout = 5400, // network size affects @@ -298,7 +298,7 @@ static const ws_cfg_t ws_cfg_defaults_large = { .sec_prot.initial_key_retry_delay = 0, // network size affects .sec_prot.initial_key_imin = 600, // network size affects .sec_prot.initial_key_imax = 1200, // network size affects - .sec_prot.initial_key_retry_cnt = 4, // network size affects + .sec_prot.initial_key_retry_cnt = 3, // network size affects }; // large network size @@ -391,7 +391,7 @@ static const ws_cfg_t ws_cfg_defaults_certification = { .timing.disc_trickle_imin = 15, // network size affects .timing.disc_trickle_imax = 60, // network size affects .timing.disc_trickle_k = 1, // network size affects - .timing.pan_timeout = 1920, // network size affects + .timing.pan_timeout = 1800, // network size affects .timing.temp_link_min_timeout = 260, // network size affects .timing.temp_eapol_min_timeout = 330, @@ -801,7 +801,7 @@ bool test_ws_cfg_network_size_functions_2() // Sets to automatic / medium cfg.network_size = NETWORK_SIZE_AUTOMATIC; - entry.ws_info->pan_information.pan_size = 200; // Medium size + entry.ws_info->pan_information.pan_size = 400; // Medium size if (ws_cfg_network_size_set(&entry, NULL, &cfg, 0) != 0) { return false; } @@ -809,16 +809,18 @@ bool test_ws_cfg_network_size_functions_2() return false; } new_cfg.gen.network_size = NETWORK_SIZE_SMALL; // to enable to compare to small configuration; - if (memcmp(&ws_cfg_defaults_small, &new_cfg, sizeof(ws_cfg_t)) != 0) { - return false; - } + + CHECK_START + CHECK_BUFFER(&ws_cfg_defaults_small, &new_cfg, sizeof(ws_cfg_t)) + new_cfg.gen.network_size = NETWORK_SIZE_AUTOMATIC; - if (entry.ws_info->trickle_params_pan_discovery.Imin != ws_cfg_defaults_medium.timing.disc_trickle_imin * 10 || - entry.ws_info->trickle_params_pan_discovery.Imax != ws_cfg_defaults_medium.timing.disc_trickle_imax * 10 || - entry.ws_info->trickle_params_pan_discovery.k != ws_cfg_defaults_medium.timing.disc_trickle_k || - entry.ws_info->trickle_params_pan_discovery.TimerExpirations != TRICKLE_EXPIRATIONS_INFINITE) { - return false; - } + + CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.Imin, ws_cfg_defaults_medium.timing.disc_trickle_imin * 10) + CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.Imax, ws_cfg_defaults_medium.timing.disc_trickle_imax * 10) + CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.k, ws_cfg_defaults_medium.timing.disc_trickle_k) + CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.TimerExpirations, TRICKLE_EXPIRATIONS_INFINITE) + CHECK_STOP + if (ws_bbr_api_stub.cur != &entry || ws_bbr_api_stub.imin != ws_cfg_defaults_medium.bbr.dio_interval_min || ws_bbr_api_stub.doubling != ws_cfg_defaults_medium.bbr.dio_interval_doublings || @@ -1006,7 +1008,7 @@ bool test_ws_cfg_network_size_configure_1() // Sets to automatic / medium cfg.network_size = NETWORK_SIZE_AUTOMATIC; - entry.ws_info->pan_information.pan_size = 1000; // Large size + entry.ws_info->pan_information.pan_size = 1200; // Large size if (ws_cfg_network_size_set(&entry, NULL, &cfg, 0) != 0) { return false; } @@ -1483,7 +1485,6 @@ bool test_ws_cfg_rpl_functions_1() ws_bbr_api_stub.redundancy != cfg.dio_redundancy_constant || ws_bbr_api_stub.dag_max_rank_increase != cfg.dag_max_rank_increase || ws_bbr_api_stub.min_hop_rank_increase != cfg.min_hop_rank_increase) { - printf("mika"); return false; }