sFlow
termKept in this browser · My desk
A traffic monitoring technology in which switches and routers export randomly sampled packet headers, one in N on average, together with periodic interface counters, to a collector that estimates the traffic mix statistically.
sFlow was described by InMon in RFC 3176 (2001) and is maintained by the sFlow.org consortium; version 5 (July 2004) is current. Unlike NetFlow and IPFIX, the agent keeps no flow cache: it copies the header of a random sample of packets and the forwarding decision made for it, and sends counters on a timer, in XDR-encoded datagrams to UDP port 6343. Accuracy depends on the number of samples, not on traffic volume, which suits very fast links but can miss short, rare flows.
What it is. sFlow monitors traffic by sampling. The specification defines packet flow sampling as "the random selection of a fraction of the Packet Flows observed at a Data Source", and the sampling rate as the ratio of packets observed to samples generated: "a sampling rate of 100 specifies that, on average, 1 sample will be generated for every 100 packets observed". For each sample the agent exports the packet's header and what the device knows about its path, such as input and output interfaces, VLANs, next hop and AS path. Separately, counter sampling exports interface counters periodically, so one stream gives both the traffic mix and the totals.
History. Peter Phaal, Sonia Panchen and Neil McKee of InMon Corporation published RFC 3176 in September 2001, an Informational RFC describing "InMon Corporation's sFlow". Version 5, by Peter Phaal of InMon and Marc Lavine of Foundry Networks, is dated July 2004 and published by sFlow.org, which lists versions 4 and 2 as deprecated and maintains extensions for dropped packets, transit delay, 802.11, optical modules, LACP counters, tunnels, host and application metrics.
How it works. After each sample the agent sets its skip counter to a random integer such that Total_Packets / Total_Samples equals the sampling rate; randomness avoids synchronizing with periodic traffic, the bias that RFC 5475 warns systematic sampling risks. Datagrams are encoded in XDR (External Data Representation), which the specification calls "more compact than ASN.1 and simpler for the sFlow Agent", and sent to UDP port 6343 by default. A datagram carries the agent address, a sub-agent ID, a sequence number, the uptime in milliseconds and a list of samples. A flow sample carries its own sequence number, the data source, sampling_rate, sample_pool ("Total number of packets that could have been sampled") and drops (samples lost for lack of resources), then the input and output interfaces and the flow records.
Counters and configuration. Counter sampling is scheduled loosely on purpose: the specification suggests adding counters to datagrams that are being sent anyway when a source is within a few seconds of its maximum sampling interval, and, where polling is scheduled, starting each counter source "at a different start time (preferably randomly) so that counter sampling is not synchronised within an agent or between agents". Agents are configured through the SFLOW MIB, so the sampling rate, the counter interval (sFlowCounterSamplingInterval) and the collector address can be set by SNMP, and the MIB's default collector port is 6343.
Accuracy. sFlow.org's note on packet sampling works an example: 2,500 samples from 1,000,000 packets, of which 1,000 are voice, give a best estimate of 400,000 voice packets, with 95% confidence between 381,000 and 419,000. Its figures fit the rule of thumb of a largest likely error of about 196 x sqrt(1/c) per cent for c samples in a class: about 6% for 1,000 samples, 65% for 9, 2.4% for 6,700. The note's conclusion is that "the accuracy of measurements doesn't depend on the total number of frames, but simply on the number of samples". A class seen 37 times at 1 in 2,048 is estimated at 37 x 2,048 = 75,776 packets with an error near 32%.
In practice. sFlow.org says it "has been implemented on a wide range of devices, from simple L2 workgroup switches to high-end core routers, without requiring additional memory and CPU", which is its point: no per-flow cache to size. It is good at answering which hosts, applications and ports dominate a link and at spotting floods quickly; it is poor at proving that one particular short connection happened. Operators check sample_pool against the configured rate and watch drops; a rising drops counter means the agent cannot keep up and, per the specification, increasing the sampling rate reduces it.
What goes wrong. Low sample counts give large errors; scaling must use the effective rate from sample_pool, not the configured one. Like NetFlow v9, sFlow datagrams are unauthenticated UDP, so the collector path should be private. Sampled headers may include the first bytes of payload and therefore personal data.
Neighbours. NetFlow and IPFIX export per-flow records from a cache; PSAMP standardizes sampling for IPFIX; port mirroring copies every packet.
Also known as: sampled flow, sflow v5, packet sampling
Sources
- IETF, RFC 3176, InMon Corporation's sFlow: A Method for Monitoring Traffic in Switched and Routed Networks, P. Phaal, S. Panchen and N. McKee, September 2001, Informational (read 2026-11-23): authors, date and status
- sFlow.org, sFlow Version 5, Peter Phaal (InMon) and Marc Lavine (Foundry Networks), July 2004 (read 2026-11-23): packet flow sampling and sampling rate, random skip counts with Total_Packets/Total_Samples = Sampling Rate, counter sampling, XDR, UDP port 6343, the flow_sample fields sampling_rate, sample_pool and drops
- Peter Phaal and Sonia Panchen, Packet Sampling Basics, sFlow.org (read 2026-11-23): worked examples of estimates and error (1,000 of 2,500 samples; 6% for c = 1,000; 65% for 9 samples; 2.4% for 6,700)
- sFlow.org, Specifications for Developers (read 2026-11-23): versions 4 and 2 deprecated; extension structures
- IETF, RFC 5475, Sampling and Filtering Techniques for IP Packet Selection, March 2009 (read 2026-11-23): systematic sampling risks bias; random n-out-of-N and probabilistic sampling