Commit 4a9afa91 authored by Bo Zhao's avatar Bo Zhao Committed by Marwan Hammouda

Adding CL option -P to simulate the propagation delay in the RF simulator

parent 97b08440
......@@ -110,6 +110,7 @@
#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n"
#define CONFIG_HLP_NOS1 "Disable s1 interface\n"
#define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n"
#define CONFIG_HLP_PROPD "Set propagation delay in the RF simulator (expressed in number of samples)\n"
/*--------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters for LOG utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
......@@ -154,4 +155,6 @@ extern int emulate_rf;
extern int numerology;
extern int usrp_tx_thread;
extern uint64_t RFsim_PropDelay; //propagation delay in the RF simulator (expressed in number of samples)
#endif
......@@ -568,6 +568,8 @@ void init_pdcp(void) {
}
}
uint64_t RFsim_PropDelay = 0;
int main( int argc, char **argv ) {
int ru_id, CC_id = 0;
start_background_system();
......
......@@ -32,6 +32,7 @@
{"ldpc-offload-enable", CONFIG_HLP_LDPC_OFFLOAD, 0, .iptr=&ldpc_offload_flag, .defstrval=0, TYPE_INT, 0}, \
{"uecap_file", CONFIG_HLP_UECAP_FILE, 0, .strptr=&uecap_file, .defstrval="./uecap_ports1.xml", TYPE_STRING, 0}, \
{"s" , CONFIG_HLP_SNR, 0, .dblptr=&snr_dB, .defdblval=25, TYPE_DOUBLE, 0}, \
{"P" , CONFIG_HLP_PROPD, 0, .u64ptr=&RFsim_PropDelay, .defintval=0, TYPE_UINT64, 0}, \
}
// clang-format on
......
......@@ -424,6 +424,7 @@ static void get_channel_model_mode() {
}
int NB_UE_INST = 1;
uint64_t RFsim_PropDelay = 0;
int main( int argc, char **argv ) {
int set_exe_prio = 1;
......
......@@ -63,6 +63,7 @@
{"chest-time", CONFIG_HLP_CHESTTIME, 0, .iptr=&(nrUE_params.chest_time), .defintval=0, TYPE_INT, 0}, \
{"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, .iptr=&(nrUE_params.no_timing_correction), .defintval=0, TYPE_INT, 0}, \
{"SLC", CONFIG_HLP_SLF, 0, .u64ptr=&(sidelink_frequency[0][0]), .defuintval=2600000000,TYPE_UINT64,0}, \
{"P" , CONFIG_HLP_PROPD, 0, .u64ptr=&RFsim_PropDelay, .defintval=0, TYPE_UINT64, 0}, \
}
// clang-format on
......
......@@ -54,7 +54,7 @@
#include "rfsimulator.h"
#define PORT 4043 //default TCP port for this simulator
#define CirSize 6144000 // 100ms is enough
#define CirSize 61440000 //curently the circular buffer can hold 100 frames
#define sampleToByte(a,b) ((a)*(b)*sizeof(sample_t))
#define byteToSample(a,b) ((a)/(sizeof(sample_t)*(b)))
......@@ -602,6 +602,7 @@ static int startClient(openair0_device *device) {
return 0;
}
extern uint64_t RFsim_PropDelay;
static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp timestamp, void **samplesVoid, int nsamps, int nbAnt, int flags, bool alreadyLocked) {
if (!alreadyLocked)
pthread_mutex_lock(&Sockmutex);
......@@ -877,7 +878,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
a,
ptr->channel_model,
nsamps,
t->nextRxTstamp,
t->nextRxTstamp-RFsim_PropDelay,
CirSize);
}
else { // no channel modeling
......@@ -893,8 +894,8 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
//LOG_I(HW, "nbAnt_tx %d\n",nbAnt_tx);
for (int i=0; i < nsamps; i++) {//loop over nsamps
for (int a_tx=0; a_tx<nbAnt_tx; a_tx++) { //sum up signals from nbAnt_tx antennas
out[i].r += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
out[i].i += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
out[i].r += (short)(ptr->circularBuf[((t->nextRxTstamp-RFsim_PropDelay+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
out[i].i += (short)(ptr->circularBuf[((t->nextRxTstamp-RFsim_PropDelay+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
} // end for a_tx
} // end for i (number of samps)
} // end of no channel modeling
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment