-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the trex tutorial document #559
Open
taylor3768
wants to merge
11
commits into
iqiyi:devel
Choose a base branch
from
taylor3768:devel
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c0cca07
trex tutorial document
ffffc4f
Revert "trex tutorial document"
122b987
Add the trex tutorial document
08d03e1
Add png files
8979f8e
Revert "Add png files"
117febc
Revert "Add the trex tutorial document"
9a0711a
Ad the trex tutorial document
b740c96
Fix the png display error
2d2c52c
Add the trex tutorial document
a4c00a9
trex tutorial document
877baf5
Merge branch 'devel' of https://github.com/taylor3768/dpvs into devel
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,276 @@ | ||
TRex是⼀款开源的发包⼯具,它跑在标准的intel处理芯⽚上,同时⽀持stateful和stateless模式,stateful可以描述L4~L7 层的应⽤场景,⽽stateless主要⽤来进⾏定制包的发送。 | ||
|
||
**T-Rex 特性** | ||
|
||
1. Stateful | ||
|
||
- ⽀持⾼达200Gb/s的流量测试,需要⽹卡及CPU⽀持,⼀般跟core个数有关 | ||
|
||
- ⽀持时延和抖动,⽀持NAT/PAT⾃动学习,⽀持L4~L7 | ||
|
||
2. Stateless | ||
|
||
- 轻易产⽣stateless traffic stream,⽀持⼤流量 20mpps,⽀持stream并发,⽀持更改报⽂字段范围 | ||
- ⽀持Continuous/Burst/Multi-burst support,⽀持console/GUI,⽀持每条流的统计 | ||
- ⽀持pythonAPI | ||
|
||
**安装** | ||
|
||
1. 下载最新v2.56版本: | ||
|
||
``` | ||
# wget https://github.com/cisco-system-traffic-generator/trex-core/archive/v2.56.tar.gz | ||
# tar -xvf v2.56.tar.gz | ||
# cd trex-core-2.56/ | ||
``` | ||
|
||
2. 编译源码: | ||
|
||
``` | ||
# yum install gcc gcc-c++ kernel-devel | ||
# cd linux_dpdk/ | ||
# ./b configure | ||
# ./b build | ||
# cd ../linux | ||
# ./b configure | ||
# ./b build | ||
``` | ||
|
||
3. 修改配置⽂件,绑定测试端⼝: | ||
|
||
``` | ||
# cat /etc/trex_cfg.yaml | ||
### Config file generated by dpdk_setup_ports.py ### | ||
- version: 2 | ||
interfaces: ['02:00.0', '02:00.1'] | ||
port_info: | ||
- ip: 10.142.116.28 | ||
default_gw: 10.142.116.254 | ||
dest_mac: 00:00:0c:9f:f3:74 | ||
- ip: 10.142.117.28 | ||
default_gw: 10.142.117.254 | ||
dest_mac: 00:00:0c:9f:f3:75 | ||
platform: | ||
master_thread_id: 0 | ||
latency_thread_id: 8 | ||
dual_if: | ||
- socket: 0 | ||
threads: [1,2,3,4,5,6,7,16,17,18,19,20,21,22,23] | ||
``` | ||
|
||
4. 启动t-rex服务 | ||
|
||
``` | ||
# cd ../scripts | ||
# ./t-rex-64 -i | ||
``` | ||
|
||
5. 另外开⼀个终端,启动trex-console,进⼊service模式,执⾏arp命令⾃动解析⽹关mac地址: | ||
|
||
``` | ||
# ./trex-console | ||
… | ||
trex>service | ||
|
||
Enabling service mode on port(s) [0, 1]: [SUCCESS] | ||
|
||
8.51 [ms] | ||
|
||
trex(service)>arp | ||
|
||
Resolving destination on port(s) [0, 1]: [SUCCESS] | ||
|
||
Port 0 - Recieved ARP reply from: 10.142.116.254, hw: 00:00:0c:9f:f3:74 | ||
Port 1 - Recieved ARP reply from: 10.142.117.254, hw: 00:00:0c:9f:f3:75 | ||
|
||
443.34 [ms] | ||
``` | ||
|
||
6. 执⾏ping测试⽹关连通性: | ||
|
||
``` | ||
trex(service)>ping -p 0 -d 10.142.116.254 | ||
|
||
Pinging 10.142.116.254 from port 0 with 64 bytes of data: | ||
Reply from 10.142.116.254: bytes=64, time=1.04ms, TTL=255 | ||
Reply from 10.142.116.254: bytes=64, time=0.84ms, TTL=255 | ||
Reply from 10.142.116.254: bytes=64, time=1.35ms, TTL=255 | ||
Reply from 10.142.116.254: bytes=64, time=1.43ms, TTL=255 | ||
Reply from 10.142.116.254: bytes=64, time=1.23ms, TTL=255 | ||
trex(service)>ping -p 1 -d 10.142.117.254 | ||
|
||
Pinging 10.142.117.254 from port 1 with 64 bytes of data: | ||
Reply from 10.142.117.254: bytes=64, time=1.48ms, TTL=255 | ||
Reply from 10.142.117.254: bytes=64, time=2.33ms, TTL=255 | ||
Reply from 10.142.117.254: bytes=64, time=1.63ms, TTL=255 | ||
Reply from 10.142.117.254: bytes=64, time=1.44ms, TTL=255 | ||
Reply from 10.142.117.254: bytes=64, time=1.29ms, TTL=255 **Stateful** | ||
``` | ||
|
||
**Stateful** | ||
|
||
Stateful模式指的是⽹络设备对每条流保存其五元组,TRex通常先录制⼀条流的⼀组报⽂,随后以这组报⽂为模板,在真 正测试的时候,更改其src/dst IP和Port,TRex⾃身没有协议栈,却让⽹络设备有了状态,因此它可以测试L4~L7层的应 ⽤,重点是提前录制连接的过程。 | ||
|
||
1. 设置端⼝与DUT相连,修改trex配置: | ||
|
||
``` | ||
![pcap](E:\code\github\dpvs\doc\pics\pcap.png)# cat /etc/trex_cfg.yaml | ||
- port_limit : 2 | ||
version : 2 | ||
#List of interfaces. Change to suit your setup. Use ./dpdk_setup_ports.py -s to see available | ||
options | ||
interfaces : ["07:00.0", "07:00.1"] | ||
port_info : # Port IPs. Change to suit your needs. In case of loopback, you can leave as | ||
is. | ||
- ip : 10.142.117.100 | ||
default_gw : 10.142.117.254 | ||
dest_mac : 6c:92:bf:13:ee:36 | ||
- ip : 10.142.117.101 | ||
default_gw : 10.142.117.254 | ||
dest_mac : 6c:92:bf:13:ee:37 | ||
``` | ||
|
||
2. 以http访问测试为例,⾸先抓取访问http⼀次访问的包作为模板,保存为http_test.pcap,内容参考如下: ![pcap](pics/pcap.png) | ||
|
||
3. 新增yaml设定,内容参考如下: | ||
|
||
``` | ||
# cat http_test.yaml | ||
- duration : 0.1 | ||
generator : | ||
distribution : "seq" | ||
clients_start : "10.142.117.100" | ||
clients_end : "10.142.117.131" | ||
servers_start : "10.142.116.1" | ||
servers_end : "10.142.116.1" | ||
clients_per_gb : 201 | ||
min_clients : 101 | ||
dual_port_mask : "1.0.0.0" | ||
tcp_aging : 0 | ||
udp_aging : 0 | ||
cap_ipg : true | ||
cap_info : | ||
- name: http_test.pcap | ||
cps : 2.776 | ||
ipg : 10000 | ||
rtt : 10000 | ||
w : 1 | ||
``` | ||
|
||
4. 执⾏trex命令测试: | ||
|
||
``` | ||
# ./t-rex-64 -f http_test.yaml -d 100 -m 100 -v 7 | ||
``` | ||
|
||
**ASTF** | ||
|
||
ASTF是⾼级statefull测试模式,可以通过python脚本⾃动化测试L4~L7场景,尤其对TCP协议栈⽀持⽐较完善。下⾯以通 过wget访问nginx⻚⾯为例,步骤如下: | ||
|
||
1. ⽹络拓扑参考如下: | ||
|
||
![topology](pics/topology.png) | ||
|
||
2. 修改python测试脚本: | ||
|
||
``` | ||
# cat astf/nginx_wget.py | ||
from trex.astf.api import * | ||
|
||
class Prof1(): | ||
def get_profile(self, **kwargs): | ||
# ip generator | ||
ip_gen_c = ASTFIPGenDist(ip_range = ["10.142.165.100", "10.142.165.131"], | ||
distribution="seq") | ||
ip_gen_s = ASTFIPGenDist(ip_range = ["10.142.166.100", "10.142.166.131"], | ||
distribution="seq") | ||
ip_gen = ASTFIPGen(glob = ASTFIPGenGlobal(ip_offset="1.0.0.0"), | ||
dist_client = ip_gen_c, | ||
dist_server = ip_gen_s) | ||
|
||
return ASTFProfile(default_ip_gen = ip_gen, | ||
cap_list = [ASTFCapInfo(file = 'nginx.pcap', | ||
cps = 1)]) | ||
def register(): | ||
return Prof1() | ||
``` | ||
|
||
3. 以astf模式开启trex服务: | ||
|
||
``` | ||
# ./t-rex-64 -i --astf | ||
``` | ||
|
||
4. 另外开终端,打开trex-console: | ||
|
||
``` | ||
# ./trex-console | ||
``` | ||
|
||
5. 执⾏start命令模拟wget访问nginx服务: | ||
|
||
``` | ||
![tui](E:\code\github\dpvs\doc\pics\tui.png)trex>start -f astf/nginx_wget.py -m 90000 -d 1000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
Loading traffic at acquired ports. [SUCCESS] | ||
|
||
Starting traffic. [SUCCESS] | ||
|
||
31.48 [ms] | ||
``` | ||
|
||
6. 执⾏tui命令在后台监控流量情况,可以看到带宽基本都被打满(tx:10.01Gbps,rx:9.92Gbps): | ||
|
||
![tui](pics/tui.png) | ||
|
||
**Stateless测试** | ||
|
||
Stateless是基于构包和发包两个阶段来完成, 构包完全基于python的scapy库,⽽发包则是其⾃开发的trex_stl_lib来完 成。 | ||
|
||
1. Stateless测试默认⽀持GUI模式,既远程通过界⾯配置trex,⾸先需要安装客户端,下载链接如下: | ||
|
||
https://github.com/cisco-system-traffic-generator/trex-stateless-gui/releases | ||
|
||
2. 在服务端以交互模式开启t-rex-64: | ||
|
||
``` | ||
# t-rex-64 -i | ||
``` | ||
|
||
3. 打开客户端界⾯,连接trex服务: ![trex-gui1](pics/trex-gui1.png) | ||
|
||
4. 这边port0跟port1分别对应dpdk绑定的⽹卡端⼝,发包在0端⼝发,1端⼝收: ![trex-gui2](pics/trex-gui2.png) | ||
|
||
5. 点进port,开启Service模式,并强制获取配置权限: | ||
|
||
![trex-gui3](pics/trex-gui3.png) | ||
|
||
6. 进Configuration菜单,设置端⼝ip及⽹关,点击Apply,如果⽹关地址arp解析成功说明配置正确: | ||
|
||
![trex-gui4](pics/trex-gui4.png) | ||
|
||
7. 新建profile配置,带宽100%,添加udp⼩包(64字节)测试项: | ||
|
||
![trex-gui5](pics/trex-gui5.png) | ||
|
||
![trex-gui6](pics/trex-gui6.png) | ||
|
||
![trex-gui7](pics/trex-gui7.png) | ||
|
||
8. 右击profile,执⾏play动作进⾏发包压测: | ||
|
||
![trex-gui8](pics/trex-gui8.png) | ||
|
||
9. 查看stat监控,如果TX跟RX的pps基本保持⼀致,说明丢包率较低,以下截图中测试结果是在万兆⽹卡上压测数 据,pps为14Mpps说明已经接近100%线速,这是最理想的数据: | ||
|
||
![trex-gui9](pics/trex-gui9.png) | ||
|
||
![trex-gui10](pics/trex-gui10.png) | ||
|
||
**参考链接:** | ||
|
||
https://trex-tgn.cisco.com/trex/doc/index.html | ||
|
||
https://github.com/cisco-system-traffic-generator/trex-core/wiki | ||
|
||
https://trex-tgn.cisco.com/trex/doc/trex_faq.html |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.