本文介绍了数据平面开发工具包(DPDK)TestPMD应用程序,展示了如何构建和配置TestPMD, 以及如何用它来检查使用DPDK的不同网络设备的性能和功能。

TestPMD是一个使用DPDK软件包分发的参考应用程序。其主要目的是在网络接口的以太网端口之间转发数据包。此外,用户还可以用TestPMD尝试一些不同驱动程序的功能,例如RSS,过滤器和英特尔®以太网流量控制器(Intel® Ethernet Flow Director)。
我们还将研究TestPMD运行时的命令行,命令行可用于配置端口之间的数据包转发和网络接口支持的其他功能。TestPMD应用程序适用于所有版本的DPDK。

TestPMD的配置示例

为了展示如何使用TestPMD,我们会考虑两个典型的硬件设置。
如图1所示,第一个配置,TestPMD应用程序把两个以太网口连接到外部的流量发生器。这样用户可以在不同的网络工作负载下测试吞吐量和功能。

第二个设置,TestPMD应用程序把两个以太网端口连成环回模式。 这样用户可以在没有外部流量发生器的情况下检查网络设备的接收和传输功能。

转发模式

TestPMD可以使用如下几种不同的转发模式。

输入/输出模式(INPUT/OUTPUT MODE)

此模式通常称为IO模式,是最常用的转发模式,也是TestPMD启动时的默认模式。 在IO模式下,CPU内核从一个端口接收数据包(Rx),并将其发送到另一个端口(Tx)。 如果需要的话,一个端口可同时用于接收和发送。

收包模式(RX-ONLY MODE)

在此模式下,应用程序会轮询Rx端口的数据包,然后直接释放而不发送。 它以这种方式充当数据包接收器。

发包模式(TX-ONLY MODE)

在此模式下,应用程序生成64字节的IP数据包,并从Tx端口发送出去。 它不接收数据包,仅作为数据包源。

后两种模式(收包模式和发包模式)对于单独检查收包或者发包非常有用。
除了这三种模式,TestPMD文档中还介绍了其他一些转发模式。

编译、准备TestPMD

以下步骤用于编译和设置TestPMD应用程序:
1.如下命令从源目录中编译DPDK,默认也编译了TestPMD应用程序:

 
1
$ make config T = x86_64-native-linuxapp-gcc

2.初始化内核模块uio:

 
1
$ sudo modprobe uio

3.加载内核模块igb_uio:

 
1
$ sudo insmod ./build/kmod/igb_uio.ko

4.预留大页内存以供DPDK TestPMD 应用程序使用,最简单的方法是通过使用DPDK附带的dpdk-setup.sh脚本工具(更多信息请参阅DPDK Getting Started Guide):

 
1
$ sudo ./usertools/dpdk-setup.sh

5.将网络接口端口绑定到igb_uio。举例来说,我们假设使用的端口PCI地址为0000:83:00.1和0000:87:00.1:(可左右滑动↓)

 
1
$ sudo ./usertools/dpdk-devbind.py -b igb_uio 0000:83:00.1 0000:87:00.1

运行TestPMD

TestPMD可以使用一系列命令行参数在非交互模式下运行,也可以使用-i选项运行在交互模式,来实时接收命令行。实时命令行可以动态配置TestPMD:(可左右滑动↓)

 
1
$ sudo ./build/app/testpmd –l 12,13,14 –n 4 -- -i

在此例中, –l选项指定了逻辑核。核12用于管理命令行,核13和14将用于转发数据包。 -n选项用于指定系统的内存通道数。–(破折号)分开了EAL参数和应用程序参数。程序运行时可以看到如下所示的输出:

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ sudo ./build/app/testpmd –l 12,13,14 –n 4 -- -i
 
EAL: Detected 40 lcore(s)
EAL: Probing VFIO support...
EAL: PCI device 0000:83:00.0 on NUMA socket 1
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:83:00.1 on NUMA socket 1
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:87:00.0 on NUMA socket 1
EAL:   probe driver: 8086:10fb net_ixgbe
EAL: PCI device 0000:87:00.1 on NUMA socket 1
EAL:   probe driver: 8086:10fb net_ixgbe
Interactive-mode selected
USER1: create a new mbuf pool <mbuf_pool_socket_0>:
       n=163456, size=2176, socket=0
Configuring Port 0 (socket 0)
Port 0: 00:1B:21:B3:44:51
Configuring Port 1 (socket 0)
Port 1: 00:1B:21:57:EE:71
Checking link statuses...
Port 0 Link Up - speed 10000 Mbps - full-duplex
Port 1 Link Up - speed 10000 Mbps - full-duplex
Done
testpmd>

testpmd>提示符允许用户输入命令,这被称为实时命令行。例如,我们可以用它来输入命令,来检查转发配置:

 
1
2
3
4
5
6
testpmd> show config fwd
io packet forwarding - ports=2 - cores=1 - streams=2
  - NUMA support disabled, MP over anonymous pages disabled
Logical Core 13 (socket 1) forwards packets on 2 streams:
  RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
  RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00

这表明TestPMD正使用前面介绍过的默认io转发模式,同时也表明核13(第二个启用的内核)将轮询端口0上的数据包,然后转发到端口1,反之亦然。 核12,也就是命令行中第一个核正用于处理运实时命令行本身。
要开始转发,只需键入命令’start’:

 
1
testpmd> start

然后,要检查端口之间是否有包正在转发,执行以下命令来显示应用程序正在使用的所有端口的统计信息:(可左右滑动↓)

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
testpmd> show port stats all
################### NIC statistics for port 0 ######################
RX-packets: 8480274     RX-missed: 0           RX-bytes: 508816632
RX-errors: 0
RX-nombuf: 0
TX-packets: 5763344     TX-errors: 0           TX-bytes: 345800320
Throughput (since last show)
Rx-pps: 1488117
Tx-pps: 1488116
############################################################
################### NIC statistics for port 1 ######################
RX-packets: 5763454     RX-missed: 0           RX-bytes: 345807432
RX-errors: 0
RX-nombuf: 0
TX-packets: 8480551     TX-errors: 0           TX-bytes: 508832612
Throughput (since last show)
Rx-pps: 1488085
Tx-pps: 1488084
############################################################

此输出显示了应用程序开始转发后的所有数据包总数,包含有这两个端口接收和发送的数据包数。吞吐率是以数据包每秒来显示的。在这个例子中,所有端口上接收到的包都以理论线速14.88Mpps往外转发。线速是指给定数据包大小和网络接口的最大速度。若要停止转发,只需输入 stop,这会停止转发并显示两个端口的累计统计数字以及一个概要。

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
testpmd> stop
Telling cores to stop...
Waiting for lcores to finish...
------------------ Forward statistics for port 0 ----------------------
RX-packets: 136718750       RX-dropped: 0           RX-total: 136718750
TX-packets: 136718750       TX-dropped: 0           TX-total: 136718750
---------------------------------------------------------------------
------------------ Forward statistics for port 1 ----------------------
RX-packets: 136718750       RX-dropped: 0           RX-total: 136718750
TX-packets: 136718750       TX-dropped: 0           TX-total: 136718750
---------------------------------------------------------------------
++++++++++Accumulated forward statistics for all ports +++++++++
RX-packets: 273437500       RX-dropped: 0           RX-total: 273437500
TX-packets: 273437500       TX-dropped: 0           TX-total: 273437500
+++++++++++++++++++++++++++++++++++++++++++++++++++

使用多核

对于一个核不足以转发所有收到的包的情况,多核可以用于处理来自不同端口的数据包。在前面的例子中,核 13和14可用于转发数据包,但只有核 13被用到了。要启用另一个核,我们可以使用以下命令:

 
1
2
3
4
5
6
7
8
9
10
testpmd> set nbcore 2
 
testpmd> show config fwd
 
io packet forwarding - ports=2 - cores=2 - streams=2
   - NUMA support disabled, MP over anonymous pages disabled
Logical Core 13 (socket 1) forwards packets on 1 streams:
  RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
Logical Core 14 (socket 1) forwards packets on 1 streams:
  RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00

这样核13将从端口0接收数据包,并从端口1发送数据包,而core14将接收来自端口1的数据包,并从端口0上发送。

改变转发模式

如上所述,TestPMD具有不同的转发模式。若要将转发模式更改为收包模式,我们可以使用set fwd命令:

 
1
2
testpmd> set fwd rxonly
testpmd> start

现在,如果我们看端口统计数据,可以看到只有接收到的数据包才会显示。由于没有发送的数据包,Tx数据仍然为0:

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
testpmd> show port stats all
####################### NIC statistics for port 0  ##########################
RX-packets: 524182888  RX-missed: 0          RX-bytes:  31450974816
RX-errors:  0
RX-nombuf:  0
TX-packets: 0          TX-errors: 0          TX-bytes:  0
 
Throughput (since last show)
Rx-pps:     14880770
Tx-pps:            0
####################################################################
####################### NIC statistics for port 1  ##########################
RX-packets: 486924876  RX-missed: 0          RX-bytes:  29215494352
RX-errors:  0
RX-nombuf:  0
TX-packets: 0          TX-errors: 0          TX-bytes:  0
 
Throughput (since last show)
Rx-pps:     14880788
Tx-pps:            0
####################################################################

在TestPMD获得帮助

TestPMD为运行时可用的命令提供在线帮助。这些帮助分为几个部分,可以通过帮助命令获取。

 
1
testpmd> help

以下部分可用“帮助”:

 
1
2
3
4
5
6
7
help control    : Start and stop forwarding.
help display    : Displaying port, stats and config information.
help config     : Configuration information.
help ports      : Configuring ports.
help registers  : Reading and setting port registers.
help filters    : Filters configuration help.
help all        : All of the above sections.

例如,要获取有关显示数据和其他信息的命令的帮助:

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
testpmd> help display
Display:
--------
 
show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)
    Display information for port_id, or all.
 
show port X rss reta (size) (mask0,mask1,...)
    Display the rss redirection table entry indicated by masks on port X. size is used to indicate the hardware supported reta size
 
show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]
    Display the RSS hash functions and RSS hash key of port X
 
clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)
    Clear information for port_id, or all.
 
show (rxq|txq) info (port_id) (queue_id)
    Display information for configured RX/TX queue.
 
show config (rxtx|cores|fwd|txpkts)
    Display the given configuration.
 
read rxd (port_id) (queue_id) (rxd_id)
    Display an RX descriptor of a port RX queue.
 
read txd (port_id) (queue_id) (txd_id)
    Display a TX descriptor of a port TX queue.

结论

本文研究了如何编译、设置和运行TestPMD以及如何通过实时命令行进行配置。

原文:DPDK开源社区

用TestPMD测试DPDK性能和功能的更多相关文章

  1. Android IOS WebRTC 音视频开发总结(五六)-- 如何测试网络性能?

    本文主要介绍如何测试网络性能,文章来自博客园RTC.Blacker,欢迎关注微信公众号blacker,更多详见www.rtc.help 网络性能直接决定了视频通话效果,比如qq,很多时候我们我们觉得通 ...

  2. Apache JMeter--网站自动测试与性能测评

    Apache JMeter--网站自动测试与性能测评 2013-02-28 15:48:05 标签:Jmeter From:http://bdql.iteye.com/blog/291987 出于学习 ...

  3. iozone测试磁盘性能

    什么是iozone? iozone是一个文件系统的benchmark工具,可以测试不同的操作系统中文件系统的读写性能. 可以测试 Read, write, re-read,re-write, read ...

  4. 使用iozone测试磁盘性能

    IOzone是一个文件系统测试基准工具.可以测试不同的操作系统中文件系统的读写性能.可以通过 write, re-write, read, re-read, random read, random w ...

  5. 使用iozone测试磁盘性能(测试文件读写)

    IOzone是一个文件系统测试基准工具.可以测试不同的操作系统中文件系统的读写性能.可以通过 write, re-write, read, re-read, random read, random w ...

  6. 使用SQLIO测试磁盘性能

    SQLIO 是一个用于测试存储系统能力的命令行工具,用以获取存储系统相关的性能指标,以判断系统的 I/O 处理能力. 在微软的网站可以下载 SQLIO 的安装包,安装后目录中会出现如下文件: EULA ...

  7. 简单练习题2编写Java应用程序。首先定义一个描述银行账户的Account类,包括成员变 量“账号”和“存款余额”,成员方法有“存款”、“取款”和“余额查询”。其次, 编写一个主类,在主类中测试Account类的功能

    编写Java应用程序.首先定义一个描述银行账户的Account类,包括成员变 量“账号”和“存款余额”,成员方法有“存款”.“取款”和“余额查询”.其次, 编写一个主类,在主类中测试Account类的 ...

  8. hdparm测试硬盘性能

    <1>Centos安装hdparm测试硬盘性能 一.安装hdparm yum install hdparm -y Linux学习,http:// linux.it.net.cn 二.评估读 ...

  9. 【转】dd命令详解及利用dd测试磁盘性能

    dd命令详解及利用dd测试磁盘性能   linux下dd命令详解 名称: dd 使用权限: 所有使用者 manpage 定义: convert and copy a file 使用方式: dd [op ...

随机推荐

  1. SpringBoot专题1----springboot与mybatis的完美融合

    springboot大家都知道了,搭建一个spring框架只需要秒秒钟.下面给大家介绍一下springboot与mybatis的完美融合: 首先:创建一个名为springboot-mybatis的ma ...

  2. [科普]什么是SysWow64

    Wow!什么是Wow64 今天有个同事,被SysWow64搞晕了.这里简单介绍一下. 64位的Windows并不是简单地把所有东西都编译成64位就万事大吉的.关于64位的CPU应该做成什么样子,Int ...

  3. CStdioFile.WriteString无法向文件写入中文

    CStdioFile.WriteString向文件中写入字符串,但字符串中带有中文的,无法写入. 解决方案: 将带有中文的字符串进行转换后再写入文件. char* pBuffer = NULL; lo ...

  4. 【总结】两种 NIO 实现:Selector 与 Epoll

    时间2012-11-17 08:38:42 开源中国新闻原文  http://my.oschina.net/ielts0909/blog/89849 我想用这个话题小结下最近这一阶段的各种测试和开发. ...

  5. 字符串 (string)与字节数组(byte[])之间的转换

    string str = "abc" //字符串转成编码为GB2312的byte[] byte[] pData =System.Text.Encoding.GetEncoding( ...

  6. window下安装mysql详细步骤

    1.下载安装包 打开mysql官网下载页面:http://dev.mysql.com/downloads/mysql/ 1.选择相应的版本和平台 2.mysql配置 打开刚刚解压的文件夹F:\mysq ...

  7. Python3+Selenium3自动化测试-(四)

    selenium鼠标事件 # coding=utf-8 import time from selenium import webdriver from selenium.webdriver.commo ...

  8. 利用EasySQLMAIL实现自动填写Excel表格并发送邮件(2)

    利用EasySQLMAIL实现自动填写Excel表格并发送邮件 转自:http://blog.sina.com.cn/s/blog_1549483b70102witg.html 前一篇博文中记录了“利 ...

  9. table实现 js数据访问 传递json数据用render_to_response

    $(document).ready(function(){ $.ajax({ url:'/query/', dataType:'json', type:'GET', success:function( ...

  10. 转:使用log4net完成程序异常日志记录(使用SQLite数据库记录和普通文本记录)

    http://www.cnblogs.com/kyo-yo/archive/2010/06/11/use-log4net-to-log-exception.html 在前端时间开发的时候由于需要将异常 ...