TRex 学习 (1)---- install

原创
2017/04/25 14:29
阅读数 2.4W

目前,路由器厂商测试用的都是商业的仪表,一般的性能衡量都是以PPS作为标准,而路由器很复杂,牵扯到7层的应用,而且希望能够提供一种更加真实的流场景测试,TRex应运而生,TRex是一款开源的发包工具,它跑在标准的inter处理芯片上,同时支持stateful和stateless模式,stateful可以描述L4~L7层的应用场景,而stateless主要用来进行定制包的发包

TRex 功能性能

stateful
支持高达200Gb/s的流量测试,需要网卡及CPU支持,一般跟core个数有关
支持时延和抖动
支持NAT/PAT自动学习
支持L4~L7
stateless
轻易产生stateless traffic stream
支持大流量 20mpps
支持stream并发
支持更改报文字段范围
支持Continuous/Burst/Multi-burst support
支持console/GUI
支持每条流的统计
支持pythonAPI

思博伦L4-L7旗舰产品Avalanche与TRex的比较

TRex的安装对OS以及网卡有特殊的要求

网卡
Intel I350
Inter 82599
Inter X710
Mellanox ConnectX-4
Cisco1300 series
VMXNET/VMXNET3
E1000

操作系统

Fedora 20
Fedora 21
Ubuntu14.04.1
Ubuntu16.04.1

检查网卡

@trex:/tmp/trex/v2.23# lspci | grep Ethernet
02:00.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:02.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:03.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)

下载和安装

mkdir trex
cd trex
wget --no-cache http://trex-tgn.cisco.com/trex/release/latest
tar -zxvf latest

first run trex

Identify the ports
root@trex:/tmp/trex/v2.23# ./dpdk_setup_ports.py -s

Network devices using DPDK-compatible driver
============================================
0000:02:01.0 '82545EM Gigabit Ethernet Controller (Copper)' 
drv=igb_uio unused=e1000,vfio-pci,uio_pci_generic
0000:02:02.0 '82545EM Gigabit Ethernet Controller (Copper)' 
drv=igb_uio unused=e1000,vfio-pci,uio_pci_generic
0000:02:03.0 '82545EM Gigabit Ethernet Controller (Copper)' 
drv=igb_uio unused=e1000,vfio-pci,uio_pci_generic

Network devices using kernel driver
===================================
0000:02:00.0 '82545EM Gigabit Ethernet Controller (Copper)' 
if=ens32 drv=e1000,unused=igb_uio,vfio-pci,uio_pci_generic *Active*

Other network devices
=====================
<none>

Active 端口作为管理端口,管理端口不能被绑定到trex,否则不能管理linx, 其它三个网卡可以绑定

cp  cfg/simple_cfg.yaml  /etc/trex_cfg.yaml,trex默认端口起动配置文件是/etc/trex_cfg.yaml,也可以自定义起动配置文件 "./t-rex-64 --cfg"

配置/etc/trex_yaml端口配置文件 
  1 - port_limit      : 2                                             #端口数量限制
  2   version         : 2                                             #trex 版本
  3 #List of interfaces. Change to suit your setup. Use 
      ./dpdk_setup_ports.py -s to see av
    ailable options
  4   interfaces    : ["02:01.0","02:02.0"]                           #对应绑定网卡的pci号
  5   port_info       :  # Port IPs. Change to suit your needs. 
       In case of loopback, you c
    an leave as is.
  6           - ip         : 192.168.10.33        #本端eth1的虚接口地址
  7             default_gw : 192.168.10.168       #对端DUT接口地址
  8           - ip         : 10.10.10.33          #本端eth2的虚接口地址
  9             default_gw : 10.10.10.1           #对端DUT接口地址

至此虚接口发免费的ARP,并发ARP学习192.168.10.168的MAC,使得本地的Linux与对端的DUT互相学习到MAC地址,此时可以进入stateless模式进行简单测试

启动stateless服务器

./t-rex-64 -i

启动终端

@trex:/tmp/trex/v2.23# ./trex-console 

Using 'python' as Python interpeter


Connecting to RPC server on localhost:4501                   [SUCCESS]


Connecting to publisher server on localhost:4500             [SUCCESS]


Acquiring ports [0, 1]:                                      [SUCCESS]


Server Info:

Server version:   v2.23
Server CPU:       1 x Intel(R) Xeon(R) CPU E5-2698 v3 @ 2.30GHz
Ports count:      2 x 1Gbps @ 82545EM Gigabit Ethernet Controller (Copper)

-=TRex Console v2.0=-

Type 'help' or '?' for supported actions

trex>

ping

trex>service

Enabling service mode on port(s) [0, 1]:                     [SUCCESS]

trex(service)>ping -p 0 -d 192.168.10.168                     # -p 端口号  -d dest_ip

Pinging 192.168.10.168 from port 0 with 64 bytes of data:    
Reply from 192.168.10.168: bytes=64, time=48.52ms, TTL=64
Reply from 192.168.10.168: bytes=64, time=2.42ms, TTL=64
^C
Action has failed with the following error:

Interrupted by a keyboard signal (probably ctrl + c)

trex(service)>ping -p 0 -d 10.10.10.1

Pinging 10.10.10.1 from port 0 with 64 bytes of data:        
Reply from 10.10.10.1: bytes=64, time=22.78ms, TTL=64
^C
Action has failed with the following error:

Interrupted by a keyboard signal (probably ctrl + c)

trex(service)>ping -p 0 -d 10.10.10.33

Pinging 10.10.10.33 from port 0 with 64 bytes of data:       
Reply from 10.10.10.33: bytes=64, time=2.07ms, TTL=128
^C
Action has failed with the following error:

Interrupted by a keyboard signal (probably ctrl + c)

只有service 模式支持ARP和PING,这个是stateless的交互模式,便于开始测试网络初始连接

 

参考:

trex-tgn.cisco.com/trex/doc/trex_stateless.html
http://trex-tgn.cisco.com/trex/doc/trex_manual.html

 

展开阅读全文
打赏
2
3 收藏
分享
加载中
大神,service测试时request time out,咋解决
2020/05/19 10:25
回复
举报
可以用虚拟端口dummy 一个端口只是发包
2019/02/24 23:27
回复
举报
绑定到trex端口如何才能释放?因为只有两个端口,只能把管理口给绑定到trex,每次要导入一个报文都要重启好麻烦。求大神支招
2018/08/30 10:35
回复
举报
更多评论
打赏
3 评论
3 收藏
2
分享
返回顶部
顶部