Previous Page Next Page

Chapter 7. NetFlow

This chapter describes the NetFlow features in Cisco IOS. It enables you to distinguish the different NetFlow versions, recognize the latest NetFlow features, and understand the natural NetFlow evolution toward IPFIX. Platform-specific details are discussed, along with command-line references, examples, and SNMP MIB details.

Cisco IOS NetFlow technology is an integral part of Cisco IOS software that collects packets, classifies packets into flows, and measures flow statistics as the packets enter or exit the network element's interface.

By analyzing NetFlow data, a network engineer can identify the cause of congestion, determine the Class of Service (CoS) for users and applications, identify the source and destination network, and so on. NetFlow allows granular and accurate traffic measurements as well as high-level aggregated traffic collection. Because it is part of Cisco IOS software, NetFlow enables networks to perform IP traffic flow analysis without deploying external probes, making traffic analysis economical even on large IP networks.

The key components of NetFlow are the NetFlow cache that stores IP flow information and the NetFlow export mechanism that sends NetFlow data to a collector, such as the NetFlow Collector. These two key components, the metering process and the exporting process, sometimes lead to confusion, because the term "NetFlow" refers to both of them. NetFlow operates by creating a NetFlow cache entry (also called flow record) for each active flow. NetFlow maintains a flow record within the cache for active flows. Each flow record contains multiple data fields, which are exported to a NetFlow collector. The Cisco NetFlow Collection Engine (NFC) is a device that provides flow filtering and aggregation capabilities. Afterwards, Network Management applications, such as performance monitoring, security analysis, and billing solutions, can access the aggregated NetFlow records for further processing. As illustrated in Figure 7-1, the Network Analysis Module (NAM) on the Catalyst 6500/Cisco 7600 can also collect flow records.

Figure 7-1. Hierarchical Representation of the NetFlow Collection


NetFlow is by far the most granular and complete accounting mechanism in the Cisco devices. This is reflected by the size of this chapter as well as the number of deployed NetFlow solutions in customer networks and the large number of partner applications that support NetFlow. The latest NetFlow developments position NetFlow as a superset of several existing accounting features. Therefore, NetFlow enables several key customer applications:

As you will see later in this chapter, new information is exported by leveraging the NetFlow version 9 export format, including Layer 2 information, new security detection and identification information, IPv6, Multicast, MPLS, BGP information, and more. NetFlow version 9 has the advantage of being flexible and extensible. Furthermore, it is the basis protocol for the IP Flow Information eXport (IPFIX) working group, developed as an IETF standards track protocol. IPFIX was designed to transport any accounting and performance information from network elements to a collection device.

Fundamentals of NetFlow

NetFlow identifies packet flows for IP packets, where a flow is identified by a number of fields in the data packet. NetFlow does not involve any connection-setup protocol between routers, networking devices, or end stations. NetFlow does not change the IP packets and is transparent to the existing network infrastructure.

NetFlow operates by creating a NetFlow cache entry that contains the information for each active flow. Unless sampling has been configured, the NetFlow process inspects every packet and creates a new flow record in the cache or updates the usage parameters (such as the number of packets and bytes) of existing flow records. Each flow record is created by identifying packets with same flow characteristics and counting or tracking the packets and bytes per flow. The cache entries are exported to a collector periodically based on the flow timers. The NetFlow Collector stores the flow records that were exported by the network elements.

It is important to note that NetFlow is not a switching path, as it was originally. In fact, NetFlow is an accounting feature on top of existing switching paths, such as Cisco Express Forwarding (CEF) or Distributed CEF. NetFlow is very efficient; the typical amount of export data is about 1.5 percent of the switched traffic in the network element. On most Cisco platforms, NetFlow accounts for every packet and provides a highly condensed and detailed view of all network traffic that passed the device. Some high-end platforms, such as the Cisco 12000 router, prefer sampled NetFlow, which meters ("samples") only a subset of all packets entering the interface.

Next to the monitoring of IPv4 flows, NetFlow supports the monitoring of IPv6 environments. NetFlow captures data from ingress (incoming) and egress (outgoing) packets. NetFlow gathers data for the following ingress IP packets:

NetFlow captures data for egress packets through the following features:

Flow Definition

A flow is defined as a set of packets having common properties: one or more packet header fields (e.g. destination IP address, transport header field), one or more characteristics of the packet itself (e.g. number of MPLS labels), one or more fields derived from packet treatment (e.g. the BGP next hop). A packet belongs to a flow record if it completely matches all defined flow properties.

NetFlow defines a flow by a combination of key-fields in the packet. In the documentation they are also called "flow keys" because they define a flow. Usually additional information is reported in a flow, such as number of packets and bytes, start and stop time, and so on. These reporting fields do not define a flow; therefore, they are called "flow values" or "non-key-fields". For consistency, we use only the terms "key-field" and "non-key-field."

Initially, NetFlow defines a flow as the combination of the following seven key-fields:

Key-fields are a set of values that determine how a flow is identified. The seven key-fields define a unique flow that represents a unidirectional stream of packets. If a flow has a different field than another flow, it is considered a new flow. A flow contains other accounting fields (such as the AS number in the NetFlow version 5 flow format) that depend on the version record format that you configure for export. Next to the key-fields, the non-key-fields complete the flow records with extra information such as number of packets, number of bytes, and BGP AS numbers.

