Home > Articles > NX-OS Troubleshooting Tools

NX-OS Troubleshooting Tools

Chapter Description

In this sample chapter from Troubleshooting Cisco Nexus Switches and NX-OS, you will review the various tools available on the Nexus platform that can help in troubleshooting and day-to-day operation.


NetFlow is a Cisco feature that provides the capability to collect statistics and information on IP traffic as it enters or exits an interface. NetFlow provides operators with network and security monitoring, network planning, traffic analysis, and IP accounting capabilities. Network traffic is often asymmetrical, even on small networks, whereas probes typically require engineered symmetry. NetFlow does not require engineering the network around the instrumentation; it follows the traffic through the network over its natural path. In addition to traffic rate, NetFlow provides QoS markings, TCP flags, and so on for specific applications, services, and traffic flows at each point in the network. NetFlow assists with validating traffic engineering or policy enforcement at any point in the topology.

Cisco NX-OS supports both traditional NetFlow (Version 5) and Flexible NetFlow (Version 9) export formats, but using flexible NetFlow is recommended on Nexus platforms. With traditional NetFlow, all the keys and fields exported are fixed and it supports only IPv4 flows. By default, a flow is defined by seven unique keys:

  • Source IP address

  • Destination IP address

  • Source port

  • Destination port

  • Layer 3 protocol type

  • TOS byte (DSCP markings)

  • Input logical interface (ifindex)

The user can select a few other fields, but NetFlow Version 5 has limitations on the details it can provide. Flexible NetFlow (FNF) is standardized on Version 9 NetFlow and gives users more flexibility on defining flows and the exported fields for each flow type. Flexible NetFlow provides support for IPv6 as well as L2 NetFlow records. The NetFlow version is template based, so users can specify what data has to be exported.

The FNF design gives the following levels benefits:

  • Flexibility to choose the definition of a flow (the key and nonkey fields)

  • Flexibility to selectively apply different flow definitions to different interfaces

  • Flexibility to choose the exporter interface

  • Extensibility to future improvements, such as IPFIX

Network operators and architects often wonder where to attach the NetFlow monitor. For such challenges, answering the following questions can assist:

  • What type of information are users looking for? MAC fields or IPv4/v6 fields?

  • What kind of interfaces are present on the box? L3 or L2 interfaces?

  • Is the box switching packets within VLANs or routing them across VLANs using Switched Virtual Interfaces (SVI)?

NetFlow Configuration

These questions help users make the right choice of applying a Layer 3 or Layer 2 NetFlow configuration. Configuring NetFlow on a Nexus switch consists of following steps:

  • Step 1. Enable the NetFlow feature.

  • Step 2. Define a flow record by specifying key and nonkey fields of interest.

  • Step 3. Define one or many flow exporters by specifying export format, protocol, destination, and other parameters.

  • Step 4. Define a flow monitor based on the previous flow record and flow exporter(s).

  • Step 5. Apply the flow monitor to an interface with a sampling method specified.

Enable NetFlow Feature

On NX-OS, the NetFlow feature is enabled using the command feature netflow. When the feature is enabled, the entire NetFlow-related CLI becomes available to the user.

Define a Flow Record

A flow record is defined by specifying the different match keys and parameters NetFlow uses to identify the packets. A flow record is created using the command flow record name. NX-OS enables the following match fields by default when a flow record is created:

  • Match interface input

  • Match interface output

  • Match flow direction

A flow record also specifies the fields of interest that has to be collected for a flow. The following match keys are supported for identifying flows in NetFlow:

  • IPv4 source/destination address

  • IPv6 source/destination address

  • IPv6 flow label

  • IPv6 options

  • ToS field

  • L4 protocol

  • L4 source/destination ports

The following match key is provided for Layer 2 NetFlow:

  • Source/destination MAC address

  • Ethertype

  • VLAN

A user has the flexibility to select the collect parameters that can be used in either Version 5 or Version 9, except for IPv6 parameters, which can be used only with Version 9. The following parameters are collected using NetFlow:

  • Number of L3 bytes (32 bit or 64 bit)

  • Number of packets (32 bit or 64 bit)

  • Direction of the flow

  • Sampler ID used for the flow

  • Interface info (input and/or output)

  • Source/destination AS number of the local device or the peer

  • Next-hop IPv4/IPv6 address

  • System uptime for the first or last packet

  • TCP flags

Example 2-12 shows the configuration for a flow record for both Layer 3 and Layer 2 traffic. In this flow record, multiple match entries are created, along parameters to be used for collection.

