What Wi-Fi gives away when you just listen
Wi-Fi encrypts what's inside a frame. It doesn't encrypt the header. Who sent the frame, who it's for, which way it's going, how long it is, how fast it was sent and whether it's a resend are all in the clear, for anyone
Wi-Fi encrypts what's inside a frame. It doesn't encrypt the header. Who sent the frame, who it's for, which way it's going, how long it is, how fast it was sent and whether it's a resend are all in the clear, for anyone with a radio to hear.
I wrote five apps for the M5Stack CoreS3 that only listen. They join no network, send nothing and never read what's inside a frame. Between them they show how busy each channel is, check the health of your own network, map your coverage around the house, count the phones nearby and find Wi-Fi cameras, such as one hidden in a holiday rental. At the end there's a sixth that does the opposite: it runs its own network to take a live poll from people's phones.
This is the second of two posts. The first covered using Wi-Fi as a sensor: a motion radar, a breathing counter, a theremin and a tape measure. This one walks through the listening apps with the actual code, the numbers I measured, and the limits I hit.
All of them are open source (MIT) and build with PlatformIO:
- esp32-wifi-waterfall
- esp32-wifi-health
- esp32-wifi-coverage-map
- esp32-wifi-phone-counter
- esp32-wifi-camera-finder
- esp32-wifi-vote
What's in the clear
Normally a Wi-Fi radio drops every frame that isn't addressed to it. In promiscuous mode it keeps them all: the ESP32-S3 hands every frame it hears to a callback, with two parts: the raw frame bytes, and a rx_ctrl block of what the radio measured while receiving it. Between them you get:
| Where | Field | What it tells you |
|---|---|---|
| Frame byte 0 | Type and subtype | Beacon (0x80), probe request (0x40), data, deauthentication (0xC0), disassociation (0xA0)... |
| Frame byte 1, bits 0 and 1 | To DS / From DS | Whether the frame is going into or out of the network behind the router (the "distribution system"). 1: device to router (upload). 2: router to device (download). |
| Frame byte 1, bit 3 | Retry | This frame is a resend |
| Bytes 4, 10, 16 | Addresses | Receiver, transmitter, and the BSSID (the router's own address, which names the network it runs). Which is which depends on the direction bits. |
rx_ctrl.rssi |
Signal strength | In dBm (decibels relative to a milliwatt; -40 is very close, -90 is barely there). Roughly how far away the sender is |
rx_ctrl.sig_len |
Length | Bytes on air, including the 4-byte checksum |
rx_ctrl.rate, mcs, sig_mode, cwb, sgi
|
Speed | Which Wi-Fi generation sent it, its data rate, and two settings that change the rate (explained in the health checker section) |
rx_ctrl.noise_floor |
Noise | The radio's estimate of background noise |
Turning it on takes a few lines. This is from the health checker, which wants control frames too, because acknowledgements use airtime:
wifi_promiscuous_filter_t f = {.filter_mask = WIFI_PROMIS_FILTER_MASK_ALL};
esp_wifi_set_promiscuous_filter(&f);
wifi_promiscuous_filter_t cf = {.filter_mask = WIFI_PROMIS_CTRL_FILTER_MASK_ALL};
esp_wifi_set_promiscuous_ctrl_filter(&cf); // acknowledgements take airtime too
esp_wifi_set_promiscuous_rx_cb(onFrame);
esp_wifi_set_promiscuous(true);
esp_wifi_set_channel(channelNow, WIFI_SECOND_CHAN_NONE);
The radio hears one channel at a time, so every app hops: set the channel, wait, move on. How long it waits on each channel is the main design choice, and each app picks differently.
Two hardware limits shape everything below:
- 2.4 GHz only. The ESP32-S3 has no 5 GHz radio.
- One antenna. Devices with two or more antennas can send two independent signals at once on the same channel (two spatial streams), doubling the speed. Pulling them apart needs as many antennas at the receiver, so the ESP32-S3 can only decode one-stream frames. It also can't decode Wi-Fi 6 (802.11ax) frames. Cheap cameras and gadgets send one stream. Most phones and laptops send two, so their frame contents are unreadable. The radio still reports their length and speed, though, so the health checker below can work out how much of the channel they use.
The waterfall: counting frames
The simplest app hops channels 1 to 13, 40 ms on each (about two sweeps a second), and counts frames. The callback is one line:
static void onFrame(void *, wifi_promiscuous_pkt_type_t) { heard++; } // counting only
The bars at the top show each channel now, and the waterfall below scrolls the recent past. Frame rates range from a handful to thousands a second, so the colour is on a log scale, full at 2,000 frames a second:
float v = constrain(log10f(fps + 1) / log10f(2001), 0.0f, 1.0f);
Colours run from deep navy for quiet, through blue and teal, to green and yellow for busy. The bottom line names the quietest of channels 1, 6 and 11 (the three that don't overlap) over the last half minute: where to put a hotspot.
Counting frames is a crude measure. One long frame at a slow rate uses far more of the channel than a hundred short fast ones. That's what the health checker fixes.
The health checker: airtime, not frames
esp32-wifi-health listens to each channel for 250 ms (a sweep every 3 or so seconds) and works out how much of the time each one is actually in use.
Airtime from length and speed
Every frame starts with a preamble: a fixed training signal the receiver uses to lock on, sent before any data and taking the same time whatever the frame's length. So how long a frame was on air is its preamble plus its length in bits divided by its rate:
static const float LEGACY_MBPS[16] = {1, 2, 5.5, 11, 1, 2, 5.5, 11, 48, 24, 12, 6, 54, 36, 18, 9};
static const float HT_MBPS[8] = {6.5, 13, 19.5, 26, 39, 52, 58.5, 65};
// How long a frame was on air, in microseconds, and its speed in Mbit/s.
static float airtime(const wifi_pkt_rx_ctrl_t &r, float *mbps) {
float rate, pre;
if (r.sig_mode == 0) { // 802.11b and g
rate = LEGACY_MBPS[r.rate & 15];
pre = r.rate <= 3 ? 192 : r.rate <= 7 ? 96 : 20;
} else { // 802.11n
int streams = r.mcs / 8 + 1;
rate = HT_MBPS[r.mcs % 8] * streams * (r.cwb ? 2.077f : 1) * (r.sgi ? 1.111f : 1);
pre = 36 + 4 * (streams - 1);
if (r.aggregation && r.ampdu_cnt > 1) pre /= r.ampdu_cnt; // one preamble per bundle
}
*mbps = rate;
return pre + r.sig_len * 8 / rate;
}
The numbers come from the standard:
- 802.11b uses a 192 ยฌยตs long preamble (rate codes 0 to 3) or a 96 ยฌยตs short one (4 to 7).
- 802.11g uses OFDM (the data is spread across many narrow sub-carriers sent side by side) and has a 20 ยฌยตs preamble. The radio reports the rate as a 4-bit code taken from the frame's own signal field, and for 6 to 54 Mbit/s those codes aren't in speed order (code 8 is 48 Mbit/s, code 11 is 6). So the code is looked up in a table rather than calculated.
- 802.11n (Wi-Fi 4) reports a modulation and coding scheme (MCS) number instead of a rate. MCS 0 to 7 are the one-stream rates, 6.5 to 65 Mbit/s; MCS 8 to 15 are the same eight with two streams, so twice as fast. The preamble is 36 ยฌยตs plus 4 ยฌยตs for each extra stream.
-
Channel width (
cwb). 802.11n can bond two 20 MHz channels into one 40 MHz channel. That carries 108 data sub-carriers instead of 52, so it's 108 / 52 = 2.077 times as fast. -
Guard interval (
sgi). Between each OFDM symbol there's a short gap so echoes from the last one die away: normally 0.8 ยฌยตs, or 0.4 ยฌยตs with the short guard interval. A symbol plus its gap goes from 4.0 ยฌยตs to 3.6 ยฌยตs, so 4.0 / 3.6 = 1.111 times as fast. - Aggregation. 802.11n can bundle several frames behind one preamble (an A-MPDU). The radio reports each frame separately with how many were in the bundle, so the preamble is split between them rather than counted for each.
This is why the single antenna matters less here than you'd expect. A two-stream frame from a laptop can't be decoded, but the radio still reports its MCS and length, so its airtime still counts. Add up the airtime of every frame heard during one 250 ms listen on a channel (a dwell), divide by 250 ms, and you get the share of the channel in use.
Choosing a channel
The best channel is the one of 1, 6 and 11 with the lowest score, where busy is in per cent and noise in dBm:
float score = chan[c].others + 5 * overlapping(c) + max(0.0f, chan[c].noise + 95) * 2;
-
othersis airtime from other networks, not yours: your own traffic moves with you. -
overlappingcounts strong neighbours on channels that overlap this one (a network on channel 3 overlaps both 1 and 6). - Noise above -95 dBm adds 2 points per dB. The noise floor is the background radio energy on the channel that isn't Wi-Fi. Microwaves, baby monitors and analogue video senders raise it, and Wi-Fi can't avoid them the way it takes turns with other Wi-Fi.
My network
Pick your network and it reports on that alone: the signal where you are, how busy its channel is with other networks' traffic, strong overlapping neighbours, noise, the share of frames resent (the retry bit), the share of data airtime sent at slow rates, and frames knocking devices off it. Those are deauthentication and disassociation frames, the management frames a router (or anything pretending to be one) sends to end a device's connection. They're a single byte check:
knock = f[0] == 0xC0 || f[0] == 0xA0; // deauthenticate, disassociate
Those matter because a flood of them is how most Wi-Fi attacks start. They're also what a router sends to a device that talks to it without joining, which is how the checker caught a real problem.
A real catch
While testing the camera finder (below) I had a fake camera running: a Cardputer sending my router 50 frames a second at 1 Mbit/s, without joining. The health checker showed:
| Channel 6 busy | Knock-off frames a minute | |
|---|---|---|
| Fake camera on | 50% | 63 |
| Fake camera off | 13% | 0 |
Half the channel, from one small device sending junk at the slowest rate. Every one of those frames made the router send back a deauthentication: "you haven't joined me, go away". That's the kind of thing that makes a home network feel slow for no obvious reason.
Limits
- Resends and slow data can only be read from one-antenna devices (gadgets, cameras, older phones). On a network of modern phones and laptops it says "not enough heard" rather than guessing.
- Frames leak into the channels either side, so a channel next to a busy one shows a little traffic of its own.
The coverage map: a heat map from passive scans
esp32-wifi-coverage-map maps your signal around the house. Walk somewhere, tap where you are on a rough floor plan on the screen, and it drops a dot. Between the dots it fills in a heat map.
The signal comes from passive scans: listen on each channel for a beacon rather than sending probe requests. Routers send a beacon every 102.4 ms, so the scan waits a little longer than that on each channel:
static const uint32_t SCAN_MS_PER_CHANNEL = 110; // a beacon is sent about every 102 ms
...
WiFi.scanNetworks(true, false, true, SCAN_MS_PER_CHANNEL); // async, passive
A scan takes about 1.5 seconds. Each reading is the average of the last three, and with a mesh it takes whichever of your routers is strongest where you're standing. So: walk, wait about 5 seconds, tap.
The CoreS3 has no idea where it is, which is why you tell it. The map is inverse distance weighting on a 6-pixel grid: each cell takes the signal of the dots near it, weighted by one over distance squared, and fades out further than 70 pixels from any dot so it doesn't pretend to know about rooms you haven't been in:
for (int i = 0; i < nPts; i++) {
float dx = cx + C / 2 - pts[i].x, dy = cy + C / 2 - pts[i].y, d2 = dx * dx + dy * dy + 1;
nearest = fminf(nearest, d2);
wsum += 1 / d2;
vsum += pts[i].dbm / d2;
}
if (nearest > 70 * 70) continue;
uint16_t c = colourOf(vsum / wsum);
float fade = 1 - sqrtf(nearest) / 70; // dimmer away from the dots
The top line says what the signal under you is good for:
| Signal | Means |
|---|---|
| -60 dBm or better | Strong: anything works |
| -60 to -67 | Good: video calls are fine |
| -67 to -72 | Fair: browsing, but video may stutter |
| -72 to -80 | Weak: drops out |
| Below -80, or not heard | Dead spot |
It only sees 2.4 GHz, which reaches further than 5 GHz. A spot that's fair on this map is probably weak on 5 GHz. The dots are kept in flash, and the CoreS3 SE has no battery, so you walk it round on a power bank.
The phone counter: probe requests and random addresses
esp32-wifi-phone-counter counts roughly how many phones are nearby.
A phone looking for Wi-Fi broadcasts probe requests ("is anyone there?", "is network X here?"), unencrypted, with its address in them. It does this even when it isn't connected to anything. The counter listens to channels 1, 6 and 11, a fifth of a second each, and keeps only probe requests (frame byte 0 is 0x40).
The random address problem
Counting addresses doesn't work any more. Phones search with random addresses that change often, so one phone shows up under many. A real address is assigned by the maker, and its first three bytes are the maker's ID from the IEEE, called the OUI (organisationally unique identifier). A random one is marked "locally administered", meaning made up by the device itself, by bit 1 of its first byte. So:
p.random = src[0] & 2;
if (!p.random) p.oui = src[0] << 16 | src[1] << 8 | src[2];
What stays the same when the address changes is the rest of the probe request: which rates, capabilities and extensions the phone says it supports. After the 24-byte header, a probe request is a list of information elements, each one an ID byte, a length byte and that many bytes of data. So the counter fingerprints that list. It hashes every element except the network name being asked for (element 0) and the channel (element 3), which change from one probe to the next:
uint32_t h = 2166136261u ^ salt;
for (int i = 24; i + 2 <= len;) {
int id = f[i], n = f[i + 1];
if (i + 2 + n > len) break;
if (id != 0 && id != 3) h = fnv(h, f + i, 2 + n);
const uint8_t *e = f + i + 2;
if (id == 221 && n >= 4 && e[0] == 0x00 && e[1] == 0x50 && e[2] == 0xF2 && e[3] == 4) readWps(p, e, n);
i += 2 + n;
}
The network name is skipped, never read. Element 221 is "vendor specific", and one with Microsoft's OUI (00:50:F2) and type 4 is WPS (Wi-Fi Protected Setup, the push-button pairing scheme). Its data includes fields where some devices say their maker and model, and those are read for the "other devices" list.
A phone's probes don't all look alike either, because different kinds of scan include different elements. So groups link both ways: a new address with a known fingerprint joins that fingerprint's group, and a known address with a new fingerprint brings the new fingerprint into its group. Each group counts as one phone.
Everything else
Fixed addresses are laptops, speakers, cars, smart plugs and older phones, and their OUI says who made them. A table of 62 common makers, generated from the IEEE list by tools/makers.py, is compiled in and searched with a binary search.
Near and in range
It shows phones near (stronger than -65 dBm, roughly the same room) and in range (through walls too) over the last 1, 5 or 15 minutes. In a block of flats or on a busy street, "in range" includes the neighbours. "Near" is the number for the room.
How good it is
It's an estimate, and it says so:
- It misses quiet phones. A phone with its screen off, or already connected, may only probe every few minutes. The 15-minute window helps.
- Same-model phones can merge. Two phones of the same model and software version send identical fingerprints.
- It only hears 2.4 GHz. Phones also probe on 5 GHz, but they scan 2.4 GHz often enough to be counted.
The camera finder: steady upload
esp32-wifi-camera-finder is the one I'd actually take on holiday. It finds Wi-Fi cameras nearby and then helps you walk to one.
| Found | Following it |
|---|---|
![]() |
![]() |
The idea: a camera streaming to the cloud uploads steadily, minute after minute, and downloads very little. Phones, laptops, speakers and TVs mostly download, or upload only for a while. The direction bits say which way every data frame is going, so this is visible without reading anything inside the frame.
Direction and device from the header
if ((f[0] >> 4) & 4) return; // "null" frames carry no data
int ds = f[1] & 3; // 1: to the router, 2: from it
if (ds != 1 && ds != 2) return; // 0: not via a router, 3: router to router
const uint8_t *dev = ds == 1 ? f + 10 : f + 4; // the device: sender up, receiver down
if (dev[0] & 1) return; // broadcast
Null data frames are data frames with nothing in them. A device sends one to tell the router it's going to sleep or waking up, so they say nothing about traffic. They're marked by bit 2 of the subtype (the top four bits of byte 0), hence (f[0] >> 4) & 4. For uploads the device is the transmitter (address 2, byte 10); for downloads it's the receiver (address 1, byte 4). An address with bit 0 of its first byte set is a group address (broadcast or multicast), sent to everyone rather than to one device, so that's skipped too.
A device belongs to one channel
It listens to channels 1 to 13, 150 ms each. Frames leak into the channels either side, and close up they're nearly as strong there, so counting every frame wherever it's heard would put a nearby device on three channels at once and count its traffic three times. So each device belongs to the channel it's heard on most, and only frames heard there count. A device moves channel only when another channel clearly wins:
if (d->heardOn[x.channel] > d->heardOn[d->channel] * 3 / 2 + 5) {
d->channel = x.channel;
...
}
The per-channel counts are halved every 5 seconds, so old history fades and a device that changes channel (say a phone moving to another router on a different channel) isn't stuck on the old one.
The verdict
At the end of each listen on a channel, every device on it gets its upload and download rate for that listen, folded into a running average. For the first ten listens the weight a is 1 / (n + 1), which makes it a plain average of everything so far; after that it's fixed at 0.1, so each new listen counts for 10% and old ones fade (an exponential moving average, roughly the last ten listens). steady is the same kind of average of a yes or no: did it upload any real amount (over 300 bytes) in this listen? So it's the share of recent listens with upload:
float a = d.windows < 10 ? 1.0f / (d.windows + 1) : 0.1f; // average of the last ~10
d.upRate += a * (up - d.upRate);
d.downRate += a * (down - d.downRate);
d.steady += a * ((d.upBytes > 300 ? 1.0f : 0.0f) - d.steady);
...
bool judged = d.windows >= MIN_WINDOWS;
bool upMostly = d.upRate > 2 * d.downRate;
bool strong = judged && d.steady >= 0.6f && d.upRate >= 10000 && upMostly;
bool some = judged && d.steady >= 0.4f && d.upRate >= 3000 && upMostly;
if (kind == 'p') d.verdict = strong ? POSSIBLE : some ? UPLOADING : QUIET; // a phone can be a camera
else if (kind == 'c') d.verdict = some ? LIKELY : POSSIBLE;
else d.verdict = strong ? LIKELY : some ? POSSIBLE : QUIET;
The kind comes from the address:
- 'c', a camera maker. Hikvision, Dahua, Wyze, Arlo, Ring and others, from a 58-maker table. A camera maker uploading at all is a likely camera; one that's quiet is still a possible one.
- 'p', a phone or computer. A random address, or Apple, Samsung, Intel and the like. Uploading steadily is shown as uploading, because that's usually a video call or a photo backup. But an old phone can be used as a camera, so one uploading as hard and as steadily as a camera (the same bar as below: at least 10 KB/s, in 60% of listens, more than twice what it downloads) is shown as a possible camera, in the same 20 seconds. A video call can look like that too, which is why it's only "possible".
- Anything else (unknown makers, Wi-Fi module makers like Espressif, which many cheap cameras use) has to earn it: at least 10 KB/s, up in 60% of listens, more than twice what it downloads.
Ten listens on its channel is about 20 seconds before anything is judged.
Following it
Tap a device and the CoreS3 stops hopping and stays on that device's channel, showing its signal strength with Warmer and Colder. Higher is closer. It's the oldest radio direction-finding trick there is, and it works well enough to walk to a device in a room.
Testing it with a fake camera
To test it without planting a real camera, I built a fake one. tools/fake-camera runs on an M5Stack Cardputer (or a second CoreS3). It sends the strongest network nearby, my own router, about 50 KB/s of junk data frames, without joining, so it looks like an ESP32 camera uploading. The Cardputer's G0 button turns the upload off and on, like a motion-triggered camera.
The finder showed it as a likely camera within about 20 seconds, measured at 30 to 38 KB/s. It reads low because it only hears the fake camera while it's on channel 6, and misses frames while it's on the other twelve. Real cameras upload about 30 to 500 KB/s, depending on resolution and how much the scene moves, so the 10 KB/s threshold leaves plenty of room.
This is also the fake camera that the health checker caught knocking channel 6 to 50% busy.
What it can't see
- Two-antenna devices. It can only read frames sent with one spatial stream. Cheap cameras use one; most phones and laptops use two, so they rarely show up at all.
- 5 GHz and Wi-Fi 6. Most cheap cameras are 2.4 GHz Wi-Fi 4 (802.11n), but not all.
- Cameras that don't use Wi-Fi. One that records to a card or uses a cable sends nothing.
- Motion-only cameras. Some only upload when they see movement. Wave at the spot you suspect.
- A phone used as a camera, sometimes. One uploading as hard as a camera shows as a possible camera, but one streaming at low quality may only show as uploading, and one with two antennas may not show at all.
Privacy
Every listening app sees other people's devices, so I kept them deliberately forgetful. Addresses and fingerprints are never stored as they are. They're hashed with FNV-1a, a small fast hash (for each byte: XOR it in, then multiply by a fixed prime). The hash starts from a random number picked at each start (a salt) that is kept only in memory, so the same device gives a different ID after every restart and there's no way to get back from an ID to an address:
salt = esp_random();
...
x.key = fnv(2166136261u ^ salt, dev, 6);
Restart and every device gets a new, unrelated ID. No device data is written to flash (the health checker keeps only the name of your own network), and the phone counter forgets everything after 15 minutes. The network names phones ask for are never read, nor the device names some devices send, because those can be a person's name. Only counts, makers and models are shown or printed. Nothing inside any frame is read: only headers, sizes and directions.
One that talks back: a live poll
The last app does the opposite of listening. esp32-wifi-vote runs its own open network, "CoreS3 vote". Join it and a voting page pops up by itself, with no app and no internet. Votes show as bars on the CoreS3 and on everyone's phone, refreshing every 2 seconds.
The pop-up is the captive portal trick hotel Wi-Fi uses (a captive portal is the sign-in page a network makes you see before it lets you out). When a phone joins a network, it fetches a known address to check for internet. The CoreS3 runs a DNS server, the service that turns names into IP addresses, and answers every name with its own address:
dns.start(53, "*", WiFi.softAPIP()); // every name points here
and its web server sends each phone's internet check to the poll:
for (const char *path : {"/generate_204", "/gen_204", "/hotspot-detect.html", "/library/test/success.html",
"/connecttest.txt", "/ncsi.txt", "/success.txt", "/canonical.html"})
web.on(path, redirectToPage);
web.onNotFound(redirectToPage);
Those are the checks Android, Apple and Windows use. The phone gets a 302 redirect (the HTTP reply for "it's moved, go here instead") instead of the answer it expects, decides it's behind a sign-in page, and shows the poll in its "sign in to network" sheet.
One vote per phone (keyed by its IP address), which it can change. Polls live in firmware/include/polls.h, or you can set a one-off poll from 192.168.4.1/admin with a code shown on the CoreS3's screen, new each start. The ESP32-S3 allows 15 connected phones at most. Some phones warn that the network has no internet: choose to stay connected. And https:// addresses can't be redirected: the CoreS3 can't prove it's the real site, so the browser refuses the connection before any redirect is seen. If the page doesn't pop up, browse to a plain http:// one.
What I'd tell someone starting out
- The header tells you a lot. Direction, size and timing are enough to tell a camera from a phone without reading a byte of content.
- Count airtime, not frames. One slow frame can use more of a channel than a hundred fast ones, and the radio gives you enough to work it out even for frames it can't decode.
- Frames leak into neighbouring channels. Decide which channel a device belongs to, or close devices show up everywhere.
- Random MAC addresses break naive counting. Fingerprint what the device says it supports instead.
- Build a fake target. A Cardputer pretending to be a camera made the finder testable and turned up a real problem in the health checker.
- Design for forgetting. Salted hashes, memory only, short windows. You get the counts without keeping anyone's data.
- Know your radio. One antenna and 2.4 GHz only rule out a lot of devices. Say so on the screen rather than pretending.
Try them
Each app builds from its firmware/ folder:
pio run -t upload
To rebuild the maker tables in the phone counter and camera finder, download the IEEE list (3.9 MB) and run tools/makers.py:
curl -L -o data/oui.csv https://standards-oui.ieee.org/oui/oui.csv
python3 tools/makers.py data/oui.csv
The fake camera for testing is in the camera finder repo:
cd tools/fake-camera
pio run -t upload
Use pio run -e m5stack-cores3 -t upload to run it on a CoreS3 instead of a Cardputer.
Every app has the same serial interface at 115200: log prints the numbers behind the screen, shot sends a screenshot to tools/screenshot.py, and tap X Y touches the screen.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.



