Skip to content

Commit

Permalink
Added support for dynamic RPL default lifetime
Browse files Browse the repository at this point in the history
RPL default lifetime is now controlled by the network size
Clients can now have larger Maximum DAO registration times

This reduces the DAO registration need if there is more
devices in the network.

DAO registrations are still done faster if we do not detect the
Border router in any other means. or routing stops working.
  • Loading branch information
Mika Tervonen authored and Mika Tervonen committed Jan 28, 2021
1 parent d258068 commit c8343b1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 10 deletions.
27 changes: 25 additions & 2 deletions source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,41 @@ static void ws_bbr_rpl_version_increase(protocol_interface_info_entry_t *cur)
ws_bbr_rpl_version_timer_start(cur, rpl_control_increment_dodag_version(protocol_6lowpan_rpl_root_dodag));
}

void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8_t doubling, uint8_t redundancy, uint16_t dag_max_rank_increase, uint16_t min_hop_rank_increase)
void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8_t doubling, uint8_t redundancy, uint16_t dag_max_rank_increase, uint16_t min_hop_rank_increase, uint32_t lifetime)
{
if (imin == 0 || doubling == 0) {
// use default values
imin = WS_RPL_DIO_IMIN_SMALL;
doubling = WS_RPL_DIO_DOUBLING_SMALL;
redundancy = WS_RPL_DIO_REDUNDANCY_SMALL;
}
uint8_t lifetime_unit = 60;
uint8_t default_lifetime;

if (lifetime == 0) {
// 2 hours default lifetime
lifetime = 120 * 60;
} else if (lifetime <= 250 * 60) {
// Lifetime unit of 60 is ok up to 4 hours
} else if (lifetime <= 250 * 120) {
//more than 4 hours needs larger lifetime unit
lifetime_unit = 120;
} else if (lifetime <= 250 * 240) {
lifetime_unit = 240;
} else {
// Maximum lifetime is 16 hours 40 minutes
lifetime = 250 * 240;
lifetime_unit = 240;
}
default_lifetime = lifetime / lifetime_unit;

if (rpl_conf.dio_interval_min == imin &&
rpl_conf.dio_interval_doublings == doubling &&
rpl_conf.dio_redundancy_constant == redundancy &&
rpl_conf.dag_max_rank_increase == dag_max_rank_increase &&
rpl_conf.min_hop_rank_increase == min_hop_rank_increase) {
rpl_conf.min_hop_rank_increase == min_hop_rank_increase &&
rpl_conf.default_lifetime == default_lifetime &&
rpl_conf.lifetime_unit == lifetime_unit) {
// Same values no update needed
return;
}
Expand All @@ -220,6 +241,8 @@ void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8
rpl_conf.dio_redundancy_constant = redundancy;
rpl_conf.dag_max_rank_increase = dag_max_rank_increase;
rpl_conf.min_hop_rank_increase = min_hop_rank_increase;
rpl_conf.default_lifetime = default_lifetime;
rpl_conf.lifetime_unit = lifetime_unit;

if (protocol_6lowpan_rpl_root_dodag) {
rpl_control_update_dodag_config(protocol_6lowpan_rpl_root_dodag, &rpl_conf);
Expand Down
4 changes: 2 additions & 2 deletions source/6LoWPAN/ws/ws_bbr_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ws_bbr_pan_version_increase(protocol_interface_info_entry_t *cur);

uint16_t ws_bbr_pan_size(protocol_interface_info_entry_t *cur);

void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8_t doubling, uint8_t redundancy, uint16_t dag_max_rank_increase, uint16_t min_hop_rank_increase);
void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8_t doubling, uint8_t redundancy, uint16_t dag_max_rank_increase, uint16_t min_hop_rank_increase, uint32_t lifetime);

void ws_bbr_dhcp_address_lifetime_set(protocol_interface_info_entry_t *cur, uint32_t dhcp_address_lifetime);

Expand All @@ -45,7 +45,7 @@ void ws_bbr_init(protocol_interface_info_entry_t *interface);
#define ws_bbr_seconds_timer( cur, seconds)
#define ws_bbr_pan_version_increase(cur)
#define ws_bbr_pan_size(cur) 0
#define ws_bbr_rpl_config( cur, imin, doubling, redundancy, dag_max_rank_increase, min_hop_rank_increase)
#define ws_bbr_rpl_config( cur, imin, doubling, redundancy, dag_max_rank_increase, min_hop_rank_increase, lifetime)
#define ws_bbr_dhcp_address_lifetime_set(cur, dhcp_address_lifetime)
#define ws_bbr_ready_to_start(cur) true
#define ws_bbr_backbone_address_get(address) 0
Expand Down
11 changes: 9 additions & 2 deletions source/6LoWPAN/ws/ws_cfg_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ static void ws_cfg_network_size_config_set_small(ws_cfg_nw_size_t *cfg)
cfg->bbr.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_SMALL; // Disabled
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.rpl_default_lifetime = WS_RPL_DEFAULT_LIFETIME;
cfg->bbr.dhcp_address_lifetime = WS_DHCP_ADDRESS_LIFETIME_SMALL;

