diff --git a/radio/rfsimulator/apply_channelmod.c b/radio/rfsimulator/apply_channelmod.c index 2eaa6a66c2..2dac26c4e6 100644 --- a/radio/rfsimulator/apply_channelmod.c +++ b/radio/rfsimulator/apply_channelmod.c @@ -27,29 +27,9 @@ #include "openair2/LAYER2/NR_MAC_gNB/mac_config.h" #include "rfsimulator.h" -/* - Legacy study: - The parameters are: - gain&loss (decay, signal power, ...) - either a fixed gain in dB, a target power in dBm or ACG (automatic control gain) to a target average - => don't redo the AGC, as it was used in UE case, that must have a AGC inside the UE - will be better to handle the "set_gain()" called by UE to apply it's gain (enable test of UE power loop) - lin_amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); - a lot of operations in legacy, grouped in one simulation signal decay: txgain*decay*rxgain - - multi_path (auto convolution, ISI, ...) - either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes - legacy: we regenerate each sub frame in UL, and each frame only in DL -*/ -void rxAddInput(const c16_t **input_sig, - cf_t *after_channel_sig, - int rxAnt, - channel_desc_t *channelDesc, - int nbSamples, - uint64_t TS) +void update_channel_model(channel_desc_t *channelDesc, uint64_t TS) { static uint64_t last_TS = 0; - if ((channelDesc->sat_height > 0) && (channelDesc->enable_dynamic_delay || channelDesc->enable_dynamic_Doppler)) { // model for transparent satellite on circular orbit @@ -239,7 +219,29 @@ void rxAddInput(const c16_t **input_sig, } } } +} +/* + Legacy study: + The parameters are: + gain&loss (decay, signal power, ...) + either a fixed gain in dB, a target power in dBm or ACG (automatic control gain) to a target average + => don't redo the AGC, as it was used in UE case, that must have a AGC inside the UE + will be better to handle the "set_gain()" called by UE to apply it's gain (enable test of UE power loop) + lin_amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); + a lot of operations in legacy, grouped in one simulation signal decay: txgain*decay*rxgain + + multi_path (auto convolution, ISI, ...) + either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes + legacy: we regenerate each sub frame in UL, and each frame only in DL +*/ +void rxAddInput(const c16_t **input_sig, + cf_t *after_channel_sig, + int rxAnt, + channel_desc_t *channelDesc, + int nbSamples, + uint64_t TS) +{ // channelDesc->path_loss_dB should contain the total path gain // so, in actual RF: tx gain + path loss + rx gain (+antenna gain, ...) // UE and NB gain control to be added diff --git a/radio/rfsimulator/rfsimulator.h b/radio/rfsimulator/rfsimulator.h index 0ebdef0d6d..90c2be2f82 100644 --- a/radio/rfsimulator/rfsimulator.h +++ b/radio/rfsimulator/rfsimulator.h @@ -30,5 +30,5 @@ void rxAddInput(const c16_t **input_sig, channel_desc_t *channelDesc, int nbSamples, uint64_t TS); - +void update_channel_model(channel_desc_t *channelDesc, uint64_t TS); #endif diff --git a/radio/rfsimulator/simulator.cpp b/radio/rfsimulator/simulator.cpp index e06e9f5bab..793dfedf18 100644 --- a/radio/rfsimulator/simulator.cpp +++ b/radio/rfsimulator/simulator.cpp @@ -1186,11 +1186,11 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t, memset(temp_array, 0, sizeof(temp_array)); channel_modelling = true; } - const uint64_t dd = ptr->channel_model->channel_offset; + const uint64_t channel_offset = ptr->channel_model->channel_offset; const uint64_t channel_length = ptr->channel_model->channel_length; std::vector> ant_buffers = combine_received_beams(t, ptr->received_packets, - timestamp - dd - (channel_length - 1), + timestamp - channel_offset - (channel_length - 1), ptr->nbAnt, nsamps + channel_length - 1, rx_beam_id); @@ -1314,6 +1314,14 @@ static int rfsimulator_read_beams(openair0_device *device, int ret = clock_gettime(CLOCK_REALTIME, &start_time); AssertFatal(ret == 0, "clock_gettime() failed: errno %d, %s\n", errno, strerror(errno)); + for (int sock = 0; sock < MAX_FD_RFSIMU; sock++) { + buffer_t *ptr = &t->buf[sock]; + + if (ptr->conn_sock != -1 && ptr->channel_model != NULL) { + update_channel_model(ptr->channel_model, t->nextRxTstamp); + } + } + if (t->poll_telnetcmdq) t->poll_telnetcmdq(t->telnetcmd_qid, t); @@ -1375,7 +1383,7 @@ static int rfsimulator_read_beams(openair0_device *device, if (ptr->conn_sock != -1 && !ptr->received_packets.empty()) { openair0_timestamp timestamp_to_free = t->nextRxTstamp - 1; if (ptr->channel_model) { - timestamp_to_free -= ptr->channel_model->channel_length - ptr->channel_model->channel_offset; + timestamp_to_free -= (ptr->channel_model->channel_length - 1) + ptr->channel_model->channel_offset; } clear_old_packets(ptr->received_packets, timestamp_to_free); }