Some doc fixes for FAQ and per stream statistics
[trex.git] / doc / trex_faq.asciidoc
1 TRex Frequently Asked Questions
2 ================================
3 :author: TRex team
4 :email: trex.tgen@gmail.com 
5 :revnumber: 0.2
6 :quotes.++:
7 :numbered:
8 :web_server_url: http://trex-tgn.cisco.com/trex
9 :local_web_server_url: csi-wiki-01:8181/trex
10 :github_stl_path: https://github.com/cisco-system-traffic-generator/trex-core/tree/master/scripts/stl
11 :github_stl_examples_path: https://github.com/cisco-system-traffic-generator/trex-core/tree/master/scripts/automation/trex_control_plane/stl/examples
12 :toclevels: 6
13
14 include::trex_ga.asciidoc[]
15
16 // PDF version - image width variable
17 ifdef::backend-docbook[]
18 :p_width: 450
19 :p_width_1: 200
20 :p_width_1a: 100
21 :p_width_1c: 150
22 :p_width_lge: 500
23 endif::backend-docbook[]
24
25 // HTML version - image width variable
26 ifdef::backend-xhtml11[]
27 :p_width: 800
28 :p_width_1: 400
29 :p_width_1a: 650
30 :p_width_1a: 400
31 :p_width_lge: 900
32 endif::backend-xhtml11[]
33
34
35 == FAQ
36
37 ===  General 
38
39 ==== What is TRex?
40 TRex is fast realistic open source traffic generation tool, running on standard Intel processors, based on DPDK. It supports both stateful and stateless traffic generation modes.
41
42 ==== What are the common use cases for TRex?
43 1. High scale benchmarks for stateful networking gear. For example: Firewall/NAT/DPI.
44 2. Generating high scale DDOS attacks. See link:https://www.incapsula.com/blog/trex-traffic-generator-software.html[Why TRex is Our Choice of Traffic Generator Software]
45 3. High scale, flexible testing for switchs (e.g. RFC2544)- see link:https://wiki.fd.io/view/CSIT[fd.io]
46 4. Scale tests for huge numbers of clients/servers for controller based testing.
47 5. EDVT and production tests.
48
49 [NOTE]
50 =====================================
51 Features terminating TCP can not be tested yet.
52 =====================================
53
54 ==== Who uses TRex?
55
56 Cisco systems, Intel, Imperva, Melanox, Vasona networks and much more.
57
58 ==== What are the Stateful and Stateless modes of operation?
59
60 ``Stateful'' mode is meant for testing networking gear which save state per flow (5 tuple). Usually, this is done by injecting pre recorded cap files on pairs of interfaces of the device under test, changing src/dst IP/port. 
61 ``Stateless'' mode is meant to test networking gear, not saving state per flow (doing the decision on per packet bases). This is usually done by injecting customed packet streams to the device under test.
62 See link:trex_stateless.html#_stateful_vs_stateless[here] for more details.
63
64 ==== Can TRex run on an hypervisor with virtual NICS?
65
66 Yes. Currently there is a need for 2-3 cores and 4GB memory. For VM use case, memory requirement can be significantly reduced if needed (at the cost of supporting less concurrent flows)
67 by using the following link:trex_manual.html#_memory_section_configuration[configuration]
68
69 Limitations:
70
71 1. Performance is limited. For each NIC port pair, you can utilize only one CPU core.
72 2. Using vSwitch will limit the maximum PPS to around 1MPPS.
73 3. Latency results will not be accurate.
74           
75 ==== Why not all DPDK supported NICs supported by TRex?
76 1. We are using specific NIC features. Not all the NICs have the capabilities we need.
77 2. We have regression tests in our lab for each recommended NIC. We do not claim to support NICs we do not have in our lab.
78
79 ==== Is Cisco VIC supported?
80 Yes. Since version 2.12, with link:trex_manual.html#_cisco_vic_support[these limitations]. Especially note that
81 a new firmware version is needed.
82
83 ==== Is 100Gbs NIC QSFP+ supported?
84 Not yet. Support for FM10K and Mellanox Connectx5 is under development.
85
86 ==== Is there a GUI?
87 TRex team is not developing it.
88 You can find GUI for statless mode developed by Exalt company in 
89 link:https://github.com/exalt-tech/trex-stateless-gui#trex-stateless-gui-beta[this link]. +
90 There is also work in progress for packet editor (not released yet) in link:https://github.com/cisco-system-traffic-generator/trex-packet-editor[here]. +
91 New stateless GUI features are developed in link:https://github.com/cisco-system-traffic-generator/trex-stateless-gui[here]. This is also work in progress, not released yet.
92
93 ==== What is the maximum number of ports per TRex application?
94 12 ports
95
96 ==== I can not see all 12 ports statistics on TRex server .
97 We present statistics only for first four ports because there is no console space. Global statistics (like total TX) is correct, taking into account all ports.
98 You can use the GUI/console or Python API, to see statistics for all ports.
99
100 ==== Can I run multiple TRex servers on the same machine?
101 One option for running few instances on the same physical machine is to install few VMs.
102 Currently, it is complicated to do without using VMs (but possible with some advanced config file options). We are working on
103 a solution to make this easier.
104
105 ==== Can I use multiple types of ports with the same TRex server instance?
106 No. All ports in the configuration file should be of the same NIC type.
107
108 ==== What is better, running TRex on VM with PCI pass through or TRex on bare metal?
109 The answer depends on your budget and needs. Bare metal will have lower latency and better performance. VM has the advantages you normally get when using VMs.
110
111 ==== I want to report an issue.
112
113 You have two options: +
114 1. Send email to our support group: trex.tgen@gmail.com +
115 2. Open a defect at our link:https://trex-tgn.cisco.com/youtrack[youtrack]. You can also influence by voting in youtrack for an
116 existing issue. Issues with lots of voters will probably be fixed sooner.
117
118
119 ==== I have Intel X710 NIC with 4x10Gb/sec ports and I can not get line rate.
120 x710da4fh with 4 10G ports can reach a maximum of 40MPPS (total for all ports) with 64 bytes packets. (can not reach the theoretical 60MPPS limit).
121 This is still better than the Intel x520 (82559 based) which can reach ~30MPPS for two ports with one NIC.
122
123 ==== I have XL710 NIC with 2x40Gb/sec ports and I can not get line rate
124 XL710-da2 with 2 40G ports can reach maximum of 40MPPS/50Gb (total for all ports) and not 60MPPS with small packets (64B)
125 Intel had in mind redundancy use case when they produced a two port NIC. Card was not intended to reach 80G line rate.
126 see link:trex_stateless_bench.html[xl710_benchmark.html] for more info.
127
128 ====  How does TRex calculate the throughput and where is this part of source code located?
129 There is good answer in the mailing list link:https://groups.google.com/forum/#!topic/trex-tgn/Hk9IFJJ0KNs[here].
130
131 ==== I want to contribute to the project
132 You have several ways you can help: +
133 1. Download the product, use it, and report issues (If no issues, we will be very happy to also hear success stories). +
134 2. If you use the product and have improvment suggestions (for the product or documentation) we will be happy to hear. +
135 3. If you fix a bug, or develop new feature, you are more than welcome to create pool request in GitHub.
136
137 ==== What is the release process? How do I know when a new release is available?
138 It is a continuous integration. The latest internal version is under 24/7 regression on few setups in our lab. Once we have enough content we release it to GitHub (Usually every few weeks).
139 We do not send an email for every new release, as it could be too frequent for some people. We announce big feature releases on the mailing list. You can always check the GitHub of course.
140
141 ===  Startup and Installation
142
143 ==== Can I experiment with TRex without installing?
144 You can. Check the TRex sandbox at Cisco devnet in the following link:https://devnetsandbox.cisco.com/RM/Diagram/Index/2ec5952d-8bc5-4096-b327-c294acd9512d?diagramType=Topology[link].
145
146 ==== How do I obtain TRex, and what kind of hardware do I need?
147 You have several options. +
148 1. For playing around and experimenting, you can install TRex on VirtualBox by following this link:trex_vm_manual.html[link]. +
149 2. To run the real product, check link:trex_manual.html#_download_and_installation[here] for hardware recommendation and
150 installation instructions.
151
152 ==== During OS installation, screen is skewed / error "out of range" / resolution not supported etc.
153
154         * Fedora - during installation, choose "Troubleshooting" -> Install in basic graphic mode.
155         * Ubuntu - try Ubuntu server, which has textual installation.
156
157 ==== How to determine relation between TRex ports and device under test ports?
158
159 Run TRex with the below command and check incoming packet count on DUT interfaces.
160
161 [source,bash]
162 ----
163         sudo ./t-rex-64 -f cap2/dns.yaml --lm 1 --lo -l 1000 -d 100
164 ----
165
166 Alternatively, you can run TRex in stateless mode, send traffic from each port, and look at the counters on the DUT interfaces.
167
168 ==== How to determine relation between Virtual OS ports and Hypervisor ports?
169
170 Compare the MACs address + name of interface, for example:
171
172 [source,bash]
173 ----
174 > ifconfig
175 eth0    Link encap:Ethernet  HWaddr 00:0c:29:2a:99:b2
176           ...
177
178 > sudo ./dpdk_setup_ports.py -s
179 03:00.0 'VMXNET3 Ethernet Controller' if=eth0 drv=vmxnet3 unused=igb_uio
180 ----
181
182 [NOTE]
183 =====================================
184 If at TRex side the NICs are not visible to ifconfig, run: +
185 ....
186 sudo ./dpdk_nic_bind.py -b <driver name> <1> <PCI address> <2>
187 ....
188
189 <1> driver name - vmxnet3 for VMXNET3 and e1000 for E1000
190 <2> 03:00.0 for example
191
192 We are planning to add MACs to `./dpdk_setup_ports.py -s`
193 =====================================
194
195 ==== TRex traffic does not show up on Wireshark, so I can not capture the traffic from the TRex port
196 TRex uses DPDK which takes ownership of the ports, so using Wireshark is not possible. You can use switch with port mirroring to capture the traffic.
197
198 ===  Stateful 
199
200 ==== How do I start using the stateful mode?
201 You should first have a YAML configuration file. See link:trex_manual.html#_traffic_yaml_parameter_of_f_option[here].
202 Then, you can find some basic examples link:trex_manual.html#_trex_command_line[here].
203
204 ==== TRex is connected to a switch and I observe many dropped packets at TRex startup.
205 A switch might be configured with spanning tree enabled. TRex reset the port at startup, making the switch reset it side as well,
206 and spanning tree can drop the packets until it stabilizes.
207 Disabling spanning tree can help. On Cisco nexus, you can do that using `spanning-tree port type edge`
208 You can also start TRex with -k <num> flag. This will send packets for k seconds before starting the actual test, letting the spanning
209 tree time to stabilize.
210 This issue will be fixed when we consolidate ``Stateful'' and ``Stateless'' RPC.
211
212 ==== I can not see any RX packets.
213 Most common reason is problems with MAC addresses.
214 If your ports are connected in loopback, follow link:trex_manual.html#_configuring_for_loopback[this] carefully. +
215 If loopback worked for you, continue link:trex_manual.html#_configuring_for_running_with_router_or_other_l3_device_as_dut[here]. +
216 If you set MAC addresses manually in your config file, check again that they are correct. +
217 If you have ip and default_gw in your config file, you can debug the initial ARP resolution process by running TRex with
218 -d 1 flag (will stop TRex 1 second after init phase, so you can scroll up and look at init stage log), and -v 1.
219 This will dump the result of ARP resolution (``dst MAC:...''). You can also try -v 3.
220 This will print more debug info, and also ARP packets TX/RX indication and statistics. +
221 On the DUT side - If you configured static ARP, verify it is correct. If you depend on TRex gratuitous ARP messages, look at the DUT ARP
222 table after TRex init phase and verify its correctness.
223
224 ==== Why the performance is low?
225
226 TRex performance depends on many factors:
227
228 1. Make sure trex_cfg.yaml is optimal see "platform" section in manual 
229 2. More concurrent flows will reduce the performance 
230 3. Short flows with one/two packets (e.g. cap2/dns.yaml ) will give the worst performance 
231
232 ==== Is there a plan to add TCP stack?
233 Yes. We know this is something many people would like, and are working on this. No ETA yet. Once a progress is made, we will announce it on the TRex site and mailing list.
234
235 ==== How can I run the YAML profile and capture the results to a pcap file?
236 You can use the simulator. see link:trex_manual.html#_simulator[simulator]
237 The output of the simulator can be loaded to Excel. The CPS can be tuned.
238
239 ==== I want to have more acrive flows in TRex, how can I do this?
240 Default maximum supported flows is 1M (From TRex prespective. DUT might have much more due to slower aging). When active flows reach higher number, you will get ``out of memory'' error message
241
242 To increase the number of supported active flows, you should add ``dp_flows'' arg in config file ``memory'' section.
243 Look link:trex_manual.html#_memory_section_configuration[here] for more info.
244
245 .example of CFG file
246 [source,bash]
247 ----
248
249  - port_limit    : 4
250    version       : 2
251    interfaces    : ["02:00.0","02:00.1","84:00.0","84:00.1"]   # list of the interfaces to bind run ./dpdk_nic_bind.py --status
252    memory    :                                          
253         dp_flows    : 10048576    #<1>
254
255 ----
256 <1>  more flows 10Mflows 
257
258 ==== Loading a big YAML file raise an error  no enough memory for specific pool 2048?
259
260 You should increse the pool with that raise an error, for example in case of 2048  
261
262 .example of CFG file
263 [source,bash]
264 ----
265
266  - port_limit    : 4
267    version       : 2
268    interfaces    : ["02:00.0","02:00.1","84:00.0","84:00.1"]   # list of the interfaces to bind run ./dpdk_nic_bind.py --status
269    memory    :                                          
270         traffic_mbuf_2048   : 8000 #<1>
271
272 ----
273 <1>  for mbuf for 2038 
274
275 You can run TRex with `-v 7` to verify that the configuration has an effect
276
277
278
279 ==== I want to have more active flows on the DUT, how can I do this?
280 After stretching TRex to its maximum CPS capacity, consider the following: DUT will have much more active flows in case of a UDP flow due to the nature of aging (DUT does not know when the flow ends while TRex knows).
281 In order to artificialy increse the length of the active flows in TRex, you can config larger IPG in the YAML file. This will cause each flow to last longer. Alternatively, you can increase IPG in your PCAP file as well.
282
283 ==== I am getting an error: The number of ips should be at least number of threads.
284 The range of clients and servers should be at least the number of threads. 
285 The number of threads is equal to (number of port pairs) * (-c value)
286
287 ==== Some of the incoming frames are of type SCTP. Why?
288 Default latency packets are SCTP, you can omit the `-l <num>` from command line, or change it to ICMP. See the manual for more info.
289  
290 ===  Stateless 
291
292 ==== How do I get started with stateless mode?
293 You should first have a YAML configuration file. See link:trex_manual.html#_traffic_yaml_parameter_of_f_option[here].
294 Then, you can have a look at the stateless manual link:trex_stateless.html[here]. You can jump right into the link:trex_stateless.html#_tutorials[tutorials section].
295
296 ==== Is pyATS supported as client framework 
297
298 Yes. Both Python 3 and Python 2
299
300 ==== Python API does not work on my Mac with the below ZMQ library issue 
301
302 We are using Python ZMQ wrapper. It needs to be compiled per platform and we have a support for many platforms but not all of them.
303 You will need to build ZMQ for your platform if it is not part of the package.
304
305 [source,Python]
306 ----
307     from .trex_stl_client import STLClient, LoggerApi
308   File "../trex_stl_lib/trex_stl_client.py", line 7, in <module>
309     from .trex_stl_jsonrpc_client import JsonRpcClient, BatchMessage
310   File "../trex_stl_lib/trex_stl_jsonrpc_client.py", line 3, in <module>
311     import zmq
312   File "/home/shilwu/trex_client/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/__init__.py", line 32, in <module>
313     _libzmq = ctypes.CDLL(bundled[0], mode=ctypes.RTLD_GLOBAL)
314   File "/usr/local/lib/python2.7/ctypes/__init__.py", line 365, in __init__
315     self._handle = _dlopen(self._name, mode)
316 OSError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/shilwu/trex_client/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/libzmq.so.3)
317  
318 ----
319
320
321 ==== Is multi-user supported
322
323 Yes. Multiple TRex clients can connect to the same TRex server.
324
325 ==== Can I create corrupted packets?
326
327 Yes. You can build any packet you like using Scapy. 
328 However, there is no way to create corrupted L1 fields (Like Ethernet FCS), since these are usually handled by the NIC hardware.
329
330 ==== Why the performance is low?
331 Major things that can reduce the performance are:
332
333 1. Many concurent streams.
334 2. Complex field engine program.
335
336 Adding ``cache'' directive can improve the performance. See link:trex_stateless.html#_tutorial_field_engine_significantly_improve_performance[here]
337
338 and try this:
339
340 [source,bash]
341 ----
342 $start -f stl/udp_1pkt_src_ip_split.py -m 100% 
343 ----
344
345 [source,python]
346 ----
347
348  vm = STLScVmRaw( [   STLVmFlowVar ( "ip_src",
349                                             min_value="10.0.0.1",
350                                             max_value="10.0.0.255",
351                                             size=4, step=1,op="inc"),
352
353                              STLVmWrFlowVar (fv_name="ip_src",
354                                              pkt_offset= "IP.src" ),
355
356                              STLVmFixIpv4(offset = "IP")
357                          ],
358                          split_by_field = "ip_src",
359                          cache_size =255 # the cache size             <1>
360                         );
361 ----
362 <1> cache 
363
364
365 ==== I want to generate gratuitous ARP/NS IPv6.
366
367 See example link:trex_stateless.html#_tutorial_field_engine_many_clients_with_arp[here]
368
369 ==== How do I create deterministic random stream variable?
370
371 use `random_seed` per stream   
372
373 [source,python]
374 ----
375         return STLStream(packet = pkt,
376                          random_seed = 0x1234,
377                          mode = STLTXCont())
378 ----
379
380 ==== Can I have a synconization betwean different stream variables?
381
382 No. each stream has its own, seperate field engine program.
383
384
385 ==== Is there a plan to have LUAJit as a field engine program?
386
387 It is a great idea to add it, we are looking for someone to contribute this support.
388
389 ==== Java API instead of Python API 
390
391 Q:: I want to use the Python API via Java (with Jython), apparently, I can not import Scapy modules with Jython.
392 The way I see it I have two options:
393
394 1. Creating python scripts and call them from java (with ProcessBuilder for example)
395 2. Call directly to the TRex server over RPC from Java
396
397 However, option 2 seems like a re-writing the API for Java (which I am not going to do)
398 On the other hand, with option 1, once the script is done, the client object destroyed and I cannot use it anymore in my tests.
399
400 Any ideas on what is the best way to use TRex within JAVA?
401
402 A:: 
403
404 The power of our Python API is the scapy integration for simple building of the packets and the field engine.
405 There is a proxy over RPC that you can extend to your use cases. It has basic functionality, like connect/start/stop/get_stats.
406 You could use it to send some pcap file via ports, or so-called python profiles, which you can configure by passing different variables (so-called tunabels) via the RPC.
407 Take a look at link:trex_stateless.html#_using_stateless_client_via_json_rpc[using_stateless_client_via_json_rpc].
408 You can even dump the profile as a string and move it to the proxy to run it (Notice that it is a potential security hole, as you allow outside content to run as root on the TRex server).
409
410 See link:https://github.com/zverevalexei/trex-http-proxy[here] an example for simple Web server proxy for interacting with TRex.
411
412 ==== Where can I find a reference to RFC2544 using TRex
413
414 link:https://gerrit.fd.io/r/gitweb?p=csit.git;a=tree;f=resources;hb=HEAD[here]
415
416
417 ==== Are you recommending TRex HLTAPI ?
418 TRex has minimal and basic support for HLTAPI. For simple use cases (without latency and per stream statistic) it will probably work. For advanced use cases, there is no replacement for native API that has full control and in most cases is simpler to use.
419
420 ==== Can I test Qos using TRex ?
421 Yes. Using Field Engine you can build streams with different TOS and get statistic/latency/jitter per stream
422
423 ==== What are the supported routing protocols TRex can emulate?
424 For now, none. You can connect your router to a switch with TRex and a machine running routem. Then, inject routes using routem, and other traffic using TRex.
425
426 ==== Latency and per stream statistics
427 ===== Does latency stream support full line rate?
428 No. latency streams are handled by rx software and there is only one core to handle the traffic. 
429 To workaround this you could create one stream in lower speed for latency (e.g. PPS=1K) and another one of the same type without latency. The latency stream will sample the DUT queues. For example, if the required latency resolution is 10usec there is no need to send a latency stream in speed higher than 100KPPS- usually queues are built over time, so it is not possible that one packet will have a latency and another packet in the same path will not have the same latency. The none latency stream could be in full line rate (e.g. 100MPPS) 
430
431 .Example
432 [source,Python]
433 --------
434         stream = [STLStream(packet = pkt,
435                             mode = STLTXCont(pps=1)),                                   <1>
436
437
438                   # latency stream   
439                   STLStream(packet = pkt,
440                             mode = STLTXCont(pps=1000),                                 <2>
441                             flow_stats = STLFlowLatencyStats(pg_id = 12+port_id))
442 --------
443 <1> non latency stream will be amplified 
444 <2> latency stream, the speed will be constant 1KPPS
445
446
447 ===== Latency stream has constant rate of 1PPS, and is not getting amplified by multiplier. Why?
448 Reason for this (besides being a CPU constrained feature) is that most of the time, the use case is that you load the DUT using some traffic streams, and check latency
449 using different streams. The latency stream is kind of ``testing probe'' which you want to keep at constant rate, while playing with the rate of your other (loading) streams.
450 So, you can use the multiplier to amplify your main traffic, without changing your ``testing probe''.
451
452 When you have the following example:
453
454 [source,Python]
455 --------
456         stream = [STLStream(packet = pkt,
457                             mode = STLTXCont(pps=1)),                                   <1>
458
459
460                   # latency stream   
461                   STLStream(packet = STLPktBuilder(pkt = base_pkt/pad_latency),
462                             mode = STLTXCont(pps=1000),                                 <2>
463                             flow_stats = STLFlowLatencyStats(pg_id = 12+port_id))
464 --------
465 <1> non latency stream
466 <2> latency stream 
467  
468
469 If you speicify a multiplier of 10KPPS in start API, the latency stream (#2) will keep the rate of 1000 PPS and will not be amplified.
470
471 If you do want to amplify latency streams, you can do this using ``tunables''.
472 You can add in the Python profile a ``tunable'' which will specify the latency stream rate and you can provide it to the ``start'' command in the console or in the API.
473 Tunables can be added through the console using ``start ... -t latency_rate=XXXXX''
474 or using the Python API directly (for automation):
475 STLProfile.load_py(..., latency_rate = XXXXX)
476 You can see example for defining and using tunables link:trex_stateless.html#_tutorial_advanced_traffic_profile[here].
477
478
479 ===== Latency and per stream statistics are not supported for all packet types.
480
481 Correct. We use NIC capabilities for counting the packets or directing them to be handled by software. Each NIC has its own capabilities. Look link:trex_stateless.html#_tutorial_per_stream_statistics[here] for per stream statistics and link:trex_stateless.html#_tutorial_per_stream_latency_jitter_packet_errors[here] for latency details.
482
483 ===== I use per stream statistics on x710/xl710 card and rx-bps counter from python API (and rx bytes releated counters in console)
484 always show N/A
485
486 This is because on these card types, we use hardware counters (as opposed to counting in software in other card types).
487 While this allows for counting of full 40G line rate streams, this does not allow for counting bytes (only packet
488 count available), because the hardware on these NICs lacks this support.
489
490
491
492