Skip to content

Commit 21af923

Browse files
author
Juha Heiskanen
committed
Wi-sun ETX update
ETX is returning 0 untill all configured values are readed ETX min sample count for calculate ETX is updated. Only full TX feilure may accelerate ETX calculation. Added possibility drop bad etx init sample's 1-2 by given limit > 2. Removed dBM link update from wi-sun side.
1 parent 80e13f4 commit 21af923

File tree

5 files changed

+113
-20
lines changed

5 files changed

+113
-20
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,6 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
15631563
}
15641564

15651565
if (neighbour_pointer_valid) {
1566-
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index, neighbor_info.neighbor->mac64);
15671566
//Update Neighbor Broadcast and Unicast Parameters
15681567
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp, (uint8_t *) data->SrcAddr);
15691568
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us, &cur->ws_info->hopping_schdule);
@@ -1652,7 +1651,6 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
16521651

16531652
llc_neighbour_req_t neighbor_info;
16541653
if (ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, false)) {
1655-
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index, neighbor_info.neighbor->mac64);
16561654
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp, (uint8_t *) data->SrcAddr);
16571655
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us, &cur->ws_info->hopping_schdule);
16581656
}
@@ -1961,6 +1959,15 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt
19611959
ws_bootstrap_neighbor_delete(cur, entry_ptr);
19621960
}
19631961

