Skip to main content

sFlow

sFlow (Sampled Flow) is a network monitoring protocol designed for high-speed networks. Unlike NetFlow and IPFIX, which capture complete flow records, sFlow uses packet sampling to provide scalable and efficient traffic analysis. Monitoring agents embedded in network devices sample packets and send them to a central collector.

Versions

The sflow device collects sFlow v5. Datagrams declaring any other version are rejected.

Structure

An sFlow datagram is layered: a datagram header carries a number of samples, each sample carries flow records, and a flow record carries the sampled packet's decoded fields. The three tables below follow that nesting.

Datagram Header

FieldDescription
VersionAlways 5
IPVersionAddress family of the agent address
AgentIPIP address of the device performing sampling
SubAgentIdDistinguishes multiple agents on one device
SequenceNumberRunning datagram counter, for loss detection
UptimeMilliseconds since the agent booted
SamplesCountNumber of samples in this datagram

Flow Sample

FieldDescription
SamplingRateRatio of sampled packets to total packets
SamplePoolTotal packets that could have been sampled
DropsPackets dropped due to a lack of resources
InputInterface the packet was received on
OutputInterface the packet was forwarded to
SampleSequenceNumberPer-source sequence counter for this sample stream
FrameLengthOriginal length of the sampled frame in bytes
OriginalLengthLength of the packet before any truncation
StrippedBytes removed from the end of the sampled packet

Expanded flow samples carry the interfaces as InputIfFormat/InputIfValue and OutputIfFormat/OutputIfValue instead of the plain Input and Output.

Sampled Packet

FieldDescription
SrcIPSource IP address
DstIPDestination IP address
SrcPortSource port number
DstPortDestination port number
ProtocolTransport protocol
TcpFlagsTCP control flags

An extended switch record adds SrcVlan and DstVlan—two directional VLAN identifiers rather than a single one.

Sample Types

The sample header's format field distinguishes flow samples (1), counter samples (2), expanded flow samples (3), expanded counter samples (4) and drop samples (5).

Only flow samples and expanded flow samples are emitted. Counter samples are decoded and then discarded, so interface counter statistics do not reach a pipeline.

Emitted Fields

The names above are those of the sFlow datagram on the wire. They are not the field names that reach a pipeline: the collector converts each sample to ECS 8.11.0 before emitting it, so a sample arrives as source.ip, destination.port, network.bytes and their siblings.