Lesson Overview

Network monitoring and traffic analysis are essential for maintaining network performance, security, and reliability. Cisco provides several technologies, including Flexible NetFlow, SPAN, RSPAN, and ERSPAN, to help network engineers monitor traffic, identify performance bottlenecks, investigate security incidents, and troubleshoot connectivity problems.


This lesson explains how these technologies work, their differences, practical applications, Cisco IOS/IOS XE configuration examples, verification commands, and troubleshooting techniques.


Learning Objectives

By the end of this lesson, learners will be able to:

  1. Understand the purpose of network traffic monitoring.

  2. Explain Flexible NetFlow architecture and components.

  3. Configure flow records, exporters, and monitors.

  4. Understand SPAN, RSPAN, and ERSPAN operation.

  5. Configure local and remote traffic mirroring on supported Cisco devices.

  6. Analyze mirrored packets using Wireshark.

  7. Verify monitoring configurations using Cisco commands.

  8. Troubleshoot common traffic monitoring issues.

  9. Select the appropriate monitoring technology for different network scenarios.

1. Introduction to Network Traffic Monitoring

Enterprise networks carry large amounts of traffic between users, applications, servers, and cloud services.

Network engineers need visibility into this traffic to identify abnormal behavior, monitor bandwidth utilization, troubleshoot application performance, and investigate security events.

Two important monitoring approaches are:

  • Flow-based monitoring: Collects summarized information about network conversations.

  • Packet-based monitoring: Copies network packets for detailed analysis.

Flexible NetFlow is primarily used for flow-based monitoring, while SPAN, RSPAN, and ERSPAN are packet-mirroring technologies.


2. Understanding Flexible NetFlow

Flexible NetFlow (FNF) is a Cisco traffic monitoring technology that allows network administrators to define which packet fields should be used to identify and measure traffic flows.

It extends traditional NetFlow by supporting customizable flow records.

A network flow is a collection of packets that share specified characteristics, such as source IP address, destination IP address, protocol, and transport ports.


How Flexible NetFlow Works

  1. Network traffic enters or leaves a monitored interface.

  2. The router or switch examines packet headers.

  3. Packets are classified into flows using configured key fields.

  4. Traffic statistics are collected for each flow.

  5. Flow information is stored in a local cache.

  6. Flow data can be exported to an external collector for analysis.

2.1 Why Flexible NetFlow Matters

A flow is a unidirectional conversation identified by a set of key fields. Typical keys include source/destination IP address, protocol, and transport ports. Flexible NetFlow summarizes many packets into one cache entry, which is far more scalable for visibility than packet-by-packet capture when the objective is traffic accounting, capacity planning, application visibility, or anomaly investigation.

Use Case

What NetFlow Helps Answer

Top talkers

Which sources and destinations are consuming the most bandwidth?

Application visibility

Which TCP/UDP ports and protocols are active?

Capacity planning

Which interfaces, links, and traffic directions carry the most bytes/packets?

Troubleshooting

Was traffic seen, in which direction, and with which source/destination/port tuple?

Security analytics

Are there unusual connection patterns, scanning behavior, or unexpected destinations?

Important: Flexible NetFlow is telemetry, not a packet capture. It records metadata and counters about flows; it does not normally preserve the application payload.


3. Flexible NetFlow Architecture

Pasted content image


The most useful way to learn Flexible NetFlow is to follow the data path. Packets arrive on a monitored interface. The flow monitor uses the referenced flow record to decide which fields make a flow unique and which values to collect. The monitor stores active entries in its cache. When a flow ages out or an active timeout is reached, the exporter formats the records and sends them to the collector.


3.1 Components of Flexible NetFlow

Flexible NetFlow consists of three major configuration components.


1. Flow Record

A flow record is the schema for a flow. It defines the fields that identify a flow and the extra information stored with that flow. The two command families are match and collect.


1.1 match Fields - Flow Keys

A match field is part of the flow key. If any key value changes, Flexible NetFlow creates a different flow entry. More match fields provide more detail but can increase the number of cache entries and exported records.


