| 1 |
.. SPDX-License-Identifier: BSD-2-Clause |
| 2 |
.. |
| 3 |
.. Copyright (C) 2022-2025 Linutronix GmbH |
| 4 |
.. Author Kurt Kanzenbach <[email protected]> |
| 5 |
.. |
| 6 |
.. Testbench documentation introduction file. |
| 7 |
.. |
| 8 |
|
| 9 |
Test runs |
| 10 |
========= |
| 11 |
|
| 12 |
Execution of test runs |
| 13 |
---------------------- |
| 14 |
|
| 15 |
PROFINET follows a deadline model. Therefore, the ``reference`` application constantly measures the |
| 16 |
round trip times of PROFINET frames. This is performed for each traffic class. The minimum, average |
| 17 |
and maximum is calculated. The transmission and reception timestamps are taken directly in the |
| 18 |
reference application. The collected information is regularly printed to the log file specified in |
| 19 |
the configuration. |
| 20 |
|
| 21 |
The worst case round trip times are predictable, as PTP is used to synchronize the involved test |
| 22 |
machines. In theory, the round trip times should not exceed two times the given PROFINET |
| 23 |
cycle. Thus, the worst case round trip time is a good indicator whether the simulation works or |
| 24 |
not. Also the outlier statistics indicate whether frames have missed the expected deadline. |
| 25 |
|
| 26 |
In order to perform test runs two machines are required. They need to be connected either via an |
| 27 |
Ethernet (TSN) network or back to back. The link speed can be 100Mbit/s, 1Gbit/s or even |
| 28 |
higher. Before the reference and mirror application are started the network interface needs to |
| 29 |
configured. Furthermore, PTP has to be used. |
| 30 |
|
| 31 |
For every simulation there are four steps required. Example for Intel x86 platform with i225: |
| 32 |
|
| 33 |
1. PTP Synchronization |
| 34 |
|
| 35 |
.. code-block:: bash |
| 36 |
:caption: Start PTP on both machines |
| 37 |
|
| 38 |
host1: cd tests/profinet |
| 39 |
host1: ../../scripts/ptp.sh enp3s0 # Requires /etc/gPTP.cfg from linuxptp |
| 40 |
host1: journalctl -f # Verify that PTP is running and stable |
| 41 |
|
| 42 |
host2: cd tests/profinet |
| 43 |
host2: ../../scripts/ptp.sh enp3s0 # Requires /etc/gPTP.cfg from linuxptp |
| 44 |
host2: journalctl -f # Verify that PTP is running and stable |
| 45 |
|
| 46 |
This step has to be done only once. |
| 47 |
|
| 48 |
2. Traffic flow configurations |
| 49 |
|
| 50 |
.. code-block:: bash |
| 51 |
:caption: Configure traffic flow for network interface on both machines |
| 52 |
|
| 53 |
host1: cd tests/profinet |
| 54 |
host1: ./flow_cml.sh enp3s0 |
| 55 |
host1: journalctl -f # Verify that PTP is running and stable |
| 56 |
|
| 57 |
host2: cd tests/profinet |
| 58 |
host2: ./flow_cml.sh enp3s0 |
| 59 |
host2: journalctl -f # Verify that PTP is running and stable |
| 60 |
|
| 61 |
This step has to be done only once. |
| 62 |
|
| 63 |
3. Mirror |
| 64 |
|
| 65 |
.. code-block:: bash |
| 66 |
:caption: Start mirror application on second device |
| 67 |
|
| 68 |
host2: cd tests/profinet |
| 69 |
host2: cp ../../build/xdp_kern_*.o . |
| 70 |
host2: ../../build/mirror -c mirror_vid100_cml.yaml |
| 71 |
host2: tail -f /var/log/mirror_vid100.log # Verify that mirror application runs |
| 72 |
|
| 73 |
4. Reference |
| 74 |
|
| 75 |
.. code-block:: bash |
| 76 |
:caption: Start reference application on first device |
| 77 |
|
| 78 |
host1: cd tests/profinet |
| 79 |
host1: cp ../../build/xdp_kern_*.o . |
| 80 |
host1: ../../build/reference -c reference_vid100_cml.yaml |
| 81 |
host1: tail -f /var/log/reference_vid100.log # Check statistics |
| 82 |
|
| 83 |
The ``reference`` and ``mirror`` applications can be stopped with Ctrl-C and started again e.g. for |
| 84 |
testing changes in the YAML configurations. However, the ``mirror`` has to be always started before |
| 85 |
the ``reference``. This is due to the internal sequence counting mechanism. |
| 86 |
|
| 87 |
For use of the integrated TSN NICs on Intel Elkhart Lake a different configuration is required: |
| 88 |
|
| 89 |
.. code:: bash |
| 90 |
|
| 91 |
host1: cd tests/multi_middleware/stmmac/xdp |
| 92 |
host1: ./mirror.sh |
| 93 |
|
| 94 |
host2: cd tests/multi_middleware/stmmac/xdp |
| 95 |
host2: ./ref.sh |
| 96 |
|
| 97 |
Interpretation of results |
| 98 |
------------------------- |
| 99 |
|
| 100 |
The following demonstrates an example test scenario performed on Intel Comet Lake CPU(s) equipped |
| 101 |
with Intel i225 NIC(s). All scripts and configuration are located in ``tests/ptm``. |
| 102 |
|
| 103 |
- Cycle time of 1ms |
| 104 |
- Rx threads scheduled at offset 600us within 1ms period |
| 105 |
- Tx threads scheduled at offset 800us within 1ms period |
| 106 |
- 64 TsnHigh frames |
| 107 |
- 64 TsnLow frames |
| 108 |
- 128 Rtc frames |
| 109 |
- 1 frame for every other traffic class |
| 110 |
- Frame size 128 bytes for real time traffic |
| 111 |
- Frame size MTU maximum for non-real time traffic |
| 112 |
- Qbv cycle of 50 % real time and 50 % non-real time traffic |
| 113 |
|
| 114 |
Expected behavior: |
| 115 |
|
| 116 |
- Test executed without any hardware or kernel issues |
| 117 |
- Maximum round trip times for real time traffic are below 2 x cycle time |
| 118 |
- No frames are lost |
| 119 |
- No frames are damaged |
| 120 |
- Frames are transmitted in strict priority order |
| 121 |
|
| 122 |
At the end of the test runs the following log files have to be analyzed to |
| 123 |
determine whether the requirements are met: |
| 124 |
|
| 125 |
- Reference machine: ``/var/log/reference_vid100.log`` |
| 126 |
- Mirror machine: ``/var/log/mirror_vid100.log`` |
| 127 |
|
| 128 |
The maximum round trip times are logged via a summary interval. Example: |
| 129 |
|
| 130 |
- TsnHighSent=973914432 | TsnHighReceived=973914304 | TsnHighRttMin=1786 [us] | TsnHighRttMax=1814 [us] | TsnHighRttAvg=1800.735701 [us] |
| 131 |
- TsnLowSent=973914432 | TsnLowReceived=973914304 | TsnLowRttMin=1773 [us] | TsnLowRttMax=1805 [us] | TsnLowRttAvg=1790.233841 [us] |
| 132 |
- RtcSent=1947828864 | RtcReceived=1947828608 | RtcRttMin=1753 [us] | RtcRttMax=1797 [us] | RtcRttAvg=1780.022262 [us] |
| 133 |
- RtaSent=76087 | RtaReceived=76087 | RtaRttMin=979 [us] | RtaRttMax=1176 [us] | RtaRttAvg=1011.953501 [us] |
| 134 |
- DcpSent=7608 | DcpReceived=7608 | DcpRttMin=980 [us] | DcpRttMax=1207 [us] | DcpRttAvg=1097.250657 [us] |
| 135 |
- LldpSent=3043 | LldpReceived=3043 | LldpRttMin=990 [us] | LldpRttMax=1196 [us] | LldpRttAvg=1165.554058 [us] |
| 136 |
- UdpHighSent=3043 | UdpHighReceived=3043 | UdpHighRttMin=1005 [us] | UdpHighRttMax=1090 [us] | UdpHighRttAvg=1035.880053 [us] |
| 137 |
- UdpLowSent=3043 | UdpLowReceived=3043 | UdpLowRttMin=984 [us] | UdpLowRttMax=1075 [us] | UdpLowRttAvg=1020.958593 [us] |
| 138 |
|
| 139 |
As to be observed, the maximum round trip time for all real time traffic classes (TSN high/low and |
| 140 |
RTC) are below 2ms as expected. In particular, the pre-calculated round-trip time for the real time |
| 141 |
frames is 1.8ms. This test runs was executed over the period of 4 hours. In total 4 billion RT |
| 142 |
frames have been transmitted, received and checked. Not a single one missed its deadline or was |
| 143 |
damaged in any way. |
| 144 |
|
| 145 |
The following image shows how the expected round-trip time is calculated according to the parameters |
| 146 |
shown above: |
| 147 |
|
| 148 |
.. image:: images/rtc_testbench_timing_1ms_en.png |
| 149 |
:width: 600 |
| 150 |
:alt: Linux RealTime Communication Testbench scheduling 1ms |
| 151 |
|
| 152 |
Furthermore, the Linux RealTime Communication ``Testbench`` can also be utilized to check the |
| 153 |
Ethernet behavior on the wire. Therefore, special hardware equipment such as a TSN-Monitor from |
| 154 |
Fraunhofer or a Profishark 1G+ network TAP is required. The image below shows a burst of real time |
| 155 |
traffic: |
| 156 |
|
| 157 |
.. image:: images/ipg_256x128bytes.png |
| 158 |
:width: 600 |
| 159 |
:alt: Linux RealTime Communication Testbench burst |
| 160 |
|
| 161 |
Predefined Test Scenarios |
| 162 |
------------------------- |
| 163 |
|
| 164 |
Multi Middleware |
| 165 |
^^^^^^^^^^^^^^^^ |
| 166 |
|
| 167 |
The Linux RealTime Communication ``Testbench`` is able to simulate different Middlewares such as |
| 168 |
OPC/UA PubSub or PROFINET. The multi middleware scenario is useful for analyzing whether it is |
| 169 |
possible to execute multiple time aware applications at the same time using the same network |
| 170 |
interface on real time Linux. |
| 171 |
|
| 172 |
The first defined scenario is the following: |
| 173 |
|
| 174 |
.. list-table:: Basic Multi Middleware Test using AF_XDP sockets |
| 175 |
:widths: 28 28 12 12 12 |
| 176 |
:header-rows: 1 |
| 177 |
|
| 178 |
* - Middleware |
| 179 |
- Traffic Class |
| 180 |
- Frames |
| 181 |
- VID |
| 182 |
- PCP |
| 183 |
|
| 184 |
* - PROFINET |
| 185 |
- TC 7 / Queue 7 |
| 186 |
- 32 x 128 |
| 187 |
- 100 |
| 188 |
- 6 |
| 189 |
|
| 190 |
* - OPC/UA PubSub |
| 191 |
- TC 6 / Queue 6 |
| 192 |
- 32 x 128 |
| 193 |
- 200 |
| 194 |
- 5 |
| 195 |
|
| 196 |
* - OPC/UA PubSub |
| 197 |
- TC 5 / Queue 5 |
| 198 |
- 32 x 128 |
| 199 |
- 300 |
| 200 |
- 4 |
| 201 |
|
| 202 |
* - AVTP |
| 203 |
- TC 3 / Queue 3 |
| 204 |
- 32 x 128 |
| 205 |
- 400 |
| 206 |
- 3 |
| 207 |
|
| 208 |
* - Non-RT |
| 209 |
- TC 4/2/1/0 |
| 210 |
- None |
| 211 |
- None |
| 212 |
- None |
| 213 |
|
| 214 |
The second one is: |
| 215 |
|
| 216 |
.. list-table:: Basic Multi Middleware Test using AF_PACKET sockets |
| 217 |
:widths: 28 28 12 12 12 |
| 218 |
:header-rows: 1 |
| 219 |
|
| 220 |
* - Middleware |
| 221 |
- Traffic Class |
| 222 |
- Frames |
| 223 |
- VID |
| 224 |
- PCP |
| 225 |
|
| 226 |
* - PROFINET |
| 227 |
- TC 7 / Queue 7 |
| 228 |
- 8 x 128 |
| 229 |
- 100 |
| 230 |
- 6 |
| 231 |
|
| 232 |
* - OPC/UA PubSub |
| 233 |
- TC 7 / Queue 7 |
| 234 |
- 8 x 128 |
| 235 |
- 200 |
| 236 |
- 6 |
| 237 |
|
| 238 |
* - OPC/UA PubSub |
| 239 |
- TC 7 / Queue 7 |
| 240 |
- 8 x 128 |
| 241 |
- 300 |
| 242 |
- 6 |
| 243 |
|
| 244 |
* - AVTP |
| 245 |
- TC 7 / Queue 7 |
| 246 |
- 8 x 128 |
| 247 |
- 400 |
| 248 |
- 6 |
| 249 |
|
| 250 |
* - Non-RT |
| 251 |
- Rest |
| 252 |
- None |
| 253 |
- None |
| 254 |
- None |
| 255 |
|
| 256 |
All required configuration files and scripts are located in ``tests/multi_middlware/``. |
| 257 |
|
| 258 |
Hardware: Intel Elkhart Lake with stmmac |
| 259 |
|
| 260 |
Precision Time Measurement |
| 261 |
^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 262 |
|
| 263 |
Precision Time Measurement enables precise coordination of events across multiple components with |
| 264 |
independent local time clocks. Some network cards such as the Intel i225 as well as Intel CPUs |
| 265 |
support this feature. It can be used to increase the precision of ``phc2sys``. Especially under |
| 266 |
heavy system and PCIe load the usage of PTM increases the synchronization precision significantly. |
| 267 |
|
| 268 |
The following test scenario is designed to create network and PCIe load and to test influence of PTM |
| 269 |
for the precision of ``phc2sys``. |
| 270 |
|
| 271 |
.. list-table:: Precision Time Measurement influence Test |
| 272 |
:widths: 28 28 12 12 12 12 |
| 273 |
:header-rows: 1 |
| 274 |
|
| 275 |
* - Name |
| 276 |
- Traffic Class |
| 277 |
- Qbv Slot |
| 278 |
- Frames |
| 279 |
- VID |
| 280 |
- PCP |
| 281 |
|
| 282 |
* - TSN High |
| 283 |
- TC 7 / Queue 0 |
| 284 |
- 125 us |
| 285 |
- 64 x 128 |
| 286 |
- 100 |
| 287 |
- 6 |
| 288 |
|
| 289 |
* - TSN Low |
| 290 |
- TC 6 / Queue 1 |
| 291 |
- 125 us |
| 292 |
- 64 x 128 |
| 293 |
- 100 |
| 294 |
- 5 |
| 295 |
|
| 296 |
* - RTC |
| 297 |
- TC 5 / Queue 2 |
| 298 |
- 250 us |
| 299 |
- 128 x 128 |
| 300 |
- 100 |
| 301 |
- 4 |
| 302 |
|
| 303 |
* - Non-RT |
| 304 |
- Rest / Queue 3 |
| 305 |
- 500 us |
| 306 |
- None |
| 307 |
- None |
| 308 |
- None |
| 309 |
|
| 310 |
All required configuration files and scripts are located in ``tests/ptm/``. |
| 311 |
|
| 312 |
Hardware: Intel CPU with Intel i225/i226 |
| 313 |
|
| 314 |
PROFINET TSN |
| 315 |
^^^^^^^^^^^^ |
| 316 |
|
| 317 |
The following test scenario is designed to simulate PROFINET over TSN. It creates traffic for all |
| 318 |
eight traffic classes ranging from stream TSN to best effort. |
| 319 |
|
| 320 |
.. list-table:: PROFINET over TSN Test |
| 321 |
:widths: 28 28 12 12 12 12 |
| 322 |
:header-rows: 1 |
| 323 |
|
| 324 |
* - Name |
| 325 |
- Traffic Class |
| 326 |
- Qbv Slot |
| 327 |
- Frames |
| 328 |
- VID |
| 329 |
- PCP |
| 330 |
|
| 331 |
* - TSN High |
| 332 |
- TC 7 / Queue 0 |
| 333 |
- 50 us |
| 334 |
- 1 x 128 |
| 335 |
- 100 |
| 336 |
- 6 |
| 337 |
|
| 338 |
* - TSN Low |
| 339 |
- TC 6 / Queue 1 |
| 340 |
- 50 us |
| 341 |
- 1 x 128 |
| 342 |
- 100 |
| 343 |
- 5 |
| 344 |
|
| 345 |
* - RTC |
| 346 |
- TC 5 / Queue 2 |
| 347 |
- 100 us |
| 348 |
- 1 x 128 |
| 349 |
- 100 |
| 350 |
- 4 |
| 351 |
|
| 352 |
* - RTA / DCP / LLDP / UDP |
| 353 |
- Remain / Queue 3 |
| 354 |
- 800 us |
| 355 |
- 1 x 200 (1400) |
| 356 |
- 100 |
| 357 |
- Remain |
| 358 |
|
| 359 |
All required configuration files and scripts are located in ``tests/profinet/`` and |
| 360 |
``tests/profinet_zc``. |
| 361 |
|
| 362 |
In addition, PROFINET supports authentication and encryption. These mechanisms are demonstrated by |
| 363 |
``tests/profinet_auth/`` and ``tests/profinet_crypt/``. |
| 364 |
|
| 365 |
Furthermore, most test scenarios utilize XDP for acceleration. However, there is one PROFINET |
| 366 |
scenario which tests standard AF_PACKET sockets instead. It is located in ``tests/profinet_packet``. |
| 367 |
|
| 368 |
Hardware: Intel CPU with Intel i225/i226 |
| 369 |
|
| 370 |
PROFINET RT |
| 371 |
^^^^^^^^^^^ |
| 372 |
|
| 373 |
The following test scenario is designed to simulate PROFINET RT. It creates traffic for cyclic and |
| 374 |
acyclic real time traffic as well as best effort. |
| 375 |
|
| 376 |
.. list-table:: PROFINET RT |
| 377 |
:widths: 28 28 12 12 12 12 |
| 378 |
:header-rows: 1 |
| 379 |
|
| 380 |
* - Name |
| 381 |
- Traffic Class |
| 382 |
- Qbv Slot |
| 383 |
- Frames |
| 384 |
- VID |
| 385 |
- PCP |
| 386 |
|
| 387 |
* - RTC |
| 388 |
- Queue 0 |
| 389 |
- 100 us |
| 390 |
- 32 x 128 |
| 391 |
- 100 |
| 392 |
- 4 |
| 393 |
|
| 394 |
* - RTA |
| 395 |
- Queue 1 |
| 396 |
- 100 us |
| 397 |
- 32 x 128 |
| 398 |
- 100 |
| 399 |
- 3 |
| 400 |
|
| 401 |
* - DCP / LLDP / Best Effort High |
| 402 |
- Queue 2 |
| 403 |
- 400 us |
| 404 |
- 1 x 1400 |
| 405 |
- 100 |
| 406 |
- 7 2 1 |
| 407 |
|
| 408 |
* - Best Effort Low |
| 409 |
- Queue 3 |
| 410 |
- 400 us |
| 411 |
- 1 x 1400 |
| 412 |
- 100 |
| 413 |
- 0 |
| 414 |
|
| 415 |
All required configuration files and scripts are located in ``tests/profinet_rt/``. |
| 416 |
|
| 417 |
Hardware: Intel CPU with Intel i225/i226 |
| 418 |
|
| 419 |
Netload |
| 420 |
^^^^^^^ |
| 421 |
|
| 422 |
Deterministic real time Ethernet communication requires guaranteed resources in the bridges as well |
| 423 |
as the end stations for bounded latency frame delivery. Thus, resource protection mechanisms are |
| 424 |
required. Additional not planned network traffic should not lead to any disturbance of the real time |
| 425 |
traffic. Therefore, PROFINET defines ingress rate limiters for bandwidth limitations of real-time |
| 426 |
and non-real time traffic (Unicast, Multicast and Broadcast). Traditionally, this Ingress Rate |
| 427 |
Limiter is used in bridges. However, this model is interesting for end stations as well, because the |
| 428 |
CPU and memory resources of individual end stations have to be protected in cases of malfunctioning |
| 429 |
or misconfigured bridges. The following test scenario is designed to test ingress rate limiting |
| 430 |
mechanisms. In contrast to all other test scenarios the netload one ignores receive errors in case |
| 431 |
any traffic has been dropped. |
| 432 |
|
| 433 |
.. list-table:: Netload Test |
| 434 |
:widths: 28 28 12 12 12 12 |
| 435 |
:header-rows: 1 |
| 436 |
|
| 437 |
* - Name |
| 438 |
- Traffic Class |
| 439 |
- Qbv Slot |
| 440 |
- Frames |
| 441 |
- VID |
| 442 |
- PCP |
| 443 |
|
| 444 |
* - RTC |
| 445 |
- TC 5 / Queue 0 |
| 446 |
- 500 us |
| 447 |
- 128 x 128 |
| 448 |
- 100 |
| 449 |
- 4 |
| 450 |
|
| 451 |
All required configuration files and scripts are located in |
| 452 |
``tests/netload/``. |
| 453 |
|
| 454 |
Hardware: Intel CPU with Intel i225/i226 |
| 455 |
|
| 456 |
Busypolling |
| 457 |
^^^^^^^^^^^ |
| 458 |
|
| 459 |
There are applications which do prefer polling instead of interrupt driven network communication in |
| 460 |
order to reduce jitter introduced by hardware and software interrupts. The following test scenario |
| 461 |
is designed to test busy polling with AF_XDP sockets. |
| 462 |
|
| 463 |
.. Note:: Busy polling on ``PREEMPT_RT`` only works with Linux kernel >= v6.5. |
| 464 |
|
| 465 |
.. list-table:: Busypolling Test |
| 466 |
:widths: 28 28 12 12 12 12 |
| 467 |
:header-rows: 1 |
| 468 |
|
| 469 |
* - Name |
| 470 |
- Traffic Class |
| 471 |
- Qbv Slot |
| 472 |
- Frames |
| 473 |
- VID |
| 474 |
- PCP |
| 475 |
|
| 476 |
* - RTC |
| 477 |
- TC 5 / Queue 0 |
| 478 |
- 500 us |
| 479 |
- 256 x 128 |
| 480 |
- 100 |
| 481 |
- 4 |
| 482 |
|
| 483 |
All required configuration files and scripts are located in |
| 484 |
``tests/busypolling/``. |
| 485 |
|
| 486 |
Hardware: Intel CPU with Intel i225/i226 |
| 487 |
|
| 488 |
Tested Hardware |
| 489 |
--------------- |
| 490 |
|
| 491 |
The Linux RealTime Communication ``Testbench`` has been successfully tested on the following |
| 492 |
hardware platforms and TSN NIC(s). |
| 493 |
|
| 494 |
Hardware platforms: |
| 495 |
|
| 496 |
- Intel Elkhart Lake |
| 497 |
- Intel Comet Lake |
| 498 |
- Intel Apollo Lake |
| 499 |
- NXP imx93 |
| 500 |
|
| 501 |
TSN NIC(s): |
| 502 |
|
| 503 |
- Intel i210 |
| 504 |
- Intel i225 |
| 505 |
- Intel i226 |
| 506 |
- stmmac |
| 507 |
|
| 508 |
Switches |
| 509 |
-------- |
| 510 |
|
| 511 |
The Linux RealTime Communication ``Testbench`` relies on precise time synchronization between all |
| 512 |
involved nodes. Therefore, the PTP is leveraged. As a consequence it is recommended to use Ethernet |
| 513 |
switches which do support PTP based on 802.1AS. |
| 514 |
|
| 515 |
Furthermore, when using Ethernet switches, disable the LLDP traffic class by setting |
| 516 |
``LldpNumFramesPerCycle`` to 0. The Linux RealTime Communication ``Testbench`` simulates LLDP |
| 517 |
traffic with its own special crafted Ethernet frames, which are not valid LLDP messages in terms of |
| 518 |
the 802.1AB protocol. As LLDP is link local traffic and interpreted by Ethernet switches, that will |
| 519 |
confuse the applications and the switches. Still LLDP can be enabled in the whole network. |