From 960f2e710122e92b2271645b48ec4f49843aff88 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 22 May 2025 09:59:57 +0000 Subject: [PATCH] NR UE: allow the epochTime-r17 in NTN-Config-r17 to be in the future The implementation is limited to epoch times that are not more than 5.12 seconds in the future (allowed are up to 10.24 seconds) and ntn-UlSyncValidityDuration < 5.12 seconds (allowed are up to 90 seconds). To fix this limitation, the hyper frame number HFN has to be introduced at the OAI UE! --- executables/nr-ue.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e7b305c7d2..1774000b8f 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -927,7 +927,15 @@ static inline void apply_ntn_config(PHY_VARS_NR_UE *UE, const int abs_subframe_tx = 10 * frame_rx + ((slot_rx + *duration_rx_to_tx) >> mu); const int abs_subframe_epoch = 10 * UE->ntn_config_message->ntn_config_params.epoch_sfn + UE->ntn_config_message->ntn_config_params.epoch_subframe; - const int ms_since_epoch = (abs_subframe_tx - abs_subframe_epoch + 10240) % 10240; + int ms_since_epoch = abs_subframe_tx - abs_subframe_epoch; + // cope with sfn wrap-around + // this currently limits us to epoch times that are not more than 5.12 seconds in the future (allowed are up to 10.24 seconds) + // and ntn-UlSyncValidityDuration < 5.12 seconds (allowed are up to 900 seconds) + // TODO: fix this limitation by introducing the hyper frame number HFN + if (ms_since_epoch < -5120) + ms_since_epoch += 10240; + else if (ms_since_epoch > 5120) + ms_since_epoch -= 10240; const double total_ta_ms = UE->ntn_config_message->ntn_config_params.ntn_total_time_advance_ms; const double total_ta_drift = UE->ntn_config_message->ntn_config_params.ntn_total_time_advance_drift; // µs/s