Skip to main content
Version: 7.26

Traffic Generator

Traffic Generator is a tool that allows evaluating the performance of a DUT (Device Under Test) or SUT (System Under Test).

The tool can generate and send raw packets over specific ports. It also collects latency and jitter values, TX/RX rates, counts lost packets, and detects Out-of-Order (OOO) packets.

Traffic Generator can be used similarly to the bandwidth test tool, as well as to generate packets that will be routed back to the packet generator for advanced status collection.

All properties and commands of the traffic generator are described in the /tool/traffic-generator CLI reference.

info

On a device that generates packets, packets generated by the traffic generator cannot be captured with a sniffer tool, torch, or firewall on the outgoing interface.

Because this tool can be used maliciously, it is disabled by default in every device mode. While traffic-gen is disabled, quick fails with a not allowed by device-mode error. Run /system/device-mode/print to check the current value. To enable it, run /system/device-mode/update traffic-gen=yes and confirm the change within the activation timeout (5 minutes by default) with physical access to the device: press the reset or mode button, or unplug the power. The device reboots after the confirmation; a regular reboot cancels the change. See Change device-mode.

General​

Sub-menu: /tool/traffic-generator

This menu holds the overall traffic generator settings: the test-id of the current measurement session, whether Out-of-Order (OOO) packets are measured (measure-out-of-order), the maximum latency range of the latency distribution (latency-distribution-max) and how many statistics samples are kept (stats-samples-to-keep). It also shows whether the generator is running (running) and the current latency measurement range (latency-distribution-measure-interval, latency-distribution-samples).

Commands​

CommandDescription
quickStarts the packet generator, prints the statistics to the terminal and assembles the latency/jitter report. Accepts parameters that override the packet template and stream settings: cpu-core, entries-to-show, id, interface, mbps, measure-out-of-order, packet-count, packet-size, port, pps, stream, test-id, tx-template. Parameters specified when running the quick command override configured values; if a parameter is specified only for one header, the value is multiplied for all the other headers (if required).
startStarts the traffic generator in the background. Accepts the same override parameters as quick, except entries-to-show (there is no terminal output).
stopStops the background traffic generator started with the start command.
injectInjects raw data into an interface.
inject-pcapReplays packets from a PCAP or PCAPNG file on an interface. The sniffer tool saves captures in PCAPNG format, which the traffic generator supports.

Packet Template​

Sub-menu: /tool/traffic-generator/packet-template

This sub-menu builds the packet content of a stream from header parameters. Based on the parameters you can build IP packets with VLAN tags, set UDP or TCP ports, or build IPv6 packets. A raw packet template is generated from the provided parameters. The full parameter list is described in the packet-template CLI reference.

If you need more low-level packets or want to take full advantage of the traffic generator, use a raw-packet-template builder to build the packet.

If the same type of header is present in the packet more than once, header field values are passed as a comma-separated list. For example, if there are two IP headers, source addresses are given like ip-src=1.1.1.1,2.2.2.2.

For quicker header construction, many header field values are assumed. For example, if the header stack is "mac, ip", the traffic generator assumes that the mac-protocol value is "ip". Or if the "port" or "interface" setting is specified, the traffic generator assumes "mac-src" to be the MAC address of the interface. Assumed values have distinct names that start with "assumed-" and are read-only. Manually specified values override assumed ones.

info

Assumed values are not automatically updated. New values are assumed after a template edit — /tool/traffic-generator/packet-template/set [find] is enough to trigger new assumed values.

The header-stack property defines the sequence of headers in the generated packet. It supports mac (Ethernet, 14 bytes), vlan (802.1Q tag, 4 bytes), ip (IPv4, 20 bytes), udp (UDP, 8 bytes), raw (arbitrary bytes as a hex string), ipv6 (IPv6, 40 bytes) and tcp (TCP, variable length). Sequence limitations follow protocol rules — for example, a VLAN header can follow only a mac header or another VLAN header; at most two IP headers and one UDP header are allowed per packet. Further limitations (for example, on repeated IPv6 or TCP headers) are validated when the template is created. The traffic generator suggests the first header for a packet template (in the port menu), but the first header is not enforced.

Port Configuration​

Sub-menu: /tool/traffic-generator/port

