Skip to content

Commit 386e5ff

Browse files
author
Juha Heiskanen
committed
Wi-sun Update
Enabler for faster ETX probe if neighbour register address Added safe for Negative ARO send and not send if neighbour is removed already. Change-Id: I5f3f1f868e6d04d2f59a8648ef48dea49830585a
1 parent 05b1fe8 commit 386e5ff

File tree

9 files changed

+110
-12
lines changed

9 files changed

+110
-12
lines changed

source/6LoWPAN/ND/nd_router_object.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,14 @@ static void nd_update_registration(protocol_interface_info_entry_t *cur_interfac
855855
*/
856856
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur_interface), ipv6_neighbour_eui64(&cur_interface->ipv6_neighbour_cache, neigh), ADDR_802_15_4_LONG);
857857

858-
if (entry && !entry->ffd_device) {
859-
rpl_control_publish_host_address(protocol_6lowpan_rpl_domain, neigh->ip_address, neigh->lifetime);
858+
if (entry) {
859+
if (ws_info(cur_interface)) {
860+
ws_common_etx_validate(cur_interface, entry);
861+
}
862+
863+
if (!entry->ffd_device) {
864+
rpl_control_publish_host_address(protocol_6lowpan_rpl_domain, neigh->ip_address, neigh->lifetime);
865+
}
860866
}
861867
protocol_6lowpan_neighbor_address_state_synch(cur_interface, aro->eui64, neigh->ip_address + 8);
862868

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static void ws_bootstrap_authentication_completed(protocol_interface_info_entry_
9595
static void ws_bootstrap_pan_version_increment(protocol_interface_info_entry_t *cur);
9696
static ws_nud_table_entry_t *ws_nud_entry_discover(protocol_interface_info_entry_t *cur, void *neighbor);
9797
static void ws_nud_entry_remove(protocol_interface_info_entry_t *cur, mac_neighbor_table_entry_t *entry_ptr);
98+
static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data);
9899

99100
typedef enum {
100101
WS_PARENT_SOFT_SYNCH = 0, /**< let FHSS make decision if synchronization is needed*/
@@ -322,6 +323,8 @@ void ws_nud_active_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
322323
//Convert TICKS to real milliseconds
323324
if (ticks > 0xffff / 100) {
324325
ticks = 0xffff;
326+
} else if (ticks == 0) {
327+
ticks = 1;
325328
} else {
326329
ticks *= 100;
327330
}
@@ -1279,12 +1282,18 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
12791282

12801283
mac_neighbor_table_entry_t *neighbor_entry_ptr = NULL;
12811284
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur, &mac_neighbor_info(interface)->neighbour_list) {
1285+
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, cur->index);
12821286

12831287
if (cur->link_role == PRIORITY_PARENT_NEIGHBOUR) {
12841288
//This is our primary parent we cannot delete
12851289
continue;
12861290
}
12871291

1292+
if (cur->nud_active || ws_neighbor->accelerated_etx_probe || ws_neighbor->negative_aro_send) {
1293+
//If NUD process is active do not trig
1294+
continue;
1295+
}
1296+
12881297
if (neighbor_entry_ptr && neighbor_entry_ptr->lifetime < cur->lifetime) {
12891298
// We have already shorter link entry found this cannot replace it
12901299
continue;
@@ -1397,7 +1406,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
13971406
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, entry_ptr->index);
13981407
etx_storage_t *etx_entry = etx_storage_entry_get(cur->id, entry_ptr->index);
13991408

1400-
if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry) {
1409+
if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry || ws_neighbor->negative_aro_send) {
14011410
return false;
14021411
}
14031412

