From ad04800b20b76b441d3a1bf5839fee231b204e6b Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Wed, 15 Jan 2025 18:38:26 +0100 Subject: [PATCH 1/2] Add preamble_index to gNB and UE logs --- openair1/PHY/NR_UE_TRANSPORT/nr_prach.c | 5 +++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index e2928b2df4..91f8f81f3c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -227,7 +227,7 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t LOG_I(PHY, "PRACH [UE %d] in frame.slot %d.%d, placing PRACH in position %d, Msg1/MsgA-Preamble frequency start %d (k1 %d), " - "preamble_offset %d, first_nonzero_root_idx %d\n", + "preamble_offset %d, first_nonzero_root_idx %d, preambleIndex = %d\n", Mod_id, frame, slot, @@ -235,7 +235,8 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t n_ra_prb, nrUE_config->prach_config.num_prach_fd_occasions_list[fd_occasion].k1, preamble_offset, - first_nonzero_root_idx); + first_nonzero_root_idx, + prach_pdu->ra_PreambleIndex); // Ncp and dftlen here is given in terms of T_s wich is 30.72MHz sampling if (prach_sequence_length == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 7b010ad5bc..a69e9bbc96 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1539,7 +1539,7 @@ static void nr_generate_Msg2(module_id_t module_idP, pdsch_pdu_rel15->precodingAndBeamforming.prgs_list[0].dig_bf_interface_list[0].beam_idx = ra->beam_id; LOG_A(NR_MAC, - "UE %04x: %d.%d Generating RA-Msg2 DCI, RA RNTI 0x%x, state %d, CoreSetType %d, RAPID %d\n", + "UE %04x: %d.%d Generating RA-Msg2 DCI, RA RNTI 0x%x, state %d, CoreSetType %d, preamble_index(RAPID) %d\n", ra->rnti, frameP, slotP, From 803c9c349a5ed2164f5a34c4eb3daecba2cd7893 Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Thu, 16 Jan 2025 06:50:05 +0100 Subject: [PATCH 2/2] Add distance in meters to RA print in gNB --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index a69e9bbc96..68301edd7a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1538,15 +1538,25 @@ static void nr_generate_Msg2(module_id_t module_idP, pdsch_pdu_rel15->precodingAndBeamforming.prgs_list[0].pm_idx = 0; pdsch_pdu_rel15->precodingAndBeamforming.prgs_list[0].dig_bf_interface_list[0].beam_idx = ra->beam_id; + // Distance calculation according to SCF222.10.02 RACH.indication (table 3-74) and 38.213 4.2/38.211 4.3.1 + // T_c according to 38.211 4.1 + float T_c_ns = 0.509; + int numerology = ra->UL_BWP.scs; + float rtt_ns = T_c_ns * 16 * 64 / (1 << numerology) * ra->timing_offset; + float speed_of_light_in_meters_per_second = 299792458.0f; + float distance_in_meters = speed_of_light_in_meters_per_second * rtt_ns / 1000 / 1000 / 1000 / 2; LOG_A(NR_MAC, - "UE %04x: %d.%d Generating RA-Msg2 DCI, RA RNTI 0x%x, state %d, CoreSetType %d, preamble_index(RAPID) %d\n", + "UE %04x: %d.%d Generating RA-Msg2 DCI, RA RNTI 0x%x, state %d, CoreSetType %d, preamble_index(RAPID) %d, " + "timing_offset = %d (estimated distance %.1f [m])\n", ra->rnti, frameP, slotP, ra->RA_rnti, ra->ra_state, pdcch_pdu_rel15->CoreSetType, - ra->preamble_index); + ra->preamble_index, + ra->timing_offset, + distance_in_meters); // SCF222: PDU index incremented for each PDSCH PDU sent in TX control message. This is used to associate control // information to data and is reset every slot.