Network Statistics

Overview

Network statistics are collected if CONFIG_NET_STATISTICS is set. Individual component statistics for IPv4 or IPv6 can be turned off if those statistics are not needed. See various options in subsys/net/ip/Kconfig.stats file for details.

By default, the system collects network statistics per network interface. This can be controlled by CONFIG_NET_STATISTICS_PER_INTERFACE option.

The CONFIG_NET_STATISTICS_USER_API option can be set if the application wants to collect statistics for further processing. The network management interface API is used for that. See Network Management for details.

The CONFIG_NET_STATISTICS_ETHERNET option can be set to collect generic Ethernet statistics. If the CONFIG_NET_STATISTICS_ETHERNET_VENDOR option is set, then Ethernet device driver can collect Ethernet device specific statistics. These statistics can then be transferred to application for processing.

If the CONFIG_NET_SHELL option is set, then network shell can show statistics information with net stats command.

API Reference

group net_stats

Network statistics library.

Typedefs

typedef uint32_t net_stats_t

Network statistics counter.

struct net_stats_bytes
#include <net_stats.h>

Number of bytes sent and received.

Public Members

net_stats_t sent

Number of bytes sent.

net_stats_t received

Number of bytes received.

struct net_stats_pkts
#include <net_stats.h>

Number of network packets sent and received.

Public Members

net_stats_t tx

Number of packets sent.

net_stats_t rx

Number of packets received.

struct net_stats_ip
#include <net_stats.h>

IP layer statistics.

Public Members

net_stats_t recv

Number of received packets at the IP layer.

net_stats_t sent

Number of sent packets at the IP layer.

net_stats_t forwarded

Number of forwarded packets at the IP layer.

net_stats_t drop

Number of dropped packets at the IP layer.

struct net_stats_ip_errors
#include <net_stats.h>

IP layer error statistics.

Public Members

net_stats_t vhlerr

Number of packets dropped due to wrong IP version or header length.

net_stats_t hblenerr

Number of packets dropped due to wrong IP length, high byte.

net_stats_t lblenerr

Number of packets dropped due to wrong IP length, low byte.

net_stats_t fragerr

Number of packets dropped because they were IP fragments.

net_stats_t chkerr

Number of packets dropped due to IP checksum errors.

net_stats_t protoerr

Number of packets dropped because they were neither ICMP, UDP nor TCP.

struct net_stats_icmp
#include <net_stats.h>

ICMP statistics.

Public Members

net_stats_t recv

Number of received ICMP packets.

net_stats_t sent

Number of sent ICMP packets.

net_stats_t drop

Number of dropped ICMP packets.

net_stats_t typeerr

Number of ICMP packets with a wrong type.

net_stats_t chkerr

Number of ICMP packets with a bad checksum.

struct net_stats_tcp
#include <net_stats.h>

TCP statistics.

Public Members

struct net_stats_bytes bytes

Amount of received and sent TCP application data.

net_stats_t resent

Amount of retransmitted data.

net_stats_t drop

Number of dropped packets at the TCP layer.

net_stats_t recv

Number of received TCP segments.

net_stats_t sent

Number of sent TCP segments.

net_stats_t seg_drop

Number of dropped TCP segments.

net_stats_t chkerr

Number of TCP segments with a bad checksum.

net_stats_t ackerr

Number of received TCP segments with a bad ACK number.

net_stats_t rsterr

Number of received bad TCP RST (reset) segments.

net_stats_t rst

Number of received TCP RST (reset) segments.

net_stats_t rexmit

Number of retransmitted TCP segments.

net_stats_t conndrop

Number of dropped connection attempts because too few connections were available.

net_stats_t connrst

Number of connection attempts for closed ports, triggering a RST.

struct net_stats_udp
#include <net_stats.h>

UDP statistics.

Public Members

net_stats_t drop

Number of dropped UDP segments.

net_stats_t recv

Number of received UDP segments.