@@ -1417,17 +1426,22 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
14171426
//ETX Sample 0: random 1-8
14181427
//ETX Sample 1: random 2-16
14191428
//ETX Sample 2: random 4-32
1420-
uint32_t probe_period = WS_PROBE_INIT_BASE_SECONDS << etx_entry->etx_samples;
1421-
uint32_t time_block = 1 << etx_entry->etx_samples;
1422-
if (time_from_start >= probe_period) {
1423-
//tr_debug("Link Probe test %u Sample trig", etx_entry->etx_samples);
1429+
if (etx_entry->etx_samples == 0 && ws_neighbor->accelerated_etx_probe) {
1430+
//Accept quick Probe for init ETX
14241431
activate_nud = true;
1425-
} else if (time_from_start > time_block) {
1426-
uint16_t switch_prob = randLIB_get_random_in_range(0, probe_period - 1);
1427-
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
1428-
if (switch_prob < 2) {
1429-
//tr_debug("Link Probe test with jitter %"PRIu32", sample %u", time_from_start, etx_entry->etx_samples);
1432+
} else {
1433+
uint32_t probe_period = WS_PROBE_INIT_BASE_SECONDS << etx_entry->etx_samples;
1434+
uint32_t time_block = 1 << etx_entry->etx_samples;
1435+
if (time_from_start >= probe_period) {
1436+
//tr_debug("Link Probe test %u Sample trig", etx_entry->etx_samples);
14301437
activate_nud = true;
1438+
} else if (time_from_start > time_block) {
1439+
uint16_t switch_prob = randLIB_get_random_in_range(0, probe_period - 1);
1440+
//Take Random from time WS_NEIGHBOR_NUD_TIMEOUT - WS_NEIGHBOR_NUD_TIMEOUT*1.5
1441+
if (switch_prob < 2) {
1442+
//tr_debug("Link Probe test with jitter %"PRIu32", sample %u", time_from_start, etx_entry->etx_samples);
1443+
activate_nud = true;
1444+
}
14311445
}
14321446
}
14331447
}
@@ -1441,6 +1455,10 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
14411455
return false;
14421456
}
14431457
entry->neighbor_info = entry_ptr;
1458+
if (ws_neighbor->accelerated_etx_probe) {
1459+
ws_neighbor->accelerated_etx_probe = false;
1460+
entry->timer = 1;
1461+
}
14441462

14451463
if (etx_entry->etx_samples >= WS_NEIGBOR_ETX_SAMPLE_MAX) {
14461464
entry->nud_process = true;
@@ -2626,4 +2644,24 @@ void ws_secondary_parent_update(protocol_interface_info_entry_t *interface)
26262644
}
26272645
}
26282646

2647+
void ws_bootstrap_etx_accelerate(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neigh)
2648+
{
2649+
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neigh->index);
2650+
//Enable Faster ETX probing
2651+
ws_neighbor->accelerated_etx_probe = true;
2652+
//Move Neighbor to first to for accelerate Process
2653+
mac_neighbor_table_t *table_class = mac_neighbor_info(interface);
2654+
ns_list_remove(&table_class->neighbour_list, neigh);
2655+
ns_list_add_to_start(&table_class->neighbour_list, neigh);
2656+
//Try to Generate Active NUD Immediately
2657+
if (!ws_neighbor_entry_nud_notify(neigh, interface)) {
2658+
return;//Return if NUD active is full
2659+
}
2660+
table_class->active_nud_process++;
2661+
neigh->nud_active = true;
2662+
//Push NS to send
2663+
ws_nud_active_timer(interface, 0);
2664+
2665+
}
2666+
26292667
#endif //HAVE_WS

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ bool ws_eapol_relay_state_active(protocol_interface_info_entry_t *cur);
7777

7878
void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur, struct llc_neighbour_req *neighbor_info);
7979

80+
void ws_bootstrap_etx_accelerate(struct protocol_interface_info_entry *cur, mac_neighbor_table_entry_t *neigh);
81+
8082
#else
8183

8284
#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)
@@ -86,6 +88,7 @@ void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur,
8688
#define ws_bootstrap_aro_failure(cur, ll_address)
8789
#define ws_primary_parent_update(interface, neighbor)
8890
#define ws_secondary_parent_update(interface)
91+
#define ws_bootstrap_etx_accelerate(cur, neigh) ((void) 0)
8992

9093
#endif //HAVE_WS
9194

