DPDK编译与演示
2024-09-01 17:21:11
环境
虚拟机系统:ubuntu:1404
安装dpdk
参考:https://www.cnblogs.com/yanhai307/p/10598138.html
先从官网(www.dpdk.org)下载安装包,解压到/opt目录
/opt# tar -xvf dpdk-18.11.11.tar.xz
/opt# ls
dpdk-18.11.11.tar.xz dpdk-stable-18.11.11
安装依赖
# apt install libnuma-dev
# apt-get install libpcap-dev
# apt-get install pkg-config
环境配置
/opt/dpdk-stable-18.11.11# export RTE_SDK=/opt/dpdk-stable-18.11.11
/opt/dpdk-stable-18.11.11# export RTE_TARGET=x86_64-native-linuxapp-gcc
/opt/dpdk-stable-18.11.11# sed -ri 's,(PMD_PCAP=).*,\1y,' config/common_base
/opt/dpdk-stable-18.11.11# make config T=$RTE_TARGET
Configuration done using x86_64-native-linuxapp-gcc
编译
/opt/dpdk-stable-18.11.11# export DESTDIR=/usr/local
/opt/dpdk-stable-18.11.11# make -j 10 install T=$RTE_TARGET
编译成功
Build complete [x86_64-native-linuxapp-gcc]
================== Installing /usr/local/
Installation in /usr/local/ complete
遇到过的问题
/home/code/dpdk-stable-16.11.11/mk/rte.subdir.mk:61: recipe for target 'linuxapp' failed
make[5]: *** [linuxapp] Error 2
/home/code/dpdk-stable-16.11.11/mk/rte.subdir.mk:61: recipe for target 'librte_eal' failed
make[4]: *** [librte_eal] Error 2
/home/code/dpdk-stable-16.11.11/mk/rte.sdkbuild.mk:78: recipe for target 'lib' failed
make[3]: *** [lib] Error 2
/home/code/dpdk-stable-16.11.11/mk/rte.sdkroot.mk:126: recipe for target 'all' failed
make[2]: *** [all] Error 2
/home/code/dpdk-stable-16.11.11/mk/rte.sdkinstall.mk:85: recipe for target 'pre_install' failed
make[1]: *** [pre_install] Error 2
/home/code/dpdk-stable-16.11.11/mk/rte.sdkroot.mk:101: recipe for target 'install' failed
make: *** [install] Error 2
root@2543f489a7d0:/home/code/dpdk-stable-16.11.11# apt-get install linuxapp
解决办法:在VM编译没遇到
/opt/dpdk-stable-18.11.11/drivers/net/pcap/rte_eth_pcap.c:19:18: fatal error: pcap.h: No such file or directory
#include <pcap.h>
^
compilation terminated.
CC nfp_nsp_eth.o
make[6]: *** [rte_eth_pcap.o] Error 1
make[5]: *** [pcap] Error 2
make[5]: *** Waiting for unfinished jobs....
解决办法1: apt-get install libpcap-dev
解决办法2:libpcap 网络数据包捕获函数库安装
下载:http://www.tcpdump.org 找到libpcap并下载
# tar zxvf libpcap
# sudo apt-get install build-essential
# sudo apt-get install m4
# sudo apt-get install flex
# sudo apt-get install bison
# ./configure
# make
# sudo make install
dpdk使用
视频教程:https://www.bilibili.com/video/BV1HU4y147Hk?t=372
dpdk的设置命令
dpdk-stable-18.11.11# ./usertools/dpdk-setup.sh
设置hugepage
cpu从内存中是以4k为单位拿取。设置了hugepage后则预先拿一整块内存如:1G,减少了内存交换次数从而提高运行效率。
设置dpdk hugepage
dpdk-stable-18.11.11# ./usertools/dpdk-setup.sh
-----------------
RTE_SDK exported as /opt/dpdk-stable-18.11.11
[21] Setup hugepage mappings for non-NUMA systems
[22] Setup hugepage mappings for NUMA systems <<< NUMA: 统一内存块
Option: 21 <<< 选项
Removing currently reserved hugepages
Unmounting /mnt/huge and removing directory
Input the number of 2048kB hugepages
Example: to have 128MB of hugepages available in a 2MB huge page system,
enter '64' to reserve 64 * 2MB pages <<< 2M一个页单位
Number of pages: 64 <<< 配置hugepage
Reserving hugepages
Creating /mnt/huge and mounting as hugetlbfs
helloworld演示
编译helloworld示例
# cd /opt/dpdk-stable-18.11.11/examples/helloworld
helloworld# export RTE_SDK=/opt/dpdk-stable-18.11.11
helloworld# make
或
# cd /opt/dpdk-stable-18.11.11/examples/helloworld
helloworld# gcc -o helloworld main.c -I /usr/local/include/dpdk/ -ldpdk -lnuma -lpthread -ldl
helloworld# ls
helloworld main.c Makefile meson.build
运行
helloworld# ./build/helloworld
EAL: Detected 2 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Probing VFIO support...
EAL: PCI device 0000:03:00.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 15ad:7b0 net_vmxnet3
hello from core 1
hello from core 0
遇到问题
helloworld# ./build/helloworld
EAL: Detected 2 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: No free hugepages reported in hugepages-2048kB
EAL: FATAL: Cannot get hugepage information.
EAL: Cannot get hugepage information.
PANIC in main():
Cannot init EAL
5: [./build/helloworld() [0x47e5af]]
4: [/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f586fcc5f45]]
3: [./build/helloworld() [0x473551]]
2: [./build/helloworld(__rte_panic+0xb8) [0x46001f]]
1: [./build/helloworld(rte_dump_stack+0x1a) [0x65308a]]
Aborted (core dumped)
解决:需要设置hugepage
timer演示
# cd /opt/dpdk-stable-18.11.11/examples/timer
timer# make
CC main.o
LD timer
INSTALL-APP timer
INSTALL-MAP timer.map
timer# ./build/timer
EAL: Detected 2 lcore(s)
EAL: Detected 1 NUMA nodes
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Probing VFIO support...
EAL: PCI device 0000:03:00.0 on NUMA socket -1
EAL: Invalid NUMA socket, default to 0
EAL: probe driver: 15ad:7b0 net_vmxnet3
Starting mainloop on core 1
Starting mainloop on core 0
timer1_cb() on lcore 1
timer1_cb() on lcore 0
timer0_cb() on lcore 0
timer1_cb() on lcore 1
参考:
- 官方文档:https://dpdk-docs.readthedocs.io/en/latest/linux_gsg/intro.html
- 官方文档:https://core.dpdk.org/doc/
- meson编译:https://www.yuque.com/zzqcn/opensource/ik2tg2
- docker编译dpdk: https://www.cnblogs.com/yanhai307/p/10880089.html
最新文章
- 8.7 jquery-dom manipulation
- JMeter压测Rest请求
- LR中日志设置和日志函数
- explicit constructor(显示构造函数)
- 基于JQuery+JSP的无数据库无刷新多人在线聊天室
- pl/sql连接远程服务器
- struts2中根对象以及ognl .
- [C++]const修饰符
- vc 基于对话框多线程编程实例——线程之间的通信
- 循环语句 ,for语句
- Servlet做简单的ajax增删改查(分页)
- jmeter系列------变量的提取
- Redis源码剖析--源码结构解析
- 利用 Blob 处理 node 层返回的二进制文件流字符串并下载文件
- C#使用NanUI或ChromiumFx碰到的坑(一)
- php post接口,注册功能
- 分享插件的使用加一个echart走数据
- php面试流程
- kali的中文输入法-安装后无中文选项的解决办法
- selenium2.0关于python的常用函数
热门文章
- C++面向对象编程之point-like classes的智能指针和迭代器、function-like classes即仿函数
- Can not set int field xxx to java.lang.Long 错误
- RE语法
- vue中使用分页组件、将从数据库中查询出来的数据分页展示(前后端分离SpringBoot+Vue)
- Seata 环境搭建
- Linux系统安装python
- NC 使用Nginx实现https的反向代理
- Dockerfile 使用 SSH docker build
- go工具pprof部署
- 面试官不按套路,竟然问我Java线程池是怎么统计线程空闲时间?