pfring的編譯 libpcap緩衝區修改

來源:互聯網
上載者:User

1)下載PF_RING:git clone https://github.com/ntop/PF_RING.git


2)下載完後,在PF_RING/kernel下面make編譯pf_ring,產生pf_ring.ko


3)insmod pf_ring.ko thansparent_mode =1


4)apt-get install bision


5)apt-get install flex




6)cd 進入PF_RING-dev/userland/libpcap-1.74目錄下,修改源碼,將pf_ring的核心ring緩衝區設為10M,預設2M,
 註:修改源碼,將pf_ring的核心ring緩衝區設為10M,預設是2M
       原始碼:userland/libpcap-1.1.1-ring/pcap-linux.c
       函數:int activate_mmap(pcap_t*handle);
       程式碼片段:
  3310         if (handle->opt.buffer_size == 0) {
  3311                 /* by defaultrequest 2M for the ring buffer */
  3312                handle->opt.buffer_size = 2*1024*1024;
  3313         } 


7)cd PF_RING-dev 執行make 編譯 
cd 進入lib目錄下,修改MakeFile,將安裝目錄指向usr/,如果不修改,就會指向/usr/local ,在lib目錄下,make,然後make install
cd 進入libpcap-1.1.1-ring目錄下,然後修改MakeFile,將安裝目錄指向usr/,預設指向usr/local。接著編譯make,然後make install;


8)這樣,就將PF_RING-dev/userland/lib/libpfring.so,
pfring_e1000e_dna.h,
PF_RING-dev/userland/lib/pfring.h,
PF_RING-dev/userland/libpcap-1.7.4/libpcap.so.1.7.4(1MB) /*這個貌似用不了,可以到usr/lib/i386/底下搜尋安裝好的libpcap.so.1.7.4(256kb)*/


9)環境搭建完了,應用記得在應用程式的標頭檔中加入#define HAVE_PF_RING ;


10)大功告成,你會發現效能有極大的提高,提高了60%以上。但是cpu佔用率也會相應的提高,cpu佔用率採用在終端採用top查看。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.