Flow-Based DDoS Detection: Thresholds, Baselines, Automation
Flow-based DDoS detection works by comparing per-destination traffic rates, measured in packets per second (pps) and bits per second (bps), against thresholds and baselines, then triggering an alert or mitigation when the rates stay abnormal. Good detection depends less on the flow protocol you use and more on how you choose thresholds, how long you wait before acting, and what you automate.
This guide covers the tuning side: which metrics matter, how to build a baseline, how to avoid false positives, and how to wire detection to automatic mitigation without causing your own outage. For sampling rates and exporter choices, see our separate comparison of NetFlow, IPFIX, and sFlow.
What flow data can and cannot tell you
Flow records summarize conversations: source and destination IP, ports, protocol, TCP flags, packet and byte counts, and timestamps. They do not carry payloads. That makes flow good for volumetric and protocol-level attacks (UDP floods, amplification, SYN floods, ICMP floods, fragments) and weak for application-layer attacks that look like normal HTTP requests.
Two practical consequences:
- Detection is delayed by the export interval. With a 60-second active timeout, you may see an attack a minute late. Set the active timeout to 15–30 seconds on routers where the CPU allows it.
- With sampling, every number is an estimate. Multiply by the sampling rate and expect noise on small flows.
Measure pps first, bps second
Bandwidth-only thresholds miss the attacks that hurt most. A small-packet flood can saturate a firewall, router line card, or game server's network stack at a modest bit rate. A large-packet amplification flood does the opposite: high bps, moderate pps.
Track both, per destination IP (and per prefix for wider attacks). To convert sampled flow data:
pps = (sampled_packets × sampling_rate) / interval_seconds
bps = (sampled_bytes × 8 × sampling_rate) / interval_seconds
You can inspect a collector's data quickly with nfdump:
# Top destination IPs by packets in the latest capture file
nfdump -r /var/flow/nfcapd.202506011200 -s dstip/packets -n 10
# Narrow to UDP only
nfdump -r /var/flow/nfcapd.202506011200 -s dstip/packets -n 10 'proto udp'
Remember that nfdump shows raw sampled counts unless your collector is configured to scale them.
Build thresholds in layers
A single global number does not work. Use three layers instead.
- Static floor. A minimum rate below which you never alert, regardless of baseline. This stops a quiet server going from 50 pps to 500 pps from paging someone.
- Dynamic baseline. A rolling average of normal traffic per destination, with a multiplier.
- Hard ceiling. A rate your service or upstream link cannot tolerate, which triggers mitigation immediately.
An illustrative profile for a single game server at 203.0.113.10 (these values are examples, not recommendations):
| Metric | Floor | Baseline multiplier | Hard ceiling |
|---|---|---|---|
| Total pps | 20 kpps | 4× | 150 kpps |
| Total bps | 100 Mbps | 3× | 800 Mbps |
| UDP from source port 53/123/11211/1900 | 5 Mbps | n/a | 50 Mbps |
| TCP SYN-only pps | 5 kpps | 5× | 40 kpps |
| ICMP pps | 1 kpps | n/a | 10 kpps |
Derive your own numbers from at least two weeks of data, including your busiest day. Use the 95th or 99th percentile as "normal peak," not the average.
A simple baseline with EWMA
An exponentially weighted moving average adapts to gradual growth without chasing an attack. Update the baseline only when traffic is not flagged as an attack, or the attack will teach your system that it is normal.
ALPHA = 0.05 # smoothing; lower = slower to adapt
def update(baseline, sample, under_attack):
if under_attack:
return baseline # freeze during incidents
return ALPHA * sample + (1 - ALPHA) * baseline
def is_anomalous(sample, baseline, floor, mult, ceiling):
if sample >= ceiling:
return True
return sample > floor and sample > baseline * mult
Keep separate baselines by hour of week. Traffic at 20:00 on Saturday is not comparable to 04:00 on Tuesday.
Match on attack signatures, not just volume
Volume alone cannot tell a flash crowd from a flood. Add conditions that describe the shape of the traffic:
- Amplification: UDP with source ports 53, 123, 161, 389, 1900, 11211, and large average packet size (often over 400 bytes) toward a host that never made those queries.
- SYN flood: high ratio of SYN-only flows to total TCP flows, many unique source IPs, very low bytes per packet.
- Fragments: a surge in non-initial fragments (no port information in flow data).
- Reflection from few sources: many packets from a small set of source IPs, high pps per source.
- Source diversity: a sudden jump in unique source IP count to one destination is a strong flood indicator, while a legitimate surge usually comes from known client networks.
Requiring volume plus one signature condition removes most noise.
Reduce false positives
False positives are expensive when mitigation is automatic, because legitimate users get dropped. The most effective controls:
- Duration requirement. Require the condition to hold for 2–3 consecutive intervals (for example, 3 × 20 seconds) before acting. Short bursts from backups or CDN refills disappear.
- Per-destination profiles. A DNS resolver, a game server, and a web server have different normal traffic. Group hosts into profiles with their own thresholds.
- Expected traffic allow-lists. Exclude known heavy peers, backup targets, monitoring probes, and your own transit traffic from "source diversity" and "top talker" rules.
- Scheduled events. Game launches, software releases, and marketing campaigns create real surges. Add maintenance windows or raise ceilings temporarily.
- Sampling-error guard. Do not alert on flows with only one or two sampled packets. The scaled estimate is meaningless at that size.
- Direction check. Make sure you only evaluate inbound traffic to your prefixes. Asymmetric routing can make an outbound spike look like an inbound one.
- Review and tune. Log every alert with the metric, threshold, and verdict (true or false). Review weekly during the first month.
Automatic mitigation without self-inflicted outages
Automation should escalate in steps, with the least destructive action first.
- Alert only. Notify via chat or email with top sources, ports, and rates.
- Targeted filtering. Apply ACLs or FlowSpec rules for clear signatures, such as UDP source port 11211 toward the victim.
- Divert to scrubbing. Move the victim prefix to a scrubbing path through a BGP announcement or tunnel so clean traffic returns.
- Blackhole. Use RTBH as a last resort when the attack threatens the rest of your network. It completes the attack for that /32.
A minimal BIRD 2 example of a triggered blackhole, using the well-known blackhole community from RFC 7999 (confirm that your upstream honors it):
protocol static rtbh {
ipv4;
route 203.0.113.10/32 blackhole {
bgp_community.add((65535, 666));
};
}
Your detector adds or removes that route through a config include and birdc configure, or through ExaBGP.
Guardrails every automation needs
- Automatic expiry. Every mitigation gets a timer (for example, 15 minutes) and is re-evaluated, not left forever.
- Hold-down before release. Withdraw only after traffic stays below threshold for several intervals, to prevent flapping.
- Scope limit. Allow automation to act on a /32 or a single customer prefix, never on an aggregate containing infrastructure.
- Rate limit on actions. Cap how many mitigations can trigger per hour. A flood of triggers usually means a bad rule.
- Kill switch and audit log. Operators must be able to disable automation quickly, and every action must be recorded.
Common mistakes
- Using bps only. Small-packet floods slip through. Add pps.
- Forgetting the sampling rate. Thresholds in the collector must use scaled values.
- Letting attacks poison the baseline. Freeze updates during incidents.
- One threshold for every host. Use profiles.
- Acting on a single interval. Require persistence.
- No testing. Replay captured flow data or generate controlled traffic in a lab and confirm that detection fires and mitigation clears.
Where Nixcon fits
If you operate your own ASN and prefixes, NixMon provides flow-based network monitoring and DDoS detection, so you can apply per-destination thresholds and review traffic without building a collector stack yourself. For mitigation, the DDoS protection and firewall services give you a filtering path to pair with detection. Whatever tooling you use, apply the same principles: measure pps and bps, baseline per host, require persistence, and put guardrails around automation.
Frequently asked questions
What is a good DDoS detection threshold in pps?
There is no universal number. Measure your own traffic for at least two weeks, take the 95th–99th percentile as normal peak, and set the alert at a multiple of that, with a static floor and a hard ceiling based on what your servers and links can handle.
How long does flow-based detection take?
Detection delay is roughly the exporter's active timeout plus the collector's processing interval. With 15–30 second timeouts and a persistence rule of two or three intervals, expect detection within one to two minutes.
Can flow data detect application-layer (L7) attacks?
Only partially. Flow records show IPs, ports, and volumes, not HTTP content. Flow works well for volumetric and protocol attacks. For L7 floods, combine it with web server logs, a WAF, or rate limiting.
Is it safe to fully automate DDoS mitigation?
Yes, if you add guardrails: persistence requirements, scope limits to single hosts or prefixes, automatic expiry, hold-down before release, action rate limits, and a manual kill switch. Start with alert-only mode and enable automation after tuning.