抓包性能问题解决
在linux平台高并发的抓包时,需要安装内核驱动模块pf_ring以提高网络数据包捕获效率。
1、获取mirrors-PF-RING-6.0.3-stable.zip压缩包并解压
2、使用uname -a命令查看内核版本,若为2.6.32,则可以使用以下命令直接安装
[root@localhost ~]# cd PF_RING/kernel
[root@localhost kernel]# sudo insmod pf_ring.ko transparent_mode=1
若内核版本不为2.6.32,则需要重新编译pf_ring并安装。切换至root用户后使用如下命令:
[root@localhost ~]# cd PF_RING/kernel
[root@localhost kernel]# ./configure
[root@localhost kernel]# make
[root@localhost kernel]# insmod pf_ring.ko transparent_mode=1
3、当PF_RING激活时,会创建/proc/net/pf_ring目录,使用cat命令查看pf_ring的属性信 息:
[root@localhost ~]# cat /proc/net/pf_ring/info
PF_RING Version : 6.0.3 (:)
Total rings : 1
Standard (non DNA/ZC) Options
Ring slots : 4096
Slot version : 16
Capture TX : Yes [RX+TX]IP Defragment : No
Socket Mode : Standard
Total plugins : 0
Cluster Fragment Queue : 0
Cluster Fragment Discard : 0
4、为了使每次系统启动时都能正确加载pf_ring,切换至root用户,使用以下命令:
[root@localhost ~]# cd PF_RING/kernel
[root@localhost kernel]# echo "depmod $(pwd)/pf_ring.ko" >> /etc/profile
[root@localhost kernel]# echo "modprobe pf_ring transparent_mode=1" >> /etc/profile