// EAPOL configuration
Expand Down Expand Up @@ -492,6 +493,7 @@ static void ws_cfg_network_size_config_set_medium(ws_cfg_nw_size_t *cfg)
cfg->bbr.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_MEDIUM; // 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.rpl_default_lifetime = WS_RPL_DEFAULT_LIFETIME_MEDIUM;
cfg->bbr.dhcp_address_lifetime = WS_DHCP_ADDRESS_LIFETIME_MEDIUM;

// EAPOL configuration
Expand Down Expand Up @@ -535,6 +537,7 @@ static void ws_cfg_network_size_config_set_large(ws_cfg_nw_size_t *cfg)
cfg->bbr.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_LARGE; // 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.rpl_default_lifetime = WS_RPL_DEFAULT_LIFETIME_LARGE;
cfg->bbr.dhcp_address_lifetime = WS_DHCP_ADDRESS_LIFETIME_LARGE;

// EAPOL configuration
Expand Down Expand Up @@ -579,6 +582,7 @@ static void ws_cfg_network_size_config_set_xlarge(ws_cfg_nw_size_t *cfg)
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.rpl_default_lifetime = WS_RPL_DEFAULT_LIFETIME_XLARGE;
cfg->bbr.dhcp_address_lifetime = WS_DHCP_ADDRESS_LIFETIME_LARGE;

// EAPOL configuration
Expand Down Expand Up @@ -622,6 +626,7 @@ static void ws_cfg_network_size_config_set_certificate(ws_cfg_nw_size_t *cfg)
cfg->bbr.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY_SMALL; // Disabled
cfg->bbr.dag_max_rank_increase = WS_CERTIFICATE_RPL_MAX_HOP_RANK_INCREASE;
cfg->bbr.min_hop_rank_increase = WS_CERTIFICATE_RPL_MIN_HOP_RANK_INCREASE;
cfg->bbr.rpl_default_lifetime = WS_RPL_DEFAULT_LIFETIME;
cfg->bbr.dhcp_address_lifetime = WS_DHCP_ADDRESS_LIFETIME_SMALL;

// EAPOL configuration
Expand Down Expand Up @@ -909,6 +914,7 @@ static int8_t ws_cfg_bbr_default_set(ws_bbr_cfg_t *cfg)
cfg->dio_redundancy_constant = 10;
cfg->dag_max_rank_increase = WS_RPL_MAX_HOP_RANK_INCREASE;
cfg->min_hop_rank_increase = WS_RPL_MIN_HOP_RANK_INCREASE;
cfg->rpl_default_lifetime = WS_RPL_DEFAULT_LIFETIME_MEDIUM;
cfg->dhcp_address_lifetime = WS_DHCP_ADDRESS_LIFETIME_MEDIUM;

return CFG_SETTINGS_OK;
Expand All @@ -932,7 +938,8 @@ int8_t ws_cfg_bbr_validate(ws_bbr_cfg_t *cfg, ws_bbr_cfg_t *new_cfg)
cfg->dio_redundancy_constant != new_cfg->dio_redundancy_constant ||
cfg->dag_max_rank_increase != new_cfg->dag_max_rank_increase ||
cfg->min_hop_rank_increase != new_cfg->min_hop_rank_increase ||
cfg->dhcp_address_lifetime != new_cfg->dhcp_address_lifetime) {
cfg->dhcp_address_lifetime != new_cfg->dhcp_address_lifetime ||
cfg->rpl_default_lifetime != new_cfg->rpl_default_lifetime) {
return CFG_SETTINGS_CHANGED;
}

