Skip to content

Commit

Permalink
refactor RPL dis sending
Browse files Browse the repository at this point in the history
if there is no RPL DIO connection made DIS message is sent
  • Loading branch information
Mika Tervonen committed Aug 6, 2018
1 parent 6e1cc58 commit 745c1dd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
35 changes: 24 additions & 11 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ static const trickle_params_t trickle_params_pan_discovery = {

static void ws_bootstrap_event_handler(arm_event_s *event);
static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp_state_t nwk_bootstrap_state);
static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur);
//static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur);
//static bool ws_bootstrap_state_wait_rpl(struct protocol_interface_info_entry *cur);
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
static bool ws_bootstrap_state_wait_rpl(struct protocol_interface_info_entry *cur);
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);

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);
Expand Down Expand Up @@ -1058,10 +1058,6 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, leaf);

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

static void ws_bootstrap_network_start(protocol_interface_info_entry_t *cur)
Expand Down Expand Up @@ -1146,6 +1142,14 @@ static void ws_bootstrap_start_configuration_learn(protocol_interface_info_entry
trickle_start(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
}
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);
// 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);
}

/*
* Event transitions
Expand Down Expand Up @@ -1394,8 +1398,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
ws_bootstrap_event_routing_ready(cur);
} else {
// routers wait until RPL root is contacted
ws_bootstrap_state_change(cur, ER_RPL_SCAN);
ws_bootstrap_rpl_scan_start(cur);
}
break;
case WS_ROUTING_READY:
Expand Down Expand Up @@ -1460,13 +1463,23 @@ void ws_bootstrap_rpl_wait_process(protocol_interface_info_entry_t *cur)
{

if (cur->ws_info->rpl_state == RPL_EVENT_DAO_DONE) {
// Trigger statemachine check
// RPL routing is ready
ws_bootstrap_event_routing_ready(cur);
} else if (!rpl_control_have_dodag(cur->rpl_domain)){
// RPL not ready send DIS message if possible
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER) {
// TODO Multicast DIS should be sent only if no DIO heard for some time
rpl_control_transmit_dis(cur->rpl_domain, cur, 0, 0, NULL, 0, ADDR_LINK_LOCAL_ALL_RPL_NODES);
}
// set timer for next DIS
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(WS_RPL_DIS_TIMEOUT/2, WS_RPL_DIS_TIMEOUT);
}
return;
}

static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur)
/*
static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur)
{
if(cur->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
return true;
Expand All @@ -1491,7 +1504,7 @@ static bool ws_bootstrap_state_wait_rpl(struct protocol_interface_info_entry *cu
}
return false;
}

*/
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur)
{
if(cur->nwk_bootstrap_state == ER_ACTIVE_SCAN) {
Expand Down
9 changes: 9 additions & 0 deletions source/6LoWPAN/ws/ws_common_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,14 @@ typedef struct ws_bs_ie {
#define WS_NEIGHBOR_LINK_TIMEOUT 240
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2

/*
* value when send the first RPL DIS in 100ms ticks. Value is randomized between timeout/2 - timeout
*/
#define WS_RPL_DIS_INITIAL_TIMEOUT 600
/*
* value when send subsequent RPL DIS in 100 ms tics. Value is randomized between timeout/2 - timeout
*/
#define WS_RPL_DIS_TIMEOUT 1800


#endif /* WS_COMMON_DEFINES_H_ */

0 comments on commit 745c1dd

Please sign in to comment.