Anatomy of a Network Intrusion Detection System
A C++17 Capture → Parse → Detect → Alert pipeline with 147 tests; an end-to-end pipeline benchmark reports 4 to 8 million packets/sec on one thread with synthetic in-memory traffic; remaining limits are listed in its README.
Four stages with different costs
SentinelFlow implements a C++17 network intrusion detection pipeline: Capture → Parse → Detect → Alert. It supports libpcap live capture and offline pcap input, seven protocol parsers, basic Snort-inspired signatures, stateful heuristics, and console/CSV alerts.
Updated 17 November 2026. SentinelFlow pull requests #4 and #5 wired rule thresholds into the detectors, bounded per-source state, and added an end-to-end benchmark and a sanitizer job; the suite now has 147 tests. This page follows the repository after those changes.
Capture and protocol dissection
LiveCapture wraps pcap_open_live, compiles optional BPF expressions and installs them through libpcap. PcapFileReader uses pcap_open_offline. The actual capture/filter execution path depends on the platform and libpcap; this source audit did not measure kernel filtering or packet-copy savings.
The parser set covers Ethernet, IPv4, TCP, UDP, ICMP, DNS and ARP. Protocol headers have different lengths and dispatch rules, so the pipeline tracks the layers present in a parsed packet. Header parsing, DNS decoding, detection state and alert output should be assessed separately rather than described as one universally allocation-free operation.
Snort-inspired does not mean Snort-compatible
The rule parser accepts a small rule syntax with protocol/address/port fields and options. Basic signature matching checks the parsed fields, TCP flags and content patterns.
alert tcp any any -> any 22 (msg:"SSH connection attempt"; sid:1001;)The rule language is small. The action field is ignored, so every matching rule alerts; port ranges, negation and address lists are not supported; and rules with options the parser does not know are rejected. Threshold rules feed the stateful detectors: the SYN-flood threshold and window and the DNS name length come from the rules file, while the port-scan detector always uses its built-in values. The implementation is not a drop-in Snort rule engine.
Stateful heuristics
- Port scans: distinct destination ports per source within a time window; the trigger is fixed in code at 15 ports in 60 seconds.
- SYN floods: SYN packets without ACK counted over a window; the default rule triggers at 100 in 10 seconds.
- DNS tunnelling indicators: query names longer than the rule's length, 50 characters in the default rules, counted per source over a window.
Per-source state is bounded: idle records expire with their window, and each detector tracks at most 65,536 sources. When the table is full a heuristic chooses which record to drop, and an attacker who can spoof enough sources can still push a record out. These are heuristic indicators. Their presence does not establish false-positive rates, resistance to evasion or production detection accuracy.
Throughput
An end-to-end pipeline benchmark replays 10,000,000 synthetic Ethernet frames through framing, parsing, the default rules, the three stateful detectors and alert dispatch on one thread. The README reports 8.1 to 8.3 million packets/sec on an idle Apple M2 and 4.3 to 7.8 million across five runs on a shared GitHub-hosted runner. The traffic is built in memory, so libpcap, the network card and disk I/O are excluded; treat it as a yardstick for comparing changes, not a capacity statement. A separate parser benchmark covers header parsing only.
Alerts and verification
The alert layer can dispatch structured events to colour-coded console output and CSV logging. CSV export can support later analysis; the repository does not establish a deployed SIEM integration.
The repository has 147 tests covering the parsers, rule parsing and signature matching, the three stateful detectors and their state limits, and the pipeline end to end, from raw Ethernet frames to alerts. CI runs the suite and replays the sample captures under AddressSanitizer and UndefinedBehaviorSanitizer. There is no fuzzing, and the README lists the limits that remain: VLAN tags and IPv6 are not parsed, fragments and TCP streams are not reassembled, and packet timestamps are trusted.