TRex 学习(6)---- Stateless (Introduction)

Stateless是基于构包和发包两个阶段来完成, 构包完全基于python的scapy库,而发包则是其自开发的trex_stl_lib来完成。

概述

  1. 大速率发包 10~22 百万 pps
  2. 支持一个接口下有多个 traffic profile
  3. 支持一个 traffic profile中有多条流,最高可达10k 条流并发
  4. 对于流
    • 支持构造任意包 (scapy)
    • 支持文件引擎,允许对源IP, packet size进行一定的改动
    • 支持 Continuous/Burst/Multi-burst
    • 支持 pps/L1 bandwidth/L2 bindwidth/interface percentage
    • 支持一条流触发另一条流
  5. 支持基于端口的统计
  6. 支持基于流的统计

TRex 与 IXExplorer 比较

输入图片说明

Trex Objects

Trex Stateless主要由以下部分组成

  • TRex: 每个装有TRex的主机可以提供多个接口进行发包
  • Interface: 每个接口支持1个或多个 traffic profile
  • Traffic Profile: 每个traffic profile可以包含一条或多条流
  • Stream: 每条流包含以下几方面
    1. Packet: 由scapy进行构建
    2. Field Engine: 可以提供包里面字段的改变,如源IP,如包大小,提供一定的灵活性
    3. Mode: 包发送模式 cont/burst/mult-burst
    4. Rx Stats: 根据每条流进行统计
    5. Rate: 速率(pps/bandwidth)
    6. 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
  1. 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 
  1. 进入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>
  1. 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]
  1. 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]
  1. Capture
    在service模式下还可以进行实时抓包 输入图片说明
    对 p 0 端口的接收方向进行抓包,这个过程需要在图形界面中进行,因为需要开启wireshark

参考:

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

转载于:https://my.oschina.net/hding/blog/892220

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值