@@ -990,16 +990,33 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
990
990
}
991
991
992
992
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 ) {
996
995
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
+ }
997
1002
}
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 );
1002
1012
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
+ }
1003
1020
}
1004
1021
}
1005
1022
0 commit comments