Report: update 3n-alt TG NICs and add picture
[csit.git] / docs / report / introduction / methodology_trex_traffic_generator.rst
1 TRex Traffic Generator
2 ----------------------
3
4 Usage
5 ~~~~~
6
7 `TRex traffic generator <https://trex-tgn.cisco.com>`_ is used for majority of
8 CSIT performance tests. TRex is used in multiple types of performance tests,
9 see :ref:`data_plane_throughput` for more detail.
10
11 TRex is installed and run on the TG compute node.
12 Versioning, installation and startup is documented in
13 :ref:`test_environment_tg`.
14
15 Traffic modes
16 ~~~~~~~~~~~~~
17
18 TRex is primarily used in two (mutually incompatible) modes.
19
20 Stateless mode
21 ______________
22
23 Sometimes abbreviated as STL.
24 A mode with high performance, which is unable to react to incoming traffic.
25 We use this mode whenever it is possible.
26 Typical test where this mode is not applicable is NAT44ED,
27 as DUT does not assign deterministic outside address+port combinations,
28 so we are unable to create traffic that does not lose packets
29 in out2in direction.
30
31 Measurement results are based on simple L2 counters
32 (opackets, ipackets) for each traffic direction.
33
34 Stateful mode
35 _____________
36
37 A mode capable of reacting to incoming traffic.
38 Contrary to the stateless mode, only UDP and TCP is supported
39 (carried over IPv4 or IPv6 packets).
40 Performance is limited, as TRex needs to do more CPU processing.
41 TRex suports two subtypes of stateful traffic,
42 CSIT uses ASTF (Advanced STateFul mode).
43
44 This mode is suitable for NAT44ED tests, as clients send packets from inside,
45 and servers react to it, so they see the outside address and port to respond to.
46 Also, they do not send traffic before NAT44ED has created the corresponding
47 translation entry.
48
49 When possible, L2 counters (opackets, ipackets) are used.
50 Some tests need L7 counters, which track protocol state (e.g. TCP),
51 but those values are less than reliable on high loads.
52
53 Traffic Continuity
54 ~~~~~~~~~~~~~~~~~~
55
56 Generated traffic is either continuous, or limited (by number of transactions).
57 Both modes support both continuities in principle.
58
59 Continuous traffic
60 __________________
61
62 Traffic is started without any data size goal.
63 Traffic is ended based on time duration, as hinted by search algorithm.
64 This is useful when DUT behavior does not depend on the traffic duration.
65 The default for stateless mode.
66
67 Limited traffic
68 _______________
69
70 Traffic has defined data size goal (given as number of transactions),
71 duration is computed based on this goal.
72 Traffic is ended when the size goal is reached,
73 or when the computed duration is reached.
74 This is useful when DUT behavior depends on traffic size,
75 e.g. target number of NAT translation entries, each to be hit exactly once
76 per direction.
77 This is used mainly for stateful mode.
78
79 Traffic synchronicity
80 ~~~~~~~~~~~~~~~~~~~~~
81
82 Traffic can be generated synchronously (test waits for duration)
83 or asynchronously (test operates during traffic and stops traffic explicitly).
84
85 Synchronous traffic
86 ___________________
87
88 Trial measurement is driven by given (or precomputed) duration,
89 no activity from test driver during the traffic.
90 Used for most trials.
91
92 Asynchronous traffic
93 ____________________
94
95 Traffic is started, but then the test driver is free to perform
96 other actions, before stopping the traffic explicitly.
97 This is used mainly by reconf tests, but also by some trials
98 used for runtime telemetry.
99
100 Trafic profiles
101 ~~~~~~~~~~~~~~~
102
103 TRex supports several ways to define the traffic.
104 CSIT uses small Python modules based on Scapy as definitions.
105 Details of traffic profiles depend on modes (STL or ASTF),
106 but some are common for both modes.
107
108 Search algorithms are intentionally unaware of the traffic mode used,
109 so CSIT defines some terms to use instead of mode-specific TRex terms.
110
111 Transactions
112 ____________
113
114 TRex traffic profile defines a small number of behaviors,
115 in CSIT called transaction templates. Traffic profiles also instruct
116 TRex how to create a large number of transactions based on the templates.
117
118 Continuous traffic loops over the generated transactions.
119 Limited traffic usually executes each transaction once
120 (typically as constant number of loops over source addresses,
121 each loop with different source ports).
122
123 Currently, ASTF profiles define one transaction template each.
124 Number of packets expected per one transaction varies based on profile details,
125 as does the criterion for when a transaction is considered successful.
126
127 Stateless transactions are just one packet (sent from one TG port,
128 successful if received on the other TG port).
129 Thus unidirectional stateless profiles define one transaction template,
130 bidirectional stateless profiles define two transaction templates.
131
132 TPS multiplier
133 ______________
134
135 TRex aims to open transaction specified by the profile at a steady rate.
136 While TRex allows the transaction template to define its intended "cps" value,
137 CSIT does not specify it, so the default value of 1 is applied,
138 meaning TRex will open one transaction per second (and transaction template)
139 by default. But CSIT invocation uses "multiplier" (mult) argument
140 when starting the traffic, that multiplies the cps value,
141 meaning it acts as TPS (transactions per second) input.
142
143 With a slight abuse of nomenclature, bidirectional stateless tests
144 set "packets per transaction" value to 2, just to keep the TPS semantics
145 as a unidirectional input value.
146
147 Duration stretching
148 ___________________
149
150 TRex can be IO-bound, CPU-bound, or have any other reason
151 why it is not able to generate the traffic at the requested TPS.
152 Some conditions are detected, leading to TRex failure,
153 for example when the bandwidth does not fit into the line capacity.
154 But many reasons are not detected.
155
156 Unfortunately, TRex frequently reacts by not honoring the duration
157 in synchronous mode, taking longer to send the traffic,
158 leading to lower then requested load offered to DUT.
159 This usualy breaks assumptions used in search algorithms,
160 so it has to be avoided.
161
162 For stateless traffic, the behavior is quite deterministic,
163 so the workaround is to apply a fictional TPS limit (max_rate)
164 to search algorithms, usually depending only on the NIC used.
165
166 For stateful traffic the behavior is not deterministic enough,
167 for example the limit for TCP traffic depends on DUT packet loss.
168 In CSIT we decided to use logic similar to asynchronous traffic.
169 The traffic driver sleeps for a time, then stops the traffic explicitly.
170 The library that parses counters into measurement results
171 than usually treats unsent packets/transactions as lost/failed.
172
173 We have added a IP4base tests for every NAT44ED test,
174 so that users can compare results.
175 If the results are very similar, it is probable TRex was the bottleneck.
176
177 Startup delay
178 _____________
179
180 By investigating TRex behavior, it was found that TRex does not start
181 the traffic in ASTF mode immediately. There is a delay of zero traffic,
182 after which the traffic rate ramps up to the defined TPS value.
183
184 It is possible to poll for counters during the traffic
185 (fist nonzero means traffic has started),
186 but that was found to influence the NDR results.
187
188 Thus "sleep and stop" stategy is used, which needs a correction
189 to the computed duration so traffic is stopped after the intended
190 duration of real traffic. Luckily, it turns out this correction
191 is not dependend on traffic profile nor CPU used by TRex,
192 so a fixed constant (0.112 seconds) works well.
193 Unfortunately, the constant may depend on TRex version,
194 or execution environment (e.g. TRex in AWS).
195
196 The result computations need a precise enough duration of the real traffic,
197 luckily server side of TRex has precise enough counter for that.
198
199 It is unknown whether stateless traffic profiles also exhibit a startup delay.
200 Unfortunately, stateless mode does not have similarly precise duration counter,
201 so some results (mostly MRR) are affected by less precise duration measurement
202 in Python part of CSIT code.
203
204 Measuring Latency
205 ~~~~~~~~~~~~~~~~~
206
207 If measurement of latency is requested, two more packet streams are
208 created (one for each direction) with TRex flow_stats parameter set to
209 STLFlowLatencyStats. In that case, returned statistics will also include
210 min/avg/max latency values and encoded HDRHistogram data.
211
212 ..
213     TODO: Mention we have added TRex self-test suites.