Traffic Mirroring Configuration Guide for Cisco 8000 Series Routers, Cisco IOS XR Release

PDF

Always-On SPAN to file with periodic write

Updated: February 5, 2026

Overview

This section explains the Always-On SPAN to file feature, which provides continuous packet capture for investigating traffic drops. It details functionalities like periodic file writing and storage management, allowing for issue diagnosis without the need to reproduce faults or change configurations.

The Always-On SPAN to file is a traffic mirroring feature that

  • serves as a more reliable tool in investigating unexpected packet drops and traffic blackholing, and

  • allows diagnosis of issues without reproducing faults, changing configurations, or needing prior user interaction before the event.

Always-On SPAN to file functionalities

These are the key functionalities of Always-On SPAN to file:

  • Default SPAN enablement: Enables a default SPAN to-file session for packet forwarding and buffer drops automatically, provided the platform supports it. The session is always active and periodically writes to the disk without stopping the capture, up to the maximum configured storage capacity limit. This functionality ensures continuous packet capture and storage.

    You can disable this session if it’s not needed using the monitor-session default-capture-disable command.

  • SPAN truncation and sampling: Allows for packet truncation and sampling for software-mirrored packets like SPAN to file, even if hardware support isn't available. This functionality enhances flexibility by enabling these operations within the software.

  • Always-on SPAN to file: Automatically starts packet capture when the file destination is configured, without requiring additional action commands. This functionality ensures immediate and continuous packet capture.

    Use the destination file always-on command in monitor-session configuration mode to enable always-on packet capture.

  • SPAN to file continuous capture: Provides the ability to write packet data to a file without stopping the ongoing packet capture. This capability ensures uninterrupted packet monitoring and data collection.

    Use the monitor-session <session name> packet-collection write [directory <dir>] [filename <file>] command to write the current packet buffer to a file without stopping packet collection. If you don't use the optional keywords directory and filename, the system writes the buffer contents to a file named <session_name>_<node location>_<timestamp>.pcap in a default capture directory.

  • SPAN periodic file writing: Allows you to set a period after which the buffered SPAN to file packet data is automatically written to a file. This automatic writing prevents data loss if there is a system reload and ensures persistent storage of captured packets. The feature includes configurable limits to manage file storage effectively, ensuring user-written files remain intact and session-specific data management doesn't impact other sessions.

    Use the destination file [size <kbytes>] [always-on [periodic-write <secs> [capacity [<num> <kB|MB|GB>]]] command in monitor-session configuration mode to set the file writing interval.

    When the periodic-write option is used, the contents of the buffer are written to a file named <session_name>_<node location>_<timestamp>.pcap, in a default capture directory /misc/scratch/SPAN/<node>/.

Storage capacity management and file retention rules

There are two configurable capacity options to manage the periodically written files.

  • A per-session limit: The maximum storage capacity for the set of files captured periodically for an individual monitor session. When this limit is exceeded, the system automatically deletes the oldest files to make room for new ones. Depending on the newer file size, it may delete multiple older files. In cases where only a single file is captured, the file is written completely, even if its size exceeds the per-session capacity limit. The file remains stored until another file is captured for that session.

    When a new file is significantly larger than the previous captures, the system may delete all existing files, leaving only the new file. This ensures that the new file is saved in its entirety without any truncation.

    Use the destination file [capacity <num> <kB|MB|GB>] command to configure the per-session capacity limit.

  • A global limit: The total storage capacity for all files captured by SPAN on disk. If this limit is exceeded, further write operations don’t happen. Stopping the write operation without deleting files protects periodic and user-triggered writes in the default directory that remain unmoved or uncleared, regardless of session.

    Use the monitor-session local-capture-capacity <num> <kB|MB|GB> command to configure the global capacity limit.

    Note

    This capacity limit configuration applies only to files written in the default directory. Any files moved out of the default directory don't count toward this limit.

If you don't configure these capacity parameters, the system uses default values specific to the platform variant to manage storage capacity.


Benefits of Always-On SPAN to file with periodic write

These are some of the benefits of the Always-On SPAN to file feature.
  • Reliable diagnostics: Allows investigation of unexpected packet drops and traffic blackholing without the need to reproduce fault scenarios or change configurations.

  • Continuous packet capture: Ensures uninterrupted packet monitoring and data collection by continuously capturing and storing packets without stopping.

  • Immediate activation: Configuring the file destination automatically starts packet capture, ensuring immediate and continuous monitoring. Activating immediately reduces the risk of missing important data because of user mistakes or delays.

  • Data loss prevention: Periodically writes packet data to a file, preventing data loss if there are system reloads and ensuring persistent storage.

  • Efficient storage management: Provides configurable storage limits for individual sessions and overall capture, managing space effectively without deleting user-written files.

  • User control: Allows you to disable default SPAN sessions and configure storage limits, giving the control over the packet capture and storage settings.


Guidelines for Always-On SPAN to file with periodic write

These guidelines apply to Always-On SPAN to file with periodic write:

  • The platform enables the default SPAN to file session only if it supports it.

  • If you do not specify directory and filename options for the packet-collection write action command, the system saves buffer contents as <session_name>_<node location>_<timestamp>.pcap in the default capture directory /misc/scratch/SPAN/<node>/.

  • Ensure that the user-specified directory already exists before you use it in the packet-collection write action command.

  • The system enforces a per-session storage limit; exceeding it results in the deletion of the oldest captures.

  • The system enforces a global storage limit for all captured files; exceeding this prevents further write operations.

  • The system enforces the global storage limit only on the default capture directory.

  • If you do not configure storage capacity limit parameters, the system uses platform-specific default values.

  • When you change a SPAN-to-File session from always-on to on-demand, you must explicitly stop packet collection or write the packet buffer to enable on-demand operation.


Configure Always-On SPAN to file with periodic write

This section includes configuration for always-on SPAN to file with periodic write and default enablement.

Procedure

1.

(Optional) Disable the default SPAN to file session by using the monitor-session default-capture-disable command. Default SPAN to file session for packet forwarding and buffer drops is enabled automatically.

Example:

Router#configure
Router(config)#monitor-session default-capture-disable
Router(config)#commit
2.

Enable Always-on SPAN to file by using the destination file always-on command in monitor-session configuration mode.

Example:

Router(config)#monitor-session test
Router(config-mon)#destination file always-on
Router(config-mon)#commit
3.

Write the current packet buffer to a file without stopping packet collection by using the monitor-session <session name> packet-collection write [directory <dir>] [filename <file>] action command.

Example:

Router#monitor-session test packet-collection write directory var/xr/scratch/SPAN/test file testfile
4.

Configure an interval for automatically writing buffered packet data to a file by using the destination file [size <kbytes>] [always-on [periodic-write]] command in monitor-session configuration mode.

Example:

Router(config)#monitor-session test
Router(config-mon)#destination file always-on periodic-write 300
Router(config-mon)#commit
5.

Set the storage capacity limit for all monitor-sessions by using the monitor-session local-capture-capacity <num> <kB|MB|GB> command in global configuration mode.

Example:

Router(config)#monitor-session local-capture-capacity 300 MB
Router(config)#monitor-session test
6.

Set the per-session limit by using the destination file [capacity <num> <kB|MB|GB>] command in monitor-session configuration mode, and save the changes.

Example:


Router(config-mon)#destination file always-on periodic-write 300 capacity 100 MB
Router(config-mon)#commit
7.

Verify the running configuration by using the show running-config command.

Example:

monitor-session test ethernet
 destination file always-on periodic-write 300 capacity 100 MB
!
monitor-session local-capture-capacity 300 MB
monitor-session default-capture-disable       
8.

Verify the monitor-session details by using the monitor-session status detail command.

Example:

Router#show monitor-session status detail 
Monitor-session test
  Destination File - Packet collecting (always-on)
  Periodic write interval: 300 seconds
  Maximum periodic capture capacity: 100MB
  Source Interfaces
  -----------------
......
9.

Verify global configuration items and information about platform capabilities by using the show monitor-session status internal command.

Example:

Router#show monitor-session status internal 
Global Configuration:
    Router ID: Default
    Global local-capture-capacity: 300MB
    Default session disabled
Write command supported

Information from SPAN Manager and MA on all nodes:
Monitor-session test (ID 0x00000001) (Ethernet)
SPAN Mgr: Destination File - FileID:0
          Filename/directory name not set
          Last error: Success

Information from SPAN EA on all nodes:
Monitor-session 0x00000001 (Ethernet)
0/RP0/CPU0: Name 'test', destination file FileID:0
            Filename/directory name not set
Platform, 0/RP0/CPU0:

  Monitor Session ID: 1
  Truncation Size: 0
  Buffer type: Circular
  Buffer size: 2000