flowscope
Passive flow & session tracking for packet capture.
flowscope is a runtime-free, cross-platform Rust library for observing
what's happening on the wire. It pairs with any source of &[u8] frames:
netring (Linux AF_PACKET / AF_XDP),
pcap files, tun/tap, eBPF, embedded — anywhere bytes show up.
No tokio, no futures, no async runtime in the core. (For tokio integration,
see netring's AsyncCapture::flow_stream etc., which consume this crate's
traits.)
What's here
PacketView → FlowExtractor → FlowTracker → Reassembler → SessionParser / DatagramParser
↑ ↓
anything typed L7 messages
Core (always on):
FlowExtractortrait + built-in extractors (5-tuple, IP-pair, MAC-pair) + decap combinators (VLAN, MPLS, VXLAN, GTP-U, GRE) +AutoDetectEncapcombinator +FlowLabelIPv6 augmentation.FlowTracker— bidirectional flow accounting, TCP state machine, idle timeouts, LRU eviction.Reassembler— sync per-(flow, side) hook for TCP byte streams.SessionParser/DatagramParser— typed L7 message parsing per flow.
Protocol parsers (each behind its own feature):
| Feature | What you get |
|---|---|
http |
HTTP/1.x request/response parsing — both HttpFactory (callback) and HttpParser (SessionParser) |
tls |
TLS handshake observer (ClientHello/ServerHello/Alert) — passive only, no decryption |
ja3 |
JA3 client fingerprinting (sub-feature of tls) |
dns |
DNS message parser, per-flow query/response correlator. UDP via DnsUdpParser (DatagramParser); TCP via DnsTcpParser (SessionParser, RFC 1035 §4.2.2 length-framed) |
pcap |
pcap file source for offline replay |
full |
All of the above |
Quick start
[]
= { = "0.3", = ["full"] }
use FiveTuple;
use PcapFlowSource;
use FlowEvent;
#
For HTTP / TLS / DNS examples and the typed SessionParser / DatagramParser
APIs, see examples/ and the per-module documentation on docs.rs.
Custom protocols
For an end-to-end example of writing a SessionParser for your own
wire format — including the synchronous offline pcap path via
FlowSessionDriver —
see examples/length_prefixed_pcap.rs. The example demonstrates a
length-prefixed binary protocol (PSMSG-shaped) with two
variable-length markers and is paired with a deterministic pcap
fixture under tests/fixtures/length_prefixed/.
Tokio integration
flowscope itself is runtime-free. To consume a live capture into a stream
of FlowEvent / SessionEvent via tokio, use netring:
use AsyncCapture;
use FiveTuple;
use HttpParser;
use StreamExt;
# async
Status
0.3.0 published — "production hardening" release. Core flow APIs
(FlowExtractor, FlowTracker, Reassembler,
SessionParser, DatagramParser) are settled; SessionEvent
and EndReason are #[non_exhaustive] so future variants are
additive.
0.3.0 ships:
FlowDatagramDriver— sync mirror of netring'sdatagram_stream.- Sync-side
Dedupprimitive +with_dedupbuilder on both drivers. - Per-key idle-timeout predicate (
with_idle_timeout_fn). - Live
FlowStatssnapshots (snapshot_flow_stats) with reassembler high-watermark. - Opt-in monotonic timestamps (
with_monotonic_timestamps). - Parser fallibility (
is_poisonedon both parser traits) → synthesisedEndReason::ParseError. SessionEvent::Anomalyforwarding through the session driver.- Optional
tracing-messagesCargo sub-feature for per-Application trace events. - Criterion benchmark harness under
benches/(run withcargo bench); baseline numbers indocs/PERFORMANCE.md.
See docs/SESSION_GUIDE.md for the
decision-flow on which API to pick, and
docs/OBSERVABILITY.md for the metric
vocabulary.
0.2.0 features remain: buffer caps with SlidingWindow /
DropFlow policies, per-flow reassembly diagnostics, live
FlowEvent::Anomaly stream, FlowSessionDriver,
metrics / tracing features, hot-cache fast path.
License
MIT OR Apache-2.0, your choice.