Skip to content

Latest commit

Β 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚜 Conntracktor

A blazingly fast, Rust-based TUI connection monitor for OpenWrt, specializing in MediaTek Hardware Offloading (PPE & WED) analytics.

Rust OpenWrt License: MIT

Conntracktor is a lightweight Terminal User Interface (TUI) utility designed for modern OpenWrt routers. While standard tools like top only show CPU usage, they completely miss the massive amount of traffic being processed by hardware accelerators. Conntracktor looks under the hood of netfilter to show you exactly what connections are active, where they are coming from, and whether they are bypassing the CPU via hardware offloading.

Compatibility: Developed and thoroughly tested on the MediaTek MT7981 (Filogic 820), with full dynamic support for the broader MediaTek family via Device Tree detection:

Filogic (modern ARM):

  • MT7988 (Filogic 880, Wi-Fi 7)
  • MT7987 (Filogic 850, Wi-Fi 7 entry)
  • MT7986 (Filogic 830, Wi-Fi 6/6E)
  • MT7981 (Filogic 820, Wi-Fi 6)
  • MT7622 (Filogic 800, Wi-Fi 6 / early ARM)

Legacy:

  • MT7629 (Wi-Fi 5)
  • MT7621 (Wi-Fi 5 / MIPS)
  • MT7628 (Wi-Fi 4/5 budget)
  • MT7620 (Wi-Fi 4/5 budget)

It also gracefully falls back to standard software metrics on any generic OpenWrt device supporting nf_conntrack.

✨ Features

  • Real-time Connection Tracking: View total active vs. maximum allowed connections.
  • Smart Traffic Classification: Automatically categorizes active sessions into:
    • πŸ–§ Router (Local): Traffic generated by the router itself (e.g., NTP, OPKG/APK).
    • πŸ–₯️ Wired: LAN client connections.
    • πŸ“Ά Wi-Fi: Wireless client connections.
    • πŸ›‘οΈ VPN: Virtual Private Network endpoints (WireGuard, OpenVPN, Tailscale).
    • 🌐 Remote: Public Internet addresses.
    • πŸ“’ Multicast: Multicast and broadcast traffic (e.g., IPTV, mDNS, IGMP, OSPF).
    • ❓ Unknown: Uncategorized private subnets or ISP management equipment.
  • Hardware Offload Analytics:
    • Tracks connections accelerated by the PPE (Packet Processing Engine), indicated by [HW_OFFLOAD].
    • Infers WED (Wireless Ethernet Dispatcher) usage by correlating hardware-offloaded sessions with wireless interfaces.
  • Dynamic SoC Adaptation: Automatically detects your router's chipset via the Linux Device Tree to adjust the layout and accurately report on all available PPE/WED engines.
  • Zero Disk I/O: Specifically designed for routers with slow or restricted eMMC storage. All data is parsed directly from RAM (/proc and /sys), and the binary runs flawlessly from tmpfs.
  • Low CPU Footprint: Written in safe, compiled Rust with a highly optimized render loop.

πŸ“Έ Interface (Mockup)

Main interface

β”Œ 🚜 Conntracktor v0.1.0 ──────────────────────────────────────── [ press ? for help ] ┐
β”‚ OpenWrt β”‚ OpenWrt 25.12-snapshot β”‚ Uptime: 2d 12h β”‚ CPU: 2% β”‚ RAM: 370/986 MB        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œ Active Connections [ 544 / 63488 ] ─────────────────────[CPU: 510] [SW: 7] [PPE: 27] ┐
β”‚   PROTO SOURCE IP              DESTINATION IP         STATUS          OFFLOAD        β”‚
β”‚                                                                                      β”‚
β”‚>> UDP   πŸ–§  168.27.134.47       🌐 221.298.97.183                      CPU           β”‚
β”‚   UDP   πŸ–§  168.27.134.47       🌐 5.79.78.211                         CPU           β”‚
β”‚   UDP   πŸ“Ά 192.168.1.30        πŸ“Ά 192.168.1.116                       CPU            β”‚
β”‚   TCP   🌐 18.146.193.61       πŸ–§  168.27.134.47       ESTABLISHED     CPU           β”‚
β”‚   UDP   🌐 37.16.72.197        πŸ–§  168.27.134.47                       CPU           β”‚
β”‚   UDP   🌐 142.51.63.179       πŸ–§  168.27.134.47                       CPU           β”‚
β”‚   UDP   🌐 65.38.65.161        πŸ–§  168.27.134.47                       CPU           β”‚
β”‚   UDP   🌐 16.119.112.248      πŸ–§  168.27.134.47                       CPU           β”‚
β”‚   TCP   πŸ“Ά 192.168.1.96        🌐 87.58.147.204       dst=87.58.147.2 HW (PPE)       β”‚
β”‚   UDP   πŸ“Ά 192.168.1.116       πŸ“Ά 192.168.1.30                        SOFTWARE       β”‚
β”‚   UDP   🌐 185.168.238.27      πŸ–§  168.27.134.47                       CPU           β”‚
β”‚   UDP   🌐 54.32.177.27        πŸ–§  168.27.134.47                       CPU           β”‚
β”‚   UDP   🌐 14.135.142.7        πŸ–§  168.27.134.47                       CPU           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Other panels

