Skip to content

Commit dae82f6

Browse files
author
Mika Tervonen
committed
implemented wisun routing cost calculation
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
1 parent f919fd1 commit dae82f6

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void ws_bbr_rpl_root_start(uint8_t *dodag_id)
6767
.authentication = 0,
6868
.path_control_size = 5,
6969
.dag_max_rank_increase = 2048,
70-
.min_hop_rank_increase = 128,
70+
.min_hop_rank_increase = 256,
7171
// DIO configuration
7272
.dio_interval_min = WS_RPL_DIO_IMIN,
7373
.dio_interval_doublings = WS_RPL_DIO_DOUBLING,

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *c
8383
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);
8484

8585
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);
86-
static uint16_t ws_bootstrap_route_cost_calculate(protocol_interface_info_entry_t *cur);
87-
static uint16_t ws_bootstrap_get_min_rank_inc(protocol_interface_info_entry_t *cur);
86+
static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entry_t *cur);
87+
static uint16_t ws_bootstrap_rank_get(protocol_interface_info_entry_t *cur);
88+
static uint16_t ws_bootstrap_min_rank_inc_get(protocol_interface_info_entry_t *cur);
8889

8990
mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
9091
{
@@ -783,6 +784,12 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
783784
*
784785
*/
785786

787+
// Save route cost for all neighbours
788+
llc_neighbour_req_t neighbor_info;
789+
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false) ) {
790+
neighbor_info.ws_neighbor->routing_cost = pan_information.routing_cost;
791+
}
792+
786793
// Save the best network parent
787794

788795
if(ws_bootstrap_state_discovery(cur)) {
@@ -1499,8 +1506,8 @@ static void ws_bootstrap_ip_stack_activate(protocol_interface_info_entry_t *cur)
14991506

15001507
static void ws_set_fhss_hop(protocol_interface_info_entry_t *cur)
15011508
{
1502-
uint16_t own_rank = ws_bootstrap_route_cost_calculate(cur);
1503-
uint16_t rank_inc = ws_bootstrap_get_min_rank_inc(cur);
1509+
uint16_t own_rank = ws_bootstrap_rank_get(cur);
1510+
uint16_t rank_inc = ws_bootstrap_min_rank_inc_get(cur);
15041511
if (own_rank == 0xffff || rank_inc == 0xffff) {
15051512
return;
15061513
}
@@ -1802,16 +1809,41 @@ static struct rpl_instance *ws_get_rpl_instance(protocol_interface_info_entry_t
18021809
return best_instance;
18031810
}
18041811

1805-
static uint16_t ws_bootstrap_route_cost_calculate(protocol_interface_info_entry_t *cur)
1812+
static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entry_t *cur)
18061813
{
1807-
struct rpl_instance *rpl_instance = ws_get_rpl_instance(cur);
1808-
if (!rpl_instance) {
1814+
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_entry_get_priority(mac_neighbor_info(cur));
1815+
if (!mac_neighbor) {
18091816
return 0xffff;
18101817
}
1811-
return rpl_control_current_rank(rpl_instance);
1818+
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, mac_neighbor->index);
1819+
if (!ws_neighbor) {
1820+
return 0xffff;
1821+
}
1822+
1823+
uint16_t etx = etx_local_etx_read(cur->id,mac_neighbor->index);
1824+
if (etx == 0) {
1825+
etx = 0xffff;
1826+
}
1827+
if (etx > 0x800) {
1828+
// 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.
1829+
etx = 0x800;
1830+
}
1831+
etx = etx >> 1;
1832+
1833+
return ws_neighbor->routing_cost + etx;
18121834
}
18131835

1814-
static uint16_t ws_bootstrap_get_min_rank_inc(protocol_interface_info_entry_t *cur)
1836+
static uint16_t ws_bootstrap_rank_get(protocol_interface_info_entry_t *cur)
1837+
{
1838+
struct rpl_instance *rpl_instance = ws_get_rpl_instance(cur);
1839+
if (!rpl_instance) {
1840+
return 0xffff;
1841+
}
1842+
return rpl_control_current_rank(rpl_instance);
1843+
}
1844+
1845+
1846+
static uint16_t ws_bootstrap_min_rank_inc_get(protocol_interface_info_entry_t *cur)
18151847
{
18161848
struct rpl_instance *rpl_instance = ws_get_rpl_instance(cur);
18171849
if (!rpl_instance) {
@@ -1847,7 +1879,7 @@ static void ws_bootstrap_pan_advert(protocol_interface_info_entry_t *cur)
18471879
} else {
18481880
// Nodes need to calculate routing cost
18491881
// PAN size is saved from latest PAN advertisement
1850-
cur->ws_info->pan_information.routing_cost = ws_bootstrap_route_cost_calculate(cur);
1882+
cur->ws_info->pan_information.routing_cost = ws_bootstrap_routing_cost_calculate(cur);
18511883
}
18521884

18531885

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef struct ws_neighbor_class_entry {
2727
fhss_ws_neighbor_timing_info_t fhss_data;
2828
uint16_t rsl_in; /*!< RSL EWMA heard from neighbour*/
2929
uint16_t rsl_out; /*!< RSL EWMA heard by neighbour*/
30+
uint16_t routing_cost; /*!< ETX to border Router. */
3031
bool candidate_parent:1;
3132
bool broadcast_timing_info_stored:1;
3233
bool broadcast_shedule_info_stored:1;

source/Service_Libs/mac_neighbor_table/mac_neighbor_table.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,13 @@ mac_neighbor_table_entry_t *mac_neighbor_entry_get_by_mac64(mac_neighbor_table_t
274274
return mac_neighbor_table_entry_allocate(table_class, mac64);
275275
}
276276

277+
mac_neighbor_table_entry_t* mac_neighbor_entry_get_priority(mac_neighbor_table_t *table_class)
278+
{
277279

280+
ns_list_foreach(mac_neighbor_table_entry_t, entry, &table_class->neighbour_list) {
281+
if (entry->link_role == PRIORITY_PARENT_NEIGHBOUR) {
282+
return entry;
283+
}
284+
}
285+
return NULL;
286+
}

source/Service_Libs/mac_neighbor_table/mac_neighbor_table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,6 @@ mac_neighbor_table_entry_t *mac_neighbor_entry_get_by_ll64(mac_neighbor_table_t
202202

203203
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);
204204

205+
mac_neighbor_table_entry_t* mac_neighbor_entry_get_priority(mac_neighbor_table_t *table_class);
206+
205207
#endif /* MAC_NEIGHBOR_TABLE_H_ */

0 commit comments

Comments
 (0)