Skip to content

Commit 0b6caa3

Browse files
Mika TervonenMika Tervonen
authored andcommitted
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
1 parent 4921465 commit 0b6caa3

File tree

3 files changed

+69
-61
lines changed

3 files changed

+69
-61
lines changed

source/6LoWPAN/ws/ws_cfg_settings.c

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ typedef struct cfg_devices_in_config {
9898
*
9999
*/
100100
const cfg_devices_in_config_t devices_by_datarate[] = {
101-
{ 1, 4, 10, 25}, // Configuration for 50 -100kbs
102-
{ 1, 8, 15, 25}, // Configuration for 150kbs - 200kbs
103-
{ 2, 15, 25, 50}, // Configuration for 300kbs
104-
{ 3, 20, 40, 100}, // Configuration for 600kbs - 2400kbs
101+
{ 1, 5, 10, 25}, // Configuration for 50 -100kbs
102+
{ 1, 10, 20, 40}, // Configuration for 150kbs - 200kbs
103+
{ 1, 15, 30, 60}, // Configuration for 300kbs
104+
{ 2, 20, 50, 100}, // Configuration for 600kbs - 2400kbs
105105
};
106106

107107

@@ -344,6 +344,39 @@ int8_t ws_cfg_network_size_set(protocol_interface_info_entry_t *cur, ws_gen_cfg_
344344
return CFG_SETTINGS_OK;
345345
}
346346

347+
static uint8_t ws_cfg_config_get_by_size(protocol_interface_info_entry_t *cur, uint8_t network_size)
348+
{
349+
(void)cur;
350+
351+
ws_phy_cfg_t phy_cfg;
352+
if (ws_cfg_phy_get(&phy_cfg, NULL) < 0) {
353+
return CONFIG_SMALL;
354+
}
355+
uint32_t data_rate = ws_common_datarate_get_from_phy_mode(phy_cfg.phy_mode_id, phy_cfg.operating_mode);
356+
357+
uint8_t index;
358+
if (data_rate < 150000) {
359+
index = 0;
360+
} else if (data_rate < 300000) {
361+
index = 1;
362+
} else if (data_rate < 600000) {
363+
index = 2;
364+
} else {
365+
index = 3;
366+
}
367+
368+
if (network_size == NETWORK_SIZE_CERTIFICATE) {
369+
return CONFIG_CERTIFICATE;
370+
} else if (network_size <= devices_by_datarate[index].max_for_small) {
371+
return CONFIG_SMALL;
372+
} else if (network_size <= devices_by_datarate[index].max_for_medium) {
373+
return CONFIG_MEDIUM;
374+
} else if (network_size <= devices_by_datarate[index].max_for_large) {
375+
return CONFIG_LARGE;
376+
}
377+
return CONFIG_XLARGE;
378+
}
379+
347380
int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint16_t network_size)
348381
{
349382
// 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
364397
memcpy(nw_size_external_cfg, &new_nw_size_cfg, sizeof(ws_cfg_nw_size_t));
365398
}
366399

367-
// Small
368-
if (network_size < 100) {
369-
// Automatic
400+
network_size = network_size / 100;
401+
if (network_size == 0) {
402+
network_size = 1;
403+
}
404+
405+
if (ws_cfg_config_get_by_size(cur, network_size) == CONFIG_SMALL) {
370406
ws_cfg_network_size_config_set_small(&new_nw_size_cfg);
371-
} else if (network_size < 800) {
372-
// Medium
407+
} else if (ws_cfg_config_get_by_size(cur, network_size) == CONFIG_MEDIUM) {
373408
ws_cfg_network_size_config_set_medium(&new_nw_size_cfg);
374-
} else if (network_size < 1500) {
375-
// Medium
409+
} else if (ws_cfg_config_get_by_size(cur, network_size) == CONFIG_LARGE) {
376410
ws_cfg_network_size_config_set_large(&new_nw_size_cfg);
377411
} else {
378-
// Large
379412
ws_cfg_network_size_config_set_xlarge(&new_nw_size_cfg);
380413
}
381414

@@ -400,34 +433,8 @@ cfg_network_size_type_e ws_cfg_network_config_get(protocol_interface_info_entry_
400433
if (ws_cfg_gen_get(&cfg, NULL) < 0) {
401434
return CONFIG_SMALL;
402435
}
403-
ws_phy_cfg_t phy_cfg;
404-
if (ws_cfg_phy_get(&phy_cfg, NULL) < 0) {
405-
return CONFIG_SMALL;
406-
}
407436

408-
uint32_t data_rate = ws_common_datarate_get_from_phy_mode(phy_cfg.phy_mode_id, phy_cfg.operating_mode);
409-
410-
uint8_t index;
411-
if (data_rate < 150000) {
412-
index = 0;
413-
} else if (data_rate < 300000) {
414-
index = 1;
415-
} else if (data_rate < 600000) {
416-
index = 2;
417-
} else {
418-
index = 3;
419-
}
420-
421-
if (cfg.network_size == NETWORK_SIZE_CERTIFICATE) {
422-
return CONFIG_CERTIFICATE;
423-
} else if (cfg.network_size <= devices_by_datarate[index].max_for_small) {
424-
return CONFIG_SMALL;
425-
} else if (cfg.network_size <= devices_by_datarate[index].max_for_medium) {
426-
return CONFIG_MEDIUM;
427-
} else if (cfg.network_size <= devices_by_datarate[index].max_for_large) {
428-
return CONFIG_LARGE;
429-
}
430-
return CONFIG_XLARGE;
437+
return ws_cfg_config_get_by_size(cur, cfg.network_size);
431438
}
432439

433440

@@ -523,15 +530,15 @@ static void ws_cfg_network_size_config_set_large(ws_cfg_nw_size_t *cfg)
523530
cfg->gen.rpl_selected_parent_max = WS_RPL_SELECTED_PARENT_MAX;
524531

525532
// Configure the Wi-SUN timing trickle parameters
526-
cfg->timing.disc_trickle_imin = TRICKLE_IMIN_60_SECS << 2; // 240 seconds
533+
cfg->timing.disc_trickle_imin = TRICKLE_IMIN_60_SECS << 1; // 120 seconds
527534
cfg->timing.disc_trickle_imax = 1536; // 1536 seconds; 25 minutes
528535
cfg->timing.disc_trickle_k = 1;
529536
cfg->timing.pan_timeout = PAN_VERSION_LARGE_NETWORK_TIMEOUT;
530537
cfg->timing.temp_link_min_timeout = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_LARGE;
531538
cfg->timing.temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_LARGE_TIMEOUT;
532539

533540
// RPL configuration
534-
cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_LARGE; // 18; 262s, 4.5min
541+
cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_LARGE; // 18; 256s, 4.5min
535542
cfg->bbr.dio_interval_doublings = WS_RPL_DIO_DOUBLING_LARGE; // 3; 2048s, 34min
536543
cfg->bbr.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_LARGE; // 10
537544
cfg->bbr.dag_max_rank_increase = WS_RPL_MAX_HOP_RANK_INCREASE;

source/6LoWPAN/ws/ws_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@
9595
*
9696
*/
9797

98-
#define PAN_VERSION_SMALL_NETWORK_TIMEOUT 32*60
98+
#define PAN_VERSION_SMALL_NETWORK_TIMEOUT 30*60
9999

100-
#define PAN_VERSION_MEDIUM_NETWORK_TIMEOUT 64*60
100+
#define PAN_VERSION_MEDIUM_NETWORK_TIMEOUT 60*60
101101

102102
#define PAN_VERSION_LARGE_NETWORK_TIMEOUT 90*60
103103

@@ -290,7 +290,7 @@ extern uint8_t DEVICE_MIN_SENS;
290290
// Large network trickle values for sending of initial EAPOL-key
291291
#define LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS 600 /* 10 to 20 minutes */
292292
#define LARGE_NW_INITIAL_KEY_TRICKLE_IMAX_SECS 1200
293-
#define LARGE_NW_INITIAL_KEY_RETRY_COUNT 4
293+
#define LARGE_NW_INITIAL_KEY_RETRY_COUNT 3
294294

295295
// Very slow network values for sending of initial EAPOL-key
296296
#define EXTRA_LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS 600 /* 10 to 20 minutes */

test/nanostack/unittest/6LoWPAN/ws_cfg_settings/test_ws_cfg_settings.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static const ws_cfg_t ws_cfg_defaults_medium = {
9999
.timing.disc_trickle_imin = 60, // network size affects
100100
.timing.disc_trickle_imax = 960, // network size affects
101101
.timing.disc_trickle_k = 1, // network size affects
102-
.timing.pan_timeout = 3840, // network size affects
102+
.timing.pan_timeout = 3600, // network size affects
103103
.timing.temp_link_min_timeout = 260, // network size affects
104104
.timing.temp_eapol_min_timeout = 330,
105105

@@ -172,7 +172,7 @@ static const ws_cfg_t ws_cfg_defaults_small = {
172172
.timing.disc_trickle_imin = 15, // network size affects
173173
.timing.disc_trickle_imax = 60, // network size affects
174174
.timing.disc_trickle_k = 1, // network size affects
175-
.timing.pan_timeout = 1920, // network size affects
175+
.timing.pan_timeout = 1800, // network size affects
176176
.timing.temp_link_min_timeout = 260, // network size affects
177177
.timing.temp_eapol_min_timeout = 330,
178178

@@ -242,7 +242,7 @@ static const ws_cfg_t ws_cfg_defaults_large = {
242242
.phy.phy_mode_id = 255,
243243
.phy.channel_plan_id = 255,
244244

245-
.timing.disc_trickle_imin = 240, // network size affects
245+
.timing.disc_trickle_imin = 120, // network size affects
246246
.timing.disc_trickle_imax = 1536, // network size affects
247247
.timing.disc_trickle_k = 1, // network size affects
248248
.timing.pan_timeout = 5400, // network size affects
@@ -298,7 +298,7 @@ static const ws_cfg_t ws_cfg_defaults_large = {
298298
.sec_prot.initial_key_retry_delay = 0, // network size affects
299299
.sec_prot.initial_key_imin = 600, // network size affects
300300
.sec_prot.initial_key_imax = 1200, // network size affects
301-
.sec_prot.initial_key_retry_cnt = 4, // network size affects
301+
.sec_prot.initial_key_retry_cnt = 3, // network size affects
302302
};
303303

304304
// large network size
@@ -391,7 +391,7 @@ static const ws_cfg_t ws_cfg_defaults_certification = {
391391
.timing.disc_trickle_imin = 15, // network size affects
392392
.timing.disc_trickle_imax = 60, // network size affects
393393
.timing.disc_trickle_k = 1, // network size affects
394-
.timing.pan_timeout = 1920, // network size affects
394+
.timing.pan_timeout = 1800, // network size affects
395395
.timing.temp_link_min_timeout = 260, // network size affects
396396
.timing.temp_eapol_min_timeout = 330,
397397

@@ -801,24 +801,26 @@ bool test_ws_cfg_network_size_functions_2()
801801

802802
// Sets to automatic / medium
803803
cfg.network_size = NETWORK_SIZE_AUTOMATIC;
804-
entry.ws_info->pan_information.pan_size = 200; // Medium size
804+
entry.ws_info->pan_information.pan_size = 400; // Medium size
805805
if (ws_cfg_network_size_set(&entry, NULL, &cfg, 0) != 0) {
806806
return false;
807807
}
808808
if (ws_cfg_settings_get(NULL, &new_cfg) < 0) {
809809
return false;
810810
}
811811
new_cfg.gen.network_size = NETWORK_SIZE_SMALL; // to enable to compare to small configuration;
812-
if (memcmp(&ws_cfg_defaults_small, &new_cfg, sizeof(ws_cfg_t)) != 0) {
813-
return false;
814-
}
812+
813+
CHECK_START
814+
CHECK_BUFFER(&ws_cfg_defaults_small, &new_cfg, sizeof(ws_cfg_t))
815+
815816
new_cfg.gen.network_size = NETWORK_SIZE_AUTOMATIC;
816-
if (entry.ws_info->trickle_params_pan_discovery.Imin != ws_cfg_defaults_medium.timing.disc_trickle_imin * 10 ||
817-
entry.ws_info->trickle_params_pan_discovery.Imax != ws_cfg_defaults_medium.timing.disc_trickle_imax * 10 ||
818-
entry.ws_info->trickle_params_pan_discovery.k != ws_cfg_defaults_medium.timing.disc_trickle_k ||
819-
entry.ws_info->trickle_params_pan_discovery.TimerExpirations != TRICKLE_EXPIRATIONS_INFINITE) {
820-
return false;
821-
}
817+
818+
CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.Imin, ws_cfg_defaults_medium.timing.disc_trickle_imin * 10)
819+
CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.Imax, ws_cfg_defaults_medium.timing.disc_trickle_imax * 10)
820+
CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.k, ws_cfg_defaults_medium.timing.disc_trickle_k)
821+
CHECK_NUM(entry.ws_info->trickle_params_pan_discovery.TimerExpirations, TRICKLE_EXPIRATIONS_INFINITE)
822+
CHECK_STOP
823+
822824
if (ws_bbr_api_stub.cur != &entry ||
823825
ws_bbr_api_stub.imin != ws_cfg_defaults_medium.bbr.dio_interval_min ||
824826
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()
10061008

10071009
// Sets to automatic / medium
10081010
cfg.network_size = NETWORK_SIZE_AUTOMATIC;
1009-
entry.ws_info->pan_information.pan_size = 1000; // Large size
1011+
entry.ws_info->pan_information.pan_size = 1200; // Large size
10101012
if (ws_cfg_network_size_set(&entry, NULL, &cfg, 0) != 0) {
10111013
return false;
10121014
}
@@ -1483,7 +1485,6 @@ bool test_ws_cfg_rpl_functions_1()
14831485
ws_bbr_api_stub.redundancy != cfg.dio_redundancy_constant ||
14841486
ws_bbr_api_stub.dag_max_rank_increase != cfg.dag_max_rank_increase ||
14851487
ws_bbr_api_stub.min_hop_rank_increase != cfg.min_hop_rank_increase) {
1486-
printf("mika");
14871488
return false;
14881489
}
14891490

0 commit comments

Comments
 (0)