Skip to content

Commit b99d497

Browse files
author
Juha Heiskanen
committed
Modify NUD operation propability.
Change-Id: I78d478709b6a85cfcf25fe60cd390bbbbd98117c
1 parent 4bb8b54 commit b99d497

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -990,16 +990,33 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
990990
}
991991

992992
if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT) {
993-
//Take Random from 1-1.5 time WS_NEIGHBOR_NUD_TIMEOUT
994-
uint32_t compare_random = randLIB_randomise_base(WS_NEIGHBOR_NUD_TIMEOUT, 0x8000, 0xC000);
995-
if (time_from_start > compare_random) {
993+
994+
if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT * 1.5) {
996995
activate_nud = true;
996+
} else {
997+
uint16_t switch_prob = randLIB_get_random_in_range(0, WS_NUD_RANDOM_SAMPLE_LENGTH -1);
998+
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
999+
if (switch_prob < WS_NUD_RANDOM_COMPARE) {
1000+
activate_nud = true;
1001+
}
9971002
}
998-
} else if (etx_entry->etx_samples < 3) {
999-
uint32_t compare_random = randLIB_get_random_in_range(1 << etx_entry->etx_samples, 8 << etx_entry->etx_samples);
1000-
if (time_from_start > compare_random) {
1001-
tr_debug("Link Probe test %u with jitter", compare_random);
1003+
} else if (etx_entry->etx_samples < WS_NEIGBOR_ETX_SAMPLE_MAX) {
1004+
//Take Random number for trig a prope.
1005+
//ETX Sample 0: random 1-8
1006+
//ETX Sample 1: random 2-16
1007+
//ETX Sample 2: random 4-32
1008+
uint32_t probe_period = WS_PROBE_INIT_BASE_SECONDS << etx_entry->etx_samples;
1009+
uint32_t time_block = 1 << etx_entry->etx_samples;
1010+
if (time_from_start >= probe_period) {
1011+
tr_debug("Link Probe test %u Sample trig", etx_entry->etx_samples);
10021012
activate_nud = true;
1013+
} else if (time_from_start > time_block) {
1014+
uint16_t switch_prob = randLIB_get_random_in_range(0, probe_period -1);
1015+
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
1016+
if (switch_prob < 2) {
1017+
tr_debug("Link Probe test with jitter %u, sample %u", time_from_start, etx_entry->etx_samples);
1018+
activate_nud = true;
1019+
}
10031020
}
10041021
}
10051022

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ typedef struct ws_bs_ie {
185185
#define WS_NEIGHBOR_LINK_TIMEOUT 2200
186186
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2
187187

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

0 commit comments

Comments
 (0)