Compare commits

..

7 Commits

Author SHA1 Message Date
rakesh mundlamuri
5c1838f7e5 Update T traces to record toa in ns and SRS time/frequency channel over multiple rx antennas and ports 2025-09-08 20:44:56 +05:30
rakesh mundlamuri
1a37ea1ad2 Introduce nr_est_toa_ns_srs() to compute SRS ToA in nanoseconds 2025-09-08 20:44:51 +05:30
rakesh mundlamuri
5e763c900f use intermediate variable to avoid unnecessary computations and improve readability 2025-09-08 20:38:44 +05:30
rakesh mundlamuri
99abfd777c refactor nr_est_timing_advance_srs to avoid overflow and remove frame_parms 2025-09-08 20:38:34 +05:30
Robert Schmidt
f155ad7202 Merge branch 'fix-oaiue-ota' into 'develop'
Fix OAIUE-OTA pipeline and increase tested traffic

I tried to "fix" the OAIUE pipeline in !3610 (merged) for making it more reliable, but inadvertently introduced many ULSCH DTX for UL traffic. Fix this, and increase DL traffic.

See merge request oai/openairinterface5g!3621
2025-08-29 16:22:17 +00:00
Robert Schmidt
2b75e09151 Increase DL UDP traffic for OAIUE OTA pipeline 2025-08-29 14:53:36 +02:00
Robert Schmidt
47d2ba1793 Fix RX gain for OAIUE-OTA pipeline
Adjust to avoid increased ULSCH DTX, probably because of saturation.

Fixes: 69cb71eddc ("Adjust configuration for OAI OTA test")
2025-08-29 14:53:31 +02:00
29 changed files with 152 additions and 785 deletions

View File

