Skip to content

Commit

Permalink
Created extra large network setup for Wi-SUN
Browse files Browse the repository at this point in the history
Created support for larger than 2500 device networks
BBR version updated in 8 hours interval

Added new latency step for networks larger than 1500 nodes
  • Loading branch information
Mika Tervonen committed May 19, 2020
1 parent 38dd4a6 commit 72b26a7
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 24 deletions.
20 changes: 13 additions & 7 deletions nanostack/ws_management_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ extern "C" {
#define CHANNEL_SPACING_100 0x03 // 100 khz
#define CHANNEL_SPACING_250 0x04 // 250 khz

#define NETWORK_SIZE_CERTIFICATE 0x00
#define NETWORK_SIZE_SMALL 0x01
#define NETWORK_SIZE_MEDIUM 0x08
#define NETWORK_SIZE_LARGE 0x10
/*
* Network Size definitions are device amount in hundreds of devices.
* These definitions are meant to give some estimates of sizes. Any value can be given as parameter
*/

#define NETWORK_SIZE_CERTIFICATE 0x00 // Network configuration used in Wi-SUN certification
#define NETWORK_SIZE_SMALL 0x01 // Small networks
#define NETWORK_SIZE_MEDIUM 0x08 // 100 - 800 device networks are medium sized
#define NETWORK_SIZE_LARGE 0x0F // 800 - 1500 device networks are large
#define NETWORK_SIZE_XLARGE 0x19 // 2500+ devices
#define NETWORK_SIZE_AUTOMATIC 0xFF

/** Temporary API change flag. this will be removed when new version of API is implemented on applications
Expand Down Expand Up @@ -229,9 +235,9 @@ int ws_management_regulatory_domain_validate(
*
* timing parameters follows the specification example from Wi-SUN specification
*
* Default value: medium
* small network size: hundreds of devices
* Large network size: thousands of devices
* Default value: medium 100 - 800 device
* small network size: less than 100 devices
* Large network size: 800 - 1500 devices
* automatic: when discovering the network network size is learned
* from advertisements and timings adjusted accordingly
*
Expand Down
4 changes: 3 additions & 1 deletion source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ static void ws_bbr_rpl_version_timer_start(protocol_interface_info_entry_t *cur,
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_SMALL;
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_MEDIUM) {
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_MEDIUM;
} else {
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_LARGE) {
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_LARGE;
} else {
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_EXTRA_LARGE;
}
}
}
Expand Down
62 changes: 48 additions & 14 deletions source/6LoWPAN/ws/ws_cfg_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static int8_t ws_cfg_to_get(ws_cfgs_t **cfg, ws_cfgs_t *new_cfg, ws_cfg_validate
static void ws_cfg_network_size_config_set_small(ws_cfg_nw_size_t *cfg);
static void ws_cfg_network_size_config_set_medium(ws_cfg_nw_size_t *cfg);
static void ws_cfg_network_size_config_set_large(ws_cfg_nw_size_t *cfg);
static void ws_cfg_network_size_config_set_xlarge(ws_cfg_nw_size_t *cfg);
static void ws_cfg_network_size_config_set_certificate(ws_cfg_nw_size_t *cfg);
static int8_t ws_cfg_network_size_default_set(ws_gen_cfg_t *cfg);
static int8_t ws_cfg_gen_default_set(ws_gen_cfg_t *cfg);
Expand Down Expand Up @@ -261,8 +262,10 @@ int8_t ws_cfg_network_size_set(protocol_interface_info_entry_t *cur, ws_gen_cfg_
set_function = ws_cfg_network_size_config_set_small;
} else if (cfg->network_size <= NETWORK_SIZE_MEDIUM) {
set_function = ws_cfg_network_size_config_set_medium;
} else {
} else if (cfg->network_size <= NETWORK_SIZE_LARGE) {
set_function = ws_cfg_network_size_config_set_large;
} else {
set_function = ws_cfg_network_size_config_set_xlarge;
}

// Overrides the values on the new configuration
Expand Down Expand Up @@ -334,9 +337,12 @@ int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint1
} else if (network_size < 800) {
// Medium
ws_cfg_network_size_config_set_medium(&new_nw_size_cfg);
} else if (network_size < 1500) {
// Medium
ws_cfg_network_size_config_set_large(&new_nw_size_cfg);
} else {
// Large
ws_cfg_network_size_config_set_large(&new_nw_size_cfg);
ws_cfg_network_size_config_set_xlarge(&new_nw_size_cfg);
}

ws_cfg_gen_set(cur, NULL, &new_nw_size_cfg.gen, &flags);
Expand Down Expand Up @@ -449,18 +455,46 @@ static void ws_cfg_network_size_config_set_large(ws_cfg_nw_size_t *cfg)

cfg->sec_prot.sec_max_ongoing_authentication = MAX_SIMULTANEOUS_SECURITY_NEGOTIATIONS_LARGE;

if (cfg->gen.network_size > NETWORK_SIZE_LARGE && cfg->gen.network_size != NETWORK_SIZE_AUTOMATIC) {
// If more than 1600 devices uses extra large initial trickle timer
cfg->sec_prot.initial_key_retry_delay = NONE_INITIAL_KEY_RETRY_TIMER;
cfg->sec_prot.initial_key_imin = EXTRA_LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS;
cfg->sec_prot.initial_key_imax = EXTRA_LARGE_NW_INITIAL_KEY_TRICKLE_IMAX_SECS;
cfg->sec_prot.initial_key_retry_cnt = EXTRA_LARGE_NW_INITIAL_KEY_RETRY_COUNT;
} else {
cfg->sec_prot.initial_key_retry_delay = NONE_INITIAL_KEY_RETRY_TIMER;
cfg->sec_prot.initial_key_imin = LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS;
cfg->sec_prot.initial_key_imax = LARGE_NW_INITIAL_KEY_TRICKLE_IMAX_SECS;
cfg->sec_prot.initial_key_retry_cnt = DEFAULT_INITIAL_KEY_RETRY_COUNT;
}
cfg->sec_prot.initial_key_retry_delay = NONE_INITIAL_KEY_RETRY_TIMER;
cfg->sec_prot.initial_key_imin = LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS;
cfg->sec_prot.initial_key_imax = LARGE_NW_INITIAL_KEY_TRICKLE_IMAX_SECS;
cfg->sec_prot.initial_key_retry_cnt = DEFAULT_INITIAL_KEY_RETRY_COUNT;
}

static void ws_cfg_network_size_config_set_xlarge(ws_cfg_nw_size_t *cfg)
{
// Configure the Wi-SUN parent configuration
cfg->gen.rpl_parent_candidate_max = WS_RPL_PARENT_CANDIDATE_MAX;
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_imax = 1920; // 1920 seconds; 32 minutes
cfg->timing.disc_trickle_k = 1;
cfg->timing.pan_timeout = PAN_VERSION_XLARGE_NETWORK_TIMEOUT;
cfg->timing.temp_link_min_timeout = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_LARGE;
cfg->timing.temp_eapol_min_timeout = WS_EAPOL_TEMPORARY_ENTRY_LARGE_TIMEOUT;

// RPL configuration
cfg->bbr.dio_interval_min = WS_RPL_DIO_IMIN_XLARGE; // 18; 262s, 4.5min
cfg->bbr.dio_interval_doublings = WS_RPL_DIO_DOUBLING_XLARGE; // 4; 2048s, 34min
cfg->bbr.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_XLARGE; // 10
cfg->bbr.dag_max_rank_increase = WS_RPL_MAX_HOP_RANK_INCREASE;
cfg->bbr.min_hop_rank_increase = WS_RPL_MIN_HOP_RANK_INCREASE;
cfg->bbr.dhcp_address_lifetime = WS_DHCP_ADDRESS_LIFETIME_LARGE;

// EAPOL configuration
cfg->sec_prot.sec_prot_trickle_imin = SEC_PROT_LARGE_IMIN;
cfg->sec_prot.sec_prot_trickle_imax = SEC_PROT_LARGE_IMAX;
cfg->sec_prot.sec_prot_trickle_timer_exp = SEC_PROT_TIMER_EXPIRATIONS;
cfg->sec_prot.sec_prot_retry_timeout = SEC_PROT_RETRY_TIMEOUT_LARGE;

cfg->sec_prot.sec_max_ongoing_authentication = MAX_SIMULTANEOUS_SECURITY_NEGOTIATIONS_LARGE;

cfg->sec_prot.initial_key_retry_delay = NONE_INITIAL_KEY_RETRY_TIMER;
cfg->sec_prot.initial_key_imin = EXTRA_LARGE_NW_INITIAL_KEY_TRICKLE_IMIN_SECS;
cfg->sec_prot.initial_key_imax = EXTRA_LARGE_NW_INITIAL_KEY_TRICKLE_IMAX_SECS;
cfg->sec_prot.initial_key_retry_cnt = EXTRA_LARGE_NW_INITIAL_KEY_RETRY_COUNT;
}

static void ws_cfg_network_size_config_set_certificate(ws_cfg_nw_size_t *cfg)
Expand Down
4 changes: 3 additions & 1 deletion source/6LoWPAN/ws/ws_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,10 @@ uint32_t ws_common_latency_estimate_get(protocol_interface_info_entry_t *cur)
latency = 4000;
} else if (network_size <= NETWORK_SIZE_MEDIUM) {
latency = 8000;
} else {
} else if (network_size <= NETWORK_SIZE_LARGE) {
latency = 16000;
} else {
latency = 24000;
}

return latency;
Expand Down
6 changes: 6 additions & 0 deletions source/6LoWPAN/ws/ws_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#define WS_RPL_DIO_DOUBLING_LARGE 3
#define WS_RPL_DIO_REDUNDANCY_LARGE 10 // May need some tuning still

#define WS_RPL_DIO_IMIN_XLARGE 18
#define WS_RPL_DIO_DOUBLING_XLARGE 4
#define WS_RPL_DIO_REDUNDANCY_XLARGE 10 // May need some tuning still

#define WS_RPL_DIO_IMIN_AUTOMATIC 14
#define WS_RPL_DIO_DOUBLING_AUTOMATIC 3
#define WS_RPL_DIO_REDUNDANCY_AUTOMATIC 0
Expand Down Expand Up @@ -88,6 +92,8 @@

#define PAN_VERSION_LARGE_NETWORK_TIMEOUT 90*60

#define PAN_VERSION_XLARGE_NETWORK_TIMEOUT 120*60

/* Routing Cost Weighting factor
*/
#define PRC_WEIGHT_FACTOR 256
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static const ws_cfg_t ws_cfg_defaults_small = {

// large network size
static const ws_cfg_t ws_cfg_defaults_large = {
.gen.network_size = 0x10, // network size affects
.gen.network_size = 0x0f, // network size affects
.gen.network_name = 0,
.gen.network_pan_id = 65535,
.gen.rpl_parent_candidate_max = 5, // network size affects
Expand Down Expand Up @@ -251,6 +251,75 @@ static const ws_cfg_t ws_cfg_defaults_large = {
.sec_prot.initial_key_retry_cnt = 2, // network size affects
};

// large network size
static const ws_cfg_t ws_cfg_defaults_xlarge = {
.gen.network_size = 0x19, // network size affects
.gen.network_name = 0,
.gen.network_pan_id = 65535,
.gen.rpl_parent_candidate_max = 5, // network size affects
.gen.rpl_selected_parent_max = 2, // network size affects

.phy.regulatory_domain = 3,
.phy.operating_class = 2,
.phy.operating_mode = 3,

.timing.disc_trickle_imin = 240, // network size affects
.timing.disc_trickle_imax = 1920, // network size affects
.timing.disc_trickle_k = 1, // network size affects
.timing.pan_timeout = 120 * 60, // network size affects
.timing.temp_link_min_timeout = 520, // network size affects
.timing.temp_eapol_min_timeout = 750,

.bbr.dio_interval_min = 18, // network size affects
.bbr.dio_interval_doublings = 4, // network size affects
.bbr.dio_redundancy_constant = 10, // network size affects
.bbr.dag_max_rank_increase = 2048, // network size affects
.bbr.min_hop_rank_increase = 196, // network size affects
.bbr.dhcp_address_lifetime = 24 * 3600,

.fhss.fhss_uc_dwell_interval = 255,
.fhss.fhss_bc_dwell_interval = 255,
.fhss.fhss_bc_interval = 1020,
.fhss.fhss_uc_channel_function = 2,
.fhss.fhss_bc_channel_function = 2,
.fhss.fhss_uc_fixed_channel = 65535,
.fhss.fhss_bc_fixed_channel = 65535,
.fhss.fhss_channel_mask[0] = 0xffffffff,
.fhss.fhss_channel_mask[1] = 0xffffffff,
.fhss.fhss_channel_mask[2] = 0xffffffff,
.fhss.fhss_channel_mask[3] = 0xffffffff,
.fhss.fhss_channel_mask[4] = 0xffffffff,
.fhss.fhss_channel_mask[5] = 0xffffffff,
.fhss.fhss_channel_mask[6] = 0xffffffff,
.fhss.fhss_channel_mask[7] = 0xffffffff,

.mpl.mpl_trickle_imin = 10,
.mpl.mpl_trickle_imax = 80,
.mpl.mpl_trickle_k = 8,
.mpl.mpl_trickle_timer_exp = 3,
.mpl.seed_set_entry_lifetime = 7680,

.sec_timer.gtk_expire_offset = 43200,
.sec_timer.pmk_lifetime = 172800,
.sec_timer.ptk_lifetime = 86400,
.sec_timer.gtk_new_act_time = 720,
.sec_timer.revocat_lifetime_reduct = 30,
.sec_timer.gtk_request_imin = 4,
.sec_timer.gtk_request_imax = 64,
.sec_timer.gtk_max_mismatch = 64,
.sec_timer.gtk_new_install_req = 80,

.sec_prot.sec_prot_retry_timeout = 750, // network size affects
.sec_prot.sec_prot_trickle_imin = 60, // network size affects
.sec_prot.sec_prot_trickle_imax = 240, // network size affects
.sec_prot.sec_prot_trickle_timer_exp = 2, // network size affects
.sec_prot.sec_max_ongoing_authentication = 50, // network size affects
.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
};

// certification network size
static const ws_cfg_t ws_cfg_defaults_certification = {
.gen.network_size = 0x00, // network size affects
Expand Down Expand Up @@ -441,6 +510,12 @@ bool test_ws_cfg_network_size_set_3()
}

if (memcmp(&ws_cfg_defaults_large, &new_cfg, sizeof(ws_cfg_t)) != 0) {
/*uint8_t *d1, *d2;
d1 = &ws_cfg_defaults_large;
d2 = &new_cfg;
for (int n = 0; n < sizeof(ws_cfg_t); n++) {
printf(" %u = %u %s\n", d1[n], d2[n], d1[n] != d2[n] ? "FAIL" : "");
}*/
return false;
}

Expand Down Expand Up @@ -524,6 +599,44 @@ bool test_ws_cfg_network_size_set_6()
return true;
}

bool test_ws_cfg_network_size_set_7()
{
if (ws_cfg_settings_init() < 0) {
return false;
}

ws_gen_cfg_t cfg;
if (ws_cfg_network_size_get(&cfg, NULL) < 0) {
return false;
}

cfg.network_size = NETWORK_SIZE_XLARGE;

// Sets large settings
if (ws_cfg_network_size_set(NULL, NULL, &cfg, 0) < 0) {
return false;
}

// Gets modified settings and verifies
ws_cfg_t new_cfg;
if (ws_cfg_settings_get(NULL, &new_cfg) < 0) {
return false;
}

if (memcmp(&ws_cfg_defaults_xlarge, &new_cfg, sizeof(ws_cfg_t)) != 0) {
/*uint8_t *d1, *d2;
d1 = &ws_cfg_defaults_xlarge;
d2 = &new_cfg;
for(int n = 0; n < sizeof(ws_cfg_t); n++) {
printf(" %u = %u %s\n",d1[n], d2[n], d1[n] != d2[n]?"FAIL":"");
}*/

return false;
}

return true;
}

bool test_ws_cfg_network_size_functions_1()
{
if (ws_cfg_settings_init() < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bool test_ws_cfg_network_size_set_2();
bool test_ws_cfg_network_size_set_3();
bool test_ws_cfg_network_size_set_4();
bool test_ws_cfg_network_size_set_5();
bool test_ws_cfg_network_size_set_7();

bool test_ws_cfg_network_size_functions_1();
bool test_ws_cfg_network_size_functions_2();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ TEST(ws_cfg_settings, test_ws_cfg_network_size_set_5)
CHECK(test_ws_cfg_network_size_set_5());
}

TEST(ws_cfg_settings, test_ws_cfg_network_size_set_7)
{
CHECK(test_ws_cfg_network_size_set_7());
}

TEST(ws_cfg_settings, test_ws_cfg_network_size_functions_1)
{
CHECK(test_ws_cfg_network_size_functions_1());
Expand Down

0 comments on commit 72b26a7

Please sign in to comment.