Skip to content

Commit 745c1dd

Browse files
author
Mika Tervonen
committed
refactor RPL dis sending
if there is no RPL DIO connection made DIS message is sent
1 parent 6e1cc58 commit 745c1dd

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ static const trickle_params_t trickle_params_pan_discovery = {
7373

7474
static void ws_bootstrap_event_handler(arm_event_s *event);
7575
static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp_state_t nwk_bootstrap_state);
76-
static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur);
76+
//static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur);
77+
//static bool ws_bootstrap_state_wait_rpl(struct protocol_interface_info_entry *cur);
7778
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
78-
static bool ws_bootstrap_state_wait_rpl(struct protocol_interface_info_entry *cur);
7979
static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t interface_id, arm_library_event_priority_e priority, void *event_data);
8080

8181
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t * neighbor_buffer, bool request_new);
@@ -1058,10 +1058,6 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
10581058
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, leaf);
10591059

10601060
cur->ws_info->rpl_state = 0xff; // Set invalid state and learn from event
1061-
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER) {
1062-
// TODO Multicast DIS should be sent only if no DIO heard for some time
1063-
rpl_control_transmit_dis(cur->rpl_domain, cur, 0, 0, NULL, 0, ADDR_LINK_LOCAL_ALL_RPL_NODES);
1064-
}
10651061
}
10661062

10671063
static void ws_bootstrap_network_start(protocol_interface_info_entry_t *cur)
@@ -1146,6 +1142,14 @@ static void ws_bootstrap_start_configuration_learn(protocol_interface_info_entry
11461142
trickle_start(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
11471143
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
11481144
}
1145+
static void ws_bootstrap_rpl_scan_start(protocol_interface_info_entry_t *cur)
1146+
{
1147+
tr_debug("Start RPL learn");
1148+
// routers wait until RPL root is contacted
1149+
ws_bootstrap_state_change(cur, ER_RPL_SCAN);
1150+
// Set timeout for check to 30 -60 seconds
1151+
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(WS_RPL_DIS_INITIAL_TIMEOUT/2,WS_RPL_DIS_INITIAL_TIMEOUT);
1152+
}
11491153

11501154
/*
11511155
* Event transitions
@@ -1394,8 +1398,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
13941398
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
13951399
ws_bootstrap_event_routing_ready(cur);
13961400
} else {
1397-
// routers wait until RPL root is contacted
1398-
ws_bootstrap_state_change(cur, ER_RPL_SCAN);
1401+
ws_bootstrap_rpl_scan_start(cur);
13991402
}
14001403
break;
14011404
case WS_ROUTING_READY:
@@ -1460,13 +1463,23 @@ void ws_bootstrap_rpl_wait_process(protocol_interface_info_entry_t *cur)
14601463
{
14611464

14621465
if (cur->ws_info->rpl_state == RPL_EVENT_DAO_DONE) {
1463-
// Trigger statemachine check
1466+
// RPL routing is ready
14641467
ws_bootstrap_event_routing_ready(cur);
1468+
} else if (!rpl_control_have_dodag(cur->rpl_domain)){
1469+
// RPL not ready send DIS message if possible
1470+
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER) {
1471+
// TODO Multicast DIS should be sent only if no DIO heard for some time
1472+
rpl_control_transmit_dis(cur->rpl_domain, cur, 0, 0, NULL, 0, ADDR_LINK_LOCAL_ALL_RPL_NODES);
1473+
}
1474+
// set timer for next DIS
1475+
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(WS_RPL_DIS_TIMEOUT/2, WS_RPL_DIS_TIMEOUT);
14651476
}
14661477
return;
14671478
}
14681479

1469-
static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur)
1480+
/*
1481+
1482+
static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur)
14701483
{
14711484
if(cur->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
14721485
return true;
@@ -1491,7 +1504,7 @@ static bool ws_bootstrap_state_wait_rpl(struct protocol_interface_info_entry *cu
14911504
}
14921505
return false;
14931506
}
1494-
1507+
*/
14951508
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur)
14961509
{
14971510
if(cur->nwk_bootstrap_state == ER_ACTIVE_SCAN) {

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,14 @@ typedef struct ws_bs_ie {
185185
#define WS_NEIGHBOR_LINK_TIMEOUT 240
186186
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2
187187

188+
/*
189+
* value when send the first RPL DIS in 100ms ticks. Value is randomized between timeout/2 - timeout
190+
*/
191+
#define WS_RPL_DIS_INITIAL_TIMEOUT 600
192+
/*
193+
* value when send subsequent RPL DIS in 100 ms tics. Value is randomized between timeout/2 - timeout
194+
*/
195+
#define WS_RPL_DIS_TIMEOUT 1800
196+
188197

189198
#endif /* WS_COMMON_DEFINES_H_ */

0 commit comments

Comments
 (0)