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
| Specification | What the module takes from it |
|---|---|
| 3GPP TS 38.331 | A3 event and conditional reconfiguration behind the shared handover guard |
| 3GPP TR 38.821 | NTN link budget and geometry |
| SGP4 / SDP4 | orbit propagation of two-line elements |
| CelesTrak two-line element format | live constellation input |
| CZML | constellation export for a Cesium viewer |
| InfluxDB line protocol | satellite 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 minutes
Examples (2)
- Live constellation snapshotLive CelesTrak constellation propagated with SGP4, with line-of-sight-checked ISLs and gateway feeder links; writes a CZML scene and a satellite state table.
- Serving-satellite predictionPredicts which satellite serves a ground terminal (highest elevation above a mask) over the next minutes, from the live TLE twin.
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-constellationwith its built-in defaults.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.
@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}
}