net_stats_t sent

Number of sent UDP segments.

net_stats_t chkerr

Number of UDP segments with a bad checksum.

struct net_stats_ipv6_nd
#include <net_stats.h>

IPv6 neighbor discovery statistics.

Public Members

net_stats_t drop

Number of dropped IPv6 neighbor discovery packets.

net_stats_t recv

Number of received IPv6 neighbor discovery packets.

net_stats_t sent

Number of sent IPv6 neighbor discovery packets.

struct net_stats_ipv6_mld
#include <net_stats.h>

IPv6 multicast listener daemon statistics.

Public Members

net_stats_t recv

Number of received IPv6 MLD queries.

net_stats_t sent

Number of sent IPv6 MLD reports.

net_stats_t drop

Number of dropped IPv6 MLD packets.

struct net_stats_ipv4_igmp
#include <net_stats.h>

IPv4 IGMP daemon statistics.

Public Members

net_stats_t recv

Number of received IPv4 IGMP queries.

net_stats_t sent

Number of sent IPv4 IGMP reports.

net_stats_t drop

Number of dropped IPv4 IGMP packets.

struct net_stats_tx_time
#include <net_stats.h>

Network packet transfer times for calculating average TX time.

Public Members

uint64_t sum

Sum of network packet transfer times.

net_stats_t count

Number of network packets transferred.

struct net_stats_rx_time
#include <net_stats.h>

Network packet receive times for calculating average RX time.

Public Members

uint64_t sum

Sum of network packet receive times.

net_stats_t count

Number of network packets received.

struct net_stats_tc
#include <net_stats.h>

Traffic class statistics.

Public Members

struct net_stats_tx_time tx_time

Helper for calculating average TX time statistics.

net_stats_t pkts

Number of packets sent for this traffic class.

Number of packets received for this traffic class.

net_stats_t bytes

Number of bytes sent for this traffic class.

Number of bytes received for this traffic class.

uint8_t priority

Priority of this traffic class.

struct net_stats_tc sent[NET_TC_TX_STATS_COUNT]

TX statistics for each traffic class.

struct net_stats_rx_time rx_time

Helper for calculating average RX time statistics.

struct net_stats_tc recv[NET_TC_RX_STATS_COUNT]

RX statistics for each traffic class.

struct net_stats_pm
#include <net_stats.h>

Power management statistics.

Public Members

uint64_t overall_suspend_time

Total suspend time.

net_stats_t suspend_count

How many times we were suspended.

uint32_t last_suspend_time

How long the last suspend took.

uint32_t start_time

Network interface last suspend start time.

struct net_stats
#include <net_stats.h>

All network statistics in one struct.

Public Members

net_stats_t processing_error

Count of malformed packets or packets we do not have handler for.

struct net_stats_bytes bytes

This calculates amount of data transferred through all the network interfaces.

struct net_stats_ip_errors ip_errors

IP layer errors.

struct net_stats_eth_errors
#include <net_stats.h>

Ethernet error statistics.

Public Members

net_stats_t rx_length_errors

Number of RX length errors.

net_stats_t rx_over_errors

Number of RX overrun errors.

net_stats_t rx_crc_errors

Number of RX CRC errors.

net_stats_t rx_frame_errors

Number of RX frame errors.

net_stats_t rx_no_buffer_count

Number of RX net_pkt allocation errors.

net_stats_t rx_missed_errors

Number of RX missed errors.

net_stats_t rx_long_length_errors

Number of RX long length errors.

net_stats_t rx_short_length_errors

Number of RX short length errors.

net_stats_t rx_align_errors

Number of RX buffer align errors.

net_stats_t rx_dma_failed

Number of RX DMA failed errors.

net_stats_t rx_buf_alloc_failed

Number of RX net_buf allocation errors.

net_stats_t tx_aborted_errors

Number of TX aborted errors.

net_stats_t tx_carrier_errors

