Flow-tools Tutorial Mark Fullmer
Agenda Network flows Cisco / Juniper implementation – NetFlow Cisco / Juniper Configuration flow-tools programs overview and examples from Abilene and Ohio- Gigapop
Network Flows Packets or frames that have a common attribute. Creation and expiration policy – what conditions start and stop a flow. Counters – packets,bytes,time. Routing information – AS, network mask, interfaces.
Network Flows Unidirectional or bidirectional. Bidirectional flows can contain other information such as round trip time, TCP behavior. Application flows look past the headers to classify packets by their contents. Aggregated flows – flows of flows.
Unidirectional Flow with Source/Destination IP Key % telnet login: Active Flows Flow Source IP Destination IP
Unidirectional Flow with Source/Destination IP Key % telnet login: Active Flows Flow Source IP Destination IP % ping ICMP echo reply
Unidirectional Flow with IP, Port,Protocol Key % telnet login: Active Flows Flow Source IP Destination IPprotsrcPortdstPort TCP TCP ICMP ICMP 0 0 % ping ICMP echo reply
Bidirectional Flow with IP, Port,Protocol Key % telnet login: Active Flows Flow Source IP Destination IPprotsrcPortdstPort TCP ICMP 00 % ping ICMP echo reply
Application Flow % netscape Content-type: Active Flows Flow Source IP Destination IPApplication HTTP Web server on Port 9090
Aggregated Flow Flow Source IP Destination IPprotsrcPortdstPort TCP TCP ICMP ICMP 0 0 Source/Destination IP Aggregate Flow Source IP Destination IP Main Active flow table
Flow Descriptors A Key with more elements will generate more flows. Greater number of flows leads to more post processing time to generate reports, more memory and CPU requirements for device generating flows. Depends on application. Traffic engineering vs. intrusion detection.
Flow Accounting Accounting information accumulated with flows. Packets, Bytes, Start Time, End Time. Network routing information – masks and autonomous system number.
Flow Collection Passive monitor. Router other existing network device.
Passive Monitor Collection Workstation AWorkstation B Campus Flow probe connected to switch port in “ traffic mirror” mode
Router Collection Flow collector stores exported flows from router. LAN Internet
Passive Monitor Directly connected to a LAN segment via a switch port in “mirror” mode, optical splitter, or repeated segment. Generate flows for all local LAN traffic. Must have an interface or monitor deployed on each LAN segment. Support for more detailed flows – bidirectional and application.
Router Collection Router will generate flows for traffic that is directed to the router. Flows are not generated for local LAN traffic. Limited to “simple” flow criteria (packet headers). Generally easier to deploy – no new equipment.
Cisco NetFlow Unidirectional flows. IPv4 unicast and multicast. Aggregated and unaggregated. Flows exported via UDP. Supported on IOS and CatIOS platforms. Catalyst NetFlow is different implementation.
Cisco NetFlow Versions 4 Unaggregated types (1,5,6,7). 14 Aggregated types (8.x). Each version has its own packet format. Version 1 does not have sequence numbers – no way to detect lost flows. The “version” defines what type of data is in the flow. Some versions specific to Catalyst platform.
NetFlow v1 Key fields: Source/Destination IP, Source/Destination Port, IP Protocol, ToS, Input interface. Accounting: Packets, Octets, Start/End time, Output interface Other: Bitwise OR of TCP flags.
NetFlow v5 Key fields: Source/Destination IP, Source/Destination Port, IP Protocol, ToS, Input interface. Accounting: Packets, Octets, Start/End time, Output interface. Other: Bitwise OR of TCP flags, Source/Destination AS and IP Mask. Packet format adds sequence numbers for detecting lost exports.
NetFlow v8 Aggregated v5 flows. 3 Catalyst 65xx specific that correspond to the configurable flow mask. Much less data to post process, but lose fine granularity of v5 – no IP addresses.
NetFlow v8 AS Protocol/Port Source Prefix Destination Prefix Prefix Destination (Catalyst 65xx) Source/Destination (Catalyst 65xx) Full Flow (Catalyst 65xx)
NetFlow v8 ToS/AS ToS/Protocol/Port ToS/Source Prefix ToS/Destination Prefix Tos/Source/Destination Prefix ToS/Prefix/Port
NetFlow Packet Format Common header among export versions. All but v1 have a sequence number. Version specific data field where N records of data type are exported. N is determined by the size of the flow definition. Packet size is kept under ~1480 bytes. No fragmentation on Ethernet.
NetFlow v5 Packet Example NetFlow v5 header v5 record IP/UDP packet v5 record … …
NetFlow v5 Packet (Header) struct ftpdu_v5 { /* 24 byte header */ u_int16 version; /* 5 */ u_int16 count; /* The number of records in the PDU */ u_int32 sysUpTime; /* Current time in millisecs since router booted */ u_int32 unix_secs; /* Current seconds since 0000 UTC 1970 */ u_int32 unix_nsecs; /* Residual nanoseconds since 0000 UTC 1970 */ u_int32 flow_sequence; /* Seq counter of total flows seen */ u_int8 engine_type; /* Type of flow switching engine (RP,VIP,etc.) */ u_int8 engine_id; /* Slot number of the flow switching engine */ u_int16 reserved;
NetFlow v5 Packet (Records) /* 48 byte payload */ struct ftrec_v5 { u_int32 srcaddr; /* Source IP Address */ u_int32 dstaddr; /* Destination IP Address */ u_int32 nexthop; /* Next hop router's IP Address */ u_int16 input; /* Input interface index */ u_int16 output; /* Output interface index */ u_int32 dPkts; /* Packets sent in Duration */ u_int32 dOctets; /* Octets sent in Duration. */ u_int32 First; /* SysUptime at start of flow */ u_int32 Last; /* and of last packet of flow */ u_int16 srcport; /* TCP/UDP source port number or equivalent */ u_int16 dstport; /* TCP/UDP destination port number or equiv */ u_int8 pad; u_int8 tcp_flags; /* Cumulative OR of tcp flags */ u_int8 prot; /* IP protocol, e.g., 6=TCP, 17=UDP,... */ u_int8 tos; /* IP Type-of-Service */ u_int16 src_as; /* originating AS of source address */ u_int16 dst_as; /* originating AS of destination address */ u_int8 src_mask; /* source address prefix mask bits */ u_int8 dst_mask; /* destination address prefix mask bits */ u_int16 drops; } records[FT_PDU_V5_MAXFLOWS]; };
NetFlow v8 Packet Example (AS Aggregation) NetFlow v8 header v8 record IP/UDP packet v8 record … …
NetFlow v8 AS agg. Packet struct ftpdu_v8_1 { /* 28 byte header */ u_int16 version; /* 8 */ u_int16 count; /* The number of records in the PDU */ u_int32 sysUpTime; /* Current time in millisecs since router booted */ u_int32 unix_secs; /* Current seconds since 0000 UTC 1970 */ u_int32 unix_nsecs; /* Residual nanoseconds since 0000 UTC 1970 */ u_int32 flow_sequence; /* Seq counter of total flows seen */ u_int8 engine_type; /* Type of flow switching engine (RP,VIP,etc.) */ u_int8 engine_id; /* Slot number of the flow switching engine */ u_int8 aggregation; /* Aggregation method being used */ u_int8 agg_version; /* Version of the aggregation export */ u_int32 reserved; /* 28 byte payload */ struct ftrec_v8_1 { u_int32 dFlows; /* Number of flows */ u_int32 dPkts; /* Packets sent in duration */ u_int32 dOctets; /* Octets sent in duration */ u_int32 First; /* SysUpTime at start of flow */ u_int32 Last; /* and of last packet of flow */ u_int16 src_as; /* originating AS of source address */ u_int16 dst_as; /* originating AS of destination address */ u_int16 input; /* input interface index */ u_int16 output; /* output interface index */ } records[FT_PDU_V8_1_MAXFLOWS]; };
Cisco IOS Configuration Configured on each input interface. Define the version. Define the IP address of the collector (where to send the flows). Optionally enable aggregation tables. Optionally configure flow timeout and main (v5) flow table size. Optionally configure sample rate.
Cisco IOS Configuration interface FastEthernet0/0/0 ip address no ip directed-broadcast ip route-cache flow interface ATM1/0/0 no ip address no ip directed-broadcast ip route-cache flow interface Loopback0 ip address no ip directed-broadcast ip flow-export version 5 origin-as ip flow-export destination ip flow-export source loopback 0 ip flow-aggregation cache prefix export destination enabled
Cisco IOS Configuration krc4#sh ip flow export Flow export is enabled Exporting flows to (5004) Exporting using source IP address Version 5 flow records, origin-as Cache for prefix aggregation: Exporting flows to (5555) Exporting using source IP address flows exported in udp datagrams 0 flows failed due to lack of export packet 45 export packets were sent up to process level 0 export packets were punted to the RP 5 export packets were dropped due to no fib 31 export packets were dropped due to adjacency issues 0 export packets were dropped due to fragmentation failures 0 export packets were dropped due to encapsulation fixup failures 0 export packets were dropped enqueuing for the RP 0 export packets were dropped due to IPC rate limiting 0 export packets were dropped due to output drops
Cisco IOS Configuration krc4#sho ip ca fl IP packet size distribution (106519M total packets): IP Flow Switching Cache, bytes active, inactive, added ager polls, 0 flow alloc failures Active flows timeout in 30 minutes Inactive flows timeout in 15 seconds last clearing of statistics never Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec) Flows /Sec /Flow /Pkt /Sec /Flow /Flow TCP-Telnet TCP-FTP TCP-FTPD TCP-WWW TCP-SMTP TCP-X TCP-BGP
Cisco IOS Configuration krc4#sho ip ca fl TCP-other UDP-DNS UDP-NTP UDP-TFTP UDP-Frag UDP-other ICMP IGMP IPINIP GRE IP-other Total: SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts AT5/0/ AT1/0/ E4B A AT4/0/ AT1/0/ BE 074C 3 AT4/0/ AT1/0/ BE 09BB 646 AT1/0/ AT4/0/ C 04BE 3
Cisco CatIOS Configuration set mls flow full set mls nde version 7 set mls nde set mls agingtime 32
Cisco CatIOS Configuration swlap1> sh mls Total packets switched = Total bytes switched = Total routes = 2283 IP statistics flows aging time = 32 seconds IP statistics flows fast aging time = 0 seconds, packet threshold = 0 IP Current flow mask is Full flow Netflow Data Export version: 8 Netflow Data Export disabled Netflow Data Export configured for port 9110 on host Total packets exported = 6545 IPX statistics flows aging time = 256 seconds IPX flow mask is Destination flow IPX max hop is 255 Module 15: Physical MAC-Address b-78-bb-fc
Cisco CatIOS Configuration swlap1> sh mls stat entry Last Used Destination IP Source IP Prot DstPrt SrcPrt Stat-Pkts Stat-Bytes TCP 2206 WWW TCP WWW TCP WWW UDP DNS TCP DNS TCP WWW TCP WWW TCP WWW TCP WWW TCP TCP WWW TCP 2282 WWW TCP WWW TCP WWW 4 176
Cisco Catalyst Native IOS Configuration mls flow ip destination-source mls nde flow include mls nde src_address version 7 ip flow-export source Loopback0 ip flow-export version 5 peer-as ip flow-export destination
Cisco Issues Cat 65K Sup2/MSFC2 NetFlow implementation does not fill in important fields like input/output interface. Bug Id : CSCdt21216 Headline Netflow records source / dst interface index missing Product cat6000 Model x6k-sup2 Component earl Duplicate of Severity 3 Status C Version Found 6.1(1) Fixed-in Version 6.2(1) 6.1(3) 6.3(1)PAN Release Notes On Sup2, the destination and source Interface indices would be reported as zero in netflow exports. This is a hardware limitation.
Juniper Configration Sample packets with firewall filter and forward to routing engine. Sampling rate is limited to 7000pps. Fine for traffic engineering, but restrictive for DoS and intrusion detection. Juniper calls NetFlow cflowd.
Juniper Configration firewall { filter all { term all { then { sample; accept; } forwarding-options { sampling { input { family inet { rate 100; } output { cflowd { port 2055; version 5; } Firewall filterEnable sampling / flows
Juniper Configration interfaces { ge-0/3/0 { unit 0 { family inet { filter { input all; output all; } address /24; } Apply firewall filter to each interface.
Flow-tools Collection of programs to post process Cisco NetFlow compatible flows. Written in C, designed to be fast (scales to large installations). Includes library (ftlib) for custom applications. Installation with configure;make;make install on most platforms (FreeBSD, Linux, Solaris, BSDi, NetBSD).
flow-capture Collect NetFlow exports and stores to disk. Built in compression. Manages disk space by expiring older flow files at configurable limits. Detects lost flows by missing sequence numbers and stores with flow metadata.
flow-fanout Replicate NetFlow UDP streams from one source to many destinations. Destination may be a multicast address.
flow-expire Expire (remove) old flow files based on disk usage. Same functionality built in to flow- capture. Used when managing disk space in a distributed environment.
Abilene Configuration Collect and process flows for Abilene routers. Use sampled NetFlow. Distribute flows to Asta and Arbor Networks. Nightly usage reports. Archive of raw anonymized flows.
Abilene Configuration 12 Abilene core routers Configured with sampled NetFlow NetFlow exports (UDP) Server running IU AstaArborInternet2.edu Post Processed NetFlow (ssh) Ohio ITEC
Abilene Configuration NetFlow exports Ohio ITEC 4 servers running flow-capture Server with RAID5 Array / web server for nightly reports. flow-expire to manage disk space Pull compressed flow files with rsync from collectors.
Collector Placement and configuration NetFlow is UDP so the collector should ideally be directly connected to the router to minimize packet loss and IP spoofing risks. No flow control. Undersized collector will drop flows. Monitor netstat –s | grep buf and configure syslog so dropped flows will be logged.
flow-capture – flows/second
flow-capture – packets/second
flow-capture – flow drops/second
flow-print Formatted output of flow files. eng1:% flow-print < ft-v | head -15 srcIP dstIP prot srcPort dstPort octets packets
flow-cat Concat many flow files or directories of files. eng1:% ls ft-v ft-v ft-v ft-v ft-v ft-v ft-v tmp-v eng1:% flow-cat. | flow-print srcIP dstIP prot srcPort dstPort octets packets
flow-merge Flow-merge is similar to flow-cat except it maintains relative ordering of flows when combining the files. Typically used when combining flows from multiple collectors.
flow-filter Filter flows based on port, protocol, ASN, IP address, ToS bits, TCP bits, and tags. eng1% flow-cat. | flow-filter -P119 | flow-print | head -10 srcIP dstIP prot srcPort dstPort octets packets
flow-split Split flow files into smaller files. Typically used with flow-stat and graphing. For example if flow files are 1 hour and want 5 minute data points in graph, flow-split can take the 1 hour flow files and generate 5 minute files.
flow-tag Adds a tag field to flows based on IP exporter, IP prefix, Autonomous System, or next hop. Like flow-filter used with other tools. Used to manage groups of prefixes or ASN’s.
flow-header Display meta information in flow file. eng1:% flow-header < ft-v # # mode: normal # capture hostname: eng1.oar.net # exporter IP address: # capture start: Mon Jan 21 09:33: # capture end: Mon Jan 21 09:45: # capture period: 676 seconds # compress: on # byte order: little # stream version: 3 # export version: 5 # lost flows: 0 # corrupt packets: 0 # sequencer resets: 0 # capture flows: #
flow-stat Generates reports from flow files. Output is readable and easily imported into graphing programs (gnuplot, etc). IP Address, IP address pairs, ports, packets, bytes, interfaces, next hop, Autonomous System, ToS bits, exporter, and tags.
flow-stat - summary Total Flows : Total Octets : Total Packets : Total Time (1/1000 secs) (flows): Duration of data (realtime) : Duration of data (1/1000 secs) : Average flow time (1/1000 secs) : Average packet size (octets) : Average flow size (octets) : Average packets per flow : Average flows / second (flow) : Average flows / second (real) : Average Kbits / second (flow) : Average Kbits / second (real) :
flow-stat – Source AS % Total # # src AS flows octets packets duration # NSFNETTEST14-AS ONENET-AS UONET UPITT-AS CONCERT OHIOU CMU-ROUTER BOSTONU-AS PURDUE STANFORD UR UMN-AGS-NET-AS RISQ-AS PENN-STATE RIT-ASN
flow-stat – Dest AS % Total # # dst AS flows octets packets duration # NSFNETTEST14-AS PENN-STATE CONCERT ONENET-AS STANFORD JANET DFN-WIN-AS CMU-ROUTER UONET PURDUE UMN-AGS-NET-AS UPITT-AS MIT-GATEWAYS RIT-ASN INDIANA-AS
flow-stat – Src/Dest AS % Total # # src AS dst AS flows octets packets duration # GEORGIA-TECH PENN-STATE NWU-AS UONET CONCERT UCLA NSFNETTEST14-AS CONCERT UONET BCNET-AS MIT-GATEWAYS UONET MIT-GATEWAYS STANFORD ONENET-AS-1 NSFNETTEST14-AS UONET PENN-STATE NOAA-AS NOAA-FSL DENET UONET NSFNETTEST14-AS UC-DOM ITALY-AS UONET NSFNETTEST14-AS CONCERT UONET ITALY-AS
flow-stat – Src Port % Total # # port flows octets packets duration # ftp-data http unidata-ldm synoptics-trap ftp ssh aol nntp
flow-stat – Dst Port % Total # # port flows octets packets duration # nntp synoptics-trap ftp-data vlsi-lm netview-aix
flow-stat – IP protocol % Total # # protocol flows octets packets duration # tcp udp icmp gre pim ipv ax ipencap igmp ospf rsvp
flow-stat –Src/Dst Prefix % Total # # Source Prefix Destination Prefix flows octets packets duration # / / / / / / / / / / / / / / / / / / / / /16 18/ / / / /
flow-stat – ifIndex % Total # # in out flows octets packets duration #
flow-stat – Next-Hop % Total # # IPaddr flows octets packets duration #
flow-stat – Multicast S,G % Total # # src IPaddr dst IPaddr flows octets packets duration #
flow-stat – ToS % Total # # ToS flows octets packets duration #
flow-stat – ToS xx % Total # # Source Prefix Destination Prefix flows octets packets duration # / / / / / / / / / / / / / / / / / / / / / / / /
flow-stat Active IP addresses
flow-stat Total Traffic To/From Abilene
flow-stat SMTP Traffic To/From Abilene
flow-stat SMTP Traffic To- From Abilene
flow-stat OSU Traffic To/From Abilene
flow-stat SEGP Traffic To/From Abilene
flow-dscan DoS detection / network scanning tool. Flag hosts which have flows to many other hosts. Flag hosts which are using a large number of TCP/UDP ports. Works better on smaller networks or with flow-filter to limit traffic. For example filter TCP port 25 to detect hosts infected with worm.
flow-gen Debugging tool to generate flows. eng1:% flow-gen -V8.1 | flow-print | head -10 srcAS dstAS in out flows octets packets duration
flow-send Transmit flow files with NetFlow protocol to another collector. Can be used to take flow-tools files and send them to other NetFlow compatible collector.
flow-receive Like flow-capture but does not manage disk space. Output is to standard out and can be used directly with other flow- tools programs. Typically used for debugging. eng1:% flow-receive 0/0/5555 | flow-print flow-receive: New exporter: time= src_ip= dst_ip= d_version=8 srcPrefix srcAS dstPrefix dstAS input output flows / / / / / / / / / / / /
flow-import Import flows from other formats into flow-tools. Currently supports ASCII and cflowd formats.
flow-export Export flows from flow-tools files to other formats. Currently supports ASCII and cflowd formats. ASCII output can be used with perl or other scripting languages (with a performance penalty).
flow-xlate Translate flows among NetFlow versions. Originally intended for use with Catalyst switches since they export some flows in version 7 and others in version 5 format.
Contributed software Dave Plonka’s Cflow module. Perl interface to flow-tools. Allows flow-tools to be the back-end to flowscan. Inter.net billing tools. Flow-extract, flow-merge and other security tools from E. Larry U Chicago. BGP tools from
References flow-tools: Abilene NetFlow page Flow-tools mailing list: IETF standards effort: