Tcpreplay のススメ 
~概要編~ 
2014/09/22 
#pakeana 21 
@twovs
agenda 
• 自己紹介 
• Tcpreplay の紹介 
•• ppiinngg fflloooodd してみた
about me 
• @twovs (masato.otsuka) 
• ネコ2人+奥さん1人+可愛い娘 
•• 無線LLAANN装置の開発((11999999~~22000044)) 
• オンラインゲームのシステム管理者(2004~) 
• ただし,ゲームには全く興味無し 
• ZFS 最高!!! beadm 便利!!!
Tcpreplay(1) 
• Tcpreplay は 
• pcap ファイルを再送信(replay) 
•• ppccaapp ファイルを編集((rreewwrriittee)) 
• TCP の双方向通信も可能!!!
Tcpreplay(2) 
• Tcpreplay は 
• オープンソース/GPLv3 
•• UUNNIIXX 系OOSS で動作
• Windows はCygwin 上で動作
Tcpreplay(3) 
• Tcpreplay は 
• IDS/IPS/FireWall/Router/Switch など 
ネットワーク機器の開発で使われている
• netmap 対応で10GbE ワイヤーレート対応 
http://info.iet.unipi.it/~luigi/netmap/
Tcpreplay(4) 
• Tcpreplay (T が大文字)はツール群の総称 
• ツール/コマンド 
11.. ttccpprreeppllaayy 
2. tcpreplay-edit 
3. tcpliveplay 
4. tcpprep 
5. tcprewrite 
6. tcpcapinfo 
7. tcpbridge
1.tcpreplay 
• pcap ファイルを再送信(replay) 
• 任意のスピードで再送信 
•• MMbbppss//ppppss 指定
• 元のpcap ファイルのn倍速 
• 最大パケット間隔指定 
• 最大速!!!
1.tcpreplay 
# tcpreplay -i eth0 --mbps=510.5 smallFlows.pcap 
Actual: 14261 packets (9216531 bytes) sent in 0.144495 seconds. 
Rated: 63784428.5 Bps, 510.27 Mbps, 98695.45 pps 
Flows: 1209 flows, 8367.07 fps, 14243 flow packets, 18 non-flow 
Statistics for network device: eth0 
Attempted packets: 14261 
Successful packets: 14261 
Failed packets: 0 
Truncated packets: 0 
Retried packets (ENOBUFS): 0 
Retried packets (EAGAIN): 0 
http://tcpreplay.appneta.com/wiki/tcpreplay.html から抜粋
1.tcpreplay 
# tcpreplay -i eth0 -tK -l1000 --netmap smallFlows.pcap 
Switching network driver for eth0 to netmap bypass mode... done! 
File Cache is enabled 
Actual: 14261000 packets (9216531000 bytes) sent in 7.07 seconds. 
Rated: 1193506409.4 Bps, 9548.05 Mbps, 1846746.34 pps 
Flows: 1209 flows, 156.56 fps, 14243000 flow packets, 1188000000 nnoonn--ffllooww 
Statistics for network device: eth0 
Attempted packets: 14261000 
Successful packets: 14261000 
Failed packets: 0 
Truncated packets: 0 
Retried packets (ENOBUFS): 0 
Retried packets (EAGAIN): 0 
Switching network driver for eth0 to normal mode... done! 
http://tcpreplay.appneta.com/wiki/tcpreplay.html から抜粋
2.tcpreplay-edit 
• pcap ファイルを書き換えながら再送信(replay) 
• tcprewrite (後述)しながらtcpreplay 
• tcprewrite でpcap ファイルを生成し 
tcpreplay した方が高速に再送信
3.tcpliveplay 
• pcap ファイルを元にTCP 双方向通信を再現 
• TCP のSEQ/ACK を書き換えながら双方向通信 
• 現在はLinux だけ対応(その他環境も近々対応)
4.tcpprep 
• (複雑な処理用/使わなくても色々できる) 
• tcpreplay やtcprewrite の処理のための 
事前処理((pprree--pprroocceessssoorr)) 
• client/server の決定や 
使用するNIC などの定義ファイルを作成
5.tcprewrite 
• pcap ファイルを読み込み 
各種ヘッダ(など)を追加・削除・変更し 
pcap ファイルに書き出す 
• DLT(DataLinkType)変換 
• IEEE802.3 <-> IEEE802.11 
• Ethernet <-> Loopback 
• などなど
5.tcprewrite 
• Src/Dst MAC Address 
• IEEE802.1q (VLAN Tag) 
• Src/Dst IP Address 
• IPv4 Headers(TTOOSS//DDiiffffSSeerrvv//EECCNN)) 
• IPv6 Headers(Traffic Class/Flow Label) 
• TCP/UDP PortNum 
• IP/TCP/UDP Checksums の付与 
• MTU 指定でtruncate
6.tcpcapinfo 
• pcap ファイルの各種情報を表示 
• pcap ファイルを読み書きするアプリケーション 
を作る開発者向けのツール
• tcprewrite のbug を直す時に作られた
7.tcpbridge 
• 2つのネットワークをブリッジ 
• パケットを書き換えながらブリッジ 
•• ttccpprreewwrriittee と同じ書き換え機能を持つ
ping flood(1) 
• Raspberry Pi 
• MODEL B (not B+) 
• CPU 700[MHz] 
•• MMeemmoorryy 551122[[MMiiBB]] 
• NIC 100[Mbps] 
• Raspbian GNU/Linux 7 
• kernel 3.12.22+
ping flood(2) 
① 標準のping コマンド(iputils-sss20101006) 
$ sudo ping -f -s 1472 192.168.0.1 
② hping3 version 3.0.0-alpha-2 
$ sudo hping3 --flood -1 -d 1472 192.168.0.1 
③ tcpreplay version: 3.4.3 (build 2375) 
$ sudo tcpreplay --topspeed -K -i eth0 -l 0 sample.pcap
ping flood(3) 
[pps] [Mbps]
ping flood(4) 
$ uname -a 
Linux raspi 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 
armv6l GNU/Linux 
$ sudo tcpreplay --topspeed -K -i eth0 -l 10000 ping-1472.pcap 
Actual: 10000 packets (15140000 bytes) sent in 1.64 seconds 
Rated: 9231707.0 bps, 70.43 Mbps, 6097.56 pps 
Statistics for network device: eth0 
Attempted packets: 10000 
Successful packets: 10000 
Failed packets: 0 
Retried packets (ENOBUFS): 0 
Retried packets (EAGAIN): 0
memo 
• http://tcpreplay.appneta.com/ 
• https://github.com/appneta/tcpreplay 
• 4.0.5 が最新(2014/09/22 時点) 
• http://tcpreplay.synfin.net/ は3.x の情報
END

about Tcpreplay

  • 1.
    Tcpreplay のススメ ~概要編~ 2014/09/22 #pakeana 21 @twovs
  • 2.
    agenda • 自己紹介 • Tcpreplay の紹介 •• ppiinngg fflloooodd してみた
  • 3.
    about me •@twovs (masato.otsuka) • ネコ2人+奥さん1人+可愛い娘 •• 無線LLAANN装置の開発((11999999~~22000044)) • オンラインゲームのシステム管理者(2004~) • ただし,ゲームには全く興味無し • ZFS 最高!!! beadm 便利!!!
  • 4.
    Tcpreplay(1) • Tcpreplayは • pcap ファイルを再送信(replay) •• ppccaapp ファイルを編集((rreewwrriittee)) • TCP の双方向通信も可能!!!
  • 5.
    Tcpreplay(2) • Tcpreplayは • オープンソース/GPLv3 •• UUNNIIXX 系OOSS で動作 • Windows はCygwin 上で動作
  • 6.
    Tcpreplay(3) • Tcpreplayは • IDS/IPS/FireWall/Router/Switch など ネットワーク機器の開発で使われている • netmap 対応で10GbE ワイヤーレート対応 http://info.iet.unipi.it/~luigi/netmap/
  • 7.
    Tcpreplay(4) • Tcpreplay(T が大文字)はツール群の総称 • ツール/コマンド 11.. ttccpprreeppllaayy 2. tcpreplay-edit 3. tcpliveplay 4. tcpprep 5. tcprewrite 6. tcpcapinfo 7. tcpbridge
  • 8.
    1.tcpreplay • pcapファイルを再送信(replay) • 任意のスピードで再送信 •• MMbbppss//ppppss 指定 • 元のpcap ファイルのn倍速 • 最大パケット間隔指定 • 最大速!!!
  • 9.
    1.tcpreplay # tcpreplay-i eth0 --mbps=510.5 smallFlows.pcap Actual: 14261 packets (9216531 bytes) sent in 0.144495 seconds. Rated: 63784428.5 Bps, 510.27 Mbps, 98695.45 pps Flows: 1209 flows, 8367.07 fps, 14243 flow packets, 18 non-flow Statistics for network device: eth0 Attempted packets: 14261 Successful packets: 14261 Failed packets: 0 Truncated packets: 0 Retried packets (ENOBUFS): 0 Retried packets (EAGAIN): 0 http://tcpreplay.appneta.com/wiki/tcpreplay.html から抜粋
  • 10.
    1.tcpreplay # tcpreplay-i eth0 -tK -l1000 --netmap smallFlows.pcap Switching network driver for eth0 to netmap bypass mode... done! File Cache is enabled Actual: 14261000 packets (9216531000 bytes) sent in 7.07 seconds. Rated: 1193506409.4 Bps, 9548.05 Mbps, 1846746.34 pps Flows: 1209 flows, 156.56 fps, 14243000 flow packets, 1188000000 nnoonn--ffllooww Statistics for network device: eth0 Attempted packets: 14261000 Successful packets: 14261000 Failed packets: 0 Truncated packets: 0 Retried packets (ENOBUFS): 0 Retried packets (EAGAIN): 0 Switching network driver for eth0 to normal mode... done! http://tcpreplay.appneta.com/wiki/tcpreplay.html から抜粋
  • 11.
    2.tcpreplay-edit • pcapファイルを書き換えながら再送信(replay) • tcprewrite (後述)しながらtcpreplay • tcprewrite でpcap ファイルを生成し tcpreplay した方が高速に再送信
  • 12.
    3.tcpliveplay • pcapファイルを元にTCP 双方向通信を再現 • TCP のSEQ/ACK を書き換えながら双方向通信 • 現在はLinux だけ対応(その他環境も近々対応)
  • 13.
    4.tcpprep • (複雑な処理用/使わなくても色々できる) • tcpreplay やtcprewrite の処理のための 事前処理((pprree--pprroocceessssoorr)) • client/server の決定や 使用するNIC などの定義ファイルを作成
  • 14.
    5.tcprewrite • pcapファイルを読み込み 各種ヘッダ(など)を追加・削除・変更し pcap ファイルに書き出す • DLT(DataLinkType)変換 • IEEE802.3 <-> IEEE802.11 • Ethernet <-> Loopback • などなど
  • 15.
    5.tcprewrite • Src/DstMAC Address • IEEE802.1q (VLAN Tag) • Src/Dst IP Address • IPv4 Headers(TTOOSS//DDiiffffSSeerrvv//EECCNN)) • IPv6 Headers(Traffic Class/Flow Label) • TCP/UDP PortNum • IP/TCP/UDP Checksums の付与 • MTU 指定でtruncate
  • 16.
    6.tcpcapinfo • pcapファイルの各種情報を表示 • pcap ファイルを読み書きするアプリケーション を作る開発者向けのツール • tcprewrite のbug を直す時に作られた
  • 17.
    7.tcpbridge • 2つのネットワークをブリッジ • パケットを書き換えながらブリッジ •• ttccpprreewwrriittee と同じ書き換え機能を持つ
  • 18.
    ping flood(1) •Raspberry Pi • MODEL B (not B+) • CPU 700[MHz] •• MMeemmoorryy 551122[[MMiiBB]] • NIC 100[Mbps] • Raspbian GNU/Linux 7 • kernel 3.12.22+
  • 19.
    ping flood(2) ①標準のping コマンド(iputils-sss20101006) $ sudo ping -f -s 1472 192.168.0.1 ② hping3 version 3.0.0-alpha-2 $ sudo hping3 --flood -1 -d 1472 192.168.0.1 ③ tcpreplay version: 3.4.3 (build 2375) $ sudo tcpreplay --topspeed -K -i eth0 -l 0 sample.pcap
  • 20.
  • 21.
    ping flood(4) $uname -a Linux raspi 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 armv6l GNU/Linux $ sudo tcpreplay --topspeed -K -i eth0 -l 10000 ping-1472.pcap Actual: 10000 packets (15140000 bytes) sent in 1.64 seconds Rated: 9231707.0 bps, 70.43 Mbps, 6097.56 pps Statistics for network device: eth0 Attempted packets: 10000 Successful packets: 10000 Failed packets: 0 Retried packets (ENOBUFS): 0 Retried packets (EAGAIN): 0
  • 22.
    memo • http://tcpreplay.appneta.com/ • https://github.com/appneta/tcpreplay • 4.0.5 が最新(2014/09/22 時点) • http://tcpreplay.synfin.net/ は3.x の情報
  • 23.