Cisco TRex Traffic Generator

October 24, 2018

For some networking tasks traffic generation is needed but sadly not every engineer has an IXIA or Spirent to hand.

An open source alternative does exist called TRex and it supports both stateful and stateless traffic of up to 200Gb/sec which is fair amount. This said one thing to note is that will require some serious compute for 200Gb/sec.

"TRex is an open source, low cost, stateful and stateless traffic generator fuelled by DPDK. It generates L4-7 traffic based on pre-processing and smart replay of real traffic templates . TRex amplifies both client and server side traffic and can scale up to 200Gb/sec with one UCS.

TRex Stateless functionality includes support for multiple streams, the ability to change any packet field and provides per stream statistics, latency and jitter.

Advanced Stateful functionality includes support for emulating L7 traffic with fully-featured scalable TCP layer." -

This is just a simple into and

The order of this post:

  1. My setup
  2. TRex installation
  3. Setting up the ports
  4. Running a simple stateless traffic profile

There is a vast amount documentation at here but this post is just how to simply get it up and running for more complex scenarios rtfm.


Supermicro Server Summary

Processor: 8x Intel(R) Xeon(R) CPU E3-1240 v5 @ 3.50GHz
Memory: 32766MB (4686MB used)
Network Card: Intel Corporation Ethernet Controller 10G X550T
Operating System: Ubuntu 16.04.4 LTS

Physical Setup

The setup itself is simple, both 10Gb NICs plugged into a switch using cat7e ethernet cables. For this demo traffic will be sent from port one to port zero via the switch but this can also be done by connecting the two ports together directly (in a kinda loopback).


sudo mkdir -p /opt/trex
sudo cd /opt/trex
sudo wget --no-cache
sudo tar -xzvf latest
test@ubuntu:/opt/trex$ sudo mkdir -p /opt/trex
test@ubuntu:/opt/trex$ sudo cd /opt/trex
test@ubuntu:/opt/trex$ sudo wget --no-cache

--2018-06-22 10:20:53--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 195168924 (186M) [application/x-tar]
Saving to: ‘latest’

latest                                        100%[=====================================================================================================>] 186.13M  25.0MB/s    in 8.2s

2018-06-22 10:21:01 (22.8 MB/s) - ‘latest’ saved [195168924/195168924]

laszlo@ubuntu:/opt/trex$ sudo tar -xzvf latest

<<output omitted>>

test@ubuntu:/opt/trex$ ls
latest  v2.41

Now installed we can begin to actually run some traffic. TRex can be used and configured in many ways but this will just be a simple demonstration.

Setting Up TRex

Before doing anything it is firstly important to look at what ports are available. Next we need to assign the ports from the Linux kernel to the application.

cd v2.41/
sudo ./ -s

Here all available ports can be seen

The two ports circled in red are the ones we wish to use.

cd v2.41/
sudo ./ -i

I am using an IP based configuration (layer3). Circled in red are the questions asked, I add port ID 0 and 1 to the configuration and assign IP address/Gateways. I am just using the defaults for this demo.

The configuration is save in /etc/trex_cfg.yaml. Once this is completed you will notice they are no longer available to the Linux kernel (ip link shows this). If you would like to release them back to the kernel do sudo ./ -l.

Running Stateless Traffic

Running TRex so that it produces stateless traffic is slightly different to how stateful traffic works, it's a more server/client orientated design.

For the purpose of this demo I am going to show the CLI/TRex Console method.

Setting Up The Server

This will require you to create two SSH session with your server as shown below.

Session one isn't doing to much, just run these commands to start the TRex server.

cd /opt/trex/v2.41
sudo ./t-rex-64 -i

You'll be presented with this screen

Setting Up The Client

Now the server is running we can now enter the console and begin to run some traffic.

cd /opt/trex/v2.41

There are several console options that are available .

But for this post we are just going to run a simple traffic profile using start -f stl/.

This start command is used to start the flow (no kidding...) -f loads a traffic profile in and stl/ is where the traffic profiles are located which you can see below.

For this traffic flow I am using this command start -f stl/ -d 1h -m 100% -p 1. This using the traffic profile for a duration of 1 hour -d 1h and the multipler and port command to run the port ones interface at 100% utilisation -m 100% -p 1.

After we start traffic running we can enter tui into our console and this gives us the output below, a live look at the traffic stats.

You can see that port one is sending 7.55 Gbps of L2 traffic, 9.91Gbps of L1 and is at 99.05% utilisation. It also shows the port zero is recieving the same.

To return to the TRex console do ESC then q and finally to stop the traffic flow enter stop -a.

This was a really basic into to TRex but I hope somebody finds it slightly useful. A hint, if you are using this in a layer3 environment make sure to add static routes for the server and client pools.

Share on Google+