This menu configures ports that bind an interface to the traffic generator for transmitting and receiving generated packets. A port entry is created automatically (dynamic) when a packet template specifies only an interface. The disabled flag (see the CLI reference) stops the port from transmitting and receiving; the examples set it to disabled=no to be explicit. The read-only first-header property of a port shows the suggested first header for packets sent out of that interface: mac, vlan, ip, udp, raw, ipv6 or tcp. All properties and flags are described in the port CLI reference.

Stats​

Sub-menu: /tool/traffic-generator/stats

If the traffic generator is not running in quick mode, all statistics about the test are stored in this menu without being printed to the terminal.

Latency Distribution​

Sub-menu: /tool/traffic-generator/stats/latency-distribution

This sub-menu shows how many packets were received in a specific latency range. The latency range can be viewed by streams or by sequences, for example print stream-id=3 or print seq=10.

Here is an example output of the latency graph:

[admin@test-host] /tool/traffic-generator/stats/latency-distribution> print
# LATENCY COUNT SHARE GRAPH
0 0-15.5us 0 0%
1 15.5us-31us 0 0%
2 31us-46.5us 0 0%
3 46.5us-62.1us 0 0%
4 62.1us-77.6us 0 0%
5 77.6us-93.1us 0 0%
6 93.1us-109us 0 0%
7 109us-124us 0 0%
8 124us-140us 0 0%
9 140us-155us 0 0%
10 155us-171us 0 0%
11 171us-186us 4 0% *
12 186us-202us 29 0% *
13 202us-217us 90 0.001% *
14 217us-233us 302 0.004% *
15 233us-248us 630 0.009% *
16 248us-264us 789 0.011% *
17 264us-279us 1 384 0.021% -*
18 279us-295us 1 990 0.03% --*
19 295us-310us 2 966 0.045% ---*
20 310us-326us 4 089 0.062% -----*
21 326us-341us 4 958 0.075% ------*
22 341us-357us 6 059 0.091% -------*
23 357us-372us 6 660 0.101% --------*
24 372us-388us 8 320 0.126% ----------*
25 388us-403us 9 988 0.151% -------------*
26 403us-419us 11 781 0.178% ---------------*
27 419us-434us 12 512 0.189% ----------------*
28 434us-450us 13 836 0.21% -----------------*
29 450us-465us 15 681 0.238% --------------------*
30 465us-481us 17 740 0.269% ----------------------*
31 481us-496us 19 913 0.302% --------------------------*
32 496us-512us 21 106 0.32% ---------------------------*
33 512us-528us 22 848 0.346% -----------------------------*
34 528us-543us 25 059 0.38% --------------------------------*
35 543us-559us 26 593 0.403% ----------------------------------*
36 559us-574us 27 663 0.419% -----------------------------------*
37 574us-590us 29 351 0.445% -------------------------------------*
38 590us-605us 31 265 0.474% ----------------------------------------*
39 605us-621us 33 224 0.504% -------------------------------------------*
40 621us-636us 34 464 0.523% --------------------------------------------*
41 636us-652us 35 630 0.54% ----------------------------------------------*
42 652us-667us 37 245 0.565% ------------------------------------------------*
43 667us-683us 38 158 0.579% -------------------------------------------------*
44 683us-698us 38 626 0.586% --------------------------------------------------*
45 698us-714us 38 985 0.591% --------------------------------------------------*
46 714us-729us 39 061 0.592% --------------------------------------------------*
47 729us-745us 39 750 0.603% ---------------------------------------------------*
48 745us-760us 39 145 0.594% --------------------------------------------------*
49 760us-776us 39 162 0.594% --------------------------------------------------*
50 776us-791us 38 197 0.579% -------------------------------------------------*
51 791us-807us 37 811 0.573% -------------------------------------------------*
52 807us-822us 37 364 0.567% ------------------------------------------------*
53 822us-838us 36 770 0.558% -----------------------------------------------*
54 838us-853us 35 831 0.543% ----------------------------------------------*
55 853us-869us 35 380 0.536% ----------------------------------------------*
56 869us-884us 34 472 0.523% --------------------------------------------*
57 884us-900us 33 672 0.511% -------------------------------------------*
58 900us-915us 33 799 0.513% --------------------------------------------*
59 915us-931us 32 754 0.497% ------------------------------------------*
60 931us-946us 32 339 0.49% ------------------------------------------*
61 946us-962us 32 419 0.492% ------------------------------------------*
62 962us-977us 32 107 0.487% -----------------------------------------*
63 977us-993us 31 552 0.478% -----------------------------------------*
64 0-993us 1 221 523 18.54%

The columns are described in the latency-distribution CLI reference.

Stream Stats​

Sub-menu: /tool/traffic-generator/stats/stream

This sub-menu stores statistics sorted by streams. The output is the same as in quick mode.

[admin@test-host] /tool/traffic-generator/stats/stream> print
# SEQ ID TX-PACKET TX-RATE RX-PACKET RX-RATE LOST-PACKET LOST-RATE
0 1 3 43 064 499.5Mbps 25 180 292.0Mbps 17 884 207.4Mbps
1 1 4 43 062 499.5Mbps 39 946 463.3Mbps 3 116 36.1Mbps
2 1 TOT 86 126 999.0Mbps 65 126 755.4Mbps 21 000 243.6Mbps
3 2 3 43 544 505.1Mbps 30 449 353.2Mbps 13 095 151.9Mbps
4 2 4 43 543 505.0Mbps 42 982 498.5Mbps 561 6.5Mbps
5 2 TOT 87 087 1010.2... 73 431 851.7Mbps 13 656 158.4Mbps

...

59 20 TOT 87 277 1012.4... 73 755 855.5Mbps 13 522 156.8Mbps
60 21 3 43 546 505.1Mbps 30 605 355.0Mbps 12 941 150.1Mbps
61 21 4 43 546 505.1Mbps 42 682 495.1Mbps 864 10.0Mbps
62 21 TOT 87 092 1010.2... 73 287 850.1Mbps 13 805 160.1Mbps
63 TOT 3 913 942 504.8Mbps 629 210 347.5Mbps 284 732 157.2Mbps
64 TOT 4 913 939 504.8Mbps 898 374 496.2Mbps 15 565 8.5Mbps
65 TOT TOT 1 827 881 1009.6... 1 527 584 843.8Mbps 300 297 165.8Mbps

Port Stats​

Sub-menu: /tool/traffic-generator/stats/port

This sub-menu stores statistics sorted by rx/tx ports.

[admin@test-host] /tool/traffic-generator/stats/port> print
# SEQ PORT RX-UNK-PACKET RX-UNK-BYTE RX-UNK... TX-PACKET TX-RATE RX-PACKET
0 1 port0:et... 0 0 0bps 43 064 499.5Mbps 39 946
1 1 port1:et... 0 0 0bps 43 062 499.5Mbps 25 180
2 1 TOT 0 0 0bps 86 126 999.0Mbps 65 126
3 2 port0:et... 0 0 0bps 43 544 505.1Mbps 42 982
4 2 port1:et... 0 0 0bps 43 543 505.0Mbps 30 449
5 2 TOT 0 0 0bps 87 087 1010.2... 73 431
6 3 port0:et... 0 0 0bps 43 540 505.0Mbps 42 615
7 3 port1:et... 0 0 0bps 43 540 505.0Mbps 30 191
8 3 TOT 0 0 0bps 87 080 1010.1... 72 806

Raw Stats​

Sub-menu: /tool/traffic-generator/stats/raw

This sub-menu stores raw statistics data.

[admin@test-host] /tool/traffic-generator/stats/raw> print
# SEQ PORT ID TX-PACKET TX-RATE RX-PACKET RX-RATE LOST-PACKET LOST-RATE
0 1 port0:e... 3 43 064 499.5Mbps 0 0bps 43 064 499.5Mbps
1 1 port1:e... 3 0 0bps 25 180 292.0Mbps -25 180 292.0Mbps
2 1 TOT 3 43 064 499.5Mbps 25 180 292.0Mbps 17 884 207.4Mbps
3 1 port0:e... 4 0 0bps 39 946 463.3Mbps -39 946 463.3Mbps
4 1 port1:e... 4 43 062 499.5Mbps 0 0bps 43 062 499.5Mbps
5 1 TOT 4 43 062 499.5Mbps 39 946 463.3Mbps 3 116 36.1Mbps
6 1 port0:e... TOT 43 064 499.5Mbps 39 946 463.3Mbps 3 118 36.1Mbps
7 1 port1:e... TOT 43 062 499.5Mbps 25 180 292.0Mbps 17 882 207.4Mbps
8 2 port0:e... 3 43 544 505.1Mbps 0 0bps 43 544 505.1Mbps
9 2 port1:e... 3 0 0bps 30 449 353.2Mbps -30 449 353.2Mbps
10 2 TOT 3 43 544 505.1Mbps 30 449 353.2Mbps 13 095 151.9Mbps

