Skip to content
Module · ntn-digital-twin

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

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.

Run it in the browser

Choose an example, set its parameters and run the real ns-3 binary on this server. The scene shows the configured geometry before the run and the results after it.

Service module

The twin propagates live CelesTrak element sets with SGP4, builds the ISL graph with an Earth line-of-sight check and hands gateway feeder links between satellites above a 25 degree mask.

AI / MARL
ns3-ai shared-memory and Gym bridge between ns-3 and Python learning agents.
Gym UE, RL handover policy
2 examples registered for this module. The live twin shown here runs continuously on the server.
Scene: Digital twin
The interactive 3D globe loads here.

What this module 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.

Outputs

  • CZML of the constellation for a Cesium viewer (one record per satellite)
  • ntn_sat_pos InfluxDB line protocol in the ntn-observability schema
  • Handover prediction file: epoch_unix header, then t_s,ueId,recommendedGnbId,confidence lines
  • REST responses from /health, /constellation/state and /predict/handover
  • Twin-versus-ns-3 handover agreement from the C++ TwinAgreement metric

Standards

SpecificationWhat the module takes from it
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

Key numbers

Stated in the module documentation, each with the conditions it was measured under.

handovers the twin exported, at 280, 610, 1100, 1650 and 2180 s, each to a different satellite, with confidence 0.13 to 0.23
5 handovers in 45 minutesone 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]

Examples (2)

Run it

  • In the browser

    Pick an example in the run panel above, set its parameters and press Run. The console streams live and the result opens with KPI charts.

  • In the ns-3 console

    The browser console accepts ns-3 style commands, for example ns3 run "twin-live-constellation --PrintHelp".

  • Locally with Docker

    The public image has the whole toolkit prebuilt. This runs twin-live-constellation with its built-in defaults.

    shell
    docker run --rm -it uzairdocker69/ns3-ntn-toolkit:latest ./ns3 run "twin-live-constellation"

Cite this

If you use this module, please cite the article that describes the toolkit: doi:10.1109/OJCOMS.2026.3745010.

M. Uzair, B. G. Aldahlan, A. A. Albar, H. Althumali and A. Alghammas, "ns3-ntn-toolkit: An integrated ns-3 platform for 6G non-terrestrial networks," IEEE Open Journal of the Communications Society, vol. 7, pp. 13440-13467, 2026, doi: 10.1109/OJCOMS.2026.3745010.

BibTeX
@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}
}