编译和安装
系统:centos7
下载:
- 官方版本,
wget https://github.com/cisco-system-traffic-generator/trex-core/archive/v2.29.tar.gz
- 支持nvgre版本,
https://github.com/lxu4net/trex-core/tree/feature_nvgre
编译trex:
|
|
可执行文件在scripts目录下面。
nat支持
修改源代码,src/bp_sim.h:3455行左右,原来是,
|
|
snat的修改(hard code了snat后的最高位是2.2.),
|
|
dnat的修改(hard code了dnat后的最高位是10.0.),
|
|
最后重新编译。
trex配置文件
以dnat测试为例,
端口的配置文件,
/etc/trex_cfg_dnat.yaml
1234567891011121314151617181920212223- port_limit : 2version : 2port_bandwidth_gb : 10interfaces : ["06:00.0","06:00.1"]port_info :- ip : 192.168.1.2default_gw : 192.168.1.15tunnels :type : 'nvgre'dl_dst : '68:05:CA:34:90:D4'dl_src : '6C:92:BF:27:3D:72'tun_id : 6057468tun_dst: '192.168.1.15'tun_src: [ 192.168.2.1,192.168.2.2,192.168.2.3,192.168.2.4,192.168.2.5,192.168.2.6,192.168.2.7,192.168.2.8,192.168.2.9,192.168.2.10,192.168.2.11,192.168.2.12,192.168.2.13,192.168.2.14,192.168.2.15,192.168.2.16,192.168.2.17,192.168.2.18,192.168.2.19,192.168.2.20,192.168.2.21,192.168.2.22,192.168.2.23,192.168.2.24,192.168.2.25,192.168.2.26,192.168.2.27,192.168.2.28,192.168.2.29,192.168.2.30,192.168.2.31,192.168.2.32,192.168.2.33,192.168.2.34,192.168.2.35,192.168.2.36,192.168.2.37,192.168.2.38,192.168.2.39,192.168.2.40,192.168.2.41,192.168.2.42,192.168.2.43,192.168.2.44,192.168.2.45,192.168.2.46,192.168.2.47,192.168.2.48,192.168.2.49,192.168.2.50,192.168.2.51,192.168.2.52,192.168.2.53,192.168.2.54,192.168.2.55,192.168.2.56,192.168.2.57,192.168.2.58,192.168.2.59,192.168.2.60,192.168.2.61,192.168.2.62,192.168.2.63,192.168.2.64,192.168.2.65,192.168.2.66,192.168.2.67,192.168.2.68,192.168.2.69,192.168.2.70,192.168.2.71,192.168.2.72,192.168.2.73,192.168.2.74,192.168.2.75,192.168.2.76,192.168.2.77,192.168.2.78,192.168.2.79,192.168.2.80,192.168.2.81,192.168.2.82,192.168.2.83,192.168.2.84,192.168.2.85,192.168.2.86,192.168.2.87,192.168.2.88,192.168.2.89,192.168.2.90,192.168.2.91,192.168.2.92,192.168.2.93,192.168.2.94,192.168.2.95,192.168.2.96,192.168.2.97,192.168.2.98,192.168.2.99,192.168.2.100,192.168.2.101,192.168.2.102,192.168.2.103,192.168.2.104,192.168.2.105,192.168.2.106,192.168.2.107,192.168.2.108,192.168.2.109,192.168.2.110,192.168.2.111,192.168.2.112,192.168.2.113,192.168.2.114,192.168.2.115,192.168.2.116,192.168.2.117,192.168.2.118,192.168.2.119,192.168.2.120,192.168.2.121,192.168.2.122,192.168.2.123,192.168.2.124,192.168.2.125,192.168.2.126,192.168.2.127,192.168.2.128 ]- ip : 192.168.1.3default_gw : 192.168.1.15tunnels :type : 'nvgre'dl_dst : '68:05:CA:34:90:D4'dl_src : '6C:92:BF:27:3D:73'tun_id : 1tun_dst: '192.168.1.15'tun_src: [ 192.168.3.1,192.168.3.2,192.168.3.3,192.168.3.4,192.168.3.5,192.168.3.6,192.168.3.7,192.168.3.8,192.168.3.9,192.168.3.10,192.168.3.11,192.168.3.12,192.168.3.13,192.168.3.14,192.168.3.15,192.168.3.16,192.168.3.17,192.168.3.18,192.168.3.19,192.168.3.20,192.168.3.21,192.168.3.22,192.168.3.23,192.168.3.24,192.168.3.25,192.168.3.26,192.168.3.27,192.168.3.28,192.168.3.29,192.168.3.30,192.168.3.31,192.168.3.32,192.168.3.33,192.168.3.34,192.168.3.35,192.168.3.36,192.168.3.37,192.168.3.38,192.168.3.39,192.168.3.40,192.168.3.41,192.168.3.42,192.168.3.43,192.168.3.44,192.168.3.45,192.168.3.46,192.168.3.47,192.168.3.48,192.168.3.49,192.168.3.50,192.168.3.51,192.168.3.52,192.168.3.53,192.168.3.54,192.168.3.55,192.168.3.56,192.168.3.57,192.168.3.58,192.168.3.59,192.168.3.60,192.168.3.61,192.168.3.62,192.168.3.63,192.168.3.64,192.168.3.65,192.168.3.66,192.168.3.67,192.168.3.68,192.168.3.69,192.168.3.70,192.168.3.71,192.168.3.72,192.168.3.73,192.168.3.74,192.168.3.75,192.168.3.76,192.168.3.77,192.168.3.78,192.168.3.79,192.168.3.80,192.168.3.81,192.168.3.82,192.168.3.83,192.168.3.84,192.168.3.85,192.168.3.86,192.168.3.87,192.168.3.88,192.168.3.89,192.168.3.90,192.168.3.91,192.168.3.92,192.168.3.93,192.168.3.94,192.168.3.95,192.168.3.96,192.168.3.97,192.168.3.98,192.168.3.99,192.168.3.100,192.168.3.101,192.168.3.102,192.168.3.103,192.168.3.104,192.168.3.105,192.168.3.106,192.168.3.107,192.168.3.108,192.168.3.109,192.168.3.110,192.168.3.111,192.168.3.112,192.168.3.113,192.168.3.114,192.168.3.115,192.168.3.116,192.168.3.117,192.168.3.118,192.168.3.119,192.168.3.120,192.168.3.121,192.168.3.122,192.168.3.123,192.168.3.124,192.168.3.125,192.168.3.126,192.168.3.127,192.168.3.128 ]
其中,192.168.1.15 是nat物理机的ip地址,68:05:CA:34:90:D4 是nat物理机的mac地址。
流的配置文件,
dnat.yaml
123456789101112131415161718- duration : 10.0generator :distribution : "seq"clients_start : "15.0.0.1"clients_end : "15.10.255.255"servers_start : "2.2.1.0"servers_end : "2.2.2.255"clients_per_gb : 201min_clients : 101dual_port_mask : "1.0.0.0"tcp_aging : 0udp_aging : 0cap_info :- name: 2.pcapcps: 20000.0ipg : 10000rtt : 10000w : 1
其中,15.x模拟的是从外网进来的源地址,2.2.模拟的是云用户的EIP地址段。10.0.模拟的是用户的内网地址段。2.pcap 是cap2/dns.pcap,可以调整这个pcap文件里来回包交互次数来达到调整pps的目的。
nat物理机配置
- nat物理机环境搭建好。
加好静态arp。
12arp -i xxx -s 192.168.1.2 6C:92:BF:27:3D:72arp -i xxx -s 192.168.1.3 6C:92:BF:27:3D:73加好静态路由。
12ip route add 192.168.2.0/24 via 192.168.1.2ip route add 192.168.3.0/24 via 192.168.1.3
运行trex
|
|
调试
- 大量并发时,需要在
trex-cfg
里调大hugepages个数,默认值是2048。 - 改dnat.yaml里的cps为0.01,name改为cap2/dns.pcap,在nat物理机上抓包看来回流量。
- 流量OK后,观察trex运行完毕后是否有丢包
Total-pkt-drop
,并增大压力。可以用这个脚本观察nat物理机上哪里有丢包,dropstat.sh