NetFlow and IPFIX traffic (netflow)
Sums the flows that a router, switch or firewall exports as NetFlow v5, NetFlow v9 or IPFIX, over a sliding window: how much traffic there is, who the biggest sources, destinations, conversations and services are, and how the traffic splits into TCP, UDP, ICMP and the rest. It can look at the whole device or at one interface of it, in one direction. Every number is a channel, so limits apply: "the biggest source is more than 60 % of the traffic", "UDP above 50 Mbit/s on the uplink", "nothing exported for five minutes".
Like the trap and syslog sensors it listens instead of asking, but it keeps something different: not the messages, never a flow, only per-interval top lists. The design, the limits and the arithmetic of the memory they need are in architecture. This page is about the sensor. For sFlow see the sflow sensor.
What it looks like

The sensor's page after a few polls, with "Who talked" above the channels: one entry for the intervals since the last poll, with the biggest sources, destinations, conversations and services, each with its share, and the protocol mix. The device exported IPFIX for seven made-up talkers. In the dark theme: the sensor's page. The form for adding it, with its parameters filled in: light, dark.
How it counts
The probe listens on UDP port 2055 once the first netflow sensor exists. Each datagram is read, its flows added to the tables of the current interval (one minute) of the exporter that sent it, and forgotten. When an interval ends, only its top entries are kept. Each poll adds up the finished intervals of the last window_secs and divides by the time the probe has been watching the device, so:
- Only finished intervals count. A poll in the middle of a minute does not see that minute yet. The first poll of a sensor has nothing to show: the rates are unknown and the message says
Collectinguntil one whole interval has passed since the probe began to watch the device. - Traffic before the first poll is not seen, and neither is traffic while the probe is down. A restart of the probe is a gap in the counts, never a page.
- A device is the address its datagrams come from. A router that exports from another address than the one it is monitored on needs that address in
extra_sources. A datagram from an address no sensor names is dropped before it is read. - Sampling is scaled. A device that samples (NetFlow v5's sampling field, a v9 or IPFIX options record) is multiplied by its interval, and the message says
sampled 1 in N, so the counts are estimates. For a device that samples without saying so, setsampling_rate. - Several sensors may watch one device, for example one for the whole device and one for each uplink. Each
interfaceasks the probe to keep one more set of tables for that device, at most 16 besides the whole device.
What the top lists are: a source and a destination are IP addresses; a conversation is one direction between two hosts for one service; a service is an IP protocol and the server's port (tcp/443), where the server's port is the lower of the two ports when it is below 49152 and otherwise unknown (tcp/ephemeral). A flow with no ports, such as ICMP, is its protocol alone.
The top lists of a window are the sums of the top lists of its intervals. A host that was big in one minute and below the top 20 in the others is counted for the minutes it was in. For a window of a few minutes that is a small difference; the totals (bits_per_s and the protocol mix) are exact for what the device exported.
Channels
| Key | Name | Unit | Default limits |
|---|---|---|---|
bits_per_s | Traffic | bit/s | none |
packets_per_s | Packets | packets/s | none |
flows_per_s | Flows | flows/s | none |
top_source_bps, top_source_share_pct | Top source, and its share of all traffic | bit/s, % | none |
top_destination_bps, top_destination_share_pct | Top destination, and its share | bit/s, % | none |
top_conversation_bps, top_conversation_share_pct | Top conversation, and its share | bit/s, % | none |
top_service_bps, top_service_share_pct | Top service, and its share | bit/s, % | none |
tcp_bps, udp_bps, icmp_bps, other_bps | Traffic by protocol class | bit/s | none |
active_sources | Distinct source hosts in the busiest interval | hosts | none |
since_last_flow_s | Time since the device last sent a flow the probe could read | s | none; unknown before the first |
dropped | Datagrams dropped by the rate limit | none | warning above 0 |
lost | Datagrams (v9) or flows (v5) missing from the device's sequence numbers | none | warning above 0 |
unreadable | Datagrams that could not be read | none | warning above 0 |
undecoded | Data sets that had no template | none | none |
Which host or service is the top one is in the sensor's message and in the "Who talked" entries, not in the channel: a channel is a number, and a number that changes its meaning from one poll to the next would make a poor history. The shares are unknown when there was no traffic. The limits that suit a site are a decision, so only the three counters of trouble have a default: set limits on the sensor's page, or from a template.
Examples worth setting:
top_source_share_pctabove 60 (warning): one host is most of the traffic.udp_bpsabove a number: a flood or a backup that went to the wrong place.since_last_flow_sabove 300: the device stopped exporting (a router that rebooted, a firewall rule, a changed collector address). Silence is a reading and not a failed poll, so this limit is how to be told.active_sourcesabove a number: a scan.
undecoded is normal for a short time after the probe starts: a NetFlow v9 or IPFIX exporter sends its templates every few minutes, and data that arrives before the next one cannot be read. It stays at 0 once the templates are known. If it does not, the exporter does not send its template (or sends it only once, at start-up): set its template refresh.
Parameters
| Parameter | Default | Meaning |
|---|---|---|
window_secs | 300 | How far back each poll sums, 60 to 86400. The probe keeps intervals for an hour by default (PROBEWARD_FLOW_RETENTION_SECS); a longer window is cut to that, and the message says so. |
interface | none (the whole device) | Count only traffic that entered or left by this interface, by its SNMP interface index. |
direction | either | With an interface: in, out or either. |
extra_sources | none | More addresses the device exports from. Up to 16. |
sampling_rate | none | The sampling interval to assume for a device that samples and does not say so, 1 to 1000000. |
top_n | 5 | How many entries of each list the message and the "Who talked" entries carry, 1 to 10. |
Suggested interval: 60 seconds. No credential. Keep the window at least as long as the poll interval and at least two intervals long, so that a poll always has something to add up.
Who talked
Each poll that finds intervals it has not reported yet keeps one entry for them, and the sensor's page lists the newest first (GET /api/v1/sensors/{id}/events returns the same). It is the history of who the big talkers were, and the only thing kept beyond the channels:
{
"from": "2026-11-30T10:00:00Z", "to": "2026-11-30T10:02:00Z", "seconds": 120,
"bytes": 2100000, "packets": 21000, "flows": 20, "bits_per_s": 140000,
"active_sources": 2, "approximate": false, "sampling": null,
"sources": [{"host": "192.0.2.10", "bytes": 1800000, "packets": 18000, "share_pct": 85.7}],
"destinations": [{"host": "198.51.100.20", "bytes": 2100000, "packets": 21000, "share_pct": 100.0}],
"conversations": [{"source": "192.0.2.10", "destination": "198.51.100.20", "protocol": "tcp", "port": 443,
"service": "tcp/443 (https)", "bytes": 1800000, "packets": 18000, "share_pct": 85.7}],
"services": [{"protocol": "tcp", "port": 443, "service": "tcp/443 (https)", "bytes": 1800000, "packets": 18000,
"share_pct": 85.7}],
"protocols": [{"protocol": "tcp", "bytes": 1800000}, {"protocol": "udp", "bytes": 300000}]
}A sensor keeps at most 1,000 entries, and the timeline's retention applies. They hold addresses and ports of your network's traffic and nothing else: no flow, no payload, no user name. Anyone who may read the sensor may read them.
What is read
| Version | Read |
|---|---|
| NetFlow v5 | Source and destination address, ports, protocol, packets, bytes, input and output interface, the sampling field of the header. At most 30 records per datagram. |
| NetFlow v9 | Templates and options templates; data sets by template. Address (IPv4 and IPv6), port, protocol, bytes (field 1, or 85 or 23), packets (2, 86 or 24), interfaces (10, 14), the sampling interval (34, 50) of an options record. Every other field is skipped by its length. |
| IPFIX | The same, with variable-length and enterprise-specific fields, template withdrawal, sampling interval (34, 50, 305), physical interfaces (252, 253) as a fallback. |
Template handling: a template is keyed by exporter, observation domain and template id; it is kept for 30 minutes after the exporter last sent it (PROBEWARD_FLOW_TEMPLATE_SECS), replaced when it is sent again and dropped when the exporter withdraws it. A template with more than 256 fields, one whose records could take no bytes, and more than 64 templates or 8 domains from one exporter are refused, and the datagram that carried them is counted as unreadable. NetFlow v9 and IPFIX over UDP only. IPFIX over TCP or SCTP, NetFlow v1, v7 and v8, and IPFIX bidirectional flows (reverse information elements) are not read.
What the exporter needs
Point the device at the probe's address, UDP port 2055 (or the port in PROBEWARD_FLOW_LISTEN, which is above 1023, so no privilege is needed), and let the firewall between them pass it. Examples:
# MikroTik RouterOS
/ip traffic-flow set enabled=yes interfaces=all
/ip traffic-flow target add dst-address=192.0.2.1 port=2055 version=ipfix
# VyOS (NetFlow v9 or v5; this is the flow-accounting service, for sFlow see the sflow sensor)
set system flow-accounting interface eth0
set system flow-accounting netflow version 9
set system flow-accounting netflow server 192.0.2.1 port 2055
set system flow-accounting netflow timeout expiry-interval 60
# Linux, with softflowd
softflowd -i eth0 -n 192.0.2.1:2055 -v 9The RouterOS lines are what the lab's router runs. The VyOS and softflowd lines are written from their documentation and were not run for this page; check them against your version.
Set the active timeout of the device to a minute or two: a long-lived flow is exported when it ends or when its active timeout expires, and the sensor attributes the whole flow to the interval in which it arrives, not the one in which it happened. A device with a 30-minute active timeout shows a long transfer as one burst every half hour.
Capacity
Measured, not estimated: the_cost_of_a_flow_is_small in proto/flow/store.rs feeds the store 60,000 NetFlow v5 flows in datagrams of 30, for a device with two scopes, every flow a new conversation (so the tables are full and being replaced for nearly all of them, the worst case). On the development machine, a release build and one core, it takes 0.34 microseconds a flow, about three million flows a second, including reading the datagram. The rate limit lets one exporter send 2,000 datagrams a second, so at 30 flows a datagram (NetFlow v5's most) 60,000 flows a second are read and the rest are counted as dropped. The CPU of a probe is therefore bounded by the number of exporters it watches (256 by default) and the datagram rate, not by the traffic the exporters describe, and the cost of reading 256 exporters at their limit is well below one core.
Memory, from the limits: the interval being filled holds at most three tables of 1,024 keys and one of 512 per watched scope, about 300 KiB with the hash tables' spare room, so 256 exporters with one scope each need at most about 80 MiB for the tables being filled. Finished intervals hold at most 20 entries in each of four lists, at most about 6 KiB counted generously, so an hour of one scope is at most about 350 KiB, and all of them together are held to 64 MiB (a probe with many busy exporters therefore keeps less than an hour of each). A probe with a few routers uses a few MiB. What reaches the database is a poll's channel values (about 20 numbers) and at most one summary event of a few kilobytes, so a sensor that polls every minute adds at most one such event a minute, and the event table keeps 1,000 per sensor, about 4 MB at the most.
What the probe cannot keep up with is lost in the kernel's receive buffer before the collector sees it. The socket asks for 4 MiB, which holds about 2,700 full-sized datagrams; lost counts the gaps in the sequence numbers of NetFlow v5, v9 and sFlow datagrams (IPFIX counts records, which cannot be known for data that has no template yet), so a probe that is too slow shows it.
Failures
| Message | Meaning |
|---|---|
cannot listen for NetFlow and IPFIX on UDP 0.0.0.0:2055: another program on this host holds it ... (kind config) | Another collector has the port. Stop it, or set PROBEWARD_FLOW_LISTEN. |
cannot listen for NetFlow and IPFIX on UDP ...: permission denied (kind config) | PROBEWARD_FLOW_LISTEN names a privileged port. See the message. |
this probe already watches N flow exporters, the most it keeps (kind config) | PROBEWARD_FLOW_EXPORTERS is reached. |
this exporter already has 16 interfaces watched by sensors, the most the collector keeps (kind config) | One device has too many sensors with an interface. |
Nothing else fails a poll. No traffic is a reading: the rates are 0 and since_last_flow_s grows.
Verification
- A real device. A MikroTik RouterOS 7 Cloud Hosted Router exported IPFIX to a probe listening on port 2055. Its templates (an IPv4 one of 37 fields and an IPv6 one of 34, most of them fields this decoder does not use) were read from the wire, and the field list is a test (
a_template_with_many_unused_fields_is_stepped_over_by_length). The router sends a template now and then and not with every datagram: data that arrived before the first one was counted asundecodedand said so in the sensor's message, and the flows were read once it came. The traffic was many short TCP connections to the router, which it exports after its inactive timeout. A continuous ping was not exported at all until it ended, because RouterOS holds a flow for its active timeout (30 minutes by default); that is why the section above tells you to shorten it. The live test iscrates/probeward-sensors/tests/live_flows.rs. - Hand-made datagrams, byte by byte, for NetFlow v5, v9 and IPFIX: templates and their expiry, replacement and withdrawal; options templates; variable-length and enterprise fields; IPv6; a template with fields it has never heard of; sampling in the v5 header and in an options record; the limits on fields, templates, domains and records. Every truncation of a valid datagram, 30,000 mutated ones and 30,000 random ones are read without a panic.
- Real sockets on loopback: v5 and IPFIX on one port, data that arrives before its template, an exporter nobody watches ignored, a flood cut at the rate limit and counted, a port another program holds, too many exporters.
- The store with a scripted clock: intervals, what counts as watched, scopes for interfaces, sampling, the bounds of the tables under a scan, retention and the byte budget, the sequence gaps. The sensor against a scripted collector: the channels, the message, the summary events once each.
- Not seen: NetFlow v5 or v9 from a real device (they are built by hand), IPFIX from any other make, IPv6 flows from a real device, templates over hours with expiry, a device that sends faster than the rate limit, IPFIX over TCP or SCTP, a remote probe's collector.
Running the live test
crates/probeward-sensors/tests/live_flows.rs runs the real sensors with the real collector against a device that exports to the test machine. It skips, saying so, when its variables are not set.
| Variable | Meaning |
|---|---|
PROBEWARD_TEST_FLOW_NETFLOW_SOURCE | The address a device exports NetFlow or IPFIX from. Turns the NetFlow test on. |
PROBEWARD_TEST_FLOW_SFLOW_SOURCE | The address a device exports sFlow from. Turns the sFlow test on. |
PROBEWARD_TEST_FLOW_SFLOW_RATE | Optional: the sampling rate that device is set to; the sensor's message must say so. |
PROBEWARD_TEST_FLOW_INTERFACE | Optional: an interface index the sFlow device exports; a second sensor for that interface alone must see traffic too. |
PROBEWARD_TEST_FLOW_WAIT_SECS | How long to wait for traffic, default 120. |
Run it with PROBEWARD_FLOW_INTERVAL_SECS=5 and make the device carry traffic while it waits (ping through it, or log in to it):
PROBEWARD_FLOW_INTERVAL_SECS=5 cargo test -p probeward-sensors --test live_flows -- --nocapture