| 1 |
.. SPDX-License-Identifier: BSD-2-Clause |
| 2 |
.. |
| 3 |
.. Copyright (C) 2025 Linutronix GmbH |
| 4 |
.. |
| 5 |
.. Testbench documentation statistics file. |
| 6 |
.. |
| 7 |
|
| 8 |
.. _Statistics: |
| 9 |
|
| 10 |
Statistics |
| 11 |
========== |
| 12 |
|
| 13 |
While running the RTC ``Testbench`` it collects statistics about various aspects including round |
| 14 |
trip and one way times, errors, processing and workload execution. This sections explains what |
| 15 |
statistics are collected and how they can be obtained and visualized. |
| 16 |
|
| 17 |
Statistics |
| 18 |
^^^^^^^^^^ |
| 19 |
|
| 20 |
The following table shows all gathered statistics. All statistics are collected per traffic class. |
| 21 |
|
| 22 |
.. list-table:: Statistics |
| 23 |
:widths: 50 100 |
| 24 |
:header-rows: 1 |
| 25 |
|
| 26 |
* - Name |
| 27 |
- Description |
| 28 |
|
| 29 |
* - FrameIdErrors |
| 30 |
- Is incremented if a traffic class receives a packet with wrong Profinet frame id. This could |
| 31 |
happen e.g., due to a wrong XDP eBPF program. Should be zero. |
| 32 |
|
| 33 |
* - FramesReceived |
| 34 |
- How many frames have been received and processed. |
| 35 |
|
| 36 |
* - FramesSent |
| 37 |
- How many frames have been transmitted. |
| 38 |
|
| 39 |
* - Oneway[Min,Max,Av] [us] |
| 40 |
- One way time measures the time between sending a packet from reference to mirror (or the |
| 41 |
other way around) and receiving it on the other side. The time stamps for this are taken in |
| 42 |
software on the application level. |
| 43 |
|
| 44 |
* - OnewayOutliers |
| 45 |
- Incremented if one way time is greater than cycle time. Should be zero. |
| 46 |
|
| 47 |
* - OutofOrderErrors |
| 48 |
- Is incremented if a frame does not have the expected sequence number. This can indicate out |
| 49 |
of order transmission, but will also be increased if a packet is lost. Should be zero. |
| 50 |
|
| 51 |
* - PayloadErrors |
| 52 |
- Is incremented if a frame does not have the expected payload. May happen due to driver |
| 53 |
bugs. Should be zero. |
| 54 |
|
| 55 |
* - ProcBatch[Min,Max,Av] [us] |
| 56 |
- Latency from the first RX hardware timestamp to the last TX hardware timestamp (batch |
| 57 |
processing latency per cycle). See :ref:`Processing Latency <ProcessingLatency>` for detailed information. |
| 58 |
|
| 59 |
* - ProcFirst[Min,Max,Av] [us] |
| 60 |
- Latency from the first RX hardware timestamp to the first TX hardware timestamp (first-frame |
| 61 |
processing latency per cycle). See :ref:`Processing Latency <ProcessingLatency>` for detailed information. |
| 62 |
|
| 63 |
* - RoundTrip[Min,Max,Av] [us] |
| 64 |
- Round trip delay measures the time from reference to mirror and back. The delay is calculated |
| 65 |
based on software timestamps. Also the mirror sends back the frame not immediately, but |
| 66 |
rather in next cycle. Therefore, the round trip time should be less than 2 * cycle time. |
| 67 |
|
| 68 |
* - RoundTripOutliers [us] |
| 69 |
- Is increment if a round trip time is greater than 2 * cycle time. This usually indicates some |
| 70 |
real time issue (e.g., kernel, driver, hardware, ...). Should be zero. |
| 71 |
|
| 72 |
* - Rx[Min,Max,Av] [us] |
| 73 |
- Latency from NIC hardware to user space based on hardware timestamps. |
| 74 |
See :ref:`Processing Latency <ProcessingLatency>` for detailed information. |
| 75 |
|
| 76 |
* - RxHw2Xdp[Min,Max,Av] [us] |
| 77 |
- Latency from NIC hardware to XDP program based on hardware timestamps. |
| 78 |
See :ref:`Processing Latency <ProcessingLatency>` for detailed information. |
| 79 |
|
| 80 |
* - RxWorkload[Min,Max,Av] [us] |
| 81 |
- Duration of workload execution. |
| 82 |
|
| 83 |
* - RxXdp2App[Min,Max,Av] [us] |
| 84 |
- Latency from XDP program to user space. |
| 85 |
See :ref:`Processing Latency <ProcessingLatency>` for detailed information. |
| 86 |
|
| 87 |
* - Tx[Min,Max,Av] [us] |
| 88 |
- Latency from user space enqueue to hardware transmit based on hardware timestamps. |
| 89 |
See :ref:`Processing Latency <ProcessingLatency>` for detailed information. |
| 90 |
|
| 91 |
* - TxHwTimestampMissing |
| 92 |
- Is incremented if hardware timestamp requested, but only software timestamp available. |
| 93 |
See :ref:`Processing Latency <ProcessingLatency>` for detailed information. |
| 94 |
|
| 95 |
.. Note:: Some statistics (e.g., ones based on hardware timestamps) are only available in |
| 96 |
combination with XDP. For detailed information about hardware timestamping, |
| 97 |
configuration requirements, and troubleshooting, see :ref:`Processing Latency <ProcessingLatency>`. |
| 98 |
|
| 99 |
File log |
| 100 |
^^^^^^^^ |
| 101 |
|
| 102 |
All statistics are logged once per collection interval into a file log in text form. |
| 103 |
|
| 104 |
MQTT / Grafana |
| 105 |
^^^^^^^^^^^^^^ |
| 106 |
|
| 107 |
Furthermore, the statistics can be submitted with MQTT and visualized with Grafana. |
| 108 |
|
| 109 |
See :ref:`MQTT` for more information. |
| 110 |
|
| 111 |
JSON/UDP |
| 112 |
^^^^^^^^ |
| 113 |
|
| 114 |
In addition, there is a JSON/UDP logger. This one submits the statistics in JSON representation per |
| 115 |
UDP once per collection interval. This is useful to get the statistics into other tools. |
| 116 |
|
| 117 |
In order to use the JSON/UDP logging, the following configuration parameters can be used: |
| 118 |
|
| 119 |
.. list-table:: JSON/UDP configuration options |
| 120 |
:widths: 50 100 |
| 121 |
:header-rows: 1 |
| 122 |
|
| 123 |
* - Option |
| 124 |
- Description |
| 125 |
|
| 126 |
* - StatsCollectionIntervalNS |
| 127 |
- Interval in which a summary of the data is generated, typically 1s |
| 128 |
|
| 129 |
* - LogJson |
| 130 |
- Enable and/or disable JSON logging |
| 131 |
|
| 132 |
* - LogJsonThreadPriority |
| 133 |
- Thread priority for the logging thread, usually low < 7 |
| 134 |
|
| 135 |
* - LogJsonThreadCpu |
| 136 |
- Thread CPU affinity |
| 137 |
|
| 138 |
* - LogJsonHost |
| 139 |
- IP address/host name where to send the JSON/UDP packets |
| 140 |
|
| 141 |
* - LogJsonPort |
| 142 |
- Port used by the UDP communication |
| 143 |
|
| 144 |
* - LogJsonMeasurementName |
| 145 |
- Used to distinguish measurements coming from different machines |
| 146 |
|
| 147 |
The code base contains a script to collect and print the statistics data. The user has to provide |
| 148 |
the measurement name and the statistics of interest. |
| 149 |
|
| 150 |
Example: |
| 151 |
|
| 152 |
.. code:: bash |
| 153 |
|
| 154 |
./scripts/stat.pl -p 8888 -m testbench1 -t TsnHigh -s FramesSent -s FramesReceived -s Workload* |
| 155 |
Measurement: testbench1 -- TC: TsnHigh |
| 156 |
FramesReceived: 0 |
| 157 |
FramesSent: 24016 |
| 158 |
RxWorkloadAv: 0 |
| 159 |
RxWorkloadMax: 0 |
| 160 |
RxWorkloadMin: 18446744073709551615 |