3
0

More than 3 years have passed since last update.

とっさにNetFlowを生成しないといけないときに

Last updated at Posted at 2019-10-22

DISCLAIMER: この記事は書かれてから、たぶん4年くらい経過しています。

はじめに

普段、なに気なく生活していると、とっさにNetFlowを生成しないといけないシチュエーションがありますよね。私もそうだったので、簡単にフロー生成できるツールを調べてみました。

NetFlowジェネレータ

軽く試したのも含めて以下に5つほど書いておきます。

  1. Paessler NetFlow Generator
  2. Flowalyzer™ NetFlow Generator
  3. flowgen
  4. Tcpreplay
  5. Ciscoルータなど、実ルータに NetFlow を設定する

私の使い分け

私は以下のように使い分けてました

  • ちょっと軽くテストしたい時には Paessler NetFlow Generator
  • 複雑なフローを作りたい時には Flowalyzer™ NetFlow Generator
  • スクリプト書いて自動化したり、負荷試験する時には flowgen

Paessler NetFlow Generator

スクリーンショット

image

いいところ:

  • WindowsのGUIで簡単に設定・試すことができる(古いツールっぽいけどWindows10でも動いた)
  • フロー生成の間隔がかなり柔軟に設定できる。ミリ秒以下まで設定できた。ちょっとしたパフォーマンス試験だったらこれでいける

いまいちなところ:

  • v5 フローしかサポートしてない、割り切った仕様
  • NetFlowのいくつかのヘッダフィールドが適当。例えば packet size フィールドがゼロパディングされてたりするさらに割り切った仕様。ちゃんとした NetFlowコレクターはこのせいで不正なフローを受け取ったとみなしてしまい、フローを捨ててしまったり。

Flowalyzer™ NetFlow Generator

スクリーンショット

image

いいところ:

  • フローバージョンは v5, v9, IPFIX までサポートしている
  • 古そうなのに Windows10 でも動いた
  • generator だけじゃなくて listner, configuratior, trender, communicator としても動く
  • 結構、複雑なフローパラメータ設定ができる

いまいちなところ:

  • フロー間隔はミリ秒以下の指定ができなかった。これでは負荷試験には使えない。

flowgen

スクリーンショット


$ ./flowgen
Usage: flowgen [options] [flowrec-options] <collector>
 options:
   -n, --count <num>
   -p, --port <num>
   -V, --version <version>
   -f, --flowrec <# of flow records in packet>
   -d, --debug <debug level>
   -N, --nosend
   -h, --help
 flowrec-options:
   -w, --wait <wait time>
   -i, --interval <interval>
   --enginetype <engine type>
   --engineid <engine id>
   --srcaddr <src ip address>
   --dstaddr <dst ip address>
   --nexthop <nexthop ip address>
   --inputif <input IfIndex>
   --outputif <output IfIndex>
   --packets <# of packets>
   --octets <# of octets>
   --firstseen <first seen>
   --lastseen <last seen>
   --srcport <src port>
   --dstport <dst port>
   --tcpflags <tcp flags>
   --protocol <protocol number>
   --tos <tos value>
   --srcas <src AS#>
   --dstas <dst AS#>
   --srcmask <src subnet mask length>
   --dstmask <dst subnet mask length>

  Numbers can be expressed using the following meta characters:
    111      (static)
    111-222  (sequential)
    111:222  (random)
    100@70,200@20,300@10   (probabilistic)

いいところ:

  • UNIXで動く(バイナリファイル1つで手軽)
  • 上記のように、かなりいろいろコンフィグできる
  • CLIなので自動化しやすい
  • しんどーさんが書いたツール

いまいちなところ:

  • v5 フローのみのサポート

Tcpreplay

これはジェネレータというよりは、リプレイです。つまり pcap ファイルを読んでその通りの NetFlow パケットを再現します

スクリーンショット


root@tcpreplay:/tcpreplay# tcpreplay -i eth0 -K --mbps 10000 bigFlows.pcap 
File Cache is enabled
Actual: 791615 packets (355417784 bytes) sent in 1.04 seconds.
Rated: 245153585.1 Bps, 1961.22 Mbps, 546025.73 pps
Flows: 40686 flows, 28063.64 fps, 791179 flow packets, 436 non-flow
Statistics for network device: eth0
    Attempted packets:         791615
    Successful packets:        791615
    Failed packets:            0
    Truncated packets:         0
    Retried packets (ENOBUFS): 0
    Retried packets (EAGAIN):  0
root@tcpreplay:/tcpreplay# tcpreplay -i eth0 -K --mbps 1000 bigFlows.pcap 
File Cache is enabled
Actual: 791615 packets (355417784 bytes) sent in 2.08 seconds.
Rated: 124999836.1 Bps, 999.99 Mbps, 278409.66 pps
Flows: 40686 flows, 14309.19 fps, 791179 flow packets, 436 non-flow
Statistics for network device: eth0
    Attempted packets:         791615
    Successful packets:        791615
    Failed packets:            0
    Truncated packets:         0
    Retried packets (ENOBUFS): 0
    Retried packets (EAGAIN):  0
root@tcpreplay:/tcpreplay# tcpreplay -i eth0 -K --mbps 1000 --loop 10 bigFlows.pcap 
File Cache is enabled
Actual: 7916150 packets (3554177840 bytes) sent in 28.04 seconds.
Rated: 124999915.2 Bps, 999.99 Mbps, 278409.83 pps
Flows: 40686 flows, 1430.92 fps, 7911790 flow packets, 4360 non-flow
Statistics for network device: eth0
    Attempted packets:         7916150
    Successful packets:        7916150
    Failed packets:            0
    Truncated packets:         0
    Retried packets (ENOBUFS): 0
    Retried packets (EAGAIN):  0
root@tcpreplay:/tcpreplay# tcpreplay -i eth0 -K --mbps 1000 --loop 10 bigFlows.pcap 
File Cache is enabled
Actual: 7916150 packets (3554177840 bytes) sent in 28.04 seconds.
Rated: 124999981.1 Bps, 999.99 Mbps, 278409.98 pps
Flows: 40686 flows, 1430.92 fps, 7911790 flow packets, 4360 non-flow
Statistics for network device: eth0
    Attempted packets:         7916150
    Successful packets:        7916150
    Failed packets:            0
    Truncated packets:         0
    Retried packets (ENOBUFS): 0
    Retried packets (EAGAIN):  0
root@tcpreplay:/tcpreplay# tcpreplay -i eth0 -K --mbps 1000 --loop 10 smallFlows.pcapFlows.pcap 
File Cache is enabled

いいところ:

  • UNIXで動く(バイナリファイル1つで手軽)
  • pcap ファイルさえあれば、何回でも同じフローを再現して生成できる

いまいちなところ:

  • 使用するには pcap ファイルが必要

実ルータを使って生成

... 省略

まとめ

このくらい知っておけばとりあえず、とっさに NetFlow 生成を振られてもあせらず対応できると思います

3
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0