Debian Codegraph @

Documentation/configuration.rst

raw
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 configuration file.
7 ..
8
9 .. _Configuration:
10
11 Configuration
12 =============
13
14 Traffic configuration
15 ^^^^^^^^^^^^^^^^^^^^^
16
17 The applications itself are configurable. The configuration defines all required parameters such as
18 how many frames are transmitted per cycle, which traffic classes are active, the cycle time, clock
19 and many more.
20
21 The configuration is based on YAML files and parsed at startup. Valid configurations have to be
22 created before starting the simulation.
23
24 Possible parameters include:
25
26 .. list-table:: Configuration options
27 :widths: 50 100
28 :header-rows: 1
29
30 * - Option
31 - Description
32
33 * - ApplicationClockId (String)
34 - ``CLOCK_TAI`` or ``CLOCK_MONOTONIC``
35
36 * - ApplicationBaseStartTimeNS (Integer)
37 - Absolute start time of simulation (or nothing for default value now + 30s)
38
39 * - ApplicationBaseCycleTimeNS (Integer)
40 - Application cycle time
41
42 * - ApplicationTxBaseOffsetNS (Integer)
43 - Execution offset of Tx threads within Application cycle time
44
45 * - ApplicationRxBaseOffsetNS (Integer)
46 - Execution offset of Rx threads within Application cycle time
47
48 * - ApplicationXdpProgram (String)
49 - Application specific XDP program
50
51 * - <Class>Enabled (Boolean)
52 - Selects whether this traffic is active or not
53
54 * - <Class>XdpEnabled (Boolean)
55 - Use XDP instead of RAW sockets
56
57 * - <Class>XdpSkbMode (Boolean)
58 - Use XDP skb mode (for testing XDP code or driver implementation)
59
60 * - <Class>XdpZcMode (Boolean)
61 - Use XDP zero copy mode
62
63 * - <Class>XdpWakeupMode (Boolean)
64 - Use XDP wakeup mode
65
66 * - <Class>XdpBusyPollMode (Boolean)
67 - Drive XDP socket in busy poll mode
68
69 * - <Class>TxTimeEnabled (Boolean)
70 - Use Tx Launch Time for all transmitted frames (requires ETF Qdisc and is not compatible with
71 XDP)
72
73 * - <Class>TxTimeOffsetNS (Integer)
74 - Optional Tx Launch Time offset relative to Qbv schedule and cycle time
75
76 * - <Class>TxTimeStampEnabled (Boolean)
77 - Enable TX hardware timestamping for latency measurement (requires TX_TIMESTAMP build option)
78
79 * - <Class>IgnoreRxErrors (Boolean)
80 - By default, the applications perform consistency checks for all received frames. This option
81 disables these checks. Do not enable this. This is only useful for testing e.g., overload
82 scenarios.
83
84 * - <Class>Vid (Integer)
85 - VLAN ID used for traffic generation
86
87 * - <Class>Pcp (Integer)
88 - VLAN PCP used for traffic generation
89
90 * - <Class>NumFramesPerCycle (Integer)
91 - Number of frames transmitted per cycle
92
93 * - <Class>PayloadPattern (String)
94 - Payload pattern for frame content. The payload is a sequence of bytes. If the payload pattern
95 is smaller than the frame size, zero padding is added.
96
97 * - <Class>FrameLength (Integer)
98 - Length of frames excluding four bytes of FCS
99
100 * - <Class>SecurityMode (String)
101 - One of ``None``, ``AO`` (Authentication only), ``AE`` (Authentication and Encryption)
102
103 * - <Class>SecurityAlgorithm (String)
104 - One of ``AES256-GCM``, ``AES128-GCM``, ``CHACHA20-POLY1305``
105
106 * - <Class>SecurityKey (String)
107 - Key to be used for crypto functions either 16 or 32 bytes depending on selected algorithm
108
109 * - <Class>SecurityIvPrefix (String)
110 - Prefix of the IV which is 6 bytes in size
111
112 * - <Class>RxQueue (Integer)
113 - Receive queue
114
115 * - <Class>TxQueue (Integer)
116 - Transmit queue. This is not used at the moment. Tx queue is determined via
117 ``SocketPriority``. For XDP the socket is bound to ``RxQueue``.
118
119 * - <Class>SocketPriority (Integer): Socket priority
120 - Socket priority. It used for QoS of the operating system.
121
122 * - <Class>TxThreadPriority (Integer)
123 - Tx thread priority based on SCHED_FIFO
124
125 * - <Class>RxThreadPriority (Integer)
126 - Rx thread priority based on SCHED_FIFO
127
128 * - <Class>TxThreadCpu (Integer)
129 - Tx thread CPU affinity
130
131 * - <Class>RxThreadCpu (Integer)
132 - Rx thread CPU affinity
133
134 * - <Class>Interface (String)
135 - Network interface to be used
136
137 * - <Class>Destination (MAC/IP Address)
138 - Destination MAC/IP address
139
140 * - LogThreadPriority (Integer):
141 - Log thread priority based on SCHED_FIFO
142
143 * - LogThreadCpu (Integer)
144 - Log thread CPU affinity
145
146 * - LogFile (String)
147 - Path to log file
148
149 * - LogLevel (String)
150 - Log level, one of ``Debug``, ``Info``, ``Warning``, ``Error``
151
152 * - StatsCollectionIntervalNS (Integer)
153 - Interval in which a summary of the data is generated, typically 1s, i.e. 1000000000Ns
154
155 * - StatsHistogramEnabled (Boolean)
156 - Decides whether a histogram is written after successful run or not
157
158 * - StatsHistogramMinimumNS (Integer)
159 - Lower boundary of RTT which is recorded in histogram e.g., 1ms
160
161 * - StatsHistogramMaximumNS (Integer)
162 - Upper boundary of RTT which is recorded in histogram e.g., 10ms
163
164 * - StatsHistogramFile (String)
165 - Path to file where to store the histogram after run
166
167 * - LogMqtt (Boolean)
168 - Enable and disable MQTT logging
169
170 * - LogMqttThreadPriority (Integer)
171 - Thread priority for the logging thread, usually low < 7
172
173 * - LogMqttThreadCpu (Integer)
174 - Thread CPU affinity
175
176 * - LogMqttBrokerIP (IP Address)
177 - IP address where MQTT broker is running
178
179 * - LogMqttBrokerPort (Integer)
180 - Port used by the MQTT Broker, default value is 1883
181
182 * - LogMqttKeepAliveSecs (Integer)
183 - Keep alive time for the connection, default value 60s
184
185 * - LogMqttMeasurementName (String)
186 - Used to distinguish measurements coming from different machines.
187
188 * - LogJson (Boolean)
189 - Enable and disable JSON logging
190
191 * - LogJsonThreadPriority (Integer)
192 - Thread priority for the logging thread, usually low < 7
193
194 * - LogJsonThreadCpu (Integer)
195 - Thread CPU affinity
196
197 * - LogJsonHost (IP Address)
198 - IP address or host name where JSON/UDP messages should be sent to
199
200 * - LogJsonPort (Integer)
201 - Port used for JSON/UDP messages
202
203 * - LogJsonMeasurementName (String)
204 - Used to distinguish measurements coming from different machines
205
206 * - DebugStopTraceOnOutlier (Integer)
207 - Stop Linux kernel tracing if round trip or oneway time exceeds expected value
208
209 * - DebugStopTraceOnError (Boolean)
210 - Stop Linux kernel tracing if error happened (e.g. transmission failure)
211
212 * - DebugMonitorMode (Boolean)
213 - Monitor mode for Fraunhofer FPGA measurement
214
215 * - DebugMonitorDestination (MAC Address)
216 - Destination address of first frame per burst
217
218 The possible traffic classes are:
219
220 - TsnHigh: TSN Stream High traffic
221 - TsnLow: TSN Stream Low traffic
222 - Rtc: Real time cyclic traffic
223 - Rta: Real time acyclic traffic
224 - Dcp: Discovery and basic Configuration Protocol
225 - Lldp: Link-Layer Discovery Protocol
226 - UdpHigh: Connection traffic Best Effort High
227 - UdpLow: Connection traffic Best Effort Low
228 - GenericL2: Traffic class to simulate any kind of protocol such as OPC/UA
229
230 .. Note:: Not all traffic class have all options available. For instance, only real time traffic classes such as TSN or
231 RT make use of XDP sockets. When the XDP option is enabled the traffic classes utilize ``AF_XDP`` instead of
232 ``AF_PACKET`` sockets for Ethernet communication.
233
234 .. Note:: The ``GenericL2`` traffic class is not PROFINET specific, but rather used to simulate general purpose Ethernet
235 (Layer 2) based protocols such as OPC/UA PubSub. In addition, to the other traffic classes the EtherType is
236 configurable.
237
238 .. Note:: The ``XdpBusyPollMode`` option requires Linux kernel >= v6.5. Previous Linux kernel version do not support
239 this feature with ``PREEMPT_RT`` enabled.
240
241 .. Note:: The **security settings** are only valid for the PROFINET real time traffic
242 classes. Furthermore, the Linux RealTime Communication ``Testbench`` demonstrates only one
243 exemplary implementation. The PROFINET security specification is still under
244 development. This implementation is to be used only for performance measurements. For
245 instance, what impact does real time frame encryption and decryption has on quantity
246 structures? Key updates and other mechanisms are not covered.
247
248 Sample configuration files are provided for Intel i210, i225/i226 and stmmac.
249
250 Starting point for PROFINET TSN:
251
252 - https://github.com/Linutronix/RTC-Testbench/tree/main/tests/profinet
253
254 Starting point for OPC/UA:
255
256 - https://github.com/Linutronix/RTC-Testbench/tree/main/tests/opcua
257
258 At minimum MAC and IP addresses as well as network interface names have to be adjusted.
259
260 Network interface configuration
261 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
262
263 The configuration of network interfaces is crucial. Different NICs have
264 different capabilities such as queue configuration, routing, Qbv, ... For instance,
265 the PROFINET specification specifies which traffic class is transmitted and
266 received on which queue. It also defines which Ethernet frames are VLAN tagged
267 and which are transmitted untagged. The configuration of all NIC settings are
268 either performed by ``tc`` from ``iproute2`` package or ``ethtool``. That
269 depends on the Linux driver implementation.
270
271 The reference applications provides sample scripts in ``tests/`` folder.
272
273 These scripts configure multiple settings:
274
275 - Tx queue assignment
276 - Rx queue assignment
277 - Qbv schedule
278 - IRQ coalescing
279 - Threaded NAPI mode
280 - IRQ and NAPI thread priorities
281
282 All of these settings are required for the PROFINET simulation to work properly.
283
284 UDP communication
285 ^^^^^^^^^^^^^^^^^
286
287 The UDP communication relies on standard sockets. It assumes that corresponding VLAN interfaces have
288 been setup on the system. VLAN interfaces can be created by multiple ways: NetworkManager, Linux
289 Distribution mechanisms or manually.
290
291 Example for manual configuration:
292
293 .. code:: bash
294
295 ip link add link eth0 name eth0.100 type vlan id 100
296 ip addr add XXX dev eth0.100
297
298 Whenever a UDP packet is transmitted or received on a VLAN network interface the kernel will
299 automatically add or strip the VLAN tag. The PCP value is derived from the socket priority. This
300 mapping between socket priority and PCP values is configurable.
301
302 Example:
303
304 .. code:: bash
305
306 ip link set eth0.100 type vlan egress-qos-map 0:0 1:1
307
308 The configured socket priorities have to match ``UdpHighSocketPriority`` and
309 ``UdpLowSocketPriority`` in the yaml files.
310
311 .. Note:: In case the UDP communication does not work check the VLAN interface configurations. In
312 case it is still not working check whether the system uses a firewall which filters UDP
313 communication on the configured ports.