Example 2-12 NetFlow Flow Record

! Flow Record for Layer 3 Traffic
flow record FR_V4
  match ipv4 source address
  match ipv4 destination address
  match ip protocol
  match ip tos
  collect timestamp sys-uptime last
  collect flow sampler id
  collect ip version
! Flow record for Layer 2 Traffic
flow record FR_L2
  match datalink mac source-address
  match datalink mac destination-address
  match datalink vlan
  match datalink ethertype
  collect counter packets
  collect flow sampler id

Define a Flow Exporter

The next step is to define a flow exporter. NetFlow data is exported to a remote collector using UDP frames. The data is exported periodically upon expiration of a flow timeout that is configurable by the user. The default flow timeout value is 30 minutes. Under the flow export, the following fields are defined:

  • Collector IPv4/IPv6 address

  • Source interface

  • Virtual Routing and Forwarding (VRF)

  • Version

  • UDP port number

Example 2-13 demonstrates the configuration of the flow exporter.

Example 2-13 NetFlow Flow Exporter

flow exporter FL_Exp
  destination use-vrf management
  transport udp 3000
  source mgmt0
  version 9

Define and Apply the Flow Monitor

After the flow exporter is defined, it is time to bind the flow record and the flow exporter to a flow monitor. When the flow monitor is defined, the flow monitor can be attached to an interface for collecting NetFlow statistics. Example 2-14 displays the configuration of the flow monitor and illustrates enabling NetFlow under the interface. To apply NetFlow for IPv4/IPv6/Layer 2 traffic, use the command [ip | ipv6 | layer2-switched] flow monitor name [input | output].

Example 2-14 NetFlow Flow Monitor and Interface Configuration

flow monitor FL_MON
  record FR_V4
  exporter FL_Exp
interface Eth3/31-32
ip flow monitor FL_MON input
ip flow monitor FL_MON output

The NetFlow configuration is viewed using the command show run netflow. To validate the NetFlow configuration, use the command show flow [record record-name | exporter exporter-name | monitor monitor-name].

To view the statistics of the flow ingressing and egressing the interface E1/4 as configured in the previous example, use the command show hardware flow [ip | ipv6] [detail]. Example 2-15 displays the statistics of the ingress and egress traffic flowing across the interfaces Eth3/31-32. This example shows both ingress (I) and egress (O) traffic. NetFlow displays the statistics for OSPF and other ICMP traffic, along with the protocol number and packet count.

Example 2-15 NetFlow Statistics

N7k-1# show hardware flow ip
slot  3
D - Direction; L4 Info - Protocol:Source Port:Destination Port
IF - Interface: ()ethernet, (S)vi, (V)lan, (P)ortchannel, (T)unnel
TCP Flags: Ack, Flush, Push, Reset, Syn, Urgent
D IF         SrcAddr         DstAddr         L4 Info         PktCnt     TCPFlags  
I 3/31 089:00000:00000 0000000159 ......
I 3/32 089:00000:00000 0000000128 ......
I 3/32 001:00000:00000 0000000100 ......
I 3/31 001:00000:00000 0000000100 ......
O 3/31 001:00000:00000 0000000100 ......
O 3/32 001:00000:00000 0000000100 ......

The statistics in Example 2-15 are collected on the N7k platform, which supports hardware-based flows. However, not all Nexus platforms have support for hardware-based flow matching. Nexus switches such as Nexus 6000 do not support hardware-based flow matching. Thus, a software-based flow matching must be performed. This can be resource consuming and can impact performance, however, so such platforms support only Sampled NetFlow (see the following section).

NetFlow Sampling

NetFlow supports sampling on the data points to reduce the amount of data collected. This implementation of NetFlow is called Sampled NetFlow (SNF). SNF supports M:N packet sampling, where only M packets are sampled out of N packets.

A sampler is configured using the command sampler name. Under the sampler configuration, sampler mode is defined using the command mode sample-number out-of packet-number, where sample-number ranges from 1 to 64 and the packet-number ranges from 1 to 65536 packets). This is defined using the sampler subcommand mode sampler-number out-of packet-number. After the sampler is defined, it is used in conjunction with the flow monitor configuration under the interface in Example 2-16.

Example 2-16 NetFlow Sampler and Interface Configuration

sampler NF-SAMPLER1
 mode 1 out-of 1000
interface Eth3/31-32
ip flow monitor FL_MON input sampler NF-SAMPLER1

