Trex简单测试

注意

  1. trex主机与dut主机第一个network为管理网,第二个与第三个network为测试用网,trex主机与dut主机测试用网eth1互联,trex主机与dut主机测试用网eth2互联;

  2. 只可运行net_set.sh 一次,获得mac地址,若mac地址全为0,重启trex主机;

  3. 测试项可在run_trex.sh修改(-m 参数为几万pps -d参数为测试时间)。

步骤

  1. 打开trex主机 运行trex_set.sh 并得到两个mac地址fa:ad:96:2e:3c:01 fa:0b:32:14:a9:02;
  2. 打开dut主机运行 dut_set.sh fa:ad:96:2e:3c:01 fa:0b:32:14:a9:02;
  3. 打开trex主机运行run_trex.sh ,等待运行结束得到trex结果。

镜像地址

dut:http://192.168.200.100/mirror/longtao.wu/image_store/linux_image/wlt-simpletrextest-dut.qcow2

trex:http://192.168.200.100/mirror/longtao.wu/image_store/linux_image/wlt-simpletrextest-trex.qcow2

脚本

dut_set.sh

1
2
3
4
5
6
7
8
9
ip link set dev eth1 up
ip link set dev eth2 up
ip a add 192.168.155.3/24 dev eth1
ip a add 192.168.166.5/24 dev eth2
ip r add 16.0.0.0/8 via 192.168.155.2
ip r add 48.0.0.0/8 via 192.168.166.4
ip n add 192.168.155.2 dev eth1 lladdr $0
ip n add 192.168.166.4 dev eth2 lladdr $1
echo 1 > /proc/sys/net/ipv4/ip_forward

net_set.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
a=(`ip a | grep ^[1-9] | awk -F: '{print $2}' | sed '1,2d'`)
for ((i=0;i<2;i++))
do
b[$i]=`ethtool -i ${a[$i]} |grep bus | awk -F ':' '{print $3 $4 $5}'|sed -e 's/../\0:/'`
done
for ((i=0;i<2;i++))
do
echo ${a[$i]} ${b[$i]}
done
for ((i=0;i<2;i++))
do
e[$i]=`ip link show ${a[$i]} |head -2|tail -1|awk '{print $2}'`
done
cp /root/trex/v2.81/cfg/simple_cfg.yaml /etc/trex_cfg.yaml.bak
sed '4,$d' /etc/trex_cfg.yaml.bak >/etc/trex_cfg.yaml
echo -e ' interfaces : ["'${b[0]}'","'${b[1]}'"]'>>/etc/trex_cfg.yaml
echo -e ' port_info : # Port IPs. Change to suit your needs. In case of loopback, you can leave as is.'>>/etc/trex_cfg.yaml
echo -e ' - ip : 192.168.155.2'>>/etc/trex_cfg.yaml
echo -e ' default_gw : 192.168.155.3'>>/etc/trex_cfg.yaml
echo -e ' - ip : 192.168.166.4'>>/etc/trex_cfg.yaml
echo -e ' default_gw : 192.168.166.5'>>/etc/trex_cfg.yaml
echo -e '\n\n'>>/etc/trex_cfg.yaml
cd ~/trex/v2.81/
./dpdk_setup_ports.py
# cat /etc/trex_cfg.yaml
cat /root/trex/v2.81/cfg/simple_cfg.yaml
cat /etc/trex_cfg.yaml
echo 'config success ! dont config again! if not configed please reboot your mechine and check your network sum is 2 and the last 2 network are connected.'
echo -e '\n'
echo ${e[0]}' '${e[1]}

run_trex.sh

1
cd /root/trex/v2.81; ./t-rex-64 -f cap2/imix_longtao_1w.yaml -m 5 -d 5