Specific to the router, the "router-based aggregation feature" aggregates the flow records further. It works by reducing or modifying the initial set of seven key-fields. For example, as described later, in Table 7-3, the Protocol Port-TOS aggregation type applies the source and destination application ports as key-fields. Alternatively, the destination IP address key-field can be modified to the destination prefix key-field, entailing flow records aggregation. Various aggregation types imply different key-field selection. More details are described in the section "NetFlow Version 8: Router-Based Aggregation."

Additionally, the Catalyst 6500/Cisco 7600 offers extra flexibility in the key-field configuration. The flow mask is used for data aggregation in the NetFlow cache. You can select (configure) the flow mask from a predefined set of values. For example, if you are interested in the traffic accounting per source and destination IP address, the destination-source (see Figure 7-2) is the best flow mask option, because it uses only the source and destination IP addresses as key-fields to classify the observed packets.

Figure 7-2. Catalyst 6500/Cisco 7600 Flow Masks


This "flow mask" concept is different from the router-based aggregation scheme. Router-based aggregation uses multiple caches; data aggregation is performed by processing flow entries as they expire from the main cache. Flow mask aggregates the flow information directly into the main NetFlow cache on the Catalyst 6000/Cisco 7600. Enhanced scalability is the main reason for the flow mask concept, which also decreases the amount of flow export. While the flow mask increases the NetFlow cache efficiency, it also decreases the level of information. Figure 7-2 shows the Catalyst 6500/Cisco 7600 flow masks' possible options.

Originally, the key-fields on the routers were defined by a fixed seven tuples of packet fields or were determined by the selected router-based aggregation. However, Flexible NetFlow overcomes those limitations by letting you define aggregation schemes. This extra flexibility for the metering process allows administrators to specify their own set of key-fields and non-key-fields. On one hand, this optimizes the metering process, because only the flows of interest are looked at. On the other hand, it optimizes the exporting process, because only the information of interest is exported. Each aggregation specified with Flexible NetFlow produces its own cache on the router and allows real-time diagnosis without exporting the flow records to the collector. In addition to the available key-fields defined in NetFlow versions 5, 8, and 9, Flexible NetFlow introduces a series of new information elements available as key-fields or non-key-fields. A full section is dedicated to Flexible NetFlow later in this chapter.

Cache Concept

The characteristics of active flows can be analyzed by displaying the cache, which makes NetFlow a powerful troubleshooting tool, even without exporting the flow records to a collector. For a better understanding, look at the following output from the NetFlow command show ip cache flow:

7200-netflow#show ip cache flow
1. IP packet size distribution (1693 total packets):
2. 1-32 64    96   128   160  192  224   256  288  320  352  384  416  448    480
3. .000 .190  .190 .615   .000 .000 .000  .000  .000 .000 .000  .000 .000  .000
.000
4. 512   544   576   1024   1536  2048  2560  3072  3584  4096   4608
5. .000 .000  .003  .000   .000  .000  .000  .000  .000  .000   .000
6. IP Flow Switching Cache, 4456704 bytes
7. 2 active, 65534 inactive, 7 added
8. 120 ager polls, 0 flow alloc failures
9. Active flows timeout in 30 minutes
10. Inactive flows timeout in 15 seconds
11. last clearing of statistics 00:03:18
12. Protocol  Total  Flows  Packets  Bytes  Packets  Active (Sec)  Idle (Sec)
13. -----     Flows  /Sec   /Flow    /Pkt    /Sec    /Flow         /Flow
14. TCP-Telnet  3    0.0    12       106     0.1     4.2            15.8
15. ICMP        2    0.0    500      100     5.2     2.6            15.4
16. Total:      5    0.0    207      100     5.4     3.6            15.6
17. SrcIf     SrcIPaddress  DstIf  DstIPaddress  Pr  SrcP  DstP  Pkts
18. Et0/0     10.10.10.34   Et0/0  10.10.10.255  11  0208  0208  1
19. Se3/0.16  10.1.10.1     Fa4/0  192.168.10.1  06  0017  2AFF  6


					  

The first portion of the output, in lines 1 through 5, is the packet size distribution. Several questions that operators ask are answered here, such as "What percentage of packets of each size have passed through this router?" This information can be very useful for network troubleshooting, traffic engineering, and capacity planning.

Lines 6 through 8 describe the parameters assigned to the NetFlow cache. The default maximum number of cached flows is 65,536. In this example, two cache entries are in use, and 65,534 are available for new flows. Furthermore, the "added" parameter on line 7 displays the total number of flows examined in the cache.

Lines 9 through 11 show how long a particular flow will stay in the cache. In this example, if there were no activity on the flow for 15 seconds, the entry would have been exported and purged from the cache. If an active entry is in the cache for 30 minutes, it is expired, even if traffic still exists. A new cache entry is built on the receipt of the next packet for that particular flow. Connection-oriented flows, such as Telnet and FTP, are purged as soon as the session is closed, which is identified by TCP-FIN (finish) or TCP-RST (reset) packets.

Lines 12 through 16 break down the flows by protocol. Again, this is an ideal source of information for the network administrator, because it lists traffic distribution by type of applications.

Lines 17 through 19 show the actual NetFlow cache entries. The show ip cache verbose flow command shows extra information about all the information elements contained in the flow record. Actually, every information element that will be exported to a NetFlow collector is visible in the cache. The following example offers the output of flow records displayed by the show ip cache verbose flow command.

7200-netflow#show ip cache verbose flow
12. SrcIf     SrcIPaddress  DstIf  DstIPaddress  Pr   TOS  Flgs         Pkts
13. Port      Msk           AS     Port          Msk  AS   NextHop     B/pk  Active
14. Et0/0     10.10.10.34   Et1    10.10.10.255  11   00   10           1
15. 0208      /0            0      0208          /0   0    10.48.71.1  52     0.0
16. Se3/0.16  10.1.10.1     Fa4/0  192.168.10.1  06   00   10          3
17. 0017     /24            0      2AFF          /24  0    10.1.20.1   78     1.5


					  

Compared to the output of show ip cache flow, only the flow records section is different (starting at line 12), because it now contains extra information elements for the flow. The first flow records are displayed in lines 14 and 15, and the second flow records are displayed in lines 16 and 17. The information element type is shown in lines 12 and 13.

The NetFlow cache size can vary from 1024 to 524,288 entries and is configurable for software-based platforms (such as the Cisco 7200 and 7500 routers). Each cache entry consumes a minimum of 64 bytes of memory. Some features such as BGP Next-Hop and MPLS-Aware NetFlow require extra bytes for additional information elements. The amount of memory on a Cisco 12000 line card denotes how many flows are possible in the cache. The maximum number of entries is directly related to the physical memory. For example, if an engine 3 line card has 256 MB of memory, NetFlow allocates 256 K entries (where K equals 1024). The Cisco Catalyst 6500/Cisco 7600 has different hardware cache sizes, based on the supervisor card and Policy Feature Card (PFC).

Table 7-1 displays the number of effective flow entries of the different supervisor engines on the Catalyst 6500/Cisco 7600.

Table 7-1. Effective Size of Flow Entries on the Catalyst 6500 and Cisco 7600
 Table SizeHash EfficiencyEffective SizeHash Key Size
Sup2128 KB25 percent32 K17 bits
Sup720128 KB50 percent64 K36 bits
Sup720-3B128 KB90 percent115 K36 bits
Sup720-3BXL256 KB90 percent230 K36 bits


The hash efficiency and the effective number of flow entries improved dramatically from the very first to the latest supervisor types. This was achieved by using more bits in the hash key size and algorithm enhancements. Combined with the table size of 256 K, the maximum effective size is 230-K entries on the latest SUP720-3BXL.

Aging Flows on a Router

On the router, the rules for expiring flow records from the cache entries include the following:

Figure 7-3 illustrates the life of a non-TCP flow. The active timer 1 (AT1) starts when the first packet arrives and a flow entry is created in the cache. In this example, we assume that packets flow constantly, with 18 packets in total. AT1 expires when it exceeds the default value of 30 minutes. At this time, the flow record, which contains the accounting details for the first 30 minutes, is exported. Because packets for this flow definition continue to arrive, the metering process creates a new flow entry in the cache that is identical to the previous one. This triggers the start of a new active timer (AT2). The inactive timer immediately starts after every packet and is cleared if new packets arrive before it expires. When no more packets for this flow arrive, the inactive timer (IT1) continues to count and expires after the default value of 15 minutes. At this point, the flow is considered inactive and is expired from the cache and exported. (Note that in Figure 7-3, IT1 actually starts 18 times and is cleared 17 times, but for simplicity this is shown only once.)

Figure 7-3. NetFlow Flow Aging Mechanism on Routers


Figure 7-4 shows the flow aging mechanism for the export of flow records from the main cache.

Figure 7-4. NetFlow Flow Aging Mechanism from the Router's Main Cache


Aging Flows on a Catalyst

Flows on Catalyst switches use different flow aging timers than the ones associated with the NetFlow cache on routers. However, the flow records aging mechanisms are almost similar to the ones on the router. On a Catalyst switch, the following three timers influence the flow aging:

The aging of a flow entry occurs when no more packets are switched for that flow (inactive timer). Fast aging reduces the number of entries in the cache for short-duration connections. For example, the fast aging timer can be configured to 128 seconds. That would ensure that short-lived flows or very slow flows would be purged more frequently. This setting can help limit the growth of the NetFlow table if the number of flows is still below the recommended upper bound and the growth trend is low. Much faster aging is required when the NetFlow table utilization gets closer to its limit. You can configure a minimum fast aging time as the most aggressive way of purging active entries to free up space for new flows. However, this drastic approach has an increasing impact on the CPU utilization as more flows are exported. A good example of fast-aging timers is to quickly clean out the many single-packet flows, such as DNS, NTP, and port scans, that consume valuable space in the flow table and offer little value in the reports.

Export Version and Related Information Elements

Expired flows are grouped into NetFlow export packets to transport them from the network element to a collector. NetFlow export packets may consist of up to 30 flow records, depending on the NetFlow protocol version.

A NetFlow export packet consists of a header and a sequence of flow records. The header contains information such as sequence number, record count, sysUpTime, and universal time (UTC). The flow record provides flow information elements such as IP addresses, ports, and routing information.

The next sections cover NetFlow versions 1, 5, 7, 8, 9 and IPFIX in detail. Versions 2, 3, and 4 were never released, and version 6 was developed for one specific customer and is no longer supported.

NetFlow Version 1: The Beginning

NetFlow version 1 is the original export protocol format and has been supported since IOS version 11.0. It is rarely used today and should not be used unless a legacy collection system requires it. Preferably, use version 5 or 9 instead.

NetFlow Version 5: The Foundation

The NetFlow protocol version 5 format adds Border Gateway Protocol (BGP) Autonomous System information and flow sequence numbers.

Figure 7-5 shows the information elements available in the NetFlow version 5 export format. The show ip route cache verbose flow command visualizes the content of all these information element values. Remember the seven key-fields: input ifIndex, type of service, protocol, IP source and destination addresses, and TCP/UDP source and destination port numbers.

Figure 7-5. NetFlow Version 5


The export of flow records with NetFlow version 5 offers answers to many questions, such as "Who are the users?", "Which applications are they using?", "In what quantities?", "At what times?", and "For how long?".

NetFlow Version 7: Catalyst-Specific

The Catalyst is the only platform that supports NetFlow version 7. From an architectural perspective, the Catalyst 6500/Cisco 7600 are composed of a supervisor, called the Policy Feature Card (PFC), and an optional Multilayer Switch Feature Card (MSFC), which performs the routing function. To grasp the NetFlow version 7 concepts on the Catalyst, you must understand the Multilayer Switching (MLS) architecture in conjunction with PFC version 1. MLS is an excellent method of accelerating routing performance with dedicated Application-Specific Integrated Circuits (ASIC). MLS offloads a significant portion of the routing function (packet rewrite) to hardware; thus, it is also called switching. Hence, MLS and Layer 3 switching are equivalent terms. MLS identifies flows on the PFC after the first packet is routed by the MSFC. By creating an entry on the PFC for routed flows, MLS transfers the process of traffic forwarding for these flows to the PFC. This mechanism bypasses the MSFC for subsequent packets of the same flow, which reduces the load on the MSFC. The flow mask command specifies the properties of these entries on the PFC.

In practical terms, if five related ping packets traverse a Catalyst 6500/Cisco 7600 with a PFC1, only the first one is routed through the MSFC. The four remaining packets are switched on the PFC. However, the five ping packets are considered a single flow because the characteristics of the packets (such as source address, destination address, and source port number) do not change. At the end of the flow, the Catalyst generates two NetFlow records. Record 1 is composed of the first packet accounted on and exported by the MSFC. Record 2 is composed of the subsequent packets of the same flow accounted on and exported by the PFC. Both records are exported to a NetFlow collector, which can aggregate them into a single flow record. To enable an easy way to merge flow records that are exported by two separate components with two different source IP addresses, the PFC provides the MLS traffic statistics in a NetFlow version 7 flow record. The only difference between NetFlow version 5 and version 7 is an extra information element in version 7: the shortcut IP address, which is the IP address of the MSFC. Because the IP address of the MSFC is also included in the MSFC's flow record, a NetFlow collector can combine the two records into a single flow entry.

With the introduction of PFC version 2, Cisco Express Forwarding (CEF) was introduced. CEF works with a Forwarding Information Base (FIB), which maintains next-hop address information based on the information in the IP routing table. When the Catalyst contains an MSFC card, it runs Distributed CEF (DCEF), which maintains a FIB on the PFC and the MSFC. As a special feature of DCEF, the FIB on the PFC synchronizes routing entries with the FIB on the MSFC, and vice versa. If a packet arrives on the Catalyst and there is no entry for the destination in the FIB on the PFC, the first packet of the flow is sent to the MFSC. Next, the MFSC performs the Address Resolution Protocol (ARP) request to map the destination IP network addresses to the MAC addresses and identify the destination port. Then the MSFC FIB creates the new entry and updates the PFC FIB. Therefore, the MSFC accounts for the first packet for this specific destination, and the PFC accounts for all the subsequent packets of a flow. Although this principle is similar to MLS, the big difference in case of DCEF is that only the first packet to a new adjacency (next hop) is accounted and collected by the MSFC. Note that the first packet to use a new adjacency is incomplete (no output interface, no IGP next hop, no destination prefix) because the ARP reply has not arrived yet. After the initial packet to a new adjacency creates an entry in the PFC's FIBs, all subsequent packets toward this destination are switched by the PFC. MLS, in contrast to DCEF, sends every initial packet of a routed flow to the MSFC. As a consequence, fewer flow records are gathered by the MSFC with DCEF, compared to MLS.

Before PFC version 2, the PFC and MSFC were treated as separate devices and used different source IP addresses, which were reported as different flows at a NetFlow collector and needed to be aggregated there. Starting with PFC version 2, the flow records from the PFC and the MSFC use the same source IP address. This means that even if the collector receives flow records from two different entities, the flow records appear as being exported by the same network element. Consequently, there was no longer a need to export the shortcut IP address. Starting with PFC version 2, flow records are exported with NetFlow version 5, which is the preferred solution.

To summarize NetFlow version 7 at the Catalyst:

NetFlow Version 8: Router-Based Aggregation

Enabling NetFlow on multiple interfaces on high-end routers (such as the Cisco 12000) usually results in a large volume of NetFlow records. Aggregation of export data is typically performed by NetFlow collection tools on management workstations. Router-based aggregation allows first-level aggregation of NetFlow records on the router. The NetFlow router-based aggregation feature enables on-board aggregation by maintaining one or more extra NetFlow caches with different combinations of fields that determine which flows from the main cache are grouped. This mechanism offers benefits such as reduced bandwidth requirements between the router and the collector, and a reduced number of collection workstations.

Router-based NetFlow aggregation introduces extra aggregation schemes with separate caches in addition to the main NetFlow cache. As flows expire in the main cache, depending on the selected aggregation scheme, relevant fields are extracted from the expired flows, and the corresponding flow entry in the aggregation cache is updated. As illustrated in Figure 7-6, the same flow aging mechanisms are applied for both the main cache and the router-based aggregation caches. The exception is terminated TCP connections, because TCP flags are not present in any of the aggregation caches.

Figure 7-6. NetFlow Versions 5 and 8


Router-based aggregation flow records are exported with NetFlow version 8. Note that some router-based aggregations introduce new information elements and therefore require exclusive export with NetFlow version 9. The BGP Next-Hop ToS aggregation scheme is an example of this. For more details, see the next section about NetFlow version 9. For completeness and comparison purposes, Figure 7-6 shows the export of both NetFlow version 5 and 8 flow records. However, when router-based aggregation is enabled, there is no need to export from the main cache with NetFlow version 5, because the router would send redundant information. An exception to this rule is a scenario in which the content of the main cache is exported to the first collector (such as for security monitoring) while the content of the aggregation cache(s) is exported to the second collector (for example, for billing purposes). Indeed, each aggregation cache scheme allows configuration of its individual cache size, its flow aging timeout parameters, its export destination IP address, and its export destination UDP port number. The default size for the secondary NetFlow aggregation cache is 4096 entries.

Selecting a NetFlow Aggregation Scheme

The following are the five non-TOS-based aggregation schemes:

The NetFlow ToS-based router aggregation feature introduces seven additional aggregation schemes that include the ToS byte as a key-field:

Note that the BGP next ToS aggregation scheme is special because the BGP next hop is a new information element introduced with NetFlow version 9. Therefore, this aggregation exports its flow records exclusively with NetFlow version 9. The section "BGP Next-Hop Information Element" in this chapter covers this new aggregation scheme, along with an example.

Tables 7-2 and 7-3 outline the router-based aggregation scheme information, with the exception of the BGP Next Hop ToS aggregation scheme. Table 7-2 shows the flow information elements used in non-ToS-based aggregation schemes; Table 7-3 lists the ones used in ToS-based aggregation schemes.

Table 7-2. Non-ToS-Based Aggregation Schemes
 ASProtocol PortSource PrefixDestination PrefixPrefix
Source Prefix  check mark check mark
Source Prefix Mask  check mark check mark
Destination Prefix   check markcheck mark
Destination Prefix Mask   check markcheck mark
Source Application Port check mark   
Destination Application Port check mark   
Input Interfacecheck mark check mark check mark
Output Interfacecheck mark  check markcheck mark
IP Protocol check mark   
Source AScheck mark check mark check mark
Destination AScheck mark  check markcheck mark
First Timestampcheck markcheck markcheck markcheck markcheck mark
Last Timestampcheck markcheck markcheck markcheck markcheck mark
Number of Flowscheck markcheck markcheck markcheck markcheck mark
Number of Packetscheck markcheck markcheck markcheck markcheck mark
Number of Bytescheck markcheck markcheck markcheck markcheck mark


Table 7-3. ToS-Based Aggregation Schemes
 AS-TOSProtocol Port-TOSSource Prefix-TOSDestination Prefix-TOSPrefix-TOSPrefix-Port
Source Prefix  check mark check markcheck mark
Source Prefix Mask  check mark check markcheck mark
Destination Prefix   check markcheck markcheck mark
Destination Prefix Mask   check markcheck markcheck mark
Source Application Port check mark   check mark
Destination Application Port check mark   check mark
Input Interfacecheck markcheck markcheck mark check markcheck mark
Output Interfacecheck markcheck mark check markcheck markcheck mark
IP Protocol check mark   check mark
Source AScheck mark check mark check mark 
Destination AScheck mark  check markcheck mark 
TOScheck markcheck markcheck markcheck markcheck markcheck mark
First Timestampcheck markcheck markcheck markcheck mark check mark
Last Timestampcheck markcheck markcheck markcheck mark check mark
Number of Flowscheck markcheck markcheck markcheck mark check mark
Number of Packetscheck markcheck markcheck markcheck mark check mark
Number of Bytescheck markcheck markcheck markcheck mark check mark


The Catalyst 6500 and Cisco 7600 platforms also support NetFlow version 8, with all the aggregation schemes described in Table 7-3. NetFlow aggregation is configured automatically on the PFC and Daughter Feature Cards (DFC) when configured on the MSFC. On the PFC, aggregation is implemented in software and therefore consumes additional CPU cycles.

After taking a glance at these comprehensive tables, you probably are wondering which aggregation scheme to choose. The first step is to determine the information elements required by the application, as explained in the section "Data Collection Details: What to Collect" in Chapter 2, "Data Collection Methodology." Next, from the preceding lists you select the best-suited aggregation scheme that maintains the required information elements. Note that the following non-key-fields are present in all aggregation schemes: the timestamps of the first and last packet of the flow, the number of flows summarized by the aggregated flow record, the number of packets in the aggregated flow record, and the number of bytes in the aggregated flow record.

NetFlow Version 9: Flexible and Extensible

NetFlow version 9 is a flexible and extensible export protocol that provides the versatility needed to support new fields and record types. The distinguishing feature of version 9 is the template-based approach. A template describes the record format and field attributes (such as type and length) within the record. In other words, it defines a collection of fields, with corresponding descriptions of the structure and semantics. NetFlow version 9 accommodates NetFlow support for new technologies or features such as multicast, MPLS, and BGP next hop. NetFlow version 9 is required for these and future information elements and can also be used to export information elements that were previously exported by NetFlow version 5. This entails that the main cache flow records can be exported with version 5 or version 9. Similarly, the router-based aggregation flow records can be exported with version 8 or version 9, with the exception of the BGP next-hop ToS aggregation scheme, which requires NetFlow version 9. Indeed, the BGP next hop was the first information element that was supported by only version 9. Nowadays, NetFlow meters multiple new technologies and information elements specified for NetFlow version 9 only. The Cisco command-line interface displays the available export versions. The following example enables both the BGP AS and BGP next-hop ToS aggregation schemes. You can see that the first scheme offers two export protocol versions and the second scheme restricts the usage to NetFlow version 9:

Router(config)# ip flow-aggregation cache as
Router(config-flow-cache)# export version ?
  8  Version 8 export format
  9  Version 9 export format
Router(config)# ip flow-aggregation cache bgp-nexthop-tos
Router(config-flow-cache)# export version ?
  9  Version 9 export format

The section "Data Collection Protocols: NetFlow Version 9 and IPFIX Export Protocols" in Chapter 3, "Accounting and Performance Standards and Definitions," describes the advantages of using templates, the protocol itself, and some examples. For more details, refer to the protocol specifications in the informational RFC 3954, Cisco Systems NetFlow Services Export Version 9. RFC 3954 specifies the list of information elements supported by the protocol. The Cisco website is regularly updated with the new additions at http://www.cisco.com/go/netflow.

NetFlow Version 10: IPFIX

The IETF IPFIX (IP Flow Information eXport) working group has chosen NetFlow version 9 as the basis for a standard IP Flow Export Protocol. After some improvements, the IPFIX protocol specification was born. To make it clear that this new protocol is an evolution of NetFlow version 9, the version number in the IPFIX header is 10.

The IPFIX section in Chapter 3 describes the history and goals of the IETF IPFIX working group; the reasons for selecting NetFlow version 9 as the basis protocol; the IPFIX protocol specification, including the enhancements compared to NetFlow version 9; and the referenced RFCs. Currently the Specification of the IPFIX Protocol for the Exchange of IP Traffic Flow Information draft is in the RFC-editor queue, waiting for publication. A major advantage for current NetFlow users is the fact that the already-specified NetFlow information elements keep their unique IDs with IPFIX. This eases the smooth transition from NetFlow version 9 to the IPFIX protocol.

Note

The IETF PSAMP (packet sampling) working group selected IPFIX as the export protocol. Refer to the section "Data Collection Protocols: PSAMP" in Chapter 3 for more details.


Comparison of Information Elements and NetFlow Version

Tables 7-2 and 7-3 analyzed the content of the flow records for the different router-based aggregation schemes. Table 7-4 compares the most common information elements with the different export protocol versions. The NetFlow metering process is executed in hardware on the Catalyst 6500/Cisco 7600. Therefore, this platform imposes some extra conditions on the classification of some information elements. Note that the latest hardware and/or software version might be required to support these new features! Finally, do not forget to select the right flow mask for the Catalyst 6500/Cisco 7600.

Table 7-4. NetFlow Flow Record Contents
FieldVersion 5Version 5 Catalyst 6500/Cisco 7600[*]Version 9Version 7 Catalyst 6500/Cisco 7600[*]
Source IP addressYesYesYesYes
Destination IP addressYesYesYesYes
Source TCP/UDP application portYesYesYesYes
Destination TCP/UDP application portYesYesYesYes
Next-hop router IP addressYesYes; 12.1(13)E[*****]YesYes[*****]
Input physical interface indexYesYes[****]YesYes[****]
Output physical interface indexYesYes; 12.1(13)EYesYes
Packet count for this flowYesYesYesYes
Byte count for this flowYesYesYesYes
Start of flow timestampYesYesYesYes
End of flow timestampYesYesYesYes
IP Protocol (for example, TCP = 6; UDP = 17)YesYesYesYes
Type of service (ToS) byteYesPFC3B and PFC3BXL only[**]YesPFC3B and PFC3BXL only[**]
TCP flags (cumulative OR of TCP flags)YesNoYesNo
Source AS numberYesYes; 12.1(13)EYesYes; 12.1(13)E
Destination AS numberYesYes; 12.1(13)EYesYes; 12.1(13)E
Source subnet maskYesYesYesYes
Destination subnet maskYesYesYesYes
Flags (indicates, among other things, which flows are invalid)YesYesYesYes
Shortcut router IP address[***]NoNoNoYes
Other flow fields[***]NoNoYesNo


[*] Assumes configuration of the Full-Interface flow mask.

[*****] Always 0 when Policy-Based Routing (PBR), Web Cache Control Protocol (WCCP), or Server Load Balancing (SLB) is configured.

[****] The flow mask Full-Interface or Destination-Source-Interface is required for correct input interface export.

[**] TOS is based on the first packet in the flow.

[***] Refer to NetFlow version 9 for a complete list of other flow information elements available.

From Table 7-4, you can see that a major difference between NetFlow versions 5 and 7 is the shortcut router IP address. This is the IP address of the Layer 3 device that provides the initial Layer 3 connection, which is shortcut by the Catalyst afterwards. This field has historical reasons from the Catalyst 5000, where originally an external router was required for the Layer 3 shortcut. For the Catalyst 6500/Cisco 7600 it contains the IP address of the MSFC.

Supported Interfaces

NetFlow supports IP and IP encapsulated traffic over a wide range of interface types and encapsulations. This includes Frame Relay, Asynchronous Transfer Mode, Interswitch Link, 802.1q, Multilink Point-to-Point Protocol, General Routing Encapsulation, Layer 2 Tunneling Protocol, MPLS VPNs, and IPsec tunnels.

To account for traffic entering a tunnel, configure ingress NetFlow on the router. To account for tunnel and post tunnel flows, enable ingress NetFlow at the tunnel endpoint.

Each interface is identified by a unique value of the ifIndex object, as defined in the SNMP MIBs (RFC 2863). NetFlow is also supported per subinterface and reports the ifIndex value related to the specific subinterface. If NetFlow is configured on the physical interface, all logical subinterfaces are monitored. Alternatively, NetFlow can be enabled per subinterface with the ip flow ingress or ip flow egress CLI command.

Export Protocol: UDP or SCTP

Historically, UDP has been the protocol of choice to export the NetFlow records to minimize the impact on the network elements. However, the simplicity of UDP comes with some drawbacks. As a nonacknowledged transport protocol, UDP faces the risk of losing packets in case of network congestion, because UDP has no retransmission function. Cisco routers and switches offer the option to export simultaneously to two different collectors, which offers increased reliability at the expense of correlating the missing flow records at the collector level.

With the emergence of router-based aggregation, leading to better aggregation and a reduced export rate, plus the definition of Flexible NetFlow, offering an optimal aggregation, losing NetFlow export packets becomes an important issue. To address the higher reliability demands from billing applications, NetFlow offers the option to export flow records over the Stream Control Transport Protocol (SCTP) instead of UDP.

SCTP (RFC 2960), along with its partially reliable extension (PR-SCTP, RFC 3758), is a reliable message-oriented transport layer protocol. It allows data to be transmitted between two endpoints in a fully reliable, partially reliable, or unreliable manner. An SCTP session consists of an association between two endpoints, which may contain one or more logical channels called streams. SCTP's stream-based transmission model facilitates the export of a mix of different data types, such as NetFlow templates and NetFlow data, over the same connection. The maximum number of inbound and outbound streams supported by an endpoint is negotiated during the SCTP association initialization process.

When configuring the NetFlow version 9 export, NetFlow creates a minimum of two streams:

Compared to UDP, stream 0 offers the advantage that the NetFlow version 9 templates are sent only once, with guaranteed delivery.

When more than one cache (main cache and one or more aggregation caches) is exporting data, each cache creates its own streams with their own configured reliability levels. For example, configuring the main cache to use SCTP in full reliability mode and the NetFlow prefix aggregation cache to use partial reliability mode sends messages to the same collector over the same SCTP port.

Note

When using SCTP as the transport protocol for exporting NetFlow traffic, the traffic is usually referred to as messages instead of datagrams because SCTP is a message-oriented protocol. When using UDP as the transport protocol for exporting NetFlow traffic, the traffic is usually referred to as datagrams because UDP is a datagram-oriented protocol.


When SCTP is operating in full reliability mode, it uses a selective acknowledgment scheme to guarantee the ordered delivery of messages. The SCTP protocol stack buffers messages until their receipt is acknowledged by the receiving endpoint, which is the NetFlow collector. SCTP has a congestion control mechanism that can be used to limit how much memory is consumed by SCTP for buffering packets.

