Skip to content

Commit

Permalink
implemented wisun routing cost calculation
Browse files Browse the repository at this point in the history
Changed min hop rank increase to 256 according to specification
Save routing cost for all neighbours
implemented the routing cost calculation function
Added priority parent finder for mac neighbour table
  • Loading branch information
Mika Tervonen committed Nov 5, 2018
1 parent f919fd1 commit dae82f6
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void ws_bbr_rpl_root_start(uint8_t *dodag_id)
.authentication = 0,
.path_control_size = 5,
.dag_max_rank_increase = 2048,
.min_hop_rank_increase = 128,
.min_hop_rank_increase = 256,
// DIO configuration
.dio_interval_min = WS_RPL_DIO_IMIN,
.dio_interval_doublings = WS_RPL_DIO_DOUBLING,
Expand Down
52 changes: 42 additions & 10 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *c
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);
static uint16_t ws_bootstrap_route_cost_calculate(protocol_interface_info_entry_t *cur);
static uint16_t ws_bootstrap_get_min_rank_inc(protocol_interface_info_entry_t *cur);
static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entry_t *cur);
static uint16_t ws_bootstrap_rank_get(protocol_interface_info_entry_t *cur);
static uint16_t ws_bootstrap_min_rank_inc_get(protocol_interface_info_entry_t *cur);

mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
Expand Down Expand Up @@ -783,6 +784,12 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
*
*/

// Save route cost for all neighbours
llc_neighbour_req_t neighbor_info;
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false) ) {
neighbor_info.ws_neighbor->routing_cost = pan_information.routing_cost;
}

// Save the best network parent

if(ws_bootstrap_state_discovery(cur)) {
Expand Down Expand Up @@ -1499,8 +1506,8 @@ static void ws_bootstrap_ip_stack_activate(protocol_interface_info_entry_t *cur)

static void ws_set_fhss_hop(protocol_interface_info_entry_t *cur)
{
uint16_t own_rank = ws_bootstrap_route_cost_calculate(cur);
uint16_t rank_inc = ws_bootstrap_get_min_rank_inc(cur);
uint16_t own_rank = ws_bootstrap_rank_get(cur);
uint16_t rank_inc = ws_bootstrap_min_rank_inc_get(cur);
if (own_rank == 0xffff || rank_inc == 0xffff) {
return;
}
Expand Down Expand Up @@ -1802,16 +1809,41 @@ static struct rpl_instance *ws_get_rpl_instance(protocol_interface_info_entry_t
return best_instance;
}

static uint16_t ws_bootstrap_route_cost_calculate(protocol_interface_info_entry_t *cur)
static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entry_t *cur)
{
struct rpl_instance *rpl_instance = ws_get_rpl_instance(cur);
if (!rpl_instance) {
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_entry_get_priority(mac_neighbor_info(cur));
if (!mac_neighbor) {
return 0xffff;
}
return rpl_control_current_rank(rpl_instance);
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, mac_neighbor->index);
if (!ws_neighbor) {
return 0xffff;
}

uint16_t etx = etx_local_etx_read(cur->id,mac_neighbor->index);
if (etx == 0) {
etx = 0xffff;
}
if (etx > 0x800) {
// Wi-SUN section 6.2.3.1.6.1 says ETX can only be maximum of 1024 (8*128) in RPL units, ie 8.0.
etx = 0x800;
}
etx = etx >> 1;

return ws_neighbor->routing_cost + etx;
}

static uint16_t ws_bootstrap_get_min_rank_inc(protocol_interface_info_entry_t *cur)
static uint16_t ws_bootstrap_rank_get(protocol_interface_info_entry_t *cur)
{
struct rpl_instance *rpl_instance = ws_get_rpl_instance(cur);
if (!rpl_instance) {
return 0xffff;
}
return rpl_control_current_rank(rpl_instance);
}


static uint16_t ws_bootstrap_min_rank_inc_get(protocol_interface_info_entry_t *cur)
{
struct rpl_instance *rpl_instance = ws_get_rpl_instance(cur);
if (!rpl_instance) {
Expand Down Expand Up @@ -1847,7 +1879,7 @@ static void ws_bootstrap_pan_advert(protocol_interface_info_entry_t *cur)
} else {
// Nodes need to calculate routing cost
// PAN size is saved from latest PAN advertisement
cur->ws_info->pan_information.routing_cost = ws_bootstrap_route_cost_calculate(cur);
cur->ws_info->pan_information.routing_cost = ws_bootstrap_routing_cost_calculate(cur);
}


Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/ws/ws_neighbor_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef struct ws_neighbor_class_entry {
fhss_ws_neighbor_timing_info_t fhss_data;
uint16_t rsl_in; /*!< RSL EWMA heard from neighbour*/
uint16_t rsl_out; /*!< RSL EWMA heard by neighbour*/
uint16_t routing_cost; /*!< ETX to border Router. */
bool candidate_parent:1;
bool broadcast_timing_info_stored:1;
bool broadcast_shedule_info_stored:1;
Expand Down
9 changes: 9 additions & 0 deletions source/Service_Libs/mac_neighbor_table/mac_neighbor_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,13 @@ mac_neighbor_table_entry_t *mac_neighbor_entry_get_by_mac64(mac_neighbor_table_t
return mac_neighbor_table_entry_allocate(table_class, mac64);
}

mac_neighbor_table_entry_t* mac_neighbor_entry_get_priority(mac_neighbor_table_t *table_class)
{

ns_list_foreach(mac_neighbor_table_entry_t, entry, &table_class->neighbour_list) {
if (entry->link_role == PRIORITY_PARENT_NEIGHBOUR) {
return entry;
}
}
return NULL;
}
2 changes: 2 additions & 0 deletions source/Service_Libs/mac_neighbor_table/mac_neighbor_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,6 @@ mac_neighbor_table_entry_t *mac_neighbor_entry_get_by_ll64(mac_neighbor_table_t

mac_neighbor_table_entry_t *mac_neighbor_entry_get_by_mac64(mac_neighbor_table_t *table_class, const uint8_t *mac64, bool allocateNew, bool *new_entry_allocated);

mac_neighbor_table_entry_t* mac_neighbor_entry_get_priority(mac_neighbor_table_t *table_class);

#endif /* MAC_NEIGHBOR_TABLE_H_ */

0 comments on commit dae82f6

Please sign in to comment.