Users can also define the active and inactive timer for the flows using the command flow timeout [active | inactive] time-in-seconds.

Starting with NX-OS Version 7.3(0)D1(1), NetFlow is also supported on the control plane policing (CoPP) interface. NetFlow on the CoPP interface enables users to monitor and collect statistics of different packets that are destined for the supervisor module on the switch. NX-OS allows an IPv4 flow monitor and a sampler to be attached to the control plane interface in the output direction. Example 2-17 demonstrates the NetFlow configuration under CoPP interface and the relevant NetFlow statistics on the Nexus 7000 platform.

Example 2-17 CoPP NetFlow Configuration and Verification

ip flow monitor FL_MON output sampler NF-SAMPLER1


Defined in RFC 3176, sFlow is a technology for monitoring traffic using sampling mechanisms that are implemented as part of an sFlow agent in data networks that contain switches and routers. The sFlow agent is a new software feature for the Nexus 9000 and Nexus 3000 platforms. The sFlow agent on these platforms collects the sampled packet from both ingress and egress ports and forwards it to the central collector, known as the sFlow Analyzer. The sFlow agent can periodically sample or poll the counters associated with a data source of the sampled packets.

When sFlow is enabled on an interface, it is enabled for both ingress and egress directions. sFlow can be configured only for Ethernet and port-channel interfaces. sFlow is enabled by configuring the command feature sflow. Various parameters can be defined as part of the configuration (see Table 2-2).

Table 2-2 sFlow Parameters

sFlow Parameter Configuration


sflow sampling rate rate

The sampling rate for packets. The default is 4096. A value of 0 implies that sampling is disabled.

sflow max-sampled-size sampling-size

The maximum sampling size for packets. The default is 128 bytes. The value ranges from 64 to 256 bytes.

sflow counter-poll-interval poll-interval

The polling interval for an interface. The default is 20 seconds.

sflow max-datagram-size size

The maximum datagram size. The default is 1400 bytes.

sflow collector-ip ip-address vrf vrf-context

The sFlow collector/analyzer IP address.

sflow collector-port port-number

The UDP port number of the sFlow analyzer.

sflow agent-ip ip-address

The address of the sFlow agent. This is the local and valid IP address on the switch.

sflow data-source interface interface-type interface-num

The sFlow sampling data source.

Example 2-18 illustrates the configuration of sFlow on a Nexus 3000 switch. The running configuration of sFlow is viewed using the command show run sflow.

Example 2-18 sFlow Configuration

feature sflow
sflow sampling-rate 1000
sflow max-sampled-size 200
sflow counter-poll-interval 100
sflow max-datagram-size 2000
sflow collector-ip vrf management
sflow collector-port 2020
sflow agent-ip
sflow data-source interface ethernet 1/1-2

To verify the configuration, use the command show sflow. This command output displays all the information that is configured for the sFlow (see Example 2-19).

Example 2-19 show sflow Command Output

N3K-1# show sflow
sflow sampling-rate : 1000
sflow max-sampled-size : 200
sflow counter-poll-interval : 100
sflow max-datagram-size : 2000
sflow collector-ip : , vrf : management
sflow collector-port : 2020
sflow agent-ip :
sflow data-source interface Ethernet1/1
sflow data-source interface Ethernet1/2

When sFlow is configured, the sFlow agent starts collecting the statistics. Although the actual flow is viewed on the sFlow collector tools, you can still see the sFlow statistics on the switch using the command show sflow statistics and also view both internal information about the sFlow and statistics using the command show system internal sflow info. Example 2-20 displays the statistics for the sFlow. Notice that although the total packet count is high, the number of sampled packets is very low. This is because the configuration defines sampling taken per 1000 packets. The system internal command for sFlow also displays the resource utilization and its present state.

Example 2-20 sFlow Statistics and Internal Info

N3K-1# show sflow statistics
Total Packets        : 1053973
Total Samples        : 11
Processed Samples    : 11
Dropped Samples      : 0
Sent Datagrams       : 56
Dropped Datagrams    : 13
N3K-1# show system internal sflow info
sflow probe state -> RUN
sflow inband sflow is valid
sflow inband driver -> UP
sflow IPv4 socket fd 47
number of sflow sampled packets : 11
number of sflow dropped packets : 0
number of sflow datagram sent : 56
number of sflow datagram dropped : 13
sflow process cpu usage 0.86
sflow process cpu limit 50
4. Network Time Protocol | Next Section Previous Section

There are currently no related articles. Please check back later.