PacketSense
A Wireshark-style traffic explorer where you search network sessions by behaviour.
| Industry | Level | Difficulty | Recommended mode |
|---|---|---|---|
| Cybersecurity | 3 of 5 | Advanced | hnsw |
The problem
Section titled “The problem”- Packet captures are huge, and display filters only work if you already know what to look for.
- A command-and-control beacon hides among normal-looking HTTPS sessions.
- There is no way to ask: “show me all traffic that behaves like this session”.
How SrvDB powers PacketSense
Section titled “How SrvDB powers PacketSense”- Zeek or tshark turn traffic into flow records; each flow becomes a vector of behaviour features (duration, bytes each way, packet-size and timing statistics, ports, protocol) and/or an embedded text summary.
- SrvDB stores millions of these with
hnswfor fast search, andsq8keeps the store 4× smaller. - Query by example (pick one session, find similar ones) or by description (a text query against embedded flow summaries).
- Sessions far from every known-normal session are surfaced as anomalies.
What changes
Section titled “What changes”| Today | With PacketSense on SrvDB |
|---|---|
| Filters need exact field names and values | Point at a session or describe it, and get the similar ones |
| One beacon found means a manual hunt for the rest | One search finds every session that behaves like it |
| Anomaly baselines are hand-built | Distance from stored normal traffic does the work |
How it works
Section titled “How it works”- Capture with tcpdump, Zeek or tshark (SrvDB does not capture packets).
- Convert each flow into features and a short text summary.
- Embed and store with flow id, endpoints and time as metadata.
- Explore: query by example or by description in a notebook or small web UI.
- Label findings and
upsertthem so later searches benefit.
SrvDB features it uses
Section titled “SrvDB features it uses”- HNSW graph (
hnsw): approximate search that visits a small part of large collections; tune withset_ef_search(). - SQ8 compression (
sq8): stores each value in one byte, 4× smaller than full precision. search_batch: runs many queries at once, in parallel inside Rust.- Thread-safe handles: one database object can be shared between threads; searches run in parallel.
upsert: inserts new items and replaces changed ones, so the knowledge base stays current.- Crash-safe
persist(): after it returns, data survives a crash or power loss and reopens exactly as committed.
Use cases
Section titled “Use cases”- Find every session similar to a known C2 beacon
- Spot flows that look like DNS tunnelling
- Find lateral-movement sessions resembling a past incident
- “HTTPS sessions with long idle gaps and small regular packets”
- Per-segment baselines of normal traffic
- Triage IDS alerts with the most similar past flows
- Saved hunting queries in a notebook
Core code
Section titled “Core code”embed() is your embedding model (for example sentence-transformers, or a function that turns your records into feature vectors).
import jsonimport srvdb
db = srvdb.Database("./packetsense-db", dimension=128, mode="hnsw")
def ingest(items): """items: list of (id, text, metadata dict)""" db.upsert( ids=[i for i, _, _ in items], embeddings=[embed(t) for _, t, _ in items], metadatas=[json.dumps(m) for _, _, m in items], ) db.persist() # crash-safe checkpoint
def similar_sessions(session_summary, k=5): hits = db.search(embed(session_summary), k) return [(json.loads(db.get(i)), round(score, 3)) for i, score in hits]Limits and honest notes
Section titled “Limits and honest notes”- SrvDB does not capture or decode packets; Zeek, tshark or similar tools do.
- Encrypted payloads leave metadata and timing only; results depend on the features you choose.
- Check
hnswrecall againstflaton a sample before relying on it.
Build roadmap
Section titled “Build roadmap”- Prototype: load a sample of real data with
flatmode and check that searches return what an expert expects. - Measure: if you move to an approximate mode, compare its results with
flaton the same queries (recall). - Pipeline: add continuous
upsertand decide when to callpersist(). - Harden: test restarts and crashes, add logging, review every output path with domain experts.
- Deploy: ship the database directory with the application or service.
All Cybersecurity projects
Section titled “All Cybersecurity projects”| Level | Project | What it does |
|---|---|---|
| 1 · Beginner | SOC Copilot | A knowledge assistant that answers analysts’ questions from your own runbooks, incidents and policies. |
| 2 · Intermediate | Phishing Hunter | Catches reworded phishing by meaning, not by exact strings. |
| 3 · Advanced | PacketSense (this page) | A Wireshark-style traffic explorer where you search network sessions by behaviour. |
| 4 · Expert | Threat Hunter Agent | An autonomous hunting agent that reasons across network, endpoint and threat-intel memory. |
| 5 · Frontier | Air-gapped OT Sentinel | Offline anomaly detection for industrial control networks, running on edge gateways. |
See also: Use cases · Live examples (coming soon)