Skip to content

Commit 61ff793

Browse files
author
Juha Heiskanen
authored
Merge pull request ARMmbed#1807 from ARMmbed/rpl_parent_candidate
RPL, FHSS and Wisun Update
2 parents 89b8eeb + a7a1ab3 commit 61ff793

File tree

15 files changed

+95
-30
lines changed

15 files changed

+95
-30
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static void ws_bbr_rpl_root_activate(uint8_t *dodag_prefix, uint8_t *dodag_id)
5555
.lifetime_unit = 60,
5656
.objective_code_point = 1, // MRHOF algorithm used
5757
.authentication = 0,
58-
.path_control_size = 0,
58+
.path_control_size = 1,
5959
.dag_max_rank_increase = 2048,
6060
.min_hop_rank_increase = 128,
6161
// DIO configuration

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,9 @@ uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr
368368
}
369369
attribute_index = mac_neighbor->index;
370370
ws_neighbor_class_entry_t *ws_neighbour = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, attribute_index);
371+
etx_storage_t *etx_entry = etx_storage_entry_get(interface->id, attribute_index);
371372

372-
if (!ws_neighbour ||
373+
if (!ws_neighbour || !etx_entry || etx_entry->etx_samples < 1 ||
373374
!ws_neighbour->candidate_parent) {
374375
// if RSL value is not good enough candidate parent flag is removed and device not accepted as parent
375376
//tr_debug("ws_etx_read not valid parent");
@@ -405,6 +406,8 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
405406
tr_error("fhss initialization failed");
406407
return -3;
407408
}
409+
410+
408411
// Save FHSS api
409412
cur->ws_info->fhss_api = ns_sw_mac_get_fhss_api(cur->mac_api);
410413

@@ -420,6 +423,8 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
420423
cur->ipv6_neighbour_cache.use_eui64_as_slla_in_aro = true;
421424
/* Omit sending of NA if ARO SUCCESS */
422425
cur->ipv6_neighbour_cache.omit_aro_success = true;
426+
/* Disable NUD Probes */
427+
cur->ipv6_neighbour_cache.send_nud_probes = false;
423428

424429
ws_bootstrap_event_discovery_start(cur);
425430

@@ -722,7 +727,6 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
722727
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us);
723728
ws_neighbor_class_neighbor_broadcast_time_info_update(neighbor_info.ws_neighbor, &ws_bt_ie, data->timestamp);
724729
ws_neighbor_class_neighbor_broadcast_schedule_set(neighbor_info.ws_neighbor, &ws_bs_ie);
725-
neighbor_info.neighbor->trusted_device = true;
726730

727731
if (cur->ws_info->configuration_learned) {
728732
// received version is lower se we need to reset the trickle
@@ -980,24 +984,55 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt
980984
ws_bootstrap_neighbor_delete(cur,entry_ptr->index);
981985
}
982986

