RFsim: Fix freeing packets in case of non-negative channel offset
In rfsim, received packets are dynamically allocated and freed when no longer needed, which is dependent on the channel model, packet timestamp and packet size (number of samples carried). This commit fixes the packet age check for channels with nonzero channel offset (most notalby NTN channels). Also present: - extract the NTN satellite position update code to a separate function and call it once per trx_read call instead of once per rx beam.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<std::vector<c16_t>> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user