NETWORK_MONITORING

Network Guardian

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.

Live demo (GitHub Pages)

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 under docs/ 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, run python main.py locally as Administrator (see Run the dashboard below).

What this project does

Requirements

System dependencies

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.

Python dependencies (requirements.txt)

Setup

1. Install Npcap (Windows only)

Download from npcap.com and install it. Check “WinPcap API-compatible mode” during installation — Scapy requires it.

2. Install Ollama and pull the model

ollama pull tinyllama

Default model is tinyllama. You can use any model Ollama supports (e.g. llama3, mistral) by setting the OLLAMA_MODEL environment variable.

3. Navigate to the project folder

cd path\to\cnfinal

4. Create a Python virtual environment

python -m venv .venv

5. Activate the environment

.venv\Scripts\activate

6. Install dependencies

pip install -r requirements.txt

Run the dashboard

Step 1 — Start Ollama (in a separate terminal)

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.

Step 2 — (Optional) Find your network interface

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.

Step 3 — Start the application (run as Administrator)

python main.py

On Windows, right-click your terminal and choose Run as administrator before activating the venv — route add requires 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

Step 4 — Open the dashboard

http://localhost:5000

How to check the project

Command-line attack injection

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.

Notes

Useful checks