The previous part of NetFun III, SNMP decoded, ended with interface counters: a router can tell you how many octets left a port in the last five minutes, but not whose they were. Flow telemetry answers that. A router or switch groups the packets it forwards into flows, keeps a counter for each, and exports a record when a flow ends, so that a collector somewhere can say who talked to whom, on which ports, for how long and how much, without storing a single packet. The series started from the five numbers that name a conversation and followed one TCP connection through its life; a flow record is those five numbers with a stopwatch and two counters attached. This part covers where records come from, the four formats that carry them (Cisco's version 5 and version 9, the Internet Engineering Task Force's IP Flow Information Export (), and , which samples packets instead of tracking flows), decodes an IPFIX message byte by byte with the template that makes it readable, shows why a sampled number can be trusted and how far, and ends with the security side in both directions: flows as evidence, and flows as data to protect. After it you should be able to read a flow record by hand, choose between sampled and unsampled export, and size the stream a collector will receive.
What a flow is
The IPFIX specification gives the definition everyone now uses: "A Flow is defined as a set of packets or frames passing an Observation Point in the network during a certain time interval. All packets belonging to a particular Flow have a set of common properties", where each property is derived from packet header fields, from characteristics of the packet itself, or from "Packet Treatment" such as the next hop or output interface (RFC 7011, section 2). The fields that define a flow are its Flow Keys, and "the traditional '5-tuple' Flow Key of source and destination IP address, source and destination transport port, and transport protocol" is the usual choice (same section). Everything else in a record, the counters and timestamps, is non-key: it describes the flow rather than identifying it.
Cisco's version 9 document is more direct about direction: "A flow is defined as a unidirectional sequence of packets with some common properties that pass through a network device" (RFC 3954, section 1). One TCP connection is therefore two flows, client to server and server to client, with the addresses and ports swapped. 5103 (January 2008) later defined how IPFIX can carry both directions in one "Biflow" record, with the reverse direction's fields marked by a private enterprise number assigned for the purpose, 29305 (RFC 5103, section 6), but unidirectional records remain the common case, and a collector that wants conversations has to pair them.
Two consequences follow from the definition. A flow record has no payload: it says that 192.0.2.10 sent 12 packets to port 443 of 198.51.100.20, not what they said. And a flow is whatever the keys say it is: add the input interface or the Differentiated Services field to the keys and the same packets split into more flows; remove the ports and every connection between two hosts becomes one flow. The definition is configuration, not physics.
The cache and its timers
The exporter, the router or switch doing the metering, keeps a flow cache: one entry per active key, with its counters. RFC 3954 lists when an entry is exported and removed (RFC 3954, section 3.2):
- "If the Exporter can detect the end of a Flow. For example, if the FIN or RST bit is detected in a TCP [RFC793] connection".
- "If the Flow has been inactive for a certain period of time", the inactive timeout, which "SHOULD be configurable at the Exporter, with a minimum value of 0 for an immediate expiration".
- "For long-lasting Flows, the Exporter SHOULD export the Flow Records on a regular basis", the active timeout, also configurable.
- "If the Exporter experiences internal constraints, a Flow MAY be forced to expire prematurely; for example, counters wrapping or low memory."
The active timeout is the one that surprises people. Configure it at 60 seconds and a 30-minute file transfer arrives at the collector as thirty records, not one, each carrying what happened since the previous report. That is why IPFIX names its counters carefully: octetDeltaCount is "The number of octets since the previous report (if any) in incoming packets for this Flow", while octetTotalCount is the total; both are listed in 's registry of information elements, with octetDeltaCount at number 1 and packetDeltaCount at 2 (IANA, IPFIX Information Elements). Summing deltas gives the transfer's size; summing totals would count it thirty times. The inactive timeout decides how long a quiet UDP exchange, which has no FIN, lingers in the cache before it is reported; set it too short and one slow conversation becomes many records, too long and the cache fills.
Four formats
| NetFlow v5 | NetFlow v9 | IPFIX | sFlow v5 | |
|---|---|---|---|---|
| Defined by | Cisco documentation | RFC 3954, October 2004, Informational | RFC 7011, September 2013, Internet Standard 77 | sFlow.org, July 2004 |
| What it exports | flow records | flow records | flow records (and more) | sampled packet headers and counters |
| Record layout | fixed, 48 bytes | described by templates | described by templates | fixed structures in (External Data Representation) |
| Version field | 5 | 9 | 10 | 5 |
| Transport | UDP | UDP (others possible) | SCTP required; UDP and TCP optional | UDP, default port 6343 |
The lineage starts at Cisco. A patent filed on 28 May 1996 by Darren R. Kerr and Barry L. Bruins and assigned to Cisco Systems is titled "Network flow switching and flow data export" (Google Patents, US6243667B1): the flow cache began as a way to switch packets faster, and exporting what it had learned came with it. Version 5 is the fixed format most collectors still read; version 9, edited by Benoit Claise of Cisco, introduced templates. RFC 3954's own front matter is careful about its status: it documents version 9 "as it was when submitted to the as a basis for further work in the IPFIX WG", and "This RFC itself is not a candidate for any level of Internet Standard" (RFC 3954, IESG Note).
The IETF's working group did not simply adopt it. RFC 3955, written by Simon Leinen of SWITCH, the Swiss research network, evaluated five candidates, "CRANE", "Diameter", "LFAP", "NetFlow v9" and "Streaming IPDR", and recommended "starting with NetFlow v9, working on lacking mechanisms in the areas of transport, security, reliability, and redundant configurations" (RFC 3955, sections 1 and 5.1). The requirements it measured them against are RFC 3917 (October 2004). The result was RFC 5101 in January 2008, replaced by RFC 7011 in September 2013, edited by Benoit Claise, Brian Trammell of ETH Zurich and Paul Aitken (RFC 7011, header; RFC 5101, header).
sFlow came from a different direction. RFC 3176, published in September 2001 by Peter Phaal, Sonia Panchen and Neil McKee of InMon Corporation, is Informational (RFC 3176, header); the current version 5 is published by the sFlow.org consortium, by Peter Phaal of InMon and Marc Lavine of Foundry Networks, dated July 2004 (sFlow.org, sFlow Version 5). sFlow.org's page of specifications says that "Previous versions of sFlow; version 4 and version 2 are deprecated" and lists extensions for dropped packets, transit delay, 802.11, optical modules, link aggregation and more (sFlow.org, Specifications for Developers).
NetFlow version 5: the fixed record
Version 5 has a 24-byte header and records of 48 bytes, at most 30 per datagram ("Number of flows exported in this packet (1-30)") (Cisco, NetFlow Export Datagram Format; read through a summary, as cisco.com refused a direct copy). The header carries the count, sys_uptime in milliseconds since boot, unix_secs and unix_nsecs, a flow_sequence "Counter of total flows seen", the engine type and slot, and a sampling_interval whose top two bits give the sampling mode and the low fourteen the interval. Each record holds, in order: source and destination addresses and next hop (4 bytes each), input and output interface as ifIndex values (2 bytes each), packets and bytes (4 each), the first and last times as sysUptime values, source and destination ports, a pad byte, tcp_flags (a "Cumulative OR of TCP flags"), protocol, type of service, source and destination autonomous system (AS) numbers (2 bytes each), the two prefix masks, and two pad bytes (Cisco, as above).
Three limits are built in. The addresses are 4 bytes, so version 5 cannot describe IPv6. The AS fields are 2 bytes, too small for the 4-byte AS numbers that the BGP primer describes. And the interface fields are the same ifIndex numbers the previous part walked in the ifTable, which is why a flow collector usually polls SNMP too: the record says "interface 5", and only the agent knows that interface 5 is the uplink to the . The largest version 5 datagram is 24 + 30 × 48 = 1,464 bytes of UDP payload.
NetFlow version 9: templates
Version 9 separates the description of a record from the record. The packet header has six fields: Version, "The value of this field is 9"; Count, the total of records of all kinds in the packet; sysUpTime, "Time in milliseconds since this device was first booted"; Secs; a Sequence Number, an "Incremental sequence counter of all Export Packets sent from the current Observation Domain"; and a Source ID that, with the exporter's address, separates "different export streams originating from the same Exporter" (RFC 3954, section 5.1). After the header come FlowSets: "the Template FlowSet (ID 0) and the Options Template FlowSet (ID 1)", while "The Data FlowSets have a FlowSet ID greater than 255", and all integers are in "network byte order (also known as the byte ordering)" (RFC 3954, section 4).
A template record is a Template ID (256 to 65535), a field count, and that many pairs of field type and field length. A data FlowSet's ID is the template's ID, and its records are the concatenated field values in template order, with padding so that "the subsequent FlowSet starts at a 4-byte aligned boundary", counted in the FlowSet's length (RFC 3954, sections 5.2 and 5.3). The field types are numbered in section 8: IN_BYTES is 1, IN_PKTS 2, PROTOCOL 4, TCP_FLAGS 6, L4_SRC_PORT 7, IPV4_SRC_ADDR 8, L4_DST_PORT 11, IPV4_DST_ADDR 12, IPV4_NEXT_HOP 15, and LAST_SWITCHED and FIRST_SWITCHED, 21 and 22, are each the "sysUptime in msec" at which the last or first packet "was switched" (RFC 3954, section 8).
The template is the price of the flexibility. "Interpretation of the Data FlowSet format can be done only if the Template FlowSet corresponding to the Template ID is available at the Collector", so the collector "MUST store the Template Record", the exporter MUST resend all templates "on a regular basis", every N packets or every N minutes, both configurable, and template IDs "are thus not guaranteed to be consistent across an Exporter or NetFlow process restart" (RFC 3954, sections 5.3 and 7). The operational symptom is familiar: after a router reloads, the collector receives data it cannot decode until the next template arrives, and if it keeps an old template under a reused ID, it decodes nonsense.
RFC 3954's own example is a good first exercise. Its template FlowSet is 28 bytes, one template (ID 256) of five fields, source, destination and next-hop addresses, packets and bytes, all 4 bytes; its data FlowSet is 64 bytes, a 4-byte header and three records of 20 bytes (RFC 3954, sections 11.2 and 11.3). Two details are worth noticing as you read it: the template example names the fields IP_SRC_ADDR and IP_DST_ADDR where the field table calls them IPV4_SRC_ADDR and IPV4_DST_ADDR, and the first record's source is printed as 198.168.1.12 while the other two are 192.168.1.27 and 192.168.1.56. The numbers 8 and 12 are what matter on the wire, and a decoder never sees the names.
IPFIX: the standard
IPFIX keeps the template idea and changes almost everything around it. The message header is 16 bytes (RFC 7011, section 3.1):
- Version: "0x000a for the current version, incrementing by one the version used in the NetFlow services export version 9".
- Length: "Total length of the IPFIX Message, measured in octets, including Message Header and Set(s)". Version 9 had a record count instead; a length lets a receiver find the end of a message on a byte stream such as TCP.
- Export Time: seconds since 1 January 1970 . There is no sysUpTime: IPFIX records carry absolute times.
- Sequence Number: "Incremental sequence counter modulo 2^32 of all IPFIX Data Records", and "Template and Options Template Records do not increase the Sequence Number". Version 9 counted packets; IPFIX counts data records, so a gap tells the collector how many records it lost.
- Observation Domain ID: the 32-bit successor of the Source ID.
Sets replace FlowSets, with new numbers: "A value of 2 is reserved for Template Sets. A value of 3 is reserved for Options Template Sets", "Values 256 and above are used for Data Sets", and "The Set ID values of 0 and 1 are not used, for historical reasons [RFC3954]" (RFC 7011, section 3.3.2). A collector that sees Set ID 0 in a version 10 message is looking at a bug.
Each field specifier in a template is the information element identifier and the field length, as in version 9, with one addition: the top bit of the identifier is the Enterprise bit. When it is zero, the element is in IANA's registry; when it is one, "the Enterprise Number MUST be present", a four-byte private enterprise number, the same registry SNMP uses for its enterprise subtree (RFC 7011, section 3.2). A field length of 65535 "is reserved for variable-length Information Elements", whose length then travels in the data (RFC 7011, section 7). And "reduced-size encoding" lets an exporter send octetDeltaCount, defined as an unsigned 64-bit integer, in 4 octets "if the Exporter will never locally encounter the need to send a value larger than 4294967295", by putting "a length of 4 versus 8 in the Template" (RFC 7011, section 6.2).
The vocabulary itself is the registry. IANA's IPFIX Information Elements registry, as read on 23 November 2026, has 506 numbered entries, the highest 533, with ranges 65 to 69 and 105 to 127 marked "Assigned for NetFlow v9 compatibility"; the most recent additions, 530 to 533, path delay statistics, are dated 2 April 2026 (IANA, as above). RFC 7012 explains the overlap with version 9: identifiers "in the range of 1-127 are compatible with field types used by NetFlow version 9 [RFC3954] for historical reasons" (RFC 7012, section 7.4). That is why sourceIPv4Address is 8 and destinationTransportPort is 11 in both.
Transport. IPFIX requires the Stream Control Transmission Protocol (SCTP) with partial reliability: it "MUST be implemented by all compliant implementations", while "UDP [UDP] MAY also be implemented" and so may TCP; the default port is 4739, and 4740 for the secured variants (RFC 7011, section 10.1). Over UDP the RFC is blunt: "UDP MUST NOT be used unless the application can tolerate some loss of IPFIX Messages", messages must fit the path's maximum transmission unit (), "If the PMTU is unknown, a maximum packet size of 512 octets SHOULD be used", and templates must be retransmitted periodically, with the collector free to expire a template not refreshed within "at least 3 times the observed retransmission rate" (RFC 7011, sections 8.4 and 10.3). In practice most exporters send IPFIX over UDP, which brings back every template problem of version 9.
An IPFIX message decoded with its template
The message below was built by hand from RFC 7011's formats and checked by a short script. One router reports one short HTTPS connection, the client-to-server direction, in a message that carries the template and the data together, 100 bytes in all.
The message header, 16 bytes:
00 0a 00 64 6b 04 a9 50 00 00 03 e8 00 00 00 01
| Bytes | Field | Value |
|---|---|---|
00 0a | Version | 10, IPFIX |
00 64 | Length | 100 octets, the whole message |
6b 04 a9 50 | Export Time | 1,795,467,600 seconds, that is 23 November 2026 21:00:00 UTC |
00 00 03 e8 | Sequence Number | 1,000 data records sent before this message |
00 00 00 01 | Observation Domain ID | 1 |
The Template Set, 48 bytes:
00 02 00 30 01 00 00 0a 00 08 00 04 00 0c 00 04
00 07 00 02 00 0b 00 02 00 04 00 01 00 06 00 02
00 02 00 04 00 01 00 04 00 96 00 04 00 97 00 04
| Bytes | Meaning |
|---|---|
00 02 00 30 | Set ID 2, a Template Set; length 48 |
01 00 00 0a | Template ID 256, 10 fields |
00 08 00 04 | element 8, sourceIPv4Address, 4 octets |
00 0c 00 04 | element 12, destinationIPv4Address, 4 octets |
00 07 00 02 | element 7, sourceTransportPort, 2 octets |
00 0b 00 02 | element 11, destinationTransportPort, 2 octets |
00 04 00 01 | element 4, protocolIdentifier, 1 octet |
00 06 00 02 | element 6, tcpControlBits, 2 octets |
00 02 00 04 | element 2, packetDeltaCount, 4 octets (reduced from 8) |
00 01 00 04 | element 1, octetDeltaCount, 4 octets (reduced from 8) |
00 96 00 04 | element 150, flowStartSeconds, 4 octets |
00 97 00 04 | element 151, flowEndSeconds, 4 octets |
Every Enterprise bit is zero: the first byte of each identifier is 00, so all ten elements are IANA's, and no enterprise numbers follow. The element names and types are the registry's: sourceIPv4Address is "The IPv4 source address in the IP packet header", protocolIdentifier is unsigned8, tcpControlBits unsigned16, flowStartSeconds "The absolute timestamp of the first packet of this Flow" (IANA, as above). The record length the template implies is 4 + 4 + 2 + 2 + 1 + 2 + 4 + 4 + 4 + 4 = 31 octets.
The Data Set, 36 bytes:
01 00 00 24 c0 00 02 0a c6 33 64 14 c0 00 01 bb
06 00 1b 00 00 00 0c 00 00 15 18 6b 04 a9 28 6b
04 a9 31 00
| Bytes | Field | Value |
|---|---|---|
01 00 00 24 | Set ID 256, length 36 | the data for template 256 |
c0 00 02 0a | sourceIPv4Address | 192.0.2.10 |
c6 33 64 14 | destinationIPv4Address | 198.51.100.20 |
c0 00 | sourceTransportPort | 49152 |
01 bb | destinationTransportPort | 443 |
06 | protocolIdentifier | 6, TCP |
00 1b | tcpControlBits | 0x001B: FIN (0x01), SYN (0x02), PSH (0x08), ACK (0x10) |
00 00 00 0c | packetDeltaCount | 12 packets |
00 00 15 18 | octetDeltaCount | 5,400 octets |
6b 04 a9 28 | flowStartSeconds | 20:59:20 UTC |
6b 04 a9 31 | flowEndSeconds | 20:59:29 UTC |
00 | padding | one zero octet |
How does the collector know the last octet is padding and not the start of a second record? The set's length is 36; minus the 4-byte header leaves 32; one record takes 31; the remaining octet is shorter than any record of this template, and RFC 7011 requires exactly that: "The padding length MUST be shorter than any allowable record in this Set", and "the padding octet(s) MUST be composed of octets with value zero" (RFC 7011, section 3.3.1).
Now the record says something. The connection lasted 9 seconds; 5,400 octets in 12 packets is 450 octets per packet on average, and 5,400 × 8 ÷ 9 = 4,800 bits per second. The control bits are the cumulative OR of every packet's flags, as the registry defines: "A bit is set to 1 if any observed packet of this Flow has the corresponding TCP control bit set to 1" (IANA, element 6). SYN and FIN both set means this direction saw the connection open and close; with no RST, it ended normally. The bit positions are those of the TCP header's flags octet in RFC 9293, with FIN as the least significant (RFC 9293, section 3.1). The octet count "includes IP header(s) and IP payload" (IANA, element 1), so it is not the application's data size. And the sequence number tells the collector that if the next message from this domain says anything other than 1,001, records were lost.
The same template in NetFlow version 9 would differ in three places: the template FlowSet's ID would be 0 instead of 2; elements 150 and 151 do not exist in version 9, whose times are FIRST_SWITCHED (22) and LAST_SWITCHED (21), milliseconds of sysUptime that the collector must convert using the header's sysUpTime and UNIX Secs; and the sequence number would count export packets, not records.
sFlow: sample the packets, not the flows
sFlow keeps no flow cache. Its agent takes "random selection of a fraction of the Packet Flows observed at a Data Source": with a sampling rate of 100, "on average, 1 sample will be generated for every 100 packets observed", and for each sample it exports the packet's header and what the device knows about its path, such as interfaces, VLANs, next hop and AS path (sFlow.org, sFlow Version 5, sections 2.1 and 3). Separately, it exports interface counters on a timer, counter sampling, so a collector gets both the traffic mix and the totals from one stream. The datagram is described in External Data Representation (XDR) rather than .1, "more compact than ASN.1 and simpler for the sFlow Agent", and goes by default to UDP port 6343 (sFlow Version 5, section 5).
The randomness is required. After each sample, the counter of packets to skip "should be set to a random integer" such that "Total_Packets/Total_Samples = Sampling Rate" (sFlow Version 5, section 3.1). A fixed one-in-N would synchronize with periodic traffic and miss it or count it twice; the PSAMP standard says the same of systematic sampling in general, "If the systematics in the Sampling process resemble systematics in the observed stochastic process ... there is a high probability that the estimation will be biased" (RFC 5475, section 5.1).
Each flow sample carries the numbers a collector needs to check the agent's honesty: sampling_rate; sample_pool, "Total number of packets that could have been sampled (i.e. packets skipped by sampling process + total number of samples)"; and drops, the number of times "a packet marked to be sampled was dropped due to lack of resources" (sFlow Version 5, the flow_sample structure). If the pool grew by 2,048,000 between two samples' worth of data that together report 1,000 samples, the effective rate was 1 in 2,048, whatever the configuration says; a rising drops counter means the agent cannot keep up and, the specification says, "Increasing sampling_rate will reduce the drop rate."
How far to trust a sampled count. sFlow.org's note on packet sampling works an example: of 1,000,000 packets, a 0.25% sample takes 2,500, of which 1,000 are voice; the best estimate is that voice was 40%, 400,000 packets, and "one can be 95% confidant that the actual number of voice was between 381,000 and 419,000" (Peter Phaal and Sonia Panchen, sFlow.org, Packet Sampling Basics). The note's equations are images, but every figure it gives fits a simple rule of thumb for the largest likely error, 196 × √(1/c) per cent, where c is the number of samples in the class: c = 1,000 gives 6.2%, the "approximately 6%" the note reads off its chart; c = 9 gives 65%, its one-voice-packet-a-second example; c = 36 gives 33%; c = 6,700 gives 2.4%. The note's conclusion is the useful one: "the accuracy of measurements doesn't depend on the total number of frames, but simply on the number of samples used to make the measurement."
A worked case of our own: a port sampled at 1 in 2,048 produces, in one minute, 37 samples whose destination is UDP port 161. The estimate is 37 × 2,048 = 75,776 SNMP packets in that minute, about 1,263 a second. The error bound is 196 ÷ √37 ≈ 32%, so the real figure is very likely between roughly 51,000 and 100,000. That is plenty to say "someone is sweeping SNMP at a thousand packets a second" and useless for billing; for billing, the note says, use "data collected over longer periods". The same logic tells you what sampling cannot do: a flow of three packets has a small chance of being sampled at all at 1 in 2,048, so a single short connection, the one attempt that mattered, can be invisible.
Flow exporters can sample too. Version 5's header has its two-bit mode and fourteen-bit interval (Cisco, as above), and PSAMP, RFC 5475 of March 2009, standardizes the selection methods an IPFIX exporter may use, from "systematic count-based" and "systematic time-based" sampling to random "n-out-of-N" and probabilistic sampling, and hash-based filtering for coordinated selection across devices (RFC 5475, sections 5 and 6). Whatever the method, a sampled record must be scaled before it is added up, and the scaling factor must travel with the data.
The export stream, sized
Flow export is a data stream that needs planning, and both specifications say so. RFC 3954 says that because UDP is not congestion-aware (what that means is in TCP flow and congestion control and UDP), the path to the collector should be "a dedicated link", or else "designed so that it can always sustain the maximum burstiness of NetFlow traffic from the Exporter" (RFC 3954, section 3.3); RFC 7011 allows UDP only "over dedicated links that are not susceptible to congestion, i.e., links that are over-provisioned compared to the maximum export rate" (RFC 7011, section 10.3.1).
The arithmetic, for a router that ends 50,000 flows a second exporting version 5:
| Step | Arithmetic | Result |
|---|---|---|
| datagrams per second | 50,000 ÷ 30 records | 1,667 |
| bytes per datagram on the wire | 1,464 payload + 8 UDP + 20 IPv4 | 1,492 |
| export rate | 1,667 × 1,492 × 8 | about 19.9 Mbit/s |
| one day | 19.9 Mbit/s × 86,400 s ÷ 8 | about 215 GB |
Templates make IPFIX records smaller or larger depending on what you choose: the 31-octet record above, packed 46 to a message under a 1,500-byte MTU (1,472 octets of UDP payload, minus the 16-octet header and a 4-octet set header, leaves room for 46), costs less than version 5's 48; add IPv6 addresses, interface indices, AS numbers and millisecond timestamps and it costs more. The collector's storage is the larger bill, and it is a choice of keys and retention, not of protocol.
What flows are for
RFC 3954 lists the uses as Cisco saw them in 2004: "enterprise accounting and departmental chargebacks, billing, data warehousing, network monitoring, capacity planning, application monitoring and profiling, user monitoring and profiling, security analysis, and data mining for marketing purposes" (RFC 3954, section 1). The IPFIX applicability statement, RFC 5472 of March 2009, groups them as accounting, traffic profiling, traffic engineering, network security and quality of service monitoring (RFC 5472, section 2). Three uses matter most in operations:
- Baselines and capacity. Who uses the uplink, and how that changes month to month; baselines without flows are totals without names.
- Attack detection. RFC 5472 notes that "A sudden increase of traffic load can be a hint that an attack has been launched", and that "A sudden increase of Flows from different sources to one destination" can mean an attack on one host (RFC 5472, section 2.4). Flow data is how most networks see a distributed denial-of-service () attack begin; what actually absorbs one is the next problem.
- Address translation logs. A carrier-grade () must record which subscriber held which public address and port, and IPFIX has elements for it: RFC 8158 (December 2017) defines a natEvent element with values such as "NAT44 session create" (4), "NAT ports exhausted" (12) and "Port block allocation" (16) and "de-allocation" (17) (RFC 8158, section 4). Why port blocks shrink those logs is in port blocks and port sets, and why the address alone no longer identifies anyone is in CGNAT and attribution.
What flows cannot do is just as clear. They carry no payload, so they cannot say what was in a request; for that you need a capture at the right point (capture points before packets). They are only as accurate as the sampling allows. And they see only what crosses an exporter: east-west traffic inside a switch that does not export, or inside a hypervisor, is not in them.
The security side
Flows as evidence. When the United States and the United Kingdom described Russian state-sponsored actors attacking routers in 2018, the detection advice was written in flow terms: "Review network device logs and netflow data for indications of UDP SNMP traffic directed at port 161/162 on all network-device hosts", and "Any correlation of inbound or spoofed SNMP closely followed by outbound should be cause for alarm" (CISA, Alert TA18-106A, 16 April 2018). In December 2024, six agencies writing to telecommunications operators after the campaign against them asked for "a strong network flow monitoring solution", with exporters and collectors "strategically centered around key ingress and egress locations" (CISA and partners, Enhanced Visibility and Hardening Guidance for Communications Infrastructure, 4 December 2024). The pair in the 2018 alert, SNMP in and TFTP out, is a two-line query against a flow store: records with destination port 161 to a router, followed within minutes by records with source the same router and destination port 69 to an outside address.
Flows as a target. Version 9 was "designed with the expectation that the Exporter and Collector would remain within a single private network", and its designers "did not impose any confidentiality, integrity or authentication requirements on the protocol". The RFC lists what follows: records observed in transit "can give an attacker information about the active flows in the network, communication endpoints and traffic patterns"; forged records can "defraud the service provider" or "prevent the detection of an attack"; forged templates can leave a collector "unable to decode the Export Packets"; and the collector itself can be flooded (RFC 3954, section 10). IPFIX answers with TLS for TCP and for UDP and SCTP, with mutual authentication, and where those are not used it says IPFIX over UDP "SHOULD be protected via segregation to a dedicated network" and that "the use of open Collecting Processes (those that will accept IPFIX Messages from any Exporting Process regardless of IP address or identity) is discouraged" (RFC 7011, sections 11.1 and 11.5). The dedicated network for management traffic is the subject of the next part.
Flows as personal data. RFC 7011 states it plainly: flow data "may be personally identifiable and privacy-sensitive", and its storage "must be protected via technical as well as policy means" (RFC 7011, section 11.8). RFC 6235 (May 2011, Experimental), by Elisa Boschi and Brian Trammell, describes how to anonymize flow records before they leave the operator's hands, by techniques such as truncation of addresses and prefix-preserving pseudonymization (RFC 6235, section 4). The legal side is in GDPR for network and security engineers, which counts a NetFlow export among the logs that usually hold personal data, and in LGPD for engineers.
The Brazilian angle
Brazil's Marco Civil da Internet (Law 12.965 of 23 April 2014) defines two kinds of record, and a flow record sits awkwardly between them. Article 5, item VI, defines the connection record as "the set of information referring to the date and time of the start and end of a connection to the internet, its duration and the IP address used by the terminal to send and receive data packets"; item VIII defines records of access to internet applications as "the set of information referring to the date and time of use of a given internet application from a given IP address" (Law 12.965/2014, the Marco Civil da Internet, article 5 (in Portuguese); our translation here and below). Article 13 requires the autonomous system administrator providing connection to keep connection records "in secrecy, in a controlled and secure environment, for a period of 1 (one) year"; article 14 says that "In the provision of connection, paid or free, it is forbidden to keep the records of access to internet applications"; article 15 requires application providers organized as companies to keep their access records for six months (Lei nº 12.965/2014, articles 13 to 15).
A flow record from a subscriber's address to port 443 of a server, with start and end times, holds more than the connection record of item VI. The law does not mention flow telemetry, and whether a connection provider's flow store counts as the "records of access to internet applications" that article 14 forbids it to keep is not answered by the text; no guidance from the Agência Nacional de Proteção de Dados () or from the Comitê Gestor da Internet no Brasil () on that question was found in what was read for this article. What the texts do make clear is that retention and purpose need a decision, made with counsel, before a provider keeps flow records for longer than operations require. How the same law treats NAT logs is in CGNAT and attribution.
On the operational side, 's programme for a safer internet uses flows as a detection tool. Its 2019 presentation to regional providers at ABRINT, describing routers compromised and used as proxies, tells providers to "increase the level of network monitoring to determine whether other devices on the network suffer from the same problem with the use of netflows, for example, monitoring the traffic on port 4145/tcp and observing an abnormal increase of connections to ports 25/tcp and 587/tcp" (Gilberto Zorello, NIC.br, Security for regional providers, ABRINT, São Paulo, 5 to 7 June 2019 (in Portuguese)). That is the flow query in one sentence: a port that should not be listening, and a jump in connections to mail submission ports, both visible without opening a packet.
What defenders can do
- Export at the edges first. Ingress and egress, where the 2024 guidance puts it (CISA and partners, 2024), then the data centre core.
- Decide the keys and the timers on purpose. Write down the active and inactive timeouts and the keys you export; the collector's reports depend on them, and two routers with different settings produce numbers that do not add up.
- Keep the exporter-to-collector path private. A dedicated or management network, or DTLS/TLS where the platform supports it, and a collector that accepts only known exporters (RFC 7011, sections 11.1 and 11.5).
- Watch the sequence numbers and the drops. Gaps in IPFIX sequence numbers are lost records; a rising sFlow
dropsis an agent overwhelmed. Either way, the numbers are low. - Scale sampled data, and say so. Store the sampling rate with every record, and show the error bound with every estimate drawn from few samples (sFlow.org, Packet Sampling Basics).
- Write the detections you will need. SNMP in and TFTP out from a network device (CISA, TA18-106A); a listener on an unexpected port and a jump in mail submission traffic (NIC.br, 2019); new flows to the management addresses from anywhere outside the management network.
- Treat the flow store as personal data. Access control, retention limits and, where data leaves the team, anonymization (RFC 7011, section 11.8; RFC 6235).
What to remember
- A flow is the set of packets that share the keys, usually the , at one observation point in one interval. It is unidirectional unless the exporter builds biflows.
- Records leave the cache on FIN or RST, on the inactive timeout, on the active timeout, or under pressure. Long flows arrive as many delta records.
- NetFlow v5: fixed 48-byte records, IPv4 only, 2-byte AS fields, 30 per datagram. v9: templates, FlowSet 0 and 1, sequence counts packets. IPFIX: version 10, Set 2 and 3, sequence counts data records, Enterprise bit, SCTP required, port 4739.
- No template, no decoding; over UDP, templates must be resent and collectors must expire them.
- sFlow samples packets at random 1 in N and exports headers plus counters; the error depends on the number of samples, roughly 196 × √(1/c) per cent.
- Flow data catches management-plane abuse (SNMP in, TFTP out) and is itself sensitive: protect the path, the collector and the store.
Sources
- B. Claise (ed.), RFC 3954, Cisco Systems NetFlow Services Export Version 9, IETF, October 2004, Informational, text: the IESG note, flow definition, expiration, transport, packet and FlowSet formats, field types, template management, security considerations, the example (accessed 23 November 2026)
- B. Claise, B. Trammell and P. Aitken (eds.), RFC 7011, Specification of the IP Flow Information Export (IPFIX) Protocol for the Exchange of Flow Information, IETF, September 2013, STD 77, text: Flow and Flow Key, message header, field specifier, sets, padding, reduced-size and variable-length encoding, UDP template management, transport, security and privacy (accessed 23 November 2026)
- B. Claise (ed.), RFC 5101, Specification of the IP Flow Information Export (IPFIX) Protocol, IETF, January 2008, text: the first IPFIX standard, obsoleted by RFC 7011 (accessed 23 November 2026)
- B. Claise and B. Trammell (eds.), RFC 7012, Information Model for IP Flow Information Export (IPFIX), IETF, September 2013, text: compatibility of identifiers 1 to 127 with NetFlow v9 (accessed 23 November 2026)
- IANA, IP Flow Information Export (IPFIX) Entities, Information Elements registry, CSV export: element definitions, counts and dates (accessed 23 November 2026)
- S. Leinen, RFC 3955, Evaluation of Candidate Protocols for IP Flow Information Export (IPFIX), IETF, October 2004, text: the five candidates and the recommendation (accessed 23 November 2026)
- J. Quittek, T. Zseby, B. Claise and S. Zander, RFC 3917, Requirements for IP Flow Information Export (IPFIX), IETF, October 2004, text: consulted for the requirements and date (accessed 23 November 2026)
- B. Trammell and E. Boschi, RFC 5103, Bidirectional Flow Export Using IP Flow Information Export (IPFIX), IETF, January 2008, text: Biflow records and the reverse PEN 29305 (accessed 23 November 2026)
- T. Zseby, E. Boschi, N. Brownlee and B. Claise, RFC 5472, IP Flow Information Export (IPFIX) Applicability, IETF, March 2009, text: application areas and attack detection (accessed 23 November 2026)
- G. Sadasivan, N. Brownlee, B. Claise and J. Quittek, RFC 5470, Architecture for IP Flow Information Export, IETF, March 2009, text: consulted for the architecture's terms (accessed 23 November 2026)
- T. Zseby, M. Molina, N. Duffield, S. Niccolini and F. Raspall, RFC 5475, Sampling and Filtering Techniques for IP Packet Selection, IETF, March 2009, text: systematic and random sampling, hash-based filtering (accessed 23 November 2026)
- E. Boschi and B. Trammell, RFC 6235, IP Flow Anonymization Support, IETF, May 2011, Experimental, text: anonymization techniques (accessed 23 November 2026)
- S. Sivakumar and R. Penno, RFC 8158, IP Flow Information Export (IPFIX) Information Elements for Logging NAT Events, IETF, December 2017, text: the natEvent values (accessed 23 November 2026)
- W. Eddy (ed.), RFC 9293, Transmission Control Protocol (TCP), IETF, August 2022, text: the control bits in the header (accessed 23 November 2026)
- P. Phaal, S. Panchen and N. McKee, RFC 3176, InMon Corporation's sFlow: A Method for Monitoring Traffic in Switched and Routed Networks, IETF, September 2001, Informational, text: authors, date and status (accessed 23 November 2026)
- Peter Phaal and Marc Lavine, sFlow Version 5, sFlow.org, July 2004, text: sampling mechanisms, XDR, port 6343, the datagram, flow_sample and counters_sample structures (accessed 23 November 2026)
- sFlow.org, Specifications for Developers, web page: deprecated versions and the extension structures (accessed 23 November 2026)
- Peter Phaal and Sonia Panchen, Packet Sampling Basics, sFlow.org, web page: the worked examples of sampling accuracy (accessed 23 November 2026)
- Cisco, NetFlow Export Datagram Format, NetFlow Collection Engine 3.6 User Guide, web page read through a WebFetch summary (direct copy refused): the version 5 header and record layout (accessed 23 November 2026)
- Google Patents, US6243667B1, Network flow switching and flow data export, Darren R. Kerr and Barry L. Bruins, Cisco Systems, filed 28 May 1996, web page: title, inventors and dates (accessed 23 November 2026)
- CISA, Alert TA18-106A, Russian State-Sponsored Cyber Actors Targeting Network Infrastructure Devices, 16 April 2018, web page: detection with netflow data (accessed 23 November 2026)
- CISA, NSA, FBI, ASD's ACSC, CCCS and NCSC-NZ, Enhanced Visibility and Hardening Guidance for Communications Infrastructure, 4 December 2024, web page: flow monitoring at ingress and egress (accessed 23 November 2026)
- Presidência da República, Lei nº 12.965, de 23 de abril de 2014 (Marco Civil da Internet), official text: articles 5, 13, 14 and 15 (accessed 23 November 2026)
- Gilberto Zorello, NIC.br, Segurança para provedores regionais: conheça as melhores práticas, ABRINT Nacional, São Paulo, 5 to 7 June 2019, PDF slides: netflows to find compromised devices (accessed 23 November 2026)