Architecture
LuCI Bandix is a thin web front end. The measuring is done by the Bandix backend, a Rust program with eBPF hooks. This page explains how the pieces fit together, so you know where to look when something does not work.
Layers
Browser (LuCI JavaScript views)
│ JSON-RPC over HTTP(S), LuCI session
▼
uhttpd / LuCI ──► rpcd ──► /usr/libexec/rpcd/luci.bandix (shell plugin, ubus object "luci.bandix")
│ curl, http://127.0.0.1:8686
▼
bandix backend (Rust, user space)
│ eBPF maps / ring buffers, conntrack
▼
Linux kernel: TC ingress/egress hooks on the LAN interface
| Layer | Provided by | Role |
|---|---|---|
| Views | this package (htdocs/luci-static/resources/view/bandix/) |
The four pages: Status, Connections, DNS, Settings |
| Shared UI modules | this package (htdocs/luci-static/resources/bandix/) |
Code shared between views |
| RPC plugin | this package (/usr/libexec/rpcd/luci.bandix) |
Validates input and proxies calls to the backend; local maintenance tasks |
| ACL and menu | this package (/usr/share/rpcd/acl.d/, /usr/share/luci/menu.d/) |
Who may call what; where the pages appear |
| Configuration | /etc/config/bandix |
Read by the backend's init script and by the views |
| Backend | the bandix package (openwrt-bandix project) |
Packet counting, rate limiting, quotas, DNS capture, connection statistics, HTTP API |
Front End
| File | Page or role |
|---|---|
view/bandix/index.js |
Status: device list, realtime charts, ranking, timeline, rate limits, quotas, hostnames |
view/bandix/connection.js |
Connections: per-device connection counts and the flow dialog |
view/bandix/dns.js |
DNS: query records and statistics |
view/bandix/settings.js |
Settings: the UCI form, maintenance buttons, GeoIP manager |
bandix/devices.js |
Device selection and batch deletion (used by Status) |
bandix/quota.js |
Quota form, summaries and saving (used by Status) |
bandix/geoip.js |
GeoIP manager, upload and location formatting (used by Settings and Connections) |
bandix/flows.js |
The flow search index (used by Connections) |
The views are standard LuCI client-side views: they declare RPC calls with rpc.declare, read UCI with the uci module and refresh with LuCI's poll module. The Settings page is a regular form.Map over the bandix configuration, so Save & Apply goes through LuCI's normal apply mechanism.
The menu entry Network → Bandix (order 90) appears only if the user has the luci-app-bandix ACL and /etc/config/bandix exists. Its tabs are Status (10), Connections (15), DNS (20) and Settings (25).
The package also installs /usr/share/luci/status/bandix.json, which describes the bandix init service as a process instance for LuCI's service status display.
Refresh Intervals
| Page | What | Interval |
|---|---|---|
| Status | Device list, realtime chart, schedule rules, quotas | 1 s |
| Status | Traffic Statistics (ranking, timeline) | manual (Query) |
| Connections | Connection counters | 1 s |
| DNS | Statistics cards | 1 s |
| DNS | Query records | manual (Refresh) |
| Settings | GeoIP status | 2 s |
These intervals mean an open Bandix page makes several RPC calls per second. Close the tab when you do not need it, especially on slow routers.
RPC Plugin
/usr/libexec/rpcd/luci.bandix is a shell script using OpenWrt's jshn and jsonfilter helpers. rpcd runs it with list to learn the methods and with call <method> to execute one, passing arguments as JSON on standard input.
At start, the script reads bandix.general.host and bandix.general.port with uci and builds the backend address. Every call then becomes one curl request. A few methods work locally instead: clearData, restartService, getVersion, getSystemArch, checkUpdate (queries the GitHub API) and installUpdate (downloads and installs a package).
The method list is in RPC Methods, the backend endpoints in Backend HTTP API.
Backend
The backend is not part of this repository. The repository's ARCHITECTURE.md (in Chinese) describes it; in summary:
- eBPF programs attach to the TC ingress and egress hooks of the monitored interface. Shared entry programs check which modules are enabled and run the traffic and DNS logic. Statistics land in eBPF maps; DNS packets go to a ring buffer. Rate limiting decisions (pass or drop) are made in the kernel.
- User space (Rust, tokio) reads the maps every second, associates IP addresses with MAC addresses through the neighbor table, keeps device state, and serves the HTTP API.
- Modules: traffic (statistics, rate limits, storage), DNS (capture and statistics, kept up to
dns_max_records), and connections (reads the kernel connection tracking table,/proc/net/nf_conntrack, and relates entries to devices). - Storage: a realtime ring of 1-second samples in memory, and long-term statistics with 1-hour samples kept for 365 days. Persistence to disk is optional (
traffic_enable_storage,dns_enable_storage). - API: port 8686, bound to
127.0.0.1in release builds and0.0.0.0in debug builds.
Note:
ARCHITECTURE.mdpredates some features (quotas, GeoIP, the usage ranking) and mentions paths such as/tmp/bandix-datathat differ from the current defaultdata_dir(/usr/share/bandix). Treat it as an overview, not a specification.
Consequences of This Design
Knowing the layers explains several behaviors:
- What is counted. Only traffic that passes through the TC hooks of the monitored interface is counted. Traffic between two LAN devices that is switched in hardware (same switch chip or Wi-Fi bridge without passing the CPU) never reaches the hooks. Hardware flow offloading moves forwarded traffic past the hooks too, which is why it should be disabled.
- Devices are MAC addresses. The backend keys statistics by MAC. A phone using randomized MAC addresses shows up as a new device for each address.
- Two version numbers. The front end and backend are separate packages that must agree on the API. A mismatch shows as missing data or errors such as "Batch deletion is unavailable. Update the Bandix service."
- Errors are generic. When
curlfails, the plugin usually returns only "Failed to connect to Bandix service". Check the backend directly withcurl http://127.0.0.1:8686/...to see the real problem. - The browser never contacts the backend. Keeping
hoston127.0.0.1is enough for LuCI; there is no need to expose port 8686.