Number of TX carrier errors.

net_stats_t tx_fifo_errors

Number of TX FIFO errors.

net_stats_t tx_heartbeat_errors

Number of TX heartbeat errors.

net_stats_t tx_window_errors

Number of TX window errors.

net_stats_t tx_dma_failed

Number of TX DMA failed errors.

net_stats_t uncorr_ecc_errors

Number of uncorrected ECC errors.

net_stats_t corr_ecc_errors

Number of corrected ECC errors.

struct net_stats_eth_flow
#include <net_stats.h>

Ethernet flow control statistics.

Public Members

net_stats_t rx_flow_control_xon

Number of RX XON flow control.

net_stats_t rx_flow_control_xoff

Number of RX XOFF flow control.

net_stats_t tx_flow_control_xon

Number of TX XON flow control.

net_stats_t tx_flow_control_xoff

Number of TX XOFF flow control.

struct net_stats_eth_csum
#include <net_stats.h>

Ethernet checksum statistics.

Public Members

net_stats_t rx_csum_offload_good

Number of good RX checksum offloading.

net_stats_t rx_csum_offload_errors

Number of failed RX checksum offloading.

struct net_stats_eth_hw_timestamp
#include <net_stats.h>

Ethernet hardware timestamp statistics.

Public Members

net_stats_t rx_hwtstamp_cleared

Number of RX hardware timestamp cleared.

net_stats_t tx_hwtstamp_timeouts

Number of RX hardware timestamp timeout.

net_stats_t tx_hwtstamp_skipped

Number of RX hardware timestamp skipped.

struct net_stats_eth
#include <net_stats.h>

All Ethernet specific statistics.

Public Members

struct net_stats_bytes bytes

Total number of bytes received and sent.

struct net_stats_pkts pkts

Total number of packets received and sent.

struct net_stats_pkts broadcast

Total number of broadcast packets received and sent.

struct net_stats_pkts multicast

Total number of multicast packets received and sent.

struct net_stats_pkts errors

Total number of errors in RX and TX.

struct net_stats_eth_errors error_details

Total number of errors in RX and TX.

struct net_stats_eth_flow flow_control

Total number of flow control errors in RX and TX.

struct net_stats_eth_csum csum

Total number of checksum errors in RX and TX.

struct net_stats_eth_hw_timestamp hw_timestamp

Total number of hardware timestamp errors in RX and TX.

net_stats_t collisions

Total number of collisions.

net_stats_t tx_dropped

Total number of dropped TX packets.

net_stats_t tx_timeout_count

Total number of TX timeout errors.

net_stats_t tx_restart_queue

Total number of TX queue restarts.

net_stats_t unknown_protocol

Total number of RX unknown protocol packets.

struct net_stats_ppp
#include <net_stats.h>

All PPP specific statistics.

Public Members

struct net_stats_bytes bytes

Total number of bytes received and sent.

struct net_stats_pkts pkts

Total number of packets received and sent.

net_stats_t drop

Number of received and dropped PPP frames.

net_stats_t chkerr

Number of received PPP frames with a bad checksum.

struct net_stats_sta_mgmt
#include <net_stats.h>

All Wi-Fi management statistics.

Public Members

net_stats_t beacons_rx

Number of received beacons.

net_stats_t beacons_miss

Number of missed beacons.

struct net_stats_wifi
#include <net_stats.h>

All Wi-Fi specific statistics.

Public Members

struct net_stats_sta_mgmt sta_mgmt

Total number of beacon errors.

struct net_stats_bytes bytes

Total number of bytes received and sent.

struct net_stats_pkts pkts

Total number of packets received and sent.

struct net_stats_pkts broadcast

Total number of broadcast packets received and sent.

struct net_stats_pkts multicast

Total number of multicast packets received and sent.

struct net_stats_pkts errors

Total number of errors in RX and TX.

struct net_stats_pkts unicast

Total number of unicast packets received and sent.