searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

Pktgen-DPDK性能测试工具使用指南

2024-04-09 01:19:05
147
0

Pktgen-DPDK 是一个基于 DPDK 的高性能数据包生成器和网络性能测试工具,上篇文章介绍了如何编译和安装Pktgen-DPDK,本文将进一步介绍该工具的相关使用。

一、环境初始化

  • 本例程以Bond双网卡为例,每当网卡切回内核态后,首次启动pktgen前需要执行,加载igb_uio模块,绑定使用网卡。
# 加载模块
modprobe uio
insmod igb_uio.ko   # insmod <your igb_uio.ko path>/igb_uio.ko

# 绑定使用网卡,pci需要替换为你的
dpdk-devbind.py -b igb_uio aa:00.1
dpdk-devbind.py -b igb_uio bb:00.1
 

二、运行Pktgen

1、相关目录:

  • 可执行文件目录:Pktgen-DPDK/build/app/pktgen

  • python运行脚本:Pktgen-DPDK/tools/run.py

2、运行命令:

cd /home/chenqingjian/pktgen/Pktgen-DPDK-main

# 方式一:使用run.py + 配置文件,比较便捷,以下命令会使用cfg/default.cfg配置文件中run下的参数运行pktgen
./tools/run.py default

# 方式二:直接使用pktgen,每次都要自己填写后面的参数
./build/app/pktgen <参数>
 
 

cfg/default.cfg内容:

 
description = 'A Pktgen default simple configuration'

# Setup configuration
setup = {
    'exec': (
    'sudo', '-E'
        ),

    'devices': (
        'aa:00.1', 'bb:00.1'
        ),
    # UIO module type, igb_uio, vfio-pci or uio_pci_generic
    'uio': 'igb_uio'
    }

# Run command and options
run = {
    'exec': ('sudo', '-E'),

    # Application name and use app_path to help locate the app
    'app_name': 'pktgen',

    # using (sdk) or (target) for specific variables
    # add (app_name) of the application
    # Each path is tested for the application
    'app_path': (
        'build/app/%(app_name)s',
        ),

    'cores': '0,1,2,3,4,5,6,7,8,16,17,18,19,20,21,22,23',
     # 0000:aa:00.1和0000:bb:00.1聚合成eth_bond0
    'vdev':'eth_bond0,mode=4,xmit_policy=l34,slave=0000:aa:00.1,slave=0000:bb:00.1',

    'blocklist': (
        #'03:00.0', '05:00.0',
        #'81:00.0', '84:00.0'
        ),
    'allowlist': (
        #'5e:00.0', '5e:00.1',
        #'af:00.0', 'af:00.1'
        ),

    'opts': (
        '-v',
        '-T',
        '-P',
        ),
    'map': (
        # [1-4:5-8].0 表示1-4核处理port 0的rx,5-8核处理port 0的tx
        '[1-4:5-8].0',
        '[16-19:20-23].1',
        ),

    'theme': 'themes/black-yellow.theme',
    #'shared': '/usr/local/lib/x86_64-linux-gnu/dpdk/pmds-21.1'
    }

说明:

  • setup内容是用于环境初始化配置的,通过./tools/run.py -s default指定运行,一般我们自己手动配置了。如果要使用该方式配置,还要设置相应的环境路径变量对应起来(RTE_SDK、RTE_TARGET),比较麻烦。

运行结果:

默认显示page main,成功根据配置文件参数执行pktgen。

三、Pktgen配置发包

1、随机发包帮助说明:

-- Setup the packet range values --
     note: SMMI = start|min|max|inc (start, minimum, maximum, increment)


range <portlist> src|dst mac <SMMI> <etheraddr> - Set destination/source MAC address
      e.g: range 0 src mac start 00:00:00:00:00:00
           range 0 dst mac max 00:12:34:56:78:90
      or  range 0 src mac 00:00:00:00:00:00 00:00:00:00:00:00 00:12:34:56:78:90 00:00:00:01:01:01
range <portlist> src|dst ip <SMMI> <ipaddr>   - Set source IP start address
      e.g: range 0 dst ip start 0.0.0.0
           range 0 dst ip min 0.0.0.0
           range 0 dst ip max 1.2.3.4
           range 0 dst ip inc 0.0.1.0
       or  range 0 dst ip 0.0.0.0 0.0.0.0 1.2.3.4 0.0.1.0
range <portlist> type ipv4|ipv6               - Set the range packet type to IPv4 or IPv6
range <portlist> proto tcp|udp                - Set the IP protocol type
range <portlist> tcp flag set <flag>          - Set the TCP flag
range <portlist> tcp flag clr <flag>          - Clear the TCP flag
range <portlist> tcp seq <SMMI> <value>       - Set the TCP sequence number
       or  range <portlist> tcp seq <start> <min> <max> <inc>
range <portlist> tcp ack <SMMI> <value>       - Set the TCP acknowledge number
       or  range <portlist> tcp ack <start> <min> <max> <inc>
range <portlist> src|dst port <SMMI> <value>  - Set UDP/TCP source/dest port number
       or  range <portlist> src|dst port <start> <min> <max> <inc>
range <portlist> vlan <SMMI> <value>          - Set vlan id start address
      or  range <portlist> vlan <start> <min> <max> <inc>
range <portlist> size <SMMI> <value>          - Set pkt size start address
      or  range <portlist> size <start> <min> <max> <inc>
range <portlist> teid <SMMI> <value>          - Set TEID value
      or  range <portlist> teid <start> <min> <max> <inc>
range <portlist> mpls entry <hex-value>       - Set MPLS entry value
range <portlist> qinq index <val1> <val2>     - Set QinQ index values
range <portlist> gre key <value>              - Set GRE key value
range <portlist> cos <SMMI> <value>           - Set cos value
range <portlist> tos <SMMI> <value>           - Set tos value
range <portlist> ttl <SMMI> <value>           - Set TTL
range <portlist> hop_limits <SMMI> <value>    - Set Hop Limits
range <portlist> traffic_class <SMMI> <value> - Set Traffic Class value
2、配置示例(以port 0为例, 所有port一起配可以用all)
range 0 type ipv6
range 0 src ip 2001::1 2001::1 2001::ffff:1 ::1:0
range 0 src port 1000 1000 65534 1
range 0 dst mac start E0:28:61:cc:bb:aa
range 0 dst mac max E0:28:61:cc:bb:aa
range 0 dst ip 3001::1 3001::1 3001::ffff:1 ::1:0
range 0 dst port 5011 5011 5011 0
range 0 proto tcp
range 0 tcp flag set syn
range 0 size 64 64 64 0
enable 0 range
 

查看range配置

page range

 开始发包

page main
start 0

 

0条评论
0 / 1000
c****k
5文章数
0粉丝数
c****k
5 文章 | 0 粉丝
原创

Pktgen-DPDK性能测试工具使用指南

2024-04-09 01:19:05
147
0

Pktgen-DPDK 是一个基于 DPDK 的高性能数据包生成器和网络性能测试工具,上篇文章介绍了如何编译和安装Pktgen-DPDK,本文将进一步介绍该工具的相关使用。

一、环境初始化

  • 本例程以Bond双网卡为例,每当网卡切回内核态后,首次启动pktgen前需要执行,加载igb_uio模块,绑定使用网卡。
# 加载模块
modprobe uio
insmod igb_uio.ko   # insmod <your igb_uio.ko path>/igb_uio.ko

# 绑定使用网卡,pci需要替换为你的
dpdk-devbind.py -b igb_uio aa:00.1
dpdk-devbind.py -b igb_uio bb:00.1
 

二、运行Pktgen

1、相关目录:

  • 可执行文件目录:Pktgen-DPDK/build/app/pktgen

  • python运行脚本:Pktgen-DPDK/tools/run.py

2、运行命令:

cd /home/chenqingjian/pktgen/Pktgen-DPDK-main

# 方式一:使用run.py + 配置文件,比较便捷,以下命令会使用cfg/default.cfg配置文件中run下的参数运行pktgen
./tools/run.py default

# 方式二:直接使用pktgen,每次都要自己填写后面的参数
./build/app/pktgen <参数>
 
 

cfg/default.cfg内容:

 
description = 'A Pktgen default simple configuration'

# Setup configuration
setup = {
    'exec': (
    'sudo', '-E'
        ),

    'devices': (
        'aa:00.1', 'bb:00.1'
        ),
    # UIO module type, igb_uio, vfio-pci or uio_pci_generic
    'uio': 'igb_uio'
    }

# Run command and options
run = {
    'exec': ('sudo', '-E'),

    # Application name and use app_path to help locate the app
    'app_name': 'pktgen',

    # using (sdk) or (target) for specific variables
    # add (app_name) of the application
    # Each path is tested for the application
    'app_path': (
        'build/app/%(app_name)s',
        ),

    'cores': '0,1,2,3,4,5,6,7,8,16,17,18,19,20,21,22,23',
     # 0000:aa:00.1和0000:bb:00.1聚合成eth_bond0
    'vdev':'eth_bond0,mode=4,xmit_policy=l34,slave=0000:aa:00.1,slave=0000:bb:00.1',

    'blocklist': (
        #'03:00.0', '05:00.0',
        #'81:00.0', '84:00.0'
        ),
    'allowlist': (
        #'5e:00.0', '5e:00.1',
        #'af:00.0', 'af:00.1'
        ),

    'opts': (
        '-v',
        '-T',
        '-P',
        ),
    'map': (
        # [1-4:5-8].0 表示1-4核处理port 0的rx,5-8核处理port 0的tx
        '[1-4:5-8].0',
        '[16-19:20-23].1',
        ),

    'theme': 'themes/black-yellow.theme',
    #'shared': '/usr/local/lib/x86_64-linux-gnu/dpdk/pmds-21.1'
    }

说明:

  • setup内容是用于环境初始化配置的,通过./tools/run.py -s default指定运行,一般我们自己手动配置了。如果要使用该方式配置,还要设置相应的环境路径变量对应起来(RTE_SDK、RTE_TARGET),比较麻烦。

运行结果:

默认显示page main,成功根据配置文件参数执行pktgen。

三、Pktgen配置发包

1、随机发包帮助说明:

-- Setup the packet range values --
     note: SMMI = start|min|max|inc (start, minimum, maximum, increment)


range <portlist> src|dst mac <SMMI> <etheraddr> - Set destination/source MAC address
      e.g: range 0 src mac start 00:00:00:00:00:00
           range 0 dst mac max 00:12:34:56:78:90
      or  range 0 src mac 00:00:00:00:00:00 00:00:00:00:00:00 00:12:34:56:78:90 00:00:00:01:01:01
range <portlist> src|dst ip <SMMI> <ipaddr>   - Set source IP start address
      e.g: range 0 dst ip start 0.0.0.0
           range 0 dst ip min 0.0.0.0
           range 0 dst ip max 1.2.3.4
           range 0 dst ip inc 0.0.1.0
       or  range 0 dst ip 0.0.0.0 0.0.0.0 1.2.3.4 0.0.1.0
range <portlist> type ipv4|ipv6               - Set the range packet type to IPv4 or IPv6
range <portlist> proto tcp|udp                - Set the IP protocol type
range <portlist> tcp flag set <flag>          - Set the TCP flag
range <portlist> tcp flag clr <flag>          - Clear the TCP flag
range <portlist> tcp seq <SMMI> <value>       - Set the TCP sequence number
       or  range <portlist> tcp seq <start> <min> <max> <inc>
range <portlist> tcp ack <SMMI> <value>       - Set the TCP acknowledge number
       or  range <portlist> tcp ack <start> <min> <max> <inc>
range <portlist> src|dst port <SMMI> <value>  - Set UDP/TCP source/dest port number
       or  range <portlist> src|dst port <start> <min> <max> <inc>
range <portlist> vlan <SMMI> <value>          - Set vlan id start address
      or  range <portlist> vlan <start> <min> <max> <inc>
range <portlist> size <SMMI> <value>          - Set pkt size start address
      or  range <portlist> size <start> <min> <max> <inc>
range <portlist> teid <SMMI> <value>          - Set TEID value
      or  range <portlist> teid <start> <min> <max> <inc>
range <portlist> mpls entry <hex-value>       - Set MPLS entry value
range <portlist> qinq index <val1> <val2>     - Set QinQ index values
range <portlist> gre key <value>              - Set GRE key value
range <portlist> cos <SMMI> <value>           - Set cos value
range <portlist> tos <SMMI> <value>           - Set tos value
range <portlist> ttl <SMMI> <value>           - Set TTL
range <portlist> hop_limits <SMMI> <value>    - Set Hop Limits
range <portlist> traffic_class <SMMI> <value> - Set Traffic Class value
2、配置示例(以port 0为例, 所有port一起配可以用all)
range 0 type ipv6
range 0 src ip 2001::1 2001::1 2001::ffff:1 ::1:0
range 0 src port 1000 1000 65534 1
range 0 dst mac start E0:28:61:cc:bb:aa
range 0 dst mac max E0:28:61:cc:bb:aa
range 0 dst ip 3001::1 3001::1 3001::ffff:1 ::1:0
range 0 dst port 5011 5011 5011 0
range 0 proto tcp
range 0 tcp flag set syn
range 0 size 64 64 64 0
enable 0 range
 

查看range配置

page range

 开始发包

page main
start 0

 

文章来自个人专栏
DPDK压测与性能调优
2 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0