983-
984987
static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
985988
{
986989
uint32_t time_from_start = entry_ptr->link_lifetime - entry_ptr->lifetime;
987990
bool activate_nud = false;
988-
if ((entry_ptr->link_role == PRIORITY_PARENT_NEIGHBOUR || entry_ptr->link_role == SECONDARY_PARENT_NEIGHBOUR) && time_from_start > WS_NEIGHBOR_NUD_TIMEOUT) {
989-
if (entry_ptr->trusted_device) {
991+
protocol_interface_info_entry_t *cur = user_data;
992+
993+
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, entry_ptr->index);
994+
etx_storage_t *etx_entry = etx_storage_entry_get(cur->id, entry_ptr->index);
995+
996+
if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry) {
997+
return false;
998+
}
999+
1000+
if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT) {
1001+
1002+
if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT * 1.5) {
9901003
activate_nud = true;
1004+
} else {
1005+
uint16_t switch_prob = randLIB_get_random_in_range(0, WS_NUD_RANDOM_SAMPLE_LENGTH -1);
1006+
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
1007+
if (switch_prob < WS_NUD_RANDOM_COMPARE) {
1008+
activate_nud = true;
1009+
}
1010+
}
1011+
} else if (etx_entry->etx_samples < WS_NEIGBOR_ETX_SAMPLE_MAX) {
1012+
//Take Random number for trig a prope.
1013+
//ETX Sample 0: random 1-8
1014+
//ETX Sample 1: random 2-16
1015+
//ETX Sample 2: random 4-32
1016+
uint32_t probe_period = WS_PROBE_INIT_BASE_SECONDS << etx_entry->etx_samples;
1017+
uint32_t time_block = 1 << etx_entry->etx_samples;
1018+
if (time_from_start >= probe_period) {
1019+
tr_debug("Link Probe test %u Sample trig", etx_entry->etx_samples);
1020+
activate_nud = true;
1021+
} else if (time_from_start > time_block) {
1022+
uint16_t switch_prob = randLIB_get_random_in_range(0, probe_period -1);
1023+
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
1024+
if (switch_prob < 2) {
1025+
tr_debug("Link Probe test with jitter %u, sample %u", time_from_start, etx_entry->etx_samples);
1026+
activate_nud = true;
1027+
}
9911028
}
992-
9931029
}
1030+
9941031
if (!activate_nud) {
9951032
return false;
9961033
}
9971034

9981035

