Simulation-driven AI agent pipeline for 5G core fault detection and response.
REAL METRICS -> REAL DETECTION -> REAL ACTION -> REAL VERIFICATION -> LLM EXPLANATION
src/simulation/: scenario and fault-driven simulation stream.src/collector/: bridge/parser that normalizes raw simulation metrics.src/agent/: observer, diagnoser, confidence, planner, executor, verifier.src/llm/: explanation-only output layer.src/utils/: runtime config and report logging.scenarios/: fault scenarios (f1,f2,f3,combo).reports/: generated audit and final report artifacts.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python run.py --engine simulationOptional scenario stream run:
python src/simulation/scenario_runner.py --scenario scenarios/f2_congestion.jsonDeploy ns-3 first:
./scripts/deploy_ns3.shRun with real mode:
python run.py --engine real --scenario scenarios/ns3_real_template.jsonReal mode contract:
- The ns-3 program must print one JSON metric record per line to stdout.
- Each record must include:
timestamp,latency,throughput,packet_loss,jitter. - Optional prefix
METRICis supported (e.g.,METRIC { ... }). - To support control actions, ns-3 should watch the configured
control_channelJSONL file.restart_nodeandreduce_loadactions are written there by the agent.
Scenario config keys for real mode:
ns3.command: command to launch ns-3 process.ns3.workdir: ns-3 repository working directory.ns3.control_channel: path for action command JSONL.
run.py executes:
- simulation stream (real ns-3 process in
--engine real) - collector normalization
- observer anomaly detection
- diagnoser fault mapping
- confidence scoring
- planner decision
- executor control action
- verifier post-action check
- audit logging
- LLM explanation (non-binding)
- Decision logic is deterministic and rule-based.
- LLM layer does not modify decisions or trigger actions.
- Reports are written to
reports/audit.jsonlandreports/final_report.json. --engine realis the production/spec path;--engine simulationis a local fallback.
The explainer now calls Ollama for incident text and the final run report when available. If Ollama is offline/unreachable, the pipeline automatically falls back to deterministic local text.
Default endpoint/model:
OLLAMA_HOST=http://127.0.0.1:11434OLLAMA_MODEL=llama3.1:8b
Run with explicit model selection:
OLLAMA_ENABLED=1 OLLAMA_MODEL=llama3.1:8b python run.py --engine real --scenario scenarios/ns3_real_template.jsonDisable Ollama and force local fallback:
OLLAMA_ENABLED=0 python run.py --engine real --scenario scenarios/ns3_real_template.jsonIf you see Ollama error model requires more system memory ... than is available, select a smaller model:
ollama pull qwen2.5:1.5b
OLLAMA_MODEL=qwen2.5:1.5b python run.py --engine real --scenario scenarios/ns3_real_template.jsonInstall/update Python dependencies:
pip install -r requirements.txtRun dashboard server:
uvicorn src.dashboard.server:app --reload --host 0.0.0.0 --port 8080If websocket live stream does not connect, install websocket runtime deps:
pip install websockets wsprotoOpen:
http://127.0.0.1:8080
The dashboard streams live updates from reports/live_metrics.jsonl and summary from reports/final_report.json.
Tip: if you run ./ns3 ... and see exit code 127, run the command from tools/ns-3-dev or use absolute path /home/pranay/ai5g/ns3-agentic/tools/ns-3-dev/ns3.
Use the Makefile so you do not need long CLI flags every time:
make help
make dashboard
make run-real
make run-real-ollama
make mentor-demoUseful overrides:
make run-real DURATION=60
make run-real-ollama OLLAMA_MODEL=qwen2.5:1.5b