ChloeDB
Apps

chloedb-packets: what went wrong in a capture

Reference, rendered from docs/chloedb/packets.md.

These docs follow main, which can be ahead of the latest release, 0.3.11 (its docs): a change made after it says so where it is described.

On this page
  1. What is kept
  2. The samples
  3. Run it
  4. Capture live
  5. A daily report of what talked
  6. Has this happened before
  7. Compare two captures
  8. The story of a capture
  9. Where your traffic went
  10. Alerts written as SQL
  11. The tables
  12. Tests

A demo. chloedb-packets shows what ChloeDB can do; it is not part of ChloeDB's releases or their promises. It is tested on a train of its own (the Demos workflow, .github/workflows/demos.yml), outside CI's required check, and the command center marks it as a demo (compatibility).

chloedb-packets is a packet explorer: a capture (a .pcap or .pcapng) is decoded by tshark, Wireshark's own dissectors, into rows of ChloeDB tables, and the page reads them as Wireshark would, then goes further and says what went wrong in each conversation, at the packet that shows it. It is a program of its own, in Rust, that talks to chloedb-server over HTTP, like the backbone explorer, and the command center shows it as an app.

  • Every packet, filtered as in Wireshark. The display filter bar takes Wireshark's filters (ip.addr == 10.0.0.0/8 && tcp.port == 443, tcp.analysis.retransmission, dns.flags.rcode != 0, http.request.uri contains "login", tcp.stream eq 12, a protocol named alone), turns green as it reads and red with where it stops, and shows the SQL it became. Words that are not a filter are looked for in the Info column. The packet list is colored by Wireshark's default rules, a click opens the packet's fields (each with apply as filter and and), and Wireshark's full tree and bytes of that packet, cut from the capture with its flow's earlier packets so that TCP's analysis reads as it would in the whole file.
  • When it happened. A timeline of the packets that match, stacked by protocol; drag to keep a window.
  • Conversations and what went wrong in each. Every TCP connection, UDP exchange and ICMP pair is a flow, checked for connections refused, unreachable (with the ICMP error that said why) or never answered, slow handshakes, resets (and whether they followed a goodbye), retransmissions, zero windows, stalls that waited out a retransmission timeout, slow or failed DNS answers, HTTP errors and slow answers, SIP errors, and for a call's audio, gaps, lost packets and jitter (RFC 3550). Each finding says what it means and links the packet that shows it. A flow's page has its bytes over time each way with those packets marked, its packets, its filter for Wireshark, and the flows shaped like it.
  • Hosts. Every address, the names it went by (DNS answers, TLS server names, HTTP hosts) and who it talks to, as a graph to pan, zoom and rearrange; a line between two hosts opens all their traffic below it (/v1/capture/CAP/edge?a=A&b=B: what passed each way, their packets on a timeline and in a list, picked by ip.addr == A && ip.addr == B, and their flows), and a host's neighbours are found by personalized PageRank (ppr) over the conversations.
  • Odd traffic. Each flow is a vector of sixteen numbers (packets and bytes each way, duration, packet size, silences, handshake, retransmissions, resets, port, ...), standardized; k-means groups flows of a like shape, the groups are described by what sets them apart, and the flows farthest from their group's centre are listed. Flows shaped like it is ORDER BY similarity(shape, :v).
  • Ask. A question in a sentence (why did the call stall?, which connections were refused?, which DNS lookups were slow?, who talks the most?, what is unusual?) is read for what it asks about and answered from the findings, citing the packets the answer rests on. No model writes the answer; each kind of question is a statement, which the SQL button shows.
  • What a conversation carried. A flow's page reads both sides' bytes from the capture's file, as Wireshark's Follow Stream shows them, each side in its color; with a TLS key log, what HTTPS carried, decrypted.
  • Live. A network interface captured as it goes, privately: see Capture live.
  • Upload. Drop a capture on the page: it is decoded on the app's machine and loaded while the page waits.

What is kept#

What Wireshark decodes, not the capture: each packet's columns (time, addresses, ports, protocol, length, Info) and the fields a display filter names (TCP flags and analysis, DNS names, answers and codes, HTTP method, host, URI and status, TLS server names, SIP methods and Call-IDs, RTP streams, Wireshark's expert notes). Payloads are not kept in the tables; Wireshark's full tree of one packet, and what a conversation carried, are read from the capture's file when asked, and only where that file still is and the app is not public. A capture holds what its network carried: load only captures you may share.

