Skip to content

Commit

Permalink
Wi-SUN Timing configuration is selected based on network size and dat…
Browse files Browse the repository at this point in the history
…a rate

Network size and data rate are used in combination when selecting
the timing configuration used by the Wi-SUN stack.

Faster data rate allows more devices to use same timing settings.
Added different device amount limits for
50kbs, 150kbs, 300kbs, 600kbs data rates.
  • Loading branch information
Mika Tervonen committed Dec 16, 2020
1 parent a5b2a26 commit ee4333d
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Release vxx.x.x

### Features
* Wi-SUN timing parameters are selected based on Data rate and network size.
*

### Changes
Expand Down
8 changes: 4 additions & 4 deletions source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ static void ws_bbr_rpl_version_timer_start(protocol_interface_info_entry_t *cur,
//stable version for RPL so slow timer update is ok
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME;
} else {
if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_SMALL) {
// handles also NETWORK_SIZE_CERTIFICATE
if (ws_cfg_network_config_get(cur) <= CONFIG_SMALL) {
// Also handles CONFIG_CERTIFICATE
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_SMALL;
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_MEDIUM) {
} else if (ws_cfg_network_config_get(cur) <= CONFIG_MEDIUM) {
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_MEDIUM;
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_LARGE) {
} else if (ws_cfg_network_config_get(cur) <= CONFIG_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
12 changes: 6 additions & 6 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,10 +1550,10 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
*/
trickle_consistent_heard(&cur->ws_info->trickle_pan_advertisement_solicit);
/*
* Optimized PAN discovery to select faster the parent if we hear solicit from someone else
* Optimized PAN discovery to select the parent faster if we hear solicit from someone else
*/

if (ws_bootstrap_state_discovery(cur) && cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_MEDIUM &&
if (ws_bootstrap_state_discovery(cur) && ws_cfg_network_config_get(cur) <= CONFIG_MEDIUM &&
cur->bootsrap_state_machine_cnt > cur->ws_info->trickle_params_pan_discovery.Imin * 2) {

cur->bootsrap_state_machine_cnt = cur->ws_info->trickle_params_pan_discovery.Imin + randLIB_get_random_in_range(0, cur->ws_info->trickle_params_pan_discovery.Imin);
Expand Down Expand Up @@ -2044,7 +2044,7 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt

static uint32_t ws_probe_init_time_get(protocol_interface_info_entry_t *cur)
{
if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_SMALL) {
if (ws_cfg_network_config_get(cur) <= CONFIG_SMALL) {
return WS_SMALL_PROBE_INIT_BASE_SECONDS;
}

Expand Down Expand Up @@ -3084,9 +3084,9 @@ static void ws_bootstrap_rpl_scan_start(protocol_interface_info_entry_t *cur)
tr_debug("Start RPL learn");
// routers wait until RPL root is contacted
ws_bootstrap_state_change(cur, ER_RPL_SCAN);
//For Large network and medium shuold do passive scan
if (cur->ws_info->cfg->gen.network_size > NETWORK_SIZE_SMALL) {
// Set timeout for check to 30 -60 seconds
//For Large network and medium should do passive scan
if (ws_cfg_network_config_get(cur) > CONFIG_SMALL) {
// Set timeout for check to 30 - 60 seconds
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(WS_RPL_DIS_INITIAL_TIMEOUT / 2, WS_RPL_DIS_INITIAL_TIMEOUT);
}
/* While in Join State 4, if a non Border Router determines it has been unable to communicate with the PAN Border
Expand Down
75 changes: 71 additions & 4 deletions source/6LoWPAN/ws/ws_cfg_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ typedef union {
ws_sec_prot_cfg_t sec_prot;
} ws_cfgs_t;


typedef struct cfg_devices_in_config {
uint8_t max_for_small;
uint8_t max_for_medium;
uint8_t max_for_large;
uint8_t max_for_xlarge;
} cfg_devices_in_config_t;

/* Table for amount of devices that certain configuration should be used
*
* larger data rates allow more devices to be used with faster settings.
*
* For example with network the size of 2000 devices we use
* Xlrage configuration with 50kbs data rate.
* Large configuration with 300kbs data rate.
* and with 600kbs data rate it is possible to use medium network settings.
*
*/
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
};


static int8_t ws_cfg_to_get(ws_cfgs_t **cfg, ws_cfgs_t *new_cfg, ws_cfg_validate valid_cb, ws_cfgs_t *external_cfg, uint8_t *cfg_flags, uint8_t *flags);

static void ws_cfg_network_size_config_set_small(ws_cfg_nw_size_t *cfg);
Expand Down Expand Up @@ -258,13 +284,13 @@ int8_t ws_cfg_network_size_set(protocol_interface_info_entry_t *cur, ws_gen_cfg_

ws_cfg_network_size_config_set_size set_function = NULL;

if (cfg->network_size == NETWORK_SIZE_CERTIFICATE) {
if (ws_cfg_network_config_get(cur) == CONFIG_CERTIFICATE) {
set_function = ws_cfg_network_size_config_set_certificate;
} else if (cfg->network_size <= NETWORK_SIZE_SMALL || cfg->network_size == NETWORK_SIZE_AUTOMATIC) {
} else if (ws_cfg_network_config_get(cur) == CONFIG_SMALL || cfg->network_size == NETWORK_SIZE_AUTOMATIC) {
set_function = ws_cfg_network_size_config_set_small;
} else if (cfg->network_size <= NETWORK_SIZE_MEDIUM) {
} else if (ws_cfg_network_config_get(cur) == CONFIG_MEDIUM) {
set_function = ws_cfg_network_size_config_set_medium;
} else if (cfg->network_size <= NETWORK_SIZE_LARGE) {
} else if (ws_cfg_network_config_get(cur) == CONFIG_LARGE) {
set_function = ws_cfg_network_size_config_set_large;
} else {
set_function = ws_cfg_network_size_config_set_xlarge;
Expand Down Expand Up @@ -360,6 +386,47 @@ int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint1
return CFG_SETTINGS_OK;
}

cfg_network_size_type_e ws_cfg_network_config_get(protocol_interface_info_entry_t *cur)
{
// Get size of the network Amount of devices in the network
// Get the data rate of the network
// Adjust the configuration type based on the network size and data rate

(void)cur;

ws_gen_cfg_t cfg;
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_get_datarate_using_operating_mode(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;
}


static void ws_cfg_network_size_config_set_small(ws_cfg_nw_size_t *cfg)
{
Expand Down
12 changes: 12 additions & 0 deletions source/6LoWPAN/ws/ws_cfg_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,23 @@ typedef struct ws_cfg_s {
#define CFG_SETTINGS_ERROR_SEC_TIMER_CONF -17 /**< Security timers configuration error */
#define CFG_SETTINGS_ERROR_SEC_PROT_CONF -18 /**< Security protocols configuration error */

/** Network configuration parameters sets for different network sizes*/
typedef enum {
CONFIG_CERTIFICATE = 0, ///< Configuration used in Wi-SUN Certification
CONFIG_SMALL = 1, ///< Small networks that can utilize fast recovery
CONFIG_MEDIUM = 2, ///< Medium networks that can form quickly but require balance on load
CONFIG_LARGE = 3, ///< Large networks that needs to throttle joining and maintenance
CONFIG_XLARGE = 4 ///< Xlarge networks with very slow joining, maintenance and recovery profile
} cfg_network_size_type_e;


int8_t ws_cfg_settings_init(void);
int8_t ws_cfg_settings_default_set(void);
int8_t ws_cfg_settings_interface_set(protocol_interface_info_entry_t *cur);
int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint16_t network_size);

cfg_network_size_type_e ws_cfg_network_config_get(protocol_interface_info_entry_t *cur);

int8_t ws_cfg_network_size_get(ws_gen_cfg_t *cfg, uint8_t *flags);
int8_t ws_cfg_network_size_validate(ws_gen_cfg_t *cfg, ws_gen_cfg_t *new_cfg);
int8_t ws_cfg_network_size_set(protocol_interface_info_entry_t *cur, ws_gen_cfg_t *cfg, ws_gen_cfg_t *new_cfg, uint8_t *flags);
Expand Down
13 changes: 4 additions & 9 deletions source/6LoWPAN/ws/ws_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,18 +564,13 @@ bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, con
uint32_t ws_common_latency_estimate_get(protocol_interface_info_entry_t *cur)
{
uint32_t latency = 0;
uint8_t network_size = cur->ws_info->cfg->gen.network_size;

if (network_size == NETWORK_SIZE_AUTOMATIC) {
network_size = cur->ws_info->pan_information.pan_size / 100;
}

if (network_size <= NETWORK_SIZE_SMALL) {
// handles also NETWORK_SIZE_CERTIFICATE
if (ws_cfg_network_config_get(cur) <= CONFIG_SMALL) {
// Also has the certificate settings
latency = 5000;
} else if (network_size <= NETWORK_SIZE_MEDIUM) {
} else if (ws_cfg_network_config_get(cur) <= CONFIG_MEDIUM) {
latency = 10000;
} else if (network_size <= NETWORK_SIZE_LARGE) {
} else if (ws_cfg_network_config_get(cur) <= CONFIG_LARGE) {
latency = 20000;
} else {
latency = 30000;
Expand Down
5 changes: 5 additions & 0 deletions test/nanostack/unittest/stub/ws_common_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ uint32_t ws_common_datarate_get(protocol_interface_info_entry_t *cur)
return 0;
}

uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode)
{
return 150000;
}

uint32_t ws_common_network_size_estimate_get(protocol_interface_info_entry_t *cur)
{
return 0;
Expand Down

0 comments on commit ee4333d

Please sign in to comment.