6G NTN
ns3-ntn-toolkit module

ntn-digital-twin

ntn-digital-twin: a constellation twin that hands handover predictions to ns-3

Python digital twin for ns-3 that propagates TLEs with SGP4, predicts A3 handovers and exports a schedule that a running ns-3 simulation actuates.

Where ntn-digital-twin 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 ntn-digital-twin 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 ntn-digital-twin does

ntn-digital-twin is a Python service for the ns-3 NTN toolkit that propagates satellite two-line elements with SGP4, applies an A3 handover guard, and serves the constellation state over REST, CZML and InfluxDB line protocol. It writes a handover schedule on a shared epoch that OranNtnTwinPredictionConsumer in the oran-ntn module loads and actuates inside a running ns-3 simulation.

What it models

The twin mirrors a satellite constellation and predicts handovers from ephemeris. Every loop interval it fetches TLEs from CelesTrak through a 6 h on-disk cache, or generates deterministic Walker elements on the same epoch the ns-3 scenario uses, then propagates them with SGP4 from the ntn-constellation package. It writes CZML for a Cesium viewer and ntn_sat_pos line protocol in the ntn-observability schema for InfluxDB and Grafana. A FastAPI server on port 8090 answers GET /health, GET /constellation/state and POST /predict/handover, computing elevation in closed form from ECEF to ENU on the hot path.

Handover prediction and actuation share one A3 guard, following the 3GPP TS 38.331 A3 event: a dB link-budget margin, hysteresis, time-to-trigger and a minimum service time. The guard ranks and compares on the same quantity, does not count initial acquisition as a handover, and restarts time-to-trigger when the best target changes. emit_predictions_file writes lines of t_s, ueId, recommendedGnbId and confidence, where t_s equals ns-3 simulation time. On the ns-3 side, OranNtnTwinPredictionConsumer fires a HANDOVER_TRIGGER into the E2 and CHO loop at each t_s whose confidence clears a floor. A C++ metric, CompareHandovers, replays the twin's TLEs in Sgp4MobilityModel and compares handover instants. The direction from simulator back to twin is not implemented: the twin does not ingest ns-3 state.

Measured numbers

5 handovers in 45 minutes

handovers the twin exported, at 280, 610, 1100, 1650 and 2180 s, each to a different satellite, with confidence 0.13 to 0.23

one deterministic run: Walker source, 66 satellites in 6 planes of 11 at 53 deg, observer at 33.68 N 73.05 E, 2700 s horizon, 10 s step; confidence is the elevation margin over the runner-up divided by 30 deg, clipped to [0, 1]

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

Standards it follows

3GPP TS 38.331A3 event and conditional reconfiguration behind the shared handover guard
3GPP TR 38.821NTN link budget and geometry
SGP4 / SDP4orbit propagation of two-line elements
CelesTrak two-line element formatlive constellation input
CZMLconstellation export for a Cesium viewer
InfluxDB line protocolsatellite position export for InfluxDB and Grafana

New on 6g-ntn.live

The toolkit now runs in the browser at 6g-ntn.live: pick an example of ntn-digital-twin 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 ntn-digital-twin-v4).

Cite

If you use ntn-digital-twin, 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