The idea: watch the traffic, compare, raise an alert
A firewall decides which connections may pass. An intrusion detection system (IDS) looks at the traffic that does pass and asks: does any of this look like an attack? It has two ways to decide. A signature engine compares the traffic with rules that describe known bad things. An anomaly engine learns what normal traffic looks like and flags what is far from normal. Either way the result is an alert: a line in a log that a person or a SIEM reads.
Reading the canvas: at the top is the network, with the sensor on a tap (IDS) or in-line (IPS). On the left are the signature rules and the event stream, one row per minute from 09:00 to 09:11, with the truth (attack or benign) and how each engine scored it. On the right are the anomaly chart (8 training minutes, then the 12 live minutes, with the mean line and the red threshold line), the alert log and the score table. The detector, threshold and sensor menus restart the stream with new settings.
Signature rules
A Snort or Suricata rule has three parts: an action (alert, or drop on an in-line sensor), a header (protocol, source, direction, destination and port) and options in brackets that say what to look for. The page uses three toy rules:
alert http any any -> $HOME_NET 80 (msg:"known scanner user-agent";
http.user_agent; content:"BadBot"; sid:1001;)
alert tcp any any -> $HOME_NET 22 (msg:"SSH connection burst"; flags:S;
detection_filter:track by_src, count 5, seconds 60; sid:1002;)
alert tcp any any -> $HOME_NET 23 (msg:"telnet to server"; sid:1003;)
content looks for bytes in a field, flags:S picks SYN packets (new TCP connections), and detection_filter only fires once one source has sent 5 of them in 60 seconds. Rule 1001 catches the BadBot scanner at 09:02 even though it sends almost nothing (Demo 2). Rule 1002 catches the SSH guessing at 09:07, and also the developer whose deploy script reconnected 5 times at 09:01: a false positive. The ScanKit tool at 09:05, 09:08 and 09:09 matches no rule, because nobody has written one yet. A signature engine is only as good as its rule set, and new rules arrive after a tool is seen, not before.
The baseline, the mean and the z-score
The anomaly engine first watches 8 quiet training minutes and records one number per minute, here requests per minute: 39, 43, 35, 41, 45, 37, 41, 39 (Demo 1). Their mean is 320 / 8 = 40. Their standard deviation says how far a normal minute strays from the mean: the deviations are −1, 3, −5, 1, 5, −3, 1, −1, their squares add up to 72, and √(72 / 8) = 3.
For each live minute the engine computes the z-score, the distance from the mean in standard deviations: z = (requests − 40) / 3. The 09:05 flood has z = (70 − 40) / 3 = 10.00, far outside anything seen in training. The engine alerts when z reaches a threshold k. It needs no rule, so it catches the new tool; but the BadBot probe (z = 0.00) and the SSH guessing (z = 0.33) are invisible to it, because they don't change the volume of web requests. (Box Plots and Outliers shows the same "far from the middle" idea with quartiles instead.)
Scoring the alerts
Each minute has a truth: 5 of the 12 hold an attack. Each engine either alerts or stays quiet, so every minute is a true positive (TP, alert on an attack), a false positive (FP, alert on benign traffic), a false negative (FN, a missed attack) or a true negative (TN). Precision = TP / (TP + FP) is the share of alerts that were real; recall = TP / (TP + FN) is the share of attacks that were caught.
| Detector | Alerts | TP | FP | FN | TN | Precision | Recall |
|---|---|---|---|---|---|---|---|
| signature (Demo 2) | 3 | 2 | 1 | 3 | 6 | 0.67 | 0.40 |
| anomaly z ≥ 3 (Demo 3) | 2 | 2 | 0 | 3 | 7 | 1.00 | 0.40 |
| anomaly z ≥ 2 (Demo 4) | 4 | 3 | 1 | 2 | 6 | 0.75 | 0.60 |
| either, z ≥ 2 (Demo 6) | 7 | 5 | 2 | 0 | 5 | 0.71 | 1.00 |
The two engines miss different attacks, so together they catch all 5 (Demo 6), at the price of both engines' false positives. The general trade-off between precision and recall is on Precision and Recall, and the view over every threshold at once is on ROC Curves and AUC.
Moving the threshold
At z ≥ 3 the red line sits at 40 + 3 × 3 = 49 requests: only the flood (70) and the scrape (50) cross it, and both are attacks, so precision is 1.00. Lower it to z ≥ 2, at 46 requests (Demo 4): the slow crawl at 09:09 (exactly 46, z = 2.00) is now caught, but so is the promo e-mail at 09:04 (47 real customers, z = 2.33). Recall goes from 0.40 to 0.60 and precision drops from 1.00 to 0.75.
A real sensor sees millions of events a day, and almost all of them are benign. Even a small false-positive rate then means many false alerts for each real one (the base-rate problem). Analysts who see mostly false alerts start to ignore them, so thresholds are tuned, rules for noisy cases are made stricter, and known-good sources are written into exceptions.
On a tap or in-line
Where the sensor sits decides what it can do. An IDS on a tap or a switch's SPAN (mirror) port gets a copy of each packet. The original has already gone on to the server, so the IDS can only alert. If the sensor is slow or down, traffic is not affected. An IPS sits in-line, on the path, so every packet goes through it and it can drop what a rule matches. Then the rules' action is drop (Demo 5): the BadBot probe and the SSH guessing never reach web1, and only 3 of the 5 attack minutes get through. But the developer at 09:01 is dropped too: an in-line false positive is an outage for a real user, not just a wasted look.
| IDS on a tap | IPS in-line | |
|---|---|---|
| sees | a copy of each packet | each packet, before the server |
| can | alert | alert and drop |
| a false positive costs | an analyst's time | a blocked real user |
| if the sensor fails | traffic flows, unwatched | traffic stops (fail-closed) or bypasses it (fail-open) |
That is why the page's IPS drops only on signature matches: an anomaly score is a statistical guess, and dropping on it would have cut off the 09:04 promo customers. Many sites run precise rules in drop mode and keep the rest, including anomaly alerts, in alert mode.
Alerts feed the log
Each alert becomes one line with the time, the rule id ([1:1001] is generator 1, sid 1001), the message and the source and destination. Snort and Suricata write lines like these to fast.log, and Suricata also writes JSON events to eve.json for a SIEM. An alert is only useful if someone reads it and acts, with enough context to tell the developer from the attacker; OWASP A09 Logging and Alerting Failures follows what happens when nobody does. A sensor's view also depends on the firewall in front of it: Stateful Firewall shows what reaches it in the first place.
See also HMAC vs Naive Keyed Hash: Length Extension for how message tags stop forged messages before any detection is needed.
See also Flow Monitoring with NetFlow and IPFIX, where a port scan shows up in flow records as many one-packet SYN flows from one source.
See also port scanning from the defender's side, where an IDS on a tap raises PORTSCAN and ODD-FLAGS alerts for every kind of probe.
What the page leaves out
The page judges whole one-minute windows by one number. Real sensors decode protocols, reassemble TCP streams and judge single packets and flows, and a real rule set has tens of thousands of rules with thresholds and suppressions. Real baselines track many measures (bytes, ports, new destinations, login times), change with the time of day and the day of the week, and are often learned by machine-learning models rather than a single mean. Attackers who know a baseline can ramp up slowly so that it learns the attack as normal. The page also leaves out host-based IDS (file integrity, system call monitoring), encrypted traffic (a sensor sees little inside TLS unless it decrypts it), how sensors keep up at high speed, and the work of tuning rules and triaging alerts.