β”Œβ”€ Hardware ────────────────────── [ Hardware support only. Software may be disabled ] ┐
β”‚ SoC            MediaTek MT7986AV (Filogic 830)                                       β”‚
β”‚ CPU            2Γ— Cortex-A53 @ 1300 MHz                                              β”‚
β”‚ Memory         1 GB DDR4 @ 3200 MT/s                                                 β”‚
β”‚ Switch         Airoha AN8855 @ 2.5G Gbps                                             β”‚
β”‚ Flash          FORESEE F35SQA001G (eMMC)                                             β”‚
β”‚ Misc           USB 3.2 Gen1 (5G)                                                     β”‚
β”‚                                                                                      β”‚
β”‚ Networking                             Security                                      β”‚
β”‚   PPE                βœ“                   Crypto Engine     βœ“                         β”‚
β”‚   WED                βœ“                   AES               βœ“                         β”‚
β”‚   RSS                βœ—                   SHA               βœ“                         β”‚
β”‚   Checksum Offload   βœ“                   TRNG              βœ“                         β”‚
β”‚   TSO                βœ“                   Secure Boot       βœ“                         β”‚
β”‚   Multi RX Queues    βœ—                   TrustZone (TEE)   βœ“                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ Packet Pipeline ────────────────────────────────────────────────────────────────────┐
β”‚ Hardware offload:                                                                    β”‚
β”‚   PPE:  βœ“ enabled (1 table)                                                          β”‚
β”‚   WED:  βœ“ enabled (2.4GHz, 5GHz)                                                     β”‚
β”‚                                                                                      β”‚
β”‚ Software processing:                                                                 β”‚
β”‚   RPS:  βœ“ enabled β†’ CPU1                                                             β”‚
β”‚   XPS:  βœ— disabled                                                                   β”‚
β”‚   Flow table: βœ— disabled                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ Network Queues ─────────────────────────────────────────────────────────────────────┐
β”‚ eth0                                                                                 β”‚
β”‚   RX queues: 1                                                                       β”‚
β”‚     rx-0  RPS: CPU1                                                                  β”‚
β”‚                                                                                      β”‚
β”‚   TX queues: 16                                                                      β”‚
β”‚                                                                                      β”‚
β”‚ DMA: RX rings: 1  TX rings: 16                                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ Interrupts ─────────────────────────────────────────────────────────────────────────┐
β”‚ Device              IRQ          CPU0        CPU1                                    β”‚
β”‚                                                                                      β”‚
β”‚ Ethernet            75,76        7.9M          0                                     β”‚
β”‚ WiFi                73          39.6M          0                                     β”‚
β”‚ MMC                 78           0.2M          0                                     β”‚
β”‚ USB                  0            0                                                  β”‚
β”‚                                                                                      β”‚
β”‚ IRQ affinity: concentrated on CPU0 ⚠                                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ SoftIRQ ────────────────────────────────────────────────────────────────────────────┐
β”‚                  NET_RX              NET_TX                                          β”‚
β”‚ CPU0             6.2M                5.3M                                            β”‚
β”‚ CPU1             4.7M                9.2M                                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ Packet Processing ──────────────────────────────────────────────────────────────────┐
β”‚ RSS:              OFF (RX queues: 1)                                                 β”‚
β”‚ RPS:              ON                                                                 β”‚
β”‚ RPS CPUs:         CPU1                                                               β”‚
β”‚ RPS flow table:   OFF                                                                β”‚
β”‚ XPS:              OFF                                                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ Hardware Offload ───────────────────────────────────────────────────────────────────┐
β”‚  PPE0:      15234/32768 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘]    WED0(2.4G):  512/2048  [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘]  β”‚
β”‚  PPE1:      28192/32768 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘]    WED1(5G):   1892/2048  [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘]  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ Software Fast Path ─────────────────────────────────────────────────────────────────┐
β”‚ Backend: nftables                                                                    β”‚
β”‚ Status: enabled βœ“                                                                    β”‚
β”‚                                                                                      β”‚
β”‚ Tables: 1                                                                            β”‚
β”‚ Flows: 150 / 4096                                                                    β”‚
β”‚                                                                                      β”‚
β”‚ Devices:                                                                             β”‚
β”‚   eth0   βœ“                                                                           β”‚
β”‚   br-lan  βœ“                                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€ Help ───────────────────────────────────────────────────────────────────────────────┐
β”‚                                                                                      β”‚
β”‚ Navigation                                                                           β”‚
β”‚   ↑ ↓ / j k        Move selection                                                    β”‚
β”‚   Enter            Expand selected                                                   β”‚
β”‚   Space                                                                              β”‚
β”‚   Tab                                                                                β”‚
β”‚                                                                                      β”‚
β”‚ Panels                                                                               β”‚
β”‚   1                Hardware                                                          β”‚
β”‚   2                Packet Pipeline                                                   β”‚
β”‚   3                Network Queues                                                    β”‚
β”‚   4                Interrupts                                                        β”‚
β”‚   5                SoftIRQ                                                           β”‚
β”‚   6                Packet Processing                                                 β”‚
β”‚   7                Hardware Offload                                                  β”‚
β”‚   8                Software Fast Path                                                β”‚
β”‚                                                                                      β”‚
β”‚ Actions                                                                              β”‚
β”‚   r                Refresh                                                           β”‚
β”‚   p                Pause updates                                                     β”‚
β”‚   e                Export diagnostics                                                β”‚
β”‚   ?                Toggle help                                                       β”‚
β”‚   q                Quit                                                              β”‚
β”‚                                                                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βš™οΈ MediaTek Hardware Acceleration (PPE & WED)

