6G NTN
ns3-ntn-toolkit module

ns3-ai

ns3-ai-ntn: a Gymnasium 1.0 reinforcement-learning bridge for ns-3

Fork of ns3-ai for ns-3.49: Gymnasium 1.0 over versioned shared memory, an AI-RAN inference contract, and NTN reinforcement-learning tooling.

Where ns3-ai sits in the toolkit: the software view of ns3-ntn-toolkit (IEEE Open Journal of the Communications Society, 2026, Fig. 2). Click to zoom.
Where ns3-ai sits in the toolkit: the software view of ns3-ntn-toolkit (IEEE Open Journal of the Communications Society, 2026, Fig. 2). Click to zoom.

What ns3-ai does

ns3-ai-ntn is a fork of the ns3-ai module that connects ns-3.49 simulations to Python agents through Gymnasium 1.0 over shared memory, with a versioned handshake that rejects schema mismatches. It adds an AI-RAN inference contract over in-process or TCP channels and a Python package of NTN reinforcement-learning environments and trainers.

What it models

The module is the interface between an ns-3 process and a learning agent rather than a network model. OpenGymInterface on the C++ side is stepped through Notify() each step, and the transition is latched inside GetObservation so the reward is computed from state the action has actually reached. The C++ and Python sides share a protobuf schema over a Boost.Interprocess shared-memory segment; the handshake carries a protocol version, a module version and an FNV-1a schema digest, so a mismatch is reported as an error. Ns3AiMsgInterface exchanges fixed-layout structs and vectors through a pybind11 module. The fork targets Python 3.10 to 3.13, NumPy 2 and Gymnasium 1.0, and a CMake helper disables link-time optimization per pybind11 target to fix the ns-3.43 import failure.

An AI-RAN inference contract (AiranInferenceClient and AiranInferenceServer) exchanges length-prefixed protobuf over in-process FIFO or TCP channels, parses Triton config.pbtxt files, and ships deterministic mock runtimes for a beam index classifier and a CSI-to-precoder model; a native grpc++ transport is not implemented yet. The ns3_ai_ntn Python package provides four NTN environments (HandoverEnv, BeamMgmtEnv, SliceEnv, PowerCtrlEnv), which are synthetic and do not boot ns-3, plus a Stable-Baselines3 PPO trainer, a PyTorch Geometric GAT model and parameter-shared multi-agent wrappers. The environment that runs on a measured radio is OranNtnGymHandover in oran-ntn. Bundled upstream examples cover RL-TCP congestion control, Wi-Fi rate control, LTE CQI prediction and multi-BSS channel access.

Measured numbers

117,017 vs 6,518 cycles

CPU cycles per C++ to Python transfer, ns3-gym versus the ns3-ai Gym interface (18x fewer)

upstream ns3-ai benchmark on the RL-TCP example, 6 seeds, mean over seeds; measured by the upstream authors, not re-measured on this fork
127,148 vs 7,584 cycles

CPU cycles per Python to C++ transfer, ns3-gym versus the ns3-ai Gym interface (17x fewer)

upstream ns3-ai benchmark on the RL-TCP example, 6 seeds; not re-measured on this fork
733,702 vs 279,648 cycles

CPU cycles per RL decision, message interface versus pure C++ (libtorch)

upstream ns3-ai benchmark on the RL-TCP example, 6 seeds; not re-measured on this fork
15.71 dB

mean serving SINR over 10 Gym steps of OranNtnGymHandover on the measured radio

one 12 s run of oran-ntn-gym-handover-example in in-process mode, 3 satellites, 2 UEs

Each number states the run it comes from; the README of the module lists the command that reproduces it.

Standards it follows

New on 6g-ntn.live

The toolkit now runs in the browser at 6g-ntn.live: pick an example of ns3-ai or any other module, change its parameters, and the real ns-3 binary runs on the server.

Watch

Watch on YouTube: the NTN Control Center running and visualizing the toolkit examples, in five minutes.

Install

Every module ships in the ready-built container image of the toolkit (version 3.0.1):

docker pull uzairdocker69/ns3-ntn-toolkit:latest
docker run --rm -it uzairdocker69/ns3-ntn-toolkit:latest bash

To build from source, clone ns3-ntn-toolkit, which vendors this module under contrib/, or follow the README of this repository (branch ns3-ai-ntn-v4).

Cite

If you use ns3-ai, please cite the toolkit article (doi:10.1109/OJCOMS.2026.3745010):

@article{uzair2026ns3ntntoolkit,
  author  = {Uzair, Muhammad and Aldahlan, Bassma G. and Albar, Ali A. and
             Althumali, Huda and Alghammas, Adnan},
  title   = {ns3-ntn-toolkit: An Integrated ns-3 Platform for 6G
             Non-Terrestrial Networks},
  journal = {IEEE Open Journal of the Communications Society},
  volume  = {7},
  pages   = {13440--13467},
  year    = {2026},
  doi     = {10.1109/OJCOMS.2026.3745010}
}

Links