How to Build : First install essentials for Trex
sudo apt -y install zlib1g-dev build-essential python python3-distutils
Note: you might need additional Linux packages for that:
-
yum based (Fedora, CentOS, RedHat):
sudo yum install kernel-devel-`uname -r`
sudo yum group install "Development tools"
-
apt based (Ubuntu):
sudo apt install linux-headers-`uname -r` build-essential
Then clone the repo from github
git clone https://github.com/cisco-system-traffic-generator/trex-core.git
cd trex-core/
cd linux_dpdk
./b configure (only once)
./b build
cd ..
sudo cp scripts/cfg/simple_cfg.yaml /etc/trex_cfg.yaml
Find out the PCI IDs of the interfaces to be used by Trex.
lspci | grep Eth
or by
./dpdk-devbind -s
Edit TRex config file by changing PCI ids.
sudo vim /etc/trex_cfg.yaml
By default congfig file looks like this :
- port_limit : 2
version : 2
#List of interfaces. Change to suit your setup. Use ./dpdk_setup_ports.py -s to see available options
interfaces : ["00:08.0","00:09.0"]
port_info : # Port IPs. Change to suit your needs. In case of loopback, you can leave as is.
- ip : 1.1.1.1
default_gw : 2.2.2.2
- ip : 2.2.2.2
default_gw : 1.1.1.1
Run server: Run TRex in a stateful mode.
cd scripts/
sudo ./t-rex-64 -i --astf
Run console: Generate HTTP flows.
cd scripts/
./trex-console
trex> start -f astf/http_simple.py -m 1000 -d 1000 -l 1000
trex> tui
Traffic profile (http_simple.py):
from trex_astf_lib.api import *
class Prof1():
def get_profile(self):
# ip generator
ip_gen_c = ASTFIPGenDist(ip_range=["10.10.10.0", "10.10.10.255"],
distribution="seq")
ip_gen_s = ASTFIPGenDist(ip_range=["20.20.20.0", "20.20.20.255"],
distribution="seq")
ip_gen = ASTFIPGen(glob=ASTFIPGenGlobal(ip_offset="1.0.0.0"),
dist_client=ip_gen_c,
dist_server=ip_gen_s)
return ASTFProfile(default_ip_gen=ip_gen,
cap_list=[ASTFCapInfo(
file="../avl/delay_10_http_browsing_0.pcap"
cps=1)
])
def register():
return Prof1()
Monitor flow statistics by pressing “Esc” and “t” buttons in “tui” mode.
for receiving Rx from different vm:
1) allow promiscious mode in vmware
2) allow forged transmits
3) sudo ./t-rex-64 -i
4) sudo ./trex-console
5) portattr -p 0 --prom on
6) start -f stl/imix.py -m 8000mbps
for sending you own pcap file:
in sudo ./trex-console run :
push -r --port 0 -f <path to pcap>
push -r --port 0 -f <path to pcap> -i 100 -c 1 //for c=1 thread ,-i=100 (latency)to give slow transmission rate,i=0.001 will give faster speed
sudo ./t-rex-64 -i --no-scapy-server
For any queries about trex you can always check this google mail group https://groups.google.com/g/trex-tgn