All statistics columns (seq, id, tx/rx counters and rates, out-of-order, bad-checksum, lost, latency and jitter) are described in the stream, port and raw CLI reference pages.

Streams​

Sub-menu: /tool/traffic-generator/stream

A stream defines the generated traffic: the packet template used (tx-template, mandatory) and the port it is transmitted through (port, usually taken from the template), the transmission rate (pps and/or mbps), the L2 packet size (packet-size, can be a range for random sizes), how many packets to transmit (packet-count) and the CPU core (or core range) the stream is pinned to (cpu-core, for multi-core tests). Its read-only default-port shows the port the stream transmits on, derived from the template. All properties are described in the stream CLI reference.

Each stream has a unique id (the old property name num is no longer used) that identifies its packets in the statistics and in the start and quick commands.

Configuration Examples​

IPsec tunnel performance test​

Consider the following test setup:

Traffic generator IPsec test setup

System Under Test (SUT) consists of two routers connected to a traffic generator server. The connection between both SUT routers is IPSec encrypted.

The traffic generator will run two streams:

  • In a direction from 1.1.1.0/24 network to 2.2.2.0/24 network.
  • In a direction from 2.2.2.0/24 network to 1.1.1.0/24 network.

R1 routing and IPsec setup​

/ip/address
add address=192.168.33.1/30 interface=ether1
add address=1.1.1.2/24 interface=ether2

/ip/route
add dst-address=2.2.2.0/24 gateway=192.168.33.2

/ip/ipsec/proposal
set default enc-algorithms=aes-128-cbc

/ip/ipsec/peer
add address=192.168.33.2 secret=123

/ip/ipsec/policy
add sa-src-address=192.168.33.1 sa-dst-address=192.168.33.2 \
src-address=1.1.1.0/24 dst-address=2.2.2.0/24 tunnel=yes

R2 routing and IPsec setup​

/ip/address
add address=192.168.33.2/30 interface=ether1
add address=2.2.2.2/24 interface=ether2

/ip/route
add dst-address=1.1.1.0/24 gateway=192.168.33.1

/ip/ipsec/proposal
set default enc-algorithms=aes-128-cbc

/ip/ipsec/peer
add address=192.168.33.1 secret=123

/ip/ipsec/policy
add sa-src-address=192.168.33.2 sa-dst-address=192.168.33.1 \
src-address=2.2.2.0/24 dst-address=1.1.1.0/24 tunnel=yes

Traffic generator server setup​

/ip/address
add address=1.1.1.1/24 interface=ether2
add address=2.2.2.1/24 interface=ether3

First, define which ports will be used as traffic generator TX/RX ports:

/tool/traffic-generator/port
add disabled=no interface=ether2 name=port0
add disabled=no interface=ether3 name=port1

To construct the actual packet that will be generated, the packet-template is used:

/tool/traffic-generator/packet-template
add header-stack=mac,ip,udp ip-dst=2.2.2.1/32 ip-gateway=1.1.1.2 ip-src=1.1.1.1/32 \
name=routing-1 port=port0
add header-stack=mac,ip,udp ip-dst=1.1.1.1/32 ip-gateway=2.2.2.2 ip-src=2.2.2.1/32 \
name=routing-2 port=port1

Notice that MAC addresses were not specified, since the template generator can assume the next-hop MAC address automatically by sending ARP messages. Since routing is performed and the destination IP is not directly reachable, the ip-gateway parameter is set to determine the next-hop MAC address.

When running print, you can see all assumed (detected) values, including MAC addresses:

[admin@test-host] /tool/traffic-generator/packet-template> print
0 name="routing-1" header-stack=mac,ip,udp port=port0
assumed-mac-dst=00:0C:42:00:38:9D assumed-mac-src=00:0C:42:40:94:25
assumed-mac-protocol=ip assumed-ip-dscp=0 assumed-ip-id=0
assumed-ip-frag-off=0 assumed-ip-ttl=64 assumed-ip-protocol=udp
ip-src=1.1.1.1/32 ip-dst=2.2.2.1/32 assumed-udp-src-port=100
assumed-udp-dst-port=200 ip-gateway=1.1.1.2 data=uninitialized data-byte=0

1 name="routing-2" header-stack=mac,ip,udp port=port1
assumed-mac-dst=00:0C:42:00:38:D1 assumed-mac-src=00:0C:42:40:94:26
assumed-mac-protocol=ip assumed-ip-dscp=0 assumed-ip-id=0
assumed-ip-frag-off=0 assumed-ip-ttl=64 assumed-ip-protocol=udp
ip-src=2.2.2.1/32 ip-dst=1.1.1.1/32 assumed-udp-src-port=100
assumed-udp-dst-port=200 ip-gateway=2.2.2.2 data=uninitialized data-byte=0

If any router in the SUT were to change, the assumed MAC addresses would not be updated automatically. To update packet templates, issue the command:

/tool/traffic-generator/packet-template/set [find]

The last part is to configure the streams:

/tool/traffic-generator/stream
add disabled=no mbps=500 name=str1 id=3 packet-size=1450 port=port0 pps=0 \
tx-template=routing-1
add disabled=no mbps=500 name=str3 id=4 packet-size=1450 port=port1 pps=0 \
tx-template=routing-2

Notice that each stream has a unique id value. This value identifies the stream packets; without it, the traffic generator will not work.

Now the test is ready to run. In this case, quick mode is used:

[admin@test-host] /tool/traffic-generator> quick mbps=450
SEQ ID TX-PACKET TX-RATE RX-PACKET RX-RATE RX-OOO LOST-PACKET LOST-RATE
37 4 39 488 458.0Mbps 39 270 455.5Mbps 15 509 218 2.5Mbps
37 TOT 78 976 916.1Mbps 76 485 887.2Mbps 22 529 2 491 28.8Mbps
38 3 38 957 451.9Mbps 37 657 436.8Mbps 7 078 1 300 15.0Mbps
38 4 38 958 451.9Mbps 38 402 445.4Mbps 14 763 556 6.4Mbps
38 TOT 77 915 903.8Mbps 76 059 882.2Mbps 21 841 1 856 21.5Mbps
39 3 38 816 450.2Mbps 37 893 439.5Mbps 7 307 923 10.7Mbps
39 4 38 815 450.2Mbps 38 642 448.2Mbps 15 110 173 2.0Mbps
39 TOT 77 631 900.5Mbps 76 535 887.8Mbps 22 417 1 096 12.7Mbps
40 3 39 779 461.4Mbps 37 415 434.0Mbps 7 136 2 364 27.4Mbps
40 4 39 780 461.4Mbps 39 567 458.9Mbps 15 908 213 2.4Mbps
40 TOT 79 559 922.8Mbps 76 982 892.9Mbps 23 044 2 577 29.8Mbps
41 3 39 218 454.9Mbps 37 089 430.2Mbps 7 075 2 129 24.6Mbps
41 4 39 218 454.9Mbps 38 663 448.4Mbps 15 752 555 6.4Mbps
41 TOT 78 436 909.8Mbps 75 752 878.7Mbps 22 827 2 684 31.1Mbps
42 3 39 188 454.5Mbps 37 906 439.7Mbps 6 729 1 282 14.8Mbps
42 4 39 187 454.5Mbps 38 954 451.8Mbps 15 565 233 2.7Mbps
42 TOT 78 375 909.1Mbps 76 860 891.5Mbps 22 294 1 515 17.5Mbps
TOT 3 1 645 468 454.4Mbps 1 568 201 433.1Mbps 280 174 77 267 21.3Mbps
TOT 4 1 645 464 454.4Mbps 1 626 896 449.3Mbps 627 480 18 568 5.1Mbps
TOT TOT 3 290 932 908.9Mbps 3 195 097 882.4Mbps 907 654 95 835 26.4Mbps

The stats show the throughput of each stream and the total throughput of both streams, the Out-of-Order packet count, the loss rate, latency and jitter.