Skip to content

Commit 20289f6

Browse files
author
Mika Tervonen
committed
Added periodic RPL version number increase
After restart increase version number in 1 hour interval about 16 times then drop the rate to once in 12 hours
1 parent d8dd18d commit 20289f6

File tree

8 files changed

+58
-22
lines changed

8 files changed

+58
-22
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,27 @@ static rpl_dodag_conf_t rpl_conf = {
8585
.dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY
8686
};
8787

88-
void ws_bbr_rpl_config(uint8_t imin, uint8_t doubling, uint8_t redundancy, uint16_t dag_max_rank_increase, uint16_t min_hop_rank_increase)
88+
static void ws_bbr_rpl_version_timer_start(protocol_interface_info_entry_t *cur, uint8_t version)
89+
{
90+
// Set the next timeout value for version update
91+
if (version < 128) {
92+
//stable version for RPL so slow timer update is ok
93+
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME;
94+
} else {
95+
cur->ws_info->rpl_version_timer = RPL_VERSION_LIFETIME_RESTART;
96+
}
97+
}
98+
99+
static void ws_bbr_rpl_version_increase(protocol_interface_info_entry_t *cur)
100+
{
101+
if (!protocol_6lowpan_rpl_root_dodag) {
102+
return;
103+
}
104+
ws_bbr_rpl_version_timer_start(cur, rpl_control_increment_dodag_version(protocol_6lowpan_rpl_root_dodag));
105+
}
106+
107+
108+
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)
89109
{
90110
if (imin == 0 || doubling == 0) {
91111
// use default values
@@ -111,11 +131,11 @@ void ws_bbr_rpl_config(uint8_t imin, uint8_t doubling, uint8_t redundancy, uint1
111131

112132
if (protocol_6lowpan_rpl_root_dodag) {
113133
rpl_control_update_dodag_config(protocol_6lowpan_rpl_root_dodag, &rpl_conf);
114-
rpl_control_increment_dodag_version(protocol_6lowpan_rpl_root_dodag);
134+
ws_bbr_rpl_version_increase(cur);
115135
}
116136
}
117137

118-
static void ws_bbr_rpl_root_start(uint8_t *dodag_id)
138+
static void ws_bbr_rpl_root_start(protocol_interface_info_entry_t *cur, uint8_t *dodag_id)
119139
{
120140
tr_info("RPL root start");
121141
rpl_data_init_root();
@@ -132,6 +152,10 @@ static void ws_bbr_rpl_root_start(uint8_t *dodag_id)
132152
}
133153
// RPL memory limits set larger for Border router
134154
rpl_control_set_memory_limits(64 * 1024, 0);
155+
156+
// Initial version number for RPL start is 240 from RPL RFC
157+
ws_bbr_rpl_version_timer_start(cur, 240);
158+
135159
}
136160

137161
static void ws_bbr_rpl_root_stop(void)
@@ -350,7 +374,7 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
350374
if (!protocol_6lowpan_rpl_root_dodag) {
351375
// Generate DODAGID
352376
if (ws_bbr_static_dodagid_create(cur) == 0) {
353-
ws_bbr_rpl_root_start(current_dodag_id);
377+
ws_bbr_rpl_root_start(cur, current_dodag_id);
354378
}
355379
}
356380

@@ -465,7 +489,8 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
465489

466490
}
467491
memcpy(current_global_prefix, global_prefix, 8);
468-
rpl_control_increment_dodag_version(protocol_6lowpan_rpl_root_dodag);
492+
ws_bbr_rpl_version_increase(cur);
493+
469494
nd_proxy_downstream_interface_register(cur->id, ws_border_router_proxy_validate, ws_border_router_proxy_state_update);
470495
} else if (memcmp(current_global_prefix, ADDR_UNSPECIFIED, 8) != 0) {
471496
/*
@@ -526,7 +551,7 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
526551
if (cur->ws_info->pan_version_timer > seconds) {
527552
cur->ws_info->pan_version_timer -= seconds;
528553
} else {
529-
// Border router has timed out
554+
// PAN version number update
530555
tr_debug("Border router version number update");
531556
cur->ws_info->pan_version_timer = ws_common_version_lifetime_get(cur->ws_info->network_size_config);
532557
cur->ws_info->pan_information.pan_version++;
@@ -537,9 +562,13 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
537562
ws_common_network_size_configure(cur, cur->ws_info->pan_information.pan_size);
538563
}
539564
}
540-
565+
if (cur->ws_info->rpl_version_timer > seconds) {
566+
cur->ws_info->rpl_version_timer -= seconds;
567+
} else {
568+
// RPL version update needed
569+
ws_bbr_rpl_version_increase(cur);
570+
}
541571
}
542-
543572
}
544573

545574
uint16_t test_pan_size_override = 0xffff;

source/6LoWPAN/ws/ws_bbr_api_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
2727

2828
uint16_t ws_bbr_pan_size(protocol_interface_info_entry_t *cur);
2929

30-
void ws_bbr_rpl_config(uint8_t imin, uint8_t doubling, uint8_t redundancy, uint16_t dag_max_rank_increase, uint16_t min_hop_rank_increase);
30+
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);
3131

3232
bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur);
3333

@@ -36,7 +36,7 @@ bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur);
3636

3737
#define ws_bbr_seconds_timer( cur, seconds)
3838
#define ws_bbr_pan_size(cur) 0
39-
#define ws_bbr_rpl_config( imin, doubling, redundancy, dag_max_rank_increase, min_hop_rank_increase)
39+
#define ws_bbr_rpl_config( cur, imin, doubling, redundancy, dag_max_rank_increase, min_hop_rank_increase)
4040
#define ws_bbr_ready_to_start(cur) true
4141

4242
#endif //HAVE_WS_BORDER_ROUTER

source/6LoWPAN/ws/ws_common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,11 @@ void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint
338338
// doublings:3 (128s)
339339
// redundancy; 0 Disabled
340340
if (cur->ws_info->network_size_config == NETWORK_SIZE_AUTOMATIC) {
341-
ws_bbr_rpl_config(14, 3, 0, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
341+
ws_bbr_rpl_config(cur, 14, 3, 0, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
342342
} else if (cur->ws_info->network_size_config == NETWORK_SIZE_CERTIFICATE) {
343-
ws_bbr_rpl_config(0, 0, 0, WS_CERTIFICATE_RPL_MAX_HOP_RANK_INCREASE, WS_CERTIFICATE_RPL_MIN_HOP_RANK_INCREASE);
343+
ws_bbr_rpl_config(cur, 0, 0, 0, WS_CERTIFICATE_RPL_MAX_HOP_RANK_INCREASE, WS_CERTIFICATE_RPL_MIN_HOP_RANK_INCREASE);
344344
} else {
345-
ws_bbr_rpl_config(0, 0, 0, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
345+
ws_bbr_rpl_config(cur, 0, 0, 0, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
346346
}
347347
ws_pae_controller_timing_adjust(1); // Fast and reactive network
348348
} else if (network_size < 300) {
@@ -352,7 +352,7 @@ void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint
352352
// imin: 15 (32s)
353353
// doublings:5 (960s)
354354
// redundancy; 10
355-
ws_bbr_rpl_config(15, 5, 10, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
355+
ws_bbr_rpl_config(cur, 15, 5, 10, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
356356
ws_pae_controller_timing_adjust(9); // medium limited network
357357
} else {
358358
// Configure the Wi-SUN discovery trickle parameters
@@ -361,7 +361,7 @@ void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint
361361
// imin: 19 (524s, 9 min)
362362
// doublings:1 (1048s, 17 min)
363363
// redundancy; 10 May need some tuning still
364-
ws_bbr_rpl_config(19, 1, 10, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
364+
ws_bbr_rpl_config(cur, 19, 1, 10, WS_RPL_MAX_HOP_RANK_INCREASE, WS_RPL_MIN_HOP_RANK_INCREASE);
365365
ws_pae_controller_timing_adjust(24); // Very slow and high latency network
366366
}
367367
return;

source/6LoWPAN/ws/ws_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ typedef struct ws_info_s {
8888
parent_info_t parent_info[WS_PARENT_LIST_SIZE];
8989
parent_info_list_t parent_list_free;
9090
parent_info_list_t parent_list_reserved;
91-
uint32_t pan_version_timer; /**< border router version udate timeout */
91+
uint16_t rpl_version_timer; /**< RPL version update timeout */
92+
uint32_t pan_version_timer; /**< border router version update timeout */
9293
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */
9394
uint32_t pan_config_sol_max_timeout;
9495
uint8_t gtkhash[32];

source/6LoWPAN/ws/ws_config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
#define PAN_VERSION_MEDIUM_NETWORK_LIFETIME 15*60
4747
#define PAN_VERSION_LARGE_NETWORK_LIFETIME 30*60 //30min
4848

49-
#define RPL_VERSION_LIFETIME 5*3600
49+
// RPL version number update intervall
50+
// after restart version numbers are increased faster and then slowed down when network is stable
51+
#define RPL_VERSION_LIFETIME 12*3600
52+
#define RPL_VERSION_LIFETIME_RESTART 3600
5053

5154
/* Border router connection lost timeout
5255
*

source/RPL/rpl_control.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,16 @@ void rpl_control_increment_dtsn(rpl_dodag_t *dodag)
621621
//rpl_dodag_inconsistency(dodag); currently implied by rpl_dodag_increment_dtsn
622622
}
623623

624-
void rpl_control_increment_dodag_version(rpl_dodag_t *dodag)
624+
uint8_t rpl_control_increment_dodag_version(rpl_dodag_t *dodag)
625625
{
626+
uint8_t new_version = 240;
626627
if (rpl_dodag_am_root(dodag)) {
627-
uint8_t new_version = rpl_seq_inc(rpl_dodag_get_version_number_as_root(dodag));
628+
new_version = rpl_seq_inc(rpl_dodag_get_version_number_as_root(dodag));
628629
rpl_dodag_set_version_number_as_root(dodag, new_version);
629630
}
631+
return new_version;
630632
}
633+
631634
void rpl_control_update_dodag_config(struct rpl_dodag *dodag, const rpl_dodag_conf_t *conf)
632635
{
633636

source/RPL/rpl_control.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct rpl_dodag *rpl_control_create_dodag_root(rpl_domain_t *domain, uint8_t in
130130
void rpl_control_delete_dodag_root(rpl_domain_t *domain, struct rpl_dodag *dodag);
131131
void rpl_control_update_dodag_route(struct rpl_dodag *dodag, const uint8_t *prefix, uint8_t prefix_len, uint8_t flags, uint32_t lifetime, bool age);
132132
void rpl_control_update_dodag_prefix(struct rpl_dodag *dodag, const uint8_t *prefix, uint8_t prefix_len, uint8_t flags, uint32_t lifetime, uint32_t preftime, bool age);
133-
void rpl_control_increment_dodag_version(struct rpl_dodag *dodag);
133+
uint8_t rpl_control_increment_dodag_version(struct rpl_dodag *dodag);
134134
void rpl_control_update_dodag_config(struct rpl_dodag *dodag, const rpl_dodag_conf_t *conf);
135135
void rpl_control_set_dodag_pref(struct rpl_dodag *dodag, uint8_t pref);
136136
void rpl_control_increment_dtsn(struct rpl_dodag *dodag);

test/nanostack/unittest/stub/rpl_control_stub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ void rpl_control_increment_dtsn(rpl_dodag_t *dodag)
144144

145145
}
146146

147-
void rpl_control_increment_dodag_version(rpl_dodag_t *dodag)
147+
uint8_t rpl_control_increment_dodag_version(rpl_dodag_t *dodag)
148148
{
149-
149+
return 0;
150150
}
151151

152152
void rpl_control_set_dodag_pref(rpl_dodag_t *dodag, uint8_t pref)

0 commit comments

Comments
 (0)