Expand All @@ -954,7 +961,7 @@ int8_t ws_cfg_bbr_set(protocol_interface_info_entry_t *cur, ws_bbr_cfg_t *cfg, w
// cur is optional, default values are for Wi-SUN small network parameters,
ws_bbr_rpl_config(cur, new_cfg->dio_interval_min, new_cfg->dio_interval_doublings,
new_cfg->dio_redundancy_constant, new_cfg->dag_max_rank_increase,
new_cfg->min_hop_rank_increase);
new_cfg->min_hop_rank_increase, new_cfg->rpl_default_lifetime);
ws_bbr_dhcp_address_lifetime_set(cur, new_cfg->dhcp_address_lifetime);
}

Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/ws/ws_cfg_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ typedef struct ws_bbr_cfg_s {
uint16_t dag_max_rank_increase;
uint16_t min_hop_rank_increase;
uint32_t dhcp_address_lifetime; /**< DHCP address lifetime in seconds minimum 2 hours and maximum as days hours*/
uint32_t rpl_default_lifetime; /**< RPL default lifetime value minimum from 30 minutes to 16 hours*/
} ws_bbr_cfg_t;

/**
Expand Down
7 changes: 6 additions & 1 deletion source/6LoWPAN/ws/ws_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
#define WS_RPL_MIN_HOP_RANK_INCREASE 196
#define WS_RPL_MAX_HOP_RANK_INCREASE 2048

#define WS_RPL_DEFAULT_LIFETIME (3600*2) // 2 hours
#define WS_RPL_DEFAULT_LIFETIME_MEDIUM (3600*4) // 4 hours
#define WS_RPL_DEFAULT_LIFETIME_LARGE (3600*8) // 8 hours
#define WS_RPL_DEFAULT_LIFETIME_XLARGE (3600*12) // 12 hours

#define WS_DHCP_ADDRESS_LIFETIME_SMALL 2*3600 // small networks less than devices 100
#define WS_DHCP_ADDRESS_LIFETIME_MEDIUM 12*3600 // Medium size networks from 100 - 1000 device networks
#define WS_DHCP_ADDRESS_LIFETIME_LARGE 24*3600 // Large size networks 1000 + device networks
Expand All @@ -60,7 +65,7 @@
/*
* RPL DAO timeout maximum value. This will force DAO timeout to happen before this time
*/
#define WS_RPL_DAO_MAX_TIMOUT (3600*2)
#define WS_RPL_DAO_MAX_TIMOUT (3600*12)

/* Border router version change interval
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static const ws_cfg_t ws_cfg_defaults_medium = {
.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.rpl_default_lifetime = 4 * 3600,
.bbr.dhcp_address_lifetime = 12 * 3600,

.fhss.fhss_uc_dwell_interval = 255,
Expand Down Expand Up @@ -179,6 +180,7 @@ static const ws_cfg_t ws_cfg_defaults_small = {
.bbr.dio_redundancy_constant = 0, // network size affects
.bbr.dag_max_rank_increase = 2048, // network size affects
.bbr.min_hop_rank_increase = 196, // network size affects
.bbr.rpl_default_lifetime = 2 * 3600,
.bbr.dhcp_address_lifetime = 2 * 3600,

.fhss.fhss_uc_dwell_interval = 255,
Expand Down Expand Up @@ -250,6 +252,7 @@ static const ws_cfg_t ws_cfg_defaults_large = {
.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.rpl_default_lifetime = 8 * 3600,
.bbr.dhcp_address_lifetime = 24 * 3600,

.fhss.fhss_uc_dwell_interval = 255,
Expand Down Expand Up @@ -321,6 +324,7 @@ static const ws_cfg_t ws_cfg_defaults_xlarge = {
.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.rpl_default_lifetime = 12 * 3600,
.bbr.dhcp_address_lifetime = 24 * 3600,

.fhss.fhss_uc_dwell_interval = 255,
Expand Down Expand Up @@ -392,6 +396,7 @@ static const ws_cfg_t ws_cfg_defaults_certification = {
.bbr.dio_redundancy_constant = 0, // network size affects
.bbr.dag_max_rank_increase = 0, // network size affects
.bbr.min_hop_rank_increase = 128, // network size affects
.bbr.rpl_default_lifetime = 2 * 3600,
.bbr.dhcp_address_lifetime = 2 * 3600,

.fhss.fhss_uc_dwell_interval = 255,
Expand Down Expand Up @@ -1354,9 +1359,9 @@ bool test_ws_cfg_rpl_functions_1()
if (ws_cfg_bbr_get(&cfg, NULL) < 0) {
return false;
}
if (memcmp(&cfg, &ws_cfg_defaults_medium.bbr, sizeof(ws_bbr_cfg_t)) != 0) {
return false;
}
CHECK_START
CHECK_BUFFER(&cfg, &ws_cfg_defaults_medium.bbr, sizeof(ws_bbr_cfg_t))
CHECK_STOP

ws_common_stub.int8_value[0] = 0;

Expand Down

0 comments on commit c8343b1

Please sign in to comment.