@@ -1747,7 +1747,6 @@ add_executable(lte-softmodem
${OPENAIR_DIR}/executables/create_tasks_mbms.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR_DIR}/radio/COMMON/sniffer_config.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${PHY_INTERFACE_DIR}/queue_t.c
${OPENAIR_DIR}/common/utils/lte/ue_power.c
@@ -1777,7 +1776,6 @@ add_executable(oairu
${OPENAIR_DIR}/executables/ru_control.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR_DIR}/radio/COMMON/sniffer_config.c
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR_DIR}/openair1/SCHED/phy_procedures_lte_common.c
${OPENAIR_DIR}/executables/main_ru.c
@@ -1806,7 +1804,6 @@ add_executable(lte-uesoftmodem
${OPENAIR_DIR}/executables/create_tasks_ue.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR_DIR}/radio/COMMON/sniffer_config.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/lte/ue_power.c
${OPENAIR_DIR}/common/utils/lte/prach_utils.c
@@ -1843,7 +1840,6 @@ add_executable(nr-softmodem
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR_DIR}/radio/COMMON/sniffer_config.c
${OPENAIR_DIR}/common/utils/lte/ue_power.c
${OPENAIR_DIR}/common/utils/lte/prach_utils.c
${PHY_INTERFACE_DIR}/queue_t.c
@@ -1915,7 +1911,6 @@ add_executable(nr-uesoftmodem
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR_DIR}/radio/COMMON/sniffer_config.c
${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c
${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c
${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c

View File

@@ -198,7 +198,7 @@ RUs = (
att_rx = 0;
bands = [78];
max_pdschReferenceSignalPower = -27;
max_rxgain = 75;
max_rxgain = 70;
eNB_instances = [0];
sf_extension = 0
sdr_addrs = "addr=192.168.80.52,clock_source=internal,time_source=internal"

View File

@@ -109,8 +109,8 @@
<testCase id="000100">
<class>Iperf</class>
<desc>iperf (DL/30Mbps/UDP)(30 sec)</desc>
<iperf_args>-u -b 30M -t 30 -i 1 -R</iperf_args>
<desc>iperf (DL/60Mbps/UDP)(30 sec)</desc>
<iperf_args>-u -b 60M -t 30 -i 1 -R</iperf_args>
<id>oai_ue_caracal</id>
<svr_id>oc-cn5g</svr_id>
<iperf_packetloss_threshold>25</iperf_packetloss_threshold>

View File

@@ -138,11 +138,11 @@ ID = GNB_PHY_UL_PAYLOAD_RX_BITS
ID = GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE
DESC = gNodeB channel estimation in the frequency domain
GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB
FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,chest_t
FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : int,port : buffer,chest_f
ID = GNB_PHY_UL_TIME_CHANNEL_ESTIMATE
DESC = gNodeB channel estimation in the time domain
GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB
FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,chest_t
FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : int,port : buffer,chest_t
ID = GNB_PHY_PRACH_INPUT_SIGNAL
DESC = gNodeB input data in the time domain for slots with PRACH detection
GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB
@@ -151,6 +151,10 @@ ID = GNB_PHY_DL_OUTPUT_SIGNAL
DESC = gNodeB output data in the freq domain for slots
GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB
FORMAT = int,gNB_ID : int,frame : int,slot : int,antenna : buffer,txdata
ID = GNB_PHY_UL_SRS_TOA_NS
DESC = gNB ToA estimate from SRS (in ns)
GROUP = ALL:PHY:GNB
FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : buffer,toa_ns
#MAC logs
ID = ENB_MAC_UE_DL_SDU

View File

@@ -590,10 +590,6 @@ static void RU_write(nr_rxtx_thread_data_t *rxtxD, bool sl_tx_action, c16_t **tx
nr_fo_compensation(ul_freq_offset, fp->samples_per_subframe, writeTimestamp, txp[i], txp[i], writeBlockSize);
}
extern int sniffer;
if (sniffer) {
memset(txp[0], 0, 4 * writeBlockSize);
}
int tmp = openair0_write_reorder(&UE->rfdevice, writeTimestamp, (void **)txp, writeBlockSize, fp->nb_antennas_tx, flags);
AssertFatal(tmp == writeBlockSize, "");
}

View File

@@ -197,7 +197,6 @@ uint64_t set_nrUE_optmask(uint64_t bitmask) {
nrUE_params_t *get_nrUE_params(void) {
return &nrUE_params;
}
int sniffer;
static void get_options(configmodule_interface_t *cfg)
{
paramdef_t cmdline_params[] = CMDLINE_NRUEPARAMS_DESC;

View File

@@ -84,7 +84,6 @@ extern uint16_t ue_id_g;
{"num-ul-actors", CONFIG_HLP_NUM_UL_ACTORS, 0, .iptr=&nrUE_params.num_ul_actors, .defintval=2, TYPE_INT, 0}, \
{"num-dl-actors", CONFIG_HLP_NUM_DL_ACTORS, 0, .iptr=&nrUE_params.num_dl_actors, .defintval=4, TYPE_INT, 0}, \
{"extra-pdu-id", CONFIG_HLP_EXTRA_PDU_ID, 0, .iptr=&nrUE_params.extra_pdu_id, .defintval=-1, TYPE_INT, 0}, \
{"sniffer", "sniffer mode", 0, .iptr=&sniffer, .defintval=0, TYPE_INT, 0}, \
}
// clang-format on

View File

@@ -36,18 +36,17 @@
#define I0_SKIP_DC 1
int nr_est_timing_advance_srs(const NR_DL_FRAME_PARMS *frame_parms,
const c16_t srs_estimated_channel_time[][frame_parms->ofdm_symbol_size])
int nr_est_timing_advance_srs(uint16_t ofdm_symbol_size,
uint8_t N_ap_srs,
const c16_t srs_estimated_channel_time[][N_ap_srs][ofdm_symbol_size])
{
int timing_advance = 0;
int max_val = 0;
int64_t max_val = 0;
for (int i = 0; i < frame_parms->ofdm_symbol_size; i++) {
int temp = 0;
for (int aa = 0; aa < frame_parms->nb_antennas_rx; aa++) {
int Re = ((c16_t*)srs_estimated_channel_time[aa])[i].r;
int Im = ((c16_t*)srs_estimated_channel_time[aa])[i].i;
temp += (Re*Re/2) + (Im*Im/2);
for (int i = 0; i < ofdm_symbol_size; i++) {
int64_t temp = 0;
for (int aa = 0; aa < N_ap_srs; aa++) {
temp += squaredMod(srs_estimated_channel_time[0][aa][i]); // computing for the first receive antenna
}
if (temp > max_val) {
timing_advance = i;
@@ -55,12 +54,12 @@ int nr_est_timing_advance_srs(const NR_DL_FRAME_PARMS *frame_parms,
}
}
if (timing_advance > frame_parms->ofdm_symbol_size/2) {
timing_advance = timing_advance - frame_parms->ofdm_symbol_size;
if (timing_advance > ofdm_symbol_size / 2) {
timing_advance = timing_advance - ofdm_symbol_size;
}
// Scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size
const uint16_t bw_scaling = frame_parms->ofdm_symbol_size >> 7;
const uint16_t bw_scaling = ofdm_symbol_size >> 7;
// do some integer rounding to improve TA accuracy
int sync_pos_rounded;

View File

@@ -42,6 +42,75 @@
#define NO_INTERP 1
#define dBc(x, y) (dB_fixed(((int32_t)(x)) * (x) + ((int32_t)(y)) * (y)))
#define NR_SRS_IDFT_OVERSAMP_FACTOR 8
/* Generic function to find the peak of channel estimation buffer */
int16_t nr_est_toa_ns_srs(uint16_t ofdm_symbol_size,
uint8_t N_arx,
uint8_t N_ap,
uint32_t samples_per_frame,
c16_t srs_estimated_channel_freq[N_arx][N_ap][ofdm_symbol_size],
int16_t *srs_toa_ns)
{
c16_t chT_interpol[N_ap][NR_SRS_IDFT_OVERSAMP_FACTOR * ofdm_symbol_size] __attribute__((aligned(32)));
int ofdm_size_half = ofdm_symbol_size >> 1;
int16_t start_offset = (NR_SRS_IDFT_OVERSAMP_FACTOR * ofdm_symbol_size) - ofdm_size_half;
for (int arx_index = 0; arx_index < N_arx; arx_index++) {
for (int ap_index = 0; ap_index < N_ap; ap_index++) {
c16_t chF_interpol[NR_SRS_IDFT_OVERSAMP_FACTOR * ofdm_symbol_size] __attribute__((aligned(32)));
memset(chF_interpol, 0, sizeof(chF_interpol));
// Place SRS channel estimates in FFT shifted format for oversampling
memcpy(&chF_interpol[0], &srs_estimated_channel_freq[arx_index][ap_index][0], ofdm_size_half * sizeof(c16_t));
memcpy(&chF_interpol[start_offset],
&srs_estimated_channel_freq[arx_index][ap_index][ofdm_size_half],
ofdm_size_half * sizeof(c16_t));
// Convert to time domain oversampled
freq2time(ofdm_symbol_size * NR_SRS_IDFT_OVERSAMP_FACTOR, (int16_t *)chF_interpol, (int16_t *)chT_interpol[ap_index]);
}
int64_t mean_val = 0;
int64_t max_val = 0;
int32_t max_idx = 0;
for (int k = 0; k < NR_SRS_IDFT_OVERSAMP_FACTOR * ofdm_symbol_size; k++) {
int64_t abs_val = 0;
for (int p_index = 0; p_index < N_ap; p_index++) {
abs_val += squaredMod(chT_interpol[p_index][k]);
}
mean_val += abs_val;
if (abs_val > max_val) {
max_val = abs_val;
max_idx = k;
}
}
max_val = max_val / N_ap;
mean_val = mean_val / (N_ap * NR_SRS_IDFT_OVERSAMP_FACTOR * ofdm_symbol_size);
if (max_idx > NR_SRS_IDFT_OVERSAMP_FACTOR * ofdm_size_half)
max_idx = max_idx - NR_SRS_IDFT_OVERSAMP_FACTOR * ofdm_symbol_size;
// Check for detection threshold
if ((mean_val != 0) && (max_val / mean_val > 100)) {
srs_toa_ns[arx_index] = (max_idx * 1e9) / (NR_SRS_IDFT_OVERSAMP_FACTOR * samples_per_frame * 100);
} else {
srs_toa_ns[arx_index] = 0x8000;
}
LOG_D(PHY,
"SRS estimatd ToA [RX ant %d]: %d ns (max_val %ld, mean_val %ld, max_idx %d)\n",
arx_index,
srs_toa_ns[arx_index],
max_val,
mean_val,
max_idx);
} // Antenna loop
// TODO currently we are reporting ns for single antenna
return srs_toa_ns[0];
}
typedef struct puschAntennaProc_s {
unsigned char Ns;
@@ -1015,7 +1084,7 @@ int nr_srs_channel_estimation(
uint32_t signal_power = max(signal_energy_nodc(ch, arr_len), 1);
#ifdef SRS_DEBUG
LOG_I(NR_PHY, "signal_power = %u\n", signal_power);
LOG_I(NR_PHY, "signal_power = %d dB\n", dB_fixed(signal_power));
#endif
if (signal_power == 0) {

View File

@@ -65,8 +65,16 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB,
unsigned char symbol,
uint8_t nrOfLayers);
int nr_est_timing_advance_srs(const NR_DL_FRAME_PARMS *frame_parms,
const c16_t srs_estimated_channel_time[][frame_parms->ofdm_symbol_size]);
int nr_est_timing_advance_srs(uint16_t ofdm_symbol_size,
uint8_t N_ap,
const c16_t srs_estimated_channel_time[][N_ap][ofdm_symbol_size]);
int16_t nr_est_toa_ns_srs(uint16_t ofdm_symbol_size,
uint8_t N_arx,
uint8_t N_ap,
uint32_t samples_per_frame,
c16_t srs_estimated_channel_freq[N_arx][N_ap][ofdm_symbol_size],
int16_t *srs_toa_ns);
void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB,
NR_DL_FRAME_PARMS *frame_parms,

View File

@@ -26,7 +26,6 @@ char *uecap_file;
#include <executables/nr-softmodem.h>
int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_state) {return 0;}
sniffer_configuration_t *read_sniffer_configuration(void) { return 0; }
void nfapi_setmode(nfapi_mode_t nfapi_mode) {}
void set_taus_seed(unsigned int seed_init){};
configmodule_interface_t *uniqCfg = NULL;

View File

@@ -1007,13 +1007,13 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N
NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
nfapi_nr_srs_pdu_t *srs_pdu = &srs->srs_pdu;
uint8_t N_symb_SRS = 1 << srs_pdu->num_symbols;
c16_t srs_received_signal[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size * N_symb_SRS];
c16_t srs_estimated_channel_freq[frame_parms->nb_antennas_rx][1 << srs_pdu->num_ant_ports]
[frame_parms->ofdm_symbol_size * N_symb_SRS] __attribute__((aligned(32)));
c16_t srs_estimated_channel_time[frame_parms->nb_antennas_rx][1 << srs_pdu->num_ant_ports][frame_parms->ofdm_symbol_size]
__attribute__((aligned(32)));
c16_t srs_estimated_channel_time_shifted[frame_parms->nb_antennas_rx][1 << srs_pdu->num_ant_ports]
[frame_parms->ofdm_symbol_size];
uint8_t N_ap = 1 << srs_pdu->num_ant_ports;
uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
uint16_t ofdm_symbol_size = frame_parms->ofdm_symbol_size;
c16_t srs_received_signal[nb_antennas_rx][ofdm_symbol_size * N_symb_SRS];
c16_t srs_estimated_channel_freq[nb_antennas_rx][N_ap][ofdm_symbol_size * N_symb_SRS] __attribute__((aligned(32)));
c16_t srs_estimated_channel_time[nb_antennas_rx][N_ap][ofdm_symbol_size] __attribute__((aligned(32)));
c16_t srs_estimated_channel_time_shifted[nb_antennas_rx][N_ap][ofdm_symbol_size];
int8_t snr_per_rb[srs_pdu->bwp_size];
start_meas(&gNB->generate_srs_stats);
@@ -1047,21 +1047,27 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N
srs_est = -1;
}
T(T_GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE,
T_INT(0),
T_INT(srs_pdu->rnti),
T_INT(frame_rx),
T_INT(0),
T_INT(0),
T_BUFFER(srs_estimated_channel_freq[0][0], frame_parms->ofdm_symbol_size * sizeof(int32_t)));
for (int ant_rx = 0; ant_rx < nb_antennas_rx; ant_rx++) {
for (int p_index = 0; p_index < N_ap; p_index++) {
T(T_GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE,
T_INT(gNB->Mod_id),
T_INT(srs_pdu->rnti),
T_INT(frame_rx),
T_INT(slot_rx),
T_INT(ant_rx),
T_INT(p_index),
T_BUFFER(srs_estimated_channel_freq[ant_rx][p_index], ofdm_symbol_size * sizeof(c16_t)));
T(T_GNB_PHY_UL_TIME_CHANNEL_ESTIMATE,
T_INT(0),
T_INT(srs_pdu->rnti),
T_INT(frame_rx),
T_INT(0),
T_INT(0),
T_BUFFER(srs_estimated_channel_time_shifted[0][0], frame_parms->ofdm_symbol_size * sizeof(int32_t)));
T(T_GNB_PHY_UL_TIME_CHANNEL_ESTIMATE,
T_INT(gNB->Mod_id),
T_INT(srs_pdu->rnti),
T_INT(frame_rx),
T_INT(slot_rx),
T_INT(ant_rx),
T_INT(p_index),
T_BUFFER(srs_estimated_channel_time_shifted[ant_rx][p_index], ofdm_symbol_size * sizeof(c16_t)));
}
}
UL_INFO->srs_ind.sfn = frame_rx;
UL_INFO->srs_ind.slot = slot_rx;
@@ -1071,10 +1077,28 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N
nfapi_nr_srs_indication_pdu_t *srs_indication = UL_INFO->srs_pdu_list + UL_INFO->srs_ind.number_of_pdus++;
srs_indication->handle = srs_pdu->handle;
srs_indication->rnti = srs_pdu->rnti;
int16_t srs_toa_ns[nb_antennas_rx];
start_meas(&gNB->srs_timing_advance_stats);
srs_indication->timing_advance_offset = srs_est >= 0 ? nr_est_timing_advance_srs(frame_parms, srs_estimated_channel_time[0]) : 0xFFFF;
srs_indication->timing_advance_offset =
srs_est >= 0 ? nr_est_timing_advance_srs(ofdm_symbol_size, N_ap, srs_estimated_channel_time) : 0xFFFF;
stop_meas(&gNB->srs_timing_advance_stats);
srs_indication->timing_advance_offset_nsec = srs_est >= 0 ? (int16_t)((((int32_t)srs_indication->timing_advance_offset - 31) * ((int32_t)TC_NSEC_x32768)) >> 15) : 0xFFFF;
srs_indication->timing_advance_offset_nsec = srs_est >= 0 ? nr_est_toa_ns_srs(ofdm_symbol_size,
nb_antennas_rx,
N_ap,
frame_parms->samples_per_frame,
srs_estimated_channel_freq,
srs_toa_ns)
: 0x8000;
T(T_GNB_PHY_UL_SRS_TOA_NS,
T_INT(gNB->Mod_id),
T_INT(srs_pdu->rnti),
T_INT(frame_rx),
T_INT(slot_rx),
T_BUFFER(srs_toa_ns, nb_antennas_rx * sizeof(int16_t)));
switch (srs_pdu->srs_parameters_v4.usage) {
case 0:
LOG_W(NR_PHY, "SRS report was not requested by MAC\n");
@@ -1116,9 +1140,9 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N
start_meas(&gNB->srs_beam_report_stats);
nfapi_nr_srs_beamforming_report_t nr_srs_bf_report;
nr_srs_bf_report.prg_size = srs_pdu->beamforming.prg_size;
nr_srs_bf_report.num_symbols = 1 << srs_pdu->num_symbols;
nr_srs_bf_report.num_symbols = N_symb_SRS;
nr_srs_bf_report.wide_band_snr = srs_est >= 0 ? (gNB->srs->snr + 64) << 1 : 0xFF; // 0xFF will be set if this field is invalid
nr_srs_bf_report.num_reported_symbols = 1 << srs_pdu->num_symbols;
nr_srs_bf_report.num_reported_symbols = N_symb_SRS;
AssertFatal(nr_srs_bf_report.num_reported_symbols == 1,
"nr_srs_bf_report.num_reported_symbols %i not handled yet!\n",
nr_srs_bf_report.num_reported_symbols);
@@ -1148,7 +1172,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N
start_meas(&gNB->srs_iq_matrix_stats);
nfapi_nr_srs_normalized_channel_iq_matrix_t nr_srs_channel_iq_matrix;
nr_srs_channel_iq_matrix.normalized_iq_representation = srs_pdu->srs_parameters_v4.iq_representation;
nr_srs_channel_iq_matrix.num_gnb_antenna_elements = gNB->frame_parms.nb_antennas_rx;
nr_srs_channel_iq_matrix.num_gnb_antenna_elements = nb_antennas_rx;
nr_srs_channel_iq_matrix.num_ue_srs_ports = srs_pdu->srs_parameters_v4.num_total_ue_antennas;
nr_srs_channel_iq_matrix.prg_size = srs_pdu->srs_parameters_v4.prg_size;
nr_srs_channel_iq_matrix.num_prgs = srs_pdu->srs_parameters_v4.srs_bandwidth_size / srs_pdu->srs_parameters_v4.prg_size;

View File

@@ -746,8 +746,6 @@ static void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
return;
}
extern int sniffer;
if (sniffer) if (dlsch[0].rnti < 1000) dlsch[0].rnti_type = TYPE_RA_RNTI_;
int harq_pid = dlsch[0].dlsch_config.harq_process_nbr;
int frame_rx = proc->frame_rx;
int nr_slot_rx = proc->nr_slot_rx;
@@ -775,11 +773,6 @@ if (sniffer) if (dlsch[0].rnti < 1000) dlsch[0].rnti_type = TYPE_RA_RNTI_;
LOG_D(PHY, "AbsSubframe %d.%d Start LDPC Decoder for CW0 [harq_pid %d] ? %d \n", frame_rx % 1024, nr_slot_rx, harq_pid, is_cw0_active);
LOG_D(PHY, "AbsSubframe %d.%d Start LDPC Decoder for CW1 [harq_pid %d] ? %d \n", frame_rx % 1024, nr_slot_rx, harq_pid, is_cw1_active);
extern int sniffer;
if (sniffer) {
LOG_E(PHY, "AbsSubframe %d.%d Start LDPC Decoder for CW0 [harq_pid %d] ? %d \n", frame_rx % 1024, nr_slot_rx, harq_pid, is_cw0_active);
LOG_E(PHY, "AbsSubframe %d.%d Start LDPC Decoder for CW1 [harq_pid %d] ? %d \n", frame_rx % 1024, nr_slot_rx, harq_pid, is_cw1_active);
}
// exit dlsch procedures as there are no active dlsch
if (is_cw0_active != ACTIVE && is_cw1_active != ACTIVE) {
@@ -816,10 +809,6 @@ if (sniffer) {
G[DLSCH_id] = nr_get_G(dlsch_config->number_rbs, nb_symb_sch, nb_re_dmrs, dmrs_len, unav_res, dlsch_config->qamModOrder, dlsch[DLSCH_id].Nl);
start_meas_nr_ue_phy(ue, DLSCH_UNSCRAMBLING_STATS);
extern int sniffer;
if (sniffer) {
LOG_E(NR_MAC, "nr_dlsch_unscrambling scrambling ID %d rnti 0x%4.4x\n", dlsch[DLSCH_id].dlsch_config.dlDataScramblingId, dlsch[DLSCH_id].rnti);
}
nr_dlsch_unscrambling(llr[DLSCH_id], G[DLSCH_id], 0, dlsch[DLSCH_id].dlsch_config.dlDataScramblingId, dlsch[DLSCH_id].rnti);
stop_meas_nr_ue_phy(ue, DLSCH_UNSCRAMBLING_STATS);
@@ -830,24 +819,17 @@ LOG_E(NR_MAC, "nr_dlsch_unscrambling scrambling ID %d rnti 0x%4.4x\n", dlsch[DLS
nr_dlsch_decoding(ue, proc, dlsch, llr, p_b, G, nb_dlsch, DLSCH_ids);
stop_meas_nr_ue_phy(ue, DLSCH_DECODING_STATS);
extern int sniffer;
int ind_type = -1;
switch (dlsch[0].rnti_type) {
case TYPE_RA_RNTI_:
if (sniffer)
LOG_E(NR_MAC, "TYPE_RA_RNTI_\n");
ind_type = FAPI_NR_RX_PDU_TYPE_RAR;
break;
case TYPE_SI_RNTI_:
if (sniffer)
LOG_E(NR_MAC, "TYPE_SI_RNTI_\n");
ind_type = FAPI_NR_RX_PDU_TYPE_SIB;
break;
case TYPE_C_RNTI_:
if (sniffer)
LOG_E(NR_MAC, "TYPE_C_RNTI_\n");
ind_type = FAPI_NR_RX_PDU_TYPE_DLSCH;
break;
@@ -1086,21 +1068,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_
NR_UE_DLSCH_t *dlsch = &phy_data->dlsch[0];
// do procedures for C-RNTI
extern int sniffer;
if (sniffer)
if (dlsch->dlsch_config.BWPSize) {
LOG_E(NR_MAC, "pdsch_processing: bwpstart %d bwp size %d\n", dlsch->dlsch_config.BWPStart, dlsch->dlsch_config.BWPSize);
LOG_E(NR_MAC, "start_rb %d number_rbs %d start_symbol %d number_symbols %d rb_offset %d mcs %d rv %d TBS %d\n",
dlsch->dlsch_config.start_rb,
dlsch->dlsch_config.number_rbs,
dlsch->dlsch_config.start_symbol,
dlsch->dlsch_config.number_symbols,
dlsch->dlsch_config.rb_offset,
dlsch->dlsch_config.mcs,
dlsch->dlsch_config.rv,
dlsch->dlsch_config.TBS);
}
bool slot_fep_map[14] = {0};
const uint32_t rxdataF_sz = ue->frame_parms.samples_per_slot_wCP;
__attribute__ ((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz];

View File

@@ -1787,10 +1787,6 @@ static void configure_timeAlignmentTimer(NR_timer_t *time_alignment_timer, NR_Ti
void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t cause)
{
extern int sniffer;
if (sniffer) {
LOG_I(MAC, "nr_rrc_mac_config_req_reset cause %d\n", (int)cause); abort();
}
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
int ret = pthread_mutex_lock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);
@@ -1908,10 +1904,6 @@ static void configure_si_schedulingInfo(NR_UE_MAC_INST_t *mac,
void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *sib1, bool can_start_ra)
{
extern int sniffer;
if (sniffer)
LOG_I(MAC, "nr_rrc_mac_config_req_sib1\n");
if (sniffer) can_start_ra = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
int ret = pthread_mutex_lock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);

View File

@@ -104,9 +104,6 @@ NR_ControlResourceSet_t *ue_get_coreset(const NR_BWP_PDCCH_t *config, const int
return coreset;
}
static int rrra_rnti = 0;
int rnti_to_monitor;
static void config_dci_pdu(NR_UE_MAC_INST_t *mac,
fapi_nr_dl_config_request_t *dl_config,
const int rnti_type,
@@ -120,9 +117,7 @@ static void config_dci_pdu(NR_UE_MAC_INST_t *mac,
fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15;
int coreset_id = *ss->controlResourceSetId;
extern int sniffer;
if (sniffer) coreset_id = 0;
const int coreset_id = *ss->controlResourceSetId;
NR_ControlResourceSet_t *coreset;
if(coreset_id > 0) {
coreset = ue_get_coreset(pdcch_config, coreset_id);
@@ -266,10 +261,6 @@ if (sniffer) coreset_id = 0;
sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12;
monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
rel15->rnti = mac->ra.ra_rnti;
extern int sniffer;
if (sniffer) {
rel15->rnti = rrra_rnti; //mac->ra.ra_rnti;
}
rel15->SubcarrierSpacing = current_DL_BWP->scs;
break;
case TYPE_MSGB_RNTI_:
@@ -289,10 +280,6 @@ rel15->rnti = rrra_rnti; //mac->ra.ra_rnti;
sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12;
monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
rel15->rnti = mac->ra.t_crnti;
if (sniffer) {
if (rnti_to_monitor)
rel15->rnti = rnti_to_monitor;
}
rel15->SubcarrierSpacing = current_DL_BWP->scs;
break;
case TYPE_SP_CSI_RNTI_:
@@ -437,7 +424,6 @@ static bool monitor_dci_for_other_SI(NR_UE_MAC_INST_t *mac,
return false;
}
/* this is important function for hacking UE: ue_dci_configuration */
void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot)
{
const NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP;
@@ -490,17 +476,8 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
}
}
RA_config_t *ra = &mac->ra;
extern int sniffer;
if (sniffer || (mac->state == UE_PERFORMING_RA && ra->ra_state >= nrRA_WAIT_RAR)) {
if (mac->state == UE_PERFORMING_RA && ra->ra_state >= nrRA_WAIT_RAR) {
const NR_SearchSpace_t *ra_SS = get_common_search_space(mac, pdcch_config->ra_SS_id);
if (sniffer) {
rrra_rnti = 0x10b;
config_dci_pdu(mac, dl_config, TYPE_RA_RNTI_, slot, ra_SS);
rrra_rnti = 0x10f;
config_dci_pdu(mac, dl_config, TYPE_RA_RNTI_, slot, ra_SS);
if (rnti_to_monitor)
config_dci_pdu(mac, dl_config, TYPE_TC_RNTI_, slot, ra_SS);
}
// if RA is ongoing use RA search space
if (is_ss_monitor_occasion(frame, slot, slots_per_frame, ra_SS)) {
nr_rnti_type_t rnti_type = 0;
@@ -509,7 +486,6 @@ if (rnti_to_monitor)
} else {
rnti_type = TYPE_MSGB_RNTI_;
}
if (!sniffer)
config_dci_pdu(mac, dl_config, rnti_type, slot, ra_SS);
}
} else if (mac->state == UE_CONNECTED) {

View File

@@ -205,14 +205,6 @@ int get_rnti_type(const NR_UE_MAC_INST_t *mac, const uint16_t rnti)
const RA_config_t *ra = &mac->ra;
nr_rnti_type_t rnti_type;
extern int sniffer;
extern int rnti_to_monitor;
if (sniffer) {
if (rnti < 1000) return TYPE_RA_RNTI_;
if (rnti_to_monitor) {
return TYPE_TC_RNTI_;
}
}
if (rnti == ra->ra_rnti) {
rnti_type = TYPE_RA_RNTI_;
} else if (rnti == ra->MsgB_rnti && (ra->ra_state == nrRA_WAIT_MSGB || ra->ra_state == nrRA_WAIT_CONTENTION_RESOLUTION)) {
@@ -226,10 +218,7 @@ if (sniffer) {
} else if (rnti == 0xFFFF) {
rnti_type = TYPE_SI_RNTI_;
} else {
if (!sniffer)
AssertFatal(1 == 0, "Not identified/handled rnti %d \n", rnti);
else
rnti_type = TYPE_RA_RNTI_;
}
LOG_D(MAC, "Returning rnti_type %s \n", rnti_types(rnti_type));
return rnti_type;
@@ -353,11 +342,8 @@ void nr_ue_decode_BCCH_DL_SCH(NR_UE_MAC_INST_t *mac,
if(ack_nack) {
LOG_D(NR_MAC, "Decoding NR-BCCH-DL-SCH-Message (SIB1 or SI)\n");
nr_mac_rrc_data_ind_ue(mac->ue_id, cc_id, gNB_index, frame, slot, 0, mac->physCellId, 0, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len);
extern int sniffer;
if (!sniffer) {
if (mac->get_sib1)
mac->get_sib1 = false;
}
for (int i = 0; i < MAX_SI_GROUPS; i++) {
if (mac->get_otherSI[i])
mac->get_otherSI[i] = false;
@@ -773,13 +759,8 @@ static int nr_ue_process_dci_dl_10(NR_UE_MAC_INST_t *mac,
if (nr_timer_is_active(&mac->ra.response_window_timer)) {
dl_conf_req->pdu_type = FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH;
} else {
extern int sniffer;
if (sniffer) {
dl_conf_req->pdu_type = FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH;
} else {
// Discard the DCI
return -1;
}
}
} else {
dl_conf_req->pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
@@ -806,18 +787,9 @@ if (sniffer) {
}
dlsch_pdu->rb_offset = dlsch_pdu->start_rb + dlsch_pdu->BWPStart;
extern int sniffer;
if (sniffer)
LOG_E(NR_MAC, "%s: dlsch_pdu->rb_offset %d dlsch_pdu->start_rb %d dlsch_pdu->BWPStart %d\n", __FUNCTION__, dlsch_pdu->rb_offset, dlsch_pdu->start_rb, dlsch_pdu->BWPStart);
if (sniffer) {
if (rnti_type == TYPE_SI_RNTI_)
if (mac->get_sib1)
dlsch_pdu->rb_offset -= dlsch_pdu->BWPStart;
} else {
if (mac->get_sib1)
dlsch_pdu->rb_offset -= dlsch_pdu->BWPStart;
}
/* TIME_DOM_RESOURCE_ASSIGNMENT */
int dmrs_typeA_pos = mac->dmrs_TypeA_Position;
@@ -1152,9 +1124,6 @@ static int nr_ue_process_dci_dl_11(NR_UE_MAC_INST_t *mac,
return -1;
}
dlsch_pdu->rb_offset = dlsch_pdu->start_rb + dlsch_pdu->BWPStart;
extern int sniffer;
if (sniffer)
LOG_E(NR_MAC, "%s: dlsch_pdu->rb_offset %d dlsch_pdu->start_rb %d dlsch_pdu->BWPStart %d\n", __FUNCTION__, dlsch_pdu->rb_offset, dlsch_pdu->start_rb, dlsch_pdu->BWPStart);
/* TIME_DOM_RESOURCE_ASSIGNMENT */
int dmrs_typeA_pos = mac->dmrs_TypeA_Position;
int mux_pattern = 1;
@@ -1488,16 +1457,6 @@ nr_dci_format_t nr_ue_process_dci_indication_pdu(NR_UE_MAC_INST_t *mac, frame_t
dci->n_CCE,
dci->payloadSize,
*(unsigned long long *)dci->payloadBits);
extern int sniffer;
if (sniffer) {
LOG_I(NR_MAC,
"Received dci indication (rnti %x, dci format %d, n_CCE %d, payloadSize %d, payload %llx)\n",
dci->rnti,
dci->dci_format,
dci->n_CCE,
dci->payloadSize,
*(unsigned long long *)dci->payloadBits);
}
const nr_dci_format_t format =
nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, dci->ss_type, dci->payloadBits, slot);
if (format == NR_DCI_NONE)
@@ -3207,14 +3166,6 @@ static void extract_10_ra_rnti(dci_pdu_rel15_t *dci_pdu_rel15, const uint8_t *dc
EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5);
// TB scaling
EXTRACT_DCI_ITEM(dci_pdu_rel15->tb_scaling, 2);
extern int sniffer;
if (sniffer)
LOG_E(NR_MAC_DCI, " FDA %d TDA %d vrb2prb %d mcs %d tb_scaling %d\n",
dci_pdu_rel15->frequency_domain_assignment.val,
dci_pdu_rel15->time_domain_assignment.val,
dci_pdu_rel15->vrb_to_prb_mapping.val,
dci_pdu_rel15->mcs,
dci_pdu_rel15->tb_scaling);
}
static uint8_t extract_10_si_rnti(dci_pdu_rel15_t *dci_pdu_rel15, const uint8_t *dci_pdu, int pos, const int N_RB)
@@ -3519,18 +3470,11 @@ static nr_dci_format_t nr_extract_dci_00_10(NR_UE_MAC_INST_t *mac,
int format_indicator = -1;
int n_RB = 0;
extern int sniffer;
if (sniffer)
LOG_E(NR_MAC_DCI, "nr_extract_dci_00_10 DCI value %lb\n", *(uint64_t *)dci_pdu);
switch (rnti_type) {
case TYPE_RA_RNTI_ :
if (sniffer)
LOG_E(NR_MAC_DCI, "slot %d extract DCI for RA-RNTI\n", slot);
format = NR_DL_DCI_FORMAT_1_0;
dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][format];
n_RB = get_nrb_for_dci(mac, format, ss_type);
if (sniffer)
LOG_E(NR_MAC_DCI, " DCI for RA-RNTI n_RB %d\n", n_RB);
if (n_RB == 0)
return NR_DCI_NONE;
extract_10_ra_rnti(dci_pdu_rel15, dci_pdu, pos, n_RB);
@@ -3550,8 +3494,6 @@ LOG_E(NR_MAC_DCI, " DCI for RA-RNTI n_RB %d\n", n_RB);
return NR_DCI_NONE;
break;
case TYPE_C_RNTI_ :
if (sniffer)
LOG_E(NR_MAC_DCI, "slot %d extract DCI for TYPE_C_RNTI_\n", slot);
// Identifier for DCI formats
EXTRACT_DCI_ITEM(format_indicator, 1);
if (format_indicator == 1) {
@@ -3573,8 +3515,6 @@ LOG_E(NR_MAC_DCI, "slot %d extract DCI for TYPE_C_RNTI_\n", slot);
break;
case TYPE_TC_RNTI_ :
case TYPE_MSGB_RNTI_:
if (sniffer)
LOG_E(NR_MAC_DCI, "slot %d extract DCI for TYPE_TC_RNTI_\n", slot);
// Identifier for DCI formats
EXTRACT_DCI_ITEM(format_indicator, 1);
if (format_indicator == 1) {
@@ -3607,10 +3547,6 @@ static nr_dci_format_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
const int slot)
{
LOG_D(NR_MAC_DCI,"nr_extract_dci_info : dci_pdu %lx, size %d, format %d\n", *(uint64_t *)dci_pdu, dci_size, dci_format);
extern int sniffer;
if (sniffer) {
LOG_I(NR_MAC_DCI,"nr_extract_dci_info : dci_pdu %lx, size %d, format %d\n", *(uint64_t *)dci_pdu, dci_size, dci_format);
}
int rnti_type = get_rnti_type(mac, rnti);
int pos = dci_size;
@@ -3819,21 +3755,7 @@ static void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_
pdu_id,
pdu_len,
dl_info->rx_ind->number_pdus);
extern int sniffer;
if (sniffer)
LOG_I(MAC,
"[%d.%d]: processing PDU %d (with length %d) of %d total number of PDUs...\n",
frameP,
slot,
pdu_id,
pdu_len,
dl_info->rx_ind->number_pdus);
if (sniffer) {
printf("got pdu[%d]:", pdu_len);
for (int i = 0; i < pdu_len; i++) printf(" %2.2x", pduP[i]);
printf("\n"); fflush(stdout);
}
if (ra->ra_type == RA_2_STEP && ra->ra_state == nrRA_WAIT_MSGB) {
int n = nr_ue_validate_successrar(pduP, pdu_len, mac, gNB_index, frameP, slot);
pduP += n;
@@ -3846,9 +3768,6 @@ printf("\n"); fflush(stdout);
uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID;
LOG_D(MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len);
if (sniffer) {
LOG_E(MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len);
}
bool ret;
switch (rx_lcid) {
// MAC CE
@@ -4296,15 +4215,6 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
break;
}
}
extern int sniffer;
if (sniffer) {
rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR));
int rnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
LOG_E(NR_MAC, "new c-rnti to monitor %4.4x\n", rnti);
extern int rnti_to_monitor;
rnti_to_monitor = rnti;
}
if (!sniffer)
if (rarh->RAPID == preamble_index) {
// The MAC entity may stop ra-ResponseWindow (and hence monitoring for Random Access Response(s)) after
// successful reception of a Random Access Response containing Random Access Preamble identifiers
@@ -4333,7 +4243,6 @@ extern int sniffer;
break;
}
if (rarh->E == 0) {
if (!sniffer) {
LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] Received RAR preamble (%d) doesn't match the intended RAPID (%d)\n",
mac->ue_id,
frame,
@@ -4342,7 +4251,6 @@ if (!sniffer) {
preamble_index);
// resume RAR response window timer if MSG2 decoding failed
nr_timer_suspension(&mac->ra.response_window_timer);
}
break;
} else {
rarh += sizeof(NR_MAC_RAR) + 1;

View File

@@ -385,9 +385,6 @@ static void fill_mib_in_rx_ind(nfapi_nr_dl_tti_request_pdu_t *pdu_list, fapi_nr_
static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu)
{
extern int sniffer;
if (sniffer)
LOG_E(NR_MAC, "is_my_dci rnti %4.4x mac->ra.ra_state %d nrRA_WAIT_RAR %d\n", received_pdu->RNTI, mac->ra.ra_state, nrRA_WAIT_RAR);
/* For multiple UEs, we need to be able to filter the rx'd messages by
the RNTI. The filtering is different between NSA mode and SA mode.
NSA mode has a two step CFRA procedure and SA has a 4 step procedure.
@@ -447,11 +444,6 @@ static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_
{
LOG_D(NR_PHY, "[%d, %d] PDCCH DCI PDU (Format for incoming PDSCH PDU)\n",
dl_tti_request->SFN, dl_tti_request->Slot);
extern int sniffer;
if (sniffer) {
LOG_E(NR_PHY, "[%d, %d] PDCCH DCI PDU (Format for incoming PDSCH PDU)\n",
dl_tti_request->SFN, dl_tti_request->Slot);
}
uint16_t num_dcis = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci;
if (num_dcis > 0)
{
@@ -1168,14 +1160,8 @@ static int8_t handle_dlsch(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i
update_harq_status(mac,
dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid,
dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack);
extern int sniffer;
if (sniffer) {
/* this one sends RAR to MAC layer */
nr_ue_send_sdu(mac, dl_info, pdu_id);
} else {
if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack)
nr_ue_send_sdu(mac, dl_info, pdu_id);
}
return 0;
}

View File

@@ -1407,11 +1407,6 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas,
return;
}
extern int sniffer;
if (sniffer) {
LOG_E(NAS, "sniffer mode: do nothing\n");
return;
}
encode_registration_complete(mm_msg, initialNasMsg->nas_data + encoded, length - encoded);
/* ciphering */
@@ -1721,11 +1716,6 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
free(mm_msg->dnn.value);
free(mm_msg->snssai.value);
extern int sniffer;
if (sniffer) {
LOG_E(NAS, "sniffer mode: do nothing\n");
return;
}
/* ciphering */
uint8_t buf[initialNasMsg->length - 7];
stream_cipher.context = nas->security_container->ciphering_context;

View File

@@ -47,5 +47,3 @@ add_boolean_option(OAI_RF_EMULATOR ON "Activate OAI's RF emulator" OFF)
if(OAI_RF_EMULATOR)
add_subdirectory(emulator)
endif()
add_subdirectory(sniffer)

View File

@@ -99,7 +99,6 @@ int load_lib(openair0_device *device,
char *deflibname=OAI_RF_LIBNAME;
openair0_cfg->command_line_sample_advance = get_softmodem_params()->command_line_sample_advance;
openair0_cfg->recplay_mode = read_recplayconfig(&(openair0_cfg->recplay_conf),&(device->recplay_state));
openair0_cfg->sniffer_conf = read_sniffer_configuration();
if (openair0_cfg->recplay_mode == RECPLAY_RECORDMODE) {
IS_SOFTMODEM_IQRECORDER = true; // softmodem has to know we use the iqrecorder to workaround randomized algorithms
@@ -125,11 +124,6 @@ int load_lib(openair0_device *device,
shlib_fdesc[0].fname="transport_init";
}
if (openair0_cfg->sniffer_conf) {
deflibname = "sniffer";
shlib_fdesc[0].fname = "device_init";
}
char *devname=NULL;
paramdef_t device_params[]=DEVICE_PARAMS_DESC ;
int numparams = sizeofArray(device_params);

View File

@@ -37,7 +37,6 @@
#include <sys/types.h>
#include <openair1/PHY/TOOLS/tools_defs.h>
#include "record_player.h"
#include "sniffer_config.h"
#include "common/utils/threadPool/notified_fifo.h"
/* default name of shared library implementing the radio front end */
@@ -292,8 +291,6 @@ typedef struct openair0_config {
//! record player configuration, definition in record_player.h
uint32_t recplay_mode;
recplay_conf_t *recplay_conf;
//! sniffer file input: configuration
sniffer_configuration_t *sniffer_conf;
//! number of samples per tti
unsigned int samples_per_tti;
//! the sample rate for receive.

View File

@@ -1,92 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "sniffer_config.h"
#include "common/utils/LOG/log.h"
#include "common/config/config_userapi.h"
sniffer_configuration_t *read_sniffer_configuration(void)
{
/* nothing to configure if the sniffer mode is not activated */
int do_sniff = 0;
paramdef_t sniffer_enabled_params[] = SNIFFER_ENABLED_PARAMS_DESC;
config_get(config_get_if(), sniffer_enabled_params, sizeofArray(sniffer_enabled_params), NULL);
if (!do_sniff)
return 0;
/* get parameters */
char *filename = 0;
double gain = 1;
int s16 = false;
int resampler_interpolation = -1;
int resampler_decimation = -1;
double frequency_offset = 0;
int delay = 0;
char *trace_filename = 0;
int skip = 0;
paramdef_t sniffer_params[] = SNIFFER_PARAMS_DESC;
config_get(config_get_if(), sniffer_params, sizeofArray(sniffer_params), SNIFFER_SECTION);
/* no configuration if filename is not given
* sniffer works in realtime
*/
if (!filename)
return 0;
if (!s16) gain *= 32767;
LOG_I(HW, "sniffer configuration:\n");
LOG_I(HW, " filename '%s'\n", filename);
LOG_I(HW, " gain %g\n", gain);
LOG_I(HW, " s16 %d\n", s16);
LOG_I(HW, " resampler_interpolation %d\n", resampler_interpolation);
LOG_I(HW, " resampler_decimation %d\n", resampler_decimation);
LOG_I(HW, " frequency_offset %g\n", frequency_offset);
LOG_I(HW, " delay %d\n", delay);
LOG_I(HW, " trace_filename '%s'\n", trace_filename);
LOG_I(HW, " skip %d\n", skip);
AssertFatal((resampler_interpolation == -1 && resampler_decimation == -1)
|| (resampler_interpolation != -1 && resampler_decimation != -1),
"sniffer: both (or none) resampler_interpolation and resampler_decimation must be passed\n");
sniffer_configuration_t *ret = calloc_or_fail(1, sizeof(*ret));
ret->filename = filename;
ret->delay = delay;
ret->gain = gain;
ret->s16 = s16;
ret->do_resample = resampler_interpolation != -1;
ret->resampler_interpolation = resampler_interpolation;
ret->resampler_decimation = resampler_decimation;
ret->do_frequency_offset = frequency_offset != 0;
ret->frequency_offset = frequency_offset;
ret->trace_filename = trace_filename;
ret->skip = skip;
return ret;
}

View File

@@ -1,60 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef RADIO_COMMON_SNIFFER_CONFIG_H
#define RADIO_COMMON_SNIFFER_CONFIG_H
#include <stdbool.h>
#define SNIFFER_SECTION "device.sniffer"
#define SNIFFER_ENABLED_PARAMS_DESC { \
{ "sniffer", "use UE as a sniffer\n", PARAMFLAG_BOOL, .iptr = &do_sniff, .defintval = 0, TYPE_INT, 0 } \
}
#define SNIFFER_PARAMS_DESC { \
{ "file", "IQ file to read samples from\n", 0, .strptr = &filename, .defstrval = 0, TYPE_STRING, 0 }, \
{ "gain", "gain to apply to input signal\n", 0, .dblptr = &gain, .defdblval = 1, TYPE_DOUBLE, 0 }, \
{ "s16", "input signal is s16, not float\n", PARAMFLAG_BOOL, .iptr = &s16, .defintval = 0, TYPE_INT, 0 }, \
{ "resampler-interpolation", "resampler interpolation value\n", 0, .iptr = &resampler_interpolation, .defintval = -1, TYPE_INT, 0 }, \
{ "resampler-decimation", "resampler decimation value\n", 0, .iptr = &resampler_decimation, .defintval = -1, TYPE_INT, 0 }, \
{ "frequency-offset", "frequency offset (Hz) to apply to input signal\n", 0, .dblptr = &frequency_offset, .defdblval = 0, TYPE_DOUBLE, 0 }, \
{ "delay", "delay to apply in trx_sniffer_read()\n", 0, .iptr = &delay, .defintval = 0, TYPE_INT, 0 }, \
{ "trace-file", "IQ file to write samples to in trx_sniffer_read()\n", 0, .strptr = &trace_filename, .defstrval = 0, TYPE_STRING, 0 }, \
{ "skip", "number of samples to skip at startup\n", 0, .iptr = &skip, .defintval = 0, TYPE_INT, 0 }, \
}
typedef struct {
char *filename;
int delay; /* delay to apply in trx_sniffer_read(), unit: microsecond */
float gain;
bool s16;
bool do_resample;
int resampler_interpolation;
int resampler_decimation;
bool do_frequency_offset;
float frequency_offset;
char *trace_filename;
int skip;
} sniffer_configuration_t;
sniffer_configuration_t *read_sniffer_configuration(void);
#endif /* RADIO_COMMON_SNIFFER_CONFIG_H */

View File

@@ -1,3 +0,0 @@
add_library(sniffer MODULE sniffer.c frequency_offset.c)
set_target_properties(sniffer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_dependencies(vrtsim generate_T)

View File

@@ -1 +0,0 @@
This is a fake device to use the UE sniffer with a file.

View File

@@ -1,54 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <math.h>
#include <complex.h>
#include "common_lib.h"
float complex *init_frequency_offset(int table_size)
{
float complex *table = malloc_or_fail(table_size * sizeof(float complex));
int i;
for (i = 0; i < table_size; i++)
table[i] = cexpf(I * 2 * M_PI * i / table_size);
return table;
}
/* returns next cur_pos to use */
int frequency_offset(float complex *table, int samplerate,
int cur_pos,
float complex *in, int in_size,
int freq_offset)
{
int i;
for (i = 0; i < in_size; i++) {
in[i] *= table[cur_pos];
cur_pos -= freq_offset;
if (cur_pos < 0) cur_pos += samplerate;
if (cur_pos > samplerate) cur_pos -= samplerate;
}
return cur_pos;
}

View File

@@ -1,33 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef RADIO_SNIFFER_FREQUENCY_OFFSET_H
#define RADIO_SNIFFER_FREQUENCY_OFFSET_H
#include <complex.h>
float complex *init_frequency_offset(int table_size);
int frequency_offset(float complex *table, int samplerate,
int cur_pos,
float complex *in, int in_size,
int freq_offset);
#endif /* RADIO_SNIFFER_FREQUENCY_OFFSET_H */

View File

@@ -1,197 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "common_lib.h"
#include "common/utils/LOG/log.h"
#include "frequency_offset.h"
typedef struct {
FILE *f;
char *name;
uint64_t next_sample;
int samplerate;
int delay; /* delay to apply in trx_sniffer_read(), unit: microsecond */
float gain;
bool s16;
bool do_resample;
int resampler_interpolation;
int resampler_decimation;
bool do_frequency_offset;
int frequency_offset;
float complex *freq_offset_table;
int freq_offset_pos;
/* for debugging */
FILE *trace;
char *tracename;
} file_replay_t;
static int trx_sniffer_get_stats(openair0_device *device)
{
LOG_I(HW, "trx_sniffer_get_stats() called, not implemented\n");
return 0;
}
static int trx_sniffer_reset_stats(openair0_device *device)
{
LOG_I(HW, "trx_sniffer_reset_stats() called, not implemented\n");
return 0;
}
static int trx_sniffer_stop(openair0_device *device)
{
LOG_I(HW, "trx_sniffer_stop() called, not implemented\n");
return 0;
}
static int trx_sniffer_set_freq(openair0_device *device, openair0_config_t *openair0_cfg)
{
LOG_I(HW, "trx_sniffer_set_freq() called, not implemented\n");
return 0;
}
static int trx_sniffer_set_gains(openair0_device *device, openair0_config_t *openair0_cfg)
{
LOG_I(HW, "trx_sniffer_set_gains() called, not implemented\n");
return 0;
}
static int trx_sniffer_start(openair0_device *device)
{
return 0;
}
static void trx_sniffer_end(openair0_device *device)
{
}
static int trx_sniffer_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags)
{
return nsamps;
}
static int16_t to_short(float f, float gain)
{
/* for srs: 10000, for oai: 60000 */
float v = f * gain;
if (v < -32767) v = 32767;
if (v > 32767) v = 32767;
return v;
}
static int trx_sniffer_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc)
{
DevAssert(cc == 1);
file_replay_t *r = device->priv;
*ptimestamp = r->next_sample;
r->next_sample += nsamps;
short *out = buff[0];
if (!r->s16) {
float in[nsamps * 2];
memset(in, 0, sizeof(float) * 2 * nsamps);
fread(in, nsamps * 2 * sizeof(float), 1, r->f);
for (int i = 0; i < nsamps * 2; i++) out[i] = to_short(in[i], r->gain);
} else {
memset(out, 0, 2 * 2 * nsamps);
fread(out, nsamps * 2 * 2, 1, r->f);
for (int i = 0; i < nsamps * 2; i++) {
float v = out[i] * r->gain;
if (v < -32767) v = 32767;
if (v > 32767) v = 32767;
out[i] = v;
}
}
if (r->do_frequency_offset) {
float complex in[nsamps];
for (int i = 0; i < nsamps; i++) in[i] = out[i*2] + I * out[i*2+1];
r->freq_offset_pos = frequency_offset(r->freq_offset_table, 3072000, r->freq_offset_pos, in, nsamps, r->frequency_offset);
for (int i = 0; i < nsamps; i++) {
out[i*2] = crealf(in[i]);
out[i*2+1] = cimagf(in[i]);
}
}
if (r->trace) {
fwrite(out, nsamps*4, 1, r->trace);
fflush(r->trace);
}
usleep(r->delay);
return nsamps;
}
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
device->openair0_cfg = openair0_cfg;
device->trx_start_func = trx_sniffer_start;
device->trx_get_stats_func = trx_sniffer_get_stats;
device->trx_reset_stats_func = trx_sniffer_reset_stats;
device->trx_end_func = trx_sniffer_end;
device->trx_stop_func = trx_sniffer_stop;
device->trx_set_freq_func = trx_sniffer_set_freq;
device->trx_set_gains_func = trx_sniffer_set_gains;
device->trx_write_func = trx_sniffer_write;
device->trx_read_func = trx_sniffer_read;
device->type = 3; /* USRP N300 */
//recplay_conf_t *c = openair0_cfg->recplay_conf;
file_replay_t *r = calloc_or_fail(1, sizeof(*r));
device->priv = r;
sniffer_configuration_t *s = openair0_cfg->sniffer_conf;
r->name = strdup(s->filename);
DevAssert(r->name);
r->f = fopen(r->name, "r");
if (!r->f) {
LOG_E(HW, "could not open file %s: %s\n", r->name, strerror(errno));
exit(1);
}
r->samplerate = openair0_cfg->sample_rate;
r->delay = s->delay;
r->gain = s->gain;
r->s16 = s->s16;
if (s->trace_filename) {
r->tracename = strdup(s->trace_filename);
DevAssert(r->tracename);
r->trace = fopen(r->tracename, "w");
if (!r->trace) {
LOG_E(HW, "cannot create trace file %s: %s\n", r->tracename, strerror(errno));
exit(1);
}
}
r->do_resample = s->do_resample;
r->resampler_interpolation = s->resampler_interpolation;
r->resampler_decimation = s->resampler_decimation;
r->frequency_offset = s->frequency_offset / r->samplerate * 3072000.;
r->do_frequency_offset = s->do_frequency_offset && r->frequency_offset;
if (s->skip) {
if (r->s16) {
short b[s->skip * 2];
fread(b, s->skip * 2 * sizeof(short), 1, r->f);
} else {
float b[s->skip * 2];
fread(b, s->skip * 2 * sizeof(float), 1, r->f);
}
}
if (r->do_frequency_offset)
r->freq_offset_table = init_frequency_offset(3072000);
return 0;
}
/*@}*/

View File

@@ -1,93 +0,0 @@
#generic command line: sudo ip netns exec oai-ue1 ./nr-uesoftmodem --uicc0.imsi 505010000000002 --log_config.nas_log_level debug --log_config.ngap_log_level debug --uicc0.dnn internet --thread-pool N --ue-fo-compensation -O ~/ant0/radio/sniffer/ue.conf
hack = 1
sniffer = 1
######################################################################
# parameters for /tmp/srs-3489420000Hz-23040000sps-sc16.raw
# sib1 decoded, ue traffic decoded
#ssb = 0
#E = 1
#C = 3489420000
#r = 51
#numerology = 1
#band = 78
#device = {
# sniffer = {
# s16 = 1
# gain = 0.04
# file = "/tmp/srs-3489420000Hz-23040000sps-sc16.raw"
# frequency-offset = -7915
# delay = 200
# trace-file = "/tmp/X"
# }
#}
######################################################################
# parameters for /tmp/oai-gnb-b78-106rb-61.44MHz.raw
# sib1 decoded, there is no ue connected so no traffic decoded
#ssb = 516
#E = 0
#C = 3489420000
#r = 106
#numerology = 1
#band = 78
#device = {
# sniffer = {
# s16 = 0
# gain = 10
# file = "/tmp/oai-gnb-b78-106rb-61.44MHz.raw"
# frequency-offset = -4793
# delay = 200
# trace-file = "/tmp/X"
# }
#}
######################################################################
# parameters for /tmp/srsRAN_tdd_n78_samprate_2304_20MHz_scs_30khz.fc32
#note: no SIB1 decoded
#ssb = 186
#E = 1
#C = 3483840000
#r = 51
#numerology = 1
#band = 78
#device = {
# sniffer = {
# s16 = 0
# #gain = 0.0565016
# gain = 0.08
# file = "/tmp/srsRAN_tdd_n78_samprate_2304_20MHz_scs_30khz.fc32"
# frequency-offset = -6981
# delay = 200
# trace-file = "/tmp/X"
# }
#}
#log_config = {
# global_log_level = "debug"
#}
######################################################################
# parameters for /tmp/srsRAN_octoclock_samprate_2304_10MHz_scscommon_15khz_b200_fdd_n71_pci_1_2phones_onevoicecall_oneyoutube_rntis_4601_4602_5seconds.resampled-15360.fc32
#note: MIB decoded, but coreset0 start PRB is -1 => AssertFatal()
ssb = 192
E = 0
C = 627750000
r = 52
numerology = 0
band = 71
device = {
sniffer = {
s16 = 0
#gain = 0.0565016
gain = 0.142262
file = "/tmp/srsRAN_octoclock_samprate_2304_10MHz_scscommon_15khz_b200_fdd_n71_pci_1_2phones_onevoicecall_oneyoutube_rntis_4601_4602_5seconds.resampled-15360.fc32"
frequency-offset = 3728
delay = 200
skip = 10000
trace-file = "/tmp/X"
}
}
log_config = {
global_log_level = "debug"
}