Pktgen-DPDK install 安装部署

声明:此文档只做学习交流使用,请勿用作其他商业用途

author:朝阳_tony
E-mail : [email protected]
Create Date: 2013-7-10 13:59:31 Wednesday
Last Change: 2013-7-14 22:53:11 Sunday

转载请注明出处:http://blog.csdn.net/linzhaolover


此文中源码可以去http://dpdk.org/dev 网页中下载;更多官方文档请访问http://dpdk.org



Pktgen-DPDK介绍

Pktgen-DPDK是6wind基于intel dpdk开发的一个发包工具;用于测试dpdk的包转发能力;

可以在https://github.com/Pktgen/Pktgen-DPDK看到其详细信息;


我的测试环境为REHL6.2系统;


 下载源码方式

git  clone  http://github.com/Pktgen/Pktgen-DPDK.git


 安装编译源码;

下载源码后进入Pktgen-DPDK/dpdk目录,执行安装;

make install T=x86_64-wr-linuxapp-gcc

如遇下面的变量名重复定义错误;

In file included from /home/linzh/repo/Pktgen-DPDK/dpdk/lib/libwr_mcos/rte_mcos.c:81:
/home/linzh/repo/Pktgen-DPDK/dpdk/lib/libwr_mcos/rte_mcos.h:321: error: redefinition of typedef ‘mcos_master_t’
/home/linzh/repo/Pktgen-DPDK/dpdk/lib/libwr_mcos/rte_mcos_debug.h:114: note: previous declaration of ‘mcos_master_t’ was here
/home/linzh/repo/Pktgen-DPDK/dpdk/lib/libwr_mcos/rte_mcos.h:385: error: redefinition of typedef ‘mInfo_t’
/home/linzh/repo/Pktgen-DPDK/dpdk/lib/libwr_mcos/rte_mcos_debug.h:113: note: previous declaration of ‘mInfo_t’ was here
需要自己去修改一下文件变量定义,我只是临时做了一下修改;

vim /home/linzh/repo/Pktgen-DPDK/dpdk/lib/libwr_mcos/rte_mcos_debug.h

%s/mInfo_t/mInfo_t_bak/g
%s/mcos_master_t/mcos_master_t_bak/g
将rte_mcos_debug.h文件中的mInfo_t 更名为mInfo_t_bak   ,   将mcos_master_t 更名为mcos_master_t_bak ;

设置环境变量;

export RTE_SDK=`pwd`

export RTE_TARGET=x86_64-wr-linuxapp-gcc

执行脚本进行安装配置;

./tools/setup.sh
运行脚本后分别运行

[6] Insert IGB UIO module
[7] Insert KNI module
[8] Setup hugepage mappings for non-NUMA systems
安装新的intel网卡驱动;

设置hugepage 信息,我输入了1024,也就是分配1024个2M的内存,等于2G的内存空间;

运行11,进行一下dpdk的测试;在11中如果一个core源码,如果输入  F 敲回车, 也就是用 0至3这几个core去测试;

[11] Run testpmd application in interactive mode ($RTE_TARGET/app/testpmd)
Option: 11


  Enter hex bitmask of cores to execute testpmd app on
  Example: to execute app on cores 0 to 7, enter 0xff
bitmask:F

输入F敲回车后,

显示下面的部分信息,说明成功了

Interactive-mode selected
Configuring Port 0
PMD: To improve 1G driver performance, consider setting the TX WTHRESH value to 4, 8, or 16.
Configuring Port 1
PMD: To improve 1G driver performance, consider setting the TX WTHRESH value to 4, 8, or 16.
Configuring Port 2
PMD: To improve 1G driver performance, consider setting the TX WTHRESH value to 4, 8, or 16.
Configuring Port 3
PMD: To improve 1G driver performance, consider setting the TX WTHRESH value to 4, 8, or 16.
Checking link statuses...
Port 0 Link Up - speed 1000 Mbps - full-duplex
Port 1 Link Up - speed 1000 Mbps - full-duplex
Port 2 Link Up - speed 1000 Mbps - full-duplex
Port 3 Link Up - speed 1000 Mbps - full-duplex
Done
testpmd>


然后在分别运行start 和 stop命令试试;

testpmd> start
  io packet forwarding - CRC stripping disabled - packets/burst=16
  nb forwarding cores=1 - nb forwarding ports=4
  RX queues=1 - RX desc=128 - RX free threshold=0
  RX threshold registers: pthresh=8 hthresh=8 wthresh=4
  TX queues=1 - TX desc=512 - TX free threshold=0
  TX threshold registers: pthresh=36 hthresh=0 wthresh=0
  TX RS bit threshold=0 - TXQ flags=0x0
testpmd> stop
Telling cores to stop...
Waiting for lcores to finish...

  ---------------------- Forward statistics for port 0  ----------------------
  RX-packets: 24             RX-dropped: 0             RX-total: 24
  TX-packets: 0              TX-dropped: 0             TX-total: 0
  ----------------------------------------------------------------------------

  ---------------------- Forward statistics for port 1  ----------------------
  RX-packets: 24             RX-dropped: 0             RX-total: 24
  TX-packets: 0              TX-dropped: 0             TX-total: 0
  ----------------------------------------------------------------------------

  ---------------------- Forward statistics for port 2  ----------------------
  RX-packets: 24             RX-dropped: 0             RX-total: 24
  TX-packets: 0              TX-dropped: 0             TX-total: 0
  ----------------------------------------------------------------------------

  ---------------------- Forward statistics for port 3  ----------------------
  RX-packets: 24             RX-dropped: 0             RX-total: 24
  TX-packets: 0              TX-dropped: 0             TX-total: 0
  ----------------------------------------------------------------------------

  +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
  RX-packets: 96             RX-dropped: 0             RX-total: 96
  TX-packets: 0              TX-dropped: 0             TX-total: 0
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Done.
testpmd>

下面测试pktgen

进入Pktgen-DPDK/dpdk/wr-examples/pktgen目录;

执行make去编译pktgen;

运行setup脚本,去配置一下环境,这个脚本其实是配置了一下hugepage,和从新安装了一下intel网卡的驱动;

./setup


运行doit去测试pktgen;

./doit

如果发现报错;

EAL: coremask set to e
EAL: Auto-detected process type: PRIMARY
EAL: Detected lcore 1 as core 1 on socket 0
EAL: Detected lcore 2 as core 2 on socket 0
EAL: Detected lcore 3 as core 8 on socket 0
EAL: Setting up hugepage memory...
EAL: Ask a virtual area of 0x80000000 bytes
EAL: Virtual area found at 0x7f1a14e00000 (size = 0x80000000)
EAL: Not enough memory available on socket 1! Requested: 128MB, available: 0MB
PANIC in rte_eal_init():
Cannot init memory
6: [./app/build/pktgen() [0x4038b9]]
5: [/lib64/libc.so.6(__libc_start_main+0xfd) [0x7f1a95368cdd]]
4: [./app/build/pktgen() [0x41595f]]
3: [./app/build/pktgen() [0x49aabb]]
2: [./app/build/pktgen() [0x49fea0]]
1: [./app/build/pktgen() [0x49fd86]]
./doit: line 8:  3445 Aborted                 (core dumped) ./app/build/pktgen -c e -n 3 --proc-type auto --socket-mem 128,128 --file-prefix pg -- -p 0x14 -P -m "2.0, 3.1" -f test/set_seq.cmd

这应该是执行程序是,传入测参数报错;
--socket-mem 128,128
这参数有问题,我暂时没有解决方法,也不理解这个参数的具体用途 ;将后面的128去掉再运行;

./app/build/pktgen -c e -n 3 --proc-type auto --socket-mem 128 --file-prefix pg -- -p 0x14 -P -m "2.0, 3.1" -f test/set_seq.cmd

-c 是指选择的core的掩码, e  等于  1110  也就是选择  1 、 2 、3 号core;  

--proc-type  选择的auto  ,如果是当前系统第一执行的dpdk相关的程序,选择primary模式,如果是第二是 secondary 模式;

--file-prefix  pg   设置/mnt/huge/内存分配模块的文件名前缀;

-p  0x14     0x14 等于    00010100  , 选择你当前系统的其中2块intel相关网卡端口;

-P  使能网络混装模式,

-m "2.0, 3.1"   这是指一个矩阵模型,2.0  是指,在2号lcore上绑定的端口0 ,  3.1  是指在 lcore3 上绑定端口1

-f test/set_seq.cmd  最后导入pktgen的执行配置文件;在执行pktgen时,利用配置产生数据包;


最终出现下面的界面;可以更具官方提供的README.pktgen文件,执行一些配置,和相关的测试;
| Ports 0-1 of 2   ** Main Page **  Copyright (c) <2010-2013>, Wind River Systems, Inc., Powered by Intel® DPDK
  Flags:Port     :      P---------:0      P---------:1
Link State       :                                                   ---TotalRate---
Pkts/s  Rx       :                 6                 6                                                    12
        Tx       :                 0                 0                                                     0
MBits/s Rx/Tx    :               0/0               0/0                                                   0/0
Broadcast        :                 0                 0
Multicast        :                 0                 0
  64 Bytes       :                 0                 0
  65-127         :                 0                 0
  128-255        :                 0                 0
  256-511        :                 0                 0
  512-1023       :                 0                 0
  1024-1518      :                 0                 0
Runts/Jumbos     :               0/0               0/0
Errors Rx/Tx     :               0/0               0/0
Total Rx Pkts    :                39                13
      Tx Pkts    :                 0                 0
      Rx MBs     :                 0                 0
      Tx MBs     :                 0                 0
ARP/ICMP Pkts    :               0/0               0/0
Tx Failed        :                 0                 0
                 :          229386/1          229386/1
Tx Count/% Rate  :      Forever/100%      Forever/100%
PktSize/Tx Burst :            64/128            64/128
Src/Dest Port    :         1234/5678         1234/5678
Pkt Type:VLAN ID :     IPv4/TCP:0001     IPv4/TCP:0001
Dst  IP Address  :       192.168.1.1       192.168.0.1
Src  IP Address  :    192.168.0.1/24    192.168.1.1/24
Dst MAC Address  :    0016:31ff:d074    0016:31ff:d01a
Src MAC Address  :    0016:31ff:d01a    0016:31ff:d074
-- Pktgen Ver:2.1.3(DPDK-1.3.0) -------------------------------------------------------------------------------------




pktgen> # *** Executing file (test/set_seq.cmd)
pktgen> *** Unable to find file (test/set_seq.cmd) or invalid call
pktgen>


技术水平有待提高,如有不对的地方希望读者指正,互相学习;O(∩_∩)O~





你可能感兴趣的:(intel,dpdk)