Tcpreplay命令詳解

來源:互聯網
上載者:User

工具的名稱就能猜到工具的作用,就是重放TCP的報文,但是這個工具究竟功能如何,是不是僅僅局限於在一個網卡上回放報文,這篇說明書主要介紹tcprelay的一些與測試有關的使用,在介紹tcpreplay命令的使用之前,先要介紹與之密切相關的一個命令:tcpprep,中文直譯就是tcp準備的意思,它的作用可以參見官方網站的介紹說明:

tcpprep is the pcap pre-processor for tcpreplay and tcprewrite. The purpose of tcpprep is to create a cache file which is used to "split" traffic into two sides (often called primary/secondary or client/server). If you are intending to use tcpreplay with two NIC's, then tcpprep is what decides which interface each packet will use. By using a seperate process to generate cache files, tcpreplay can send packets at a much higher rate then if it had to do the calculations to split traffic itself.


個人翻譯:(建議大家看man檔案,閱讀3次就能夠比較好的理解了)


P:<list> - Must be one of the listed packets where the list corresponds to the packet number in the capture file.

Ex: -xP:1-5,9,15 would only send packets 1 through 5, 9 and 15.

根據參數後的參數值(報文編號)發送指定的報文。可以在ethereal中確認報文的編號,然後把需要的報文發送。可以用於排除ARP報文。

F:"<filter>" - BPF filter. See the tcpdump(8) man page for syntax.

未知,以後補充。

-X <match> Send all the packets except those specified

選擇性參數,就是-x參數的取反,參數內容也是一樣。

-v Verbose

選擇性參數,顯示trpprep產生cache檔案的處理過程,就是一些資訊的即時列印。

-V Version

顯示版本號碼。
Tcpprep使用小結

再構造cache檔案的過程中我用的比較多的選項參數就-v、-P、-xB、-xP,一般都是client和server的模式,其它兩種模式沒有實驗過,暫時還不知道怎麼使用,bridge模式我使用過一次,結果發現報文是從一個網卡送出。

對於tcp和udp協議都做了測試,是可以支援的,icmp還沒有成功。對於網路上的BT報文,只要你有pcap檔案,也是可以構造cache檔案來類比完全真實的BT流量。

目前的使用就是這麼多,感覺還是很有用的,tcpreplay的參數有一部分是和tcpprep重複,下面的協助檔案說明就不詳細說明了,但是特殊有好用的參數會使用藍色字型標記出來給予重視。存在的不足是還沒有學會在nat模式下重放報文,現在所有的報文重放都是在透明模式下完成的。
Tcpreplay協助檔案說明

Usage: tcpreplay [args] <file(s)>

-A "<args>" Pass arguments to tcpdump decoder (use w/ -v)

選擇性參數,在使用tcpdump風格列印輸出資訊時,同時再調用tcpdump中的參數,預設已經帶有“-n,-l”,所以一般看到的都是ip地址,而沒有主機名稱的列印,注意這個是在tcpreplay使用了-v參數時,才能使用,不帶-v不會報錯,但是沒有實際意義。格式:-vA “nnt”表示以tcpdump風格輸出報文資訊,並且不列印時間戳記、主機名稱、連接埠服務名稱。注意不要使用-c參數來指定列印的資料報文的個數,這樣發送出去的報文也會變少。

-b Bridge two broadcast domains in sniffer mode

選擇性參數,沒有用過

-c <cachefile> Split traffic via cache file

雙網卡回放報文必選參數,後面緊跟cache檔案名稱,該檔案為tcpprep根據對應的pcap檔案構造出來。

-C <CIDR1,CIDR2,...> Split traffic by matching src IP

選擇性參數,

-D Data dump mode (set this BEFORE -w and -W)

選擇性參數,把應用程式層的資料,使用dump mode寫入到指定檔案中去,和-w、-W參數一起使用。

-e <ip1:ip2> Specify IP endpoint rewriting

選擇性參數,指定端點的ip,即把發送報文的和接收的報文的ip都修改稱對應的參數值中指定的ip,但是這樣發送的出的報文不會區分client和server,還沒有發現使用的地方。

-f <configfile> Specify configuration file

選擇性參數,指定設定檔,目前不會使用。

-F Fix IP, TCP, UDP and ICMP checksums

選擇性參數,在發送報文時,自動糾正錯誤的校正和。對測試DUT的校正和檢驗還是有用的。

-h Help

顯示協助檔案。

-i <nic> Primary interface to send traffic out of

雙網卡回放報文必選參數,指定主介面。

-I <mac> Rewrite dest MAC on primary interface

選擇性參數,重寫主網卡發送出報文的目的MAC地址。

-j <nic> Secondary interface to send traffic out of

雙網卡回放報文必選參數,指定從介面。

-J <mac> Rewrite dest MAC on secondary interface

選擇性參數,重寫從網卡發送出報文的目的MAC地址。

-k <mac> Rewrite source MAC on primary interface

選擇性參數,重寫主網卡發送報文的源MAC地址。

-K <mac> Rewrite source MAC on secondary interface

選擇性參數,重寫從網卡發送報文的源MAC地址。

-l <loop> Specify number of times to loop

選擇性參數,指定迴圈的次數,測試過程發現不是那麼好用,有待確認。

-L <limit> Specify the maximum number of packets to send

選擇性參數,指定最大的發包數量。可以在確認串連的調試時使用。

-m <multiple> Set replay speed to given multiple

選擇性參數,指定一個倍數值,就是必預設發送速率要快多少倍的速率發送報文。加大發送的速率後,對於DUT可能意味著有更多的並發串連和串連數,特別是對於BT報文的重放,因為串連的逾時是固定的,如果速率增大的話,留在session表中的串連數量增大,還可以通過修改串連的逾時時間來達到該目的。

-M Disable sending martian IP packets

選擇性參數,表示不發送“火星”的ip報文,man檔案中的定義是0/8、172/8、255/8。

-n Not nosy mode (not promisc in sniff/bridge mode)

選擇性參數,在使用-S參數,不對混雜模式進行偵聽。沒有測試過。

-N <CIDR1:CIDR2,...> Rewrite IP's via pseudo-NAT

選擇性參數,通過偽造的NAT,重寫IP地址。這個參數應該有很重要的應用,目前沒有測試使用。

-O One output mode

選擇性參數,沒有測試使用

-p <packetrate> Set replay speed to given rate (packets/sec)

Tcpreplay 的詳細介紹:請點這裡
Tcpreplay 的:請點這裡

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.