How imsnif/bandwhich works
bandwhich is a CLI network-utilization monitor: users select an interface and output options, then it captures traffic, associates connections with processes, optionally resolves remote IPs, and presents live or raw bandwidth summaries. The graph preserves the documented DNS, platform-specific socket lookup, and terminal-display capabilities. Some orchestration and display wiring is unsampled; dashed edges mark relationships not directly shown in the excerpts.
Main entry points: ui.rs Terminal and raw UI · main.rs Monitor runtime · shared.rs Input setup · sniffer.rs Packet capture
Components 22
CLI and orchestration
- CLI options
src/cli.rs - Monitor runtime
src/main.rs
Traffic and process data
- Input setup
src/os/shared.rs - Packet capture
src/network/sniffer.rs - Connection model
src/network/connection.rs - Traffic utilization
src/network/utilization.rs - Socket lookup
src/os/shared.rs - Linux sockets
src/os/linux.rs - lsof socket lookup
src/os/lsof.rs - lsof parsing
src/os/lsof_utils.rs - Windows sockets
src/os/windows.rs
Address resolution
- DNS setup
src/os/shared.rs - Reverse resolver
src/network/dns/resolver.rs - DNS client
src/network/dns/client.rs
State and presentation
- Bandwidth state
src/display/ui_state.rs - Terminal and raw UI
src/display/ui.rs - Bandwidth display
src/display/components/display_bandwidth.rs - Header details
src/display/components/header_details.rs - Responsive layout
src/display/components/layout.rs - Summary tables
src/display/components/table.rs - Help text
src/display/components/help_text.rs
Other components
- CLI user
Connections 23
- CLI user → CLI options: sets options
README.md - CLI options → Monitor runtime: configures
src/main.rs - Monitor runtime → Input setup: starts input
- Input setup → Packet capture: opens capture
- Packet capture → Connection model: identifies flows
src/network/sniffer.rs - Packet capture → Traffic utilization: reports traffic
- Input setup → Socket lookup: provides lookup
src/os/shared.rs - Socket lookup → Linux sockets: dispatches on Linux
src/os/shared.rs - Socket lookup → lsof socket lookup: dispatches on macOS
src/os/shared.rs - lsof socket lookup → lsof parsing: uses parsing
src/os/lsof.rs - Socket lookup → Windows sockets: dispatches on Windows
src/os/shared.rs - Input setup → DNS setup: initializes DNS
src/os/shared.rs - DNS setup → DNS client: creates client
src/os/shared.rs - DNS client → Reverse resolver: calls lookup
src/network/dns/client.rs - Monitor runtime → DNS client: requests names
src/main.rs - Monitor runtime → Bandwidth state: updates state
src/main.rs - Monitor runtime → Terminal and raw UI: drives display
src/main.rs - Terminal and raw UI → Bandwidth state: reads state
- Terminal and raw UI → Bandwidth display: renders bandwidth
- Terminal and raw UI → Header details: renders headers
- Terminal and raw UI → Responsive layout: uses layout
- Terminal and raw UI → Summary tables: renders tables
- Terminal and raw UI → Help text: renders help