Real-Time Network Monitor with Web Dashboard
A high-performance, modular network monitoring daemon written in C++17 that captures packets, tracks active connections, and aggregates bandwidth and protocol statistics in real-time. Features a modern web-based dashboard with live visualizations, session-based authentication, and a REST API for programmatic access.
Key Features:
- π Real-time bandwidth visualization (D3.js line charts)
- π Secure session-based authentication with bcrypt
- π Modern web dashboard with live updates
- π Protocol breakdown pie charts (TCP/UDP/OTHER)
- π Active connection tracking and display
- π‘οΈ Privilege dropping for security
- π¦ SQLite persistence for historical data
- β‘ Sub-second latency metrics
- macOS/Linux with libpcap installed
- C++17 compiler (clang++ or g++)
- CMake 3.16+
- Python 3.x with pip (for integration tests)
- Root/sudo access (for packet capture)
- envsubst (usually included with
gettext)
# Clone repository
git clone https://github.com/humanauction/net-net.git
cd net-net
# Build daemon
make clean
make build
# Start daemon with live capture (requires sudo)
make demon
# Or start with environment variables for your interface
NETNET_IFACE=en0 NETNET_BPF_FILTER="" make demon
# Open dashboard in browser
open http://localhost:8082The project includes a comprehensive Makefile with the following targets:
| Command | Description |
|---|---|
make |
Build all binaries |
make build |
Build the project |
make rebuild |
Clean and rebuild |
make demon |
Run daemon with live capture (requires sudo) |
make demon-stop |
Stop running daemon |
make demon-ol |
Run daemon with PCAP file replay |
make test |
Run ALL tests (C++ + Python) |
make test-cpp |
Run C++ tests only |
make test-python |
Run Python integration tests only |
make coverage |
Generate coverage report |
make coverage-html |
Generate HTML coverage report |
make clean |
Clean all build artifacts |
make venv |
Set up Python virtual environment |
make config-ci |
Generate CI config from template |
Configure capture settings via environment variables:
export NETNET_IFACE=en0 # Network interface (default: en0)
export NETNET_USER=nobody # User for privilege drop
export NETNET_GROUP=nobody # Group for privilege drop
export NETNET_BPF_FILTER="" # BPF filter (empty = capture all)- Username:
admin - Password:
adminpass
Real-time bandwidth monitoring with protocol breakdown and active connections
Secure session-based authentication
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Web Dashboard β
β (HTML/CSS/JavaScript + D3.js) β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β REST API (HTTP)
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β NetMonDaemon (C++) β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β SessionManager (bcrypt + SQLite) β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β REST API (cpp-httplib) β β
β β β’ /login, /logout, /metrics β β
β β β’ /control/{start,stop,reload} β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β StatsAggregator (Metrics) β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β ConnectionTracker (Flow State) β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β Parser (Ethernet/IPv4/TCP/UDP/ICMP) β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β PcapAdapter (libpcap wrapper) β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βββββββββΌββββββββββ
β Network β
β Interface β
β (en0, eth0) β
βββββββββββββββββββ
See docs/design.md for detailed architecture documentation.
net-net/
βββ src/ # C++ source code
β βββ core/ # Core monitoring logic
β β βββ Parser.{cpp,h} # Packet parsing (EthernetβIPβTCP/UDP)
β β βββ ConnectionTracker.{cpp,h} # Flow tracking
β β βββ StatsAggregator.{cpp,h} # Metrics aggregation
β β βββ StatsPersistence.{cpp,h} # SQLite storage
β β βββ SessionManager.{cpp,h} # Authentication
β β βββ PacketMeta.h # Packet metadata structures
β βββ net/ # Network adapters
β β βββ PcapAdapter.{cpp,h} # libpcap wrapper
β βββ daemon/ # Daemon implementation
β βββ Main.cpp # Entry point
β βββ NetMonDaemon.{cpp,h} # Main daemon class
β βββ httplib.h # HTTP server (header-only)
βββ www/ # Web dashboard
β βββ index.html # Dashboard UI
β βββ style.css # Styling
β βββ app.js # JavaScript (D3.js + Chart.js)
βββ include/net-net/vendor/ # Third-party code
β βββ bcrypt.{cpp,h} # Password hashing
β βββ uuid_gen.{cpp,h} # Session token generation
βββ tests/ # Test suites
β βββ unit/ # C++ unit tests (GoogleTest)
β βββ integration/ # Python integration tests
β βββ fixtures/ # Test PCAP files
βββ docs/ # Documentation
β βββ design.md # Architecture overview
β βββ api.md # REST API reference
β βββ EntityRelationshipDataModel.md # Database schema
β βββ packetFlowDiagram.md # Packet processing flow
β βββ securityChecklistReview.md # Security audit
βββ examples/ # Configuration templates
β βββ sample-config.yaml # Template with env vars
β βββ sample-config.ci.yaml # Generated CI config
βββ CMakeLists.txt # Build configuration
βββ Makefile # Build wrapper
βββ README.md # This file
Configuration uses YAML with environment variable substitution. The Makefile generates sample-config.ci.yaml from sample-config.yaml using envsubst.
interface:
name: "${NETNET_IFACE}" # Network interface (e.g., en0, eth0)
promiscuous: true # Capture all packets on segment
snaplen: 65535 # Max bytes per packet
timeout_ms: 1000 # Read timeout
bpf_filter: "${NETNET_BPF_FILTER}" # BPF filter (empty = all traffic)offline:
file: "/path/to/capture.pcap" # Uncomment to replay PCAP fileapi:
enabled: true
host: "0.0.0.0" # Listen address
port: 8082 # Listen port
token: "your_secure_token" # For /control endpoints
session_expiry: 3600 # Session timeout (seconds)users:
- username: "admin"
password: "$2a$12$..." # bcrypt hash
- username: "user"
password: "$2a$12$..."Generate bcrypt hashes:
python3 -c "import bcrypt; print(bcrypt.hashpw(b'yourpassword', bcrypt.gensalt()).decode())"tracking:
idle_timeout: 300 # Remove idle connections after N seconds
cleanup_interval: 60 # Cleanup check intervalstats:
window_size: 60 # Aggregation window (seconds)
history_depth: 24 # Number of windows to retaindatabase:
path: "/tmp/netnet.db" # SQLite file path
retention_days: 7 # Data retention periodprivilege:
drop: true
user: "${NETNET_USER}"
group: "${NETNET_GROUP}"logging:
level: "debug" # debug, info, warn, error
file: "" # Empty = stdout
timestamps: trueAuthenticate user and receive session token.
Request:
{
"username": "admin",
"password": "adminpass"
}Response:
{
"token": "550e8400-e29b-41d4-a716-446655440000",
"username": "admin",
"expires_in": 3600
}Invalidate session token.
Headers:
X-Session-Token: <token>Retrieve current network statistics.
Headers:
X-Session-Token: <token>Response:
{
"timestamp": 1732656147000,
"window_start": 1732656140,
"total_bytes": 1048576,
"total_packets": 256,
"bytes_per_second": 104857,
"protocol_breakdown": {
"TCP": 900000,
"UDP": 148576,
"OTHER": 0
},
"active_flows": [
{
"src_ip": "192.168.1.100",
"src_port": 54321,
"dst_ip": "142.250.80.46",
"dst_port": 443,
"protocol": "TCP",
"bytes": 15360,
"packets": 45
}
]
}Start packet capture.
Stop packet capture.
Reload configuration file.
Headers (all control endpoints):
Authorization: Bearer <api_token>See docs/api.md for complete API documentation.
make testmake test-cppmake test-python# Terminal summary
make coverage
# HTML report (opens in browser)
make coverage-htmlTest Suites:
test_parser- Packet parsing logictest_pcap_adapter- Capture adaptertest_connection_tracker- Flow trackingtest_stats_aggregator- Metrics aggregationtest_session_manager- Authentication
- β Privilege Dropping: Daemon drops to configured user/group after opening capture device
- β bcrypt Password Hashing: All passwords hashed with salt
- β Session Tokens: UUID-based tokens, SQLite-backed, configurable expiry
- β Rate Limiting: Control endpoints limited to 1 request per 2 seconds per IP
- β Input Validation: BPF filter sanitization, JSON schema validation
- β No Credential Logging: Passwords never logged or displayed
- β HTTPS Ready: Designed for reverse proxy (nginx/Caddy) with TLS
- Change default passwords
- Use strong API tokens (32+ characters)
- Enable HTTPS via reverse proxy
- Restrict API access by IP/firewall
- Run daemon as dedicated user
- Enable audit logging
- Review
docs/securityChecklistReview.md
# Check you're capturing on the right interface
ifconfig | grep -B1 "inet "
# Run with empty BPF filter to capture ALL traffic
NETNET_IFACE=en0 NETNET_BPF_FILTER="" make demon# Packet capture requires root
sudo ./build/netnet-daemon --config examples/sample-config.ci.yaml
# Or use make target (includes sudo)
make demon# Kill existing daemon
sudo pkill netnet-daemon
# Check what's using the port
lsof -i :8082# List available interfaces (macOS)
ifconfig | grep -E "^[a-z]" | cut -d: -f1
# Common interfaces:
# macOS WiFi: en0
# macOS Ethernet: en1
# Linux: eth0, wlan0
# Loopback: lo0 (macOS), lo (Linux)- Check daemon is running:
ps aux | grep netnet-daemon - Check port:
lsof -i :8082 - Verify config has
host: "0.0.0.0"not"localhost"
# Clear browser localStorage (F12 console)
localStorage.clear()- Architecture design
- Entity-relationship diagram
- Packet flow diagram
- Config schema definition
- PcapAdapter implementation
- BPF filter validation
- Unit tests with mocked adapter
- Integration tests with PCAP files
- Multi-protocol parser (Ethernet/IPv4/IPv6/TCP/UDP/ICMP)
- 5-tuple flow tracking
- Connection state machine
- Per-flow throughput counters
- Rolling-window metrics
- In-memory ring buffer
- SQLite persistence
- Configurable aggregation windows
- NetMonDaemon headless mode
- REST API with cpp-httplib
- Session-based authentication
- Rate limiting
- Privilege dropping
- Configurable logging
- HTML/CSS/JavaScript frontend
- Real-time bandwidth chart (D3.js)
- Protocol breakdown pie chart (Chart.js)
- Active connections table
- Login/logout UI
- Session token management
- CI/CD pipeline (GitHub Actions)
- Code coverage reporting (gcov/gcovr)
- Comprehensive Makefile
- Environment variable configuration
- Documentation updates
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Before submitting:
- Run tests:
make test - Check formatting:
clang-format -i src/**/*.cpp src/**/*.h - Update documentation if needed
This project is licensed under the MIT License - see LICENSE file for details.
- libpcap - Packet capture
- cpp-httplib - HTTP server
- yaml-cpp - YAML parsing
- nlohmann/json - JSON handling
- GoogleTest - Unit testing
- D3.js - Data visualization
- Chart.js - Pie charts
- bcrypt - Password hashing
- GitHub Issues: github.com/humanauction/net-net/issues
- Email: humanauction@gmail.com