Previously, we talked about libpcap packet capture, especially in the case of a gigabit network, which results in a large number of packet loss and a long time of searching on the Internet. This is probably a method like PF_PACKET + MMAP, NAPI, and PF_RING, I tested PF_RING + libpcap and found that the packet capture performance was good under gigabit network conditions, with almost no packet loss. The following figure shows how to configure the LinuxFedora14 experiment environment: 1) download PF_RING: svncohttps: // svn.ntop.org/sv
Previously, we talked about libpcap packet capture, especially in the case of a gigabit network, which results in a large number of packet loss and a long time of searching on the Internet. This is probably a method like PF_PACKET + MMAP, NAPI, and PF_RING, I tested PF_RING + libpcap and found that the packet capture performance was good under gigabit network conditions, with almost no packet loss. The configuration process of the Linux Fedora 14 experiment environment was as follows:
1) download PF_RING: svn co https://svn.ntop.org/svn/ntop/trunk/PF_RING/
2) After the download, compile PF_RING in pf_ring/kernel to generate pf_ring.ko.
3) insmod pf_ring.ko thansparent_mode = 1
4) Run cd in the lib directory, modify the MakeFile, and direct the installation directory to usr/. If no modification is made, it will point to/usr/local.
5) in the lib directory, make and then make install
6) cd into the libpcap-1.1.1-ring directory, modify the source code, the pf_ring kernel ring buffer is set to 2 M, the default 0.5 M, and then modify the MakeFile, the installation directory pointing to usr /, the default value is usr/local. Compile make, and then make install;
7) in this way, the libpfring. so, pfring_e1000e_dna .h, pfring. h, libpfring. a copied to usr/include or usr/lib, and replaced the original libpcap library file with the library file of the libpcap-1.1.1-ring;
8) after the environment is set up, add # define HAVE_PF_RING to the header file of the application;
9) you will find that the performance has been greatly improved by more than 60%. However, the cpu usage will also increase accordingly. You can view the cpu usage on the terminal using top.