999-
protocol_interface_info_entry_t *cur = user_data;
1000-
10011036
uint8_t ll_target[16];
10021037
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
10031038
memcpy(ll_target + 8, entry_ptr->mac64, 8);

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,19 @@ typedef struct ws_bs_ie {
184184

185185
#define WS_FAN_VERSION_1_0 1
186186

187-
#define WS_NEIGHBOR_LINK_TIMEOUT 240
187+
#define WS_NEIGHBOR_LINK_TIMEOUT 2200
188188
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2
189189

190+
#define WS_NEIGBOR_ETX_SAMPLE_MAX 3
191+
192+
#define WS_PROBE_INIT_BASE_SECONDS 8
193+
194+
#define WS_NUD_RAND_PROBABILITY 1
195+
196+
#define WS_NUD_RANDOM_SAMPLE_LENGTH WS_NEIGHBOR_NUD_TIMEOUT / 2
197+
198+
#define WS_NUD_RANDOM_COMPARE (WS_NUD_RAND_PROBABILITY*WS_NUD_RANDOM_SAMPLE_LENGTH) / 100
199+
190200
/*
191201
* Threshold (referenced to DEVICE_MIN_SENS) above which a neighbor node may be considered for inclusion into candidate parent set
192202
*/

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#ifdef HAVE_WS
2929

30-
#define RSL_UNITITIALIZED 0x7fff
30+
3131
#define TRACE_GROUP "wsne"
3232

3333

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "fhss_ws_extension.h"
2222
#include "6LoWPAN/ws/ws_common_defines.h"
2323

24+
#define RSL_UNITITIALIZED 0x7fff
25+
2426
typedef struct ws_neighbor_class_entry {
2527
fhss_ws_neighbor_timing_info_t fhss_data;
2628
uint16_t rsl_in; /*!< RSL EWMA heard from neighbour*/

source/MAC/IEEE802_15_4/mac_fhss_callbacks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int mac_set_channel(const fhss_api_t *fhss_api, uint8_t channel_number)
8282
if (!mac_setup) {
8383
return -1;
8484
}
85-
if (mac_setup->mac_ack_tx_active || (mac_setup->active_pd_data_request && mac_setup->active_pd_data_request->asynch_request)) {
85+
if (mac_setup->mac_ack_tx_active || (mac_setup->active_pd_data_request && (mac_setup->active_pd_data_request->asynch_request || mac_setup->timer_mac_event == MAC_TIMER_ACK))) {
8686
return -1;
8787
}
8888
return mac_mlme_rf_channel_change(mac_setup, channel_number);

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,14 @@ static void mac_data_interface_frame_handler(mac_pre_parsed_frame_t *buf)
10531053

10541054
}
10551055

1056+
static void mac_mcps_asynch_finish(protocol_interface_rf_mac_setup_s *rf_mac_setup, mac_pre_build_frame_t *buffer)
1057+
{
1058+
if (buffer->asynch_request && rf_mac_setup->fhss_api) {
1059+
// Must return to scheduled channel after asynch process by calling TX done
1060+
rf_mac_setup->fhss_api->data_tx_done(rf_mac_setup->fhss_api, false, true, buffer->msduHandle);
1061+
}
1062+
}
1063+
10561064
void mac_mcps_trig_buffer_from_queue(protocol_interface_rf_mac_setup_s *rf_mac_setup)
10571065
{
10581066
if (!rf_mac_setup) {
@@ -1075,6 +1083,7 @@ void mac_mcps_trig_buffer_from_queue(protocol_interface_rf_mac_setup_s *rf_mac_s
10751083
mac_data_request_init(rf_mac_setup, buffer);
10761084
if (mcps_pd_data_request(rf_mac_setup, buffer) != 0) {
10771085
rf_mac_setup->active_pd_data_request = NULL;
1086+
mac_mcps_asynch_finish(rf_mac_setup, buffer);
10781087
mcps_data_confirm_handle(rf_mac_setup, buffer, NULL);
10791088
} else {
10801089
return;
@@ -1120,14 +1129,12 @@ static void mac_pd_data_confirm_handle(protocol_interface_rf_mac_setup_s *rf_mac
11201129
mac_pre_build_frame_t *buffer = rf_mac_setup->active_pd_data_request;
11211130
if (mac_data_request_confirmation_finnish(rf_mac_setup, buffer) ) {
11221131
rf_mac_setup->active_pd_data_request = NULL;
1123-
if (buffer->asynch_request && rf_mac_setup->fhss_api) {
1124-
// Must return to scheduled channel after asynch process by calling TX done
1125-
rf_mac_setup->fhss_api->data_tx_done(rf_mac_setup->fhss_api, false, true, buffer->msduHandle);
1126-
}
1132+
mac_mcps_asynch_finish(rf_mac_setup, buffer);
11271133
mcps_data_confirm_handle(rf_mac_setup, buffer, NULL);
11281134
} else {
11291135
if (mcps_pd_data_request(rf_mac_setup, buffer) != 0) {
11301136
rf_mac_setup->active_pd_data_request = NULL;
1137+
mac_mcps_asynch_finish(rf_mac_setup, buffer);
11311138
mcps_data_confirm_handle(rf_mac_setup, buffer, NULL);
11321139
} else {
11331140
return;
@@ -1155,10 +1162,6 @@ static void mac_pd_data_ack_handler(mac_pre_parsed_frame_t *buf) {
11551162
}
11561163

11571164
rf_mac_setup->active_pd_data_request = NULL;
1158-
if (buffer->asynch_request && rf_mac_setup->fhss_api) {
1159-
// Must return to scheduled channel after asynch process by calling TX done
1160-
rf_mac_setup->fhss_api->data_tx_done(rf_mac_setup->fhss_api, false, true, buffer->msduHandle);
1161-
}
11621165
mcps_data_confirm_handle(rf_mac_setup, buffer, buf);
11631166
mcps_sap_pre_parsed_frame_buffer_free(buf);
11641167

@@ -1423,7 +1426,7 @@ static void mcps_data_confirm_handle(protocol_interface_rf_mac_setup_s *rf_ptr,
14231426
sw_mac_stats_update(rf_ptr, STAT_MAC_TX_CCA_ATT, rf_ptr->mac_tx_status.cca_cnt);
14241427
sw_mac_stats_update(rf_ptr, STAT_MAC_TX_RETRY, rf_ptr->mac_tx_status.retry);
14251428
mcps_data_conf_t confirm;
1426-
if (rf_ptr->fhss_api) {
1429+
if (rf_ptr->fhss_api && !buffer->asynch_request) {
14271430
// FHSS checks if this failed buffer needs to be pushed back to TX queue and retransmitted
14281431
if ((rf_ptr->mac_tx_result == MAC_TX_FAIL) || (rf_ptr->mac_tx_result == MAC_CCA_FAIL)) {
14291432
if (rf_ptr->fhss_api->data_tx_fail(rf_ptr->fhss_api, buffer->msduHandle, mac_convert_frame_type_to_fhss(buffer->fcf_dsn.frametype)) == true) {
@@ -1989,7 +1992,7 @@ static mac_pre_build_frame_t * mcps_sap_pd_req_queue_read(protocol_interface_rf_
19891992
// With FHSS, check TX conditions
19901993
if (rf_mac_setup->fhss_api) {
19911994
while (buffer) {
1992-
if ((flush == true) || (rf_mac_setup->fhss_api->check_tx_conditions(rf_mac_setup->fhss_api, !mac_is_ack_request_set(buffer),
1995+
if (buffer->asynch_request || (flush == true) || (rf_mac_setup->fhss_api->check_tx_conditions(rf_mac_setup->fhss_api, !mac_is_ack_request_set(buffer),
19931996
buffer->msduHandle, mac_convert_frame_type_to_fhss(buffer->fcf_dsn.frametype), buffer->mac_payload_length,
19941997
rf_mac_setup->dev_driver->phy_driver->phy_header_length, rf_mac_setup->dev_driver->phy_driver->phy_tail_length) == true)) {
19951998
break;

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
387387

388388
if (rf_ptr->mac_ack_tx_active) {
389389
rf_ptr->mac_ack_tx_active = false;
390+
if (rf_ptr->fhss_api) {
391+
//SET tx completed false because ack isnot never queued
392+
rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, false, false, 0xff);
393+
}
390394
if (rf_ptr->active_pd_data_request) {
391395

392396
if (rf_ptr->active_pd_data_request->fcf_dsn.securityEnabled) {
@@ -464,7 +468,7 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
464468
static int8_t mac_data_interface_tx_done_by_ack_cb(protocol_interface_rf_mac_setup_s *rf_ptr, mac_pre_parsed_frame_t *buf)
465469
{
466470

467-
if (!rf_ptr->macRfRadioTxActive) {
471+
if (!rf_ptr->macRfRadioTxActive || !rf_ptr->active_pd_data_request || rf_ptr->active_pd_data_request->fcf_dsn.DSN != buf->fcf_dsn.DSN) {
468472
return -1;
469473
}
470474

@@ -479,9 +483,7 @@ static int8_t mac_data_interface_tx_done_by_ack_cb(protocol_interface_rf_mac_set
479483
mcps_sap_pd_ack(buf);
480484

481485
if (rf_ptr->fhss_api) {
482-
if (rf_ptr->active_pd_data_request->asynch_request == false) {
483-
rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, false, true, rf_ptr->active_pd_data_request->msduHandle);
484-
}
486+
rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, false, true, rf_ptr->active_pd_data_request->msduHandle);
485487
}
486488
return 0;
487489
}

source/RPL/rpl_structures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ typedef struct rpl_dao_non_root
134134
uint32_t refresh_timer; /* Refresh timer (seconds) - 0xFFFFFFFF = infinite, 0 = not yet set */
135135
} rpl_dao_non_root_t;
136136

137+
137138
/* Descriptor for a RPL DAO target */
138139
struct rpl_dao_target
139140
{

source/RPL/rpl_upward.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,7 @@ void rpl_instance_slow_timer(rpl_instance_t *instance, uint16_t seconds)
15551555
}
15561556
}
15571557

1558+
15581559
void rpl_upward_dio_timer(rpl_instance_t *instance, uint16_t ticks)
15591560
{
15601561
rpl_dodag_version_t *dodag_version = instance->current_dodag_version;

source/Service_Libs/etx/etx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ void etx_transm_attempts_update(int8_t interface_id, uint8_t attempts, bool succ
8181
if (!entry) {
8282
return;
8383
}
84+
if (entry->etx_samples < 7) {
85+
entry->etx_samples++;
86+
}
8487

8588
accumulated_failures = entry->accumulated_failures;
8689

source/Service_Libs/etx/etx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ typedef struct etx_storage_s {
3838
unsigned accumulated_failures: 5;
3939
unsigned tmp_etx: 1;
4040
unsigned linkIdr: 4;
41+
unsigned etx_samples: 3;
4142
} etx_storage_t;
4243

4344
/**

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,14 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
652652
return -1;
653653
}
654654
platform_enter_critical();
655+
fhss_structure->platform_functions.fhss_timer_stop(fhss_broadcast_handler, fhss_structure->fhss_api);
655656
uint32_t time_from_reception_ms = (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - bc_timing_info->bt_rx_timestamp)/1000;
656657
uint32_t true_bc_interval_offset = (bc_timing_info->broadcast_interval_offset + time_from_reception_ms) % bc_timing_info->broadcast_interval;
657658
uint32_t timeout = ((bc_timing_info->broadcast_interval-true_bc_interval_offset)*1000);
658-
fhss_structure->ws->is_on_bc_channel = false;
659+
660+
if (fhss_structure->ws->is_on_bc_channel) {
661+
timeout -= ((bc_timing_info->broadcast_interval - bc_timing_info->broadcast_dwell_interval) *1000);
662+
}
659663
fhss_start_timer(fhss_structure, timeout, fhss_broadcast_handler);
660664
uint16_t slots_since_reception = (bc_timing_info->broadcast_interval_offset + time_from_reception_ms) / bc_timing_info->broadcast_interval;
661665
// TODO: Calculate drift error

source/Service_Libs/mac_neighbor_table/mac_neighbor_table.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ void mac_neighbor_table_neighbor_connected(mac_neighbor_table_t *table_class, ma
192192
void mac_neighbor_table_trusted_neighbor(mac_neighbor_table_t *table_class, mac_neighbor_table_entry_t *neighbor_entry, bool trusted_device)
193193
{
194194
(void)table_class;
195+
if (!neighbor_entry->trusted_device && trusted_device) {
196+
neighbor_entry->lifetime = neighbor_entry->link_lifetime;
197+
}
195198
neighbor_entry->trusted_device = trusted_device;
196199
}
197200

test/nanostack/unittest/service_libs/mac_neighbor_table/test_mac_neighbor_table.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,19 @@ bool test_mac_neighbor_table_use()
133133

134134
mac_neighbor_table_trusted_neighbor(entry, mac_entry3, true);
135135

136-
if (!mac_entry3->trusted_device) {
136+
if (!mac_entry3->trusted_device && mac_entry3->lifetime != 240) {
137137
return false;
138138
}
139139

140140
mac_neighbor_table_neighbor_timeout_update(entry, 31);
141141

142-
if (mac_entry3->lifetime != 199 || mac_entry2->lifetime != 199 || mac_entry1->lifetime != 199) {
142+
if (mac_entry3->lifetime != 209 || mac_entry2->lifetime != 199 || mac_entry1->lifetime != 199) {
143143
return false;
144144
}
145145

146146
mac_neighbor_table_neighbor_timeout_update(entry, 170);
147147

148-
if (mac_entry3->lifetime != 29 || mac_entry2->lifetime != 29 || mac_entry1->lifetime != 29) {
148+
if (mac_entry3->lifetime != 39 || mac_entry2->lifetime != 29 || mac_entry1->lifetime != 29) {
149149
return false;
150150
}
151151

0 commit comments

Comments
 (0)