Protocol 45 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
sflowsFlow Version 5 Switched & Routed Packet Sampling

1-in-N Switch Packet Sampling (tor_sw -> collector sflow UDP 6343)

Default Port / Protocol
UDP 6343
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
sflow
Standards & Specs
sFlow v5 Specification
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6UDP 6343sFlow v5

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.

sflow_quickstart.frasm6 lines
Open in 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 6343 and aligns all fields to 4-byte XDR boundaries per the sFlow v5 specification.
  • Sets Agent Address Type to 1 (4-byte IPv4) or 2 (16-byte IPv6) automatically from agentip.
  • Includes an Enterprise 0, Format 1 Flow Sample containing a sampled Raw Packet Header record so Wireshark dissects the full sFlow tree.
Multi-Frame Lab · Ready to Compile

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.

sflow_leaf_spine.frasm9 lines
Open in Playground
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
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 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.frasm

All 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 / OptionAccepted ValueDefaultEffect on Packet
agentip <ip>IPv4 or IPv6 switch management/loopback IPSource host IPSets the sFlow Agent Address (XDR Type 1 IPv4 or Type 2 IPv6) in the datagram header.
subagentid <number>32-bit Sub-Agent ID0Disambiguates multiple linecards or virtual switches sharing one agentip.
seq <number>32-bit datagram sequence number1Sets the sFlow v5 datagram sequence counter (collectors track gaps in seq to detect dropped UDP telemetry).
uptime <number>32-bit milliseconds since boot1000Sets sysUpTime in milliseconds inside the sFlow v5 header.
samples <number>Sample count1Sets 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
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances 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)OmittedAppends 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 MACHost MAC / RFC multicast MACOverrides 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..1UntaggedWraps 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..4095Untagged (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..255Unlabeled (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..3ttl 64, dscp 0, ecn 0Sets 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..8191ipid 1, flags 0, fragoffset 0Sets 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)0Sets 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..65535srcport 49152 (remembered), UDP 6343Overrides 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)

Valid v3.1.2 Syntax
tor_sw01 -> sflow_col sflow agentip 10.40.0.11 seq 42

Because 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

Valid v3.1.2 Syntax
tor_sw01 -> sflow_col sflow uptime 600000

In sFlow v5, uptime 600000 represents 600 seconds (10 minutes) since the switch agent initialized.

Field Guide 04
Encrypted SNMPv3 Traps, Syslog & NetFlow From Your Desk