The samples#

chloedb-packets fetch --dir DIR downloads public samples (tcpreplay's smallFlows.pcap, and the Wireshark wiki's captures of a SIP call, HTTP, DNS, TCP trouble, ECN, redirects, a shell over DNS and DHCP); --only bigFlows.pcap (368 MB) adds tcpreplay's five minutes of an office's link to the internet. It also makes one capture up, labelled as made up wherever it is shown: the SIP call with 61 of the caller's audio packets (1.2 s) deleted by editcap, to show what a stalled call looks like.

Run it#

It needs tshark and editcap (Wireshark's command-line tools: apt install tshark, brew install wireshark), or CHLOEDB_PACKETS_TSHARK and CHLOEDB_PACKETS_EDITCAP.

chloedb-packets fetch --dir ~/pcaps
chloedb-packets serve --local ~/packets-db --captures ~/pcaps/smallFlows.pcap,~/pcaps/sip-call-stalled.pcap
# or, into a server already running:
chloedb-packets add ~/pcaps/*.pcap* --out ~/packets-prepared --strata http://127.0.0.1:7700

serve --local DIR starts a chloedb-server with the app as its app packets (command center: Apps → Packets), keeps uploads in DIR/uploads, and adds the --captures not loaded yet. prepare and load are add's two halves: prepare writes a capture's rows as JSON lines in a folder, load puts a folder in, replacing the capture's earlier rows. With --public the app serves its page at / to anyone, within --per-minute requests a minute from one address, and takes no uploads and shows no packet bytes.

On a laptop-sized machine (4 cores), tcpreplay's bigFlows.pcap (791,615 packets, 368 MB) decodes in 45 s, most of it tshark's, and loads in 27 s: 28,034 flows and 1,987 hosts. Over it, a page of packets with the count and the timeline takes 0.16 s, tcp.analysis.retransmission (55,799 packets) 0.34 s, and the flows, hosts and odd traffic pages under 0.05 s.

Capture live#

chloedb-packets serve --local ~/packets-db --live en0
# or, into a server already running:
chloedb-packets live --iface en0 --strata http://127.0.0.1:7700

--live IFACE runs tshark on a network interface (tshark -D lists them; en0 is a Mac's Wi-Fi) and keeps what it sees as the capture live: the new packets every --every seconds (2), the flows they belong to judged again as they come, the hosts and who talks to whom every 10 s, and the groups by shape every 30 s. It keeps the last --keep minutes (30), in memory and in the tables, and starts tshark again every hour, since its TCP analysis lives in tshark's memory. With serve --local DIR it also keeps each packet's bytes, a file per run of tshark in DIR/live (--contents DIR names another folder, --no-contents keeps only the fields), deleted with their rows, so that a live packet opens with Wireshark's full tree and bytes and a conversation with what it carried. --live-filter is a capture filter (not port 22, host 10.0.0.5); serve leaves out its own port and its server's, whose requests would otherwise fill a capture on any. The page marks the capture live, its overview draws itself again every 5 seconds, and its packet list follows the newest packets until a packet is picked or a time chosen. live --file F reads a capture as if it came live, as the capture live-<name>.

Most of what a browser sends is encrypted with TLS. A browser started with a key log writes its session keys there, and --tls-keys FILE (or SSLKEYLOGFILE) has tshark read them: HTTPS then shows as HTTP and HTTP/2 in the packet list, the full tree and what a conversation carried. On a Mac, quit Chrome and start it from Terminal with "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --ssl-key-log-file=$HOME/packets-db/tls-keys.log, or Firefox with SSLKEYLOGFILE=$HOME/packets-db/tls-keys.log /Applications/Firefox.app/Contents/MacOS/firefox; Safari keeps its keys. The key log opens everything that browser sends while it runs: keep it on the machine, and delete it when done.

A live capture holds what the network carries, so it stays on the machine that captures it: serve --live refuses --public, and a public app shows no live capture even if one is written into its database. Capturing needs the right to: on a Mac, brew install --cask wireshark-chmodbpf (beside brew install wireshark) lets your account capture without sudo, from a new Terminal window; on Linux, join the wireshark group. When tshark cannot capture, the capture says why in its description and the command exits.

A daily report of what talked#

A live capture keeps 30 minutes of packets. Beside them it keeps a history, pk_history: a row for each conversation, written as the capture writes its flows, with no bytes of it. A row has the day and hour it began (local time), when it began and ended, the local host and port, the remote host and port, the remote's name (the TLS server name, the HTTP host, or the name a DNS answer gave the address), its domain (the name's last two labels, three under a suffix such as co.uk), the app, bytes and packets each way, what went wrong, and the process that made it. The window lets the packets go; the history stays for --history-days days (30), pruned once a day. --no-history keeps none.

The process is found by looking at this machine's sockets every 3 seconds: lsof -nP -iTCP -iUDP on a Mac, ss -tunap on Linux (or lsof where there is no ss). A flow's local address and port find the socket, and its program's name and pid go on the row. It is best effort: a connection that opens and closes between two looks has no process, and without root lsof lists only your own account's programs. --no-procs turns it off. A file read with live --file names no process, since its packets are not this machine's.

The page's Report (in the menu once there is history) and GET /v1/report?day=YYYY-MM-DD (today by default, else the newest day kept) show a day:

  • each process, and the domains it reached with bytes sent and received;
  • the day's top domains, with the names under each;
  • what was new: domains not seen on any earlier day of the history;
  • what talked in the quiet hours, --quiet-hours 0-7 by default (local time; 22-6 wraps past midnight), when the machine is likely idle;
  • the day by hour, bytes sent above the line and received below.

A click on a row or an hour lists the history rows behind it (GET /v1/report/rows?day=&process=&domain=&hour=&only=quiet), and a row whose flow is still in the live window opens with its packets. As on the other pages, the SQL button shows each statement and its rows.

The history is what this machine talked to, so it stays on it: nothing is looked up by name or address, and a public app answers 404 for /v1/history, /v1/report and its rows, and leaves pk_history out of How it works.

Has this happened before#

A flow's page has a card "Like this, before": the troubled flows of every other capture whose shape is nearest this flow's, by ORDER BY similarity(shape, :v) over pk_flows, those with the same first finding (a stall, a slow lookup) first, then other trouble of a like shape. Each says its capture, when it was (the capture's start plus the flow's), what went wrong and at which packet, so a stall today links to the stalls of last week. GET /v1/before/<flow> answers it.

A capture's overview has a card "Seen before" (GET /v1/capture/<cap>/before): its troubled flows, the newest first, whose nearest earlier troubled flow of the same kind is at least 80% alike, and the list of what went wrong marks them "seen before". On a live capture, "earlier" also takes in the live capture's own flows that began before, so new trouble that looks like trouble of a few minutes ago is marked as it comes.

A public app lists no live capture's flows here: the statement leaves out every live capture (capture NOT IN them, and any live-…), and the answer is filtered again by name; a live flow's own card is a 404 there.

Compare two captures#

The page Compare (a capture's overview has "Compare with…") takes two captures, a before and b after, and GET /v1/diff?a=CAP&b=CAP answers:

  • the hosts new in b and gone from a, and the names (DNS, TLS server names, HTTP hosts, a host's names) new in b and gone from a;
  • the applications and the services by flows and bytes, each with its change;
  • the latency of each service: the median and 90th percentile of the handshake, the round trip, the DNS answer and the HTTP answer, a against b, with the change of the median and whether it is beyond noise. With fewer than 5 flows on a side it says "too few to tell". Otherwise b's median minus a's is bootstrapped (each side drawn again with replacement, 2,000 times, with a fixed seed, so the same captures give the same answer), and the change is beyond noise when the middle 95% of those differences leaves out zero;
  • what went wrong, by kind, a against b;
  • b's flows that did worse than the same conversation in a (the same transport, server port and name, or server address without a name): a kind of trouble the conversation never had in a, a time more than twice a's median and 50 ms more, or a worse score.

Each part carries the statements it was read with (sql), shown under it on the page. The flows and the times are read 10,000 a capture at most.

The story of a capture#

A capture's overview and a flow's page have "Tell me what happened": the app gathers what it already has (the worst flows and their findings with their packet numbers, the flows that carried the most, the packets per tenth of the capture; for a flow, its findings, times and the packets that went wrong) and asks chloedb-server's llm() for a short account in which every claim cites packets as [#123] or flows as [flow N]. The page turns those into links, and the app drops any citation that names a packet or a flow the facts did not give. "What the model was told" shows the facts as sent. GET /v1/story/capture/<cap> and GET /v1/story/flow/<flow> give a kept story or say one can be asked for; ?go=1 asks.

The model is --llm-model (default anthropic/claude-haiku-5-5, as chloedb-hn's), and chloedb-server holds its key (ANTHROPIC_API_KEY where the server runs). When the server has no key, or llm() fails, the card says so in one line. An answer is kept per model and facts, in pk_stories (in memory only in a public app), so a reload, or asking again while the capture is the same, costs nothing.

It sends what a capture holds to the model's provider, so it is off for live captures unless the app is started with --llm-live, and off in a public app unless it is started with --public-llm.

Where your traffic went#

The Where page of a capture places each remote address on the internet: the network that announces it (its AS number and name), the country its block of addresses was given to, the route's prefix, and whether that route is valid in RPKI. It shows the traffic by country (a world map and bars) and by network (bytes, flows, flows in trouble, the mean time to connect), calls out the destinations whose route RPKI finds invalid, and lists the networks whose flows were most often slow or in trouble, with their time to connect beside the capture's mean, so that a far network reads as far. A network links to its page: its addresses, its flows worst first, its packets as a display filter, and what the reference tables say of it. A host's page and a flow's page say where their ends on the internet are. Private and reserved addresses are not looked up: they are counted under their range (private, loopback, multicast, carrier NAT, ...).

The lookups use public files downloaded in bulk, the same files for everyone, so nothing about a capture leaves the machine:

chloedb-packets refdata --dir ~/packets-refdata          # about 165 MB; again later to refresh
chloedb-packets serve --local ~/packets --refdata ~/packets-refdata
# or with a capture or a live capture:
chloedb-packets add capture.pcap --out prepared --refdata ~/packets-refdata
chloedb-packets live --iface en0 --refdata ~/packets-refdata
file from what
pfx2as-v4.gz, pfx2as-v6.gz CAIDA's RouteViews prefix2as each routed prefix and its origin AS
asn.txt RIPE NCC's asnames each AS's name and country
delegated-<rir>-extended-latest ARIN, RIPE NCC, APNIC, LACNIC, AFRINIC the country each block was given to
vrps.json rpki-client (console.rpki-client.org) RPKI's validated ROAs

refdata keeps a file fetched less than 20 hours ago (--fresh-hours), and a file whose download fails keeps its last copy. With --refdata, serve, load, add and live read the folder into memory (longest-prefix tables, a sorted list per prefix length, so IPv6 prefixes longer than /64 are left out) and place every host as its capture loads, a live capture's as its hosts are written, and at serve's start every capture not placed yet. A route is valid when a ROA covering it names its origin and allows its length, invalid when ROAs cover it but none does, and no ROA when none covers it (RFC 6811); a prefix announced by several origins takes the best of them. The country is the registry's, which says where a block was given, not where a server stands.

On a 4-core Linux VM with 15 GB (November 2026): the files were 165 MB (vrps.json 108 MB) and downloaded in 19 s; reading them into memory took 1.9 s, and the app held 148 MB with them read (1.17 million IPv4 and 271,000 IPv6 routes, 1.04 million VRPs, 334,000 blocks, 123,000 ASes); writing them into the tables took 29 s, once: a stamp of the files in pk_refdata skips it until they change.

table what
pk_where an address of a capture: its scope (public or its range), AS, AS name, country, prefix, RPKI state, and the ASes of the ROAs covering an invalid route
pk_prefixes every routed prefix, its origin AS (and every origin seen) and its block's country
pk_asns every AS's short name, full name and country
pk_vrps every validated ROA: prefix, max length, AS, trust anchor
pk_refdata each reference file: where it came from, its size and rows, when it was fetched and loaded

With --backbone URL (and --backbone-token, or CHLOEDB_BACKBONE_TOKEN), the Where page also asks your own chloedb-backbone app about the 15 networks that carried the most bytes: their alerts (outages, withdrawn routes) over the capture's span, or the open ones for a live capture, and their announcements it found RPKI invalid in its last day. It sends AS numbers and nothing else, and it is off unless you pass it. The backbone app keeps a few days, so an old capture's span finds no alerts.

A network's page links to its page in a backbone app (URL/#/as/<asn>: its routes and their RPKI state, its outages, the networks it buys transit from), https://backbone.chloetech.ai unless --backbone-link URL names another (or --backbone does, when no link is given); --backbone-link '' hides it. It is only a link: the app asks nothing of it, and the AS number goes to that site only when someone clicks.

tests/whereis.rs makes up a capture to three addresses and a folder of reference data a few lines long (no network), loads them into a real chloedb-server with add --refdata and live --file --refdata, and checks the Where page, a network's page and the places of a flow's ends, including a route that is RPKI invalid.

Alerts written as SQL#

The page's Alerts tab shows what rules found in a capture. A rule is a row of pk_rules: a title, a line saying what it means, a severity, and one SELECT over the app's tables. Each row the statement returns is evidence. Rows about the same thing (the same subject column, else the same host and remote) are one alert, a row of pk_alerts that keeps the flows (flow, flows) and packets (no) its rows cite, when it began and when it was last seen. An alert stays open while its rule finds it and ends when the rule stops finding it or is turned off.

The rules run every minute over a live capture, reading its last five minutes, and once over a capture when it is loaded, reading all of it, so the samples have alerts too. serve also runs them once over loaded captures they never read. A statement may name :cap, :scope, :since and :since_hour (seconds into the capture where its window starts: five minutes and an hour before the newest packet live, the whole capture loaded), :until, :since_ts and :now_ts (the same as times).

rule fires on
Beaconing a host reaching the same remote (a name, or an address and port) six times or more on a steady rhythm: the gaps between contacts vary less than 20% of their mean (their coefficient of variation is under 0.2) and are a second or more
First contact a name or remote address never seen before in this database, after the first hour of watching
DNS failures burst twenty or more NXDOMAIN or SERVFAIL answers to one host in five minutes
Plain-text credentials HTTP without TLS carrying an Authorization header (Basic or a bearer token, not Digest, NTLM or Negotiate) or a posted form with a password-like field
Unusual ports TCP connections from a local host to a port outside a common set, on hosts outside its network: one alert per host and port
Trouble rising the share of flows in trouble over five minutes at least twice the share over the hour (the whole capture, loaded), at least one in five, with twenty flows or more
Newly registered domain a name whose domain was registered in the last 30 days; off unless serve --rdap

SQL is awkward at the gaps between a group's rows, so beaconing is measured in Rust (src/beacon.rs): pk_beacons holds, for each host and remote reached three times or more, the contacts (connections opened within a second of each other count as one), the median gap and the coefficient of variation, and the rule reads that table, so its thresholds stay SQL. Traffic on a timer by design is left out: anything to a multicast or broadcast address (mDNS, SSDP, LLMNR, NetBIOS, DHCP) and NTP, whose clients poll every 64 to 1,024 seconds. pk_seen holds each name, remote address and country (from pk_where, when the app has --refdata) a scope has seen, with when and where first; a live capture's scope is live, kept across runs, and each loaded capture is its own. Nothing is first contact in a scope's first hour, so a new database is not all alerts.

The credentials rule needs the secret to be read but not kept: tshark prints the Authorization header and the form's field names, and the decoder keeps only a flag in the packet's issues (cleartext-auth, cleartext-form). The header, the form's values and the password are in no table.

The Rules tab lists every rule with its SQL, whether it is on, its last run and how many rows it returned. Its editor tries a rule over the capture on screen ("Test" shows the rows and the alerts it would make, and keeps nothing) and saves it. A rule's SQL is checked before it is kept: one SELECT (or WITH … SELECT), not calling llm() or embed(), parsed and bound by the server (/v1/sql/check), then run over the capture. Rules run through /v1/query, which takes only a SELECT, within 10 seconds (20 for the minute's run). The built-in rules are written as serve starts and rewritten when their text in src/rules.rs changes, unless a person edited them; an edited one can go back to its built-in text. A built-in rule is turned off, not deleted. A public app shows the rules read-only (without their last runs) and the alerts of the captures it shows, none of a live capture's; changes and tests need the token and are refused in public mode.

--rdap turns on the newly registered domain rule: each minute up to 20 new names are looked up at rdap.org (the registrable part of the name, from the last two labels, or three under co.uk and the like) for their registration date. It is off by default because it sends the names this network looks up to the registries; nothing else in this feature leaves the machine.

The tables#

table what
pk_captures a capture: its file, span, packets, bytes, flows, hosts, its protocols, its groups, and how many flows went wrong, by kind
pk_packets a packet: its columns, the fields a display filter names, its TCP analysis (issues), Wireshark's expert note, and its flow
pk_flows a conversation: its ends, packets and bytes each way, timings (handshake, round trip, DNS, HTTP, jitter, gaps), state, findings (each at a packet), shape VECTOR(16), group and how odd it is
pk_hosts an address: its names, role, services, bytes each way, peers and trouble
pk_talks who talks to whom (an edge table, weighted by bytes), read by ppr
pk_history a live conversation kept for days: its day and hour, ends, name and domain, bytes and packets each way, findings and process, no packets
pk_stories the stories a model told of captures and flows, kept by model and facts
pk_rules an alert rule: its SQL, the built-in text it came from, on or off, its last run
pk_alerts an alert: its rule, what it is about, the flows and packets that fired it, the rows (evidence), open or ended
pk_beacons each host's rhythm of contact with each remote: contacts, median gap, coefficient of variation
pk_seen each name, remote address and country first seen in a scope, when and where

Tests#

cd chloedb-packets && cargo test --profile ci

tests/cluster.rs writes a capture byte by byte (a slow DNS lookup, an HTTP request answered 500 and sent again, a refused connection), decodes it with tshark, loads it into a real chloedb-server, and checks every route: the findings and the packets they cite, the display filters against the packets Wireshark would pick, the full tree, the hosts' names, groups and answers to questions; then it reads the same file with live --file and checks that the live capture finds the same things, that its newest packets come in order, that its packets open from the file and its conversation shows what it carried, and that a public app on the same database shows none of it, nor any capture's contents. tests/history.rs writes a laptop's three days (October, an afternoon and a night in November), reads them with live --file and a one-minute window, and checks that the history keeps what the window let go, that October is pruned, each day's report (names from DNS answers and HTTP hosts, what was new, the quiet hours, the hours), the rows behind a number, --no-history, and that a public app answers 404. They need chloedb-server (CHLOEDB_SERVER_BIN) and tshark, and is skipped without them unless CHLOEDB_PACKETS_NEED_SERVER is set, as the Demos workflow does.

tests/history.rs writes a laptop's three days (October, an afternoon and a night in November), reads them with live --file and a one-minute window, and checks that the history keeps what the window let go, that October is pruned, each day's report (names from DNS answers and HTTP hosts, what was new, the quiet hours, the hours), the rows behind a number, --no-history, and that a public app answers 404.

tests/rules.rs writes two captures (a laptop that calls a server every 30 seconds or so, fails 25 lookups in half a minute, sends a password in plain HTTP as a header and as a form, and an hour on reaches a new name; and a clean visit to a page) and checks which rules fire, what they cite, that the password is in no answer, the rules' API (test, save, edit, turn off, delete, and what it refuses) and a public app's refusals. Both need chloedb-server (CHLOEDB_SERVER_BIN) and tshark, and is skipped without them unless CHLOEDB_PACKETS_NEED_SERVER is set, as the Demos workflow does.

tests/compare.rs writes two days of a shopper's computer (six lookups answered in 20 ms, then in 400 ms; a refused connection to the shop, then to a new host), loads both, and reads the second as if it came live. It checks that the second day's refusal finds the first day's, of the same kind and with its date, that a public app lists no live flow and answers 404 for anything live, that the comparison finds the new host, the slower DNS beyond noise, the six lookups that got worse and the SQL of each part, and that the story says in one line that llm() could not be asked (the server is started without a key), and is refused for a live capture and in a public app. The citation filter is a unit test in src/story.rs.