Commit 32e4d66c authored by Nada Bouknana's avatar Nada Bouknana Committed by Robert Schmidt

Improve nr_dlsim/nr_ulsim help message and CSV file logs

- Reorder help messages
- Add possibility to log results per SNR to CSV file with `-X` or `-Z`
- Reformat files
Co-authored-by: default avatarMoadMaroufi <maaroufi.moaad321@gmail.com>
Co-authored-by: default avatarfrancescomani <email@francescomani.it>
Co-authored-by: default avatarRobert Schmidt <robert.schmidt@openairinterface.org>
parent afc75c5d
......@@ -85,7 +85,6 @@ PHY_VARS_gNB *gNB;
PHY_VARS_NR_UE *UE;
RAN_CONTEXT_t RC;
int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
double cpuf;
char *uecap_file;
......@@ -275,6 +274,8 @@ int NB_UE_INST = 1;
int main(int argc, char **argv)
{
FILE *csv_file = NULL;
char *filename_csv = NULL;
setbuf(stdout, NULL);
int c;
int i,aa;//,l;
......@@ -363,7 +364,7 @@ int main(int argc, char **argv)
FILE *scg_fd=NULL;
while ((c = getopt(argc, argv, "f:hA:p:f:g:i:n:s:S:t:v:x:y:z:o:M:N:F:GR:d:PI:L:a:b:e:m:w:T:U:q:X:Y")) != -1) {
while ((c = getopt(argc, argv, "f:hA:p:f:g:i:n:s:S:t:v:x:y:z:o:M:N:F:GR:d:PI:L:a:b:e:m:w:T:U:q:X:Y:Z:")) != -1) {
switch (c) {
case 'f':
scg_fd = fopen(optarg,"r");
......@@ -374,10 +375,6 @@ int main(int argc, char **argv)
}
break;
/*case 'd':
frame_type = 1;
break;*/
case 'g':
switch ((char)*optarg) {
case 'A':
......@@ -545,6 +542,10 @@ int main(int argc, char **argv)
//target_error_rate=0.1;
slot = 0;
break;
case 'Z' :
filename_csv = strdup(optarg);
AssertFatal(filename_csv != NULL, "strdup() error: errno %d\n", errno);
break;
case 'o':
delay = atoi(optarg);
......@@ -552,47 +553,38 @@ int main(int argc, char **argv)
default:
case 'h':
printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n",
argv[0]);
printf("%s -h(elp)\n", argv[0]);
printf("-a Start PRB for PDSCH\n");
printf("-b Number of PRB for PDSCH\n");
printf("-d number of dlsch threads, 0: no dlsch parallelization\n");
printf("-e MSC index\n");
printf("-f raw file containing RRC configuration (generated by gNB)\n");
printf("-g Channel model: [A] TDLA30, [B] TDLB100, [C] TDLC300, e.g. -g A\n");
printf("-h This message\n");
printf("-L <log level, 0(errors), 1(warning), 2(analysis), 3(info), 4(debug), 5(trace)>\n");
//printf("-p Use extended prefix mode\n");
//printf("-d Use TDD\n");
printf("-i Change channel estimation technique. Arguments list: Frequency domain {0:Linear interpolation, 1:PRB based averaging}, Time domain {0:Estimates of last DMRS symbol, 1:Average of DMRS symbols}\n");
printf("-m Numerology\n");
printf("-n Number of frames to simulate\n");
printf("-o Introduce delay in terms of number of samples\n");
printf("-p Precoding matrix index\n");
printf("-q MCS Table index\n");
printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
//printf("-t Delay spread for multipath channel\n");
printf("-g Channel model: [A] TDLA30, [B] TDLB100, [C] TDLC300, e.g. -g A\n");
printf("-o Introduce delay in terms of number of samples\n");
printf("-t Acceptable effective throughput (in percentage)\n");
printf("-v Maximum number of rounds\n");
printf("-w Write txdata to binary file (one frame)\n");
printf("-x Num of layer for PDSCH\n");
printf("-y Number of TX antennas used in gNB\n");
printf("-z Number of RX antennas used in UE\n");
printf("-x Num of layer for PDSCH\n");
printf("-p Precoding matrix index\n");
printf("-i Change channel estimation technique. Arguments list: Frequency domain {0:Linear interpolation, 1:PRB based averaging}, Time domain {0:Estimates of last DMRS symbol, 1:Average of DMRS symbols}\n");
//printf("-j Relative strength of second intefering gNB (in dB) - cell_id mod 3 = 2\n");
printf("-R N_RB_DL\n");
printf("-O oversampling factor (1,2,4,8,16)\n");
printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
//printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
printf("-f raw file containing RRC configuration (generated by gNB)\n");
printf("-F Input filename (.txt format) for RX conformance testing\n");
printf("-o CORESET offset\n");
printf("-a Start PRB for PDSCH\n");
printf("-b Number of PRB for PDSCH\n");
printf("-c Start symbol for PDSCH (fixed for now)\n");
printf("-j Number of symbols for PDSCH (fixed for now)\n");
printf("-e MSC index\n");
printf("-q MCS Table index\n");
printf("-t Acceptable effective throughput (in percentage)\n");
printf("-I Maximum LDPC decoder iterations\n");
printf("-L <log level, 0(errors), 1(warning), 2(analysis), 3(info), 4(debug), 5(trace)>\n");
printf("-P Print DLSCH performances\n");
printf("-R N_RB_DL\n");
printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n");
printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n");
printf("-P Print DLSCH performances\n");
printf("-v Maximum number of rounds\n");
printf("-w Write txdata to binary file (one frame)\n");
printf("-d number of dlsch threads, 0: no dlsch parallelization\n");
printf("-X gNB thread pool configuration, n => no threads\n");
printf("-Y Run initial sync in UE\n");
printf("-Z Output filename (.csv format) for stats\n");
exit (-1);
break;
}
......@@ -925,6 +917,20 @@ int main(int argc, char **argv)
uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment
UE->phy_sim_dlsch_b = calloc(1, dlsch_bytes);
// csv file
if (filename_csv != NULL) {
csv_file = fopen(filename_csv, "a");
if (csv_file == NULL) {
printf("Can't open file \"%s\", errno %d\n", filename_csv, errno);
return 1;
}
// adding name of parameters into file
fprintf(csv_file,"SNR,false_positive,");
for (int r = 0; r < num_rounds; r++)
fprintf(csv_file,"n_errors_%d,errors_scrambling_%d,channel_bler_%d,channel_ber_%d,",r,r,r,r);
fprintf(csv_file,"avg_round,eff_rate,eff_throughput,TBS\n");
}
//---------------
for (SNR = snr0; SNR < snr1; SNR += .2) {
varArray_t *table_tx=initVarArray(1000,sizeof(double));
......@@ -1057,7 +1063,6 @@ int main(int argc, char **argv)
slot);
}
}
if (n_trials==1) {
char filename[100];//LOG_M
for (aa=0;aa<n_tx;aa++) {
......@@ -1111,7 +1116,6 @@ int main(int argc, char **argv)
pdsch_processing(UE,
&UE_proc,
&phy_data);
//----------------------------------------------------------
//---------------------- count errors ----------------------
//----------------------------------------------------------
......@@ -1163,7 +1167,6 @@ int main(int argc, char **argv)
}
}
////////////////////////////////////////////////////////////
if (errors_bit > 0) {
......@@ -1201,7 +1204,13 @@ int main(int argc, char **argv)
printf(") Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", roundStats, effRate, effRate / TBS * 100, TBS);
printf("*****************************************\n");
printf("\n");
// writing to csv file
if (filename_csv != NULL) { // means we are asked to print stats to CSV
fprintf(csv_file,"%f,%d/%d,",SNR,n_false_positive,n_trials);
for (int r = 0; r < num_rounds; r++)
fprintf(csv_file,"%d/%d,%u/%u,%f,%e,",n_errors[r], round_trials[r], errors_scrambling[r], available_bits * round_trials[r],blerStats[r],berStats[r]);
fprintf(csv_file,"%.2f,%.4f,%.2f,%u\n", roundStats, effRate, effRate / TBS * 100, TBS);
}
if (print_perf==1) {
printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, block %d)\n",
1000 >> *scc->ssbSubcarrierSpacing,
......@@ -1223,7 +1232,6 @@ int main(int argc, char **argv)
printStatIndent2(&gNB->dlsch_resource_mapping_stats, "DLSCH Resource Mapping time");
printStatIndent2(&gNB->dlsch_precoding_stats,"DLSCH Layer Precoding time");
printf("\nUE RX function statistics (per %d us slot)\n",1000>>*scc->ssbSubcarrierSpacing);
/*
printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx");
......@@ -1313,6 +1321,12 @@ int main(int argc, char **argv)
if (scg_fd)
fclose(scg_fd);
// closing csv file
if (filename_csv != NULL) { // means we are asked to print stats to CSV
fclose(csv_file);
free(filename_csv);
}
return n_errs;
}
......
......@@ -74,7 +74,6 @@ const char *__asan_default_options()
/* don't do leak checking in nr_ulsim, not finished yet */
return "detect_leaks=0";
}
PHY_VARS_gNB *gNB;
PHY_VARS_NR_UE *UE;
RAN_CONTEXT_t RC;
......@@ -153,8 +152,9 @@ int NB_UE_INST = 1;
int main(int argc, char *argv[])
{
int c;
FILE *csv_file = NULL;
char *filename_csv = NULL;
char c;
int i;
double SNR, snr0 = -2.0, snr1 = 2.0;
double sigma, sigma_dB;
......@@ -168,8 +168,6 @@ int main(int argc, char *argv[])
int trial, n_trials = 1, n_false_positive = 0, delay = 0;
double maxDoppler = 0.0;
uint8_t n_tx = 1, n_rx = 1;
//uint8_t transmission_mode = 1;
//uint16_t Nid_cell = 0;
channel_desc_t *UE2gNB;
uint8_t extended_prefix_flag = 0;
//int8_t interf1 = -21, interf2 = -21;
......@@ -235,14 +233,10 @@ int main(int argc, char *argv[])
/* initialize the sin-cos table */
InitSinLUT();
while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:kl:m:n:op:q:r:s:t:u:v:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:E:")) != -1) {
while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:k:m:n:op:q:r:s:t:u:v:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:E:X:")) != -1) {
printf("handling optarg %c\n",c);
switch (c) {
/*case 'd':
frame_type = 1;
break;*/
case 'a':
start_symbol = atoi(optarg);
AssertFatal(start_symbol >= 0 && start_symbol < 13,"start_symbol %d is not in 0..12\n",start_symbol);
......@@ -334,10 +328,6 @@ int main(int argc, char *argv[])
openair0_cfg[0].threequarter_fs= 1;
break;
case 'l':
nb_symb_sch = atoi(optarg);
break;
case 'm':
Imcs = atoi(optarg);
break;
......@@ -392,20 +382,6 @@ int main(int argc, char *argv[])
eff_tp_check = atof(optarg);
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 'x':
transmission_mode = atoi(optarg);
break;*/
case 'y':
n_tx = atoi(optarg);
if ((n_tx == 0) || (n_tx > 4)) {
......@@ -446,10 +422,6 @@ int main(int argc, char *argv[])
ilbrm = atoi(optarg);
break;
case 'N':
// Nid_cell = atoi(optarg);
break;
case 'R':
N_RB_DL = atoi(optarg);
N_RB_UL = N_RB_DL;
......@@ -492,6 +464,11 @@ int main(int argc, char *argv[])
params_from_file = 1;
break;
case 'X' :
filename_csv = strdup(optarg);
AssertFatal(filename_csv != NULL, "strdup() error: errno %d\n", errno);
break;
case 'Z':
transform_precoding = transformPrecoder_enabled;
num_dmrs_cdm_grps_no_data = 2;
......@@ -513,46 +490,47 @@ int main(int argc, char *argv[])
default:
case 'h':
printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -i Intefrence0 -j Interference1 -n n_frames -s snr0 -S snr1 -t Delayspread -x transmission_mode -y TXant -z RXant -A interpolation_file -C(alibration offset dB) -N CellId -Z Enable SC-FDMA in Uplink \n", argv[0]);
//printf("-d Use TDD\n");
printf("%s -h(elp)\n", argv[0]);
printf("-a ULSCH starting symbol\n");
printf("-b ULSCH number of symbols\n");
printf("-c RNTI\n");
printf("-d Introduce delay in terms of number of samples\n");
printf("-f Number of frames to simulate\n");
printf("-e To simulate MSG3 configuration\n");
printf("-f Input file to read from\n");// file not used in the code
printf("-g Channel model configuration. Arguments list: Number of arguments = 3, {Channel model: [A] TDLA30, [B] TDLB100, [C] TDLC300}, {Correlation: [l] Low, [m] Medium, [h] High}, {Maximum Doppler shift} e.g. -g A,l,10\n");
printf("-h This message\n");
printf("-i Change channel estimation technique. Arguments list: Number of arguments=2, Frequency domain {0:Linear interpolation, 1:PRB based averaging}, Time domain {0:Estimates of last DMRS symbol, 1:Average of DMRS symbols}. e.g. -i 1,0\n");
//printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-k 3/4 sampling\n");
printf("-m MCS value\n");
printf("-n Number of trials to simulate\n");
printf("-o ldpc offload flag\n");
printf("-p Use extended prefix mode\n");
printf("-q MCS table\n");
printf("-r Number of allocated resource blocks for PUSCH\n");
printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-t Acceptable effective throughput (in percentage)\n");
printf("-u Set the numerology\n");
printf("-v Set the max rounds\n");
printf("-w Start PRB for PUSCH\n");
//printf("-x Transmission mode (1,2,6 for the moment)\n");
printf("-y Number of TX antennas used at UE\n");
printf("-z Number of RX antennas used at gNB\n");
printf("-v Set the max rounds\n");
printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
//printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
printf("-C Specify the number of threads for the simulation\n");
printf("-E {SRS: [0] Disabled, [1] Enabled} e.g. -E 1\n");
printf("-F Input filename (.txt format) for RX conformance testing\n");
printf("-G Offset of samples to read from file (0 default)\n");
printf("-L <log level, 0(errors), 1(warning), 2(info) 3(debug) 4 (trace)>\n");
printf("-H Slot number\n");
printf("-I Maximum LDPC decoder iterations\n");
printf("-L <log level, 0(errors), 1(warning), 2(info) 3(debug) 4 (trace)>\n");
printf("-M Use limited buffer rate-matching\n");
printf("-N Nid_cell\n");
printf("-O oversampling factor (1,2,4,8,16)\n");
printf("-R Maximum number of available resorce blocks (N_RB_DL)\n");
printf("-t Acceptable effective throughput (in percentage)\n");
printf("-P Print ULSCH performances\n");
printf("-Q If -F used, read parameters from file\n");
printf("-R Maximum number of available resorce blocks (N_RB_DL)\n");
printf("-T Enable PTRS, arguments list: Number of arguments=2 L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 0,2 \n");
printf("-U Change DMRS Config, arguments list: Number of arguments=4, DMRS Mapping Type{0=A,1=B}, DMRS AddPos{0:3}, DMRS Config Type{1,2}, Number of CDM groups without data{1,2,3} e.g. -U 0,2,0,1 \n");
printf("-Q If -F used, read parameters from file\n");
printf("-Z If -Z is used, SC-FDMA or transform precoding is enabled in Uplink \n");
printf("-W Num of layer for PUSCH\n");
printf("-E {SRS: [0] Disabled, [1] Enabled} e.g. -E 1\n");
printf("-X Output filename (.csv format) for stats\n");
printf("-Z If -Z is used, SC-FDMA or transform precoding is enabled in Uplink \n");
exit(-1);
break;
......@@ -927,6 +905,20 @@ int main(int argc, char *argv[])
code_rate = nr_get_code_rate_ul(Imcs, mcs_table);
}
// csv file
if (filename_csv != NULL) {
csv_file = fopen(filename_csv, "a");
if (csv_file == NULL) {
printf("Can't open file \"%s\", errno %d\n", filename_csv, errno);
return 1;
}
// adding name of parameters into file
fprintf(csv_file,"SNR,false_positive,");
for (int r = 0; r < max_rounds; r++)
fprintf(csv_file,"n_errors_%d,errors_scrambling_%d,channel_bler_%d,channel_ber_%d,",r,r,r,r);
fprintf(csv_file,"avg_round,eff_rate,eff_throughput,TBS,DMRS-PUSCH delay estimation: (min,max,average)\n");
}
//---------------
int ret = 1;
for (SNR = snr0; SNR <= snr1; SNR += snr_step) {
......@@ -1549,6 +1541,10 @@ int main(int argc, char *argv[])
roundStats/=((float)n_trials);
effRate /= (double)n_trials;
// -------csv file-------
// adding values into file
printf("*****************************************\n");
printf("SNR %f: n_errors (%d/%d", SNR, n_errors[0], round_trials[0]);
for (int r = 1; r < max_rounds; r++)
......@@ -1560,6 +1556,7 @@ int main(int argc, char *argv[])
printf(")\n");
printf("\n");
for (int r = 0; r < max_rounds; r++) {
blerStats[r] = (double)n_errors[r] / round_trials[r];
berStats[r] = (double)errors_scrambling[r] / available_bits/round_trials[r];
......@@ -1571,6 +1568,7 @@ int main(int argc, char *argv[])
printf(" Channel BER (%e", berStats[0]);
for (int r = 1; r < max_rounds; r++)
printf(",%e", berStats[r]);
printf(") Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", roundStats,effRate,effTP,TBS);
printf("DMRS-PUSCH delay estimation: min %i, max %i, average %f\n",
......@@ -1578,7 +1576,13 @@ int main(int argc, char *argv[])
printf("*****************************************\n");
printf("\n");
// writing to csv file
if (filename_csv) { // means we are asked to print stats to CSV
fprintf(csv_file,"%f,%d/%d,",SNR,n_false_positive,n_trials);
for (int r = 0; r < max_rounds; r++)
fprintf(csv_file,"%d/%d,%u/%u,%f,%e,",n_errors[r], round_trials[r], errors_scrambling[r], available_bits * round_trials[r],blerStats[r],berStats[r]);
fprintf(csv_file,"%.2f,%.4f,%.2f,%u,(%i,%i,%f)\n", roundStats, effRate, effTP, TBS,min_pusch_delay >> 1, max_pusch_delay >> 1, (double)sum_pusch_delay / (2 * delay_pusch_est_count));
}
FILE *fd=fopen("nr_ulsim.log","w");
if (fd == NULL) {
printf("Problem with filename %s\n", "nr_ulsim.log");
......@@ -1628,7 +1632,6 @@ int main(int argc, char *argv[])
break;
}
} // SNR loop
printf("\n");
printf( "Num RB:\t%d\n"
"Num symbols:\t%d\n"
......@@ -1660,5 +1663,11 @@ int main(int argc, char *argv[])
if (scg_fd)
fclose(scg_fd);
// closing csv file
if (filename_csv != NULL) { // means we are asked to print stats to CSV
fclose(csv_file);
free(filename_csv);
}
return ret;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment