Read the Environment count from AngryOxide's capture file, not its database #108

Merged
aluminum-ice merged 1 commit from fix/environment-from-capture-file into main 2026-10-31 02:40:38 +00:00
Owner

What this PR does

Fixes the dashboard's Environment card going to "Unknown – Scanning the area…" in a busy area while capture keeps working. The collector now reads the in-range count from the tail of AngryOxide's pcapng capture file instead of AngryOxide's kismet database.

Why. AngryOxide v0.9.3 inserts and commits one kismet-database row per frame. On a Pi 5's SD card, with about 600 radios in range, that topped out around 66 rows/s while about 220 frames/s arrived. Over a 17.5-minute capture the database held only the first 5.4 minutes of frames. The collector read the database's newest data, so the reading fell further behind every minute and aged out to "Unknown", while capture itself (handshakes are separate files) never missed a beat. The pcapng is a plain append and keeps up.

Change (capture-collect.py):

  • Reads the pcapng tail. The collector remembers how far it has read each run-dir *.pcapng (the current launch's and, across an agent relaunch, the previous one's). Every poll it parses only the blocks added since: SHB/IDB/EPB, little- or big-endian, honouring if_tsresol. It counts each frame's 802.11 transmitter address (addr2: management and data frames, plus BlockAckReq/BlockAck/PS-Poll/RTS; group and null addresses excluded).
  • Bounded reads. A half-written block at the end is left for the next poll. A file met for the first time is caught up over several polls (at most 16 MB each, and never more than what's actually new). A replaced file is re-read from the start, and a file that isn't pcapng is skipped.
  • Same output. radios_recent and data_ts keep the same shape and meaning, so the daemon, dashboard, e-ink face and capture interface (contract v3) are unchanged.
  • No database. No sqlite, no locks, nothing that can slow AngryOxide down. The previous reading is still carried across a relaunch, as before.
  • Docs and comments: capture-interface.md (how radios_recent is derived), agent-interface.md, and comments in config.toml, capture-launch.sh, capture.py, daemon.py and web.py. The deferred entry "Confirm the collector can still read the Kismet database" is removed: this resolves it (the cause was the database's lag, not WAL mode).

Validated on the device

The new parser was run on the real capture file from the run where the card went "Unknown" (counts only, no addresses leaving the device):

  • Newest frame: the moment capture stopped, at minute 17.5. The database's newest row was at minute 5.4.
  • Radios: 578 transmitters in the last 5 minutes of capture, consistent with the ~600 the database showed while it was still current.
  • Speed: the whole 29 MB file parsed in 0.7 s on the Pi 5, a first read. Ordinary polls read only the new bytes.

Checklist

  • Lint passes — make lint passes locally.
  • Tests pass — make test: the full suite passed on the branch before the rebase (1,451; the one failure, test_gps_serial_reader_recovers_from_a_stalled_link, fails the same way on main). After rebasing, the collector, capture, daemon and web tests pass (345). test_capture_collect.py is rewritten around invented pcapng files: counts in the window, only new frames per poll, a partial block, catching up over several polls, the previous run's file, at most two files, a replaced file, big-endian and nanosecond timestamps, a non-pcapng file, the carried reading, and a test that fails if the collector ever opens the kismet database again.
  • Nothing real: no secrets, no personal information, no real data. Test captures use invented frames and RFC 7042 placeholder addresses.
  • Consent gates intact. Not affected. The collector still runs as pi and only reads root's run dir (root:pi 0750); it writes nothing there.
  • Docs updated in the same PR.
  • Commit messages are short and imperative.

Release impact

  • App-layer-safe — capture-collect.py and capture-launch.sh are in the engine's LIB_SCRIPTS; the rest is the kestrel_pi package and docs. The config.toml change is comments only, so updated devices keep their file with no effect.

Notes for review

  • AngryOxide's own write rate is fixed separately in the AngryOxide fork (batched inserts, merged there); shipping that build is a reflash-class Kestrel release. This PR doesn't depend on it.

🤖 Generated with Claude Code

## What this PR does Fixes the dashboard's **Environment** card going to "Unknown – Scanning the area…" in a busy area while capture keeps working. The collector now reads the in-range count from the tail of AngryOxide's pcapng capture file instead of AngryOxide's kismet database. **Why.** AngryOxide v0.9.3 inserts and commits one kismet-database row per frame. On a Pi 5's SD card, with about 600 radios in range, that topped out around 66 rows/s while about 220 frames/s arrived. Over a 17.5-minute capture the database held only the first 5.4 minutes of frames. The collector read the database's newest data, so the reading fell further behind every minute and aged out to "Unknown", while capture itself (handshakes are separate files) never missed a beat. The pcapng is a plain append and keeps up. **Change** (`capture-collect.py`): - **Reads the pcapng tail.** The collector remembers how far it has read each run-dir `*.pcapng` (the current launch's and, across an agent relaunch, the previous one's). Every poll it parses only the blocks added since: SHB/IDB/EPB, little- or big-endian, honouring `if_tsresol`. It counts each frame's 802.11 transmitter address (addr2: management and data frames, plus BlockAckReq/BlockAck/PS-Poll/RTS; group and null addresses excluded). - **Bounded reads.** A half-written block at the end is left for the next poll. A file met for the first time is caught up over several polls (at most 16 MB each, and never more than what's actually new). A replaced file is re-read from the start, and a file that isn't pcapng is skipped. - **Same output.** `radios_recent` and `data_ts` keep the same shape and meaning, so the daemon, dashboard, e-ink face and capture interface (contract v3) are unchanged. - **No database.** No sqlite, no locks, nothing that can slow AngryOxide down. The previous reading is still carried across a relaunch, as before. - **Docs and comments:** `capture-interface.md` (how `radios_recent` is derived), `agent-interface.md`, and comments in `config.toml`, `capture-launch.sh`, `capture.py`, `daemon.py` and `web.py`. The deferred entry "Confirm the collector can still read the Kismet database" is removed: this resolves it (the cause was the database's lag, not WAL mode). ## Validated on the device The new parser was run on the real capture file from the run where the card went "Unknown" (counts only, no addresses leaving the device): - **Newest frame:** the moment capture stopped, at minute 17.5. The database's newest row was at minute 5.4. - **Radios:** 578 transmitters in the last 5 minutes of capture, consistent with the ~600 the database showed while it was still current. - **Speed:** the whole 29 MB file parsed in 0.7 s on the Pi 5, a first read. Ordinary polls read only the new bytes. ## Checklist - [x] **Lint passes** — `make lint` passes locally. - [x] **Tests pass** — `make test`: the full suite passed on the branch before the rebase (1,451; the one failure, `test_gps_serial_reader_recovers_from_a_stalled_link`, fails the same way on `main`). After rebasing, the collector, capture, daemon and web tests pass (345). `test_capture_collect.py` is rewritten around invented pcapng files: counts in the window, only new frames per poll, a partial block, catching up over several polls, the previous run's file, at most two files, a replaced file, big-endian and nanosecond timestamps, a non-pcapng file, the carried reading, and a test that fails if the collector ever opens the kismet database again. - [x] **Nothing real: no secrets, no personal information, no real data.** Test captures use invented frames and RFC 7042 placeholder addresses. - [x] **Consent gates intact.** Not affected. The collector still runs as `pi` and only reads root's run dir (`root:pi 0750`); it writes nothing there. - [x] **Docs updated in the same PR.** - [x] Commit messages are short and imperative. ## Release impact - [x] **App-layer-safe** — `capture-collect.py` and `capture-launch.sh` are in the engine's `LIB_SCRIPTS`; the rest is the `kestrel_pi` package and docs. The `config.toml` change is comments only, so updated devices keep their file with no effect. ## Notes for review - AngryOxide's own write rate is fixed separately in the AngryOxide fork (batched inserts, merged there); shipping that build is a reflash-class Kestrel release. This PR doesn't depend on it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Read the Environment count from AngryOxide's capture file, not its database
All checks were successful
Test / test (push) Successful in 25s
Lint / lint (push) Successful in 32s
Test / test (pull_request) Successful in 21s
Lint / lint (pull_request) Successful in 32s
51c60d71da
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch fix/environment-from-capture-file 2026-10-31 02:40:39 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aluminum-ice/kestrel!108
No description provided.