If a stream is specified as unreliable, the packet is simply sent once and not buffered on the exporter. If the packet is lost on the way to the receiver, the exporter cannot retransmit it. This mode is equal to UDP transport.

When a stream is specified as partially reliable, a limit is placed on how much memory is dedicated to storing unacknowledged packets. This limit can be configured using the buffer-limit command. If the limit is exceeded and the router attempts to buffer another packet, the oldest unacknowledged packet is discarded, and a message called forward-tsn (transmit sequence number) is sent to the collector to indicate that this packet will not be acknowledged. This mechanism prevents NetFlow from consuming all the free memory on a router in a situation that requires buffering many packets—for example, if SCTP is experiencing long response times from a collector.

Because SCTP is a connection-oriented protocol, a backup collector can be used as a message destination in the event that the primary collector becomes unavailable. When connectivity with the primary collector has been lost, and a backup collector is configured, SCTP uses the backup collector. The default time that SCTP waits until it starts using the backup collector is 25 seconds. You can configure a different value for this interval with the fail-over time command. The router sends periodic SCTP heartbeat messages to the SCTP collectors configured and uses the heartbeat function to monitor the status of each collector. This notifies the NetFlow exporting process quickly if connectivity to a collector is lost.

Two SCTP backup options exist:

Failover mode is the preferred method when the backup collector is on the end of an expensive lower-bandwidth link such as ISDN. During the time that SCTP is using the backup collector, it tries to restore the association with the primary collector. This continues until connectivity is restored or the primary SCTP collector is removed from the configuration.

Under either failover mode, any records that have been queued between losing connectivity with the primary destination and establishing the association with the backup collector might be lost. A counter tracks how many records are lost, which you can view with the show ip flow export sctp verbose command.

To avoid a flapping SCTP association with a collector where the connection goes up and down in quick succession, the period configured with the restore-time command should be greater than the period of a typical connectivity problem. Consider a scenario in which a router is configured to use IP fast convergence for its routing table. Suddenly a LAN interface starts flapping, causing the IP route to the primary collector to be added and removed from the routing table every 2000 msec. In this case, the restore time should have a value greater than 2000 msec.

NetFlow Device-Level Architecture: Combining the Elements

NetFlow services at the device level can be categorized as follows:

Figure 7-7 illustrates these three categories.

Figure 7-7. NetFlow Services Categories


Figure 7-8 assembles all elements at the device level. The first step is the creation and classification of flows in the main cache. The expiration of flows from the main cache is the second step. Step 3 checks if an aggregation scheme is enabled. If this is the case, step 4 is executed, and the flow records are further combined in the aggregation cache. If no aggregation is configured, nonaggregated flow records are exported. Finally, when the flow records are ready for export, step 5 takes place and selects the NetFlow version (5, 8, 9), along with the choice of the transport protocol (UDP or SCTP).

Figure 7-8. NetFlow Device-Level Architecture


Cisco NetFlow Collector

The Cisco NetFlow Collection Engine offers fast and scalable data collection, filtering, and aggregation of exported NetFlow records. Even though the official Cisco documentation uses the name "Cisco CNS NetFlow Collection Engine," the term "Cisco NetFlow Collector" is widely known and used throughout the industry, and it is also used in this book. Note that the Network Analysis Module (NAM) for the Catalyst 6500/Cisco 7600 performs a similar role as the Cisco NetFlow Collector. The NAM receives NetFlow records from the Catalyst 6500/Cisco 7600 device as well as external routers and switches. Records are not stored in NetFlow format; instead, they are converted into standard RMON records and stored in RMON format. This introduces a benefit for customers who already have an RMON application and do not want to deploy a NetFlow Collector.

One part of the NetFlow network element configuration is the IP address that identifies a NetFlow Collector as the recipient of flow records. Additionally, the transport protocol (UDP or SCTP) is selected, along with the port number (a logical port designator) in case of UDP. The NetFlow Collector listens for exported flow records from the network elements and performs the following functions:

The NetFlow Collector aggregates flow records into data files based on user-defined criteria, which are called aggregators. An aggregator defines a set of user-configurable attributes that specify how a NetFlow Collector summarizes the flow records. Two important aggregator functions are the aggregation schemes and the filters. The aggregation schemes define which subset of data in flow records are relevant, and they state which statistics are gathered. The filters define the criteria for accepting or rejecting flow records for aggregation afterwards. For example, an aggregation scheme might impose the aggregation of all flow records based on the same source and/or destination IP addresses, and a filter might exclude all flow records whose destination is the network 10.0.0.0. As a special feature, the Cisco NetFlow Collector offers to augment the flow records with extra information. For example, the BGP passive peer client at the collector can add BGP-related information, which can be used for an aggregator, as either non-key-fields or key-fields. The key-fields and non-key-fields have exactly the same meaning at the NetFlow Collector as they have at the network element. Another example is the DNS name resolution, in which the DNS name replaces the source and destination IP addresses. In an MPLS environment, a NetFlow Collector can match the flow record interface with the Virtual Routing and Forwarding (VRF) by querying MPLS topology-aware applications such as Cisco IP Solution Center (ISC).

Previous Page Next Page