bandwhich for Mere Mortals
Every machine sooner or later asks the same question: something is using the network — what is it? The router's lights blink. A speed test says the link is busy. Your totals say the machine has moved gigabytes today. None of them gives the answer a name. bandwhich is the terminal tool that does: current network use by process, by connection, and by remote address, live, with sending and receiving rates for every row — the total, taken apart until each piece has a program's name on it.
One rule governs everything it shows, and this guide states it in chapter 1 and keeps pointing back to it: a name in bandwhich is a match it made, not a proof of who sent the bytes — and a rate is a sample over a short window, not a measurement of a transfer. It joins packets to processes by matching socket records, a join that can lose; and it smooths byte counts into rates, a smoothing that can overshoot, linger, and freeze. Most of the ways bandwhich can mislead you are ways of forgetting one half of that rule or the other.
The lab behind this guide ran the real
thing: bandwhich 0.23.1, the
official release binary from the
project's GitHub releases, on a small
Linux machine. It built traffic it
could swear to — a payload of exactly
10,485,760 bytes, served by a fixture
server on loopback and downloaded by a
client process with a name of its own,
throttled to 1 MiB per second so the
watcher's once-a-second eye could
follow (9.811 seconds, hash identical
at both ends) — and watched bandwhich
attribute the flow to the right two
processes, refresh by refresh, in both
its raw output and its drawn tables.
It ran the same download at twice the
rate under a different client, and a
third time unthrottled, where the whole
file crossed in 0.060 seconds and the
watcher's report — a client it could
not name, wearing one frozen,
impossible rate — became this guide's
best lesson. It counted the same bytes
independently in the kernel's own
counters, did the process-matching join
by hand in /proc, and read every
figure in the totals mode against the
payload's known size.
What the lab could not do, it did not
fake — and its one real obstacle is
worth stating here, because it taught
the privilege chapter. This sandbox's
kernel capability ceiling excludes the
capture capabilities entirely, so
bandwhich refused, in writing, every
way the lab first asked: as root, as an
unprivileged user, and with the
documented setcap grant applied and
verified on the binary. The refusal is
kept verbatim in the transcripts, with
the ceiling decoded. The lab's captures
were therefore made inside a private
network namespace of its own, where its
processes held the capabilities over
their own loopback — the same binary,
the same flags, the same output. The
detour meant some things stayed out of
reach and are labelled documented-only:
traffic to a genuinely remote machine
(the sandbox will not connect to one),
the view from inside a tunnel, and the
macOS and Windows matching routes.
criteria.md keeps the full ledger of
what was run and what was only read.
What this guide covers
- What bandwhich is — the question totals cannot answer, the three tables, and the one rule
- The moving parts — the sniffer, the matcher, the sampler, the resolver, and the display
- Installing bandwhich — the release file the lab used, the package and cargo routes, and why the refusal is not a broken install
- Your first look — the privilege, granted two honest ways with each capability explained, the safety side, and the screen taken apart
- The three tables — processes, connections, and remote addresses, read line by line from a real capture, and read across
- Making traffic you can trust — the stated-size payload, the named client, the rate limit, and what the watcher reported
- Raw mode and flags — plain lines for scripts and logs, one table at a time, totals versus rates, units, and interfaces
- Names and DNS — resolution arriving late and costing queries, the off switch, and names as claims
- How matching works —
the
/procjoin done by hand, and the four ways it breaks: exits, tails, shared sockets, tunnels - Reading rates honestly — ramp-up, overshoot, the frozen burst figure, loopback's two traps, and the kernel counter as witness
- The neighbours —
nethogs, iftop, btop's network panel,
ss, the manual/procway, and the packet tools at the boundary - Limits — metadata never contents, samples not measurements, the quiet matcher, the hard privilege gate, and one machine's vantage point
- Troubleshooting — the refusal, the wrong interface, the anonymous process, the doubled and impossible rates
- Glossary — the terms, collected in one place
What it doesn't cover
Reading packet contents — bandwhich never has them, and chapter 11 points at the tools that do. Long-term recording, graphing, and alerting — bandwhich keeps no history of its own. Acting on what you find: blocking, shaping, or killing traffic is other tools' work; bandwhich is a meter with names on it, not a valve. And watching anyone else's machine or network: every procedure here watches the machine you are sitting at, with traffic you started yourself.
How to use this guide
Read chapter 1 for the rule and
chapter 2 for the map of parts;
chapter 4 is the gate everything else
passes through, so do not skip it.
Chapter 6 is best done with two
terminals open — the fixture only
teaches once its numbers are on your
screen. Chapters 9 and 10 are the two
that change how you read every later
row: how a name is earned, and how a
rate is built. The lab's fixture
generator and run scripts live in
examples/, its transcripts in
examples/transcripts/, its distilled
commands are examples/commands.txt,
and its notes examples/lab-notes.txt.
Part of the series
This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.
Related guides:
License
The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.