End-to-end O-RAN Near-RT RIC testbed with srsRAN + Open5GS, KPM Style 5 xApps, experiment generator, and cascaded ML for malicious UE detection.

End-to-end framework for generating realistic multi-UE 4G/5G RAN experiments (benign + attack traffic), collecting standardized O-RAN KPM Style 5 metrics, engineering temporal features, and performing cascaded multi-stage malicious UE classification inside a Near-RT RIC python xApp.
This repository contains:
kpm5_xapp.py).detector_xapp.py).generate_experiments.py, generate_malicious_experiments.py) producing structured per-run folders with traffic profiles & radio channel parameters.run_enhanced.sh) that orchestrates: RIC stack, core (Open5GS), srsRAN gNB + UEs, GNU Radio fading/channel scenario, traffic generation (iperf profiles), metric capture, retries, health checks, and cleanup.The system enables repeatable dataset creation and online inference without writing intermediate CSVs for the detector (buffer-based streaming processing).
+----------------------+ +---------------------+ +------------------+
| Traffic Profiles & | | Experiment Folders | | run_enhanced.sh |
| (iperf scripts) | ---> | trX/expY: | --> | Orchestrator |
| normal/malicious | | - conditions.csv | | (RIC+Core+RAN) |
+----------+-----------+ | - run_scenario.sh | +---------+--------+
| | - metrics/ | |
| +----------+-----------+ |
v | v
generate_experiments.py / | Near-RT RIC (docker)
generate_malicious_experiments.py | - submgr / e2term / appmgr
v - python_xapp_runner
GNU Radio Channel Model |
| |
srsRAN gNB (tmux) <---- E2 ----> KPM xApp
| \
UE netns (srsUE x N) \
| \
iperf traffic (benign/malicious) \
| \
+--------> Detector xApp (buffer -> engineered features -> cascade models)
Key flows:
| Component | File(s) | Purpose |
|---|---|---|
| KPM Metrics Collector xApp | kpm5_xapp.py | Subscribes to Style 5, writes wide CSV (one row per UE per indication) |
| Malicious Detector xApp | detector_xapp.py | Buffers metrics, engineers features, cascaded prediction (Stage 1 binary → Stage 2 subtype) |
| xApp Base Abstraction | openran/oran-sc-ric/xApps/python/lib/xAppBase.py | Wraps RMR init, HTTP subscription callbacks, threading, subscription dispatch |
| E2SM-KPM Handling | openran/oran-sc-ric/xApps/python/lib/e2sm_kpm_module.py (not expanded here) | Packs/unpacks KPM indications and subscription payloads |
| Experiment Generator (benign) | generate_experiments.py | Creates structured experiment folders with M-map stochastic assignment |
| Experiment Generator (malicious) | generate_malicious_experiments.py | Same as above but injects malicious traffic profiles (2 malicious UEs / run) |
| Orchestrator Script | run_enhanced.sh | Starts/stops entire stack, health checks, retries, validates outputs |
| Models | openran/oran-sc-ric/xApps/python/lib/ml_models.py & external .joblib artifacts | Defines neural architectures used during training/inference |
| GNU Radio Scenario | multi_ue_scenario.grc / generated runner scripts | Provides RF/channel impairment dynamics |
Each generated experiment (e.g. generated_malicious_experiments/tr12/exp1/) contains:
conditions.csv # UE ↔ iperf profile mapping + M-map & channel params
run_scenario.sh # Launches GNU Radio scenario & writes PID to /tmp/python_scenario.pid
metrics/ # Output metrics (if collector xApp used)
ue_logs/ # Per UE stdout, metrics CSV, pcap, tracing
gnb_logs/ # gNB logs, pcap traces
The orchestrator later augments these directories with runtime artifacts.
Raw subscribed metrics (default list):
RRU.PrbAvailDl, RRU.PrbAvailUl, RRU.PrbUsedDl, RRU.PrbUsedUl,
RACH.PreambleDedCell, DRB.UEThpDl, DRB.UEThpUl,
DRB.RlcPacketDropRateDl, DRB.RlcSduTransmittedVolumeDL, DRB.RlcSduTransmittedVolumeUL,
CQI, RSRP, RSRQ, DRB.RlcSduDelayDl, DRB.RlcDelayUl
Derived (detector) features include (non-exhaustive):
The detector reindexes engineered frame to the feature signature expected by loaded models (self.selected_features).
UE 2 → Malicious-udp_flood).--buffer_size, default 30) and periodically cleared after large accumulation (1440 rows safeguard).run_enhanced.sh)Major phases (with retries/backoff):
ric_submgr health.ue_data.csv).run_scenario.sh.conditions.csv.python_xapp_runner container.Resilience features:
retry_with_backoff).traffic_profiles/cd openran/oran-sc-ric
docker compose up -d
# Enter runner and launch xApp
docker compose exec python_xapp_runner bash -c "./kpm5_xapp.py --metrics_dir metrics --ue_ids 0,1,2"
Place model artifacts in the mounted xApps/python directory (or provide relative paths). Then:
docker compose exec python_xapp_runner bash -c "./detector_xapp.py \
--s1_model_path s1_model.joblib \
--s2_ben_path s2_benign_model.joblib \
--s2_mal_path s2_malicious_model.joblib \
--buffer_size 60 --ue_ids 0,1,2"
python3 generate_experiments.py # benign runs (50 by default)
python3 generate_malicious_experiments.py # malicious-injected runs (100 by default)
Edit path constants near the top of run_enhanced.sh (or parameterize) then:
bash run_enhanced.sh 0 1 # start from training set 0, experiment 1
metrics/kpm_style5_metrics.csv wide form (Timestamp, E2AgentID, SubscriptionID, UE_ID, Granularity, <metrics...>).ue_logs/ueX_metrics.csv (native srsUE metrics if enabled) + pcaps.Model artifacts (*.joblib) expected to deserialize into either:
nn.Module objects, or.predict().To add a new feature:
_feature_engineer_network_data.self.selected_features ordering updated.To support output logging of predictions, extend predict_cascaded() to append to a CSV or push RMR control messages.
ue1..ue3) are deleted at cleanup.10.45.0.0/16 via 10.53.1.2 added if missing; removed on teardown.| Area | Improvement |
|---|---|
| Config Hardcoding | Externalize paths (CSV_FILE, BASE_EXP_DIR) via env/CLI args. |
| Model Feature Sync | Automate persistence of selected_features to avoid mismatch risk. |
| Detector Persistence | Log per-UE classification timeline to disk for auditing. |
| Real-time Control | Add RIC control messages when malicious UE detected (e.g., throttle or isolate). |
| CI Testing | Add unit tests mocking E2 indications & feature pipeline correctness. |
| Metrics Streaming | Optionally stream engineered features to a time-series DB (e.g., InfluxDB, Prometheus). |
| Parameter Search | Integrate automated hyperparameter search & model registry. |
| Visualization | Dashboard for live UE status & feature trends. |
| Action | Command (example) |
|---|---|
| Start RIC | cd openran/oran-sc-ric && docker compose up -d |
| Run KPM xApp | docker compose exec python_xapp_runner ./kpm5_xapp.py --ue_ids 0,1,2 |
| Run Detector xApp | docker compose exec python_xapp_runner ./detector_xapp.py --buffer_size 60 |
| Generate Benign Experiments | python3 generate_experiments.py |
| Generate Malicious Experiments | python3 generate_malicious_experiments.py |
| Run Automated Pipeline | bash run_enhanced.sh 0 1 |
This repository underpins a dissertation project exploring online RAN telemetry analytics for malicious UE behavior detection using multi-stage classification and temporal feature extraction over E2SM-KPM Style 5 streams within an O-RAN Near-RT RIC testbed.
If publishing, cite O-RAN specifications and srsRAN / Open5GS projects accordingly.
See upstream component licenses (O-RAN SC images, srsRAN, Open5GS). Local additions fall under the repository's chosen license (add a LICENSE file if not already present for clarity).
Open to extensions (pull requests) focusing on: configuration externalization, control-plane reactions, richer model evaluation, or visualization tooling.
Core functionality implemented: experiment generation, orchestration, KPM collection, feature engineering, cascaded detection. Ready for iterative refinement & evaluation.
Stars
1
Forks
2
Watchers
0
Primary Language
C++