一、前言
pktgen-dpdk是用于对DPDK进行高速数据包测试的工具,本文将介绍如何编译以及使用pktgen。
转载自https://blog.csdn.net/cloudvtech
二、编译pktgen-dpdk
2.1 版本信息:
OS: CentOS 7.2.1511
DPDK: dpdk-stable-17.08.1 (https://fast.dpdk.org/rel/dpdk-17.08.1.tar.xz)
PKTGEN: pktgen-3.4.2 (http://dpdk.org/browse/apps/pktgen-dpdk/snapshot/pktgen-3.4.2.tar.gz)
下载
wget http://dpdk.org/browse/apps/pktgen-dpdk/snapshot/pktgen-3.4.2.tar.gz
tar -zxvf pktgen-3.4.2.tar.gz
cd pktgen-3.4.2
编译
export RTE_SDK=/root/dpdk-stable-17.08.1
export RTE_TARGET=x86_64-native-linuxapp-gcc
make
and the binary is at app/x86_64-native-linuxapp-gcc/pktgen
2.2 试运行
VM配置为4个core、4GB内存
# core 0 as master, 1 and 2 as slave
./app/x86_64-native-linuxapp-gcc/pktgen -l 0-2 -n 3 -- -P -m "[1].0, [2].1"
转载自https://blog.csdn.net/cloudvtech
三、pktgen send packet to testpmd, 1 DPDK NIC in promiscuous mode
3.1 测试环境
两个虚拟机VM1和VM2,每个虚拟机两个网卡,一个给DPDK用,一个给管理用。
VM1: pktgen(port 0 send out) -> VM2: testpmd(port 0 rxonly)
3.2 虚拟机VM1上面的配置运行pktgen
IP: 192.168.166.131
DPDK NIC ens34: 00:0c:29:3d:d7:10
运行pktgen
cd dpdk-stable-17.08.1
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
modprobe uio_pci_generic
modprobe uio
modprobe vfio-pci
insmod build/kmod/igb_uio.ko
ifconfig ens34 down
./usertools/dpdk-devbind.py --bind=igb_uio 02:02.0
# run pktgen
cd ../pktgen-3.4.2
./app/x86_64-native-linuxapp-gcc/pktgen -l 0-1 -n 3 -- -P -m "[1].0"
set 0 dst mac 00:0C:29:D0:46:4C
set 0 count 100000
str
# test with 10000000
set 0 dst mac 00:0C:29:D0:46:4C
set 0 count 10000000
str
3.3 虚拟机VM2上面的配置运行testpmd
IP: 192.168.166.131
DPDK NIC ens34: 00:0c:29:d0:46:4c
#setup
cd dpdk-stable-17.08.1
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
modprobe uio_pci_generic
modprobe uio
modprobe vfio-pci
insmod build/kmod/igb_uio.ko
ifconfig ens34 down
./usertools/dpdk-devbind.py --bind=igb_uio 02:02.0
# run testpmd
cd dpdk-stable-17.08.1
./build/app/testpmd -l 0-1 -n 1 -- -i
set fwd rxonly
show port stats all
clear port stats all
start
四、pktgen send packet to testpmd, 1 DPDK NIC no promiscuous mode
4.1 测试环境与上一节描述的类似
4.2 VM1上面运行pktgen
IP: 192.168.166.131
DPDK NIC ens34: 00:0c:29:3d:d7:10
# setups
1. huge memory
2. uio kernel module
3. bind NIC to DPDK
# run pktgen
cd ../pktgen-3.4.2
./app/x86_64-native-linuxapp-gcc/pktgen -l 0-1 -n 3 -- -P -m "[1].0"
set 0 dst mac 00:0C:29:D0:46:4C
set 0 count 1000000
set 0 rate 1
str
4.3 VM2上面的设置
IP: 192.168.166.131
DPDK NIC ens34: 00:0c:29:d0:46:4c
# setups
1. huge memory
2. uio kernel module
3. bind NIC to DPDK
# run testpmd
cd dpdk-stable-17.08.1
./build/app/testpmd -l 0-1 -n 1 -- -i
set fwd rxonly
show port stats all
clear port stats all
start
转载自https://blog.csdn.net/cloudvtech