match ipv4 source address - identifies the source IPv4 address.

match ipv4 destination address - identifies the destination IPv4 address.

match ip protocol - separates TCP, UDP, ICMP, and other IP protocols.

match transport source-port - separates client/source transport ports.

match transport destination-port - separates destination/service ports.


1.2 collect Fields - Measured Data

A collect field does not normally create a new flow by itself. It adds measured or descriptive data to the existing flow entry, such as bytes, packets, timestamps, or output-interface information.


collect counter bytes long - total bytes associated with the flow.

collect counter packets long - packet count for the flow.

collect timestamp sys-uptime first - when the first packet was observed, relative to device uptime.

collect timestamp sys-uptime last - when the most recent packet was observed.


Example - Custom IPv4 Flow Record

flow record FNF-RECORD

 description IPv4 5-tuple with counters and timestamps

 match ipv4 source address

 match ipv4 destination address

 match ip protocol

 match transport source-port

 match transport destination-port

 collect counter bytes long

 collect counter packets long

 collect timestamp sys-uptime first

 collect timestamp sys-uptime last

Note: The exact fields supported by a record can vary by hardware, software release, and forwarding architecture. Use context-sensitive help (?) on the target platform.

2. Flow Monitors

The flow monitor is the operational object that maintains the flow cache. It references a flow record and, when export is required, one or more exporters. The monitor is the object attached to interfaces.


Example - Flow Monitor

flow monitor FNF-MONITOR

 description Enterprise IPv4 monitoring

 record FNF-RECORD

 exporter FNF-EXPORTER

 cache timeout active 60

 cache timeout inactive 15

Note: Active timeout exports a long-running flow periodically. Inactive timeout ages a flow after traffic stops. Timer defaults and supported values can differ by platform.

2.1 Active and Inactive Timeouts

Timer

Purpose

Training Interpretation

Active timeout

Periodically expires/exports a still-active flow

A long TCP session can be reported in multiple intervals instead of waiting for it to end.

Inactive timeout

Expires a flow after no packets are seen for a period

Short conversations are removed quickly after they stop, freeing cache space.

2.2 The Flow Cache

The cache is where the monitor stores current flow entries. A flow appears in the cache only after traffic matching the applied interface/direction is observed. For troubleshooting, this makes the local cache the first proof point: if the cache is empty, collector troubleshooting is premature.

Troubleshooting rule: Verify local cache population first. Only after flows exist locally should you troubleshoot export packets, routing to the collector, firewalls, UDP ports, or the collector application.

3. Flow Exporters

The exporter defines how the device sends aged flow records to an external collector. The exporter does not create flows by itself; it transports flow data produced by a monitor.


Example - NetFlow v9 Exporter

interface Loopback0

 ip address 1.1.1.1 255.255.255.255

!

flow exporter FNF-EXPORTER

 description Export to NetFlow Collector

 destination 192.168.50.10

 source Loopback0

 transport udp 2055

 export-protocol netflow-v9

 template data timeout 60

UDP 2055 is common in labs, but the collector and network policy must agree on the chosen destination port. NetFlow v9 uses templates so the collector can decode the exported field layout.


Flexible NetFlow Exporter – Key Parameters Explained

destination – NetFlow Collector Address

Purpose: Specifies the IP address of the server that receives exported flow records.

Why it matters: The router must have a valid route to the collector for successful flow export.


source – Export Source Interface

Purpose: Defines the source interface whose IP address is used for NetFlow export packets.

Why it matters: Using a loopback interface provides a consistent source IP address, as long as the collector can reach it.


transport udp – Collector UDP Port

Purpose: Specifies the destination UDP port used to export flow records.

Why it matters: The NetFlow collector must listen on the same port, and firewalls or ACLs must allow the traffic.


export-protocol – Flow Export Format

Purpose: Determines the format used to export flow records, such as NetFlow v9 or IPFIX, depending on platform support.

Why it matters: The collector must support the selected protocol to interpret the exported data.


template data…