Pktgen指南01

  • Author:ZERO-A-ONE
  • Date:2021-03-01

本人最近在学习使用Pktgen构造DDoS的攻击流,就记录了一下Pktgen和DPDK的使用学习笔记

dpdk是Intel发起的高速网络处理工具,能够旁路Linux在用户空间接管CPU、内存和网卡队列,进行高度并行的网络收发包。pktgen-dpdk是Linux内核发包工具的dpdk加强版

一、安装配置

安装过程需要设置hugepage以支持dpdk,编译加载dpdk模块和绑定网卡,编译pktgen-dpdk,运行pktgen-dpdk查看网卡cpu对应关系以设定cpu分配关系

为顺利安装,需要Linux系统Ubuntu 18.04或以上,以及支持dpdk的网卡,dpdk官网可以查询你的网卡是否支持

1.1 安装dpdk

下载源代码

$ wget http://fast.dpdk.org/rel/dpdk-19.11.6.tar.xz

解压

$ tar xf dpdk-19.11.6.tar.xz

libpcap依赖安装

$ apt-get install libpcap-dev

启用pcap

$ make config T=x86_64-native-linuxapp-gcc
$ sed -ri 's,(PMD_PCAP=).*,\1y,' build/.config

安装numa依赖(numa.h库)

$ apt-get install libnuma-dev

编译

$ make -j2

进入工具目录里,利用usertools/dpdk-setup.sh配置环境

$ cd usertools
$ ./dpdk-setup.sh

选择自己对应的DPDK环境,然后进行IGB UIO\VFIO\KNI 模块的加载、HugePage的映射设置、网卡绑定等功能

1.2 安装pktgen

1.2.1 配置Lua环境

pktgen需要具有lua语言环境,所以我们需要首先配置lua环境,首先去官网下载源码

 $ wget http://www.lua.org/ftp/lua-5.4.2.tar.gz

然后解压源码包

$ tar xzvf lua-5.4.2.tar.gz

然后之前需要安装一些依赖包

$ apt install libreadline-dev libreadline5 python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential

然后进入编译目录

$ cd lua-5.4.2/

开始编译

$ make linux test -j2

编译完成后编译安装

$ make install
1.2.2 pktgen

下载pktgen源码

$ git clone https://github.com/pktgen/Pktgen-DPDK.git

进入目录

$ cd Pktgen-DPDK

安装pkg-config

$ apt-get install pkg-config -y

安装libdpdk-dev

$ apt install libdpdk-dev -y

安装meson

$ pip3 install meson

安装ninja

$ pip3 install ninja

然后在编译前需要指定一些环境变量

$ export RTE_SDK=/root/test/dpdk-stable-19.11.6/ #请根据自己dpdk的位置设置
$ export RTE_TARGET=x86_64-native-linuxapp-gcc   #请根据自己安装的编译工具设置

然后编译

$ make -j2

1.3 运行

1.3.1 端口绑定

在运行pktgen时,需要执行dpdk的端口绑定,首先需要进入dpdk所在的文件夹

$ cd dpdk-stable-19.11.6/

执行以下指令

$ modprobe uio
$ insmod x86_64-native-linuxapp-gcc/kmod/igb_uio.ko

我们可以先查看绑定的端口

$ ./usertools/dpdk-devbind.py --status

将在Linux Kernel内核绑定的网卡解绑,然后绑定到dpdk上

解绑端口

$ ./usertools/dpdk-devbind.py -u eth1

绑定端口

$ ./usertools/dpdk-devbind.py -b igb_uio eth1

然后进入到pktgen的文件夹里

$ cd pktgen-19.12.0/

pktgen真正的执行文件

$ cd ./app/x86_64-native-linuxapp-gcc/pktgen

1.4 遇到的问题记录

在绑定网卡到DPDK模块时 报错 :is active. Not modifying

解决方法:

$ ifconfig <网卡名称> down

遇到错误insmod: ERROR: could not insert module x86_64-native-linuxapp-gcc/kmod/igb_uio.ko: Invalid module format

解决方法:

  • cd 4.15.0-136-generic/kernel/ 进入到内核目录
  • rm build 删除原有软连接
  • 创建新的软连接ln -s /usr/src/linux-headers-4.15.0-136-generic build

二、EAL命令行选项

与其他DPDK应用程序一样,Pktgen将命令行参数分为DPDK环境抽象层(EAL)的参数和应用程序本身的参数。两组参数使用以下标准约定分隔--,也就是说pktgen命令分为两部分,--前面的传给dpdk,后面的传给pktgen,Pktgen可执行文件位于 ./app/app/${RTE_TARGET}/pktgen

一条常见的Pktgen命令如下图所示:

$ pktgen -l 0-4 -n 3 – -P -m “[1:3].0, [2:4].1

Pktgen命令常用的参数选项是这样的:

$ pktgen -c COREMASK -n NUM \
             [-m NB] \
             [-r NUM] \
             [-b <domain:bus:devid.func>] \
             [--proc-type primary|secondary|auto] -- [pktgen options]

