Stateless是基于构包和发包两个阶段来完成, 构包完全基于python的scapy库,而发包则是其自开发的trex_stl_lib来完成。
概述
- 大速率发包 10~22 百万 pps
- 支持一个接口下有多个 traffic profile
- 支持一个 traffic profile中有多条流,最高可达10k 条流并发
- 对于流
- 支持构造任意包 (scapy)
- 支持文件引擎,允许对源IP, packet size进行一定的改动
- 支持 Continuous/Burst/Multi-burst
- 支持 pps/L1 bandwidth/L2 bindwidth/interface percentage
- 支持一条流触发另一条流
- 支持基于端口的统计
- 支持基于流的统计
TRex 与 IXExplorer 比较
Trex Objects
Trex Stateless主要由以下部分组成
- TRex: 每个装有TRex的主机可以提供多个接口进行发包
- Interface: 每个接口支持1个或多个 traffic profile
- Traffic Profile: 每个traffic profile可以包含一条或多条流
- Stream: 每条流包含以下几方面
- Packet: 由scapy进行构建
- Field Engine: 可以提供包里面字段的改变,如源IP,如包大小,提供一定的灵活性
- Mode: 包发送模式 cont/burst/mult-burst
- Rx Stats: 根据每条流进行统计
- Rate: 速率(pps/bandwidth)
- Action: 可以指定流与流之间的关系
Stateless vs Stateful
Simple Interactive Mode
Trex Stateless在运用时有三种方式
- 简单基于端口的一些测试模式,如ARP, PING
- 简单命令行交互,需要特定的py文件
- 纯Python接口编写的py文件,可直接执行
本文主要介绍第一种,基于端口的简单发包 Port Layer Mode Configuration
Trex Port可以工作在两种模式下
- Layer 2 mode -- MAC level
- Layer 3 mode -- IP level
- start stateless server
./t-rex-64 -i
Per port stats table
ports | 0 | 1
-----------------------------------------------------------------------------------------
opackets | 0 | 0
obytes | 0 | 0
ipackets | 3 | 0
ibytes | 192 | 0
ierrors | 0 | 0
oerrors | 0 | 0
Tx Bw | 0.00 bps | 0.00 bps
Global stats enabled
Cpu Utilization : 0.0 % 0.0 Gb/core
Platform_factor : 1.0
Total-Tx : 0.00 bps
Total-Rx : 0.00 bps
Total-PPS : 0.00 pps
Total-CPS : 0.00 cps
Expected-PPS : 0.00 pps
Expected-CPS : 0.00 cps
Expected-BPS : 0.00 bps
Active-flows : 0 Clients : 0 Socket-util : 0.0000 %
Open-flows : 0 Servers : 0 Socket : 0 Socket/Clients : -nan
drop-rate : 0.00 bps
current time : 125.4 sec
test duration : 0.0 sec
- 进入Trex Console接口
root@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>
- L2 Port Service
trex>service
Enabling service mode on port(s) [0, 1]: [SUCCESS]
trex(service)>l2 --help
usage: port [-h] --port PORT --dst DST_MAC
Configures a port in L2 mode
optional arguments:
-h, --help show this help message and exit
--port PORT, -p PORT source port for the action #接口信息
--dst DST_MAC Configure destination MAC address #源MAC,目的MAC
trex(service)>l2 -p 0 --dst 00:10:10:11:11:11
Setting port 0 in L2 mode: [SUCCESS]
6.25 [ms]
- L3 Port Service
trex(service)>l3 --help
usage: port [-h] --port PORT --src SRC_IPV4 --dst DST_IPV4
Configures a port in L3 mode
optional arguments:
-h, --help show this help message and exit
--port PORT, -p PORT source port for the action #接口信息
--src SRC_IPV4 Configure source IPv4 address #源IP
--dst DST_IPV4 Configure destination IPv4 address #目的IP
trex(service)>l3 -p 0 --src 192.168.10.11 --dst 192.168.10.168 #切换p 0为L3模式
Setting port 0 in L3 mode: [SUCCESS]
ARP resolving address '192.168.10.168': [SUCCESS]
33.92 [ms]
trex(service)>arp
Resolving destination on port(s) [0, 1]: [SUCCESS]
Port 0 - Recieved ARP reply from: 192.168.10.168, hw: c0:ea:e4:69:a2:fa #arp send by p 0
Port 1 - Recieved ARP reply from: 10.10.10.1, hw: c0:ea:e4:69:a2:fc #arp send by p 1
76.12 [ms]
- Capture
在service模式下还可以进行实时抓包
对 p 0 端口的接收方向进行抓包,这个过程需要在图形界面中进行,因为需要开启wireshark
参考:
http://trex-tgn.cisco.com/trex/doc/trex_stateless.html