Skip to content

Commit ee4333d

Browse files
author
Mika Tervonen
committed
Wi-SUN Timing configuration is selected based on network size and data 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.
1 parent a5b2a26 commit ee4333d

File tree

7 files changed

+103
-23
lines changed

7 files changed

+103
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Release vxx.x.x
44

55
### Features
6+
* Wi-SUN timing parameters are selected based on Data rate and network size.
67
*
78

89
### Changes

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ static void ws_bbr_rpl_version_timer_start(protocol_interface_info_entry_t *cur,
176176
//stable version for RPL so slow timer update is ok
177177
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME;
178178
} else {
179-
if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_SMALL) {
180-
// handles also NETWORK_SIZE_CERTIFICATE
179+
if (ws_cfg_network_config_get(cur) <= CONFIG_SMALL) {
180+
// Also handles CONFIG_CERTIFICATE
181181
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_SMALL;
182-
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_MEDIUM) {
182+
} else if (ws_cfg_network_config_get(cur) <= CONFIG_MEDIUM) {
183183
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_MEDIUM;
184-
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_LARGE) {
184+
} else if (ws_cfg_network_config_get(cur) <= CONFIG_LARGE) {
185185
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_LARGE;
186186
} else {
187187
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART_EXTRA_LARGE;

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,10 +1550,10 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
15501550
*/
15511551
trickle_consistent_heard(&cur->ws_info->trickle_pan_advertisement_solicit);
15521552
/*
1553-
* Optimized PAN discovery to select faster the parent if we hear solicit from someone else
1553+
* Optimized PAN discovery to select the parent faster if we hear solicit from someone else
15541554
*/
15551555

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

15591559
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);
@@ -2044,7 +2044,7 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt
20442044

20452045
static uint32_t ws_probe_init_time_get(protocol_interface_info_entry_t *cur)
20462046
{
2047-
if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_SMALL) {
2047+
if (ws_cfg_network_config_get(cur) <= CONFIG_SMALL) {
20482048
return WS_SMALL_PROBE_INIT_BASE_SECONDS;
20492049
}
20502050

@@ -3084,9 +3084,9 @@ static void ws_bootstrap_rpl_scan_start(protocol_interface_info_entry_t *cur)
30843084
tr_debug("Start RPL learn");
30853085
// routers wait until RPL root is contacted
30863086
ws_bootstrap_state_change(cur, ER_RPL_SCAN);
3087-
//For Large network and medium shuold do passive scan
3088-
if (cur->ws_info->cfg->gen.network_size > NETWORK_SIZE_SMALL) {
3089-
// Set timeout for check to 30 -60 seconds
3087+
//For Large network and medium should do passive scan
3088+
if (ws_cfg_network_config_get(cur) > CONFIG_SMALL) {
3089+
// Set timeout for check to 30 - 60 seconds
30903090
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(WS_RPL_DIS_INITIAL_TIMEOUT / 2, WS_RPL_DIS_INITIAL_TIMEOUT);
30913091
}
30923092
/* While in Join State 4, if a non Border Router determines it has been unable to communicate with the PAN Border

source/6LoWPAN/ws/ws_cfg_settings.c

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@ typedef union {
7979
ws_sec_prot_cfg_t sec_prot;
8080
} ws_cfgs_t;
8181

82+
83+
typedef struct cfg_devices_in_config {
84+
uint8_t max_for_small;
85+
uint8_t max_for_medium;
86+
uint8_t max_for_large;
87+
uint8_t max_for_xlarge;
88+
} cfg_devices_in_config_t;
89+
90+
/* Table for amount of devices that certain configuration should be used
91+
*
92+
* larger data rates allow more devices to be used with faster settings.
93+
*
94+
* For example with network the size of 2000 devices we use
95+
* Xlrage configuration with 50kbs data rate.
96+
* Large configuration with 300kbs data rate.
97+
* and with 600kbs data rate it is possible to use medium network settings.
98+
*
99+
*/
100+
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
105+
};
106+
107+
82108
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);
83109

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

259285
ws_cfg_network_size_config_set_size set_function = NULL;
260286

261-
if (cfg->network_size == NETWORK_SIZE_CERTIFICATE) {
287+
if (ws_cfg_network_config_get(cur) == CONFIG_CERTIFICATE) {
262288
set_function = ws_cfg_network_size_config_set_certificate;
263-
} else if (cfg->network_size <= NETWORK_SIZE_SMALL || cfg->network_size == NETWORK_SIZE_AUTOMATIC) {
289+
} else if (ws_cfg_network_config_get(cur) == CONFIG_SMALL || cfg->network_size == NETWORK_SIZE_AUTOMATIC) {
264290
set_function = ws_cfg_network_size_config_set_small;
265-
} else if (cfg->network_size <= NETWORK_SIZE_MEDIUM) {
291+
} else if (ws_cfg_network_config_get(cur) == CONFIG_MEDIUM) {
266292
set_function = ws_cfg_network_size_config_set_medium;
267-
} else if (cfg->network_size <= NETWORK_SIZE_LARGE) {
293+
} else if (ws_cfg_network_config_get(cur) == CONFIG_LARGE) {
268294
set_function = ws_cfg_network_size_config_set_large;
269295
} else {
270296
set_function = ws_cfg_network_size_config_set_xlarge;
@@ -360,6 +386,47 @@ int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint1
360386
return CFG_SETTINGS_OK;
361387
}
362388

389+
cfg_network_size_type_e ws_cfg_network_config_get(protocol_interface_info_entry_t *cur)
390+
{
391+
// Get size of the network Amount of devices in the network
392+
// Get the data rate of the network
393+
// Adjust the configuration type based on the network size and data rate
394+
395+
(void)cur;
396+
397+
ws_gen_cfg_t cfg;
398+
if (ws_cfg_gen_get(&cfg, NULL) < 0) {
399+
return CONFIG_SMALL;
400+
}
401+
ws_phy_cfg_t phy_cfg;
402+
if (ws_cfg_phy_get(&phy_cfg, NULL) < 0) {
403+
return CONFIG_SMALL;
404+
}
405+
406+
uint32_t data_rate = ws_get_datarate_using_operating_mode(phy_cfg.operating_mode);
407+
uint8_t index;
408+
if (data_rate < 150000) {
409+
index = 0;
410+
} else if (data_rate < 300000) {
411+
index = 1;
412+
} else if (data_rate < 600000) {
413+
index = 2;
414+
} else {
415+
index = 3;
416+
}
417+
418+
if (cfg.network_size == NETWORK_SIZE_CERTIFICATE) {
419+
return CONFIG_CERTIFICATE;
420+
} else if (cfg.network_size <= devices_by_datarate[index].max_for_small) {
421+
return CONFIG_SMALL;
422+
} else if (cfg.network_size <= devices_by_datarate[index].max_for_medium) {
423+
return CONFIG_MEDIUM;
424+
} else if (cfg.network_size <= devices_by_datarate[index].max_for_large) {
425+
return CONFIG_LARGE;
426+
}
427+
return CONFIG_XLARGE;
428+
}
429+
363430

364431
static void ws_cfg_network_size_config_set_small(ws_cfg_nw_size_t *cfg)
365432
{

source/6LoWPAN/ws/ws_cfg_settings.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,23 @@ typedef struct ws_cfg_s {
148148
#define CFG_SETTINGS_ERROR_SEC_TIMER_CONF -17 /**< Security timers configuration error */
149149
#define CFG_SETTINGS_ERROR_SEC_PROT_CONF -18 /**< Security protocols configuration error */
150150

151+
/** Network configuration parameters sets for different network sizes*/
152+
typedef enum {
153+
CONFIG_CERTIFICATE = 0, ///< Configuration used in Wi-SUN Certification
154+
CONFIG_SMALL = 1, ///< Small networks that can utilize fast recovery
155+
CONFIG_MEDIUM = 2, ///< Medium networks that can form quickly but require balance on load
156+
CONFIG_LARGE = 3, ///< Large networks that needs to throttle joining and maintenance
157+
CONFIG_XLARGE = 4 ///< Xlarge networks with very slow joining, maintenance and recovery profile
158+
} cfg_network_size_type_e;
159+
160+
151161
int8_t ws_cfg_settings_init(void);
152162
int8_t ws_cfg_settings_default_set(void);
153163
int8_t ws_cfg_settings_interface_set(protocol_interface_info_entry_t *cur);
154164
int8_t ws_cfg_network_size_configure(protocol_interface_info_entry_t *cur, uint16_t network_size);
155165

166+
cfg_network_size_type_e ws_cfg_network_config_get(protocol_interface_info_entry_t *cur);
167+
156168
int8_t ws_cfg_network_size_get(ws_gen_cfg_t *cfg, uint8_t *flags);
157169
int8_t ws_cfg_network_size_validate(ws_gen_cfg_t *cfg, ws_gen_cfg_t *new_cfg);
158170
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);

source/6LoWPAN/ws/ws_common.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -564,18 +564,13 @@ bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, con
564564
uint32_t ws_common_latency_estimate_get(protocol_interface_info_entry_t *cur)
565565
{
566566
uint32_t latency = 0;
567-
uint8_t network_size = cur->ws_info->cfg->gen.network_size;
568567

569-
if (network_size == NETWORK_SIZE_AUTOMATIC) {
570-
network_size = cur->ws_info->pan_information.pan_size / 100;
571-
}
572-
573-
if (network_size <= NETWORK_SIZE_SMALL) {
574-
// handles also NETWORK_SIZE_CERTIFICATE
568+
if (ws_cfg_network_config_get(cur) <= CONFIG_SMALL) {
569+
// Also has the certificate settings
575570
latency = 5000;
576-
} else if (network_size <= NETWORK_SIZE_MEDIUM) {
571+
} else if (ws_cfg_network_config_get(cur) <= CONFIG_MEDIUM) {
577572
latency = 10000;
578-
} else if (network_size <= NETWORK_SIZE_LARGE) {
573+
} else if (ws_cfg_network_config_get(cur) <= CONFIG_LARGE) {
579574
latency = 20000;
580575
} else {
581576
latency = 30000;

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ uint32_t ws_common_datarate_get(protocol_interface_info_entry_t *cur)
9595
return 0;
9696
}
9797

98+
uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode)
99+
{
100+
return 150000;
101+
}
102+
98103
uint32_t ws_common_network_size_estimate_get(protocol_interface_info_entry_t *cur)
99104
{
100105
return 0;

0 commit comments

Comments
 (0)