


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、pktgen 的安裝與使用0 頂0 踩簡單的vim配置| Linux 如何在系統(tǒng)啟動時自動加載內(nèi)核模塊2011-03-31pktgen的安裝與使用L腳本CC+pktgen 的安裝與使用系統(tǒng)環(huán)境: fefora core 12 如果你和我一樣,在 pktgen 面前是個新人。 是不是也曾遇到下面的問題:( 1)以為 pktgen 和 tcpdump 一樣是 Linux 下的工具軟件;( 2)后來,明白了 pktgen 不是工具,而是內(nèi)核模塊,但是不知道如何加載;(3)加載后,卻不會使用,并且一度一位pktgen 無法與網(wǎng)絡接口 eth0 建立映射關系;那么,我寫下的東西可能對你學習 pktgen
2、 有所幫助。 因為,我也在 google 上搜了一同, 卻沒有很好的對于 pktgen 講解的文檔。 A 首先, pktgen 是Linux 下的一個內(nèi)核模塊,并不是工具軟件。所以,不能通過在命令行輸入pktgen 的方式運行。那么,我的系統(tǒng)默認pktgen 不是自動加載進內(nèi)核,所以,如果你和我有一樣的情況,就需要自己手動添加pktgen 入內(nèi)核。查看pktgen是否在內(nèi)核命令:$ lsmod | grep pktgen加載pktgen模塊入內(nèi)核的命令:$ modprobe pktgen此時,就會不禁想到,加載的模塊文件到底在哪。我的系統(tǒng)位于/lib/modules/ 內(nèi)核版本號 /kerne
3、l/net/core/pktgen.ko B加載成功后,看看pktgen 模塊的線程是不是已經(jīng)運行了(更準確的說,是不是處于sleep 狀態(tài))。 $ ps aux | grep pktgen 看到如下內(nèi)容,說明pktgen的線程已經(jīng)啟動了。線程個數(shù)與cpu核數(shù)相關,本機 cpu 雙核,所以兩個線程。root20610.00.000 ?S<Mar300:28kpktgend_0root20620.00.000 ?S<Mar300:00 kpktgend_1 C然后,pktgen.txt 上說可以檢測下面三個文件的信息來了解pktgen /proc/net/pktgen
4、/pgctrl/proc/net/pktgen/kpktgend_X/proc/net/pktgen/ethX但是,我發(fā)現(xiàn)自己主機中并沒有 /proc/net/pktgen/ethX( X 代表編號,例如接口 eth0或 eth1)。此時,我以為是不是pktgen 沒有和網(wǎng)絡接口eth0 建立關系呢?難道是模塊有問題? 其實,并不是這樣,因為 pktgen 的運行需要腳本來驅(qū)動。因為我運行了網(wǎng)上的實例腳本 pktgen.conf-1-1 ,但是也沒有獲得預期的結(jié)果。/proc/net/pktgen/ethX 還是不存在。一度認為pktgen.c 編碼有問題,因為我看到了本機中,之有 eth0
5、網(wǎng)絡接口。 命令如下:$ dmesg | grep pktgen 輸出結(jié)果: pktgen: no such netdevice: "eth1" pktgen.conf-1-1 下載地址: ftp:/robur.slu.se/pub/Linux/net-development/pktgen-testing/exa mples/ D 最后我終于發(fā)現(xiàn),既不是源碼 pktgen.c 的問題,也不是 pktgen 模塊的問題。原因在于,驅(qū)動腳本 pktgen.conf-1-1中的網(wǎng)絡接口配置與我的本機的不符所致。pktgen.conf-1-1 源碼如下:#! /bin/sh #mo
6、dprobe pktgenfunction pgset() local resultecho $1 > $PGDEVresult=cat$PGDEV | fgrep "Result: OK:"if "$result" = "" ; thencat $PGDEV | fgrep Result:fi function pg() echo inject > $PGDEVcat $PGDEV # Config Start Here- # thread config# Each CPU has own thread.
7、 Two CPU exammple. We add eth1,eth2 respectivly. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices"pgset "rem_device_all"echo "Adding eth1"pgset "add_device eth1"# 就在這一句, 默認的配置網(wǎng)絡接口為 eth1,但是我的本機并沒有這個接口,而是 eth0。所以,應該自己手動修改。echo "Setting max_befor
8、e_softirq 10000" pgset "max_before_softirq 10000" # device config# delay 0 means maximum speed. CLONE_SKB="clone_skb 1000000"# NIC adds 4 bytes CRCPKT_SIZE="pkt_size 60" # COUNT 0 means forever#COUNT="count 0"COUNT="count 10000000"DELAY="de
9、lay 0" PGDEV=/proc/net/pktgen/eth0 echo "Configuring $PGDEV"pgset "$COUNT"pgset "$CLONE_SKB"pgset "$PKT_SIZE"pgset "$DELAY"pgset "dst "pgset "dst_mac 00:04:23:08:91:dc" # Time to run PGDEV=/proc/net/pktgen/pgctrl ec
10、ho "Running. ctrlC to stop"pgset "start"echo "Done" # Result can be vieved in /proc/net/pktgen/eth1 E驅(qū)動腳本也有自己的一些命令方式,或者語法。下面列出一些規(guī)則:同時,我自己也要進一步學習,也不是全懂。* Pgcontrolcommands: startstop * Thread commands: add_devicerem_device_allmax_before_softirq * Device commands: countcl
11、one_skbdebug fragsdelay src_mac_countdst_mac_count pkt_sizemin_pkt_sizemax_pkt_size mpls udp_src_minudp_src_max udp_dst_minudp_dst_max flagIPSRC_RNDTXSIZE_RNDIPDST_RNDUDPSRC_RNDUDPDST_RNDMACSRC_RNDMACDST_RND dst_mindst_max src_minsrc_max dst_macsrc_mac clear_counters dst6src6 flowsflowlen F再寫一些實例。pg
12、set "clone_skb 1"sets thenumber of copies of the same packetpgset "clone_skb 0"use single SKB for all transmitspgset "pkt_size 9014"sets packet size to 9014pgset "frags 5"packet will consist of 5 fragmentspgset "count 200000"sets number of packets to
13、 send, set tozerofor continuous sends untilexplicitly stopped. pgset "delay 5000"adds delay tohard_start_xmit(). nanoseconds pgset "dst "sets IPdestination address(BEWARE! This generator isvery aggressive!) pgset "dst_min "Sameas dstpgset "dst_max 1
14、54"Set the maximumdestination IP.pgset "src_min "Set the minimum (oronly) source IP.pgset "src_max 54"Set the maximumsource IP.pgset "dst6 fec0:1"IPV6 destination addresspgset "src6 fec0:2"IPV6 source addresspgset "dstmac 00:00
15、:00:00:00:00"sets MAC destinationaddresspgset "srcmac 00:00:00:00:00:00"sets MAC source addresspgset "queue_map_min 0" Sets the min value of tx queue intervalpgset "queue_map_max 7" Sets the max value of tx queue interval, for multiqueue devicesTo select queue 1 of
16、 a givendevice,use queue_map_min=1 andqueue_map_max=1 pgset "src_mac_count 1" Sets the number ofMACs we'll range through.The 'minimum' MAC is what youset with srcmac. pgset "dst_mac_count 1" Sets the number of MACs we'll range through.The 'minimum' MAC is
17、what youset with dstmac. pgset "flag name"Set a flag todetermine behaviour.Current flagsare: IPSRC_RND #IP Source israndom (between min/max),IPDST_RND,UDPSRC_RND,UDPDST_RND,MACSRC_RND, MACDST_RNDMPLS_RND, VID_RND,SVID_RNDQUEUE_MAP_RND #queue map randomQUEUE_MAP_CPU #queue map mirrors smp_p
18、rocessor_id() pgset "udp_src_min 9"set UDP source port min, If < udp_src_max, thencycle through the port range.pgset "udp_src_max 9"set UDP source port max.pgset "udp_dst_min 9" set UDP destination port min, If < udp_dst_max, thencycle through the port ran
19、ge.pgset "udp_dst_max 9"set UDP destination port max. pgset"mpls 0001000a,0002000a,0000000a" set MPLS labels (in thisexampleouterlabel=16,middle label=32,inner label=0 (IPv4 NULL) Note thatthere must be no spaces between thearguments. Leading zeros are required.Do not set the bot
20、tom of stack bit,that's done automatically. If you doset the bottom of stack bit, thatindicates that you want to randomlygenerate that address and the flagMPLS_RND will be turned on. Youcan have any mix of random and fixedlabels in the label stack. pgset "mpls 0"turn off mpls (or anyinvalid argument works too!) pgset "vlan_id 77"setVLAN ID 0-4095pgset "vlan_p 3"set priority bit 0-7 (default
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 掌眾集團java面試題及答案
- 杭州老板電器面試題及答案
- 急救模考試題及答案
- 藻類苔蘚測試題及答案
- java設計面試題及答案
- 酒店實習面試題及答案
- 2025年餐飲行業(yè)會員精細化運營與顧客滿意度提升策略報告
- 吉他彩色線描課件
- 2025年高端定制農(nóng)產(chǎn)品標準化生產(chǎn)技術與應用報告
- 慢阻肺的護理查房模板
- 風電居間合同協(xié)議書
- 浙江開放大學2025年《社會保障學》形考任務4答案
- 醬料研發(fā)知識培訓課件
- 2025核輻射突發(fā)事件放射性污染人員洗消流程及技術要求
- 湖北省黃岡市黃梅縣2023-2024學年六年級下學期語文期末質(zhì)量監(jiān)測試卷(含答案)
- 醫(yī)療廢物處置項目可行性研究報告(范文)
- 七大浪費培訓
- 針灸養(yǎng)生推拿培訓課件
- 南岸區(qū)小升初試題及答案
- 監(jiān)護人安全培訓試卷(答案)
- 小學綜合實踐活動與勞動教育有效整合的策略研究
評論
0/150
提交評論