Skip to content

Commit

Permalink
Modify NUD operation propability.
Browse files Browse the repository at this point in the history
Change-Id: I78d478709b6a85cfcf25fe60cd390bbbbd98117c
  • Loading branch information
Juha Heiskanen committed Sep 11, 2018
1 parent 4bb8b54 commit b99d497
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
31 changes: 24 additions & 7 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,16 +990,33 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
}

if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT) {
//Take Random from 1-1.5 time WS_NEIGHBOR_NUD_TIMEOUT
uint32_t compare_random = randLIB_randomise_base(WS_NEIGHBOR_NUD_TIMEOUT, 0x8000, 0xC000);
if (time_from_start > compare_random) {

if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT * 1.5) {
activate_nud = true;
} else {
uint16_t switch_prob = randLIB_get_random_in_range(0, WS_NUD_RANDOM_SAMPLE_LENGTH -1);
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
if (switch_prob < WS_NUD_RANDOM_COMPARE) {
activate_nud = true;
}
}
} else if (etx_entry->etx_samples < 3) {
uint32_t compare_random = randLIB_get_random_in_range(1 << etx_entry->etx_samples, 8 << etx_entry->etx_samples);
if (time_from_start > compare_random) {
tr_debug("Link Probe test %u with jitter", compare_random);
} else if (etx_entry->etx_samples < WS_NEIGBOR_ETX_SAMPLE_MAX) {
//Take Random number for trig a prope.
//ETX Sample 0: random 1-8
//ETX Sample 1: random 2-16
//ETX Sample 2: random 4-32
uint32_t probe_period = WS_PROBE_INIT_BASE_SECONDS << etx_entry->etx_samples;
uint32_t time_block = 1 << etx_entry->etx_samples;
if (time_from_start >= probe_period) {
tr_debug("Link Probe test %u Sample trig", etx_entry->etx_samples);
activate_nud = true;
} else if (time_from_start > time_block) {
uint16_t switch_prob = randLIB_get_random_in_range(0, probe_period -1);
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
if (switch_prob < 2) {
tr_debug("Link Probe test with jitter %u, sample %u", time_from_start, etx_entry->etx_samples);
activate_nud = true;
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions source/6LoWPAN/ws/ws_common_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ typedef struct ws_bs_ie {
#define WS_NEIGHBOR_LINK_TIMEOUT 2200
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2

#define WS_NEIGBOR_ETX_SAMPLE_MAX 3

#define WS_PROBE_INIT_BASE_SECONDS 8

#define WS_NUD_RAND_PROBABILITY 10

#define WS_NUD_RANDOM_SAMPLE_LENGTH WS_NEIGHBOR_NUD_TIMEOUT / 2

#define WS_NUD_RANDOM_COMPARE (WS_NUD_RAND_PROBABILITY*WS_NUD_RANDOM_SAMPLE_LENGTH) / 100

/*
* Threshold (referenced to DEVICE_MIN_SENS) above which a neighbor node may be considered for inclusion into candidate parent set
*/
Expand Down

0 comments on commit b99d497

Please sign in to comment.