Real-Time Network Intrusion Detection System โ a production-grade Deep Packet Inspection pipeline in C++, a live SOC dashboard in React, and a Streamlit DPI analyzer โ all deployed.
| Service | URL | What it does |
|---|---|---|
| Dashboard | netsentry-two.vercel.app | Live SOC โ world threat map, real-time alert feed, attack charts |
| DPI Analyzer | netsentry-dpi-adi.streamlit.app | Paste any payload โ classified with entropy analysis |
| API Health | netsentry-api.onrender.com/api/health | WebSocket + REST API status |
The Render free tier sleeps after 15 minutes of inactivity. First request after sleep takes ~30 seconds to wake up โ subsequent requests are instant.
NetSentry inspects network packets at wire speed, classifies them with signature matching + entropy analysis, and streams every threat to a global threat dashboard in real time.
- Aho-Corasick multi-pattern automaton matches thousands of Snort signatures in a single O(n) pass over packet payloads
- Shannon entropy profiling over 128-byte sliding windows detects encrypted C2 beaconing that evades signature-based IDS
- MATLAB
wavedec(H, 4, "db4")wavelet decomposition reveals periodic high-entropy bursts invisible to FFT โ the core research contribution - Bloom filter IP reputation pre-filter rejects 99.9% of benign IPs in ~5 ns before the full rule engine runs
- Lock-free SPSC ring buffer transfers packets from capture to dispatcher with zero locks, zero allocation
- WebSocket fan-out streams alerts to all connected dashboard clients in <5 ms
Text version of the architecture (click to expand)
Network / NIC
โ
โผ AF_XDP / libpcap โ zero-copy capture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ C++ DPI Engine โ
โ โโ Lock-free SPSC ring buffer โ
โ โโ 5-tuple dispatcher โ N worker threads โ
โ โโ Aho-Corasick pattern matcher โ
โ โโ Trie protocol parser โ
โ โโ Shannon entropy scorer โ
โ โโ Bloom filter IP reputation โ
โ โโ Rule engine โ {BLOCK, ALERT, LOG} โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ JSON lines โ stdout / Unix socket
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Node.js API ยท Port 3001 โ
โ โโ WebSocket server (ws.Server) โ
โ โโ REST API GET /api/alerts /stats โ
โ โโ POST /api/classify (Streamlit demo) โ
โ โโ In-memory alert store (ring, 1000 max) โ
โโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ WebSocket โ REST
โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ React Dashboardโ โ Streamlit Analyzer โ
โ โโ Leaflet map โ โ โโ Payload input โ
โ โโ Alert feed โ โ โโ Entropy gauge โ
โ โโ Recharts โ โ โโ Byte freq chart โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
| Structure | Used in | Complexity | Why |
|---|---|---|---|
| Aho-Corasick automaton | DPI core โ payload pattern match | O(n+m) build, O(n) search | Match thousands of Snort rules in a single pass over payload |
| Deterministic Trie | L4โL7 protocol parser | O(k) per lookup | Prefix-based protocol ID, no backtracking |
| Cuckoo hash (per-thread) | Flow state table (5-tuple key) | O(1) avg lookup | Zero cross-thread locking โ each worker owns its table |
| Bloom filter | IP reputation pre-filter | O(k) ยท 4 MB | Rejects 99.9% of benign IPs in ~5 ns |
| Lock-free SPSC ring | Capture โ dispatcher queue | O(1) wait-free | Zero allocation, zero CAS on the hot path |
| Michael-Scott MPSC queue | Worker threads โ alert relay | O(1) lock-free | Multiple producers, single consumer, guaranteed progress |
Traditional signature-based DPI (Snort, Suricata) is blind to encrypted command-and-control traffic. NetSentry adds a novel detection layer:
- Shannon entropy
H(X) = โฮฃ p(x) logโ(p(x))computed over 128-byte payload windows per flow - The resulting entropy time-series is passed to MATLAB
wavedec(H, 4, "db4")โ a 4-level Daubechies-4 Discrete Wavelet Transform - Level-1 and level-2 detail coefficients reveal periodic high-entropy spikes โ the signature of C2 beaconing
- The discriminator is timing regularity, not entropy alone โ benign TLS is also high-entropy, but only a beacon calls home on a regular cadence (low coefficient of variation)
Method: A flow is flagged as C2 only when it is both encrypted (mean entropy โฅ 6.5 bits) and periodic (inter-arrival regularity โฅ 0.55). This catches Cobalt Strike / Sliver-style beacons that bypass signature-based tools.
๐ See BENCHMARKS.md for detection accuracy, latency percentiles, and the full Snort comparison.
๐ฌ The full reproducible experiment harness lives in research/ โ run python research/selftest.py to validate the detector, then point it at real Stratosphere IPS captures.
git clone https://github.com/gitadi2/netsentry.git
cd netsentry
chmod +x start.sh && ./start.shOpen http://localhost:5173 โ dashboard is live with the built-in simulator.
# Terminal 1 โ API
cd netsentry\api
npm install
npm start
# Terminal 2 โ Dashboard
cd netsentry\frontend
npm install
npm run dev
# Terminal 3 โ Streamlit Analyzer
cd netsentry\streamlit
pip install -r requirements.txt
python -m streamlit run app.pycd cpp
mkdir build && cd build
# macOS / dev mode (no libpcap)
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j4
./netsentry --sim
# Linux โ live packet capture (requires libpcap + root)
sudo apt install libpcap-dev
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_PCAP=ON
make -j$(nproc)
sudo ./netsentry --iface eth0Once built, the Node API auto-detects the binary and pipes its JSON output instead of the JS simulator:
[NetSentry] C++ engine connected at /path/to/cpp/build/netsentry
The C++ core is covered by a 31-test GoogleTest suite spanning the Aho-Corasick matcher, Bloom filter, entropy function, and the classify rule engine.
cd cpp
cmake -B build -DBUILD_TESTS=ON
cmake --build build
./build/netsentry_tests # Windows: .\build\netsentry_tests.exeGoogleTest is fetched automatically via CMake FetchContent โ no manual install needed.
# Start the API locally, then in another terminal:
pip install aiohttp numpy matplotlib requests
python benchmark/detection_test.py # detection accuracy vs Snort
python benchmark/load_test.py # latency / throughput percentiles
python benchmark/plot_latency.py # render the latency chartFull results, methodology, and the Snort comparison are in BENCHMARKS.md.
docker compose up --build- Dashboard โ
http://localhost:5173 - API โ
http://localhost:3001 - Streamlit โ
http://localhost:8501
- New โ Web Service โ connect GitHub repo
- Root Directory:
api - Build:
npm install - Start:
node server.js - Instance: Free
- New Project โ import repo
- Root Directory:
frontend - Framework Preset: Vite (auto-detected)
- Environment variables:
VITE_API_URL=https://netsentry-api.onrender.comVITE_WS_URL=wss://netsentry-api.onrender.com
- New app โ repo โ
streamlit/app.py - Secrets:
NETSENTRY_API = "https://netsentry-api.onrender.com" NETSENTRY_DASH = "https://netsentry-two.vercel.app"
Every push to main auto-redeploys all three services.
netsentry/
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml โ GitHub Actions โ build, lint, health check
โโโ cpp/
โ โโโ src/
โ โ โโโ netsentry.h โ AhoCorasick ยท BloomFilter ยท entropy ยท FlowTable
โ โ โโโ main.cpp โ simulator + libpcap capture + JSON stdout
โ โโโ tests/
โ โ โโโ test_netsentry.cpp โ GoogleTest suite (31 tests)
โ โโโ CMakeLists.txt โ engine build + BUILD_TESTS / COVERAGE options
โโโ api/
โ โโโ server.js โ Express + ws + REST + built-in JS simulator
โ โโโ package.json
โโโ frontend/
โ โโโ src/
โ โ โโโ App.jsx โ WebSocket client, state, layout
โ โ โโโ index.css โ pure black SOC theme + Leaflet overrides
โ โ โโโ components/
โ โ โโโ ThreatMap.jsx โ Leaflet map ยท radar sweep ยท animated arcs
โ โ โโโ AlertFeed.jsx โ scrollable alert list ยท country leaderboard
โ โ โโโ StatsBar.jsx โ header ยท live counters
โ โ โโโ Charts.jsx โ alerts/s timeline ยท threat donut
โ โโโ vite.config.js
โโโ streamlit/
โ โโโ app.py โ DPI analyzer ยท entropy gauge ยท byte freq chart
โ โโโ requirements.txt
โโโ benchmark/
โ โโโ detection_test.py โ accuracy harness vs Snort baseline
โ โโโ load_test.py โ latency / throughput harness
โ โโโ plot_latency.py โ renders the latency percentile chart
โโโ research/
โ โโโ c2_detect.py โ entropy + db4 wavelet + IAT-regularity classifier
โ โโโ selftest.py โ synthetic labeled flows โ validates the detector
โ โโโ run_pcap.py โ runs detection on real pcaps (Stratosphere IPS)
โ โโโ plot_c2.py โ renders the beacon-vs-benign figure
โ โโโ requirements.txt โ scapy ยท numpy ยท scipy ยท matplotlib ยท PyWavelets
โ โโโ README.md โ full reproducible experiment workflow
โโโ docs/
โ โโโ system-design.png โ architecture diagram (this README)
โ โโโ system-design.svg โ vector source for slides / print
โ โโโ latency-percentiles.png
โ โโโ c2-detection.png โ C2 beacon vs benign timing comparison
โโโ Dockerfile.api
โโโ Dockerfile.frontend
โโโ Dockerfile.cpp
โโโ docker-compose.yml
โโโ start.sh โ one-command dev launcher
โโโ BENCHMARKS.md
โโโ README.md
| Layer | Technology |
|---|---|
| DPI Engine | C++17 ยท CMake ยท libpcap ยท std::atomic ยท pthread |
| Algorithms | Aho-Corasick ยท Shannon entropy ยท MATLAB db4 wavelet ยท FNV-1a ยท MurmurHash3 |
| Data Structures | Bloom filter ยท Trie ยท Cuckoo hash ยท SPSC/MPSC lock-free queues |
| API | Node.js 20 ยท Express 4 ยท ws (WebSocket) |
| Frontend | React 18 ยท Vite 5 ยท Leaflet ยท Recharts |
| Analyzer | Streamlit ยท Plotly ยท NumPy |
| Research | Python ยท SciPy ยท PyWavelets ยท scapy |
| Testing | GoogleTest (C++) ยท GitHub Actions CI |
| Infra | Docker ยท docker-compose ยท Nginx ยท GitHub Actions |
| Deploy | Vercel ยท Render ยท Streamlit Cloud ยท GitHub |
- C++ DPI core with Aho-Corasick, Bloom filter, entropy
- Node.js WebSocket API with built-in simulator fallback
- React dashboard with live Leaflet threat map
- Streamlit DPI analyzer with entropy gauge
- Docker deploy for all services
- Cloud deploy (Vercel + Render + Streamlit Cloud)
- Benchmark suite + document vs Snort
- GoogleTest unit tests for C++ core (31 tests)
- C2 detection research harness (entropy + wavelet + IAT regularity)
- Jest integration tests for the API
- Prometheus
/metricsendpoint + Grafana dashboard - JWT authentication + rate limiting on the API
- Kubernetes manifests (Deployment, Service, HPA)
- Real AF_XDP integration (currently libpcap fallback)
| Symptom | Fix |
|---|---|
| Dashboard shows RECONNECTING | Wake the Render API โ visit /api/health directly, then refresh |
| Streamlit shows OFFLINE | Check the NETSENTRY_API secret on Streamlit Cloud โ no trailing slash, https:// prefix |
| Map tiles don't load | Check internet โ CartoDB tiles need network |
| WebSocket disconnects on Render | Render free tier sleeps after 15 min โ upgrade to Starter ($7/mo) for always-on |
| C++ fails to compile | Need CMake โฅ 3.16, GCC โฅ 11, and libpcap-dev on Linux |
| Vercel build fails | Root directory must be frontend, not /frontend |
MIT โ use freely for portfolio, interviews, research, or commercial projects.
ADITYA SATAPATHY

