Raw mode and flags
Outcome: you can turn bandwhich from a screen you watch into a record you keep — and you know each flag that changes what it shows, which ones the lab ran, and what each one did to the output.
The interactive display vanishes when you close it. Everything in this chapter follows from wanting the same knowledge in a form that survives: a log file, a pipe, a script's input.
Raw mode
sudo bandwhich --raw --no-resolve --interface lo > watch.txt
--raw replaces the drawn tables with
the plain lines chapter 5 quoted: a
Refreshing: header per cycle, then
process:, connection:, and
remote_address: lines, or <NO
TRAFFIC> when a cycle is empty. It
never ends on its own; stop it with
Ctrl-C or from another terminal, and
what it wrote stays written. The lab's
transcripts t02, t03, t05, t06, and t07
are all raw captures, made exactly this
way.
Raw mode is also the only mode that
works without a terminal. Ask for the
interactive display with output
redirected and bandwhich refuses, and
names the fix in its own error
(transcript
examples/transcripts/t10-errors.txt):
Error: Failed to get stdout: if you are trying to pipe 'bandwhich' you should use the --raw flag
Treat that message as the rule: screen
for eyes, raw for files. A practical
pattern is to capture generously and
filter later — grep '"fixture-fetch"'
watch.txt pulls one process's history
out of a long watch, timestamps and
all.
One table at a time
--processes, --connections, and
--addresses each show only their
table. The lab ran --processes in raw
mode against the fixture (transcript
t07): the capture contains process
lines only — not one connection: or
remote_address: line — which makes it
the right shape for a script that only
asks "who". In the interactive display
the same flags leave more room for the
table you kept.
Totals instead of rates
--total-utilization switches every
figure from a per-second rate to a
running total since bandwhich started.
The lab ran it against the fixture
(transcript t06): the server's total
climbed steadily and ended at
14,099,830 on the connection the
payload crossed. Compare that with the
payload's true size, 10,485,760 bytes,
and hold the difference in mind: a
bandwhich total is bandwhich's
accounting of the traffic it
attributed — both ends of a loopback
conversation, housekeeping and all —
not a file size. Chapter 10 says what
totals are safely good for (which
process moved the most, by far) and
what they are not (auditing bytes).
Units
--unit-family chooses how the
interactive display writes its rates:
bin-bytes (the default; powers of
1024, shown as KiB and MiB),
bin-bits, si-bytes (powers of
1000), or si-bits. The lab's terminal
capture (transcript t09) shows the
default at work — 889.31KiB on
screen, where raw mode was reporting
plain bytes per second for the same
flow. Bits are the language of link
specifications ("a 100 megabit
connection"), bytes the language of
files; being able to flip is how you
compare bandwhich's numbers with a
speed test without doing arithmetic in
your head. An unknown value is refused
with the four legal ones listed
(transcript t01).
Choosing interfaces
--interface names one interface to
watch — lo for loopback, or your
machine's real one (the lab's sandbox
called it host0; yours might be
eth0 or wlan0). With no
--interface, bandwhich watches all
the interfaces it can. Naming one
quiets the screen and narrows the
question. Naming one that does not
exist is refused before anything else
happens (transcript t10):
Error: Cannot find interface nosuch0
Two flags held for later
--show-dns adds the DNS lookups
themselves to the display, and
--dns-server chooses which resolver
the background lookups use. Both belong
to the resolver's story and are covered
in the next chapter. --log-to <file>
(with --verbose / --quiet) writes
bandwhich's own debug log; it is named
here from the --help text and was not
needed by the lab.
Check: capture ten seconds of fixture
traffic in raw mode, then find your
client's name in the file with grep.
If the lines are there with timestamps,
you own the difference between watching
bandwhich and keeping it.