sflowsFlow Version 5 Switched & Routed Packet Sampling1-in-N Switch Packet Sampling (tor_sw -> collector sflow UDP 6343)
What It Does on the Wire
Hardware ASICs love sFlow v5 on UDP 6343 because sampling 1-in-4096 frames takes zero stateful flow memory. sflow encodes both IPv4 (1) and IPv6 (2) XDR agent headers cleanly.
sFlow v5 (sflow) is the wire-speed packet sampling telemetry protocol built into Arista, Juniper, Cisco Nexus, HPE/Aruba, and SONiC data-center switches on UDP port 6343. Instead of maintaining stateful flow caches on the switch ASIC, sFlow exports XDR-encoded packet header samples directly to collectors such as sFlow-RT, pmacct, Akvorado, and FastNetMon.
FrameAssembly constructs a valid XDR-aligned sFlow v5 datagram containing the Agent IP (agentip, automatically tagged as IPv4 type 1 or IPv6 type 2), subagentid, datagram seq, switch uptime, and sampled Ethernet frame header records.
Test DDoS Scrubbing Triggers (FastNetMon / sFlow-RT)
Send sflow datagrams with incrementing seq numbers to UDP 6343 to verify DDoS mitigation pipelines and BGP FlowSpec automation.
Leaf-Spine Telemetry Firewall & VRF Reachability
Confirm out-of-band management firewalls pass UDP 6343 from every switch agentip to central telemetry collectors.
Dual-Stack IPv6 Switch Agent Testing
Set an IPv6 agentip to verify collectors decode XDR Address Type 2 (128-bit IPv6 agent addresses) accurately.
Minimal Quickstart (sflow_quickstart.frasm)
Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.
host tor_sw01 { ip 10.40.0.11 }host sflow_col { ip 10.40.0.200 }compile { tor_sw01 -> sflow_col sflow agentip 10.40.0.11 subagentid 1 seq 1 uptime 360000 samples 1}What the Compiler Calculates So You Don't Have To
- Defaults UDP destination port to
6343and aligns all fields to 4-byte XDR boundaries per the sFlow v5 specification. - Sets Agent Address Type to
1(4-byte IPv4) or2(16-byte IPv6) automatically fromagentip. - Includes an Enterprise
0, Format1Flow Sample containing a sampled Raw Packet Header record so Wireshark dissects the full sFlow tree.
Multi-Switch Leaf-Spine sFlow v5 Telemetry Stream
Simulates two leaf switches exporting sequential sFlow v5 datagrams (including an IPv6 loopback agent IP) to a central collector.
host leaf_01 { ip 172.18.1.11 }host leaf_02 { ip 172.18.1.12 }host collector { ip 172.18.100.50 }compile { leaf_01 -> collector sflow agentip 172.18.1.11 subagentid 0 seq 101 uptime 450000 samples 1 wait 2ms leaf_01 -> collector sflow agentip 172.18.1.11 subagentid 0 seq 102 uptime 451000 samples 1 wait 2ms leaf_02 -> collector sflow agentip 2001:db8:18::12 subagentid 1 seq 55 uptime 820000 samples 1}# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show sflow_leaf_spine.frasm
# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly sflow_leaf_spine.frasm sflow_leaf_spine.pcap
frameassembly sflow_leaf_spine.frasm sflow_leaf_spine.pcapng
# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse sflow_leaf_spine.pcap sflow_leaf_spine_edited.frasmAll sflow Keywords & Header Options
Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after sflow:
src_host -> dst_host sflow [agentip <ip>] [subagentid <number>] [seq <number>] [uptime <number>] [samples <number>]| Keyword / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| agentip <ip> | IPv4 or IPv6 switch management/loopback IP | Source host IP | Sets the sFlow Agent Address (XDR Type 1 IPv4 or Type 2 IPv6) in the datagram header. |
| subagentid <number> | 32-bit Sub-Agent ID | 0 | Disambiguates multiple linecards or virtual switches sharing one agentip. |
| seq <number> | 32-bit datagram sequence number | 1 | Sets the sFlow v5 datagram sequence counter (collectors track gaps in seq to detect dropped UDP telemetry). |
| uptime <number> | 32-bit milliseconds since boot | 1000 | Sets sysUpTime in milliseconds inside the sFlow v5 header. |
| samples <number> | Sample count | 1 | Sets the number of sample records carried in the sFlow datagram. |
Cross-Layer Wrappers Valid with sflow
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
10 options
Cross-Layer Wrappers Valid with sflow
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
| Option | Range / Format | Default | Effect on Packet |
|---|---|---|---|
| wait <number><ns|us|ms|s|m> | Time gap (ns, us, ms, s, m) | 10ms | Advances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back). |
| payload "<text>" | hexpayload "<hex>" | Quoted text or hex bytes (choose one) | Omitted | Appends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums. |
| srcmac <mac> | dstmac <mac> | Colon, hyphen, or Cisco dot MAC | Host MAC / RFC multicast MAC | Overrides the 14-byte Ethernet II source or destination MAC address for this single packet. |
| vlan <0..4095> [pcp <0..7>] [dei <0|1>] | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | Untagged | Wraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority. |
| qinq <0..4095> [innervlan <0..4095>] | Outer S-VLAN 0..4095, Inner C-VLAN 0..4095 | Untagged (innervlan 1 when qinq is set) | Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100). |
| mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>] | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | Unlabeled (at most 1 mpls tag per packet) | Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header. |
| ttl <0..255> [dscp <0..63>] [ecn <0..3>] | TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3 | ttl 64, dscp 0, ecn 0 | Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings. |
| ipid <0..65535> [df] [mf] [fragoffset <0..8191>] | IPv4 ID, DF/MF flags, fragment offset 0..8191 | ipid 1, flags 0, fragoffset 0 | Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6). |
| flowlabel <0..1048575> | 20-bit IPv6 Flow Label (0..1048575) | 0 | Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts). |
| srcport <0..65535> | dstport <0..65535> | Port number 0..65535 | srcport 49152 (remembered), UDP 6343 | Overrides source or destination port and remembers the port pair automatically on <- replies. |
Gotchas & Quick Fixes
seq on sflow Sets the sFlow Datagram Counter (UDP Has No TCP seq)
tor_sw01 -> sflow_col sflow agentip 10.40.0.11 seq 42Because sFlow runs over UDP 6343, seq sets the 32-bit sFlow datagram sequence number rather than a TCP sequence number.
uptime Is Measured in Milliseconds
tor_sw01 -> sflow_col sflow uptime 600000In sFlow v5, uptime 600000 represents 600 seconds (10 minutes) since the switch agent initialized.