Modern MediaTek Filogic (MT798x) SoCs include two independent hardware acceleration engines that dramatically reduce CPU utilization during packet forwarding. Although they are often mentioned together, PPE and WED solve different problems and operate independently.

Packet Processing Engine (PPE)

The Packet Processing Engine (PPE) is a dedicated hardware accelerator responsible for forwarding established network flows without traversing the full Linux networking stack.

After the first packets of a connection are processed by the kernel (connection tracking, firewall, NAT, routing, etc.), compatible flows can be offloaded into the PPE through Linux nftables flowtables. Once offloaded, subsequent packets are forwarded almost entirely in hardware.

PPE accelerates:

  • IPv4 routing
  • NAT
  • PPPoE
  • VLAN forwarding
  • Checksum calculation
  • Long-lived TCP/UDP flows

In addition, the hardware is capable of supporting:

  • bridge forwarding
  • multicast forwarding
  • hardware flow aging
  • packet classification
  • ACLs
  • QoS/traffic prioritization

Support for these advanced capabilities depends on the Linux driver and OpenWrt implementation.

Wireless Ethernet Dispatcher (WED)

The Wireless Ethernet Dispatcher (WED) is a dedicated accelerator for the Wi-Fi data path.

Unlike the PPE, WED does not perform routing, NAT, firewalling or packet inspection. Its only responsibility is to accelerate packet movement between the Wi-Fi subsystem, DMA engines and the rest of the networking pipeline.

WED improves performance by:

  • reducing interrupt frequency
  • managing RX/TX DMA rings
  • accelerating descriptor processing
  • recycling packet buffers
  • optimizing DMA queue handling
  • improving burst traffic handling
  • reducing CPU cache pressure

The result is significantly lower CPU utilization while maintaining high Wi-Fi throughput.

How They Work Together

Although completely independent hardware blocks, PPE and WED complement each other.

For Wi-Fi to Ethernet traffic:

  1. WED accelerates packet movement inside the wireless subsystem.
  2. Linux processes only the first packets required to establish a flow.
  3. The flow is installed into the PPE.
  4. All subsequent packets bypass most of the Linux networking stack.

This architecture enables MediaTek Filogic routers to sustain near wire-speed routing while keeping CPU utilization extremely low.


πŸš€ Installation & Building

Since routers run on specific architectures (like ARM64 for MediaTek MT7981B) and use musl-libc, the easiest way to compile Conntracktor is using cross.

Prerequisites

Install Rust and cross on your development machine:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install cross

Build for ARM64 (OpenWrt)

git clone https://github.com/yourusername/conntracktor.git
cd conntracktor

# Cross-compile for aarch64 with musl (MT7981 / Filogic 820)
cross build --target aarch64-unknown-linux-musl --release

Deployment to the Router

⚠️ Important for hardware lifespan: To prevent unnecessary wear on the router's eMMC/Flash memory and avoid I/O bottlenecks, it is highly recommended to run the binary from /tmp (which is tmpfs / RAM).

# Copy the compiled binary to the router's RAM
scp target/aarch64-unknown-linux-musl/release/conntracktor root@192.168.1.1:/tmp/

# SSH into the router and run the monitor
ssh root@192.168.1.1
/tmp/conntracktor

πŸ› οΈ Configuration (Optional)

Currently, Conntracktor auto-detects ethX, lanX for wired connections and wlanX, phyX for wireless interfaces. If you have custom interface names (e.g., VLANs, WireGuard), you can map them in an optional config file or via CLI arguments (coming in v0.2).

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Connection monitor for OpenWrt, specializing in MediaTek Hardware Offloading (PPE & WED) analytics

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages