From a1b4220a916a1c67c2e63b0b9e11abe261aa82f2 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 27 Nov 2025 14:39:01 +0100 Subject: [PATCH 1/2] Exclusively use OAI_RNGSEED env variable everywhere Hide normal table initialization of Ziggurat generator from outside to force the usage of randominit() for RNG initialization. In this step, remove the randominit() seed parameter and only rely on OAI_RNGSEED for a consistent RNG initialization, as this parameter was used differently ("0" as fixed number or to force a random seed). Now, only use OAI_RNGSEED env variable to force the usage of a fixed seed. --- doc/environment-variables.md | 3 +- executables/lte-softmodem.c | 1 - executables/lte-uesoftmodem.c | 1 - executables/nr-softmodem.c | 1 - executables/nr-uesoftmodem.c | 1 - openair1/PHY/CODING/TESTBENCH/ldpctest.c | 2 +- openair1/PHY/CODING/TESTBENCH/ltetest.c | 4 +-- openair1/PHY/CODING/TESTBENCH/pdcch_test.c | 5 ++-- openair1/PHY/CODING/TESTBENCH/polartest.c | 2 +- .../PHY/CODING/TESTBENCH/smallblocktest.c | 2 +- openair1/PHY/INIT/lte_param_init.c | 2 +- openair1/PHY/TOOLS/tests/test_dft.c | 1 + openair1/SIMULATION/LTE_PHY/framegen.c | 2 +- openair1/SIMULATION/LTE_PHY/syncsim.c | 2 +- openair1/SIMULATION/LTE_PHY/test.c | 2 +- openair1/SIMULATION/LTE_PHY/ulsim.c | 3 +- openair1/SIMULATION/LTE_PHY/ulsim2.c | 2 +- openair1/SIMULATION/NR_PHY/dlschsim.c | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 28 ++++--------------- openair1/SIMULATION/NR_PHY/prachsim.c | 2 +- openair1/SIMULATION/NR_PHY/psbchsim.c | 6 ++-- openair1/SIMULATION/NR_PHY/pucchsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 2 +- openair1/SIMULATION/RF/rf.c | 2 +- openair1/SIMULATION/TOOLS/ch_desc_proto.c | 2 +- openair1/SIMULATION/TOOLS/random_channel.c | 5 ---- openair1/SIMULATION/TOOLS/rangen_double.c | 25 +++++++++-------- openair1/SIMULATION/TOOLS/sim.h | 3 +- radio/rfsimulator/simulator.c | 16 +---------- 31 files changed, 47 insertions(+), 88 deletions(-) diff --git a/doc/environment-variables.md b/doc/environment-variables.md index 767afa6db4..6fb7b884ae 100644 --- a/doc/environment-variables.md +++ b/doc/environment-variables.md @@ -9,7 +9,8 @@ OAI uses/supports a number of environment variables, documented in the following - `NVRAM_DIR`: directory to read/write NVRAM data in (5G) `nvram` tool; if not defined, will use `PWD` (working directory) - `OAI_CONFIGMODULE`: can be used to pass the configuration file instead of `-O` - `OAI_GDBSTACKS`: if defined when hitting an assertion (`DevAssert()`, `AssertFatal()`, ...), OAI will load `gdb` and provide a backtrace for every thread -- `OAI_RNGSEED`: overwrites any seed for random number generators (RNG) in simulators +- `OAI_RNGSEED`: provide a fixed seed for random number generators (RNG). If + this variable is absent, a random seed will be read (from `/dev/urandom`). - `USIM_DIR`: directory to read/write USIM data in (4G) `usim` tool; if not defined, will use `PWD` (working directory) Furthermore, these variables appear in code that is not maintained and maybe not even compiled anywhere: diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c index 6ff535fb5b..e2c4144707 100644 --- a/executables/lte-softmodem.c +++ b/executables/lte-softmodem.c @@ -405,7 +405,6 @@ int main ( int argc, char **argv ) #if T_TRACER T_Config_Init(); #endif - //randominit (0); set_taus_seed (0); printf("configuring for RAU/RRU\n"); diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index f36bdde2b5..fc741ec300 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -492,7 +492,6 @@ int main( int argc, char **argv ) { #if T_TRACER T_Config_Init(); #endif - //randominit (0); set_taus_seed (0); cpuf=get_cpu_freq_GHz(); pthread_cond_init(&sync_cond,NULL); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 125bfbd898..ee20c68efe 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -546,7 +546,6 @@ int main( int argc, char **argv ) { #if T_TRACER T_Config_Init(); #endif - //randominit (0); set_taus_seed (0); cpuf=get_cpu_freq_GHz(); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index ca6c48dbef..f1cc659cae 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -340,7 +340,6 @@ int main(int argc, char **argv) T_Config_Init(); #endif initTpool(get_softmodem_params()->threadPoolConfig, &(nrUE_params.Tpool), cpumeas(CPUMEAS_GETSTATE)); - //randominit (0); set_taus_seed (0); if (!has_cap_sys_nice()) diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 97b39beaf8..4dddaf7e7e 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -438,7 +438,7 @@ int main(int argc, char *argv[]) int n_trials = 1; double SNR_step = 0.1; - randominit(0); + randominit(); int test_uncoded = 0; n_iter_stats_t dec_iter[400] = {0}; diff --git a/openair1/PHY/CODING/TESTBENCH/ltetest.c b/openair1/PHY/CODING/TESTBENCH/ltetest.c index 45abec1697..97d66de486 100644 --- a/openair1/PHY/CODING/TESTBENCH/ltetest.c +++ b/openair1/PHY/CODING/TESTBENCH/ltetest.c @@ -72,7 +72,7 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx,unsigned char transmi PHY_vars_UE = malloc(sizeof(PHY_VARS_UE)); mac_xface = malloc(sizeof(MAC_xface)); - randominit(0); + randominit(); set_taus_seed(0); lte_frame_parms = &(PHY_vars_eNB->lte_frame_parms); @@ -367,7 +367,7 @@ int main(int argc, char *argv[]) int num_pdcch_symbols = 1; int subframe = 6; - randominit(0); + randominit(); logInit(); lte_param_init(1,1,1,0,0,3); diff --git a/openair1/PHY/CODING/TESTBENCH/pdcch_test.c b/openair1/PHY/CODING/TESTBENCH/pdcch_test.c index 873e9e19bc..2a752bfee8 100644 --- a/openair1/PHY/CODING/TESTBENCH/pdcch_test.c +++ b/openair1/PHY/CODING/TESTBENCH/pdcch_test.c @@ -47,7 +47,7 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx) PHY_config = malloc(sizeof(PHY_CONFIG)); mac_xface = malloc(sizeof(MAC_xface)); - randominit(0); + randominit(); set_taus_seed(0); lte_frame_parms = &(PHY_config->lte_frame_parms); @@ -241,8 +241,7 @@ int main(int argc, char *argv[]) PHY_vars = malloc(sizeof(PHY_VARS)); mac_xface = malloc(sizeof(MAC_xface)); - - randominit(0); + randominit(); set_taus_seed(0); ccodelte_init(); diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index e84a62775b..cb51f85aca 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -125,7 +125,7 @@ int main(int argc, char *argv[]) cpu_meas_enabled = 1; reset_meas(&timeEncoder); reset_meas(&timeDecoder); - randominit(0); + randominit(); crcTableInit(); if (polarMessageType == 0) { // PBCH diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c index a701a49d1a..275262428c 100644 --- a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) cpu_meas_enabled = 1; reset_meas(&timeEncoder); reset_meas(&timeDecoder); - randominit(0); + randominit(); int ret = 1; int arguments, iterations = 1000, messageLength = 11; diff --git a/openair1/PHY/INIT/lte_param_init.c b/openair1/PHY/INIT/lte_param_init.c index 81177a63cb..d2d963ade4 100644 --- a/openair1/PHY/INIT/lte_param_init.c +++ b/openair1/PHY/INIT/lte_param_init.c @@ -77,7 +77,7 @@ void lte_param_init(PHY_VARS_eNB **eNBp, eNB->RU_list[0] = ru; ru->num_eNB=1; srand(0); - randominit(0); + randominit(); set_taus_seed(0); frame_parms = &(eNB->frame_parms); frame_parms->N_RB_DL = N_RB_DL; //50 for 10MHz and 25 for 5 MHz diff --git a/openair1/PHY/TOOLS/tests/test_dft.c b/openair1/PHY/TOOLS/tests/test_dft.c index 8b4c344c6c..abcb0c05f7 100644 --- a/openair1/PHY/TOOLS/tests/test_dft.c +++ b/openair1/PHY/TOOLS/tests/test_dft.c @@ -70,6 +70,7 @@ void math_dft(cd_t *in, cd_t *out, int len) int main(void) { int ret = 0; + randominit(); load_dftslib(); c16_t *d16 = malloc16(12 * dftFtab[sizeofArray(dftFtab) - 1].size * sizeof(*d16)); c16_t *o16 = malloc16(12 * dftFtab[sizeofArray(dftFtab) - 1].size * sizeof(*d16)); diff --git a/openair1/SIMULATION/LTE_PHY/framegen.c b/openair1/SIMULATION/LTE_PHY/framegen.c index fe1c4b49b7..30fc6d5745 100644 --- a/openair1/SIMULATION/LTE_PHY/framegen.c +++ b/openair1/SIMULATION/LTE_PHY/framegen.c @@ -378,7 +378,7 @@ void lte_param_init( unsigned char transmission_mode, mac_xface->get_dci_sdu = get_dci; mac_xface->get_dlsch_sdu = get_DLSCH_pdu; - randominit(0); + randominit(); set_taus_seed(0); lte_frame_parms = &(PHY_vars_eNB_g[0]->lte_frame_parms); diff --git a/openair1/SIMULATION/LTE_PHY/syncsim.c b/openair1/SIMULATION/LTE_PHY/syncsim.c index ccdac230f8..456bc53a2c 100644 --- a/openair1/SIMULATION/LTE_PHY/syncsim.c +++ b/openair1/SIMULATION/LTE_PHY/syncsim.c @@ -249,7 +249,7 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx,unsigned char transmi PHY_vars_UE[1] = malloc(sizeof(PHY_VARS_UE)); //PHY_config = malloc(sizeof(PHY_CONFIG)); mac_xface = malloc(sizeof(MAC_xface)); - randominit(0); + randominit(); set_taus_seed(0); lte_frame_parms = &(PHY_vars_eNB->lte_frame_parms); lte_frame_parms->N_RB_DL = N_RB_DL; //50 for 10MHz and 25 for 5 MHz diff --git a/openair1/SIMULATION/LTE_PHY/test.c b/openair1/SIMULATION/LTE_PHY/test.c index 6b78dad4e7..b292279860 100644 --- a/openair1/SIMULATION/LTE_PHY/test.c +++ b/openair1/SIMULATION/LTE_PHY/test.c @@ -174,7 +174,7 @@ int main(int argc, char **argv) for (i = 0; i<4; i++) ch[i] = (struct complexd*) malloc(channel_length * sizeof(struct complexd)); - randominit(0); + randominit(); set_taus_seed(0); #ifdef RF diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 76cc2e0716..7a442a4082 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -839,8 +839,7 @@ int main(int argc, char **argv) { ack_errors=0; cqi_crc_falsepositives=0; cqi_crc_falsenegatives=0; - round=0; - //randominit(0); + round = 0; harq_pid = subframe2harq_pid(&UE->frame_parms,proc_rxtx_ue->frame_tx,subframe); input_buffer_length = UE->ulsch[0]->harq_processes[harq_pid]->TBS/8; diff --git a/openair1/SIMULATION/LTE_PHY/ulsim2.c b/openair1/SIMULATION/LTE_PHY/ulsim2.c index e994d4fc36..32c0d4d8e9 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim2.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim2.c @@ -232,7 +232,7 @@ int main(int argc, char **argv) //LOG_M("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); // multipath channel - randominit(0); + randominit(); for (i=0; inb_antennas_tx; aa++) { diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index ea4a068b6e..d760e2394b 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -141,7 +141,7 @@ int main(int argc, char **argv) } // logInit(); - randominit(0); + randominit(); int c; while ((c = getopt(argc, argv, "--:O:df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:X:")) != -1) { diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 82984657d3..78ba2c6096 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -393,7 +393,7 @@ int main(int argc, char **argv) exit_fun("[NR_DLSIM] Error, configuration module init failed\n"); } - randominit(0); + randominit(); int print_perf = 0; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index c86744afaa..30905619a7 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -176,8 +176,6 @@ int main(int argc, char **argv) float target_error_rate = 0.01; - int seed = 0; - cpuf = get_cpu_freq_GHz(); if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) { @@ -185,8 +183,7 @@ int main(int argc, char **argv) } int c; - while ((c = getopt (argc, argv, "--:O:c:F:g:hIL:m:M:n:N:o:P:r:R:s:S:x:y:z:")) != -1) { - + while ((c = getopt(argc, argv, "--:O:c:F:g:hIL:m:M:n:N:o:P:R:s:S:x:y:z:")) != -1) { /* ignore long options starting with '--', option '-O' and their arguments that are handled by configmodule */ /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ if (c == 1 || c == '-' || c == 'O') @@ -312,20 +309,6 @@ int main(int argc, char **argv) printf("Illegal PBCH phase (0-3) got %d\n",pbch_phase); break; - /* - case 'r': - ricean_factor = pow(10,-.1*atof(optarg)); - if (ricean_factor>1) { - printf("Ricean factor must be between 0 and 1\n"); - exit(-1); - } - break; - */ - - case 'r': - seed = atoi(optarg); - break; - case 'R': N_RB_DL = atoi(optarg); break; @@ -379,8 +362,10 @@ int main(int argc, char **argv) default: case 'h': - printf("%s -F input_filename -g channel_mod -h(elp) -I(nitial sync) -L log_lvl -n n_frames -M SSBs -n frames -N cell_id -o FO -P phase -r seed -R RBs -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant\n", - argv[0]); + printf( + "OAI_RNGSEED=xxx ./%s -F input_filename -g channel_mod -h(elp) -I(nitial sync) -L log_lvl -n n_frames -M SSBs -n frames " + "-N cell_id -o FO -P phase -R RBs -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant\n", + argv[0]); //printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); printf("-c SSB subcarrier offset\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); @@ -401,7 +386,6 @@ int main(int argc, char **argv) //printf("-O oversampling factor (1,2,4,8,16)\n"); //printf("-p Use extended prefix mode\n"); printf("-P PBCH phase, allowed values 0-3\n"); - printf("-r set the random number generator seed (default: 0 = current time)\n"); printf("-R N_RB_DL\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if not -S given. If -n 1, then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); @@ -414,7 +398,7 @@ int main(int argc, char **argv) } } - randominit(seed); + randominit(); logInit(); set_glog(loglvl); diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index aba532a80d..9fd9757f9d 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -162,7 +162,7 @@ int main(int argc, char **argv){ exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); } - randominit(0); + randominit(); int c; while ((c = getopt (argc, argv, "--:O:hHaA:Cc:l:r:p:g:m:n:s:S:t:x:y:v:V:z:N:F:d:Z:L:R:E")) != -1) { diff --git a/openair1/SIMULATION/NR_PHY/psbchsim.c b/openair1/SIMULATION/NR_PHY/psbchsim.c index 17c3473eb8..fc5280559e 100644 --- a/openair1/SIMULATION/NR_PHY/psbchsim.c +++ b/openair1/SIMULATION/NR_PHY/psbchsim.c @@ -325,15 +325,13 @@ int main(int argc, char **argv) // int frame_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms; - int seed = 0; - cpuf = get_cpu_freq_GHz(); if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) { exit_fun("[NR_PSBCHSIM] Error, configuration module init failed\n"); } - randominit(0); + randominit(); int c; while ((c = getopt(argc, argv, "--:O:c:hn:o:s:FIL:N:R:S:T:")) != -1) { @@ -456,7 +454,7 @@ int main(int argc, char **argv) } } - randominit(seed); + randominit(); logInit(); set_glog(loglvl); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 8c9f2961c4..21d43f48ad 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -151,7 +151,7 @@ int main(int argc, char **argv) exit_fun("[NR_PUCCHSIM] Error, configuration module init failed\n"); } - randominit(0); + randominit(); logInit(); int c; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 77a0046e1f..3705df3b2c 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -139,7 +139,7 @@ int main(int argc, char **argv) } //logInit(); - randominit(0); + randominit(); int c; while ((c = getopt(argc, argv, "--:O:hg:n:s:S:py:z:M:N:R:F:m:l:q:r:W:")) != -1) { diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 85c165b00d..04b3521cf0 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -348,7 +348,7 @@ int main(int argc, char *argv[]) } int ul_proc_error = 0; // uplink processing checking status flag //logInit(); - randominit(0); + randominit(); /* initialize the sin-cos table */ InitSinLUT(); diff --git a/openair1/SIMULATION/RF/rf.c b/openair1/SIMULATION/RF/rf.c index 081a102bbb..e9b49ed8f2 100644 --- a/openair1/SIMULATION/RF/rf.c +++ b/openair1/SIMULATION/RF/rf.c @@ -248,7 +248,7 @@ int main(int argc, char* argv[]) channel_desc_t *channel; srand(0); - randominit(0); + randominit(); set_taus_seed(0); channel = new_channel_desc_scm(nb_antennas, diff --git a/openair1/SIMULATION/TOOLS/ch_desc_proto.c b/openair1/SIMULATION/TOOLS/ch_desc_proto.c index b1e71fcfb4..dbc77a9b9b 100644 --- a/openair1/SIMULATION/TOOLS/ch_desc_proto.c +++ b/openair1/SIMULATION/TOOLS/ch_desc_proto.c @@ -93,7 +93,7 @@ int main() { {3420,2820},{1580,3940},{660,2100},{2740,1180},{2500,2500}, {3580,3580},{3740,3140},{3020,3020},{4340,4140},{980,4300} }; - randominit(0); + randominit(); ///////////////////////////////////////////////////////////////////////////////////////////////// int tabl_len=0; double local_table[MCS_COUNT][9][9]; diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index d13cfd8921..bed23968e4 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -572,11 +572,6 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, double path_loss_dB, float noise_power_dB) { - // To create tables for normal distribution - struct timespec t; - clock_gettime(CLOCK_MONOTONIC, &t); - tableNor((long) (t.tv_nsec % INT_MAX)); - channel_desc_t *chan_desc = (channel_desc_t *)calloc(1,sizeof(channel_desc_t)); for(int i=0; ichannelmod > 0) { // create channel simulation model for this mode reception - static bool init_done = false; - - if (!init_done) { - uint64_t rand; - FILE *h = fopen("/dev/random", "r"); - - if (1 != fread(&rand, sizeof(rand), 1, h)) - LOG_W(HW, "Can't read /dev/random\n"); - - fclose(h); - randominit(rand); - tableNor(rand); - init_done = true; - } char modelname[30]; snprintf(modelname, sizeofArray(modelname), @@ -1170,7 +1156,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { AssertFatal((rfsimulator->epollfd = epoll_create1(0)) != -1, "epoll_create1() failed, errno(%d)", errno); // we need to call randominit() for telnet server (use gaussdouble=>uniformrand) - randominit(0); + randominit(); set_taus_seed(0); /* look for telnet server, if it is loaded, add the channel modeling commands to it */ add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME); From ce7cb165dd6e0382661479eb51bad888cac3e84c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sat, 29 Nov 2025 16:52:14 +0100 Subject: [PATCH 2/2] Fix OAI_RNGSEED to capture unsigned long atoi() used previously does not capture all of unsigned long (so we could not reproduce a high seed), and its use is discouraged as it does not detect errors. Use strtoul() instead, which allows to also use other bases (so we can e.g., write OAI_RNGSEED=0x1234) --- openair1/SIMULATION/TOOLS/rangen_double.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openair1/SIMULATION/TOOLS/rangen_double.c b/openair1/SIMULATION/TOOLS/rangen_double.c index 5f6f898066..9c38e33ce9 100644 --- a/openair1/SIMULATION/TOOLS/rangen_double.c +++ b/openair1/SIMULATION/TOOLS/rangen_double.c @@ -56,7 +56,14 @@ void randominit() unsigned long seed; const char* str_oai_rngseed = getenv("OAI_RNGSEED"); if (str_oai_rngseed != NULL) { - seed = atoi(str_oai_rngseed); + char *end; + seed = strtoul(str_oai_rngseed, &end, 0); /* 0: any base in hex, dec, oct */ + AssertFatal(*end == '\0' || *end == '\n', + "could not read seed %s at char '%c' (%d), pos %ld\n", + str_oai_rngseed, + *end, + *end, + end - str_oai_rngseed); } else { fill_random(&seed, sizeof(seed)); }