1962+
static uint32_t ws_probe_init_time_get(protocol_interface_info_entry_t *cur)
1963+
{
1964+
if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_SMALL) {
1965+
return WS_SMALL_PROBE_INIT_BASE_SECONDS;
1966+
}
1967+
1968+
return WS_NORMAL_PROBE_INIT_BASE_SECONDS;
1969+
}
1970+
19641971
static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
19651972
{
19661973
uint32_t time_from_start = entry_ptr->link_lifetime - entry_ptr->lifetime;
@@ -2013,17 +2020,23 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
20132020
nud_proces = activate_nud;
20142021
} else if (etx_entry->etx_samples < WS_NEIGHBOR_ETX_SAMPLE_MAX) {
20152022
//Take Random number for trig a prope.
2023+
//Small network
2024+
//ETX Sample 0: random 1-4
2025+
//ETX Sample 1: random 2-8
2026+
//ETX Sample 2: random 4-16
2027+
//Medium and large
20162028
//ETX Sample 0: random 1-8
20172029
//ETX Sample 1: random 2-16
20182030
//ETX Sample 2: random 4-32
2031+
20192032
ws_bootsrap_create_ll_address(ll_address, entry_ptr->mac64);
20202033
if (!rpl_control_probe_parent_candidate(cur, ll_address)) {
20212034
return false;
20222035
}
20232036

2024-
2025-
uint32_t probe_period = WS_PROBE_INIT_BASE_SECONDS << etx_entry->etx_samples;
2037+
uint32_t probe_period = ws_probe_init_time_get(cur) << etx_entry->etx_samples;
20262038
uint32_t time_block = 1 << etx_entry->etx_samples;
2039+
20272040
if (time_from_start >= probe_period) {
20282041
//tr_debug("Link Probe test %u Sample trig", etx_entry->etx_samples);
20292042
activate_nud = true;
@@ -2086,6 +2099,11 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
20862099
return -1;
20872100
}
20882101

2102+
if (!etx_allow_drop_for_poor_measurements(WS_ETX_BAD_INIT_LINK_LEVEL, WS_ETX_MAX_BAD_LINK_DROP)) {
2103+
etx_storage_list_allocate(cur->id, 0);
2104+
return -1;
2105+
}
2106+
20892107
etx_max_update_set(WS_ETX_MAX_UPDATE);
20902108
etx_max_set(WS_ETX_MAX);
20912109

@@ -2655,8 +2673,6 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
26552673
ws_bootstrap_neighbor_set_stable(cur, entry->mac64);
26562674
//Copy fhss temporary data
26572675
*ws_neigh = entry->neigh_info_list;
2658-
//ETX Create here
2659-
etx_lqi_dbm_update(cur->id, entry->mpduLinkQuality, entry->signal_dbm, neigh_buffer.neighbor->index, neigh_buffer.neighbor->mac64);
26602676
mac_neighbor_table_trusted_neighbor(mac_neighbor_info(cur), neigh_buffer.neighbor, true);
26612677
}
26622678
ws_llc_free_multicast_temp_entry(cur, entry);

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ typedef struct ws_bs_ie {
255255
#define WS_NEIGHBOR_ETX_SAMPLE_MAX 3
256256
#define WS_NEIGHBOR_FIRST_ETX_SAMPLE_MIN_COUNT 3 //This can't be bigger than WS_NEIGHBOR_ETX_SAMPLE_MAX
257257

258-
#define WS_PROBE_INIT_BASE_SECONDS 8
258+
#define WS_SMALL_PROBE_INIT_BASE_SECONDS 4
259+
#define WS_NORMAL_PROBE_INIT_BASE_SECONDS 8
259260

260261
#define WS_NUD_RAND_PROBABILITY 1
261262

@@ -270,6 +271,10 @@ typedef struct ws_bs_ie {
270271

271272
#define WS_ETX_MIN_WAIT_TIME 60
272273

274+
#define WS_ETX_BAD_INIT_LINK_LEVEL 3 //3 or higher attempt count will be dropped
275+
#define WS_ETX_MAX_BAD_LINK_DROP 2 //Drop 2 bad link from init 3
276+
277+
273278
#define WS_RPL_PARENT_CANDIDATE_MAX 5
274279
#define WS_RPL_SELECTED_PARENT_MAX 2
275280

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,6 @@ static void ws_llc_data_indication_cb(const mac_api_t *api, const mcps_data_ind_
729729
ws_neighbor_class_rsl_in_calculate(neighbor_info.ws_neighbor, data->signal_dbm);
730730

731731
if (neighbor_info.neighbor) {
732-
//Refresh ETX dbm
733-
etx_lqi_dbm_update(interface->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index, neighbor_info.neighbor->mac64);
734732
if (data->Key.SecurityLevel) {
735733
//SET trusted state
736734
mac_neighbor_table_trusted_neighbor(mac_neighbor_info(interface), neighbor_info.neighbor, true);

source/Service_Libs/etx/etx.c

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ typedef struct {
7474
uint8_t etx_min_sampling_time;
7575
uint8_t ext_storage_list_size;
7676
uint8_t min_attempts_count;
77+
uint8_t drop_bad_max;
78+
uint8_t bad_link_level;
7779
bool cache_sample_requested;
7880
int8_t interface_id;
7981
} ext_info_t;
@@ -87,6 +89,8 @@ static ext_info_t etx_info = {
8789
.etx_cache_storage_list = NULL,
8890
.ext_storage_list_size = 0,
8991
.min_attempts_count = 0,
92+
.drop_bad_max = 0,
93+
.bad_link_level = 0,
9094
.max_etx_update = 0,
9195
.max_etx = 0xffff,
9296
.init_etx_sample_count = 1,
@@ -133,6 +137,8 @@ static void etx_calculation(etx_storage_t *entry, uint16_t attempts, uint8_t ack
133137
entry->tmp_etx = false;
134138

135139
entry->etx = etx;
140+
//Clear Drop count
141+
entry->drop_bad_count = 0;
136142

137143
if (entry->etx_samples >= etx_info.init_etx_sample_count) {
138144
etx_cache_entry_init(etx_neigh_info->attribute_index);
@@ -149,6 +155,7 @@ static void etx_cache_entry_init(uint8_t attribute_index)
149155

150156
etx_sample_storage_t *storage = etx_info.etx_cache_storage_list + attribute_index;
151157
storage->attempts_count = 0;
158+
storage->transition_count = 0;
152159
storage->etx_timer = etx_info.etx_min_sampling_time;
153160
storage->received_acks = 0;
154161
}
@@ -162,21 +169,22 @@ static bool etx_update_possible(etx_sample_storage_t *storage, etx_storage_t *en
162169
storage->etx_timer -= time_update;
163170
}
164171
}
172+
if (entry->etx_samples == etx_info.init_etx_sample_count && time_update == 0) {
173+
return true;
174+
}
165175

166176
if (entry->etx_samples > etx_info.init_etx_sample_count) {
167177
//Slower ETX update phase
168-
if (storage->attempts_count >= etx_info.min_attempts_count) {
169-
170-
if (storage->etx_timer == 0 || storage->attempts_count == 0xffff || storage->received_acks == 0xff) {
178+
if (storage->etx_timer == 0 || storage->attempts_count == 0xffff || storage->received_acks == 0xff) {
179+
//When time is going zero or too much sample data
180+
if (storage->transition_count >= etx_info.min_attempts_count) {
171181
//Got least min sample in requested time or max possible sample
172182
return true;
183+
} else if (storage->transition_count != storage->received_acks) {
184+
//Missing ack now ETX can be accelerated
185+
return true;
173186
}
174187
}
175-
return false;
176-
}
177-
178-
if (time_update == 0) {
179-
return true;
180188
}
181189

182190
return false;
@@ -188,6 +196,7 @@ static etx_sample_storage_t *etx_cache_sample_update(uint8_t attribute_index, ui
188196
{
189197
etx_sample_storage_t *storage = etx_info.etx_cache_storage_list + attribute_index;
190198
storage->attempts_count += attempts;
199+
storage->transition_count++;
191200
if (ack_rx) {
192201
storage->received_acks++;
193202
}
@@ -196,6 +205,26 @@ static etx_sample_storage_t *etx_cache_sample_update(uint8_t attribute_index, ui
196205
}
197206

198207

208+
static bool etx_drop_bad_sample(etx_storage_t *entry, uint8_t attempts, bool success)
209+
{
210+
if (etx_info.bad_link_level == 0 || !success) {
211+
//Not enabled or Failure
212+
return false;
213+
}
214+
215+
if (attempts < etx_info.bad_link_level) {
216+
//under configured value is accepted
217+
return false;
218+
}
219+
220+
if (entry->drop_bad_count < etx_info.drop_bad_max) {
221+
//Accepted only configured max value 1-2
222+
entry->drop_bad_count++;
223+
return true;
224+
}
225+
226+
return false;
227+
}
199228

200229
/**
201230
* \brief A function to update ETX value based on transmission attempts
@@ -222,6 +251,11 @@ void etx_transm_attempts_update(int8_t interface_id, uint8_t attempts, bool succ
222251
etx_neigh_info.mac64 = mac64_addr_ptr;
223252

224253
if (entry->etx_samples < 7) {
254+
255+
if (etx_drop_bad_sample(entry, attempts, success)) {
256+
tr_debug("Drop bad etx init %u", attempts);
257+
return;
258+
}
225259
entry->etx_samples++;
226260
}
227261

@@ -409,9 +443,8 @@ uint16_t etx_local_etx_read(int8_t interface_id, uint8_t attribute_index)
409443
}
410444

411445
if (etx_info.cache_sample_requested && entry->etx_samples < etx_info.init_etx_sample_count) {
412-
if (!entry->etx_samples) {
413-
return 0;
414-
}
446+
//Not ready yet
447+
return 0;
415448
}
416449

417450
return etx_current_calc(entry->etx, entry->accumulated_failures) >> 4;
@@ -668,6 +701,36 @@ bool etx_cached_etx_parameter_set(uint8_t min_wait_time, uint8_t etx_min_attempt
668701
return true;
669702
}
670703

704+
bool etx_allow_drop_for_poor_measurements(uint8_t bad_link_level, uint8_t max_allowed_drops)
705+
{
706+
//No ini ETX allocation done yet
707+
if (etx_info.ext_storage_list_size == 0) {
708+
return false;
709+
}
710+
711+
if (bad_link_level == 0) {
712+
//Disable feature
713+
etx_info.bad_link_level = 0;
714+
etx_info.drop_bad_max = 0;
715+
return true;
716+
}
717+
718+
if (bad_link_level < 2) {
719+
// 2 attepts is min value
720+
return false;
721+
}
722+
723+
if (max_allowed_drops == 0 || max_allowed_drops > 3) {
724+
//Accepted values is 1-3
725+
return false;
726+
}
727+
728+
729+
etx_info.bad_link_level = bad_link_level;
730+
etx_info.drop_bad_max = max_allowed_drops;
731+
return true;
732+
}
733+
671734
void etx_max_update_set(uint16_t etx_max_update)
672735
{
673736
if (etx_max_update) {

source/Service_Libs/etx/etx.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ typedef struct etx_storage_s {
5858
unsigned tmp_etx: 1;
5959
unsigned linkIdr: 4;
6060
unsigned etx_samples: 3;
61+
unsigned drop_bad_count: 2;
6162
} etx_storage_t;
6263

6364
typedef struct etx_sample_storage_s {
6465
uint16_t attempts_count; /*!< TX attempt count */
6566
uint8_t etx_timer; /*!< Count down from configured value 0 means that ETX Update is possible done again*/
6667
uint8_t received_acks; /*!< Received ACK's */
68+
uint8_t transition_count;
6769
} etx_sample_storage_t;
6870

6971
/**
@@ -279,6 +281,15 @@ bool etx_cached_etx_parameter_set(uint8_t min_wait_time, uint8_t etx_min_attempt
279281
*/
280282
void etx_max_update_set(uint16_t etx_max_update);
281283

284+
/**
285+
* \brief A function for configure limit for detect bad init ETX sample
286+
*
287+
* \param bad_link_level 0 No limit and >=2 Level
288+
* \param max_allowed_drops How many init probe is accepted to drop 1-2 are possible values
289+
*
290+
*/
291+
bool etx_allow_drop_for_poor_measurements(uint8_t bad_link_level, uint8_t max_allowed_drops);
292+
282293
/**
283294
* \brief A function for set Maxium ETX value
284295
*

0 commit comments

Comments
 (0)