The neighbours
Outcome: you can place bandwhich among
the tools it lives beside, and reach
for the right one first. These are
characterisations, not benchmarks —
each neighbour is described by what it
sees and what it is for. Of them, only
ss and the /proc files were run in
this guide's lab (transcript t08); the
rest are described from their
documentation, and criteria.md says
so.
nethogs — the closest relative
nethogs answers the same question —
traffic by process — in a plainer
dress: a list of programs with their
sent and received rates, updated every
few seconds, grouped by process rather
than unfolded into connections and
remote addresses. It is the tool to
reach for when you want the headline
("which program?") with the least
ceremony, and it has been asking it
longer than bandwhich has. bandwhich's
edge is the cross-cutting: the
connection and remote-address tables
that tell you where a process's bytes
are going, and raw mode for the record.
Both need the same privilege, for the
same reason.
iftop — the per-address view
iftop shows traffic by connection
between hosts — who is talking to whom
and how fast — with bars and totals per
pair, and no process names at all. It
is the natural tool when the question
is about the link ("which remote host
is eating the connection?") rather than
the process, and when the machine is a
router or server whose processes you do
not care about. bandwhich's remote
address table is the overlap;
bandwhich adds the names iftop cannot
give, and iftop gives a cleaner
per-pair picture without needing to
resolve sockets to owners.
btop — the view from the dashboard
btop is a system monitor — processor,
memory, disks, and a network panel with
the interface's total rate over time, a
graph, and cumulative bytes. It answers
"is the machine busy, and with what, in
general?" beautifully, and its network
panel is the right place to notice a
problem. It cannot say which process;
that is not its job. The usual incident
shape is btop (or its kin) spots it,
bandwhich names it.
ss — the socket table, no sniffing
ss prints the kernel's own records of
sockets and connections: states, queues,
endpoints, and — with -p — the owning
process. It needs no packet capture and
no special privilege for your own
processes' sockets; it reads the same
/proc tables chapter 9 opened. The
lab used it as the fixture's independent
witness (transcript t08):
ESTAB 127.0.0.1:60632 127.0.0.1:18090 users:(("fixture-fetch",pid=3856,fd=5))
ss tells you a connection exists
and whose it is, with byte counts per
socket on request (ss -i), but no
live per-process rates: it is a
snapshot of state, not a meter. When
bandwhich will not start — no privilege
available — ss -tnp is the fallback
that still answers half the question.
The manual way: /proc itself
Everything bandwhich and ss show
starts as files: /proc/net/dev for
per-interface byte counters,
/proc/net/tcp and its siblings for
the socket tables, /proc/<pid>/fd for
ownership. The lab read all three
directly (transcripts t08 and t11).
Doing it by hand is slow and shows you
exactly one moment, but it has one
unbeatable property: it works when
nothing else is installed, and knowing
it is knowing what your tools are made
of.
And the boundary: tcpdump and Wireshark
When the question stops being "how much and whose" and becomes "what is in the packets", these are the tools — they capture and dissect contents, which bandwhich never does. They are also heavier, in output and in responsibility: contents are other programs' data, and the privilege and privacy questions grow accordingly. The series treats packet capture in its own right; here it is enough to know the boundary and which side of it bandwhich stands on.
The pattern to keep: totals tools tell
you the link is busy, ss tells you the
connections exist, the packet tools
tell you what the bytes are. bandwhich
owns the middle question — whose bytes,
how fast, right now — and owns it
exactly as well as its matcher and its
sampler allow, which is what the last
ten chapters were about.