doc/connectivity/networking/net_pkt_processing_stats.rst
.. _net_pkt_processing_stats:
Network Packet Processing Statistics ####################################
.. contents:: :local: :depth: 2
This page describes how to get information about network packet processing statistics inside network stack.
Network stack contains infrastructure to figure out how long the network packet
processing takes either in sending or receiving path. There are two Kconfig
options that control this. For transmit (TX) path the option is called
:kconfig:option:CONFIG_NET_PKT_TXTIME_STATS and for receive (RX) path the options is
called :kconfig:option:CONFIG_NET_PKT_RXTIME_STATS. Note that for TX, all kind of
network packet statistics is collected. For RX, only UDP, TCP or raw packet
type network packet statistics is collected.
After enabling these options, the :ref:net stats <net_shell> network shell
command will show this information:
.. code-block:: console
Avg TX net_pkt (11484) time 67 us Avg RX net_pkt (11474) time 43 us
.. note::
The values above and below are from emulated qemu_x86 board and UDP traffic
The TX time tells how long it took for network packet from its creation to
when it was sent to the network. The RX time tells the time from its creation
to when it was passed to the application. The values are in microseconds. The
statistics will be collected per traffic class if there are more than one
transmit or receive queues defined in the system. These are controlled by
:kconfig:option:CONFIG_NET_TC_TX_COUNT and :kconfig:option:CONFIG_NET_TC_RX_COUNT options.
If you enable :kconfig:option:CONFIG_NET_PKT_TXTIME_STATS_DETAIL or
:kconfig:option:CONFIG_NET_PKT_RXTIME_STATS_DETAIL options, then additional
information for TX or RX network packets are collected when the network packet
traverses the IP stack.
After enabling these options, the :ref:net stats <net_shell> will show
this information:
.. code-block:: console
Avg TX net_pkt (18902) time 63 us [0->22->15->23=60 us] Avg RX net_pkt (18892) time 42 us [0->9->6->11->13=39 us]
The numbers inside the brackets contain information how many microseconds it took for a network packet to go from previous state to next.
In the TX example above, the values are averages over 18902 packets and contain this information:
In the RX example above, the values are averages over 18892 packets and contain this information: