-
Notifications
You must be signed in to change notification settings - Fork 3k
Add Wi-SUN statistics interface #12766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,33 @@ typedef enum { | |
MESH_DEVICE_TYPE_WISUN_BORDER_ROUTER /*<! Wi-SUN border router */ | ||
} mesh_device_type_t; | ||
|
||
/** | ||
* Mesh network statistics | ||
*/ | ||
typedef struct { | ||
uint32_t rpl_total_memory; /*<! RPL current memory usage total. */ | ||
uint16_t etx_1st_parent; /*<! Primary parent ETX. */ | ||
uint16_t etx_2nd_parent; /*<! Secondary parent ETX. */ | ||
uint32_t asynch_tx_count; /*<! Asynch TX counter */ | ||
uint32_t asynch_rx_count; /*<! Asynch RX counter */ | ||
} mesh_nw_statistics_t; | ||
|
||
/** | ||
* Mesh physical layer statistics | ||
*/ | ||
typedef struct { | ||
uint32_t mac_rx_count; /*<! MAC RX packet count. */ | ||
uint32_t mac_tx_count; /*<! MAC TX packet count. */ | ||
uint32_t mac_bc_rx_count; /*<! MAC broadcast RX packet count. */ | ||
uint32_t mac_bc_tx_count; /*<! MAC broadcast TX packet count. */ | ||
uint32_t mac_tx_bytes; /*<! MAC TX bytes count. */ | ||
uint32_t mac_rx_bytes; /*<! MAC RX bytes count. */ | ||
uint32_t mac_tx_failed_count; /*<! MAC TX failed count. */ | ||
uint32_t mac_retry_count; /*<! MAC TX retry count. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mac_bc_tx_count, mac_tx_count and mac_retry_count are important. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
uint32_t mac_cca_attempts_count; /*<! MAC CCA attempts count. */ | ||
uint32_t mac_failed_cca_count; /*<! MAC failed CCA count. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mac_failed_cca and tx failed are usable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
} mesh_mac_statistics_t; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
#include "sw_mac.h" | ||
#include "ns_list.h" | ||
#include "net_interface.h" | ||
#include "nwk_stats_api.h" | ||
#include "ws_management_api.h" //ws_management_node_init | ||
#ifdef MBED_CONF_MBED_MESH_API_CERTIFICATE_HEADER | ||
#if !defined(MBED_CONF_MBED_MESH_API_ROOT_CERTIFICATE) || !defined(MBED_CONF_MBED_MESH_API_OWN_CERTIFICATE) || \ | ||
|
@@ -118,6 +119,15 @@ static wisun_network_settings_t wisun_settings_str = { | |
}; | ||
static mac_api_t *mac_api = NULL; | ||
|
||
typedef struct { | ||
nwk_stats_t nwk_stats; | ||
mac_statistics_t mac_statistics; | ||
ws_statistics_t ws_statistics; | ||
} wisun_statistics_t; | ||
|
||
static bool statistics_started = false; | ||
static wisun_statistics_t *statistics = NULL; | ||
|
||
extern fhss_timer_t fhss_functions; | ||
|
||
/* private function prototypes */ | ||
|
@@ -128,6 +138,7 @@ static void wisun_tasklet_configure_and_connect_to_network(void); | |
static void wisun_tasklet_clear_stored_certificates(void) ; | ||
static int wisun_tasklet_store_certificate_data(const uint8_t *cert, uint16_t cert_len, const uint8_t *cert_key, uint16_t cert_key_len, bool remove_own, bool remove_trusted, bool trusted_cert); | ||
static int wisun_tasklet_add_stored_certificates(void) ; | ||
static void wisun_tasklet_statistics_do_start(void); | ||
|
||
/* | ||
* \brief A function which will be eventually called by NanoStack OS when ever the OS has an event to deliver. | ||
|
@@ -257,7 +268,6 @@ static void wisun_tasklet_configure_and_connect_to_network(void) | |
} else { | ||
wisun_tasklet_data_ptr->operating_mode = NET_6LOWPAN_ROUTER; | ||
} | ||
|
||
wisun_tasklet_data_ptr->operating_mode_extension = NET_6LOWPAN_WS; | ||
|
||
arm_nwk_interface_configure_6lowpan_bootstrap_set( | ||
|
@@ -367,6 +377,10 @@ static void wisun_tasklet_configure_and_connect_to_network(void) | |
arm_network_own_certificate_add((const arm_certificate_entry_s *)&own_cert); | ||
#endif | ||
|
||
if (statistics_started) { | ||
wisun_tasklet_statistics_do_start(); | ||
} | ||
|
||
status = arm_nwk_interface_up(wisun_tasklet_data_ptr->network_interface_id); | ||
if (status >= 0) { | ||
wisun_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_STARTED; | ||
|
@@ -681,3 +695,66 @@ int wisun_tasklet_set_trusted_certificate(uint8_t *cert, uint16_t cert_len) | |
} | ||
return wisun_tasklet_store_certificate_data(cert, cert_len, NULL, 0, false, false, true); | ||
} | ||
|
||
int wisun_tasklet_statistics_start(void) | ||
{ | ||
statistics_started = true; | ||
|
||
if (statistics == NULL) { | ||
statistics = ns_dyn_mem_alloc(sizeof(wisun_statistics_t)); | ||
} | ||
if (statistics == NULL) { | ||
return -1; | ||
} | ||
memset(statistics, 0, sizeof(wisun_statistics_t)); | ||
|
||
wisun_tasklet_statistics_do_start(); | ||
|
||
return 0; | ||
} | ||
|
||
static void wisun_tasklet_statistics_do_start(void) | ||
{ | ||
if (!wisun_tasklet_data_ptr || wisun_tasklet_data_ptr->network_interface_id < 0 || !mac_api) { | ||
return; | ||
} | ||
|
||
protocol_stats_start(&statistics->nwk_stats); | ||
ns_sw_mac_statistics_start(mac_api, &statistics->mac_statistics); | ||
ws_statistics_start(wisun_tasklet_data_ptr->network_interface_id, &statistics->ws_statistics); | ||
} | ||
|
||
int wisun_tasklet_statistics_nw_read(mesh_nw_statistics_t *stats) | ||
{ | ||
if (!statistics || !stats) { | ||
return -1; | ||
} | ||
|
||
stats->rpl_total_memory = statistics->nwk_stats.rpl_total_memory; | ||
stats->etx_1st_parent = statistics->nwk_stats.etx_1st_parent; | ||
stats->etx_2nd_parent = statistics->nwk_stats.etx_2nd_parent; | ||
stats->asynch_tx_count = statistics->ws_statistics.asynch_tx_count; | ||
stats->asynch_rx_count = statistics->ws_statistics.asynch_rx_count; | ||
|
||
return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This binds the nanostack API to mbedOS API and we can't make changes to any independently I think we need to select the wanted statistics to Mbed OS API and just copy those not take everything at bulk There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrected |
||
} | ||
|
||
int wisun_tasklet_statistics_mac_read(mesh_mac_statistics_t *stats) | ||
{ | ||
if (!statistics || !stats) { | ||
return -1; | ||
} | ||
|
||
stats->mac_rx_count = statistics->mac_statistics.mac_rx_count; | ||
stats->mac_tx_count = statistics->mac_statistics.mac_tx_count; | ||
stats->mac_bc_rx_count = statistics->mac_statistics.mac_bc_rx_count; | ||
stats->mac_bc_tx_count = statistics->mac_statistics.mac_bc_tx_count; | ||
stats->mac_tx_bytes = statistics->mac_statistics.mac_tx_bytes; | ||
stats->mac_rx_bytes = statistics->mac_statistics.mac_rx_bytes; | ||
stats->mac_tx_failed_count = statistics->mac_statistics.mac_tx_failed_count; | ||
stats->mac_retry_count = statistics->mac_statistics.mac_retry_count; | ||
stats->mac_cca_attempts_count = statistics->mac_statistics.mac_cca_attempts_count; | ||
stats->mac_failed_cca_count = statistics->mac_statistics.mac_failed_cca_count; | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have multiple levels of RX counts and byte counts I think one is enough
Mac_tx/rx_count
Mac_bx_tx/rx_count and
Mac_tx/rx/bytes
seems the best on that area
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected