DPDK
来源:互联网 发布:js判断ie浏览器版本 编辑:程序博客网 时间:2024/05/21 21:41
环境
- Ubuntu-16.04 LTS
- dpdk-16.11.3.tar.xz (LTS), from DPDK
- pktgen-3.4.2.tar
安装DPDK和Pktgen
tar -xf *.tar to extract the files
Set the environment variable:
export RTE_SDK=” (dpdk files directory, 参阅其他安装说明)
export RTE_TARGET=” (the setting of the installation)
edit the ~/.profile, reboot and make it enable(永久生效)Install the DPDK
run the ./tools/dpdk-setup.sh
then, step 1-4:- install the DPDK environment(‘x86_64-native-linuxapp-gcc’)
- setup linuxapp environment(drivers, e.g. IGB UIO; hugepage bind the network devices )
- test
- Install the pktgen
Download Pktgen and Install
直接通过github指示或者官网下载pktgen解压安装即可,该过程中可能存在的问题:
First, use ‘sudo apt-get install libpcap-dev’ to install pcap library( the pktgen used).
Second, use the tools/setup.sh to test if the environment is OK
Finally, make the pktgen
测试环境
可以使用DPDK自带的一些examples来测试,这些examples的使用方法直接参考DPDK文档即可.
l2fwd
Iocation: dpdk-…/examples/l2fwd/build/ (Before using, please ‘make’)
./l2fwd -c 0xf -n 3 – -p 0x3 -q 1
前面的参数称为EAL,属于DPDK通用初始化参数(参看help,编程时通过rte_eal_init(argc, argv)直接完成)
-c 0xf 运行的十六机制掩码核心数。在这里指分配4个core
-n 3 每个处理器的内存通道数
– 表示之后的为次参数(每个程序可以进行自定义,使用Linux的getopt_long()进行自定义处理);
-p 0x3 设置起点的端口数对应掩码,0x3=0b11,即起点两个端口
-q 确定每个core的队列的数量,表示每个逻辑核心有一个队列pktgen
location: pktgen home directory ( Before using, ‘make’)
./app/build/pktgen -c e -n 3 –proc-type auto –file-prefix pg – -p 0x14 -P -m “2.0, 3.1” -f test/set_seq.cmd
Similar to the l2fwd, for more information, look at the help
[查看文档时通过 Shift+PgDn/PgUp 上下翻页].程序运行中的其他事情
If the warning is the hugepage, try:
3.1 原程序前加sudo -E
3.2 尝试运行下面命令后再运行程序(delete the too many pages)sudo rm -rf /dev/hugepages/*
Pktgen Usage
Start Usage
sudo -E ./app/build/pktgen [EAL options] – [-h] [-P] [-G] [-T] [-f cmd_file] [-l log_file] [-s P:PCAP_file] [-m ]
使用-f cmd_file进行定制化配置(配置在文件里,也可以在启动后pcktgen的命令行里进行相关设置操作–设置报文的内容,速率,存储等)
TODO:
[ ] 尝试使用-f 的方法进行配置并总结, 搭配出自定义的网络测试环境(在不同的报文构成下, size,burst等; 速率和丢包率–pktgen保存对应结果)
启动后的命令行操作
可以使用的命令:
help, ls (-l)… 各种命令的使用说明参看4
切换页面page < page name >
cpu:查看CPU
log: 查看log
main: 主页
range: 查看range的相关设置
命令举例如下为:
str/stp: 全部端口开始/停止发包;
start/stop port-number: 开始/停止某些端口的发包
clr: 全部清零;
clear port-number: 清除某个端口的相关统计信息
set < port list > < type > value: 把端口列表进行配置
比较重要的一些配置方案有
1. set 0 count 10 //0端口发送10个报文就结束
2. set all size 100 //所有端口发送的报文内容大小为100
3. set 0,1 rate 70 //端口0,1的速率设置为70%
4. set 1 burst 100 // 1端口的burst为100
5. set 1 dump 100 // 记录之后收到的100个报文到?log?(还没搞清楚)
注意使用range 设置相关随机设置前,需要使用enable < portlist > range操作打开相关选项
注意set,range,sequence的使用,可以配置速率,IP,MAC等信息
参考文档: https://media.readthedocs.org/pdf/pktgen-dpdk/latest/pktgen-dpdk.pdf
使用DPDK做自定义开发
Environment
为了方便查看函数调用,使用Eclipse CDT进行编辑, 拷贝DPDK的example文件夹下的makefile类工程, 同时增加DPDK的include文件夹到工程的include目录内(这样可以方便地查看DPDK自定义的函数在头文件里的说明–等价于查看文档)
rte_eal_init(argc, argv); 初始化操作,返回值<0表示出错
rte_exit(EXIT_FAILURE, “Port %d RX queue setup error (%d)\n”, port_rx, ret);退出操作,可以提示错误信息(注意后面的字符串的使用)
rte_
Reference
- http://blog.csdn.net/linzhaolover/article/details/9290083
About the Pktgen - http://blog.csdn.net/weicuidi/article/details/52925527
About the l2fwd - https://github.com/pktgen/Pktgen-DPDK/issues/4
About the pcap.h question - http://pktgen-dpdk.readthedocs.io/en/latest/commands.html
About the pktgen usage
- DPDK
- DPDK
- DPDK
- DPDK
- DPDK
- DPDK
- DPDK中文-DPDK工具
- Intel DPDK
- Intel DPDK
- Intel DPDK
- DPDK资料
- DPDK helloworld
- dpdk l2fwd
- dpdk mbuf
- DPDK初识
- DPDK链接
- DPDK-CH3
- DPDK简介
- Java的多态
- Android ndk初探(一)
- CentOS-7.2添加桌面快捷方式
- C#中正则表达式的使用
- 理解闭包(一)
- DPDK
- [Leetcode]Course Schedule
- MFC中使用控制台窗口输入输出
- egl introduce
- PostGreSQL + PostGIS 在windows下安装以及与Arcgis的连接(离线安装)
- mac安装xgboost报错:fopen
- [LeetCode]171. Excel Sheet Column Number
- 车载设置--按键提示音
- 标准与实现