source/6LoWPAN/ws/ws_common.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "6LoWPAN/ws/ws_common.h"
2828
#include "6LoWPAN/ws/ws_bootstrap.h"
2929
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
30+
#include "Service_Libs/etx/etx.h"
3031
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
3132
#include "Service_Libs/blacklist/blacklist.h"
3233
#include "ws_management_api.h"
@@ -398,6 +399,29 @@ bool ws_common_allow_child_registration(protocol_interface_info_entry_t *interfa
398399
return true;
399400
}
400401

402+
bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, const uint8_t *eui64)
403+
{
404+
mac_neighbor_table_entry_t *neighbour = mac_neighbor_table_address_discover(mac_neighbor_info(interface), eui64, ADDR_802_15_4_LONG);
405+
if (!neighbour) {
406+
return false;
407+
}
408+
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbour->index);
409+
ws_neighbor->negative_aro_send = true;
410+
neighbour->lifetime = 30; //Remove anyway if Packet is freed before MAC push
411+
return true;
412+
}
413+
414+
void ws_common_etx_validate(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neigh)
415+
{
416+
etx_storage_t *etx_entry = etx_storage_entry_get(interface->id, neigh->index);
417+
418+
if (neigh->nud_active || !neigh->trusted_device || etx_entry->etx_samples) {
419+
return; //Do not trig Second NS if Active NUD already, not trusted or ETX samples already done
420+
}
421+
422+
ws_bootstrap_etx_accelerate(interface, neigh);
423+
}
424+
401425

402426
#endif // HAVE_WS
403427

source/6LoWPAN/ws/ws_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ void ws_common_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8
122122

123123
bool ws_common_allow_child_registration(protocol_interface_info_entry_t *cur, const uint8_t *eui64);
124124

125+
void ws_common_etx_validate(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neigh);
126+
127+
bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, const uint8_t *eui64);
128+
125129
#define ws_info(cur) ((cur)->ws_info)
126130
#else
127131
#define ws_info(cur) ((ws_info_t *) NULL)
@@ -131,6 +135,8 @@ bool ws_common_allow_child_registration(protocol_interface_info_entry_t *cur, co
131135
#define ws_common_neighbor_remove(cur, ll_address)
132136
#define ws_common_fast_timer(cur, ticks) ((void) 0)
133137
#define ws_common_allow_child_registration(cur, eui64) (false)
138+
#define ws_common_etx_validate(interface, neigh) ((void) 0)
139+
#define ws_common_negative_aro_mark(interface, eui64)(false)
134140

135141

136142
#endif //HAVE_WS

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ typedef struct ws_neighbor_class_entry {
3232
bool broadcast_timing_info_stored: 1;
3333
bool broadcast_shedule_info_stored: 1;
3434
bool synch_done : 1;
35+
bool accelerated_etx_probe : 1;
36+
bool negative_aro_send : 1;
3537
} ws_neighbor_class_entry_t;
3638

3739
/**

source/Common_Protocols/icmpv6.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,10 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
16771677
}
16781678
if (ws_info(cur) && aro && aro->status != ARO_SUCCESS) {
16791679
/*If Aro failed we will kill the neigbour after we have succeeded in sending message*/
1680+
if (!ws_common_negative_aro_mark(cur, aro->eui64)) {
1681+
tr_debug("Neighbour removed for negative response send");
1682+
return buffer_free(buf);
1683+
}
16801684
buf->ack_receive_cb = ack_remove_neighbour_cb;
16811685
}
16821686

test/nanostack/unittest/stub/ws_bootstrap_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,8 @@ void ws_bootstrap_eapol_parent_synch(struct protocol_interface_info_entry *cur,
120120
{
121121

122122
}
123+
124+
void ws_bootstrap_etx_accelerate(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neigh)
125+
{
126+
127+
}

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,13 @@ void ws_common_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8
7777
(void) cur;
7878
(void) ll_address;
7979
}
80+
81+
bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, const uint8_t *eui64)
82+
{
83+
return true;
84+
}
85+
86+
void ws_common_etx_validate(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neigh)
87+
{
88+
89+
}

0 commit comments

Comments
 (0)