diff --git a/common/utils/telnetsrv/DOC/telnetarch.md b/common/utils/telnetsrv/DOC/telnetarch.md index 683b14a1b8..4b738faa35 100644 --- a/common/utils/telnetsrv/DOC/telnetarch.md +++ b/common/utils/telnetsrv/DOC/telnetarch.md @@ -21,11 +21,11 @@ The telnet server provides an API which can be used by any oai component to add telnet server source files are located in [common/utils/telnetsrv](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv) -1. [telnetsrv.c](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv/telnetsrv.c) contains the telnet server implementation, including the implementation of the `telnet` CLI command. This implementation is compatible with all softmodem executables and is in charge of loading any additional `libtelnetsrv_ .so` containing code specific to the running executables. -1. [telnetsrv.h](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv/telnetsrv.h) is the telnet server include file containing both private and public data type definitions. It also contains API prototypes for functions that are used to register a new command in the server. +1. [telnetsrv.c](../telnetsrv.c) contains the telnet server implementation, including the implementation of the `telnet` CLI command. This implementation is compatible with all softmodem executables and is in charge of loading any additional `libtelnetsrv_ .so` containing code specific to the running executables. +1. [telnetsrv.h](../telnetsrv.h) is the telnet server include file containing both private and public data type definitions. It also contains API prototypes for functions that are used to register a new command in the server. 1. `telnetsrv_.c`: implementation of \ CLI command which are delivered with the telnet server and are common to all softmodem executables. 1. `telnetsrv_.h`: include file for the implementation of XXX CLI command. Usually included only in the corresponding `.c`file 1. `telnetsrv__.c`: implementation of \ CLI command specific to the executable identified by \.These sources are used to create `libtelnetsrv_.so` at build time. -1. [telnetsrv_CMakeLists.txt](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/utils/telnetsrv/telnetsrv_CMakeLists.txt): CMakelists file containing the cmake instructions to build the telnet server. this file is included in the [global oai CMakelists](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/cmake_targets/CMakeLists.txt). +1. [telnetsrv_CMakeLists.txt](../CMakeLists.txt): CMakelists file containing the cmake instructions to build the telnet server. this file is included in the [global oai CMakelists](../../../../cmake_targets/CMakeLists.txt). [oai telnet server home](telnetsrv.md) diff --git a/common/utils/telnetsrv/DOC/telnetusage.md b/common/utils/telnetsrv/DOC/telnetusage.md index 8b8b72a698..8c69d247a8 100644 --- a/common/utils/telnetsrv/DOC/telnetusage.md +++ b/common/utils/telnetsrv/DOC/telnetusage.md @@ -26,7 +26,7 @@ Below are examples of telnet sessions: * [measur command](telnetmeasur.md) # telnet server parameters -The telnet server is using the [oai configuration module](Config/Rtusage). Telnet parameters must be specified in the `telnetsrv` section. Some parameters can be modified via the telnet telnet server command, as specified in the last column of the following table. +The telnet server is using the [oai configuration module](../../../../common/config/DOC/config/rtusage.md). Telnet parameters must be specified in the `telnetsrv` section. Some parameters can be modified via the telnet telnet server command, as specified in the last column of the following table. | name | type | default | description | dynamic | |:---:|:---:|:---:|:----|:----:| diff --git a/doc/README.md b/doc/README.md index 1ceba8f494..9789726fc8 100644 --- a/doc/README.md +++ b/doc/README.md @@ -43,6 +43,7 @@ There is some general information in the [OpenAirInterface Gitlab Wiki](https:// - [How to run a 5G-NSA setup](./TESTING_GNB_W_COTS_UE.md) - [How to run a 4G setup using L1 simulator](./L1SIM.md) _Note: we recommend the RFsimulator_ - [How to use the L2 simulator](./L2NFAPI.md) +- [How to use the OAI channel simulator](../openair1/SIMULATION/TOOLS/DOC/channel_simulation.md) - [How to use multiple BWPs](./RUN_NR_multiple_BWPs.md) - [How to run OAI-VNF and OAI-PNF](./RUN_NR_NFAPI.md) _Note: does not work currently_ - [How to use the positioning reference signal (PRS)](./RUN_NR_PRS.md) diff --git a/executables/lte-softmodem.h b/executables/lte-softmodem.h index ac403ecfec..058018001b 100644 --- a/executables/lte-softmodem.h +++ b/executables/lte-softmodem.h @@ -170,9 +170,6 @@ extern void init_UE(int nb_inst, extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char *name); -extern void init_ocm(void); -extern void init_ue_devices(PHY_VARS_UE *); - PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); void init_eNB_afterRU(void); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index ee6ad7200e..3d9c02f5e4 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -116,7 +116,6 @@ unsigned char NB_gNB_INST = 1; char *uecap_file; runmode_t mode = normal_txrx; -static double snr_dB=20; #if MAX_NUM_CCs == 1 rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}}; diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index 54bcc0fc5d..6f2a54f2e8 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -28,7 +28,6 @@ {"U" , CONFIG_HLP_ULBM_PHYTEST, 0, .u64ptr=&ulsch_slot_bitmap, .defintval=0, TYPE_UINT64, 0}, \ {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, .iptr=&usrp_tx_thread, .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}, \ } // clang-format on diff --git a/executables/rfsim.c b/executables/rfsim.c deleted file mode 100644 index c7ab4ccb66..0000000000 --- a/executables/rfsim.c +++ /dev/null @@ -1,495 +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 - */ - -/*! \file rfsim.c -* \brief function for simulated RF device -* \author R. Knopp -* \date 2018 -* \version 1.0 -* \company Eurecom -* \email: openair_tech@eurecom.fr -* \note -* \warning -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "assertions.h" -#include "rfsim.h" -#include "openair1/SIMULATION/TOOLS/sim.h" -#include "enb_config.h" -#include "enb_paramdef.h" -#include "common/platform_constants.h" -#include "common/config/config_paramdesc.h" -#include "common/config/config_userapi.h" -#include "common/ran_context.h" -#include "PHY/defs_UE.h" -#include "PHY/defs_eNB.h" -#include "PHY/defs_RU.h" -#include "common/utils/LOG/vcd_signal_dumper.h" - -RAN_CONTEXT_t RC; -extern PHY_VARS_UE ***PHY_vars_UE_g; - - -// put all of these in a common structure after -sim_t sim; - - -void init_ru_devices(void); - -void init_RU(char *,int send_dmrssync); - -void *rfsim_top(void *n_frames); - -void wait_RUs(void) { - int i; - // wait for all RUs to be configured over fronthaul - pthread_mutex_lock(&RC.ru_mutex); - - while (RC.ru_mask>0) { - pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); - } - - pthread_mutex_unlock(&RC.ru_mutex); - - // copy frame parameters from RU to UEs - for (i=0; iframe_parms->samples_per_tti + RC.ru[0]->frame_parms->ofdm_symbol_size + RC.ru[0]->frame_parms->nb_prefix_samples0; - } - - for (int ru_id=0; ru_idframe_parms->samples_per_tti; - - printf("RUs are ready, let's go\n"); -} - -void wait_eNBs(void) { - return; -} - - -void RCConfig_sim(void) { - paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; - // Get num RU instances - config_getlist( &RUParamList,NULL,0, NULL); - RC.nb_RU = RUParamList.numelt; - AssertFatal(RC.nb_RU>0,"we need at least 1 RU for simulation\n"); - printf("returned with %d rus\n",RC.nb_RU); - init_RU(NULL,0); - printf("Waiting for RUs to get set up\n"); - wait_RUs(); - init_ru_devices(); - static int nframes = 100000; - AssertFatal(0 == pthread_create(&sim.rfsim_thread, - NULL, - rfsim_top, - (void *)&nframes), ""); -} - - - -int ru_trx_start(openair0_device *device) { - return(0); -} - -void ru_trx_end(openair0_device *device) { - return; -} - -int ru_trx_stop(openair0_device *device) { - return(0); -} -int UE_trx_start(openair0_device *device) { - return(0); -} -void UE_trx_end(openair0_device *device) { - return; -} -int UE_trx_stop(openair0_device *device) { - return(0); -} -int ru_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) { - return(0); -} -int ru_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { - return(0); -} -int UE_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) { - return(0); -} -int UE_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { - return(0); -} - -extern pthread_mutex_t subframe_mutex; -extern int subframe_ru_mask,subframe_UE_mask; - - -int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - int ru_id = device->Mod_id; - int CC_id = device->CC_id; - int subframe; - int sample_count=0; - *ptimestamp = sim.last_ru_rx_timestamp[ru_id][CC_id]; - LOG_D(SIM,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, - (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id], - (unsigned long long)sim.last_ru_rx_timestamp[ru_id][CC_id], - (int)((*ptimestamp/RC.ru[ru_id]->frame_parms->samples_per_tti)%10)); - - // if we're at a subframe boundary generate UL signals for this ru - - while (sample_countframe_parms->samples_per_tti)%10; - - if (subframe_select(RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms->frame_type == FDD) { - LOG_D(SIM,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id]); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,1); - do_UL_sig(&sim, - subframe, - 0, // abstraction_flag - RC.ru[ru_id]->frame_parms, - 0, // frame is only used for abstraction - ru_id, - CC_id, - 1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,0); - } - - sim.last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms->samples_per_tti; - sample_count += RC.ru[ru_id]->frame_parms->samples_per_tti; - } - - return(nsamps); -} - -int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,1); - int UE_id = device->Mod_id; - int CC_id = device->CC_id; - int subframe; - int sample_count=0; - int read_size; - int sptti = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti; - *ptimestamp = sim.last_UE_rx_timestamp[UE_id][CC_id]; - LOG_D(PHY,"UE %d DL simulation 0: UE_trx_read nsamps %d TS %llu (%llu, offset %d) antenna %d\n", - UE_id, - nsamps, - (unsigned long long)sim.current_UE_rx_timestamp[UE_id][CC_id], - (unsigned long long)sim.last_UE_rx_timestamp[UE_id][CC_id], - (int)(sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti), - cc); - - if (nsamps < sptti) - read_size = nsamps; - else - read_size = sptti; - - while (sample_countframe_parms, - UE_id, - CC_id); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_DL_SIGNAL,0); - LOG_D(PHY,"UE %d: DL simulation 6: UE_trx_read @ TS %"PRIi64" (%"PRIi64")=> frame %d, subframe %d\n", - UE_id, sim.current_UE_rx_timestamp[UE_id][CC_id], - sim.last_UE_rx_timestamp[UE_id][CC_id], - (int)((sim.last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023), - subframe); - sim.last_UE_rx_timestamp[UE_id][CC_id] += read_size; - sample_count += read_size; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,0); - return(nsamps); -} - - -int ru_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - int ru_id = device->Mod_id; - LTE_DL_FRAME_PARMS *frame_parms = RC.ru[ru_id]->frame_parms; - pthread_mutex_lock(&sim.subframe_mutex); - LOG_D(SIM,"[TXPATH] ru_trx_write: RU %d mask %d\n",ru_id,sim.subframe_ru_mask); - pthread_mutex_unlock(&sim.subframe_mutex); - // compute amplitude of TX signal from first symbol in subframe - // note: assumes that the packet is an entire subframe - sim.ru_amp[ru_id] = 0; - - for (int aa=0; aanb_tx; aa++) { - sim.ru_amp[ru_id] += (double)signal_energy((int32_t *)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL); - } - - sim.ru_amp[ru_id] = sqrt(sim.ru_amp[ru_id]); - LOG_D(PHY,"Setting amp for RU %d to %f (%d)\n",ru_id,sim.ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t *)buff[0],frame_parms->ofdm_symbol_size))); - // tell top-level we are done - pthread_mutex_lock(&sim.subframe_mutex); - sim.subframe_ru_mask|=(1<rfdevice.Mod_id = ru_id; - ru->rfdevice.CC_id = 0; - ru->rfdevice.trx_start_func = ru_trx_start; - ru->rfdevice.trx_read_func = ru_trx_read; - ru->rfdevice.trx_write_func = ru_trx_write; - ru->rfdevice.trx_end_func = ru_trx_end; - ru->rfdevice.trx_stop_func = ru_trx_stop; - ru->rfdevice.trx_set_freq_func = ru_trx_set_freq; - ru->rfdevice.trx_set_gains_func = ru_trx_set_gains; - sim.last_ru_rx_timestamp[ru_id][0] = 0; - } -} - -void init_ue_devices(PHY_VARS_UE *UE) { - AssertFatal(UE!=NULL,"UE context is not allocated\n"); - printf("Initializing UE %d.%d\n",UE->Mod_id,UE->CC_id); - UE->rfdevice.Mod_id = UE->Mod_id; - UE->rfdevice.CC_id = UE->CC_id; - UE->rfdevice.trx_start_func = UE_trx_start; - UE->rfdevice.trx_read_func = UE_trx_read; - UE->rfdevice.trx_write_func = UE_trx_write; - UE->rfdevice.trx_end_func = UE_trx_end; - UE->rfdevice.trx_stop_func = UE_trx_stop; - UE->rfdevice.trx_set_freq_func = UE_trx_set_freq; - UE->rfdevice.trx_set_gains_func = UE_trx_set_gains; - sim.last_UE_rx_timestamp[UE->Mod_id][UE->CC_id] = 0; -} - -void init_ocm(void) { - module_id_t UE_id, ru_id; - int CC_id; - double DS_TDL = .03; - randominit(0); - set_taus_seed(0); - init_channelmod(); - double snr_dB = channelmod_get_snr_dB(); - double sinr_dB = channelmod_get_sinr_dB(); - init_channel_vars ();//fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); - // initialize channel descriptors - LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST); - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - for (CC_id=0; CC_idframe_parms->N_RB_DL); - sim.RU2UE[ru_id][UE_id][CC_id] = - new_channel_desc_scm(RC.ru[ru_id]->nb_tx, - PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), - DS_TDL, - CORR_LEVEL_LOW, - 0.0, - 0, - 0, - 0); - random_channel(sim.RU2UE[ru_id][UE_id][CC_id],0); - LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN", UE_id, ru_id); - - sim.UE2RU[UE_id][ru_id][CC_id] = - new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, - RC.ru[ru_id]->nb_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), - DS_TDL, - CORR_LEVEL_LOW, - 0.0, - 0, - 0, - 0); - random_channel(sim.UE2RU[UE_id][ru_id][CC_id],0); - // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. - //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id]; - AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); - AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); - - //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE - if (ru_id == (UE_id % RC.nb_RU)) { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } - - LOG_I(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, - snr_dB); - } - } - } -} - - -void update_ocm(double snr_dB,double sinr_dB) { - module_id_t UE_id, ru_id; - int CC_id; - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - for (CC_id=0; CC_idpath_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } - - LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, - snr_dB); - } - } - } -} - - -void init_channel_vars(void) { - int i; - memset(sim.RU_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX); - - for (i=0; iframe_parms,(sf+4)%10)!=SF_UL) ? sim.subframe_ru_mask : ((1<frame_parms->frame_type == FDD || subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? sim.subframe_UE_mask : ((1<frame_parms->samples_per_tti; - LOG_D(SIM,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,sim.current_ru_rx_timestamp[ru_id][CC_id]); - } - - for (int UE_inst = 0; UE_instframe_parms.samples_per_tti; - LOG_D(SIM,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,sim.current_UE_rx_timestamp[UE_inst][CC_id]); - } - - if (oai_exit == 1) return((void *)NULL); - } - } - - return((void *)NULL); -} diff --git a/openair1/PHY/TOOLS/calibration_test.c b/openair1/PHY/TOOLS/calibration_test.c index 0c5f40cffd..46ab22e19a 100644 --- a/openair1/PHY/TOOLS/calibration_test.c +++ b/openair1/PHY/TOOLS/calibration_test.c @@ -14,7 +14,6 @@ int8_t threequarter_fs; uint64_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int opp_enabled; -static double snr_dB=20; THREAD_STRUCT thread_struct; uint32_t target_ul_mcs = 9; uint32_t target_dl_mcs = 9; diff --git a/openair1/PHY/defs_L1_NB_IoT.h b/openair1/PHY/defs_L1_NB_IoT.h index 38996e20a0..3eb0ed044f 100644 --- a/openair1/PHY/defs_L1_NB_IoT.h +++ b/openair1/PHY/defs_L1_NB_IoT.h @@ -551,9 +551,6 @@ typedef struct PHY_VARS_eNB_NB_IoT_s { int max_eNB_id, max_sync_pos; /// int N_TA_offset; ///timing offset used in TDD - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// first index: ? [0..N_RB_DL*12[ - double *sinr_dB; /// N0 (used for abstraction) double N0; /// @@ -885,9 +882,6 @@ typedef struct { int mac_enabled; /// Flag to initialize averaging of PHY measurements int init_averaging; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. /// - first index: ? [0..12*N_RB_DL[ double *sinr_CQI_dB; diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h index 06eaf4a15d..5a090752d5 100644 --- a/openair1/PHY/defs_UE.h +++ b/openair1/PHY/defs_UE.h @@ -738,10 +738,6 @@ typedef struct { /// Flag to initialize averaging of PHY measurements int init_averaging; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; - /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. /// - first index: ? [0..12*N_RB_DL[ double *sinr_CQI_dB; diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 389f15e82b..b872148dd2 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -616,10 +616,6 @@ typedef struct PHY_VARS_eNB_s { uint32_t max_peak_val; int max_eNB_id, max_sync_pos; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// first index: ? [0..N_RB_DL*12[ - double *sinr_dB; - /// N0 (used for abstraction) double N0; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 834163d8ed..bb77dac067 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -512,10 +512,6 @@ typedef struct PHY_VARS_NR_UE_s { /// Flag to initialize averaging of PHY measurements int init_averaging; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; - /// sinr_effective used for CQI calulcation double sinr_eff; diff --git a/openair1/SIMULATION/TOOLS/DOC/arch.md b/openair1/SIMULATION/TOOLS/DOC/arch.md deleted file mode 100644 index 30be337829..0000000000 --- a/openair1/SIMULATION/TOOLS/DOC/arch.md +++ /dev/null @@ -1,9 +0,0 @@ -# Channel simulation source files - -1. [random_channel.c](../random_channel.c) -1. [sim.h](../sim.h) - - - -[channel simulation main page](channel_simulation.md) -[oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) \ No newline at end of file diff --git a/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md b/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md index be2b987b40..6d1546b484 100644 --- a/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md +++ b/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md @@ -1,13 +1,206 @@ +[[_TOC_]] + # OAI channel simulation feature -oai includes a channel simulation feature that any component can use to alter time domain samples of a RF channel by applying pre-defined models as defined, for example, in 3GPP TR 36.873 or TR 38.901 +OpenAirInterface RFSimulator incorporates a channel simulation feature. This feature allows any component to modify the time domain samples of a RF channel. It achieves this by applying predefined models, such as those defined in 3GPP TR 36.873 or TR 38.901. -Definition, configuration and run-time modification of a channel model are implemented in common code included in UEs, gNb, eNB and used when running with the rfsimulator or the L1 simulator. Phy simulators are also using channel simulation but configuration is done via dedicated command line options. The rfsimulator is the only option to get access to all the configurations and run-time modifications features of oai channel simulation. +The definition, configuration, and real-time modification of a channel model are implemented in a common code. This code is included in UE, gNB and eNB. It is utilized when operating with the RFSimulator or the L1 simulator. PHY simulators also employ channel simulation, but their configuration is accomplished via dedicated command-line options. -## Documentation +The RFSimulator is the exclusive option that provides access to all the configuration and real-time modification features of OAI's channel simulation. This makes it a comprehensive tool for managing and manipulating channel simulations in OAI. -* [runtime usage](rtusage.md) -* [developer usage](devusage.md) -* [module architecture](arch.md) + +# Implementation +OAI channel simulation is using the [config module](../../../../common/config/DOC/config.md) to get its parameters at init time. The [telnet server](../../../../common/utils/telnetsrv/DOC/telnetsrv.md) includes a set of commands which can be used to dynamically modify some channel model parameters. + +The relevant source files are: + +1. [`radio/rfsimulator/simulator.c`](../../../../radio/rfsimulator/simulator.c) +2. [`radio/rfsimulator/apply_channelmod.c`](../../../../radio/rfsimulator/apply_channelmod.c) +3. [`random_channel.c`](../random_channel.c) +4. [`sim.h`](../sim.h) + +All channel parameters are set depending on the model name via a call to: + +```bash +channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, + uint8_t nb_rx, + SCM_t channel_model, + double sampling_rate, + uint64_t center_freq, + double channel_bandwidth, + double DS_TDL, + double maxDoppler, + const corr_level_t corr_level, + double forgetting_factor, + int32_t channel_offset, + double path_loss_dB, + float noise_power_dB); +``` + +# Channel Model configuration file + +To define and use a channel model for uplink, the gNB configuration file needs to include a channel configuration file. To do this, add `@include "channelmod_rfsimu.conf"` at the end of the gNB configuration file, and place the channel configuration file in the same directory. The same shall be done for downlink by including the channel model configuration file at the end of UE configuration file (e.g. [`ci-scripts/conf_files/nrue.uicc.conf`](../../../../ci-scripts/conf_files/nrue.uicc.conf)). + +All channel simulation parameters are defined in the `channelmod` section. Most parameters are specific to a channel model and are only used by the rfsimulator. An example of the configuration file can be found here: + +* [`ci-scripts/conf_files/channelmod_rfsimu.conf`](../../../../ci-scripts/conf_files/channelmod_rfsimu.conf) + +e.g.: + +```bash +channelmod = { + max_chan = 10; + modellist = "modellist_rfsimu_1"; + modellist_rfsimu_1 = ( + { + model_name = "rfsimu_channel_enB0" + type = "AWGN"; + ploss_dB = 20; + noise_power_dB = -4; + forgetfact = 0; + offset = 0; + ds_tdl = 0; + }, + { + model_name = "rfsimu_channel_ue0" + type = "AWGN"; + ploss_dB = 20; + noise_power_dB = -2; + forgetfact = 0; + offset = 0; + ds_tdl = 0; + } + ); +}; +``` + +where `rfsimu_channel_ue0` will be activated on server side (i.e. eNB/gNB) for uplink and `rfsimu_channel_enB0` will be activated on client side (i.e. UE) for downlink. + +# Run OAI with a channel model + +When the `chanmod` option is enabled, the RF channel simulator with a channel modeling function is called. Add the following options to the command line to enable the channel model: +```bash +--rfsimulator.options chanmod +``` + +Example run of OAI RFSIM on the same machine with activation of the channel model via command line: +gNB: +```bash +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa --rfsimulator.options chanmod --telnetsrv +``` +UE: +```bash +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --rfsimulator.serveraddr 127.0.0.1 --uicc0.imsi 001010000000001 -O ../../../ci-scripts/conf_files/nrue.uicc.conf --rfsimulator.options chanmod +``` +where `@include "channelmod_rfsimu.conf"` has been added at the end of `ci-scripts/conf_files/channelmod_rfsimu.conf` which has been copied to `targets/PROJECTS/GENERIC-LTE-EPC/CONF/`. + +## Set channel simulation parameters via CL: + +Channel simulation parameters can also be specified on the command line by using the `--channelmod` option: + +### Global parameters +| CL option |type |default | description | +|:--- |:---- |:---- |:----| +|`modellist` |char string |`DefaultChannelList`|select and load the `modellist` from the config file.| +|`max_chan` |integer |10 |set the maximum number of channel models that can be defined in the system. Must be greater than the number of model definitions in the model list loaded at init time.| + +Example usage: +```bash +--channelmod.modellist modellist_rfsimu_2 +``` + +### Model lists +Several model lists can be defined in the OAI channel simulation configuration file. One, defined by the `modellist` parameter is loaded at init time. In the configuration file each model list item describes a channel model using a group of parameters: + +|Parameter name |Type |Default |Description | +|:--- |:---: |---: |:---- | +| `model_name` |char string | mandatory |name of the model, as used in the code to retrieve a model definition.| +| `type` |char string | `AWGN` |name of the channel modelization algorithm applied on RF signal. The list of available models is defined in [`sim.h`](../sim.h]| +| `ploss_dB` |real (float) | 0|total path loss of the channel including shadow fading, in dB | +| `noise_power_dB`|real (double)| -50|Noise power in dB, used to compute the SNR. Its value is proportional to the noise added.| +| `forgetfact` |real (double)| 0|Forgetting factor, allows for simple 1st order temporal variation. 0 means a new channel every call, 1 means keep channel constant all the time| +| `offset` |integer | 0|channel offset for accessing the input signal, in samples| +| `ds_tdl` |real double | 0|delay spread for TDL models| + +`ploss_dB` and `noise_power_dB` are applied to each IQ sample in order to scale the received signal. + +Example usage, set the offset for the selected model of the selected `modellist`: +```bash +--channelmod..[].offset +``` + +e.g. with the softmodem: +```bash +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa --rfsimulator.options chanmod --telnetsrv --channelmod.modellist modellist_rfsimu_2 --channelmod.modellist_rfsimu_2.[1].offset 120 +``` + +## Real time control and monitoring with telnet server +Add the `--telnetsrv` option to the command line. Then in a new shell, connect to the telnet server, e.g.: + +```bash +$ telnet 127.0.0.1 9090 +Trying 127.0.0.1... +Connected to 127.0.0.1. +Escape character is '^]' +``` +to enter the command and control of the simulator press any key: `softmodem_enb` will be displayed for the eNB/gNB and `softmodem_5Gue` will be displayed for the UE. Select a different port in order to use both servers on the same machine. + +The telnet server includes two modules to change the RF channel simulation in real-time: + +1. `channelmod` to dynamically modify the channel model configuration parameters +2. `rfsimu` to set a different channel model + +They both have their own help: +```bash +softmodem_enb> help +..................................... + module 4 = channelmod: + channelmod help + channelmod show + channelmod modify + channelmod show params + module 5 = rfsimu: + rfsimu setmodel + rfsimu setdistance + rfsimu getdistance + rfsimu vtime +softmodem_enb> channelmod help +channelmod commands can be used to display or modify channel models parameters +channelmod show predef: display predefined model algorithms available in oai +channelmod show current: display the currently used models in the running executable +channelmod modify : set the specified parameters in a current model to the given value + specifies the model, the show current model command can be used to list the current models indexes + can be one of "riceanf", "aoa", "randaoa", "ploss", "noise_power_dB", "offset", "forgetf" +softmodem_enb> +``` + +### channelmod module +Example usage: + +| Command |Description | +|:--- |:---- | +|`channelmod show current` |Monitor the current status | +|`channelmod show predef` |See the available channel modelss| +|`channelmod modify `|Set parameters specific to the channel model, e.g. pathloss, Ricean factor| + +Where `` in the `channelmod modify` command can be: + +|Parameter |Type |Range |Description | +|:--- |:---: |:---: |:---- | +|`riceanf` |double|0 to 1 |Ricean factor, of first tap w.r.t. other taps (where 0 means AWGN and 1 means Rayleigh channel)| +|`aoa` |double|0 to 2*Pi|Angle of arrival of wavefront (in radians). For Ricean channel only. This assumes that both RX and TX have linear antenna arrays with lambda/2 antenna spacing. Also it is assumed that the arrays are parallel to each other and that they are far enough apart so that we can safely assume plane wave propagation. | +|`randaoa` |bool |0 or 1 |randomized angle of arrival according to a uniform random distribution| +|`ploss` |double|- |same as ploss_dB in [Model lists](#model-lists)| +|`noise_power_dB`|int |- |same as noise_power_dB in [Model lists](#model-lists)| +|`forgetf` |double|0 to 1 |same as forgetfact in [Model lists](#model-lists)| + +Example usage: +```bash +channelmod modify 0 ploss 12 +channelmod modify 0 noise_power_dB 3 +``` + +### rfsimu module +This module can be used to set a different channel model, e.g. `rfsimu setmodel AWGN`. [oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) diff --git a/openair1/SIMULATION/TOOLS/DOC/devusage.md b/openair1/SIMULATION/TOOLS/DOC/devusage.md deleted file mode 100644 index 8fa6b3fe7a..0000000000 --- a/openair1/SIMULATION/TOOLS/DOC/devusage.md +++ /dev/null @@ -1,7 +0,0 @@ -### channel simulation developer usage - - -[Configuring the channel simulation](rtusage.md) - -[channel simulation main page](channel_simulation.md) -[oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) \ No newline at end of file diff --git a/openair1/SIMULATION/TOOLS/DOC/rtusage.md b/openair1/SIMULATION/TOOLS/DOC/rtusage.md deleted file mode 100644 index 5e1bd1b1da..0000000000 --- a/openair1/SIMULATION/TOOLS/DOC/rtusage.md +++ /dev/null @@ -1,69 +0,0 @@ -## configuring the channel simulation -Oai channel simulation is using the [config module](../../../config/config.md) to get its parameters at init time. The [telnet server](../../telnetsrv/DOC/telnetsrv.md) includes a set of commands which can be used to dynamically modify some channel model parameters - -All channel simulation parameters are defined in the `channelmod` section. Most parameters are specific to a channel model and are only used by the rfsimulator. - -### global parameters - -| name | type | default | description | -|:---:|:---:|:---:|:----| -| `max_chan` | integer | `25` | Maximum number of channel model that can be defined in the system. Must be greater than the number of model definitions in the model list loaded at init time. | -| `modellist` | character string | `DefaultChannelList` | Name of the channel models list to load at init time. | - -### Model lists - -Several model lists can be defined in the oai configuration file. One, defined by the `modellist` parameter is loaded at init time. In the configuration file each model list item describes a channel model using a group of parameters: - -| parameter name | type | default | description | -|:---:|:---:|:---:|:----| -| `model name` | character string | mandatory |name of the model, as used in the code to retrieve a model definition| -| `type` | | `AWGN` | name of the channel modelization algorithm applied on rf signal. The list of available model types can be listed via the [telnet server](../../telnetsrv/DOC/telnetsrv.md) or by entering an invalid type name | -| `ploss_dB` | real (float) | | path loss of the channel, in dB | -| `noise_power_dB` | real (double) | | noise of the channel in dB | -| `forgetfact` | real (double) | | | -| `offset` | integer | | | -| `ds_tdl` | real double | | | - -Channel simulation parameters can also be specified on the command line: - -```bash -./lte-softmodem -O ../../../ci-scripts/conf_files/enb.band7.tm1.50prb.usrpb210.conf --noS1 --rfsim --rfsimulator.options chanmod --rfsimulator.serveraddr enb --telnetsrv --channelmod.modellist modellist_rfsimu_2 --channelmod.modellist_rfsimu_2.[1].offset 120 -``` -### Using the telnet server to modify channel simulator parameters -The telnet server includes a `channelmod` command which can be used to dynamically modify some channel model parameters. This command is only available when channel simulation is enabled (via `rfsimulator.options chanmod` option when running the rfsimulator. `channelmod` command has its own help: - -``` -$ telnet 127.0.0.1 9090 -Trying 127.0.0.1... -Connected to 127.0.0.1. -Escape character is '^]'. - -softmodem_enb> help -..................................... - module 6 = channelmod: - channelmod help - channelmod show - channelmod modify - module 7 = rfsimu: - rfsimu setmodel -softmodem_enb> channelmod help -channelmod commands can be used to display or modify channel models parameters -channelmod show predef: display predefined model algorithms available in oai -channelmod show current: display the currently used models in the running executable -channelmod modify : set the specified parameters in a current model to the given value - specifies the model, the show current model command can be used to list the current models indexes - can be one of "riceanf", "aoa", "randaoa", "ploss", "noise_power_dB", "offset", "forgetf" -softmodem_enb> - -``` - - - - - - - -The [rfsimulator documentation](../../../../radio/rfsimulator/README.md ) has also some specific information when using the channel simulation via this tool. - -[channel simulation main page](channel_simulation.md) -[oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 4e28a4ce13..753302fc73 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -72,8 +72,6 @@ static telnetshell_cmddef_t channelmod_cmdarray[] = { static telnetshell_vardef_t channelmod_vardef[] = {{"", 0, 0, NULL}}; -static double snr_dB=25; -static double sinr_dB=0; static unsigned int max_chan; static channel_desc_t **defined_channels; static char *modellist_name; @@ -2261,14 +2259,6 @@ int modelid_fromstrtype(char *modeltype) { return modelid; } -double channelmod_get_snr_dB(void) { - return snr_dB; -} - -double channelmod_get_sinr_dB(void) { - return sinr_dB; -} - void init_channelmod(void) { paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC; int numparams = sizeofArray(channelmod_params); diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 366e9c6c6e..33c3f0f9ee 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -264,8 +264,6 @@ typedef enum { #define CHANNELMOD_HELP_MODELLIST " channel list name in config file describing the model type and its parameters\n" // clang-format off #define CHANNELMOD_PARAMS_DESC { \ - {"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, .dblptr=&snr_dB, .defdblval=25, TYPE_DOUBLE, 0}, \ - {"sinr_dB", NULL, 0, .dblptr=&sinr_dB, .defdblval=0 , TYPE_DOUBLE, 0}, \ {"max_chan", "Max number of runtime models", 0, .uptr=&max_chan, .defintval=10, TYPE_UINT, 0}, \ {CHANNELMOD_MODELLIST_PARANAME, CHANNELMOD_HELP_MODELLIST, 0, .strptr=&modellist_name, .defstrval="DefaultChannelList", TYPE_STRING, 0}, \ } @@ -302,18 +300,11 @@ typedef struct { double r_re_UL[NUMBER_OF_eNB_MAX][2][30720]; double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; int RU_output_mask[NUMBER_OF_UE_MAX]; - int UE_output_mask[NUMBER_OF_RU_MAX]; pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; - pthread_mutex_t subframe_mutex; - int subframe_ru_mask; - int subframe_UE_mask; openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; - openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; double ru_amp[NUMBER_OF_RU_MAX]; - pthread_t rfsim_thread; } sim_t; diff --git a/radio/rfsimulator/README.md b/radio/rfsimulator/README.md index 4b33860809..376255d282 100644 --- a/radio/rfsimulator/README.md +++ b/radio/rfsimulator/README.md @@ -12,6 +12,29 @@ As much as possible, it works like an RF board, but not in real-time: It can run faster than real-time if there is enough CPU, or slower (it is CPU-bound instead of real-time RF sampling-bound). +# Architecture + +High-level flowchart of the RF Simulator, including the channel simulation feature: + +```mermaid +flowchart TD + subgraph ide1 [RX] + RU[ru_thread]-->|FH southbound|FH[rx_rf] + FH-->read + read -->|apply channel model|rxAddInput + end + subgraph ide2 [RFSim initialization] + A[load_lib] -->|load RFSIM lib| B[device_init] + B[device_init] -.-> |set trx_read_func|read[rfsimulator_read] + rxAddInput --> FH + B -->cfg[rfsimulator_readconfig] + cfg -->|read RFSIM CL options|C{rfsimu_params} + C -->|chanmod|loadchannel[load_channellist] + C -->|saviq|E[saveIQfile] + loadchannel-->|new SCM|scm[new_channel_desc_scm] + end +``` + # Build ## From [build_oai](../../../doc/BUILD.md) script @@ -44,46 +67,19 @@ default the RF simulator device will try to connect to host 127.0.0.1, port have to pass `--rfsimulator.serveraddr server` on the command line, or specify the corresponding section in the configuration file. -The RF simulator is using the configuration module, and its parameters are defined in a specific section called "rfsimulator". +The RF simulator is using the configuration module, and its parameters are defined in a specific section called "rfsimulator". Add the following options to the command line in order to enable different RFSim features: -| parameter | usage | default | -|:---------------------|:------------------------------------------------------------------------------------------------------------------|----:| -| serveraddr | ip address to connect to, or `server` to behave as a tcp server | 127.0.0.1 | -| serverport | port number to connect to or to listen on (eNB, which behaves as a tcp server) | 4043 | -| options | list of comma separated run-time options, two are supported: `chanmod` to enable channel modeling and `saviq` to write transmitted iqs to a file | all options disabled | -| modelname | Name of the channel model to apply on received iqs when the `chanmod` option is enabled | AWGN | -| IQfile | Path to the file to be used to store iqs, when the `saviq` option is enabled | /tmp/rfsimulator.iqs | +| CL option | usage | default | +|:--------------------- |:-------------------------------------------------------------------------------|----: | +|`--rfsimulator.serveraddr `| ip address to connect to, or `server` to behave as a tcp server | 127.0.0.1 | +|`--rfsimulator.serverport `| port number to connect to or to listen on (eNB, which behaves as a tcp server) | 4043 | +| `--rfsimulator.options` | list of comma separated run-time options, two are supported: `chanmod`, `saviq`| all options disabled | +| `--rfsimulator.options saviq` | store IQs to a file for future replay | disabled | +|`--rfsimulator.options chanmod` | enable the channel model | disabled | +|`--rfsimulator.IQfile ` | path to a file to store the IQ samples to (only with `saviq`) | `/tmp/rfsimulator.iqs` | +|`--rfsimulator.wait_timeout` | wait timeout when no UE is connected | 1 | -## How to use the RF simulator options - -To define and use a channel model, the configuration file needs to include a -channel configuration file. To do this, add `@include "channelmod_rfsimu.conf"` -to the end of the configuration file, and place the channel configuration file -in the same directory. An example channel configuration file is -[`ci-scripts/conf_files/channelmod_rfsimu.conf`](../../ci-scripts/conf_files/channelmod_rfsimu.conf). - -Add the following options to the command line to enable the channel model and the IQ samples saving for future replay: -```bash ---rfsimulator.options chanmod,saviq -``` -or just: -```bash ---rfsimulator.options chanmod -``` -to enable the channel model. - -set the model with: -```bash ---rfsimulator.modelname AWGN -``` - -Example run: - -```bash -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --rfsimulator.options chanmod --rfsimulator.modelname AWGN -``` - -where `@include "channelmod_rfsimu.conf"` has been added at the end of the file, and `ci-scripts/conf_files/channelmod_rfsimu.conf` copied to `targets/PROJECTS/GENERIC-LTE-EPC/CONF/`. +Please refer to this document [`SIMULATION/TOOLS/DOC/channel_simulation.md`](../../openair1/SIMULATION/TOOLS/DOC/channel_simulation.md) for information about using the RFSimulator options to run the simulator with a channel model. ## 4G case @@ -133,9 +129,9 @@ sudo ./nr-uesoftmodem --rfsim --phy-test --rfsimulator.serveraddr ` should be the IP interface address of the remote host running the gNB executable, if the gNB and nrUE run on separate hosts, or be omitted if they are on the same host. -3. To enable the noS1 mode, `--noS1` option should be added to the command line, see again [RUNMODEM.md](../../doc/RUNMODEM.md). +3. To enable the noS1 mode, `--noS1` option should be added to the command line, see again [`RUNMODEM.md`](../../doc/RUNMODEM.md). 4. To operate the gNB/UE with a 5GC, start them using the `--sa` option. More information can be found [here](../../../doc/NR_SA_Tutorial_OAI_CN5G.md). ## Store and replay @@ -152,65 +148,9 @@ The file format is successive blocks of a header followed by the I/Q array. If y The format intends to be compatible with the OAI store/replay feature on USRP. -## Channel simulation +## How to use OAI RFSIM with a channel model -When the `chanmod` option is enabled, the RF channel simulator is called. - -In the current version all channel parameters are set depending on the model name via a call to: -```bash -new_channel_desc_scm(bridge->tx_num_channels, - bridge->rx_num_channels, - , - bridge->sample_rate, - bridge->tx_bw, - 0.0, // forgetting_factor - 0, // maybe used for TA - 0); // path_loss in dB -``` -Only the input noise can be changed on command line with the `-s` parameter. - -With path loss = 0 set `-s 5` to see a little noise. `-s` is a shortcut to `channelmod.s`. It is expected to enhance the channel modelization flexibility by the addition of more parameters in the channelmod section. - -Example to add a very small noise: -```bash --s 30 -``` -to add a lot of noise: -```bash --s 5 -``` - -Example run commands: -```bash -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --rfsimulator.options chanmod --rfsimulator.modelname AWGN - -``` -# Real time control and monitoring - -Add the `--telnetsrv` option to the command line. Then in a new shell, connect to the telnet server, example: -```bash -telnet 127.0.0.1 9090 -``` -once connected it is possible to monitor the current status: -```bash -channelmod show current -``` - -see the available channel models: -```bash -channelmod show predef -``` - -or modify the channel model, for example setting a new model: -```bash -rfsimu setmodel AWGN -``` -setting the pathloss, etc...: -```bash -channelmod modify -channelmod modify 0 ploss 15 -``` -where `` can be one of `riceanf`, `aoa`, `randaoa`, `ploss`, `offset`, `forgetf`. +Please refer to this document [`channel_simulation.md`](../../openair1/SIMULATION/TOOLS/DOC/channel_simulation.md) to get familiar with channel simulation in RFSIM and to see the list of commands for real-time usage with telnet. # Caveats diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c index 0196f8b1b9..0bfc26b10b 100644 --- a/radio/rfsimulator/simulator.c +++ b/radio/rfsimulator/simulator.c @@ -206,17 +206,6 @@ static int allocCirBuf(rfsimulator_state_t *bridge, int sock) if ( bridge->channelmod > 0) { // create channel simulation model for this mode reception - // snr_dB is pure global, coming from configuration paramter "-s" - // Fixme: referenceSignalPower should come from the right place - // but the datamodel is inconsistant - // legacy: RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower - // (must not come from ru[]->frame_parms as it doesn't belong to ru !!!) - // Legacy sets it as: - // ptr->channel_model->path_loss_dB = -132.24 + snr_dB - RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower; - // we use directly the paramter passed on the command line ("-s") - // the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value) - // Legacy changes directlty the variable channel_model->path_loss_dB place to place - // while calling new_channel_desc_scm() with path losses = 0 static bool init_done=false; if (!init_done) {