A local network monitoring and attack mitigation dashboard built with Python. It captures live traffic, detects five attack types, uses a local LLM (via Ollama) to reason about threats, and automatically applies temporary IP route blocks — all visible in a real-time browser dashboard.
https://prasadadi18.github.io/NETWORK_MONITORING/
This is a simulation, not the running system. GitHub Pages serves static files only — it cannot run
main.py, capture packets with Scapy, reach a local Ollama instance, or modify routing tables. The demo underdocs/reproduces the dashboard UI and replays the detection → LLM verdict → mitigation → auto-revert pipeline entirely in the browser, using the same thresholds, attack labels, and mitigation commands as the real backend. To see real traffic being captured and blocked, runpython main.pylocally as Administrator (see Run the dashboard below).
network_sniffer.py — captures traffic and extracts packet metadata using Scapy.attack_detector.py — detects ICMP flood, SYN flood, UDP flood, port scan, and fragmentation attacks using sliding-window counters.llm_analyzer.py — sends threat evidence to Ollama, receives a JSON verdict, and extracts the mitigation command.mitigator.py — applies a temporary IP route block (route add on Windows, ip route blackhole on Linux) and auto-reverts it after 60 seconds.main.py — Flask + Socket.IO dashboard; orchestrates all threads.attack_injector.py — injects test attacks over loopback for local testing.| Dependency | Why | Windows | Linux |
|---|---|---|---|
| Python 3.11+ | Runtime | python.org | sudo apt install python3 |
| Npcap | Scapy needs it to capture packets | npcap.com — install with “WinPcap API-compatible mode” checked | sudo apt install libpcap-dev |
| Ollama | Local LLM backend | ollama.com/download | curl -fsSL https://ollama.com/install.sh \| sh |
Admin / root privileges are required. Packet capture and IP route manipulation both need elevated permissions.
requirements.txt)Download from npcap.com and install it. Check “WinPcap API-compatible mode” during installation — Scapy requires it.
ollama pull tinyllama
Default model is
tinyllama. You can use any model Ollama supports (e.g.llama3,mistral) by setting theOLLAMA_MODELenvironment variable.
cd path\to\cnfinal
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
ollama serve
Ollama must be running at http://localhost:11434 before the app starts. Verify it is up:
curl http://localhost:11434/api/tags
If Ollama is unreachable, the system falls back to built-in rule-based analysis automatically — no crash.
If you want to sniff a specific interface instead of letting Scapy auto-detect:
python find_interface.py
This prints all available interfaces with their IP addresses. Note the name of the one you want to use.
python main.py
On Windows, right-click your terminal and choose Run as administrator before activating the venv —
route addrequires elevation.
Optional flags:
--interface Network interface to sniff (e.g. "NPF_Loopback"). Default: auto-detect.
--threshold Packets/sec to trigger an alert. Default: 100.
--port Web dashboard port. Default: 5000.
Example with flags:
python main.py --interface "NPF_Loopback" --threshold 50 --port 8080
http://localhost:5000
guardian.log.You can also inject attacks manually without the browser:
python attack_injector.py --attack icmp_flood --rate 150 --duration 10
python attack_injector.py --attack syn_flood --rate 80 --duration 10
python attack_injector.py --attack udp_flood --rate 150 --duration 10
python attack_injector.py --attack port_scan --ports 100
python attack_injector.py --attack fragmentation
python attack_injector.py --attack all --duration 5
All attacks use 203.0.113.50 (RFC 5737 TEST-NET) as the fake source IP so the detector can block it without refusing to block a loopback address.
mitigator.py never passes the LLM’s text directly to a shell. It validates the IP and constructs the OS command itself — no command injection risk.route add <ip> mask 255.255.255.255 192.0.2.1 (RFC 5737 blackhole gateway).ip route add blackhole <ip>/32..gitignore guardian.log to avoid large log files in the repo.OLLAMA_BASE_URL — Ollama endpoint, default http://localhost:11434OLLAMA_MODEL — model name, default tinyllamaALLOW_LOOPBACK_BLOCK=true — enables blocking loopback IPs (only needed if you override FAKE_ATTACKER_IP in attack_injector.py)main.py starts without errors.http://localhost:5000.guardian.log for detector, LLM analyzer, and mitigator events.