netstats.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016 INRIA
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
20 #include <stdint.h>
21 #include "cib.h"
22 #include "net/l2util.h"
23 #include "mutex.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
32 #ifndef NETSTATS_NB_SIZE
33 #define NETSTATS_NB_SIZE (8)
34 #endif
35 
39 #ifndef NETSTATS_NB_QUEUE_SIZE
40 #define NETSTATS_NB_QUEUE_SIZE (4)
41 #endif
42 
47 #define NETSTATS_LAYER2 (0x01)
48 #define NETSTATS_IPV6 (0x02)
49 #define NETSTATS_RPL (0x03)
50 #define NETSTATS_ALL (0xFF)
56 typedef struct {
57  uint32_t tx_unicast_count;
58  uint32_t tx_mcast_count;
60  uint32_t tx_success;
63  uint32_t tx_failed;
64  uint32_t tx_bytes;
65  uint32_t rx_count;
66  uint32_t rx_bytes;
67 } netstats_t;
68 
72 typedef struct {
73 #if IS_USED(MODULE_NETSTATS_NEIGHBOR_TX_TIME) || DOXYGEN
74  uint32_t time_tx_avg;
75 #endif
76 #if IS_USED(MODULE_NETSTATS_NEIGHBOR_ETX) || DOXYGEN
77  uint16_t etx;
78 #endif
79 #if IS_USED(MODULE_NETSTATS_NEIGHBOR_COUNT) || DOXYGEN
80  uint16_t tx_count;
81  uint16_t tx_fail;
82  uint16_t rx_count;
83 #endif
84  uint16_t last_updated;
85  uint16_t last_halved;
86  uint8_t l2_addr[L2UTIL_ADDR_MAX_LEN];
87  uint8_t l2_addr_len;
88  uint8_t freshness;
89 #if IS_USED(MODULE_NETSTATS_NEIGHBOR_RSSI) || DOXYGEN
90  uint8_t rssi;
91 #endif
92 #if IS_USED(MODULE_NETSTATS_NEIGHBOR_LQI) || DOXYGEN
93  uint8_t lqi;
94 #endif
96 
100 typedef struct {
105 
110 
114  uint32_t stats_queue_time_tx[NETSTATS_NB_QUEUE_SIZE];
115 
120 
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
Circular integer buffer interface.
#define L2UTIL_ADDR_MAX_LEN
maximum expected length for addresses
Definition: l2util.h:34
#define NETSTATS_NB_SIZE
The max number of entries in the peer stats table.
Definition: netstats.h:33
#define NETSTATS_NB_QUEUE_SIZE
The CIB size for tx correlation.
Definition: netstats.h:40
Link-layer helper function definitions.
Mutex for thread synchronization.
circular integer buffer structure
Definition: cib.h:41
Mutex structure.
Definition: mutex.h:36
Stats per peer struct.
Definition: netstats.h:72
uint8_t rssi
Average RSSI of received frames in abs([dBm])
Definition: netstats.h:90
uint16_t last_halved
seconds timestamp of last halving
Definition: netstats.h:85
uint16_t tx_fail
Number of sent frames that did not get ACKed.
Definition: netstats.h:81
uint16_t tx_count
Number of sent frames to this peer.
Definition: netstats.h:80
uint16_t etx
ETX of this peer.
Definition: netstats.h:77
uint8_t l2_addr_len
Length of netstats_nb::l2_addr.
Definition: netstats.h:87
uint32_t time_tx_avg
Average frame TX time in µs.
Definition: netstats.h:74
uint16_t last_updated
seconds timestamp of last update
Definition: netstats.h:84
uint8_t freshness
Freshness counter.
Definition: netstats.h:88
uint8_t lqi
Average LQI of received frames.
Definition: netstats.h:93
uint16_t rx_count
Number of received frames.
Definition: netstats.h:82
L2 Peer Info struct.
Definition: netstats.h:100
mutex_t lock
Neighbor Table access lock.
Definition: netstats.h:124
cib_t stats_idx
CIB for the tx correlation.
Definition: netstats.h:104
Global statistics struct.
Definition: netstats.h:56
uint32_t tx_bytes
sent bytes
Definition: netstats.h:64
uint32_t rx_bytes
received bytes
Definition: netstats.h:66
uint32_t tx_mcast_count
packets sent via multicast (including broadcast)
Definition: netstats.h:58
uint32_t tx_failed
failed sending operations
Definition: netstats.h:63
uint32_t tx_unicast_count
packets sent via unicast
Definition: netstats.h:57
uint32_t rx_count
received (data) packets
Definition: netstats.h:65
uint32_t tx_success
successful sending operations (either acknowledged or unconfirmed sending operation,...
Definition: netstats.h:60