From db51b7325c57a8c115d6944a8c2854b39635a535 Mon Sep 17 00:00:00 2001 From: Arto Kinnunen Date: Thu, 11 Apr 2019 13:53:59 +0300 Subject: [PATCH] Configure Thread neighbour and destination cache (#2057) Adjust Thread devices neighbour and destination cache parameters. --- source/6LoWPAN/Thread/thread_bbr_api.c | 7 ++++-- source/6LoWPAN/Thread/thread_bootstrap.c | 25 ++++++++++++++++++++ source/6LoWPAN/Thread/thread_config.h | 29 +++++++++++++++++++++--- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/source/6LoWPAN/Thread/thread_bbr_api.c b/source/6LoWPAN/Thread/thread_bbr_api.c index c6473f8718df..4401a150ecb6 100644 --- a/source/6LoWPAN/Thread/thread_bbr_api.c +++ b/source/6LoWPAN/Thread/thread_bbr_api.c @@ -1144,8 +1144,11 @@ int thread_bbr_start(int8_t interface_id, int8_t backbone_interface_id) // By default multicast forwarding is not enabled as it causes multicast loops multicast_fwd_set_forwarding(this->interface_id, false); - // Adjust BBR neighbor and destination cache size - arm_nwk_ipv6_max_cache_entries(THREAD_BBR_IPV6_DESTINATION_CACHE_SIZE); + // Configure BBR neighbour cache parameters + arm_nwk_ipv6_neighbour_cache_configure(THREAD_BBR_IPV6_NEIGHBOUR_CACHE_SIZE, + THREAD_BBR_IPV6_NEIGHBOUR_CACHE_SHORT_TERM, + THREAD_BBR_IPV6_NEIGHBOUR_CACHE_LONG_TERM, + THREAD_BBR_IPV6_NEIGHBOUR_CACHE_LIFETIME); thread_extension_bbr_init(interface_id, backbone_interface_id); diff --git a/source/6LoWPAN/Thread/thread_bootstrap.c b/source/6LoWPAN/Thread/thread_bootstrap.c index 7f88c67999f7..d8b62e3a8117 100644 --- a/source/6LoWPAN/Thread/thread_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_bootstrap.c @@ -945,6 +945,31 @@ static void thread_interface_bootsrap_mode_init(protocol_interface_info_entry_t tr_debug("Set End node Mode"); cur->thread_info->thread_device_mode = THREAD_DEVICE_MODE_END_DEVICE; } + + if (cur->thread_info->thread_device_mode == THREAD_DEVICE_MODE_ROUTER) { + // set router neighbour cache + ipv6_neighbour_cache_configure(THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_SIZE, + THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_SHORT_TERM, + THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_LONG_TERM, + THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_LIFETIME); + // set router destination cache + ipv6_destination_cache_configure(THREAD_ROUTER_IPV6_DESTINATION_CACHE_SIZE, + THREAD_ROUTER_IPV6_DESTINATION_CACHE_SHORT_TERM, + THREAD_ROUTER_IPV6_DESTINATION_CACHE_LONG_TERM, + THREAD_ROUTER_IPV6_DESTINATION_CACHE_LIFETIME); + } else { + // device is some sort of end device + ipv6_neighbour_cache_configure(THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_SIZE, + THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_SHORT_TERM, + THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_LONG_TERM, + THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_LIFETIME); + + ipv6_destination_cache_configure(THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_SIZE, + THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_SHORT_TERM, + THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_LONG_TERM, + THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_LIFETIME); + } + cur->thread_info->thread_attached_state = THREAD_STATE_NETWORK_DISCOVER; } diff --git a/source/6LoWPAN/Thread/thread_config.h b/source/6LoWPAN/Thread/thread_config.h index a4542f01cf94..4b8d41db1869 100644 --- a/source/6LoWPAN/Thread/thread_config.h +++ b/source/6LoWPAN/Thread/thread_config.h @@ -326,11 +326,34 @@ */ #define THREAD_BBR_ROUTER_ID_REQUEST_STATUS THREAD_COAP_STATUS_TLV_HAVE_CHILD_ID_REQUEST -/* - * Number of destination and neighbor cache entries assuming 250 thread devices (worst case) connecting to cloud service. +/* Border Router IPv6 neighbour and destination cache configuration + * Number of neighbor cache entries assuming 250 thread devices (worst case) connecting to cloud service. * Six entries reserved for backbone devices. */ -#define THREAD_BBR_IPV6_DESTINATION_CACHE_SIZE 256 +#define THREAD_BBR_IPV6_NEIGHBOUR_CACHE_SIZE 256 +#define THREAD_BBR_IPV6_NEIGHBOUR_CACHE_SHORT_TERM 128 +#define THREAD_BBR_IPV6_NEIGHBOUR_CACHE_LONG_TERM 32 +#define THREAD_BBR_IPV6_NEIGHBOUR_CACHE_LIFETIME 600 + +/* Router IPv6 neighbour and destination cache configuration */ +#define THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_SIZE 128 +#define THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_SHORT_TERM 64 +#define THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_LONG_TERM 8 +#define THREAD_ROUTER_IPV6_NEIGHBOUR_CACHE_LIFETIME 600 +#define THREAD_ROUTER_IPV6_DESTINATION_CACHE_SIZE 32 +#define THREAD_ROUTER_IPV6_DESTINATION_CACHE_SHORT_TERM 16 +#define THREAD_ROUTER_IPV6_DESTINATION_CACHE_LONG_TERM 4 +#define THREAD_ROUTER_IPV6_DESTINATION_CACHE_LIFETIME 600 + +/* End device IPv6 neighbour and destination cache configuration */ +#define THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_SIZE 32 +#define THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_SHORT_TERM 16 +#define THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_LONG_TERM 4 +#define THREAD_END_DEVICE_IPV6_NEIGHBOUR_CACHE_LIFETIME 600 +#define THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_SIZE 16 +#define THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_SHORT_TERM 8 +#define THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_LONG_TERM 4 +#define THREAD_END_DEVICE_IPV6_DESTINATION_CACHE_LIFETIME 600 /* * Timeout to solicit address from DHCP if previous request fails.