Table Of Contents
Using NetFlow Sampling to Select the Network Traffic to Track
First Published: June 19, 2006Last Updated: July 31, 2009
This module contains information about and instructions for selecting the network traffic to track through the use of NetFlow sampling. The Random Sampled NetFlow feature, described in this module, allows you to collect data from specific subsets of traffic. The Random Sampled NetFlow feature provides NetFlow data for a subset of traffic in a Cisco router by processing only one randomly selected packet out of n sequential packets (n is a user-configurable parameter).
NetFlow is a Cisco IOS XE application that provides statistics on packets flowing through the router. It is emerging as a primary network accounting and security technology.
Finding Feature Information
For the latest feature information and caveats, see the release notes for your platform and software release. To find information about the features documented in this module, and to see a list of the releases in which each feature is supported, see the "Feature Information for Using NetFlow Sampling to Select Network Traffic to Track" section.
Use Cisco Feature Navigator to find information about platform support and Cisco IOS XE software image support. To access Cisco Feature Navigator, go to http://www.cisco.com/go/cfn. An account on Cisco.com is not required.
Prerequisites for Using NetFlow Sampling to Select Network Traffic to Track
Before you can configure the Random Sampled NetFlow feature, you must:
•Configure the router for IP routing
•Configure Cisco Express Forwarding on your router and on the interfaces on which you want to configure Random Sampled NetFlow. Fast switching is not supported.
•Configure NetFlow Version 5 or Version 9 data export if you want to export NetFlow data (otherwise, NetFlow data is visible in the cache, but is not exported)
•Configure NetFlow Version 9 if you want to use sampler option templates or view NetFlow sampler IDs
Restrictions for Using NetFlow Sampling to Select Network Traffic to Track
If full NetFlow is enabled on an interface, it takes precedence over Random Sampled NetFlow (which will thus have no effect). This means that you should disable full NetFlow on an interface before enabling Random Sampled NetFlow on that interface.
Enabling Random Sampled NetFlow on a physical interface does not automatically enable Random Sampled NetFlow on subinterfaces; you must explicitly configure it on subinterfaces. Also, disabling Random Sampled NetFlow on a physical interface (or a subinterface) does not enable full NetFlow. This restriction prevents the transition to full NetFlow from overwhelming the physical interface (or subinterface). If you want full NetFlow, you must explicitly enable it.
If you enable Random Sampled NetFlow with Version 5 data export, sampler option templates are not exported. Use NetFlow Version 9 if you want to use sampler option templates.
Information About Using NetFlow Sampling to Select Network Traffic to Track
Before configuring NetFlow sampling, you should understand the following:
Sampling of NetFlow Traffic
NetFlow provides highly granular per-flow traffic statistics in a Cisco router. A flow is a unidirectional stream of packets that arrive at the router on the same subinterface, have the same source and destination IP addresses, Layer 4 protocol, TCP/UDP source and destination ports, and the same ToS (type of service) byte in the IP headers. The router accumulates NetFlow statistics in a NetFlow cache and can export them to an external device (such as the Cisco Networking Services (CNS) NetFlow Collection Engine) for further processing.
Full NetFlow accounts for all traffic entering the subinterface on which it is enabled. But in some cases, you might gather NetFlow data on only a subset of this traffic. The Random Sampled NetFlow feature provides a way to limit incoming traffic to only traffic of interest for NetFlow processing. Random Sampled NetFlow provides NetFlow data for a subset of traffic in a Cisco router by processing only one randomly selected packet out of n sequential packets.
Note Random Sampled NetFlow is more statistically accurate than Sampled NetFlow. NetFlow's ability to sample packets was first provided by a feature named Sampled NetFlow. The methodology that the Sampled NetFlow feature uses is deterministic sampling, which selects every nth packet for NetFlow processing on a per-interface basis. For example, if you set the sampling rate to 1 out of 100 packets, then Sampled NetFlow samples the 1st, 101st, 201st, 301st, and so on packets. Sampled NetFlow does not allow random sampling and thus can make statistics inaccurate when traffic arrives in fixed patterns.
Random Sampled NetFlow: Sampling Mode
Sampling mode makes use of an algorithm that selects a subset of traffic for NetFlow processing. In the random sampling mode that the Random Sampled NetFlow feature uses, incoming packets are randomly selected so that one out of each n sequential packets is selected on average for NetFlow processing. For example, if you set the sampling rate to 1 out of 100 packets, then NetFlow might sample the 5th packet and then the 120th, 199th, 302nd, and so on. This sample configuration provides NetFlow data on 1 percent of total traffic. The n value is a parameter from 1 to 65535 packets that you can configure.
Random Sampled NetFlow: The NetFlow Sampler
A NetFlow sampler map defines a set of properties (such as the sampling rate and NetFlow sampler name) for NetFlow sampling. Each NetFlow sampler map can be applied to one or many subinterfaces as well as physical interfaces. You can define up to eight NetFlow sampler maps.
For example, you can create a NetFlow sampler map named mysampler1 with the following properties: random sampling mode and a sampling rate of 1 out of 100 packets. This NetFlow sampler map can be applied to any number of subinterfaces, each of which would refer to mysampler1 to perform NetFlow sampling. Traffic from these subinterfaces is merged (from a sampling point of view). This introduces even more "randomness" than random per-subinterface NetFlow sampling does, but statistically it provides the same sampling rate of 1 out of 100 packets for each participating subinterface.
The sampling in random sampled NetFlow is done by NetFlow samplers. A NetFlow sampler is defined as an instance of a NetFlow sampler map that has been applied to a physical interface or subinterface. If full NetFlow is configured on a physical interface, it overrides random sampled NetFlow on all subinterfaces of this physical interface.
How to Configure NetFlow Sampling
This section contains the procedure required for configuring NetFlow sampling:
Configuring Random Sampled NetFlow to Reduce the Impact of NetFlow Data Export
To configure and verify the configuration for the Random Sampled NetFlow feature, perform the following tasks:
•Defining a NetFlow Sampler Map (Required)
•Applying a NetFlow Sampler Map to an Interface (Required)
Defining a NetFlow Sampler Map
To define a NetFlow sampler map, perform the following steps.
2. configure terminal
3. flow-sampler-map sampler-map-name
4. mode random one-out-of sampling-rate
Applying a NetFlow Sampler Map to an Interface
To apply a NetFlow sampler map to an interface, perform the following steps.
You can apply a NetFlow sampler map to a physical interface (or a subinterface) to create a NetFlow sampler.
2. configure terminal
3. interface interface-type interface-number
4. flow-sampler sampler-map-name
Verifying the Configuration of Random Sampled NetFlow
To verify the configuration of random sampled NetFlow, perform the following steps.
2. show flow-sampler
3. show ip cache verbose flow
4. show ip flow export template
Step 1 enable
Use this command to enable privileged EXEC mode. Enter your password if prompted.Router> enable
Step 2 show flow-sampler
Use this command to display attributes (including mode, sampling rate, and number of sampled packets) of one or all Random Sampled NetFlow samplers to verify the sampler configuration. For example:Router# show flow-samplerSampler : mysampler1, id : 1, packets matched : 10, mode : random sampling modesampling interval is : 100Sampler : myflowsampler2, id : 2, packets matched : 5, mode : random sampling modesampling interval is : 200
To verify attributes for a particular NetFlow sampler, use the show flow-sampler sampler-map-name command. For example, enter the following for a NetFlow sampler named mysampler1:Router# show flow-sampler mysampler1Sampler : mysampler1, id : 1, packets matched : 0, mode : random sampling modesampling interval is : 100
Step 3 show ip cache verbose flow
Use this command to display additional NetFlow fields in the header when Random Sampled NetFlow is configured. For example:Router# show ip cache verbose flow...SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs PktsPort Msk AS Port Msk AS NextHop B/Pk ActiveBGP: BGP NextHopFet1/0/0 126.96.36.199 FEt0/0/0* 188.8.131.52 01 00 10 30000 /8 302 0800 /8 300 184.108.40.206 100 0.1BGP: 220.127.116.11 Sampler: 1 Class: 1 FFlags: 01
This example shows the NetFlow output of the show ip cache verbose flow command in which the sampler, class-id, and general flags are set. What is displayed for a flow depends on what flags are set in the flow. If the flow was captured by a sampler, the output shows the sampler ID. If the flow was marked by MQC, the display includes the class ID. If any general flags are set, the output includes the flags.
NetFlow flags (FFlags) that might appear in the show ip cache verbose flow command output are:
•FFlags: 01 (#define FLOW_FLAGS_OUTPUT 0x0001)—Egress flow
•FFlags: 02 (#define FLOW_FLAGS_DROP 0x0002)—Dropped flow (for example, dropped by an ACL)
•FFlags: 08 (#define FLOW_FLAGS_IPV6 0x0008)—IPv6 flow
•FFlags: 10 (#define FLOW_FLAGS_RSVD 0x0010)—Reserved
IPv6 and RSVD FFlags are seldom used. If FFlags is zero, the line is omitted from the output. If multiple flags are defined (logical ORed together), then both sets of flags are displayed in hexadecimal format.
Step 4 show ip flow export template
Use this command to display the statistics for the NetFlow data export (such as template timeout and refresh rate) for the template-specific configurations. For example:Router# show ip flow export templateTemplate Options Flag = 0Total number of Templates added = 0Total active Templates = 0Flow Templates active = 0Flow Templates added = 0Option Templates active = 0Option Templates added = 0Template ager polls = 0Option Template ager polls = 0Main cache version 9 export is enabledTemplate export informationTemplate timeout = 30Template refresh rate = 20Option export informationOption timeout = 30Option refresh rate = 20
Step 5 end
Use this command to exit privileged EXEC mode.Router# end
Use the debug flow-sampler command to display debugging output for Random Sampled NetFlow.
Configuration Examples for Configuring NetFlow Sampling
This section contains the following example for configuring NetFlow sampling:
Configuring Random Sampled NetFlow to Reduce the Impact of NetFlow Data Export: Examples
This section contains the following configuration examples:
Defining a NetFlow Sampler Map: Example
The following example shows how to define a NetFlow sampler map named mysampler1:configure terminal!flow-sampler-map mysampler1mode random one-out-of 100end
Applying a NetFlow Sampler Map to an Interface: Example
The following example shows how to enable Cisco Express Forwarding switching and apply a NetFlow sampler map named mysampler1 to Fastethernet interface 1/0/0 to create a NetFlow sampler on that interface:configure terminal!ip cef!interface fastethernet 1/0/0flow-sampler mysampler1end
The following sections provide references related to configuring NetFlow sampling.
No new or modified standards are supported by this feature, and support for existing standards has not been modified by this feature.
No new or modified RFCs are supported by this feature, and support for existing RFCs has not been modified by this feature.
Feature Information for Using NetFlow Sampling to Select Network Traffic to Track
Table 1 lists the features in this module and provides links to specific configuration information.
Use Cisco Feature Navigator to find information about platform support and software image support. Cisco Feature Navigator enables you to determine which Cisco IOS XE software images support a specific software release, feature set, or platform. To access Cisco Feature Navigator, go to http://www.cisco.com/go/cfn. An account on Cisco.com is not required.
Note Table 1 lists only the Cisco IOS XE software release that introduced support for a given feature in a given Cisco IOS XE software release train. Unless noted otherwise, subsequent releases of that Cisco IOS XE software release train also support that feature.
ACL—Access control list. A roster of users and groups of users kept by a router. The list is used to control access to or from the router for a number of services.
BGP—Border Gateway Protocol. Interdomain routing protocol that replaces Exterior Gateway Protocol (EGP). A BGP system exchanges reachability information with other BGP systems. BGP is defined by RFC 1163.
CEF—Cisco Express Forwarding. Layer 3 IP switching technology that optimizes network performance and scalability for networks with large and dynamic traffic patterns.
fast switching—Cisco feature in which a route cache is used to expedite packet switching through a router.
flow—Unidirectional stream of packets between a given source and destination. Source and destination are each defined by a network-layer IP address and transport-layer source and destination port numbers.
MQC—Modular Quality of Service (QoS) Command-line Interface (CLI). A CLI structure that lets you create traffic polices and attach them to interfaces. A traffic policy contains a traffic class and one or more QoS features. The QoS features in the traffic policy determine how the classified traffic is treated.
NBAR—Network-Based Application Recognition. A classification engine in Cisco IOS software that recognizes a wide variety of applications, including web-based applications and client/server applications that dynamically assign Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) port numbers. After the application is recognized, the network can invoke specific services for that application. NBAR is a key part of the Cisco Content Networking architecture and works with QoS features to let you use network bandwidth efficiently.
NetFlow—Cisco IOS XE security and accounting feature that maintains per-flow information.
NetFlow sampler—A set of properties that are defined in a NetFlow sampler map that has been applied to at least one physical interface or subinterface.
NetFlow sampler map—The definition of a set of properties (such as the sampling rate) for NetFlow sampling.
NetFlow v9—NetFlow export format Version 9. A flexible and extensible means for carrying NetFlow records from a network node to a collector. NetFlow Version 9 has definable record types and is self-describing for easier NetFlow Collection Engine configuration.
ToS—type of service. Second byte in the IP header that indicates the desired quality of service for a specific datagram.
Cisco and the Cisco Logo are trademarks of Cisco Systems, Inc. and/or its affiliates in the U.S. and other countries. A listing of Cisco's trademarks can be found at www.cisco.com/go/trademarks. Third party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1005R)
Any Internet Protocol (IP) addresses used in this document are not intended to be actual addresses. Any examples, command display output, and figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses in illustrative content is unintentional and coincidental.
© 2006-2009 Cisco Systems, Inc. All rights reserved.