This memo defines InMon Coporation's sFlow system. sFlow is technology for monitoring traffic in data networks switches and routers. In particular, it defines the
mechanisms implemented in an sFlow Agent for monitoring traffic,
sFlow MIB for controlling the sFlow Agent, and the format of
data used by the sFlow Agent when forwarding data to a central collector
Table of
1. Overview ..................................................... 2
2. Sampling Mechanisms .......................................... 2
2.1 Sampling of Switched Flows ............................... 3
2.1.1 DistributedSwitching .............................. 4
2.1.2 Random Number Generation ........................... 4
2.2 Sampling of Network InterfaceStatistics ................. 4
3. sFlow MIB .................................................... 5
3.1 The SNMP ManagementFramework ............................ 5
3.2 Definitions .............................................. 6
4. sFlow Datagram Format ........................................ 14
5. SecurityConsiderations ...................................... 25
5.1 Control .................................................. 26
5.2 Transport ................................................ 26
5.3 Confidentiality .......................................... 26
6. References ................................................... 27
7. Authors' Addresses ........................................... 29
The sFlow monitoring system consists of an sFlow Agent (embedded in
switch or router or in a stand alone probe) and a central collector, or sFlow Analyzer
This document describes the sampling mechanisms used by the
Agent, the SFLOW MIB used by the sFlow Analyzer to control the
Agent, and the sFlow Datagram Format used by the sFlow Agent to
traffic data to the sFlow Analyzer
A flow is defined as all the packets that are received on interface, enter the Switching/Routing Module and are sent to interface. In the case of a one-armed router, the source destinationinterface could be the same. In the case of a
or multicast packet there may be multipledestination interfaces
The samplingmechanism must ensure that any packet involved in a
has an equal chance of being sampled, irrespective of the flow
which it belongs
Sampling flows is accomplished as follows: When a packet arrives
an interface, a filteringdecision is made that determines
the packet should be dropped. If the packet is not filtered destinationinterface is assigned by the switching/routing function
At this point a decision is made on whether or not to sample
packet. The mechanism involves a counter that is decremented
each packet. When the counter reaches zero a sample is taken
Whether or not a sample is taken, the counter Total_Packets
incremented. Total_Packets is a count of all the packets that
have been sampled
Taking a sample involves either copying the packet's header,
extracting features from the packet (see sFlow Datagram Format for description of the different forms of sample). Every time a
is taken, the counter Total_Samples, is incremented. Total_
is a count of the number of samples generated. Samples are sent
the sampling entity to the sFlow Agent for processing. The
includes the packet information, and the values of the Total_
and Total_Samples counters
When a sample is taken, the counter indicating how many packets
skip before taking the next sample should be reset. The value of
counter should be set to a random integer where the sequence
random integers used over time should be such
(1) Total_Packets/Total_Samples =
An alternativestrategy for packet sampling is to generate a
number for each packet, compare the random number to a threshold and take a sample whenever the random number is
than the threshold value. Calculation of an appropriate
value depends on the characteristics of the random number generator
however, the resulting sample stream must still satisfy (1).
The SFLOW MIB permits separatesamplingentities to be
with differentphysical or logical elements of the switch (such
interfaces, backplanes or VLANs). Each sampling engine has its independent state (i.e., Total_Packets, Total_Samples, Skip
Rate), and forwards its own sample messages to the sFlow Agent.
sFlow Agent is responsible for packaging the samples into
for transmission to an sFlow Analyzer
2.1.2 Random Number
The essential property of the random number generator is that
mean value of the numbers it generates converges to the sampling rate
The random number generator must ensure that all numbers in the
between its maximum and minimum values of the distribution possible; a random number generator only capable of generating
numbers, or numbers with any common divisor is unsuitable
A new skip value is only required every time a sample is taken
Flow sampling and counter sampling are designed as part of integrated system. Both types of samples are combined in
Datagrams. Since flow sampling will cause a steady, but random
stream of datagrams to be sent to the sFlow Analyzer, counter
may be taken opportunistically in order to fill these datagrams
One strategy for counter sampling has the sFlow Agent keep a list
counter sources being sampled. When a flow sample is generated
sFlow Agent examines the list and adds counters to the datagram, least recently sampled first. Counters are only added
the datagram if the sources are within a short period, 5 seconds say
of failing to meet the requiredsamplinginterval (
sFlowCounterSamplingInterval in SFLOW MIB). Whenever a
source's statistics are added to a sample datagram, the time
counter source was last sampled is updated and the counter source
placed at the end of the list. Periodically, say every second,
sFlow Agent examines the list of counter sources and sends
counters that need to be sent to meet the sampling requirement
Alternatively, if the agent regularly schedules counter sampling
then it should schedule each counter source at a different start
(preferably randomly) so that counter sampling is not
within an agent or between agents
RFC 1155 [3], STD 16, RFC 1212 [4] and RFC 1215 [5]. The
version, called SMIv2, is described in STD 58, RFC 2578 [6],
58, RFC 2579 [7] and STD 58, RFC 2580 [8].
o Message protocols for transferring managementinformation.
first version of the SNMP message protocol is called SNMPv1 described in STD 15, RFC 1157 [9]. A second version of the
message protocol, which is not an Internetstandards protocol, is called SNMPv2c and described in RFC 1901 [10] and
1906 [11]. The third version of the message protocol is
SNMPv3 and described in RFC 1906 [11], RFC 2572 [12] and RFC 2574
[13].
A more detailed introduction to the current SNMP Management
can be found in RFC 2570 [17].
Managed objects are accessed via a virtual information store,
the ManagementInformation Base or MIB. Objects in the MIB
defined using the mechanisms defined in the SMI
This memo specifies a MIB module that is compliant to the SMIv2.
MIB conforming to the SMIv1 can be produced through the
translations. The resulting translated MIB must be equivalent, except where objects or events are omitted because translation is possible (use of Counter64). Some machine information in SMIv2 will be converted into textual descriptions
SMIv1 during the translation process. However, this loss of readableinformation is not considered to change the semantics of
MIB
As an example, the string '1.2;InMon Corp.;2.1.1'
that this agent implements version '1.2' of the SFLOW MIB,
it was developed by 'InMon Corp.' and that the software
is '2.1.1'.
The MIB Version will change with each revision of the
Managemententities must check the MIB Version and not
to manage agents with MIB Versions greater than that for
they were designed
Note: The sFlow Datagram Format has an independent
number which may change independently from . applies to the structure and semantics
the SFLOW MIB only."
DEFVAL { "1.2;;" }
::= { sFlowAgent 1 }
sFlowAgentAddressType OBJECT-
SYNTAX
MAX-ACCESS read-
STATUS
"The address type of the address associated with this agent
Only ipv4 and ipv6 types are supported."
::= { sFlowAgent 2 }
sFlowAgentAddress OBJECT-
SYNTAX
MAX-ACCESS read-
STATUS
"The IP address associated with this agent. In the case of
multi-homed agent, this should be the loopback address of
agent. The sFlowAgent address must provide SNMP
to the agent. The address should be an invariant that does
change as interfaces are reconfigured, enabled, disabled
added or removed. A manager should be able to use
sFlowAgentAddress as a unique key that will identify
agent over extended periods of time so that a history
be maintained."
::= { sFlowAgent 3 }
sFlowTable OBJECT-
SYNTAX SEQUENCE OF
MAX-ACCESS not-
STATUS
"A table of the sFlow samplers within a device."
::= { sFlowAgent 4 }
sFlowDataSource OBJECT-
SYNTAX OBJECT
MAX-ACCESS read-
STATUS
"Identifies the source of the data for the sFlow sampler
The following data source types are currently defined
- ifIndex.
DataSources of this traditional form are called 'port-based'.
Ideally the sampling entity will perform sampling on all
originating from or destined to the specifiedinterface
However, if the switch architecture only permits input
output sampling then the sampling agent is permitted to
sample input flows input or output flows. Each packet
only be considered once for sampling, irrespective of
number of ports it will be forwarded to
Note: Port 0 is used to indicate that all ports on the
are represented by a single data source
- sFlowPacketSamplingRate applies to all ports on
device capable of packet sampling
- sFlowCounterSamplingInterval applies to all ports
- smonVlanDataSource.
A dataSource of this form refers to a 'Packet-based VLAN
and is called a 'VLAN-based' dataSource. is the
ID as defined by the IEEE 802.1Q standard.
value is between 1 and 4094 inclusive, and it
an 802.1Q VLAN-ID with global scope within a
bridged domain Sampling is performed on all packets received that are
of the specified VLAN (no matter which port they arrived on).
Each packet will only be considered once for sampling
irrespective of the number of ports it will be forwarded to
- entPhysicalEntry.
A dataSource of this form refers to a physical entity
the agent (e.g., entPhysicalClass = backplane(4)) and is
an 'entity-based' dataSource Sampling is performed on all packets entering the resource (e.g
If the backplane is being sampled, all packets transmitted
the backplane will be considered as single candidates sampling irrespective of the number of ports they
reach).
Note: Since each DataSource operates independently, a
that crosses multiple DataSources may generate
flow records."
::= { sFlowEntry 1 }
sFlowOwner OBJECT-
SYNTAX
MAX-ACCESS read-
STATUS
"The entity making use of this sFlow sampler. The empty indicates that the sFlow sampler is currently unclaimed
An entity wishing to claim an sFlow sampler must make
that the sampler is unclaimed before trying to claim it
The sampler is claimed by setting the owner string to
the entity claiming the sampler. The sampler must be
before any changes can be made to other sampler objects
In order to avoid a race condition, the entity taking
of the sampler must set both the owner and a value
sFlowTimeout in the same SNMP set request
When a management entity is finished using the sampler
it should set its value back to unclaimed. The
must restore all other entities this row to
default values when the owner is set to unclaimed
competition for a sampler is fairly resolved."
DEFVAL { "" }
::= { sFlowEntry 2 }
sFlowTimeout OBJECT-
SYNTAX Integer32
MAX-ACCESS read-
STATUS
"The time (in seconds) remaining before the sampler is
and stops sampling. When set, the owner establishes
for the specified period. When read, the remaining time in interval is returned
A management entity wanting to maintain control of the
is responsible for setting a new value before the old
expires
When the interval expires, the agent is responsible
restoring all other entities in this row to their
values."
DEFVAL { 0 }
::= { sFlowEntry 3 }
sFlowPacketSamplingRate OBJECT-
SYNTAX Integer32
MAX-ACCESS read-
STATUS
Set to N to sample 1/Nth of the packets in the monitored flows
An agent should choose its own algorithmintroduce
into the sampling so that exactly every Nth packet is
counted. A sampling rate of 1 counts all packets. A
rate of 0 disables sampling
The agent is permitted to have minimum and maximum
values for the sampling rate. A minimum rate lets the
designer set an upper bound on the overheadassociated sampling, and a maximum rate may be the result of
restrictions (such as counter size). In addition not all
between the maximum and minimum may be realizable as sampling rate (again because of implementationconsiderations).
When the sampling rate is set the agent is free to adjust
value so that it lies between the maximum and minimum
When read, the agent must return the actual sampling rate
will be using (after the adjustments previously described). samplingalgorithm must converge so that over time the
of packets sampled approaches 1/Nth of the total number
packets in the monitored flows."
DEFVAL { 0 }
::= { sFlowEntry 4 }
sFlowCounterSamplingInterval OBJECT-
SYNTAX Integer32
MAX-ACCESS read-
STATUS
"The maximum number of seconds between successive samples of
counters associated with this data source. A sampling
of 0 disables counter sampling."
DEFVAL { 0 }
::= { sFlowEntry 5 }
sFlowMaximumHeaderSize OBJECT-
SYNTAX Integer32
MAX-ACCESS read-
STATUS
"The maximum number of bytes that should be copied from
sampled packet. The agent may have an internal maximum
minimum permissible sizes. If an attempt is made to set
value outside the permissible range then the agent
adjust the value to the closest permissible value."
DEFVAL { 128 }
::= { sFlowEntry 6 }
sFlowMaximumDatagramSize OBJECT-
SYNTAX Integer32
MAX-ACCESS read-
STATUS
"The maximum number of data bytes that can be sent in a
sample datagram. The manager should set this value to
fragmentation of the sFlow datagrams."
DEFVAL { 1400 }
::= { sFlowEntry 7 }
"The type of sFlowCollectorAddress."
DEFVAL { ipv4 }
::= { sFlowEntry 8 }
sFlowCollectorAddress OBJECT-
SYNTAX
MAX-ACCESS read-
STATUS
"The IP address of the sFlow collector
If set to 0.0.0.0 all sampling is disabled."
DEFVAL { "0.0.0.0" }
::= { sFlowEntry 9 }
sFlowCollectorPort OBJECT-
SYNTAX Integer32
MAX-ACCESS read-
STATUS
"The destination port for sFlow datagrams."
DEFVAL { 6343 }
::= { sFlowEntry 10 }
sFlowDatagramVersion OBJECT-
SYNTAX Integer32
MAX-ACCESS read-
STATUS
"The version of sFlow datagrams that should be sent
When set to a value not support by the agent, the agent
adjust the value to the highest supported value less than requested value, or return an error if no such values exist."
DEFVAL { 4 }
::= { sFlowEntry 11 }
The format of the sFlow datagram is specified using the XDR
[1]. XDR is more compact than ASN.1 and simpler for the sFlow
to encode and the sFlow Analyzer to decode
Samples are sent as UDP packets to the host and port specified in
SFLOW MIB. The lack of reliability in the UDP transport
does not significantly affect the accuracy of the
obtained from an sFlow Agent
o If counter samples are lost then new values will be sent
the next polling interval. The chance of an undetected
wrap is negligible. The sFlow datagramspecifies 64 bit
counters, and with typical counter polling intervals between 20
120 seconds, the chance of a long enough sequence of
datagrams being lost to hide a counter wrap is very small
o The net effect of lost flow samples is a slight reduction in effectivesampling rate
The agent should try to piggyback counter samples on the
stream resulting from flow sampling. Before sending out a
the remaining space in the buffer can be filled with counter samples
The agent has discretion in the timing of its counter polling, specified counter sampling intervals sFlowCounterSamplingInterval
a maximum, so the agent is free to sample counters early if it
space in a datagram. If counters must be sent in order to
the maximum samplinginterval then a datagram must be sent
the outstanding counters
unsigned int length; /* The length of the IP packet
lower layer encapsulations */ unsigned int protocol; /* IP Protocol
(for example, TCP = 6, UDP = 17) */
ip_v4 src_ip; /* Source IP Address */
ip_v4 dst_ip; /* Destination IP Address */ unsigned int src_port; /* TCP/UDP source port number equivalent */ unsigned int dst_port; /* TCP/UDP destination port number equivalent */ unsigned int tcp_flags; /* TCP flags */ unsigned int tos; /* IP type of service */
/* Packet IP version 6 data */
struct sampled_ipv6 { unsigned int length; /* The length of the IP packet
lower layer encapsulations */ unsigned int protocol; /* IP next
(for example, TCP = 6, UDP = 17) */
ip_v6 src_ip; /* Source IP Address */
ip_v6 dst_ip; /* Destination IP Address */ unsigned int src_port; /* TCP/UDP source port number equivalent */ unsigned int dst_port; /* TCP/UDP destination port number equivalent */ unsigned int tcp_flags; /* TCP flags */ unsigned int priority; /* IP priority */
/* Packet data */
enum packet_information_type {
HEADER = 1, /* Packet headers are sampled */
IPV4 = 2, /* IP version 4 data */
IPV6 = 3 /* IP version 6 data */
union packet_data_type (packet_information_type type) {
case HEADER
sampled_header header
case IPV4:
sampled_ipv4 ipv4;
case IPV6:
sampled_ipv6 ipv6;
struct flow_sample { unsigned int sequence_number; /* Incremented with each flow generated by this source_id */ unsigned int source_id; /* sFlowDataSource encoded as follows
The most significant byte of
source_id is used to indicate
type of
(0 = ifIndex
1 = smonVlanDataSource
2 = entPhysicalEntry) and
lower three bytes contain relevant index value.*/
unsigned int sampling_rate; /* sFlowPacketSamplingRate */ unsigned int sample_pool; /* Total number of packets that
have been sampled (i.e.,
skipped by sampling process +
number of samples) */ unsigned int drops; /* Number times a packet was
due to lack of resources */
struct if_counters { unsigned int ifIndex unsigned int ifType unsigned hyper ifSpeed unsigned int ifDirection; /* derived from MAU MIB (RFC 2668)
0 = unknown, 1=full-duplex
2=half-duplex, 3 = in, 4=out */ unsigned int ifStatus; /* bit field with the following
bit 0 =
(0 = down, 1 = up
bit 1 =
(0 = down, 1 = up) */ unsigned hyper ifInOctets unsigned int ifInUcastPkts unsigned int ifInMulticastPkts unsigned int ifInBroadcastPkts unsigned int ifInDiscards unsigned int ifInErrors unsigned int ifInUnknownProtos unsigned hyper ifOutOctets unsigned int ifOutUcastPkts unsigned int ifOutMulticastPkts unsigned int ifOutBroadcastPkts unsigned int ifOutDiscards unsigned int ifOutErrors unsigned int ifPromiscuousMode
struct ethernet_counters {
if_counters generic unsigned int dot3StatsAlignmentErrors unsigned int dot3StatsFCSErrors unsigned int dot3StatsSingleCollisionFrames unsigned int dot3StatsMultipleCollisionFrames unsigned int dot3StatsSQETestErrors unsigned int dot3StatsDeferredTransmissions unsigned int dot3StatsLateCollisions unsigned int dot3StatsExcessiveCollisions unsigned int dot3StatsInternalMacTransmitErrors unsigned int dot3StatsCarrierSenseErrors unsigned int dot3StatsFrameTooLongs
struct tokenring_counters {
if_counters generic unsigned int dot5StatsLineErrors unsigned int dot5StatsBurstErrors unsigned int dot5StatsACErrors unsigned int dot5StatsAbortTransErrors unsigned int dot5StatsInternalErrors unsigned int dot5StatsLostFrameErrors unsigned int dot5StatsReceiveCongestions unsigned int dot5StatsFrameCopiedErrors unsigned int dot5StatsTokenErrors unsigned int dot5StatsSoftErrors unsigned int dot5StatsHardErrors unsigned int dot5StatsSignalLoss unsigned int dot5StatsTransmitBeacons unsigned int dot5StatsRecoverys unsigned int dot5StatsLobeWires unsigned int dot5StatsRemoves unsigned int dot5StatsSingles unsigned int dot5StatsFreqErrors
/* 100 BaseVG interface counters - see RFC 2020 */
struct vg_counters {
if_counters generic unsigned int dot12InHighPriorityFrames unsigned hyper dot12InHighPriorityOctets unsigned int dot12InNormPriorityFrames unsigned hyper dot12InNormPriorityOctets unsigned int dot12InIPMErrors unsigned int dot12InOversizeFrameErrors unsigned int dot12InDataErrors unsigned int dot12InNullAddressedFrames unsigned int dot12OutHighPriorityFrames unsigned hyper dot12OutHighPriorityOctets unsigned int dot12TransitionIntoTrainings
union counters_type (counters_version version) {
case GENERIC
if_counters generic
case ETHERNET ethernet_counters ethernet
case TOKENRING tokenring_counters tokenring
case FDDI
fddi_counters fddi
case VG
vg_counters vg
case WAN
wan_counters wan
case VLAN
struct counters_sample { unsigned int sequence_number; /* Incremented with each
sample generated by
source_id */ unsigned int source_id; /* sFlowDataSource encoded
follows
The most significant byte of
source_id is used to indicate
type of
(0 = ifIndex
1 = smonVlanDataSource
2 = entPhysicalEntry) and
lower
bytes contain the
index value.*/
union sample_type (sample_types sampletype) {
case FLOWSAMPLE
flow_sample flowsample
case COUNTERSSAMPLE
counters_sample counterssample
struct sample_datagram_v4 {
address agent_address /* IP address of sampling agent
sFlowAgentAddress. */ unsigned int sequence_number; /* Incremented with each datagramgenerated */ unsigned int uptime; /* Current time (in milliseconds
device last booted). Should be
as close to datagram
time as possible.*/
The sFlow MIB is used to configure the generation of sFlow samples
The security of SNMP, with access control lists, is considered adequate in an enterprise setting. However, there
situations when these security measures are insufficient (for
a WAN router) and SNMP configuration control will be disabled
Traffic information is sent unencrypted across the network from
sFlow Agent to the sFlow Analyzer and is thus vulnerable
eavesdropping. This risk can be limited by creating a measurement network and routing the sFlow Datagrams over
network. The choice of technology for creating the measurement network is deploymentspecific, but could include the
of VLANs or VPN tunnels
The sFlow Analyzer is vulnerable to attacks involving spoofed
Datagrams. To limit this vulnerability the sFlow Analyzer
check sequence numbers and verify source addresses. If a measurement network has been constructed then only sFlow received from that network should be processed
The traffic patterns discernible by decoding the sFlow Datagrams
the sFlow Analyzer can reveal details of an individual's
related activities and due care should be taken to secure access
the sFlow Analyzer
[21] Brownlee, N., "Traffic Flow Measurement: Meter MIB", RFC 2720,
October 1999.
[22] Smith, A., Flick, J., de Graaf, K., Romanscanu, D., McMaster
D., McCloghrie, K. and S. Roberts, "Definition of
Objects for IEEE 802.3 Medium Attachment Units (MAUs)",
2668, August 1999.
[26] McCloghrie, K. and E. Decker, "IEEE 802.5 MIB using SMIv2",
1748, December 1994.
[27] Flick, J., "Definitions of Managed Objects for IEEE 802.12
Interfaces", RFC 2020, October 1996.
[28] Willis, S., Burruss, J. and J. Chu, "Definitions of
Objects for the Fourth Version of the Border Gateway
(BGP-4) using SMIv2", RFC 1657, July 1994.
The IETF invites any interested party to bring to its attention
copyrights, patents or patent applications, or other
rights which may cover technology that may be required to
this standard. Please address the information to the IETF Director
The limited permissions granted above are perpetual and will not
revoked by the Internet Society or its successors or assigns
This document and the information contained herein is provided on
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
if you see any problems within the linking, don't worry be happy,
this is version 0.1 of the Relevance System and you gotta expect some crappy subroutines sometimes,
just be content we did not write this in Java, which would have made this "bigger and better" HAHAHHA.