An Open RAN (O-RAN) Near-Real-Time RIC xApp for Dynamic Subcarrier Allocation in 5G/6G Integrated Sensing and Communication (ISAC) networks using DJCSR (D3QN-Based Joint Communication–Sensing Resource Optimization) Framework by Deep Dueling Double Q-Networks (D3QN), integrated with OpenAirInterface (OAI) and FlexRIC.
As 5G-Advanced and 6G networks evolve toward Integrated Sensing and Communication (ISAC), base stations (gNBs) must dynamically share spectrum and subcarriers between target radar sensing and multi-tenant communication services (eMBB and URLLC).
DJCSR/
├── Train_Model/ # Offline D3QN training (pure simulation, no RIC/E2)
│ ├── environment.py # ISACEnvironment: 3-gNB ISAC channel + sensing model, 16-dim state
│ ├── agent.py # Dueling Double DQN (D3QN), replay buffer, Double-DQN target
│ └── train.py # Training + evaluation loop -> d3qn_isac_best.pth / d3qn_isac_final.pth
├── OAI_FlexRIC/
│ ├── launch_topology.py # Launches 3 gNBs + 10 namespaced UEs on the OAI RF simulator
│ ├── generate_traffic.sh # Background ping traffic per UE namespace
│ └── d3qn_isac_final.pth # Trained checkpoint loaded by the live xApp
├── Metrics/
│ ├── plot_metrics.py # Renders throughput / latency / sensing-RMSE plots from a metrics CSV
│ └── live_metrics.csv # Per-epoch metrics written by the live xApp
├── examples/ # Vendored FlexRIC examples (unmodified except the added xapp_isac.py)
│ ├── emulator/ # E2 node emulators (synthetic RAN)
│ ├── ric/ # nearRT-RIC executable (near_ric.c)
│ └── xApp/
│ ├── c/ # C xApp examples (monitor, ctrl, slice, tc, kpm_rc, ...)
│ └── python3/
│ └── xapp_isac.py # OFFLINE variant: steps ISACEnvironment only, no E2 (not for testbed runs)
├── openair2/ # Partial OAI overlay - NOT built by this repo's CMake;
│ │ # must be copied over an openairinterface5g source tree
│ ├── E2AP/
│ │ ├── RAN_FUNCTION/
│ │ │ ├── init_ran_func.c # Registers KPM/RC + custom MAC/RLC/PDCP/GTP/SLICE/TC callbacks
│ │ │ ├── CUSTOMIZED/ # FlexRIC-custom (non-O-RAN) service-model handlers
│ │ │ │ ├── ran_func_mac.c # MAC UE stats harvester (scheduler-mutex protected)
│ │ │ │ ├── ran_func_rlc.c # RLC per-bearer stats: SDU delay, buffer occupancy, retx
│ │ │ │ ├── ran_func_slice.c # SLICE control handler - currently logs ADD/DEL/ASSOC + returns ACK only
│ │ │ │ └── ran_func_{pdcp,gtp,tc}.c
│ │ │ └── O-RAN/ # O-RAN-standard service models
│ │ │ ├── ran_func_kpm.c / ran_func_kpm_subs.c # E2SM-KPM measurements + subscriptions
│ │ │ └── ran_func_rc.c / ran_func_rc_subs.c # E2SM-RC
│ │ └── flexric/ # Full vendored FlexRIC copy that the OAI build links against
│ │ └── examples/xApp/python3/xapp_isac.py # LIVE E2 xApp: D3QN inference -> SLICE control
│ ├── E3AP/ # E3 (real-time RIC / dApp) interface
│ └── LAYER2/
│ ├── NR_MAC_gNB/
│ │ └── gNB_scheduler_dlsch.c # NR downlink scheduler - UNMODIFIED; target for slice-quota actuation
│ └── MAC/slicing/ # LTE slicer (NVS/EDF) - vendored, unused by the NR path
├── oai-workshops/ # OAI CN5G + RAN deployment helpers
│ ├── cn/ # 5G core docker-compose
│ └── ran/conf/isac_setup/ # gnb1-3.conf, ue1-10.conf for the ISAC topology
├── src/ test/ # Vendored upstream FlexRIC platform (identical to mosaic5g dev, v2.0.0)
├── docker/ openshift/ # Deployment scaffolding
├── multiRAT/ multiRIC/ # Upstream FlexRIC multi-RAT / multi-RIC notes
├── CMakeLists.txt # Builds src/ examples/ test/ only (does NOT build openair2/)
├── flexric.conf # Near-RT RIC / xApp DB configuration
├── requirements.txt # Python dependencies (D3QN training + xApp)
├── Ngn-project.md # Implementation-status + architecture reference (kept accurate)
├── LICENSE # CSSL v1.0 (inherited from OAI / FlexRIC)
└── README.md
| Parameter | Value | Description |
|---|---|---|
| gNB Topology | 3 Base Stations | Line layout spaced 500m apart |
| Antennas ( |
8 per gNB | Uniform Linear Array (ULA) |
| Carrier Frequency ( |
3.5 GHz | 3GPP NR Band n78 |
| Subcarrier Spacing ( |
30 kHz | Numerology |
| Total Subcarriers ( |
780 | Total bandwidth |
| URLLC Users | 5 UEs | Latency target: |
| eMBB Users | 5 UEs | High throughput demand |
The requirements.txt file includes all required libraries for running DJCSR (Train_Model) and the FlexRIC Python xApp (OAI_FlexRIC):
- Deep Reinforcement Learning & ML Frameworks:
torch>=2.0.0, torchvision, torchaudio, gymnasium>=0.28.1, gym>=0.26.0 - Numerical & Signal Processing:
numpy>=1.22.0,<2.0.0, scipy>=1.8.0 - Data Logging & Analysis:
pandas>=1.4.0, h5py>=3.6.0 - Visualization:
matplotlib>=3.5.0, seaborn>=0.11.2, tensorboard>=2.10.0 - FlexRIC SWIG/Python Bindings & Utilities:
cffi>=1.15.0, pyyaml>=6.0, pydantic>=1.10.0, requests>=2.28.0
pip install -r requirements.txt- Add Docker's official GNU Privacy Guard (GPG) key:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg- Set up the Docker stable repository:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null- Install Docker Engine, CLI, Containerd, and Docker Compose Plugin:
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin- Verify Docker installation:
docker --version
docker compose version- System Build Prerequisites (Ubuntu 22.04 LTS):
sudo apt update && sudo apt install -y \
build-essential cmake ninja-build gcc-12 g++-12 git bison flex swig \
python3-dev python3-pip python3-numpy libsctp-dev libpcre2-dev ccache- Clone & Build FlexRIC (v1.0, 2024.w12):
git clone https://gitlab.eurecom.fr/mosaic5g/flexric.git
cd flexric
git fetch --all --tags
mkdir -p build && cd build
cmake -DCMAKE_C_COMPILER=gcc-12 \
-DCMAKE_CXX_COMPILER=g++-12 \
-DXAPP_MULTICELL=ON \
-DXAPP_PYTHON3=ON ..
make -j$(nproc)
sudo make install
sudo ldconfig- Clone & Build OpenAirInterface 5G (v2024.w24):
cd ~
git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
cd openairinterface5g
git fetch --all --tags cd cmake_targets
# -I installs missing OAI packages, --build-e2 links against installed FlexRIC
./build_oai -I -w SIMU --gNB --nrUE --build-e2 --ninjaThe simulation pipeline uses environment.py (ISAC Environment) and agent.py (D3QN Architecture) to train the resource allocation policy.
cd “Train_Model"
python train.py
# Output: d3qn_isac_final.pthTo validate the trained d3qn_isac_final.pth model on a live OpenAirInterface (OAI) & FlexRIC Near-RT RIC testbed, execute the following steps in sequence:
cd ~/oai-workshops/cn
docker compose up -d
docker pssudo ~/openair2/E2AP/flexric/build/examples/ric/nearRT-RIC cd ~/openairinterface5g/cmake_targets/ran_build/build
sudo ./nr-softmodem -O ~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim -E --gNBs.[0].min_rxtxtime 6 sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim -O
~/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf -E --num-ues 10sudo python3 launch_topology.pysudo bash generate_traffic.shdocker logs oai-amf -f [2026-09-01 13:55:35.592] [amf_app] [info]
|------------------------------------------------------------------------------------------------------------------------------------------------------------|
|----------------------------------------------------------------------gNBs' Information---------------------------------------------------------------------|
| Index | Status | Global Id | gNB Name | PLMN |
| 1 | Connected | 0x0E00 | gNB-OAI-1 | 001,01 |
| 2 | Connected | 0x0E01 | gNB-OAI-2 | 001,01 |
| 3 | Connected | 0x0E02 | gNB-OAI-3 | 001,01 |
|------------------------------------------------------------------------------------------------------------------------------------------------------------|
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
|---------------------------------------------------------------------UEs' Information----------------------------------------------------------------------|
| Index | 5GMM State | IMSI | GUTI | RAN UE NGAP ID | AMF UE NGAP ID | PLMN | Cell Id |
| 1 | 5GMM-REGISTERED | 001010000000100 |00101010041259605347| 0x01 | 0x01 | 001,01 | 0000e014f |
| 2 | 5GMM-REGISTERED | 001010000000101 |00101010041026984396| 0x01 | 0x02 | 001,01 | 0000e0ec6 |
| 3 | 5GMM-REGISTERED | 001010000000102 |00101010041366923341| 0x02 | 0x03 | 001,01 | 0000e014f |
| 4 | 5GMM-REGISTERED | 001010000000103 |00101010041329122198| 0x03 | 0x04 | 001,01 | 0000e014f |
| 5 | 5GMM-REGISTERED | 001010000000104 |00101010041217329206| 0x04 | 0x05 | 001,01 | 0000e014f |
| 6 | 5GMM-REGISTERED | 001010000000105 |00101010041373143116| 0x02 | 0x06 | 001,01 | 0000e0ec6 |
| 7 | 5GMM-REGISTERED | 001010000000106 |00101010041302980548| 0x05 | 0x07 | 001,01 | 0000e014f |
| 8 | 5GMM-REGISTERED | 001010000000107 |00101010041553893943| 0x06 | 0x08 | 001,01 | 0000e014f |
| 9 | 5GMM-REGISTERED | 001010000000108 |00101010041148878210| 0x07 | 0x09 | 001,01 | 0000e014f |
| 10 | 5GMM-REGISTERED | 001010000000109 |00101010041379311732| 0x01 | 0x0A | 001,01 | 0000e014e |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
Run the xApp controller to perform real-time E2 control using the trained policy:
python3 ~/openair2/E2AP/flexric/examples/xApp/python3/xapp_isac.pyThe below demonstrates real-time E2 control exchange (E2SM-RC NVS capacity slice allocation) and the D3QN agent's score convergence from Episode 10 (score: 1613.3) to Episode 200 (score: 5513.5):
[xApp]: CONTROL-REQUEST tx
[xApp]: CONTROL ACK rx
[xApp]: Successfully received CONTROL response
# of episode :10, avg score : 1613.3, optimization step: 100
ADD NVS DL SLICE: id 1, label eMBB, conf 1(capacity), pct_reserved 0.596154
ADD NVS DL SLICE: id 2, label URLLC, conf 1(capacity), pct_reserved 0.4
# of episode :20, avg score : 1562.2, optimization step: 200
# of episode :30, avg score : 1920.9, optimization step: 300
# of episode :40, avg score : 2151.6, optimization step: 400
# of episode :50, avg score : 2228.6, optimization step: 500
# of episode :60, avg score : 2596.4, optimization step: 600
# of episode :70, avg score : 2673.2, optimization step: 700
# of episode :200, avg score : 5513.5, optimization step: 2000Generate throughput, latency, and sensing accuracy plots from metrics.csv:
python3 plot_metrics.py-
eMBB Throughput (+31.0% Gain):
- DJCSR dynamically adapts subcarrier allocation ratios (
$\rho$ ) and transmit power budgets ($p$ ), yielding a 31% throughput increase over conventional DQN while consistently exceeding the 60 Mbps QoS target.
- DJCSR dynamically adapts subcarrier allocation ratios (
-
URLLC Latency (-16.7% Reduction):
- Dynamic subcarrier allocation ratios (
$\rho$ ) and joint power splitting ($p$ ) optimize resource assignment to maintain median URLLC latency at 3.93 ms (a 16.7% reduction over conventional DQN), strictly enforcing the < 5 ms ultra-low latency constraint under dynamic traffic bursts.
- Dynamic subcarrier allocation ratios (
-
Sensing Accuracy:
- By joint optimization of sensing subcarrier interleaved spacing (
$\Delta_s$ ), DJCSR achieves an average range estimation RMSE of 0.184 m.
- By joint optimization of sensing subcarrier interleaved spacing (
- Adaptive Joint Resource Allocation: DJCSR successfully resolves the fundamental trade-off between communication Quality-of-Service (QoS) and radar sensing precision in multi-cell 6G ISAC networks.
- Hardware Feasibility: Real-time E2 control loop validation on the FlexRIC Near-RT RIC and OpenAirInterface (OAI) gNB testbed confirms that D3QN-driven xApps operate seamlessly within sub-10ms Near-RT RIC decision epochs.
- Scalability for 6G O-RAN: The framework demonstrates that AI-native xApps can dynamically adjust subcarrier spacing, power splitting, and slice priorities in real time under dynamic fading and mobile traffic.