From 37421c3f929ff4cfb659f715d10977006975686e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sat, 13 Apr 2024 10:45:35 +0200 Subject: [PATCH 01/26] BuildUnitTests: need to use ran-base:ci-temp if changes in ran-base Use correct baseTag for Unit Tests build in execution: - if build_helper or othe files changed, which would trigger rebuild of ran-base, use the corresponding ci-temp tag - use that tag consistently afterwards --- ci-scripts/cls_containerize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 7b2813325f..75a421495e 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -668,7 +668,7 @@ class Containerize(): cmd.run(f'git diff HEAD..origin/develop -- cmake_targets/build_oai cmake_targets/tools/build_helper docker/Dockerfile.base{self.dockerfileprefix} | grep --colour=never -i INDEX') result = re.search('index', cmd.getBefore()) if result is not None: - baseTag = 'develop' + baseTag = 'ci-temp' ret = cmd.run(f"docker image inspect --format=\'Size = {{{{.Size}}}} bytes\' {baseImage}:{baseTag}") if ret.returncode != 0: logging.error(f'No {baseImage} image present, cannot build tests') @@ -688,8 +688,8 @@ class Containerize(): HTML.CreateHtmlTestRowQueue("Build unit tests", 'OK', [dockerfile]) # it worked, build and execute tests, and close connection - ret = cmd.run(f'docker run -a STDOUT --rm ran-unittests:develop ctest --output-on-failure --no-label-summary -j$(nproc)') - cmd.run(f'docker rmi ran-unittests:develop') + ret = cmd.run(f'docker run -a STDOUT --rm ran-unittests:{baseTag} ctest --output-on-failure --no-label-summary -j$(nproc)') + cmd.run(f'docker rmi ran-unittests:{baseTag}') build_log_name = f'build_log_{self.testCase_id}' CopyLogsToExecutor(cmd, lSourcePath, build_log_name) cmd.close() From bfd519953b835480cf9247dcbe7a79efcb8790c5 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Mar 2024 09:06:03 +0100 Subject: [PATCH 02/26] ITTI: lower 'Starting itti queue' message to debug --- common/utils/ocp_itti/intertask_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 56781f79a4..9d22e06d7d 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -343,7 +343,7 @@ typedef struct timer_elm_s { tasks[newQueue]= new task_list_t; tasks[newQueue]->task_parms = {0}; pthread_mutex_unlock (&lock_nb_queues); - LOG_I(ITTI,"Starting itti queue: %s as task %d\n", taskInfo->name, newQueue); + LOG_D(ITTI, "Starting itti queue: %s as task %d\n", taskInfo->name, newQueue); pthread_mutex_init(&tasks[newQueue]->queue_cond_lock, NULL); memcpy(&tasks[newQueue]->admin, taskInfo, sizeof(task_info_t)); AssertFatal( ( tasks[newQueue]->epoll_fd = epoll_create1(0) ) >=0, ""); From 55728a98c1fc169b420df91b1940a02a220534e0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Mar 2024 15:03:37 +0100 Subject: [PATCH 03/26] RFsim: demote log level, remove useless log message --- radio/rfsimulator/simulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c index 6349742fb8..f4dfead811 100644 --- a/radio/rfsimulator/simulator.c +++ b/radio/rfsimulator/simulator.c @@ -868,7 +868,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest if (first_sock == MAX_FD_RFSIMU) { // no connected device (we are eNB, no UE is connected) if ( t->nextRxTstamp == 0) - LOG_W(HW, "No connected device, generating void samples...\n"); + LOG_I(HW, "No connected device, generating void samples...\n"); if (!flushInput(t, t->wait_timeout, nsamps)) { for (int x=0; x < nbAnt; x++) @@ -1019,7 +1019,6 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { rfsimulator->sample_rate=openair0_cfg->sample_rate; rfsimulator->tx_bw=openair0_cfg->tx_bw; rfsimulator_readconfig(rfsimulator); - LOG_W(HW, "sample_rate %f\n", rfsimulator->sample_rate); if (rfsimulator->prop_delay_ms > 0.0) rfsimulator->chan_offset = rfsimulator->sample_rate * rfsimulator->prop_delay_ms / 1000; if (rfsimulator->chan_offset != 0) { From 006b68fa3ffca0b2cd96b268204294a7bcf0f28d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Mar 2024 15:18:52 +0100 Subject: [PATCH 04/26] NR L1: demote log to info --- openair1/PHY/INIT/nr_parms.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 2e292e4705..22366bb070 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -213,8 +213,13 @@ void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, int N_RB_DL) fp->first_carrier_offset = 0; fp->nb_prefix_samples = fp->ofdm_symbol_size / 128 * 9; fp->nb_prefix_samples0 = fp->ofdm_symbol_size / 128 * (9 + (1 << mu)); - LOG_W(PHY,"Init: N_RB_DL %d, first_carrier_offset %d, nb_prefix_samples %d,nb_prefix_samples0 %d, ofdm_symbol_size %d\n", - N_RB_DL,fp->first_carrier_offset,fp->nb_prefix_samples,fp->nb_prefix_samples0, fp->ofdm_symbol_size); + LOG_I(PHY, + "Init: N_RB_DL %d, first_carrier_offset %d, nb_prefix_samples %d,nb_prefix_samples0 %d, ofdm_symbol_size %d\n", + N_RB_DL, + fp->first_carrier_offset, + fp->nb_prefix_samples, + fp->nb_prefix_samples0, + fp->ofdm_symbol_size); } uint32_t get_samples_per_slot(int slot, const NR_DL_FRAME_PARMS *fp) From b9fd5a6f7505521f029ebbee0e5036d8dc9adc95 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Mar 2024 15:18:43 +0100 Subject: [PATCH 05/26] config module: make it less verbose --- common/config/config_load_configmodule.c | 8 +++++--- common/config/libconfig/config_libconfig.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 76808cf59f..5d6fb5de1f 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -208,9 +208,11 @@ int config_cmdlineonly_get(configmodule_interface_t *cfg, paramdef_t *cfgoptions } } /* for loop on options */ - printf("[CONFIG] %s: %i/%i parameters successfully set \n", - ((prefix == NULL)?"(root)":prefix), - numdefvals,numoptions ); + printf_params(cfg, + "[CONFIG] %s: %i/%i parameters successfully set \n", + prefix == NULL ? "(root)" : prefix, + numdefvals, + numoptions); if (fatalerror == 1) { fprintf(stderr,"[CONFIG] fatal errors found when assigning %s parameters \n", diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index b0c3c2c6cf..64737e4067 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -70,7 +70,7 @@ int read_strlist(configmodule_interface_t *cfg, paramdef_t *cfgoptions, config_s str=config_setting_get_string_elem(setting,i); if (str==NULL) { - printf("[LIBCONFIG] %s%i not found in config file\n", cfgoptions->optname,i); + printf_params(cfg, "[LIBCONFIG] %s%i not found in config file\n", cfgoptions->optname,i); } else { snprintf(cfgoptions->strlistptr[i], DEFAULT_EXTRA_SZ, "%s",str); st++; @@ -481,9 +481,12 @@ int config_libconfig_get(configmodule_interface_t *cfg, paramdef_t *cfgoptions, } } /* for loop on options */ - printf("[LIBCONFIG] %s: %i/%i parameters successfully set, (%i to default value)\n", - ((prefix == NULL)?"(root)":prefix), - status,numoptions,numdefvals ); + printf_params(cfg, + "[LIBCONFIG] %s: %i/%i parameters successfully set, (%i to default value)\n", + prefix == NULL ? "(root)" : prefix, + status, + numoptions, + numdefvals); if (fatalerror == 1) { fprintf(stderr,"[LIBCONFIG] fatal errors found when processing %s \n", libconfig_privdata.configfile ); @@ -517,8 +520,7 @@ int config_libconfig_getlist(configmodule_interface_t *cfg, status = ParamList->numelt = config_setting_length(setting); printf_params(cfg, "[LIBCONFIG] %i %s in config file %s \n", ParamList->numelt, listpath, libconfig_privdata.configfile); } else { - printf("[LIBCONFIG] list %s not found in config file %s \n", - listpath,libconfig_privdata.configfile ); + printf_params(cfg, "[LIBCONFIG] list %s not found in config file %s \n", listpath, libconfig_privdata.configfile); ParamList->numelt= 0; status = -1; } From 7a8b2fe4a9118829cd4bf815052586c640c701c8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sat, 13 Apr 2024 12:23:09 +0200 Subject: [PATCH 06/26] config module: print clear error when config file does not exist Print a clear error if a config file does not exist (unclear previously, when the user would get a confusing, unspecific, "file I/O error" on line 0) I tried to free the memory that had been allocated at that point, and verified that using the address sanitizer. Nevertheless, the function does too much, and is too complicated for refactoring. --- common/config/config_load_configmodule.c | 15 +++++++++++++-- common/config/libconfig/config_libconfig.c | 6 ++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 5d6fb5de1f..411e737976 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -343,9 +343,20 @@ configmodule_interface_t *load_configmodule(int argc, atoken = strtok_r(NULL,":",&strtokctx); } - printf("[CONFIG] get parameters from %s ", cfgmode); for (i = 0; i < cfgptr->num_cfgP; i++) { - printf("%s ", cfgptr->cfgP[i]); + /* check if that file actually exists */ + if (access(cfgptr->cfgP[i], F_OK) != 0) { + fprintf(stderr, "error: file %s does not exist\n", cfgptr->cfgP[i]); + for (int j = 0; j < cfgptr->num_cfgP; ++j) + free(cfgptr->cfgP[j]); + free(modeparams); + free(cfgptr->cfgmode); + free(cfgptr->argv_info); + free(cfgptr); + if (cfgmode != NULL) + free(cfgmode); + return NULL; + } } if (cfgptr->rtflags & CONFIG_PRINTPARAMS) { diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index 64737e4067..a41a4dab33 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -576,8 +576,10 @@ int config_libconfig_init(configmodule_interface_t *cfg) config_set_auto_convert (&(libconfig_privdata.cfg), CONFIG_TRUE); /* Read the file. If there is an error, report it and exit. */ if( config_read_file(&(libconfig_privdata.cfg), libconfig_privdata.configfile) == CONFIG_FALSE) { - fprintf(stderr,"[LIBCONFIG] %s %d file %s - line %d: %s\n",__FILE__, __LINE__, - libconfig_privdata.configfile, config_error_line(&(libconfig_privdata.cfg)), + fprintf(stderr, + "[LIBCONFIG] file %s - line %d: %s\n", + libconfig_privdata.configfile, + config_error_line(&(libconfig_privdata.cfg)), config_error_text(&(libconfig_privdata.cfg))); config_destroy(&(libconfig_privdata.cfg)); printf( "\n"); From a25b209e7f98f1bf8d0aaf9d0c2cf5ccb365f4ab Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 11 Mar 2024 19:10:30 +0100 Subject: [PATCH 07/26] Remove Check if fedora and inside kernel It's completely unclear what this is supposed to do. --- common/utils/system.c | 21 --------------------- common/utils/system.h | 3 --- executables/lte-ue.c | 5 ----- executables/nr-uesoftmodem.c | 4 ---- 4 files changed, 33 deletions(-) diff --git a/common/utils/system.c b/common/utils/system.c index 7cdeb5a21d..d8570fe14e 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -95,17 +95,6 @@ static void read_pipe(int p, char *b, int size) { size -= ret; } } -int checkIfFedoraDistribution(void) { - return !system("grep -iq 'ID_LIKE.*fedora' /etc/os-release "); -} - -int checkIfGenericKernelOnFedora(void) { - return system("uname -a | grep -q rt"); -} - -int checkIfInsideContainer(void) { - return !system("egrep -q 'libpod|podman|kubepods' /proc/self/cgroup"); -} /********************************************************************/ /* background process */ @@ -234,11 +223,6 @@ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, LOG_I(UTIL,"Creating thread %s with affinity %d and priority %d\n",name,affinity,priority); - if (checkIfFedoraDistribution()) - if (checkIfGenericKernelOnFedora()) - if (checkIfInsideContainer()) - settingPriority = 0; - if (settingPriority) { ret=pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); AssertFatal(ret == 0, "Error in pthread_attr_setinheritsched(): ret: %d, errno: %d\n", ret, errno); @@ -314,11 +298,6 @@ void thread_top_init(char *thread_name, } } - if (checkIfFedoraDistribution()) - if (checkIfGenericKernelOnFedora()) - if (checkIfInsideContainer()) - settingPriority = 0; - if (settingPriority) { memset(&sparam, 0, sizeof(sparam)); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); diff --git a/common/utils/system.h b/common/utils/system.h index c25c2a6f1f..1b7c0c570f 100644 --- a/common/utils/system.h +++ b/common/utils/system.h @@ -61,9 +61,6 @@ void thread_top_init(char *thread_name, * Functions to check system at runtime. ****************************************************/ -int checkIfFedoraDistribution(void); -int checkIfGenericKernelOnFedora(void); -int checkIfInsideContainer(void); int rt_sleep_ns (uint64_t x); #ifdef __cplusplus } diff --git a/executables/lte-ue.c b/executables/lte-ue.c index 5176533b8e..df5c47c3ca 100644 --- a/executables/lte-ue.c +++ b/executables/lte-ue.c @@ -195,11 +195,6 @@ void init_thread(int sched_runtime, char *name) { int settingPriority = 1; - if (checkIfFedoraDistribution()) - if (checkIfGenericKernelOnFedora()) - if (checkIfInsideContainer()) - settingPriority = 0; - if (settingPriority) { if (CPU_COUNT(cpuset) > 0) AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), ""); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 6199abf070..0676dd2e18 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -457,10 +457,6 @@ ldpc_interface_t ldpc_interface = {0}, ldpc_interface_offload = {0}; int main(int argc, char **argv) { int set_exe_prio = 1; - if (checkIfFedoraDistribution()) - if (checkIfGenericKernelOnFedora()) - if (checkIfInsideContainer()) - set_exe_prio = 0; if (set_exe_prio) set_priority(79); From 6b37d183cefdd0a8e72e022c792c948b96e49659 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 11 Mar 2024 19:13:42 +0100 Subject: [PATCH 08/26] Remove set_latency_target(), add lock_memory_to_ram() set_latency_target() attempts to set keep "low latency" by - writing a specific latency to /dev/cpu_dma_latency - setting manually the minimum CPU processor frequency to be the maximum There is no functionality to undo this after stopping the softmodem(s), and most users are probably not even aware that OAI does this. It is generally preferable to set this beforehand using a governor or by disabling sleep states (as outlined in the tutorial, and in a follow-up commit in the performance tuning docs). The previous mlockall() call, to lock memory to RAM, is retained in a new function. There were additional mlockall() calls, which have been replaced with lock_memory_to_ram(), where necessary. --- common/utils/system.c | 39 +++++---------------------- common/utils/system.h | 2 +- executables/lte-softmodem.c | 3 +-- executables/lte-uesoftmodem.c | 3 +-- executables/main_ru.c | 4 +-- executables/nr-softmodem.c | 3 +-- executables/nr-uesoftmodem.c | 2 +- openair1/PHY/TOOLS/calibration_test.c | 3 +-- 8 files changed, 14 insertions(+), 45 deletions(-) diff --git a/common/utils/system.c b/common/utils/system.c index d8570fe14e..4e332a4ee4 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -326,37 +326,10 @@ void thread_top_init(char *thread_name, } } - -// Block CPU C-states deep sleep -void set_latency_target(void) { - int ret; - static int latency_target_fd=-1; - uint32_t latency_target_value=2; // in microseconds - if (latency_target_fd == -1) { - if ( (latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR)) != -1 ) { - ret = write(latency_target_fd, &latency_target_value, sizeof(latency_target_value)); - if (ret == 0) { - printf("# error setting cpu_dma_latency to %u!: %s\n", latency_target_value, strerror(errno)); - close(latency_target_fd); - latency_target_fd=-1; - return; - } - } - } - if (latency_target_fd != -1) - LOG_I(HW,"# /dev/cpu_dma_latency set to %u us\n", latency_target_value); - else - LOG_E(HW,"Can't set /dev/cpu_dma_latency to %u us\n", latency_target_value); - - // Set CPU frequency to it's maximum - int system_ret = system("for d in /sys/devices/system/cpu/cpu[0-9]*; do cat $d/cpufreq/cpuinfo_max_freq > $d/cpufreq/scaling_min_freq; done"); - if (system_ret == -1) { - LOG_E(HW, "Can't set cpu frequency: [%d] %s\n", errno, strerror(errno)); - return; - } - if (!((WIFEXITED(system_ret)) && (WEXITSTATUS(system_ret) == 0))) { - LOG_E(HW, "Can't set cpu frequency\n"); - } - mlockall(MCL_CURRENT | MCL_FUTURE); - +/* \brief lock memory to RAM to avoid delays */ +void lock_memory_to_ram(void) +{ + int rc = mlockall(MCL_CURRENT | MCL_FUTURE); + if (rc != 0) + LOG_W(UTIL, "mlockall() failed: %d, %s\n", errno, strerror(errno)); } diff --git a/common/utils/system.h b/common/utils/system.h index 1b7c0c570f..1c36f29ea3 100644 --- a/common/utils/system.h +++ b/common/utils/system.h @@ -42,7 +42,7 @@ int background_system(char *command); void start_background_system(void); -void set_latency_target(void); +void lock_memory_to_ram(void); void threadCreate(pthread_t *t, void *(*func)(void *), void *param, char *name, int affinity, int priority); diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index 9e1adf1cbe..615f6106fe 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -448,7 +448,7 @@ int main ( int argc, char **argv ) mode = normal_txrx; logInit(); - set_latency_target(); + lock_memory_to_ram(); printf("Reading in command-line options\n"); get_options(uniqCfg); @@ -518,7 +518,6 @@ int main ( int argc, char **argv ) // init UE_PF_PO and mutex lock pthread_mutex_init(&ue_pf_po_mutex, NULL); memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs); - mlockall(MCL_CURRENT | MCL_FUTURE); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index a8f6d01227..47f6c884c4 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -530,7 +530,7 @@ int main( int argc, char **argv ) { mode = normal_txrx; memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); logInit(); - set_latency_target(); + lock_memory_to_ram(); printf("Reading in command-line options\n"); for (int i=0; i Date: Thu, 14 Mar 2024 17:04:54 +0100 Subject: [PATCH 09/26] thread pool: don't print core, threadCreate() does that already --- common/utils/threadPool/thread-pool.c | 1 - 1 file changed, 1 deletion(-) diff --git a/common/utils/threadPool/thread-pool.c b/common/utils/threadPool/thread-pool.c index 84347a88a1..6410f7f4b9 100644 --- a/common/utils/threadPool/thread-pool.c +++ b/common/utils/threadPool/thread-pool.c @@ -141,7 +141,6 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name ptr=pool->allthreads; pool->allthreads=(struct one_thread *)malloc(sizeof(struct one_thread)); pool->allthreads->next=ptr; - printf("create a thread for core %d\n", atoi(curptr)); pool->allthreads->coreID=atoi(curptr); pool->allthreads->id=pool->nbThreads; pool->allthreads->pool=pool; From 6a12784872cd49e453f6fc52a6bb7d105acead91 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Mar 2024 15:01:46 +0100 Subject: [PATCH 10/26] RFsim: don't shell out to improve kernel socket buffer sizes, teach the user instead A later commit in this series adds performance tuning tips, which includes the call made in RFsim until this commit. --- radio/rfsimulator/README.md | 15 ++++++++++++++ radio/rfsimulator/simulator.c | 39 +---------------------------------- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/radio/rfsimulator/README.md b/radio/rfsimulator/README.md index 679b922d2d..ea2188d4df 100644 --- a/radio/rfsimulator/README.md +++ b/radio/rfsimulator/README.md @@ -174,3 +174,18 @@ To successfully establish a connection with such a GEO satellite channel, both g # Caveats There are issues in power control: txgain/rxgain setting is not supported. + +# How to improve performance + +Most importantly, note that the RFsimulator is not designed to be as performant +as possible, nor is it designed to run close to real-time. It might run faster +or slower than realtime, depending on CPU, and by design, as this allows to +stop the entire system for inspection, e.g., using a debugger. + +In order to improve performance, you can modify the radio parameters of the gNB +to reduce the amount of transported samples: + +- Use option `-E` for three-quarter sampling (also to be done on the UE-side!) +- Prefer smaller cell bandwidths + +A possible, unimplemented optimization would be to compress samples. diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c index f4dfead811..e524097898 100644 --- a/radio/rfsimulator/simulator.c +++ b/radio/rfsimulator/simulator.c @@ -86,8 +86,7 @@ // // #define MAX_FD_RFSIMU FD_SETSIZE #define MAX_FD_RFSIMU 250 -#define SYSCTL_MEM_VALUE 134217728 // Kernel network buffer size -#define SEND_BUFF_SIZE SYSCTL_MEM_VALUE // Socket buffer size +#define SEND_BUFF_SIZE 100000000 // Socket buffer size // Simulator role typedef enum { SIMU_ROLE_SERVER = 1, SIMU_ROLE_CLIENT } simuRole; @@ -540,40 +539,6 @@ static int rfsimu_vtime_cmd(char *buff, int debug, telnet_printfunc_t prnt, void return CMDSTATUS_FOUND; } -static void customNetForPerf() -{ - int res = 0; - char sysctlmem[256]; - memset(sysctlmem, 0, 256); - sprintf(sysctlmem, "/sbin/sysctl -n -e -q -w net.core.rmem_default=%d", SYSCTL_MEM_VALUE); - LOG_W(HW, "running command \"%s\" to increase RFsim performance\n", sysctlmem); - res = system(sysctlmem); - if (res != 0) { - LOG_W(HW, "Cannot set net.core.rmem_default to %d\n", SYSCTL_MEM_VALUE); - } - memset(sysctlmem, 0, 256); - sprintf(sysctlmem, "/sbin/sysctl -n -e -q -w net.core.rmem_max=%d", SYSCTL_MEM_VALUE); - LOG_W(HW, "running command \"%s\" to increase RFsim performance\n", sysctlmem); - res = system(sysctlmem); - if (res != 0) { - LOG_W(HW, "Cannot set net.core.rmem_max to %d\n", SYSCTL_MEM_VALUE); - } - memset(sysctlmem, 0, 256); - sprintf(sysctlmem, "/sbin/sysctl -n -e -q -w net.core.wmem_default=%d", SYSCTL_MEM_VALUE); - LOG_W(HW, "running command \"%s\" to increase RFsim performance\n", sysctlmem); - res = system(sysctlmem); - if (res != 0) { - LOG_W(HW, "Cannot set net.core.wmem_default to %d\n", SYSCTL_MEM_VALUE); - } - memset(sysctlmem, 0, 256); - sprintf(sysctlmem, "/sbin/sysctl -n -e -q -w net.core.wmem_max=%d", SYSCTL_MEM_VALUE); - LOG_W(HW, "running command \"%s\" to increase RFsim performance\n", sysctlmem); - res = system(sysctlmem); - if (res != 0) { - LOG_W(HW, "Cannot set net.core.wmem_max to %d\n", SYSCTL_MEM_VALUE); - } -} - static int startServer(openair0_device *device) { rfsimulator_state_t *t = (rfsimulator_state_t *) device->priv; t->role = SIMU_ROLE_SERVER; @@ -588,7 +553,6 @@ static int startServer(openair0_device *device) { return -1; } struct sockaddr_in addr = {.sin_family = AF_INET, .sin_port = htons(t->port), .sin_addr = {.s_addr = INADDR_ANY}}; - customNetForPerf(); int rc = bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr)); if (rc < 0) { LOG_E(HW, "bind() failed, errno(%d)\n", errno); @@ -620,7 +584,6 @@ static int startClient(openair0_device *device) { addr.sin_addr.s_addr = inet_addr(t->ip); bool connected=false; - customNetForPerf(); while(!connected) { LOG_I(HW, "Trying to connect to %s:%d\n", t->ip, t->port); From 66bf27bce9625f65ed35e2eae7691a6ae2ab2327 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Mar 2024 14:52:52 +0100 Subject: [PATCH 11/26] threadCreate(): check for and handle missing SYS_NICE SYS_NICE is a capability that allows a process to set thread affinity and priority, among other things (see capabilities(7) for more info). In this commit, add a function that allows to determine if the process has this capability, and try to change the thread affinity and priority, if requested. If the capability does not exist, the function will simply not attempt to change the corresponding thread attributes. To determine if the process has SYS_NICE, libcap can be used. However, it might not be installed by default. To avoid requiring another dependency, if we detect that libcap is not present, use a workaround by try to set a real-time scheduling policy; if it's present, or can be changed, we assume that the process has SYS_NICE (and clean up, if relevant). Simplify reading of capabilities --- CMakeLists.txt | 6 +++ common/utils/system.c | 80 +++++++++++++++++++++++++++----------- common/utils/system.h | 2 + executables/nr-softmodem.c | 4 ++ 4 files changed, 69 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28b317fedb..136b2ebd62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -659,6 +659,12 @@ add_library(UTIL ${OPENAIR_DIR}/common/utils/time_meas.c ${OPENAIR_DIR}/common/utils/time_stat.c ) +pkg_check_modules(cap libcap) +if (cap_FOUND) + # see system.c for more info + target_link_libraries(UTIL PRIVATE cap) + target_compile_definitions(UTIL PRIVATE HAVE_LIB_CAP) +endif() target_link_libraries(UTIL PUBLIC ${T_LIB} pthread) set(SECURITY_SRC diff --git a/common/utils/system.c b/common/utils/system.c index 4e332a4ee4..270c3ae321 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -32,6 +32,7 @@ #include "system.h" #include #include +#include #include #include #include @@ -214,38 +215,71 @@ int rt_sleep_ns (uint64_t x) return clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &myTime, NULL); } -void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){ - pthread_attr_t attr; +#ifdef HAVE_LIB_CAP +#include +/* \brief reports if the current thread has capability CAP_SYS_NICE, i.e. */ +bool has_cap_sys_nice(void) +{ + /* get capabilities of calling PID */ + cap_t cap = cap_get_pid(0); + cap_flag_value_t val; + /* check to what CAP_SYS_NICE is currently ("effective capability") set */ + int ret = cap_get_flag(cap, CAP_SYS_NICE, CAP_EFFECTIVE, &val); + AssertFatal(ret == 0, "Error in cap_get_flag(): ret %d errno %d\n", ret, errno); + cap_free(cap); + /* return true if CAP_SYS_NICE is currently set */ + return val == CAP_SET; +} +#else +/* libcap has not been detected on this system. We do not need to require it -- + * we can try to read directly via a syscall. This is discouraged, though; from + * the man page: "The portable interfaces are cap_set_proc(3) and + * cap_get_proc(3); if possible, you should use those interfaces in + * applications". */ +#include /* Definition of SYS_* constants */ +#include /* capabilities used below */ +/* \brief reports if the current thread has capability CAP_SYS_NICE, i.e. */ +bool has_cap_sys_nice(void) +{ + struct __user_cap_header_struct hdr = {.version = _LINUX_CAPABILITY_VERSION_3}; + struct __user_cap_data_struct cap[2]; + if (syscall(SYS_capget, &hdr, cap) == -1) + return false; + return (cap[0].effective & (1 << CAP_SYS_NICE)) != 0; +} +#endif + +void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority) +{ int ret; - int settingPriority = 1; + bool set_prio = has_cap_sys_nice(); + + pthread_attr_t attr; ret=pthread_attr_init(&attr); AssertFatal(ret == 0, "Error in pthread_attr_init(): ret: %d, errno: %d\n", ret, errno); - LOG_I(UTIL,"Creating thread %s with affinity %d and priority %d\n",name,affinity,priority); - - if (settingPriority) { - ret=pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + if (set_prio) { + ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); AssertFatal(ret == 0, "Error in pthread_attr_setinheritsched(): ret: %d, errno: %d\n", ret, errno); - ret=pthread_attr_setschedpolicy(&attr, SCHED_OAI); + ret = pthread_attr_setschedpolicy(&attr, SCHED_OAI); AssertFatal(ret == 0, "Error in pthread_attr_setschedpolicy(): ret: %d, errno: %d\n", ret, errno); - if(prioritysched_get_priority_max(SCHED_OAI)) { - LOG_E(UTIL,"Prio not possible: %d, min is %d, max: %d, forced in the range\n", - priority, - sched_get_priority_min(SCHED_OAI), - sched_get_priority_max(SCHED_OAI)); - if(prioritysched_get_priority_max(SCHED_OAI)) - priority=sched_get_priority_max(SCHED_OAI); - } - AssertFatal(priority<=sched_get_priority_max(SCHED_OAI),""); - struct sched_param sparam={0}; + AssertFatal(priority >= sched_get_priority_min(SCHED_OAI) && priority <= sched_get_priority_max(SCHED_OAI), + "Scheduling priority %d not possible: must be within [%d, %d]\n", + priority, + sched_get_priority_min(SCHED_OAI), + sched_get_priority_max(SCHED_OAI)); + AssertFatal(priority <= sched_get_priority_max(SCHED_OAI), ""); + struct sched_param sparam = {0}; sparam.sched_priority = priority; - ret=pthread_attr_setschedparam(&attr, &sparam); + ret = pthread_attr_setschedparam(&attr, &sparam); AssertFatal(ret == 0, "Error in pthread_attr_setschedparam(): ret: %d errno: %d\n", ret, errno); + LOG_I(UTIL, "%s() for %s: creating thread with affinity %x, priority %d\n", __func__, name, affinity, priority); + } else { + affinity = -1; + priority = -1; + LOG_I(UTIL, "%s() for %s: creating thread (no affinity, default priority)\n", __func__, name); } - - LOG_I(UTIL,"threadCreate for %s, affinity %x, priority %d\n",name,affinity,priority); + ret=pthread_create(t, &attr, func, param); AssertFatal(ret == 0, "Error in pthread_create(): ret: %d, errno: %d\n", ret, errno); diff --git a/common/utils/system.h b/common/utils/system.h index 1c36f29ea3..2a4b920357 100644 --- a/common/utils/system.h +++ b/common/utils/system.h @@ -23,6 +23,7 @@ #define _SYSTEM_H_OAI_ #include #include +#include #ifdef __cplusplus extern "C" { #endif @@ -44,6 +45,7 @@ void start_background_system(void); void lock_memory_to_ram(void); +bool has_cap_sys_nice(void); void threadCreate(pthread_t *t, void *(*func)(void *), void *param, char *name, int affinity, int priority); #define SCHED_OAI SCHED_RR diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 6bc0b4e621..d880090d99 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -633,6 +633,10 @@ int main( int argc, char **argv ) { exit(-1); } + if (!has_cap_sys_nice()) + LOG_W(UTIL, + "no SYS_NICE capability: cannot set thread priority and affinity, consider running with sudo for optimum performance\n"); + if (get_softmodem_params()->do_ra) AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); From 37f3f0b6a4567b0495a06f6d47073c3805a05b22 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sat, 13 Apr 2024 09:05:44 +0200 Subject: [PATCH 12/26] nr-uesoftmodem: don't set priority, check for SYS_NICE The main thread of nr-uesoftmodem (executing main()) is mostly working; it is thus not necessary to set high priority. Instead, the threads created with threadCreate() will receive higher priority, if possible (as determined by the availability of SYS_NICE capability). To inform if SYS_NICE is not present, print a warning in main(). --- executables/nr-uesoftmodem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 15fb1ae838..e588e2f75b 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -456,10 +456,6 @@ ldpc_interface_t ldpc_interface = {0}, ldpc_interface_offload = {0}; int main(int argc, char **argv) { - int set_exe_prio = 1; - if (set_exe_prio) - set_priority(79); - start_background_system(); if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) { @@ -484,6 +480,10 @@ int main(int argc, char **argv) //randominit (0); set_taus_seed (0); + if (!has_cap_sys_nice()) + LOG_W(UTIL, + "no SYS_NICE capability: cannot set thread priority and affinity, consider running with sudo for optimum performance\n"); + cpuf=get_cpu_freq_GHz(); itti_init(TASK_MAX, tasks_info); From 5ae7d6685aefff897eec8c98a4e7af9241c7e902 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Apr 2024 08:57:12 +0200 Subject: [PATCH 13/26] Aerial: use threadCreate() to create P7 thread Use common threadCreate() function to create P7 thread with high(er) priority. Remove old calls to set_priority(), as this is already done with threadCreate(). --- nfapi/oai_integration/aerial/fapi_vnf_p5.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nfapi/oai_integration/aerial/fapi_vnf_p5.c b/nfapi/oai_integration/aerial/fapi_vnf_p5.c index e3af58537f..472487ae2f 100644 --- a/nfapi/oai_integration/aerial/fapi_vnf_p5.c +++ b/nfapi/oai_integration/aerial/fapi_vnf_p5.c @@ -54,7 +54,6 @@ void *aerial_vnf_nr_aerial_p7_start_thread(void *ptr) void *aerial_vnf_nr_p7_thread_start(void *ptr) { - // set_thread_priority(79); int s; cpu_set_t cpuset; @@ -63,8 +62,6 @@ void *aerial_vnf_nr_p7_thread_start(void *ptr) if (s != 0) printf("failed to set afinity\n"); - set_priority(79); - pthread_attr_t ptAttr; if (pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) { printf("Failed to set pthread sched policy SCHED_RR\n"); @@ -115,7 +112,7 @@ void *aerial_vnf_nr_p7_thread_start(void *ptr) p7_vnf->config->allocate_p7_vendor_ext = &aerial_phy_allocate_p7_vendor_ext; p7_vnf->config->deallocate_p7_vendor_ext = &aerial_phy_deallocate_p7_vendor_ext; NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI P7 start thread %s\n", __FUNCTION__); - pthread_create(&vnf_aerial_p7_start_pthread, NULL, &aerial_vnf_nr_aerial_p7_start_thread, p7_vnf->config); + threadCreate(&vnf_aerial_p7_start_pthread, &aerial_vnf_nr_aerial_p7_start_thread, p7_vnf->config, "aerial_p7_start", -1, OAI_PRIORITY_RT); return 0; } @@ -227,7 +224,7 @@ int aerial_pnf_nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr if (p7_vnf->thread_started == 0) { pthread_t vnf_p7_thread; - pthread_create(&vnf_p7_thread, NULL, &aerial_vnf_nr_p7_thread_start, p7_vnf); + threadCreate(&vnf_p7_thread, &aerial_vnf_nr_p7_thread_start, p7_vnf, "aerial_p7_thread", -1, OAI_PRIORITY_RT); p7_vnf->thread_started = 1; } else { // P7 thread already running. @@ -570,7 +567,7 @@ void aerial_configure_nr_fapi_vnf() if (p7_vnf->thread_started == 0) { pthread_t vnf_p7_thread; - pthread_create(&vnf_p7_thread, NULL, &aerial_vnf_nr_p7_thread_start, p7_vnf); + threadCreate(&vnf_p7_thread, &aerial_vnf_nr_p7_thread_start, p7_vnf, "aerial_p7_thread", -1, OAI_PRIORITY_RT); p7_vnf->thread_started = 1; } else { // P7 thread already running. From 811721bb72643b17f230d920f7adf9472082cc20 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Apr 2024 09:02:02 +0200 Subject: [PATCH 14/26] PNF: use threadCreate() to create P7 thread Use common threadCreate() function to create P7 thread with high(er) priority. Remove old calls to set_priority(), as this is already done with threadCreate(). --- nfapi/oai_integration/nfapi_pnf.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 33f85a97ea..a933aba614 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -217,26 +217,8 @@ void pnf_nfapi_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) va_end(args); } -void pnf_set_thread_priority(int priority) { - set_priority(priority); - - pthread_attr_t ptAttr; - if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) { - printf("failed to set pthread SCHED_RR %d\n", errno); - } - - pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED); - struct sched_param thread_params; - thread_params.sched_priority = 20; - - if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) { - printf("failed to set sched param\n"); - } -} - void *pnf_p7_thread_start(void *ptr) { NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P7 THREAD %s\n", __FUNCTION__); - pnf_set_thread_priority(79); nfapi_pnf_p7_config_t *config = (nfapi_pnf_p7_config_t *)ptr; nfapi_pnf_p7_start(config); return 0; @@ -244,7 +226,6 @@ void *pnf_p7_thread_start(void *ptr) { void *pnf_nr_p7_thread_start(void *ptr) { NFAPI_TRACE(NFAPI_TRACE_INFO, "[NR_PNF] NR P7 THREAD %s\n", __FUNCTION__); - pnf_set_thread_priority(79); nfapi_pnf_p7_config_t *config = (nfapi_pnf_p7_config_t *)ptr; nfapi_nr_pnf_p7_start(config); return 0; @@ -1708,7 +1689,7 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv; NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__); pthread_t p7_thread; - pthread_create(&p7_thread, NULL, &pnf_p7_thread_start, p7_config); + threadCreate(&p7_thread, &pnf_p7_thread_start, p7_config, "pnf_p7_thread", -1, OAI_PRIORITY_RT); //((pnf_phy_user_data_t*)(phy_info->fapi->user_data))->p7_config = p7_config; NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__); l1_north_init_eNB(); @@ -1835,7 +1816,7 @@ int nr_start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, n p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv; NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__); pthread_t p7_thread; - pthread_create(&p7_thread, NULL, &pnf_nr_p7_thread_start, p7_config); + threadCreate(&p7_thread, &pnf_nr_p7_thread_start, p7_config, "pnf_p7_thread", -1, OAI_PRIORITY_RT); NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__); l1_north_init_gNB(); NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] HACK - Set p7_config global ready for subframe ind%s\n", __FUNCTION__); From 973d13937d4ace6a5067d1e4d69f1a400432a4f7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Apr 2024 09:08:38 +0200 Subject: [PATCH 15/26] VNF: use threadCreate() to create P7 thread Use common threadCreate() function to create P7 thread with high(er) priority. Remove old calls to set_priority(), as this is already done with threadCreate(). --- nfapi/oai_integration/nfapi_vnf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index a70b52c08c..dc9dd46b5c 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -1405,10 +1405,7 @@ void *vnf_p7_start_thread(void *ptr) { return config; } -void set_thread_priority(int priority); - void *vnf_nr_p7_thread_start(void *ptr) { - set_thread_priority(79); init_queue(&gnb_rach_ind_queue); init_queue(&gnb_rx_ind_queue); init_queue(&gnb_crc_ind_queue); @@ -1451,7 +1448,6 @@ void *vnf_nr_p7_thread_start(void *ptr) { } void *vnf_p7_thread_start(void *ptr) { - set_thread_priority(79); vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr; p7_vnf->config->port = p7_vnf->local_port; p7_vnf->config->sync_indication = &phy_sync_indication; @@ -1495,7 +1491,7 @@ int pnf_nr_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_pnf_st if(p7_vnf->thread_started == 0) { pthread_t vnf_p7_thread; - pthread_create(&vnf_p7_thread, NULL, &vnf_nr_p7_thread_start, p7_vnf); + threadCreate(&vnf_p7_thread, &vnf_nr_p7_thread_start, p7_vnf, "vnf_p7_thread", -1, OAI_PRIORITY_RT); p7_vnf->thread_started = 1; } else { // P7 thread already running. @@ -1519,7 +1515,7 @@ int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_re if(p7_vnf->thread_started == 0) { pthread_t vnf_p7_thread; - pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, p7_vnf); + threadCreate(&vnf_p7_thread, &vnf_p7_thread_start, p7_vnf, "vnf_p7_thread", -1, OAI_PRIORITY_RT); p7_vnf->thread_started = 1; } else { // P7 thread already running. From 8dc29be02f910df2ca43db479708e3bd7da85293 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Apr 2024 09:06:25 +0200 Subject: [PATCH 16/26] Remove unused set_priority()/set_thread_priority() --- common/utils/utils.c | 15 --------------- common/utils/utils.h | 2 -- nfapi/oai_integration/nfapi.c | 17 ----------------- nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp | 19 ------------------- 4 files changed, 53 deletions(-) diff --git a/common/utils/utils.c b/common/utils/utils.c index 66b840c7d9..377c4512b7 100644 --- a/common/utils/utils.c +++ b/common/utils/utils.c @@ -118,21 +118,6 @@ char *itoa(int i) { return strdup(buffer); } - -void set_priority(int priority) -{ - struct sched_param param = - { - .sched_priority = priority, - }; - fprintf(stderr, "Calling sched_setscheduler(%d)\n", priority); - if (sched_setscheduler(0, SCHED_RR, ¶m) == -1) - { - fprintf(stderr, "sched_setscheduler: %s\n", strerror(errno)); - abort(); - } -} - /** * @brief Convert a version string x.y.z into numbers. * diff --git a/common/utils/utils.h b/common/utils/utils.h index 8cb9a357fd..082d1dd635 100644 --- a/common/utils/utils.h +++ b/common/utils/utils.h @@ -116,8 +116,6 @@ int hex_char_to_hex_value (char c); // Converts an hexadecimal ASCII coded string into its value.** int hex_string_to_hex_value (uint8_t *hex_value, const char *hex_string, int size); -void set_priority(int priority); - char *itoa(int i); #define STRINGIFY(S) #S diff --git a/nfapi/oai_integration/nfapi.c b/nfapi/oai_integration/nfapi.c index f60e36fb06..7b4d1b6239 100644 --- a/nfapi/oai_integration/nfapi.c +++ b/nfapi/oai_integration/nfapi.c @@ -40,23 +40,6 @@ typedef struct { static nfapi_params_t nfapi_params = {0}; -void set_thread_priority(int priority) { - set_priority(priority); - - pthread_attr_t ptAttr; - if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) { - printf("Failed to set pthread sched policy SCHED_RR\n"); - } - - pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED); - struct sched_param thread_params; - thread_params.sched_priority = 20; - - if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) { - printf("failed to set sched param\n"); - } -} - const char *nfapi_get_strmode(void) { if (nfapi_params.nfapi_mode > NFAPI_MODE_UNKNOWN) return nfapi_str_mode[NFAPI_MODE_UNKNOWN]; diff --git a/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp index 4fe5065cea..72df4e306c 100644 --- a/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp +++ b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp @@ -137,25 +137,6 @@ extern "C" } fapi_internal_t; } -extern void set_thread_priority(int); -/* -{ - pthread_attr_t ptAttr; - - struct sched_param schedParam; - schedParam.__sched_priority = 79; - sched_setscheduler(0, SCHED_RR, &schedParam); - - pthread_attr_setschedpolicy(&ptAttr, SCHED_RR); - - pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED); - - struct sched_param thread_params; - thread_params.sched_priority = 20; - pthread_attr_setschedparam(&ptAttr, &thread_params); -} -*/ - void send_uplink_indications(fapi_internal_t *instance, uint16_t sfn_sf) { fapi_harq_ind_t harq_ind; (instance->callbacks.fapi_harq_ind)(&(instance->_public), &harq_ind); From 9b3ab10c2078bda8614402552c26a09462d0a34e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sat, 13 Apr 2024 12:32:29 +0200 Subject: [PATCH 17/26] Make failed TUN socket operation non-fatal It might be desirable to run the UE without superuser rights. More concretely, it might run without NET_ADMIN. In this case, various corresponding operations on the TUN socket fd might fail. In this commit, - improve error reports to make them more clear - do not automatically exit(1), but return from the function to ensure continuity of the softmodem --- openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c | 2 +- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 837d977f65..75f5e83632 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -144,7 +144,7 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, . if (nas_sock_fd[i] == -1) { LOG_E(PDCP, "TUN: Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); - exit(1); + return 0; } LOG_I(PDCP, "TUN: Opened socket %s with fd nas_sock_fd[%d]=%d\n", diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index c2e49f7856..58adc41a65 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -406,8 +406,7 @@ static void reblock_tun_socket(void) f = fcntl(nas_sock_fd[0], F_GETFL, 0); f &= ~(O_NONBLOCK); if (fcntl(nas_sock_fd[0], F_SETFL, f) == -1) { - LOG_E(PDCP, "reblock_tun_socket failed\n"); - exit(1); + LOG_E(PDCP, "fcntl(F_SETFL) failed on fd %d: errno %d, %s\n", nas_sock_fd[0], errno, strerror(errno)); } } @@ -425,8 +424,8 @@ static void *enb_tun_read_thread(void *_) while (1) { len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD); if (len == -1) { - LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); + LOG_E(PDCP, "could not read(): errno %d %s\n", errno, strerror(errno)); + return NULL; } LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len); @@ -483,8 +482,8 @@ static void *ue_tun_read_thread(void *_) while (1) { len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD); if (len == -1) { - LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); + LOG_E(PDCP, "error: cannot read() from fd %d: errno %d, %s\n", nas_sock_fd[0], errno, strerror(errno)); + return NULL; /* exit thread */ } LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len); From 9f8fad86ee092962aba25ea5be73b3fbea6b0285 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 18 Apr 2024 18:15:01 +0200 Subject: [PATCH 18/26] Use capabilities in 5G RFsim docker-compose - 5g rfsim fdd_phytest - 5g rfsimulator - 5g fdd rfsim - 5g f1 rfsim - 5g l2sim - 5g rfsim 24prb - 5g rfsim 2x2 - 5g rfsim accelleran - 5g rfsim e1 - 5g rfsim fr2 32prb - 5g rfsim u0 - Update doc We give NET_ADMIN (for interface bringup) and NET_RAW (for ping). IPC_LOCK and SYS_NICE are intentionally left out to verify the softmodems run without. --- .../5g_f1_rfsimulator/docker-compose.yaml | 14 +++- .../5g_fdd_rfsimulator/docker-compose.yaml | 11 ++- .../5g_l2sim_tdd/docker-compose.yaml | 14 +++- .../yaml_files/5g_rfsimulator/README.md | 8 +- .../5g_rfsimulator/docker-compose.yaml | 83 ++++++++++++++++--- .../5g_rfsimulator_24prb/docker-compose.yaml | 11 ++- .../5g_rfsimulator_2x2/docker-compose.yaml | 11 ++- .../docker-compose.yaml | 11 ++- .../5g_rfsimulator_e1/docker-compose.yaml | 45 +++++++--- .../docker-compose.yaml | 16 +++- .../docker-compose.yaml | 11 ++- .../docker-compose.yaml | 16 +++- .../docker-compose.yaml | 11 ++- 13 files changed, 218 insertions(+), 44 deletions(-) diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml index 80313eea4d..f768bd7ca1 100644 --- a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml @@ -84,8 +84,9 @@ services: oai-cu: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-cu + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 @@ -104,8 +105,9 @@ services: oai-du: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-du + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time @@ -128,8 +130,12 @@ services: oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 @@ -142,6 +148,8 @@ services: networks: public_net: ipv4_address: 192.168.71.181 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf - ../../conf_files/rfsim_channel_ci.conf:/opt/oai-nr-ue/etc/rfsim_channel_ci.conf diff --git a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml index 558e4670c0..11e1fc4534 100644 --- a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml @@ -82,8 +82,9 @@ services: retries: 5 oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa -E --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 @@ -101,8 +102,12 @@ services: retries: 5 oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 --band 66 -C 2169090000 --CO -400000000 --ssb 378 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -110,6 +115,8 @@ services: networks: public_net: ipv4_address: 192.168.71.150 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml index 423e458cad..d56239d0b4 100644 --- a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml @@ -82,8 +82,9 @@ services: retries: 5 oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: "l2sim-oai-gnb" + cap_drop: + - ALL network_mode: "host" environment: TZ: Europe/Paris @@ -102,8 +103,9 @@ services: proxy: image: oai-lte-multi-ue-proxy:latest - privileged: true container_name: "l2sim-proxy" + cap_drop: + - ALL network_mode: "host" environment: TZ: Europe/Paris @@ -118,14 +120,20 @@ services: oai-nr-ue0: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: "l2sim-oai-nr-ue0" + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping network_mode: "host" environment: TZ: Europe/Paris OPENAIR_DIR: /opt/oai-nr-ue USE_ADDITIONAL_OPTIONS: --nfapi STANDALONE_PNF --node-number 2 --sa --emulate-l1 --log_config.global_log_options level,time,thread_id,nocolor ASAN_OPTIONS: detect_leaks=0 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.band78.106prb.l2sim.conf:/opt/oai-nr-ue/etc/nr-ue.conf - ../../../openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results:/opt/oai-nr-ue/openair1/SIMULATION/LTE_PHY/BLER_SIMULATIONS/AWGN/AWGN_results diff --git a/ci-scripts/yaml_files/5g_rfsimulator/README.md b/ci-scripts/yaml_files/5g_rfsimulator/README.md index cb4a69aacb..eec4eb17d2 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/README.md +++ b/ci-scripts/yaml_files/5g_rfsimulator/README.md @@ -237,12 +237,18 @@ Create the entry for the second UE in `docker-compose.yaml` file as follows: ```yaml oai-nr-ue2: image: oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue2 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf networks: diff --git a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml index 8672285830..e46e9b1ab4 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml @@ -82,8 +82,9 @@ services: retries: 5 oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa -E --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 @@ -101,8 +102,12 @@ services: retries: 5 oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001100 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -110,6 +115,8 @@ services: networks: public_net: ipv4_address: 192.168.71.150 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -119,8 +126,12 @@ services: retries: 5 oai-nr-ue2: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue2 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001101 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -128,6 +139,8 @@ services: networks: public_net: ipv4_address: 192.168.71.151 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -137,8 +150,12 @@ services: retries: 5 oai-nr-ue3: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue3 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001102 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -146,6 +163,8 @@ services: networks: public_net: ipv4_address: 192.168.71.152 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -155,8 +174,12 @@ services: retries: 5 oai-nr-ue4: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue4 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001103 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -164,6 +187,8 @@ services: networks: public_net: ipv4_address: 192.168.71.153 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -173,8 +198,12 @@ services: retries: 5 oai-nr-ue5: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue5 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001104 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -182,6 +211,8 @@ services: networks: public_net: ipv4_address: 192.168.71.154 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -191,8 +222,12 @@ services: retries: 5 oai-nr-ue6: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue6 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001105 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -200,6 +235,8 @@ services: networks: public_net: ipv4_address: 192.168.71.155 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -209,8 +246,12 @@ services: retries: 5 oai-nr-ue7: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue7 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001106 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -218,6 +259,8 @@ services: networks: public_net: ipv4_address: 192.168.71.156 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -227,8 +270,12 @@ services: retries: 5 oai-nr-ue8: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue8 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001107 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -236,6 +283,8 @@ services: networks: public_net: ipv4_address: 192.168.71.157 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -245,8 +294,12 @@ services: retries: 5 oai-nr-ue9: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue9 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001108 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -254,6 +307,8 @@ services: networks: public_net: ipv4_address: 192.168.71.158 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -263,8 +318,12 @@ services: retries: 5 oai-nr-ue10: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue10 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --uicc0.imsi 208990100001109 -C 3619200000 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -272,6 +331,8 @@ services: networks: public_net: ipv4_address: 192.168.71.159 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml index 3f652f5433..86573d0227 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_24prb/docker-compose.yaml @@ -82,8 +82,9 @@ services: retries: 5 oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 @@ -101,8 +102,12 @@ services: retries: 5 oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 24 --ssb 24 --numerology 1 -C 3604800000 --uicc0.imsi 208990100001100 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -110,6 +115,8 @@ services: networks: public_net: ipv4_address: 192.168.71.150 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml index 25af557271..8cc47c77c6 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_2x2/docker-compose.yaml @@ -82,8 +82,9 @@ services: retries: 5 oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 @@ -102,8 +103,12 @@ services: oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 106 --numerology 1 --band 78 -C 3319680000 --ue-nb-ant-tx 2 --uicc0.imsi 208990100001100 --ue-nb-ant-rx 2 --uecap_file /opt/oai-nr-ue/etc/uecap.xml --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -111,6 +116,8 @@ services: networks: public_net: ipv4_address: 192.168.71.150 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap_ports2.xml:/opt/oai-nr-ue/etc/uecap.xml - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf diff --git a/ci-scripts/yaml_files/5g_rfsimulator_accelleran/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_accelleran/docker-compose.yaml index f065f7a0cf..daaec8e5ee 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_accelleran/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_accelleran/docker-compose.yaml @@ -1,8 +1,9 @@ services: oai-du: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-du + cap_drop: + - ALL network_mode: "host" environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --MACRLCs.[0].local_n_address 172.21.16.109 --MACRLCs.[0].remote_n_address 172.21.6.22 --log_config.global_log_options level,nocolor,time @@ -15,13 +16,19 @@ services: retries: 5 oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping network_mode: "host" environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 106 --numerology 1 -C 3619200000 --uicc0.imsi 208990100001140 --rfsimulator.serveraddr 127.0.0.1 --log_config.global_log_options level,nocolor,time depends_on: - oai-du + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml index a3c16e0137..92f04bc074 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_e1/docker-compose.yaml @@ -66,8 +66,9 @@ services: oai-cucp: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-cucp + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2 @@ -92,8 +93,9 @@ services: oai-cuup: image: oaisoftwarealliance/oai-nr-cuup:develop - privileged: true container_name: rfsim5g-oai-cuup + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time --gNBs.[0].E1_INTERFACE.[0].ipv4_cucp 192.168.77.2 @@ -120,8 +122,9 @@ services: oai-cuup2: image: oaisoftwarealliance/oai-nr-cuup:develop - privileged: true container_name: rfsim5g-oai-cuup2 + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_CU_UP_ID 0xe01 @@ -151,8 +154,9 @@ services: oai-cuup3: image: oaisoftwarealliance/oai-nr-cuup:develop - privileged: true container_name: rfsim5g-oai-cuup3 + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_CU_UP_ID 0xe02 @@ -182,8 +186,9 @@ services: oai-du: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-du + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time --MACRLCs.[0].local_n_address 192.168.72.3 @@ -210,8 +215,9 @@ services: oai-du2: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-du2 + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_DU_ID 0xe01 @@ -241,8 +247,9 @@ services: oai-du3: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-du3 + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time --gNBs.[0].gNB_DU_ID 0xe02 @@ -272,8 +279,12 @@ services: oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 @@ -284,6 +295,8 @@ services: networks: ue_net: ipv4_address: 192.168.78.5 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -294,8 +307,12 @@ services: oai-nr-ue2: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue2 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 @@ -306,6 +323,8 @@ services: networks: ue_net: ipv4_address: 192.168.78.6 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: @@ -316,8 +335,12 @@ services: oai-nr-ue3: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue3 + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time -r 106 --numerology 1 -C 3619200000 @@ -329,6 +352,8 @@ services: networks: ue_net: ipv4_address: 192.168.78.7 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_fdd_phytest/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_fdd_phytest/docker-compose.yaml index cddb304b9d..b60c34e945 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_fdd_phytest/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_fdd_phytest/docker-compose.yaml @@ -1,14 +1,20 @@ services: oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --phy-test --rfsim --rfsimulator.wait_timeout 20 --noS1 --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 networks: public_net: ipv4_address: 192.168.71.140 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/gnb.band66.106prb.rfsim.phytest-dora.conf:/opt/oai-gnb/etc/gnb.conf - rrc.config:/opt/oai-gnb/ @@ -20,11 +26,17 @@ services: oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --phy-test --rfsim --noS1 --reconfig-file etc/rrc/reconfig.raw --rbconfig-file etc/rrc/rbconfig.raw --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf - rrc.config:/opt/oai-nr-ue/etc/rrc/ diff --git a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml index 66516f624d..22900465b6 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml @@ -83,8 +83,9 @@ services: oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 @@ -101,13 +102,19 @@ services: oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time -r 32 --numerology 3 --band 261 -C 27533160000 --ssb 73 ASAN_OPTIONS: detect_leaks=0 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf depends_on: diff --git a/ci-scripts/yaml_files/5g_rfsimulator_tdd_dora/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_tdd_dora/docker-compose.yaml index 44c2ffd8ae..f5a3d9a042 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_tdd_dora/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_tdd_dora/docker-compose.yaml @@ -1,14 +1,20 @@ services: oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --do-ra --rfsim --rfsimulator.wait_timeout 20 --noS1 --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 networks: public_net: ipv4_address: 192.168.71.140 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/gnb.band78.106prb.rfsim.phytest-dora.conf:/opt/oai-gnb/etc/gnb.conf - rrc.config:/opt/oai-gnb/ @@ -20,11 +26,17 @@ services: oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --do-ra --rfsim --noS1 --reconfig-file etc/rrc/reconfig.raw --rbconfig-file etc/rrc/rbconfig.raw --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf - rrc.config:/opt/oai-nr-ue/etc/rrc/ diff --git a/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml index cedbcb3cbb..2ae4874eee 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_u0_25prb/docker-compose.yaml @@ -82,8 +82,9 @@ services: retries: 5 oai-gnb: image: oaisoftwarealliance/oai-gnb:develop - privileged: true container_name: rfsim5g-oai-gnb + cap_drop: + - ALL environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 @@ -102,8 +103,12 @@ services: oai-nr-ue: image: oaisoftwarealliance/oai-nr-ue:develop - privileged: true container_name: rfsim5g-oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 25 --numerology 0 --uicc0.imsi 208990100001100 --band 66 -C 2152680000 --CO -400000000 --ssb 48 --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time depends_on: @@ -111,6 +116,8 @@ services: networks: public_net: ipv4_address: 192.168.71.150 + devices: + - /dev/net/tun:/dev/net/tun volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf healthcheck: From ffa5ba400af47a70c1dd384c1686911d01bc78c6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 22 Apr 2024 17:12:34 +0200 Subject: [PATCH 19/26] Use capabilities in N310-based docker compose - SA 2x2 tests on 60 and 100 MHz - N310-based OAI gNB + UE Give SYS_NICE and IPC_LOCK for performance. On the UE side, give NET_ADMIN (for interface bringup) and NET_RAW (for ping an TUN). --- .../5g_sa_n310_2x2_100MHz/docker-compose.yml | 6 +++++- .../yaml_files/5g_sa_n310_2x2_60MHz/docker-compose.yml | 6 +++++- .../yaml_files/5g_sa_n310_gnb/docker-compose.yml | 6 +++++- .../yaml_files/5g_sa_n310_nrue/docker-compose.yml | 10 +++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ci-scripts/yaml_files/5g_sa_n310_2x2_100MHz/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_2x2_100MHz/docker-compose.yml index 9be2d550c0..9368957b03 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_2x2_100MHz/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_2x2_100MHz/docker-compose.yml @@ -1,9 +1,13 @@ services: oai-gnb: image: oai-gnb:latest - privileged: true network_mode: "host" container_name: oai-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK environment: TZ: Europe/Paris USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time diff --git a/ci-scripts/yaml_files/5g_sa_n310_2x2_60MHz/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_2x2_60MHz/docker-compose.yml index d970d96e33..efe9f03c36 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_2x2_60MHz/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_2x2_60MHz/docker-compose.yml @@ -1,9 +1,13 @@ services: oai-gnb: image: oai-gnb:latest - privileged: true network_mode: "host" container_name: oai-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK environment: TZ: Europe/Paris USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time diff --git a/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml index 625308d863..31a0532d2e 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml @@ -1,9 +1,13 @@ services: oai-gnb: image: oai-gnb:latest - privileged: true network_mode: "host" container_name: oai-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: diff --git a/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml index 388e5a5feb..c427a5ef4c 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml @@ -1,9 +1,17 @@ services: oai-nr-ue: image: oai-nr-ue:latest - privileged: true network_mode: host container_name: oai-nr-ue + cap_drop: + - ALL + cap_add: + - NET_ADMIN # for interface bringup + - NET_RAW # for ping + - SYS_NICE # for performance + - IPC_LOCK # for memory locking + devices: + - /dev/net/tun:/dev/net/tun ulimits: core: -1 # for core dumps #entrypoint: /bin/bash -c "sleep infinity" From 9dd52c9d440ecf9dc24783b151ecf7c6dcd068ae Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Apr 2024 07:53:31 +0200 Subject: [PATCH 20/26] Use capabilities in B200-based docker-compose - sa_b200_gnb - sa_aw2s_gnb - sa_e1_b200 - sa_f1_b200 - sa_sc_b200_gnb - nsa_b200_gnb By default, the container has no access to /dev. Mount all USB devices into the container to ease usability: by default, USB devices are mounted under /dev/bus/usb using the bus ID, which is different on every system and might change on reboots or with (un-)plugging USB devices. Hence, mount all USB; the process has not many capabilities anyway, and thus might not do much harm. A proper solution would be to write a udev rule to mount a device using its vendor and product ID, and only mount the corresponding device into the container. --- .../yaml_files/nsa_b200_gnb/docker-compose.yml | 9 +++++++-- .../yaml_files/sa_b200_gnb/docker-compose.yml | 9 +++++++-- .../sa_e1_b200_gnb/docker-compose.yml | 18 ++++++++++++++---- .../sa_f1_b200_gnb/docker-compose.yml | 12 +++++++++--- .../sa_sc_b200_gnb/docker-compose.yml | 9 +++++++-- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml index fa5f9b0a28..290ba46280 100644 --- a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml @@ -1,16 +1,21 @@ services: gnb_mono_tdd: image: oai-gnb:latest - privileged: true container_name: nsa-b200-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function + devices: + - /dev/bus/usb/:/dev/bus/usb/ volumes: - ../../conf_files/gnb.nsa.band78.106prb.usrpb200.conf:/opt/oai-gnb/etc/gnb.conf - - /dev:/dev networks: public_net: ipv4_address: 192.168.68.194 diff --git a/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml index e440cec52d..d97daf49d1 100644 --- a/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml @@ -1,16 +1,21 @@ services: gnb_mono_tdd: image: oai-gnb:latest - privileged: true container_name: sa-b200-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function + devices: + - /dev/bus/usb/:/dev/bus/usb/ volumes: - ../../conf_files/gnb.sa.band78.51prb.usrpb200.conf:/opt/oai-gnb/etc/gnb.conf - - /dev:/dev # for performance reasons, we use host mode: in bridge mode, we have # unacceptable DL TCP performance. However, the whole point of # containerization is to not be in host mode, so update this to macvlan diff --git a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml index 7798d41c88..4c2d0b7cc9 100644 --- a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml @@ -1,8 +1,9 @@ services: gnb_cucp: image: oai-gnb:latest - privileged: true container_name: sa-cucp-gnb + cap_drop: + - ALL ulimits: core: -1 # for core dumps environment: @@ -25,8 +26,12 @@ services: gnb_cuup: image: oai-nr-cuup:latest - privileged: true container_name: sa-cuup-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: @@ -48,8 +53,12 @@ services: gnb_du_tdd: image: oai-gnb:latest - privileged: true container_name: sa-du-b200-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: @@ -61,9 +70,10 @@ services: --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 1 --RUs.[0].att_rx 14 --RUs.[0].att_tx 14 --log_config.global_log_options level,nocolor,time,line_num,function + devices: + - /dev/bus/usb/:/dev/bus/usb/ volumes: - ../../conf_files/gnb-du.sa.band78.106prb.usrpb200.conf:/opt/oai-gnb/etc/gnb.conf - - /dev:/dev # for performance reasons, we use host mode: in bridge mode, we have # unacceptable DL TCP performance. However, the whole point of # containerization is to not be in host mode, so update this to macvlan diff --git a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml index b2f682aada..8f026245ac 100644 --- a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml @@ -1,8 +1,9 @@ services: gnb_cu: image: oai-gnb:latest - privileged: true container_name: sa-cu-gnb + cap_drop: + - ALL ulimits: core: -1 # for core dumps environment: @@ -26,8 +27,12 @@ services: gnb_du_fdd: image: oai-gnb:latest - privileged: true container_name: sa-du-b200-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: @@ -36,9 +41,10 @@ services: --telnetsrv --telnetsrv.listenport 9091 --telnetsrv.shrmod ci --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 0 --L1s.[0].max_ldpc_iterations 20 --log_config.global_log_options level,nocolor,time,line_num,function + devices: + - /dev/bus/usb/:/dev/bus/usb/ volumes: - ../../conf_files/gnb-du.sa.band1.52prb.usrpb210.conf:/opt/oai-gnb/etc/gnb.conf - - /dev:/dev # for performance reasons, we use host mode: in bridge mode, we have # unacceptable DL TCP performance. However, the whole point of # containerization is to not be in host mode, so update this to macvlan diff --git a/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml index 7bd0f03b10..4ec5900521 100644 --- a/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml @@ -1,16 +1,21 @@ services: gnb_mono_tdd: image: oai-gnb:latest - privileged: true container_name: sa-b200-gnb + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function -E + devices: + - /dev/bus/usb/:/dev/bus/usb/ volumes: - ../../conf_files/gnb.sa.band78.106prb.usrpb200.sc-fdma.conf:/opt/oai-gnb/etc/gnb.conf - - /dev:/dev # for performance reasons, we use host mode: in bridge mode, we have # unacceptable DL TCP performance. However, the whole point of # containerization is to not be in host mode, so update this to macvlan From b4750d8d812f66159222fe8909f85cdcb6af5fa0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Apr 2024 09:33:10 +0200 Subject: [PATCH 21/26] Use capabilities in AW2S-based docker compose --- ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml index 40b0837168..9e0fcce062 100644 --- a/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml @@ -1,9 +1,13 @@ services: oai-gnb: image: oai-gnb-aw2s:latest - privileged: true network_mode: "host" container_name: oai-gnb-aw2s + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ulimits: core: -1 # for core dumps environment: From 0cc278f19b675b8d48f78e62c88e9ec447631cdc Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 23 Apr 2024 08:00:11 +0200 Subject: [PATCH 22/26] Use capabilities in Aerial-based docker-compose --- ci-scripts/yaml_files/sa_gnb_aerial/docker-compose.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci-scripts/yaml_files/sa_gnb_aerial/docker-compose.yaml b/ci-scripts/yaml_files/sa_gnb_aerial/docker-compose.yaml index fa3c23b25b..0391b39142 100644 --- a/ci-scripts/yaml_files/sa_gnb_aerial/docker-compose.yaml +++ b/ci-scripts/yaml_files/sa_gnb_aerial/docker-compose.yaml @@ -38,7 +38,11 @@ services: depends_on: nv-cubb: condition: service_healthy - privileged: true + cap_drop: + - ALL + cap_add: + - SYS_NICE + - IPC_LOCK ipc: "container:nv-cubb" environment: USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time From 13517cd6bc130373619eab06382089e25e0a97c4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 14 Mar 2024 18:21:03 +0100 Subject: [PATCH 23/26] Write documentation on performance tuning and security --- doc/NR_SA_Tutorial_COTS_UE.md | 2 + doc/README.md | 1 + doc/tuning_and_security.md | 165 ++++++++++++++++++++++++++++++++++ radio/rfsimulator/README.md | 2 + 4 files changed, 170 insertions(+) create mode 100644 doc/tuning_and_security.md diff --git a/doc/NR_SA_Tutorial_COTS_UE.md b/doc/NR_SA_Tutorial_COTS_UE.md index 0924eee1b0..291dfdd7b4 100644 --- a/doc/NR_SA_Tutorial_COTS_UE.md +++ b/doc/NR_SA_Tutorial_COTS_UE.md @@ -163,6 +163,8 @@ docker exec -it oai-ext-dn iperf -u -t 86400 -i 1 -fk -B 192.168.70.135 -b 100M # 6. Advanced configurations (optional) +See also the [dedicated document on performance tuning](./tuning_and_security.md). + ## 6.1 USRP N300 and X300 Ethernet Tuning Please also refer to the official [USRP Host Performance Tuning Tips and Tricks](https://kb.ettus.com/USRP_Host_Performance_Tuning_Tips_and_Tricks) tuning guide. diff --git a/doc/README.md b/doc/README.md index ef72249725..1c4413a8a5 100644 --- a/doc/README.md +++ b/doc/README.md @@ -24,6 +24,7 @@ - [clang-format.md](./clang-format.md): how to format the code - [sanitizers.md](./dev_tools/sanitizers.md): how to run with ASan/UBSan/MemSAN/TSan - [environment-variables.md](./environment-variables.md): the environment variables used by OAI +- [tuning_and_security.md](./tuning_and_security.md): performance and security considerations There is some general information in the [OpenAirInterface Gitlab Wiki](https://gitlab.eurecom.fr/oai/openairinterface5g/-/wikis/home) diff --git a/doc/tuning_and_security.md b/doc/tuning_and_security.md new file mode 100644 index 0000000000..94b6ceb07c --- /dev/null +++ b/doc/tuning_and_security.md @@ -0,0 +1,165 @@ +This document outlines some information specific to system tuning for +running all executables (`nr-softmodem`, `lte-softmodem`, `nr-uesoftmodem`, +`lte-uesoftmodem`, `nr-cuup`, called softmodems for short in the following). +Also, it explains which Linux capabilities are required to run, and how to run +without sudo. + +[TOC] + +# Performance Tuning + +Please also refer to the [advanced configuration in the +tutorial](NR_SA_Tutorial_COTS_UE.md#6-advanced-configurations-optional), which +groups many tips and tricks. + +## CPU + +OAI used to try to set the minimum CPU-DMA latency to 2 us by writing to +`/dev/cpu_dma_latency`. However, it is unclear if this has a significant +effect. Further, in containerized workloads, it might not be possible to set +this at all. We assume the user of OAI sets this value before starting OAI. +See the [Linux kernel +documentation](https://www.kernel.org/doc/html/latest/admin-guide/pm/cpuidle.html) +for more information. + +OAI used to try to set the minimum frequency of cores running OAI to the +maximum frequency. We assume that the user sets CPU frequency policies +accordingly; in fact, tutorials generally suggest to either set a performance +CPU governor, or disable any sleep states at all. Hence, setting these +low-level parameters seems useless, and we assume the user of OAI disables +sleep states before starting OAI. + +To disable all sleep states, simply run the following: +``` +sudo cpupower idle-set -D0 +``` +Sometimes, dependencies might not be installed, in which case you should +install what `cpupower` asks you to install. Note that this is not persistent. + +See the [Linux kernel +documentation](https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html) +for more information. + +You can disable hyper-threading in the BIOS. + +You can disable KPTI Protections for Spectre/Meltdown for more performance. +**This is a security risk.** Add `mitigations=off nosmt` in your grub config and +update grub. + +## Ethernet-based Radios + +For ethernet-based radios, such as AW2S, some USRPs, and 7.2 radios, increase +the ringbuffers to a maximum. Read on interface `` +using option `-g`, then set it with `-G`: + +``` +ethtool -g +ethtool -G rx tx +``` + +Also, you can increase the kernel's default and maximum read and write socket +buffer sizes to a high values, e.g., 134217728: + +``` +sudo sysctl -n -e -q -w net.core.rmem_default=134217728 +sudo sysctl -n -e -q -w net.core.rmem_max=134217728 +sudo sysctl -n -e -q -w net.core.wmem_default=134217728 +sudo sysctl -n -e -q -w net.core.wmem_max=134217728 +``` + +# Capabilities + +Historically, all softmodems are executed as `root`, typically using `sudo`. +This remains a possibility, but we do not recommend it due to security +considerations. Rather, consider giving specific capabilities as outlined +below. Read `capabilities(7)` (`man 7 capabilities`) for more information on +each of the below capabilities. + +Note that we tested this using 5G executables; 4G should work, but have not +been tested as extensively. If in doubt, run eNB/lteUE using `sudo`. The below +comments on capabilities apply in general as well; however, 4G executable might +not warn about missing capabilities or just fail. + +Refer to any of the docker-compose files under `ci-scripts/` to see how to give +capabilities in docker. If you run from source, you can use `setcap` to mark a +process to run with specific capabilities. For instance, you can add the "general +capabilities" as described further below on the files like this: + +``` +sudo setcap cap_sys_nice+ep ./nr-softmodem +sudo setcap cap_ipc_lock+ep ./nr-softmodem +sudo setcap cap_sys_nice+ep ./nr-uesoftmodem +sudo setcap cap_ipc_lock+ep ./nr-uesoftmodem +sudo setcap cap_net_admin+ep ./nr-uesoftmodem +``` + +To make only temporary changes to capabilities, use `capsh`. It needs to be +started with all capabilities, so needs `sudo`. To drop all capabilities, +issue: +``` +sudo -E capsh --drop="cap_sys_nice,cap_chown,cap_dac_read_search,cap_fowner,cap_fsetid,\ +cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,\ +cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,\ +cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,\ +cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,\ +cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,\ +cap_block_suspend,cap_audit_read,cap_perfmon,cap_bpf,cap_checkpoint_restore" --print -- \ + -c "/absolute/path/to/nr-softmodem -O /absolute/path/to/config.conf" +``` + +(For readability, the command has been separated onto multiple lines through +`\`). To run with `SYS_NICE`, remove the first capability (`cap_sys_nice`) +from the list of dropped capabilities. + +## General capabilities + +- `SYS_NICE`: required by all softmodems to assign a higher priority to + threads to increase the likelihood that the Linux scheduler schedules a + thread for CPU time. Also, in some configurations, CPU pinning is employed to + ensure consistent performance, also known as setting a CPU affinity. + + This capability is necessary by default when running any softmodem, for + setting real-time requirements on processing threads. To allow to run without + these requirements, the softmodems check if `SYS_NICE` is available, and + skips any thread priority and affinity settings if the capability is not + available. This allows to run any softmodem without root privileges in RFsim; + you can see this by either observing a corresponding warning at the beginning + of the execution, or the fact that no affinity/default priority is set for + new threads. + +- `IPC_LOCK`: OAI tries to lock all its virtual address space into RAM, + preventing that memory from being paged to the swap area. If this capability + is not present, a warning is printed. + +- `NET_ADMIN`: Required at the UE to open the interface `oaitun_ue1` or eNB/gNB + in noS1 mode. 5G executables will throw an error if they cannot create or + modify an interface, but will continue running. It is therefore possible to + run without this capability, but you cannot inject any traffic into the + system. 4G executables might need this requirement, and possibly fail. + +## Capabilities with DPDK + +Additionally to the "general capabilities" above, you need these capabilities +when running with 7.2 fronthaul, which uses the xran library with a dependency +on DPDK: + +- `IPC_LOCK` (becomes mandatory with DPDK) +- `SYS_RESOURCE` +- `NET_RAW` + +## Capabilities with UHD + +You don't need any additional capabilities for UHD beyond the "general +capabilities" for performance outlined above. Make sure that the USB device(s) +are readable and writable by the current user (e.g., `uhd_usrp_probe` can be +executed by a non-root user). + +## Capabilities with AW2S + +You don't need any additional capabilities for AW2S beyond the "general +capabilities" for performance outlined above. + +## Other radios + +Other radios have not been tested. If they do not work without additional +capabilities beyond the "general capabilities", please file a bug report. diff --git a/radio/rfsimulator/README.md b/radio/rfsimulator/README.md index ea2188d4df..ba63ae4ec0 100644 --- a/radio/rfsimulator/README.md +++ b/radio/rfsimulator/README.md @@ -189,3 +189,5 @@ to reduce the amount of transported samples: - Prefer smaller cell bandwidths A possible, unimplemented optimization would be to compress samples. + +You can further [tune your machine](../../doc/tuning_and_security.md) From 971ab65fe5196fb9a979d12c0e3d23e17cf5d328 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 31 May 2024 07:50:23 +0200 Subject: [PATCH 24/26] Physims don't need sudo --- cmake_targets/autotests/run_exec_autotests.bash | 12 ------------ cmake_targets/build_oai | 11 ++--------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/cmake_targets/autotests/run_exec_autotests.bash b/cmake_targets/autotests/run_exec_autotests.bash index 0b8c86795e..c531f62f9a 100755 --- a/cmake_targets/autotests/run_exec_autotests.bash +++ b/cmake_targets/autotests/run_exec_autotests.bash @@ -30,7 +30,6 @@ fi source $OPENAIR_DIR/cmake_targets/tools/test_helper -SUDO="sudo -E" tdir=$OPENAIR_DIR/cmake_targets/autotests rm -fr $tdir/bin mkdir -p $tdir/bin @@ -178,8 +177,6 @@ RUN_GROUP=0 test_case_group="" test_case_group_array=() test_case_array=() -echo_info "Note that the user should be sudoer for executing certain commands, for example loading kernel modules" - until [ -z "$1" ]; do case "$1" in @@ -207,15 +204,6 @@ until [ -z "$1" ]; do esac done -tmpfile=`mktemp` -$SUDO echo $HOME > $tmpfile -tstsudo=`cat $tmpfile` -if [ "$tstsudo" != "$HOME" ]; then - echo_error "$USER does not have sudo privileges. Exiting" - exit -fi -rm -fr $tmpfile - test_case_excl_list=`xmlstarlet sel -t -v "/testCaseList/TestCaseExclusionList" $xml_conf` test_case_excl_list=`sed "s/\+/\*/g" <<< "$test_case_excl_list" ` # Replace + with * for bash string substituion echo "Test Case Exclusion List = $test_case_excl_list " diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index c59017b5ac..beb1b51039 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -542,22 +542,15 @@ function main() { # Auto-tests # ############## if [ "$OAI_TEST" = "1" ] ; then - echo_error "These scripts ASSUME that user is in /etc/sudoers and can execute commands without PASSWORD prompt" - echo_error "Add the following lines in /etc/sudoers file to make your __user_name__ sudo without password prompt" - echo_error " __your_user_name__ ALL = (ALL:ALL) NOPASSWD: ALL" - echo_error " __your_user_name__ ALL = (ALL) NOPASSWD: ALL " echo_info "The log file for the autotest script for debugging is located here: $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log " echo_info "The results of autotests results is located here: $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml " echo_info "You can hit CTRL-C at any time to terminate the autotests..." - echo "Current User Name: $USER" - read -s -p "Enter Password: " mypassword - echo -e "\n" rm -fr $OPENAIR_DIR/cmake_targets/autotests/log mkdir -p $OPENAIR_DIR/cmake_targets/autotests/log if [ "$RUN_GROUP" -eq "1" ]; then - $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -g "$TEST_CASE_GROUP" -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log & + $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -g "$TEST_CASE_GROUP" >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log else - $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log & + $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log fi wait else From a87df90504fef4d789d8e958a28c7f57f5995c4d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 31 May 2024 09:00:13 +0200 Subject: [PATCH 25/26] Add documentation for physical simulators --- doc/README.md | 1 + doc/TESTBenches.md | 1 + doc/physical-simulators.md | 135 +++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 doc/physical-simulators.md diff --git a/doc/README.md b/doc/README.md index 1c4413a8a5..c4957566b7 100644 --- a/doc/README.md +++ b/doc/README.md @@ -51,6 +51,7 @@ There is some general information in the [OpenAirInterface Gitlab Wiki](https:// - [How to use the positioning reference signal (PRS)](./RUN_NR_PRS.md) - [How to use device-to-device communication (D2D, 4G)](./d2d_emulator_setup.txt) - [How to run with E2 agent](../openair2/E2AP/README.md) +- [How to run the physical simulators](./physical-simulators.md) Legacy unmaintained files: - [`L2NFAPI_NOS1.md`](./L2NFAPI_NOS1.md), [`L2NFAPI_S1.md`](./L2NFAPI_S1.md): diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index 9ea8534faa..028736d195 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -169,6 +169,7 @@ information on how the images are built. ~4G-LTE ~5G-NR - cluster (`Asterix-OC-oaicicd-session` resource), tests in OpenShift Cluster - unitary simulators (`nr_dlsim`, etc.) + - see [`./physical-simulators.md`](./physical-simulators.md) for an overview - [RAN-RF-Sim-Test-4G](https://jenkins-oai.eurecom.fr/job/RAN-RF-Sim-Test-4G/) ~4G-LTE - obelix (eNB, lteUE, OAI EPC) diff --git a/doc/physical-simulators.md b/doc/physical-simulators.md new file mode 100644 index 0000000000..f52b2e371d --- /dev/null +++ b/doc/physical-simulators.md @@ -0,0 +1,135 @@ +This document describes the physical simulators, also called "unitary +simulators", or short "physims". + +[[_TOC_]] + +# Introduction + +There are several unitary simulations for the physical layer, testing +individual L1 transport/control channels using Monte-Carlo simulations, for +instance: + +- `nr_pucchsim` for 5G PUCCH, +- `nr_dlsim` for 5G DLSCH/PDSCH, +- `nr_prachsim` for 5G PRACH, +- `dlsim` for 4G DLSCH/PDSCH, etc. + +These simulators constitute the starting point for testing any new code in the +PHY layer, and are required tests to be performed before committing any new +code to the repository, in the sense that all of these should compile and +execute correctly. They provide estimates of the transport block error rates +and HARQ thoughput, DCI error rates, etc. The simulators reside in +`openair1/SIMULATION/LTE_PHY` and `openair1/SIMULATION/NR_PHY`. For instance, +`nr_dlsim` is built from `openair1/SIMULATION/NR_PHY/dlsim.c`. + +Further unitary simulation of the coding subsystem components also exists in +`openair1/PHY/CODING/TESTBENCH`, e.g., `ldpctest` for encoding/decoding of +LDPC. + +These are the simulators known to work properly and tested in CI: +- 4G: `dlsim`, `ulsim` +- 5G: `nr_dlsim`, `nr_ulsim`, `nr_dlschsim`, `nr_ulschsim`, `ldpctest`, + `nr_pbchsim`, `nr_prachsim`, `nr_pucchsim`, `polartest`, `smallblocktest`, + `nr_psbchsim` (sidelink) + +# How to run + +You first have to build simulators: + +```bash +cd openairinterface5g/ +. oaienv # important for the run_exec_autotests.bash script +cd cmake_targets/ +./build_oai --ninja -P +``` + +This builds the simulators in the default build directory `ran_build/build` +(all paths given here are relative to `cmake_targets/` in the root of +`openairinterface5g/`). To run all simulators in this default build directory +of above `build_oai` invocation, run the `run_exec_autotests.bash` script: +```bash +autotests/run_exec_autotests.bash +``` + +This runs all simulations as defined in `autotests/test_case_list.xml`. + +To run a group of tests, you can specify the group using `-g`. You can also +specify the build directory, after building the simulators, which, for the +default directory, is: + +```bash +autotests/run_exec_autotests.bash -g "nr_dlsim.basic" -d ran_build/build/ +``` + +This will run the `nr_dlsim.basic` group, as listed in +`autotests/test_case_list.xml`. + +## How to interpret the output + +From the output, you can see the invoked tests, its parameters, and the log files. +Example: + +``` +[user@oai cmake_targets]$ autotests/run_exec_autotests.bash -g "nr_dlsim.basic" -d ran_build/build/ +[...] +Test case nr_dlsim.basic match found in group +name = nr_dlsim.basic +Description = nr_dlsim Test cases. (Test1: 106 PRB), + (Test2: 217 PRB), + (Test3: 273 PRB), + (Test4: HARQ test 25% TP 4 rounds), + (Test5: HARQ test 33% TP 3 rounds), + (Test6: HARQ test 50% TP 2 rounds), + (Test7: 25 PRBs, 15 kHz SCS) +main_exec = ran_build/build//nr_dlsim +main_exec_args = -n100 -R106 -b106 -s5 + -n100 -R217 -b217 -s5 + -n100 -R273 -b273 -s5 + -n100 -s1 -S2 -t25 + -n100 -s1 -S2 -t33 + -n100 -s5 -S7 -t50 + -n100 -m0 -e0 -R25 -b25 -i 2 1 0 +search_expr_true = PDSCH test OK +search_expr_false = segmentation fault|assertion|exiting|fatal +tags = test1 test2 test3 test4 test5 test6 test7 +nruns = 3 +i = PDSCH test OK +Test1: 106 PRB +Executing test case nr_dlsim.basic.test1, Run Index = 1, Execution Log file = /home/oai/openairinterface5g/cmake_targets/autotests/log/nr_dlsim.basic/test.nr_dlsim.basic.test1.run_1 +Executing test case nr_dlsim.basic.test1, Run Index = 2, Execution Log file = /home/oai/openairinterface5g/cmake_targets/autotests/log/nr_dlsim.basic/test.nr_dlsim.basic.test1.run_2 +Executing test case nr_dlsim.basic.test1, Run Index = 3, Execution Log file = /home/oai/openairinterface5g/cmake_targets/autotests/log/nr_dlsim.basic/test.nr_dlsim.basic.test1.run_3 +[...] +nr_dlsim.basic.test1 RUN = 1 Result = PASS +nr_dlsim.basic.test1 RUN = 2 Result = PASS +nr_dlsim.basic.test1 RUN = 3 Result = PASS +execution nr_dlsim.basic.test1 {Test1: 106 PRB} Run_Result = " Run_1 =PASS Run_2 =PASS Run_3 =PASS" Result = PASS +``` + +You see: +- the `Description` of the test cases (here, 7 tests) +- the executable that is used, and the parameters (`main_exec` and + `main_exec_args`), for instance `-n100 -R106 -b106 -s5` for `Test1` +- what is the condition for a successful test +- where are the log files +- if the tests passed or not `PASS`, otherwise `FAIL` and a summary for the + three runs. + +## How to change the parameters + +You can modify the parameters in `autotests/test_case_list.xml`. To learn about +their meaning, run the simulator manually with flag `-h` ("help"). For +instance, for the above run, it would be + +```bash +ran_build/build/nr_dlsim -h +``` + +## How to change the code + +You can modify the source files to adapt to your needs. For instance, for +`nr_dlsim` above, refer to file `openair1/SIMULATION/NR_PHY/dlsim.c`. + +# CI + +These tests are run in this pipeline: +[RAN-PhySim-Cluster](https://jenkins-oai.eurecom.fr/job/RAN-PhySim-Cluster/). From 0077d219fbc576eed3af2da23bc320d17a985f55 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 3 Jun 2024 17:01:43 +0200 Subject: [PATCH 26/26] CI DeployObject: don't grep, just give service name With the capabilities now given as part of this MR, it happens that when checking the "docker compose config", the container_name might not be close to the service name. Something like service: cap_drop: ... cap_add: ... container_name: This is inconvenient, as the previous grep for the service name + 3 lines might not cover the service name. To circumvent this, give the service name directly in "docker compose config". (no clue why it has not been done like this from the start) --- ci-scripts/cls_containerize.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 75a421495e..f0503c0160 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -897,9 +897,7 @@ class Containerize(): mySSH.command(f'docker compose --file ci-docker-compose.yml up -d -- {svcName}', '\$', 30) # Checking Status - grep = '' - if svcName != '': grep = f' | grep -A3 --color=never {svcName}' - mySSH.command(f'docker compose --file ci-docker-compose.yml config {grep}', '\$', 5) + mySSH.command(f'docker compose --file ci-docker-compose.yml config {svcName}', '\$', 5) result = re.search('container_name: (?P[a-zA-Z0-9\-\_]+)', mySSH.getBefore()) unhealthyNb = 0 healthyNb = 0