How 22bet10009-shuvam/packet_anomaly_detector works
This is a single-node desktop application (Python) that performs live network packet capture and runs intrusion detection on the captured traffic using:
• Rule-based detection (signatures/heuristics like SYN floods, port scans, keywords)
• ML-based anomaly detection (online baseline/clustering; “adaptive anomaly detection”)
…and then presents results in a professional GUI with:
• live packet feed
• alerts + severity
• explainable ML deviations
• mitigation/prevention suggestions
• alert history + export (CSV)
• configurable thresholds via YAML
File structure analysis (map folders → architectural components)
From the tree:
Entrypoints / Application bootstrap
• src/ids_app/__main__.py → python -m ids_app entrypoint
• src/ids_app/app.py → likely wires together UI + sniffer + detectors + config
Configuration
• src/ids_app/config/config.yaml → user-tunable thresholds, ML settings, keyword rules
• src/ids_app/core/config.py → config loader/validator and access object
Core runtime (capture + detect + model + suggestions)
• src/ids_app/core/sniffer.py → live packet capture (Npcap/scapy/pyshark-style)
• src/ids_app/core/detector.py → rule-based detection pipeline
• src/ids_app/core/ml_detector.py → ML anomaly model, baseline updates, scoring, explanations
• src/ids_app/core/models.py → domain models: Packet, Alert, HistoryEntry, etc. (and maybe DTOs)
• src/ids_app/core/suggestions.py → mapping alert type/severity → mitigation steps
UI layer (desktop GUI)
• src/ids_app/ui/main_window.py → GUI composition: packet table, alerts panel, controls
• src/ids_app/ui/theme.qss → styling (Qt stylesheet strongly implied)
Build/Deps
• requirements.txt → runtime dependencies (capture + GUI + ML stack)
• OS constraint: Windows + admin + Npcap (from README)
Architectural pattern implied: classic layered design:
• UI layer (presentation)
• Core/services (capture + detection + recommendation)
• Config + models (shared foundation)
No separate backend/server is evident; everything runs in one process.
README insights to explicitly include
Key runtime responsibilities to reflect:
• Live packet feed (high-throughput stream)
• Detection alerts + alert history
• ML explainability (“top feature deviations and anomaly score context”)
• Export dataset (CSV)
• Interface selection + start/stop capture
• YAML-configured thresholds
• Windows + Npcap dependency
• control flow (start/stop, adapter selection)
• data flow (packets → features → alerts → UI/history/export)
• stateful ML baseline (adaptive model updated over time)
Network Interface(s) (Ethernet/Wi‑Fi adapters)
Application (Python process: ids_app)
Config Loader + Config Object (core/config.py reading config/config.yaml)
13. Export Service (CSV) (even if implemented inside UI/core, show it as a distinct capability because it’s a user-facing subsystem)
Storage (likely local, lightweight)
14. In-memory Alert History / Dataset (if there’s no DB in tree, model it as in-memory + exported file)
Important design principles/patterns
• Single-process modular architecture (UI + Core in same runtime)
• Streaming pipeline (continuous packet ingestion)
• Two detection strategies in parallel (rule + ML)
• Stateful ML (online learning / clustering baseline)
• Explainability path (ML detector emits “top feature deviations” not just a score)
• Config-driven behavior (YAML controls thresholds and rules)
Relevant tech/frameworks
Based on cues:
• Python 3.10+
• Npcap (Windows packet capture driver)
• Qt-style UI implied by theme.qss (so likely PyQt/PySide). If requirements confirm later, annotate as “PySide6/PyQt”.
“Separate into as many components as possible” (without overthinking)
For maximum accuracy/detail, explicitly split these as separate components even if implemented together:
• Capture vs Decode/Parse vs Feature extraction
• Rule detection vs ML detection
• Alert aggregation vs Alert history store
• Suggestion mapping vs UI rendering
Level 0 (Context): User + Network + Windows/Npcap ↔ “IDS Live Monitor App”
2. Level 1 (Containers within app): UI ↔ Core (Sniffer + Detection + Suggestions) ↔ Config/Export