在Pktgen下的DPDK环境抽象层(EAL)的完成参数是这样的:

  -c COREMASK         : A hexadecimal bitmask of cores to run on
  -n NUM              : Number of memory channels
  -v                  : Display version information on startup
  -d LIB.so           : Add driver (can be used multiple times)
  -m MB               : Memory to allocate (see also --socket-mem)
  -r NUM              : Force number of memory ranks (don't detect)
  --xen-dom0          : Support application running on Xen Domain0 without
                        hugetlbfs
  --syslog            : Set syslog facility
  --socket-mem        : Memory to allocate on specific
                        sockets (use comma separated values)
  --huge-dir          : Directory where hugetlbfs is mounted
  --proc-type         : Type of this process
  --file-prefix       : Prefix for hugepage filenames
  --pci-blacklist, -b : Add a PCI device in black list.
                        Prevent EAL from using this PCI device. The argument
                        format is <domain:bus:devid.func>.
  --pci-whitelist, -w : Add a PCI device in white list.
                        Only use the specified PCI devices. The argument
                        format is <[domain:]bus:devid.func>. This option
                        can be present several times (once per device).
                        NOTE: PCI whitelist cannot be used with -b option
  --vdev              : Add a virtual device.
                        The argument format is <driver><id>[,key=val,...]
                        (ex: --vdev=eth_pcap0,iface=eth2).
  --vmware-tsc-map    : Use VMware TSC map instead of native RDTSC
  --base-virtaddr     : Specify base virtual address
  --vfio-intr         : Specify desired interrupt mode for VFIO
                        (legacy|msi|msix)
  --create-uio-dev    : Create /dev/uioX (usually done by hotplug)

EAL options for DEBUG use only:
  --no-huge           : Use malloc instead of hugetlbfs
  --no-pci            : Disable pci
  --no-hpet           : Disable hpet
  --no-shconf         : No shared config (mmap'd files)

下面来详细解析一下各个参数选项的意思:

  • -l:代表使用的核心

  • -w:指定网口,PCI的ID号

    • 例如3b:00.0
  • -c COREMASK:16进制掩码设置应用程序使用哪些cpu核,eg:-c 3, 3代表的是十六进制0x03,它的二进制是11,假如服务器有8个cpu核,二进制11写成00000011,从右到左依次代表核0-7,11设置使用0和1号核

    • 注意:core编号在不同的平台不一样,需要事先确定好
  • -n NUM:设置每个处理器socket的内存通道数,也就是服务器内存通道数,一般是4、6或者8通道等

  • -v:展示版本信息

  • -d LIB.so:加载额外驱动,参数可以是一个驱动文件或是包含多个驱动文件的文件夹。可以使用多个-d选项

  • -m MB:设置启动时与分配存储数量

  • -r NUM:设置内存ranks数(默认自动检测)

  • --xen-dom0:支持在Xen Domain0上运行,而无需大页

  • --syslog:设置日志设备

  • --socket-mem:预分配每个socket内存大小,可以理解为给每个发包进程使用的内存大页大小

    • 参数用逗号分隔列表值,例如:--socket-mem 1024,2048,意思是在0号socket上预分配1024M,在1号socket上分配2048M
  • --huge-dir:使用指定的hugetlbfs目录而不是自动检测的。hugetlbfs 是大页使用目录

  • --proc-type:设置当前进程类型

  • --file-prefix:为一个DPDK进程设置一个不同的共享文件前缀。使用多个不同的前缀文件允许运行多个独立的dpdk进程组。dpdk支持多进程协同完成工作,多进程使用相同的共享文件组成进程组(进程组里的进程分为primary和secondary),也就是区分每个不同发包进程内存大页空间

  • --pci-blacklist, -b:EAL不会使用黑名单中的pci设备,可以使用多个-b参数

  • --pci-whitelist, -w:添加一个pci设备到白名单中

    • 注意:一次只能使用-b和-w中的一个参数
  • --vdev:添加一个虚拟设备

  • --vmware-tsc-map:使用VMware TSC map而不是本地RDTSC

  • --base-virtaddr:DPDK的primary进程尝试使用一个不同的内存映射开始地址。 对于因为地址映射冲突而不能启动的secondary 进程非常有用

  • --vfio-intr:为绑定到VFIO内核驱动的设备指定中断模式

  • --create-uio-dev:为设备创建/dev/uioX 文件并绑定的igb_uio内核驱动(通常由ifb_uio驱动自己完成)

下面是一些DPDK的调试参数选项:

  • --no-huge:使用匿名存储而不是大页(暗指不支持多进程)
  • --no-pci:禁止pci总线
  • --no-hpet:禁止使用HPET定时器
  • --no-shconf:不创建共享文件(暗指不支持多进程)

-c COREMASK-n NUM 参数是必需的。其他参数是可选的,Pktgen需要2个逻辑核心(lcore)才能运行

下面我们来看一个完成的启动Pktgen的例子:

$ pktgen -l 0-4 -n 3 --proc-type auto --socket-mem 256,256
             -b 0000:03:00.0 -b 0000:03:00.1 \
              --file-prefix pg \
             -- -P -m "[1:3].0, [2:4].1

这里使用到的几个EAL参数:

  • -n 3:表示每个处理器socket拥有三个内存通道

  • --proc-type auto:自动设置当前进程类型

  • --socket-mem 256,256:在0号socket上预分配256M内存大小,在1号socket上预分配256M

  • --file-prefix pg:为一个DPDK进程设置一个pg的共享文件前缀

三、Pktgen命令行选项

一个简单的pktgen命令行

$ ./app/app/``$(target}``/pktgen [EAL options] -- \
                             [-h] [-P] [-G] [-T] [-f cmd_file] \
                             [-l log_file] [-s P:PCAP_file] [-m <string>]

一个更具体的例子是

$ ./app/app/x86_64-dnet-linux-gcc/pktgen [EAL选项][-h] [-P] [-G] [-T] [-f cmd_file] [-l log_file] [- s P:PCAP_file] [-m <字符串>]

简单来说就是:

  • -h:显示上面显示的用法/帮助信息:
$ lspci | grep Ethernet

这显示了系统中所有端口的列表,DPDK / Pktgen可能无法使用某些端口,列出的第一个端口是-cEAL核心掩码中的位0或最低指示位

还有一种方法编译并运行DPDK示例应用程序testpmd以列出DPDK可以使用的端口:

$ ./test_pmd -c 0x3 -n 2
  • -s P:file: 要流式传输的PCAP数据包文件,也就是给发包线程指定数据包
    • 具体情况如-s 0 : 1.pcap,0表示在第0个网卡,1.pcap表示文件路径
    • 0:pcap/big/pcap:1:使用核心1加载数据包在0号口
  • -f filename:要执行的脚本命令文件(.pkt)或Lua脚本(.lua)文件
  • -l filename:要写入日志的文件名
  • -P:启动所有网卡端口,并进入混杂模式,想指定特定网卡 用 -p mask
  • -G:让pktgen成为服务器,之后后可以进行远程控制 默认是 localhost:0x5606
  • -g address:让pktgen成为服务器,之后后可以进行远程控制 可以进行IP和端口的设置
  • -T:在VT100中启用彩色端子输出,也就是显示界面为彩色
  • -N:启用NUMA支持。
  • -m<string:用于将端口映射到逻辑核心的矩阵。端口映射字符串的格式由类似于BNF的语法定义

这个-m<string参数比较难理解,官网的给的定义和例子:

BNF: (or kind of BNF)
<matrix-string>   := """ <lcore-port> { "," <lcore-port>} """
<lcore-port>      := <lcore-list> "." <port-list>
<lcore-list>      := "[" <rx-list> ":" <tx-list> "]"
<port-list>       := "[" <rx-list> ":" <tx-list>"]"
<rx-list>         := <num> { "/" (<num> | <list>) }
<tx-list>         := <num> { "/" (<num> | <list>) }
<list>            := <num> { "/" (<range> | <list>) }
<range>           := <num> "-" <num> { "/" <range> }
<num>             := <digit>+
<digit>           := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
1.0, 2.1, 3.2                 - core 1 handles port 0 rx/tx,
                                core 2 handles port 1 rx/tx
                                core 3 handles port 2 rx/tx
1.[0-2], 2.3, ...             - core 1 handle ports 0,1,2 rx/tx,
                                core 2 handle port 3 rx/tx
[0-1].0, [2/4-5].1, ...       - cores 0-1 handle port 0 rx/tx,
                                cores 2,4,5 handle port 1 rx/tx
[1:2].0, [4:6].1, ...         - core 1 handles port 0 rx,
                                core 2 handles port 0 tx,
[1:2].[0-1], [4:6].[2/3], ... - core 1 handles port 0 & 1 rx,
                                core 2 handles port  0 & 1 tx
[1:2-3].0, [4:5-6].1, ...     - core 1 handles port 0 rx, cores 2,3 handle port 0 tx
                                core 4 handles port 1 rx & core 5,6 handles port 1 tx
[1-2:3].0, [4-5:6].1, ...     - core 1,2 handles port 0 rx, core 3 handles port 0 tx
                                core 4,5 handles port 1 rx & core 6 handles port 1 tx
[1-2:3-5].0, [4-5:6/8].1, ... - core 1,2 handles port 0 rx, core 3,4,5 handles port 0 tx
                                core 4,5 handles port 1 rx & core 6,8 handles port 1 tx
[1:2].[0:0-7], [3:4].[1:0-7], - core 1 handles port 0 rx, core 2 handles ports 0-7 tx
                                core 3 handles port 1 rx & core 4 handles port 0-7 tx
BTW: you can use "{}" instead of "[]" as it does not matter to the syntax.

这里简单理解就是:

  • .:表示lcore和port的分割
  • -:表示范围
  • /:表示关系或范围
  • ::前面表示读,后面表示写

例如[1:2].[0-1], [4:6].[2/3],意思就是:

  • lcore=1 进行 0-1 的 Rx
  • lcore=2 进行 0-1 的 Tx
  • lcore=4 进行 2和3 的 Rx
  • lcore=6 进行 2和3 的 Tx

下面来看一个我一般日常使用的一个完整的打流的指令:

$ /root/pktgen-3.1.2_work/app/arm64-armv8a-linuxapp-gcc/pktgen -l 1-16,65-93 -n 8 --proc-type auto --socket-mem 10240,10240 -- -T -P -m [2:3-7].0 -m [9:10-14].1 -m [65:66-70].2 -m [72:73-77].3 -f scripts/mytest.lua

这里需要提前告诉一下在我的机器上执行lspci | grep Ethernet后显示的端口列表

$ lspci | grep Ethernet
03:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
04:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
05:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
06:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
7d:00.0 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21)
7d:00.1 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21)
7d:00.2 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21)
7d:00.3 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21)
85:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
86:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
87:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
88:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)

下面我们来一步步解析这条指令:

  • /root/pktgen-3.1.2_work/app/arm64-armv8a-linuxapp-gcc/pktgen:这个表示我们执行的是在arm64-armv8a-linuxapp-gcc环境下的pktgen
  • -l 1-16,65-93:代表使用1-16号处理器核心和65-93号处理器核心,共45个核心
  • -n 8:每个处理器socket拥有8个内存通道
  • --proc-type auto:自动设置当前进程类型
  • --socket-mem 10240,10240:在0号socket上预分配10240M内存大小,在1号socket上预分配10240M
  • -T:在VT100中启用彩色端子输出
  • -P:启动所有网卡端口,并进入混杂模式
  • -m [2:3-7].0
    • lcore=2进行网卡端口0的Rx
    • lcore=3-7进行网卡端口0的Tx
  • -m [9:10-14].1
    • lcore=9进行网卡端口1的Rx
    • lcore=10-14进行网卡端口1的Tx
  • -m [65:66-70].2
    • lcore=65进行网卡端口2的Rx
    • lcore=66-70进行网卡端口2的Tx
  • -m [72:73-77].3
    • lcore=72进行网卡端口3的Rx
    • lcore=73-77进行网卡端口3的Tx
  • -f scripts/mytest.lua:指定了一个脚本文件mytest.lua

四、Pktgen运行时选项和命令

在pktgen运行时,进入pktgen应用程序后有不同的选项和指令可以操作和控制pktgen的运行

4.1 help

执行help指令可以获得帮助:

Pktgen:/> help

set <portlist> <xxx> value    - Set a few port values
save <path-to-file>           - Save a configuration file using the
                                filename
load <path-to-file>           - Load a command/script file from the
                                given path
...

4.2 page

page指令可以显示不同的屏幕:

page <pages>                      - Show the port pages or configuration or sequence page
    [0-7]                         - Page of different ports
    main                          - Display page zero
    range                         - Display the range packet page
    config | cfg                  - Display the configuration page
    pcap                          - Display the pcap page
    cpu                           - Display some information about the CPU system
    next                          - Display next page of PCAP packets.
    sequence | seq                - sequence will display a set of packets for a given port
                                    Note: use the 'port <number>' to display a new port sequence
    rnd                           - Display the random bitfields to packets for a given port
                                    Note: use the 'port <number>' to display a new port sequence
    log                           - Display the log messages page
    latency                       - Display the latency page
    stats                         - Display physical ports stats for all ports
    xstats                        - Display the extended stats per port
  • [0-7]:可以展示不同端口的页面,
  • main:展示程序运行的主页面
  • range:展示设置生成包各类参数的页面,可以查看各个端口设置包的参数
  • config|cfg:显示配置页面
  • pcap:展示配置pcap包的页面(如果制定了pcap文件的话)
  • cpu:显示有关CPU系统的一些信息
  • next:显示PCAP数据包的下一页
  • sequence | seq:序列将显示给定端口的一组数据包
    • 格式prot <number>
  • rnd:显示给定端口的数据包的随机位域
    • 格式prot <number>
  • log:显示日志消息页面
  • latency:显示时间延迟页面
  • states:显示所有物理端口的统计信息
  • xstates:显示每个端口的扩展统计信息

下面展示一下不同页面的情况

4.2.1 main
-- Ports 0-3 of 8   <Main Page>  Copyright (c) <2010-2019>, Intel Corporation
        Flags:Port        :   P----S---------:0   P--------------:1   P--------------:2   P--------------:3
        Link State        :       <UP-10000-FD>       <UP-10000-FD>       <UP-10000-FD>       <UP-10000-FD>     ----TotalRate----
        Pkts/s Max/Rx     :                 0/0                 0/0                 0/0                 0/0                   0/0
               Max/Tx     :                 0/0                 0/0                 0/0                 0/0                   0/0
        MBits/s Rx/Tx     :                 0/0                 0/0                 0/0                 0/0                   0/0
                          :
        Latency usec      :                   0                   0                   0                   0
        Jitter Threshold  :                  50                  50                  50                  50
        Jitter count      :                   0                   0                   0                   0
        Total Rx pkts     :                   0                   0                   0                   0
        Jitter percent    :                   0                   0                   0                   0
                          :
        Pattern Type      :             abcd...             abcd...             abcd...             abcd...
        Tx Count/% Rate   :       Forever /100%       Forever /100%       Forever /100%       Forever /100%
        PktSize/Tx Burst  :           64 /   32           64 /   32           64 /   32           64 /   32
        Src/Dest Port     :         1234 / 5678         1234 / 5678         1234 / 5678         1234 / 5678
        Pkt Type:VLAN ID  :     IPv4 / TCP:0001     IPv4 / TCP:0001     IPv4 / TCP:0001     IPv4 / TCP:0001
        Dst  IP Address   :         192.168.1.1         192.168.0.1         192.168.3.1         192.168.2.1
        Src  IP Address   :      192.168.0.1/24      192.168.1.1/24      192.168.2.1/24      192.168.3.1/24
        Dst MAC Address   :   3c:fd:fe:9c:5c:d9   3c:fd:fe:9c:5c:d8   3c:fd:fe:9c:5c:db   3c:fd:fe:9c:5c:da
        Src MAC Address   :   3c:fd:fe:9c:5c:d8   3c:fd:fe:9c:5c:d9   3c:fd:fe:9c:5c:da   3c:fd:fe:9c:5c:db
        VendID/PCI Addr   :   8086:1572/04:00.0   8086:1572/04:00.1   8086:1572/04:00.2   8086:1572/04:00.3

        -- Pktgen Ver: 3.2.4 (DPDK 17.05.0-rc0)  Powered by DPDK ---------------
4.2.2 range
Port #                           Port-0              Port-1              Port-2              Port-3
dst.ip            :         192.168.1.1         192.168.2.1         192.168.3.1         192.168.4.1
    inc           :             0.0.0.1             0.0.0.1             0.0.0.1             0.0.0.1
    min           :         192.168.1.1         192.168.2.1         192.168.3.1         192.168.4.1
    max           :       192.168.1.254       192.168.2.254       192.168.3.254       192.168.4.254
                  :
src.ip            :         192.168.0.1         192.168.1.1         192.168.2.1         192.168.3.1
    inc           :             0.0.0.0             0.0.0.0             0.0.0.0             0.0.0.0
    min           :         192.168.0.1         192.168.1.1         192.168.2.1         192.168.3.1
    max           :       192.168.0.254       192.168.1.254       192.168.2.254       192.168.3.254
                  :
ip_proto          :                 TCP                 TCP                 TCP                 TCP
                  :
dst.port / inc    :             0/    1           256/    1           512/    1           768/    1
     min / max    :             0/  254           256/  510           512/  766           768/ 1022
                  :
src.port / inc    :             0/    1           256/    1           512/    1           768/    1
     min / max    :             0/  254           256/  510           512/  766           768/ 1022
                  :
vlan.id / inc     :              1/   0              1/   0              1/   0              1/   0
    min / max     :              1/4095              1/4095              1/4095              1/4095
                  :
pkt.size / inc    :             64/   0             64/   0             64/   0             64/   0
     min / max    :             64/1518             64/1518             64/1518             64/1518
                  :
dst.mac           :   3c:fd:fe:9c:5c:d9   3c:fd:fe:9c:5c:d8   3c:fd:fe:9c:5c:db   3c:fd:fe:9c:5c:da
    inc           :   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00
    min           :   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00
    max           :   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00
                  :
src.mac           :   3c:fd:fe:9c:5c:d8   3c:fd:fe:9c:5c:d9   3c:fd:fe:9c:5c:da   3c:fd:fe:9c:5c:db
    inc           :   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00
    min           :   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00
    max           :   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00   00:00:00:00:00:00
                  :
gtpu.teid / inc   :             0/    0             0/    0             0/    0             0/    0
      min / max   :             0/    0             0/    0             0/    0             0/    0
-- Pktgen Ver: 3.2.4 (DPDK 17.05.0-rc0)  Powered by DPDK ---------------

Pktgen:/>
4.2.3 config
<CPU Page>  Copyright (c) <2010-2019>, Intel Corporation
 2 sockets, 18 cores, 2 threads
  Socket   :    0         1      Port description
  Core   0 : [ 0,36]   [18,54]   0000:04:00.0 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core   1 : [ 1,37]   [19,55]   0000:04:00.1 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core   2 : [ 2,38]   [20,56]   0000:04:00.2 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core   3 : [ 3,39]   [21,57]   0000:04:00.3 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core   4 : [ 4,40]   [22,58]   0000:05:00.0 : Intel Corporation I350 Gigabit Network Connection (rev 01)
  Core   5 : [ 5,41]   [23,59]   0000:05:00.1 : Intel Corporation I350 Gigabit Network Connection (rev 01)
  Core   6 : [ 6,42]   [24,60]   0000:81:00.0 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core   7 : [ 7,43]   [25,61]   0000:81:00.1 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core   8 : [ 8,44]   [26,62]   0000:81:00.2 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core   9 : [ 9,45]   [27,63]   0000:81:00.3 : Intel Corporation X710 for 10GbE SFP+ (rev 01)
  Core  10 : [10,46]   [28,64]   0000:82:00.0 : Intel Corporation XL710 for 40GbE QSFP+ (rev 02)
  Core  11 : [11,47]   [29,65]   0000:83:00.0 : Intel Corporation XL710 for 40GbE QSFP+ (rev 02)
  Core  12 : [12,48]   [30,66]
  Core  13 : [13,49]   [31,67]
  Core  14 : [14,50]   [32,68]
  Core  15 : [15,51]   [33,69]
  Core  16 : [16,52]   [34,70]
  Core  17 : [17,53]   [35,71]

  -- Pktgen Ver: 3.2.4 (DPDK 17.05.0-rc0)  Powered by DPDK ---------------
4.2.4 cpu
<CPU Page>  Copyright (c) <2010-2019>, Intel Corporation

Kernel: Linux rkwiles-DESK1.intel.com 4.4.0-66-generic #87-Ubuntu SMP Fri Mar 3 15:29:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Model Name: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz
CPU Speed : 1201.031
Cache Size: 46080 KB

CPU Flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts
  2 sockets, 18 cores per socket and 2 threads per core.
  Socket   :    0         1
  Core   0 : [ 0,36]   [18,54]
  Core   1 : [ 1,37]   [19,55]
  Core   2 : [ 2,38]   [20,56]
  Core   3 : [ 3,39]   [21,57]
  Core   4 : [ 4,40]   [22,58]
  Core   5 : [ 5,41]   [23,59]
  Core   6 : [ 6,42]   [24,60]
  Core   7 : [ 7,43]   [25,61]
  Core   8 : [ 8,44]   [26,62]
  Core   9 : [ 9,45]   [27,63]
  Core  10 : [10,46]   [28,64]
  Core  11 : [11,47]   [29,65]
  Core  12 : [12,48]   [30,66]
  Core  13 : [13,49]   [31,67]
  Core  14 : [14,50]   [32,68]
  Core  15 : [15,51]   [33,69]
  Core  16 : [16,52]   [34,70]
  Core  17 : [17,53]   [35,71]
4.2.6 sequence
<Sequence Page>  Copyright (c) <2010-2019>, Intel Corporation
  Port   :  0, Sequence Count:  8 of 16                                                                            GTPu
    * Seq:            Dst MAC           Src MAC          Dst IP            Src IP    Port S/D Protocol:VLAN  Size  TEID
    *   0:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0
    *   1:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0
    *   2:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0
    *   3:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0
    *   4:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0
    *   5:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0
    *   6:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0
    *   7:  3c:fd:fe:9c:5c:d9 3c:fd:fe:9c:5c:d8     192.168.1.1    192.168.0.1/24   1234/5678 IPv4/TCP:0001   64     0

    -- Pktgen Ver: 3.2.4 (DPDK 17.05.0-rc0)  Powered by DPDK ---------------
4.2.7 rnd
Port 0           <Random bitfield Page>  Copyright (c) <2010-2019>, Intel Corporation
  Index   Offset     Act?  Mask [0 = 0 bit, 1 = 1 bit, X = random bit, . = ignore]
     0        0      No   00000000 00000000 00000000 00000000
     1        0      No   00000000 00000000 00000000 00000000
     2        0      No   00000000 00000000 00000000 00000000
     3        0      No   00000000 00000000 00000000 00000000
     4        0      No   00000000 00000000 00000000 00000000
     5        0      No   00000000 00000000 00000000 00000000
     6        0      No   00000000 00000000 00000000 00000000
     7        0      No   00000000 00000000 00000000 00000000
     8        0      No   00000000 00000000 00000000 00000000
     9        0      No   00000000 00000000 00000000 00000000
     10       0      No   00000000 00000000 00000000 00000000
     11       0      No   00000000 00000000 00000000 00000000
     12       0      No   00000000 00000000 00000000 00000000
     13       0      No   00000000 00000000 00000000 00000000
     14       0      No   00000000 00000000 00000000 00000000
     15       0      No   00000000 00000000 00000000 00000000
     16       0      No   00000000 00000000 00000000 00000000
     17       0      No   00000000 00000000 00000000 00000000
     18       0      No   00000000 00000000 00000000 00000000
     19       0      No   00000000 00000000 00000000 00000000
     20       0      No   00000000 00000000 00000000 00000000
     21       0      No   00000000 00000000 00000000 00000000
     22       0      No   00000000 00000000 00000000 00000000
     23       0      No   00000000 00000000 00000000 00000000
     24       0      No   00000000 00000000 00000000 00000000
     25       0      No   00000000 00000000 00000000 00000000
     26       0      No   00000000 00000000 00000000 00000000
     27       0      No   00000000 00000000 00000000 00000000
     28       0      No   00000000 00000000 00000000 00000000
     29       0      No   00000000 00000000 00000000 00000000
     30       0      No   00000000 00000000 00000000 00000000
     31       0      No   00000000 00000000 00000000 00000000
     -- Pktgen Ver: 3.2.4 (DPDK 17.05.0-rc0)  Powered by DPDK -----

4.3 enable/disable

enabledisable命令用于开启或者关闭指定端口的功能,指令格式:

$ enable|disable <portlist> <features>

完成的指令参数如下:

enable|disable <portlist> <features>
    Feature - process              - Enable or Disable processing of ARP/ICMP/IPv4/IPv6 packets
              mpls                 - Enable/disable sending MPLS entry in packets
              qinq                 - Enable/disable sending Q-in-Q header in packets
              gre                  - Enable/disable GRE support
              gre_eth              - Enable/disable GRE with Ethernet frame payload
              vlan                 - Enable/disable VLAN tagging
              garp                 - Enable or Disable Gratuitous ARP packet processing
              random               - Enable/disable Random packet support
              latency              - Enable/disable latency testing
              pcap                 - Enable or Disable sending pcap packets on a portlist
              blink                - Blink LED on port(s)
              rx_tap               - Enable/Disable RX Tap support
              tx_tap               - Enable/Disable TX Tap support
              icmp                 - Enable/Disable sending ICMP packets
              range                - Enable or Disable the given portlist for sending a range of packets
              capture              - Enable/disable packet capturing on a portlist
              bonding              - Enable call TX with zero packets for bonding driver
              short                - Allow shorter then 64 byte frames to be sent
              vxlan                - Send VxLAN packets

enable|disable screen              - Enable/disable updating the screen and unlock/lock window
               mac_from_arp        - Enable/disable MAC address from ARP packet
off                                - screen off shortcut
on                                 - screen on shortcut
  • process:启用或禁用ARP / ICMP / IPv4 / IPv6数据包处理

  • mpls:启用/禁用在数据包中发送MPLS条目

  • qinq:启用/禁用在数据包中发送Q-in-Q标头

  • gre:启用/禁用GRE支持

  • gre_eth:启用/禁用以太网帧负载GRE支持

  • vlan:启用/禁用VLAN标记

  • garp:启用或禁用免费ARP数据包处理

  • random:启用/禁用随机数据包支持

  • latency:启用/禁用延迟测试

  • pcap:启用或禁用在端口列表上发送pcap数据包

  • blink:启用或禁用端口上的LED闪烁

  • rx_tap:启用/禁用RX Tap支持

  • tx_tap:启用/禁用TX Tap支持

  • icmp:启用/禁用发送ICMP数据包

  • range:启用或禁用给定的端口列表以发送一定范围的数据包

  • capture:在端口列表上启用/禁用数据包捕获

  • bonding:在绑定设备中启用或禁用发送0内容数据包

  • short:允许发送短于64字节的帧

  • vxlan:启用或禁用发送VxLAN数据包

  • screen:启用/禁用更新屏幕和解锁/锁定窗口

  • mac_from_arp:启用/禁用ARP数据包中的MAC地址

  • off:屏幕关闭快捷方式

  • on:屏幕开启快捷方式

4.4 set

set指令主要用于设置端口的信息,指令格式:

note: <portlist> - a list of ports (no spaces) e.g. 2,4,6-9,12 or the word 'all'
set <portlist> count <value>       - number of packets to transmit
set <portlist> size <value>        - size of the packet to transmit
set <portlist> rate <percent>      - Packet rate in percentage
set <portlist> burst <value>       - number of packets in a burst
set <portlist> tx_cycles <value>   - DEBUG to set the number of cycles per TX burst
set <portlist> sport <value>       - Source port number for TCP
set <portlist> dport <value>       - Destination port number for TCP
set <portlist> seq_cnt|seqcnt|seqCnt <value>
                                   - Set the number of packet in the sequence to send [0-16]
set <portlist> prime <value>       - Set the number of packets to send on prime command
set <portlist> dump <value>        - Dump the next N received packets to the screen
set <portlist> vlan <value>        - Set the VLAN ID value for the portlist
set <portlist> jitter <value>      - Set the jitter threshold in micro-seconds
set <portlist> src|dst mac <addr>  - Set MAC addresses 00:11:22:33:44:55 or 0011:2233:4455 format
set <portlist> type ipv4|ipv6|vlan|arp - Set the packet type to IPv4 or IPv6 or VLAN
set <portlist> proto udp|tcp|icmp  - Set the packet protocol to UDP or TCP or ICMP per port
set <portlist> pattern <type>      - Set the fill pattern type
                 type - abc        - Default pattern of abc string
                        none       - No fill pattern, maybe random data
                        zero       - Fill of zero bytes
                        user       - User supplied string of max 16 bytes
set <portlist> user pattern <string> - A 16 byte string, must set 'pattern user' command
set <portlist> [src|dst] ip ipaddr - Set IP addresses, Source must include network mask e.g. 10.1.2.3/24
set <portlist> qinqids <id1> <id2> - Set the Q-in-Q ID's for the portlist
set <portlist> rnd <idx> <off> <mask> - Set random mask for all transmitted packets from portlist
    idx: random mask index slot
    off: offset in bytes to apply mask value
    mask: up to 32 bit long mask specification (empty to disable):
          0: bit will be 0
          1: bit will be 1
          .: bit will be ignored (original value is retained)
          X: bit will get random value
set <portlist> cos <value>         - Set the CoS value for the portlist
set <portlist> tos <value>         - Set the ToS value for the portlist
set <portlist> vxlan <flags> <group id> <vxlan_id> - Set the vxlan values
set ports_per_page <value>         - Set ports per page value 1 - 6
  • set <portlist> count <value>:发送报文数量

  • set <portlist> size <value>:发送报文大小

  • set <portlist> rate <percent>:发送报文速率百分比

  • set <portlist> burst <value>:批量收发报文数量

  • set <portlist> tx_cycles <value>:调试以设置每个TX突发的周期数

  • set <portlist> sport <value>:TCP源端口号

  • set <portlist> dport <value>:TCP目的端口号

  • set <portlist> seq_cnt|seqcnt|seqCnt <value>:设置发送顺序中的包数[0-16]

  • set <portlist> prime <value>:设置在prime命令上发送的数据包数量

  • set <portlist> dump <value>:将接下来的N个接收到的数据包转储到屏幕上

  • set <portlist> vlan <value>:设置端口列表的VLAN ID值

  • set <portlist> jitter <value>:设置抖动阈值(以微秒为单位)

  • set <portlist> src|dst mac <addr>:设置源端口或者目的端口MAC地址00:11:22:33:44:55或0011:2233:4455格式

  • set <portlist> type ipv4|ipv6|vlan|arp:将数据包类型设置为IPv4或IPv6或VLAN

  • set <portlist> proto udp|tcp|icmp:将每个端口的数据包协议设置为UDP或TCP或ICMP

  • set <portlist> pattern <type>:设置填充数据类型

    • abc:默认填充的数据为字符串abc
    • none:没有填充模式,可能是随机数据
    • zero:不填充任何数据
    • user:用户提供的最大16个字节的字符串
  • set <portlist> user pattern <string>:一个16字节的字符串,必须在之前设置pattern user命令

  • set <portlist> [src|dst] ip ipaddr:设置源IP地址或者目的IP地址,格式类似10.1.2.3/24

  • set <portlist> qinqids <id1> <id2>:设置端口列表的Q-in-Q ID

  • set <portlist> rnd <idx> <off> <mask>:为端口列表中的所有传输数据包设置随机掩码

    • idx:随机掩码索引槽
    • off:以字节为单位的偏移量,以应用掩码值
    • mask:最长32位长的掩码规范(可禁用):
      • 0:位将为0
      • 1:位将为1
      • .:位将被忽略(保留原始值)
      • X:位将获得随机值
  • set <portlist> cos <value>:设置端口列表的cos值

  • set <portlist> tos <value>:设置端口列表的tos值

  • set <portlist> vxlan <flags> <group id> <vxlan_id>:设置vxlan值

  • set ports_per_page <value>:设置每页端口值1-6

4.5 range

range命令主要用于设置包内容的随机数值范围,例如:

-- 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> proto tcp|udp                - Set the IP protocol type
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

对于每一个参数选项,我们都需要设置SMMI,也就是这个参数的起始值、最小值、最大值和增量

  • range <portlist> src|dst mac <SMMI> <etheraddr>:设置目的或者源MAC地址
    • 一些例子
      • range 0 src mac start 00:00:00:00:00:00
      • range 0 dst mac max 00:12:34:56:78:90
      • 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>:设置目的或者源IP地址
    • 一些例子
      • 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
      • range 0 dst ip 0.0.0.0 0.0.0.0 1.2.3.4 0.0.1.0
  • range <portlist> proto tcp|udp:设置IP协议类型
  • range <portlist> src|dst port <SMMI> <value>:设置UDP和TCP的源或目的端口
    • 或者另一种形式range <portlist> src|dst port <start> <min> <max> <inc>
  • range <portlist> vlan <SMMI> <value>:设置VLAN ID的起始地址
    • range <portlist> vlan <start> <min> <max> <inc>
  • range <portlist> size <SMMI> <value>:设置包的大小
    • range <portlist> size <start> <min> <max> <inc>
  • range <portlist> teid <SMMI> <value>:设置TEID值
  • range <portlist> mpls entry <hex-value>:设置MPLS表项值
  • range <portlist> qinq index <val1> <val2>:设置qinq
  • range <portlist> gre key <value>:设置gre
  • range <portlist> cos <SMMI> <value>:设置cos
  • range <portlist> tos <SMMI> <value>:设置tos
  • 6
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值