From c9587a88766ccf1e5837e27103378734d86a0670 Mon Sep 17 00:00:00 2001 From: Rakesh Mundlamuri Date: Sun, 3 May 2026 19:24:13 +0530 Subject: [PATCH] Modify nr-cu-nrppa-test simulator to use UE data from config file Signed-off-by: Rakesh Mundlamuri --- tests/nr-cu-nrppa/nr-cu-nrppa.c | 65 ++++++------------- tests/nr-cu-nrppa/nr-nrppa-test.conf | 7 ++ .../nr-ue-nas-simulator/nr-ue-nas-simulator.c | 2 +- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/tests/nr-cu-nrppa/nr-cu-nrppa.c b/tests/nr-cu-nrppa/nr-cu-nrppa.c index c45a313de4..a65fedbad0 100644 --- a/tests/nr-cu-nrppa/nr-cu-nrppa.c +++ b/tests/nr-cu-nrppa/nr-cu-nrppa.c @@ -23,6 +23,10 @@ uint64_t downlink_frequency[MAX_NUM_CCs][4]; int64_t uplink_frequency_offset[MAX_NUM_CCs][4]; int oai_exit = 0; int gnb_id; +uint32_t tac = 1; +uint16_t mcc = 1; +uint16_t mnc = 1; +uint8_t mnc_len = 2; int NB_UE_INST = 1; void exit_function(const char *file, const char *function, const int line, const char *s, const int assert) @@ -492,44 +496,6 @@ static nrppa_measurement_resp_t fill_measurement_response(uint16_t transaction_i return resp; } -// Initializing UE NAS Context with simulated SIM data -nr_ue_nas_t *simulated_ue_nas = NULL; -void init_ue_nas_context(void) -{ - simulated_ue_nas = calloc_or_fail(1, sizeof(nr_ue_nas_t)); - simulated_ue_nas->UE_id = 1; - simulated_ue_nas->security_container = calloc_or_fail(1, sizeof(stream_security_container_t)); - // Allocation and simulation of UICC data - simulated_ue_nas->uicc = calloc_or_fail(1, sizeof(uicc_t)); - // IMSI : 001010000000001 - simulated_ue_nas->uicc->imsiStr = calloc_or_fail(1, 16 * sizeof(char)); - strcpy(simulated_ue_nas->uicc->imsiStr, "001010000000001"); - simulated_ue_nas->uicc->nmc_size = 2; - // DNN : oai - simulated_ue_nas->uicc->dnnStr = calloc_or_fail(1, 32 * sizeof(char)); - strcpy(simulated_ue_nas->uicc->dnnStr, "oai"); - // IMEISV : 6754567890123413 - simulated_ue_nas->uicc->imeisvStr = calloc_or_fail(1, 17 * sizeof(char)); - strcpy(simulated_ue_nas->uicc->imeisvStr, "6754567890123413"); - // NSSAI: sst = 1, sd = 0xffffff - simulated_ue_nas->uicc->nssai_sst = 1; - simulated_ue_nas->uicc->nssai_sd = 0xffffff; - // Ki: fec86ba6eb707ed08905757b1bb44b8f - static const uint8_t TEST_K[16] = - {0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0, 0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f}; - memcpy(simulated_ue_nas->uicc->key, TEST_K, 16); - // OPc: c42449363bbad02b66d16bc975d77cc1 - static const uint8_t TEST_OPC[16] = - {0xc4, 0x24, 0x49, 0x36, 0x3b, 0xba, 0xd0, 0x2b, 0x66, 0xd1, 0x6b, 0xc9, 0x75, 0xd7, 0x7c, 0xc1}; - memcpy(simulated_ue_nas->uicc->opc, TEST_OPC, 16); - // routing indicator - simulated_ue_nas->uicc->routing_indicatorStr = calloc_or_fail(1, 5 * sizeof(char)); - strcpy(simulated_ue_nas->uicc->routing_indicatorStr, "0000"); - simulated_ue_nas->security.nas_count_ul = 0; - simulated_ue_nas->security.nas_count_dl = 0; - simulated_ue_nas->fiveGMM_state = FGS_DEREGISTERED; -} - // Emulate registration request to register UE in the AMF (required for positioning) void send_initial_ue_message(instance_t instance) { @@ -537,16 +503,23 @@ void send_initial_ue_message(instance_t instance) NGAP_NAS_FIRST_REQ(msg_p).gNB_ue_ngap_id = 1; // Simulated UE ID - NGAP_NAS_FIRST_REQ(msg_p).plmn.mcc = 1; - NGAP_NAS_FIRST_REQ(msg_p).plmn.mnc = 1; - NGAP_NAS_FIRST_REQ(msg_p).plmn.mnc_digit_length = 2; + NGAP_NAS_FIRST_REQ(msg_p).plmn.mcc = mcc; + NGAP_NAS_FIRST_REQ(msg_p).plmn.mnc = mnc; + NGAP_NAS_FIRST_REQ(msg_p).plmn.mnc_digit_length = mnc_len; NGAP_NAS_FIRST_REQ(msg_p).nr_cell_id = gnb_id; NGAP_NAS_FIRST_REQ(msg_p).establishment_cause = NGAP_RRC_CAUSE_MO_SIGNALLING; as_nas_info_t initialNasMsg = {0}; - generateRegistrationRequest(&initialNasMsg, simulated_ue_nas, false); + nr_ue_nas_t *nr_ue_nas = get_ue_nas_info(0); + // serving network name (snn) + // Ideally snn should be filled from SIB1, but we operate at NAS/RRC level and we dont decode SIB1 + nr_ue_nas->sn_id = calloc(1, sizeof(plmn_id_t)); + nr_ue_nas->sn_id->mcc = mcc; + nr_ue_nas->sn_id->mnc = mnc; + nr_ue_nas->sn_id->mnc_digit_length = mnc_len; + generateRegistrationRequest(&initialNasMsg, nr_ue_nas, false); NGAP_NAS_FIRST_REQ(msg_p).nas_pdu.buf = initialNasMsg.nas_data; NGAP_NAS_FIRST_REQ(msg_p).nas_pdu.len = initialNasMsg.length; @@ -621,7 +594,7 @@ void *rrc_gnb_task(void *args_p) itti_exit_task(); break; case NGAP_DOWNLINK_NAS: - LOG_I(NR_RRC, "Ignore NGAP_DOWNLINK_NAS: dont have to handle"); + LOG_I(NR_RRC, "Ignore NGAP_DOWNLINK_NAS: dont have to handle\n"); ngap_downlink_nas_t *nas = &NGAP_DOWNLINK_NAS(msg_p); if (nas->nas_pdu.buf) { free(nas->nas_pdu.buf); @@ -679,7 +652,7 @@ int main(int argc, char **argv) } logInit(); - init_ue_nas_context(); + nas_init_nrue(NB_UE_INST); set_softmodem_sighandler(); @@ -706,6 +679,10 @@ int main(int argc, char **argv) msg_p = itti_alloc_new_message(TASK_GNB_APP, 0, NGAP_REGISTER_GNB_REQ); RCconfig_NR_NG(msg_p, 0); gnb_id = NGAP_REGISTER_GNB_REQ(msg_p).gNB_id; + tac = NGAP_REGISTER_GNB_REQ(msg_p).tac; + mcc = NGAP_REGISTER_GNB_REQ(msg_p).plmn[0].plmn.mcc; + mnc = NGAP_REGISTER_GNB_REQ(msg_p).plmn[0].plmn.mnc; + mnc_len = NGAP_REGISTER_GNB_REQ(msg_p).plmn[0].plmn.mnc_digit_length; LOG_I(GNB_APP, "Sending NGAP_REGISTER_GNB_REQ to TASK_NGAP\n"); itti_send_msg_to_task(TASK_NGAP, 0, msg_p); diff --git a/tests/nr-cu-nrppa/nr-nrppa-test.conf b/tests/nr-cu-nrppa/nr-nrppa-test.conf index 1bbda67679..5dc87cb279 100644 --- a/tests/nr-cu-nrppa/nr-nrppa-test.conf +++ b/tests/nr-cu-nrppa/nr-nrppa-test.conf @@ -51,6 +51,13 @@ positioning_config = ( } ); +uicc0 = { + imsi = "001010000000001"; + key = "fec86ba6eb707ed08905757b1bb44b8f"; + opc = "C42449363BBAD02B66D16BC975D77CC1"; + pdu_sessions = ({ dnn = "oai"; nssai_sst = 1; }); +} + L1s = ( { tr_n_preference = "local_mac"; diff --git a/tests/nr-ue-nas-simulator/nr-ue-nas-simulator.c b/tests/nr-ue-nas-simulator/nr-ue-nas-simulator.c index b216ecd567..b5ee18e301 100644 --- a/tests/nr-ue-nas-simulator/nr-ue-nas-simulator.c +++ b/tests/nr-ue-nas-simulator/nr-ue-nas-simulator.c @@ -75,7 +75,7 @@ int nr_rlc_get_available_tx_space(const rnti_t rntiP, const logical_chan_id_t ch configmodule_interface_t *uniqCfg = NULL; -// Emulate registration request to register UE in the AMF (required for positioning) +// Emulate registration request to register UE in the AMF void send_initial_ue_message(instance_t instance) { MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_GNB, 0, NGAP_NAS_FIRST_REQ);