Skip to content

Commit 4d6abb3

Browse files
author
Juha Heiskanen
committed
Added 15 second guarantee time for packet handler before remove link.
Change-Id: Ic134d0b0c004cf37e42997cb2f19c2c648ca70a0
1 parent 9ed97eb commit 4d6abb3

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,16 @@ static void ws_bootstrap_asynch_confirm(struct protocol_interface_info_entry *in
12951295
(void)interface;
12961296
(void)asynch_message;
12971297
}
1298+
1299+
uint32_t ws_time_from_last_unicast_traffic(uint32_t current_time_stamp, ws_neighbor_class_entry_t *ws_neighbor)
1300+
{
1301+
uint32_t time_from_last_unicast_shedule = current_time_stamp;
1302+
//Time from last RX unicast in us
1303+
time_from_last_unicast_shedule -= ws_neighbor->fhss_data.uc_timing_info.utt_rx_timestamp;
1304+
time_from_last_unicast_shedule /= 1000000; //Convert to seconds
1305+
return time_from_last_unicast_shedule;
1306+
}
1307+
12981308
static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_entry *interface)
12991309
{
13001310
uint8_t ll_target[16];
@@ -1305,6 +1315,9 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13051315
}
13061316
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
13071317

1318+
uint32_t current_time_stamp = 0;
1319+
ns_sw_mac_read_current_timestamp(interface->mac_api, &current_time_stamp);
1320+
13081321
mac_neighbor_table_entry_t *neighbor_entry_ptr = NULL;
13091322
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur, &mac_neighbor_info(interface)->neighbour_list) {
13101323
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, cur->index);
@@ -1340,14 +1353,29 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13401353
}
13411354
}
13421355

1356+
uint32_t link_min_timeout;
1357+
//Read current timestamp
1358+
uint32_t time_from_last_unicast_shedule = ws_time_from_last_unicast_traffic(current_time_stamp, ws_neighbor);
13431359

13441360

13451361
if (cur->trusted_device) {
1346-
neighbor_entry_ptr = cur;
1362+
link_min_timeout = WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT;
13471363
} else {
1348-
if (cur->link_lifetime - cur->lifetime > WS_NEIGHBOR_NOT_TRUSTED_LINK_TIMEOUT) {
1349-
//Accept only Enough Old not trusted Device
1364+
1365+
link_min_timeout = WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT;
1366+
}
1367+
1368+
if (time_from_last_unicast_shedule > link_min_timeout) {
1369+
//Accept only Enough Old Device
1370+
if (!neighbor_entry_ptr) {
1371+
//Accept first compare
13501372
neighbor_entry_ptr = cur;
1373+
} else {
1374+
uint32_t compare_neigh_time = ws_time_from_last_unicast_traffic(current_time_stamp, ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor_entry_ptr->index));
1375+
if (compare_neigh_time < time_from_last_unicast_shedule) {
1376+
//Accept older RX timeout allways
1377+
neighbor_entry_ptr = cur;
1378+
}
13511379
}
13521380
}
13531381
}

source/6LoWPAN/ws/ws_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, con
407407
}
408408
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbour->index);
409409
ws_neighbor->negative_aro_send = true;
410-
neighbour->lifetime = WS_NEIGHBOR_NOT_TRUSTED_LINK_TIMEOUT; //Remove anyway if Packet is freed before MAC push
410+
neighbour->lifetime = WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT; //Remove anyway if Packet is freed before MAC push
411411
return true;
412412
}
413413

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ typedef struct ws_bs_ie {
186186
#define WS_FAN_VERSION_1_0 1
187187

188188
#define WS_NEIGHBOR_LINK_TIMEOUT 2200
189-
#define WS_NEIGHBOR_NOT_TRUSTED_LINK_TIMEOUT 60
189+
#define WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT 60
190+
#define WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT 15
190191
#define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2
191192

192193
#define WS_NEIGBOR_ETX_SAMPLE_MAX 3

0 commit comments

Comments
 (0)