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; ...@@ -85,7 +85,6 @@ PHY_VARS_gNB *gNB;
PHY_VARS_NR_UE *UE; PHY_VARS_NR_UE *UE;
RAN_CONTEXT_t RC; RAN_CONTEXT_t RC;
int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
double cpuf; double cpuf;
char *uecap_file; char *uecap_file;
...@@ -110,11 +109,11 @@ void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB ...@@ -110,11 +109,11 @@ void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB
} }
int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
const int CC_id, const int CC_id,
const uint8_t gNB_id, const uint8_t gNB_id,
const frame_t frameP, const frame_t frameP,
const rb_id_t Srb_id, const rb_id_t Srb_id,
uint8_t *buffer_pP) uint8_t *buffer_pP)
{ {
return 0; return 0;
} }
...@@ -275,6 +274,8 @@ int NB_UE_INST = 1; ...@@ -275,6 +274,8 @@ int NB_UE_INST = 1;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FILE *csv_file = NULL;
char *filename_csv = NULL;
setbuf(stdout, NULL); setbuf(stdout, NULL);
int c; int c;
int i,aa;//,l; int i,aa;//,l;
...@@ -351,7 +352,7 @@ int main(int argc, char **argv) ...@@ -351,7 +352,7 @@ int main(int argc, char **argv)
uint16_t rbSize = 106; uint16_t rbSize = 106;
uint8_t mcsIndex = 9; uint8_t mcsIndex = 9;
uint8_t dlsch_threads = 0; uint8_t dlsch_threads = 0;
int chest_type[2] = {0}; int chest_type[2] = {0};
uint8_t max_ldpc_iterations = 5; uint8_t max_ldpc_iterations = 5;
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) { if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) {
exit_fun("[NR_DLSIM] Error, configuration module init failed\n"); exit_fun("[NR_DLSIM] Error, configuration module init failed\n");
...@@ -359,11 +360,11 @@ int main(int argc, char **argv) ...@@ -359,11 +360,11 @@ int main(int argc, char **argv)
randominit(0); randominit(0);
int print_perf = 0; int print_perf = 0;
FILE *scg_fd=NULL; 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) { switch (c) {
case 'f': case 'f':
scg_fd = fopen(optarg,"r"); scg_fd = fopen(optarg,"r");
...@@ -374,10 +375,6 @@ int main(int argc, char **argv) ...@@ -374,10 +375,6 @@ int main(int argc, char **argv)
} }
break; break;
/*case 'd':
frame_type = 1;
break;*/
case 'g': case 'g':
switch ((char)*optarg) { switch ((char)*optarg) {
case 'A': case 'A':
...@@ -545,6 +542,10 @@ int main(int argc, char **argv) ...@@ -545,6 +542,10 @@ int main(int argc, char **argv)
//target_error_rate=0.1; //target_error_rate=0.1;
slot = 0; slot = 0;
break; break;
case 'Z' :
filename_csv = strdup(optarg);
AssertFatal(filename_csv != NULL, "strdup() error: errno %d\n", errno);
break;
case 'o': case 'o':
delay = atoi(optarg); delay = atoi(optarg);
...@@ -552,47 +553,38 @@ int main(int argc, char **argv) ...@@ -552,47 +553,38 @@ int main(int argc, char **argv)
default: default:
case 'h': 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", printf("%s -h(elp)\n", argv[0]);
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("-h This message\n");
printf("-L <log level, 0(errors), 1(warning), 2(analysis), 3(info), 4(debug), 5(trace)>\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("-p Use extended prefix mode\n"); printf("-m Numerology\n");
//printf("-d Use TDD\n");
printf("-n Number of frames to simulate\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 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("-S Ending SNR, runs from SNR0 to SNR1\n");
//printf("-t Delay spread for multipath channel\n"); printf("-t Acceptable effective throughput (in percentage)\n");
printf("-g Channel model: [A] TDLA30, [B] TDLB100, [C] TDLC300, e.g. -g A\n"); printf("-v Maximum number of rounds\n");
printf("-o Introduce delay in terms of number of samples\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("-y Number of TX antennas used in gNB\n");
printf("-z Number of RX antennas used in UE\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("-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("-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("-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("-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("-X gNB thread pool configuration, n => no threads\n");
printf("-Y Run initial sync in UE\n"); printf("-Y Run initial sync in UE\n");
printf("-Z Output filename (.csv format) for stats\n");
exit (-1); exit (-1);
break; break;
} }
...@@ -650,7 +642,7 @@ int main(int argc, char **argv) ...@@ -650,7 +642,7 @@ int main(int argc, char **argv)
// free the memory // free the memory
SEQUENCE_free( &asn_DEF_NR_RRCReconfiguration, NR_RRCReconfiguration, 1 ); SEQUENCE_free( &asn_DEF_NR_RRCReconfiguration, NR_RRCReconfiguration, 1 );
exit(-1); exit(-1);
} }
fclose(scg_fd); fclose(scg_fd);
AssertFatal(NR_RRCReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration,"wrong NR_RRCReconfiguration->criticalExstions.present type\n"); AssertFatal(NR_RRCReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration,"wrong NR_RRCReconfiguration->criticalExstions.present type\n");
...@@ -668,7 +660,7 @@ int main(int argc, char **argv) ...@@ -668,7 +660,7 @@ int main(int argc, char **argv)
// free the memory // free the memory
SEQUENCE_free( &asn_DEF_NR_CellGroupConfig, secondaryCellGroup, 1 ); SEQUENCE_free( &asn_DEF_NR_CellGroupConfig, secondaryCellGroup, 1 );
exit(-1); exit(-1);
} }
NR_ServingCellConfigCommon_t *scc = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon; NR_ServingCellConfigCommon_t *scc = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
*/ */
...@@ -719,8 +711,8 @@ int main(int argc, char **argv) ...@@ -719,8 +711,8 @@ int main(int argc, char **argv)
//xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); //xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface");
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
// common configuration // common configuration
nr_mac_config_scc(RC.nrmac[0], pdsch_AntennaPorts, n_tx, 0, 6, scc); nr_mac_config_scc(RC.nrmac[0], pdsch_AntennaPorts, n_tx, 0, 6, scc);
...@@ -859,11 +851,11 @@ int main(int argc, char **argv) ...@@ -859,11 +851,11 @@ int main(int argc, char **argv)
unsigned int available_bits=0; unsigned int available_bits=0;
unsigned char *estimated_output_bit; unsigned char *estimated_output_bit;
unsigned char *test_input_bit; unsigned char *test_input_bit;
unsigned int errors_bit = 0; unsigned int errors_bit = 0;
initFloatingCoresTpool(dlsch_threads, &nrUE_params.Tpool, false, "UE-tpool"); initFloatingCoresTpool(dlsch_threads, &nrUE_params.Tpool, false, "UE-tpool");
test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
// generate signal // generate signal
...@@ -882,13 +874,13 @@ int main(int argc, char **argv) ...@@ -882,13 +874,13 @@ int main(int argc, char **argv)
memset((void*)&scheduled_response,0,sizeof(scheduled_response)); memset((void*)&scheduled_response,0,sizeof(scheduled_response));
dcireq.module_id = 0; dcireq.module_id = 0;
dcireq.gNB_index = 0; dcireq.gNB_index = 0;
dcireq.cc_id = 0; dcireq.cc_id = 0;
scheduled_response.dl_config = &dcireq.dl_config_req; scheduled_response.dl_config = &dcireq.dl_config_req;
scheduled_response.ul_config = &dcireq.ul_config_req; scheduled_response.ul_config = &dcireq.ul_config_req;
scheduled_response.tx_request = NULL; scheduled_response.tx_request = NULL;
scheduled_response.module_id = 0; scheduled_response.module_id = 0;
scheduled_response.CC_id = 0; scheduled_response.CC_id = 0;
scheduled_response.frame = frame; scheduled_response.frame = frame;
scheduled_response.slot = slot; scheduled_response.slot = slot;
scheduled_response.phy_data = &phy_data; scheduled_response.phy_data = &phy_data;
...@@ -925,6 +917,20 @@ int main(int argc, char **argv) ...@@ -925,6 +917,20 @@ int main(int argc, char **argv)
uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment
UE->phy_sim_dlsch_b = calloc(1, dlsch_bytes); 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) { for (SNR = snr0; SNR < snr1; SNR += .2) {
varArray_t *table_tx=initVarArray(1000,sizeof(double)); varArray_t *table_tx=initVarArray(1000,sizeof(double));
...@@ -959,12 +965,12 @@ int main(int argc, char **argv) ...@@ -959,12 +965,12 @@ int main(int argc, char **argv)
//multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0); //multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0);
UE->rx_offset=0; UE->rx_offset=0;
UE_proc.frame_rx = frame; UE_proc.frame_rx = frame;
UE_proc.nr_slot_rx = slot; UE_proc.nr_slot_rx = slot;
UE_proc.gNB_id = 0; UE_proc.gNB_id = 0;
dcireq.frame = frame; dcireq.frame = frame;
dcireq.slot = slot; dcireq.slot = slot;
NR_UE_DLSCH_t *dlsch0 = &phy_data.dlsch[0]; NR_UE_DLSCH_t *dlsch0 = &phy_data.dlsch[0];
...@@ -1057,7 +1063,6 @@ int main(int argc, char **argv) ...@@ -1057,7 +1063,6 @@ int main(int argc, char **argv)
slot); slot);
} }
} }
if (n_trials==1) { if (n_trials==1) {
char filename[100];//LOG_M char filename[100];//LOG_M
for (aa=0;aa<n_tx;aa++) { for (aa=0;aa<n_tx;aa++) {
...@@ -1111,7 +1116,6 @@ int main(int argc, char **argv) ...@@ -1111,7 +1116,6 @@ int main(int argc, char **argv)
pdsch_processing(UE, pdsch_processing(UE,
&UE_proc, &UE_proc,
&phy_data); &phy_data);
//---------------------------------------------------------- //----------------------------------------------------------
//---------------------- count errors ---------------------- //---------------------- count errors ----------------------
//---------------------------------------------------------- //----------------------------------------------------------
...@@ -1163,7 +1167,6 @@ int main(int argc, char **argv) ...@@ -1163,7 +1167,6 @@ int main(int argc, char **argv)
} }
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
if (errors_bit > 0) { if (errors_bit > 0) {
...@@ -1201,7 +1204,13 @@ int main(int argc, char **argv) ...@@ -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(") 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");
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) { if (print_perf==1) {
printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, block %d)\n", printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, block %d)\n",
1000 >> *scc->ssbSubcarrierSpacing, 1000 >> *scc->ssbSubcarrierSpacing,
...@@ -1223,7 +1232,6 @@ int main(int argc, char **argv) ...@@ -1223,7 +1232,6 @@ int main(int argc, char **argv)
printStatIndent2(&gNB->dlsch_resource_mapping_stats, "DLSCH Resource Mapping time"); printStatIndent2(&gNB->dlsch_resource_mapping_stats, "DLSCH Resource Mapping time");
printStatIndent2(&gNB->dlsch_precoding_stats,"DLSCH Layer Precoding time"); printStatIndent2(&gNB->dlsch_precoding_stats,"DLSCH Layer Precoding time");
printf("\nUE RX function statistics (per %d us slot)\n",1000>>*scc->ssbSubcarrierSpacing); printf("\nUE RX function statistics (per %d us slot)\n",1000>>*scc->ssbSubcarrierSpacing);
/* /*
printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx"); printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx");
...@@ -1257,7 +1265,7 @@ int main(int argc, char **argv) ...@@ -1257,7 +1265,7 @@ int main(int argc, char **argv)
} }
if (n_trials == 1) { if (n_trials == 1) {
LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1); LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1);
if (UE->frame_parms.nb_antennas_rx>1) if (UE->frame_parms.nb_antennas_rx>1)
LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1); LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1);
...@@ -1313,6 +1321,12 @@ int main(int argc, char **argv) ...@@ -1313,6 +1321,12 @@ int main(int argc, char **argv)
if (scg_fd) if (scg_fd)
fclose(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; return n_errs;
} }
......
...@@ -74,7 +74,6 @@ const char *__asan_default_options() ...@@ -74,7 +74,6 @@ const char *__asan_default_options()
/* don't do leak checking in nr_ulsim, not finished yet */ /* don't do leak checking in nr_ulsim, not finished yet */
return "detect_leaks=0"; return "detect_leaks=0";
} }
PHY_VARS_gNB *gNB; PHY_VARS_gNB *gNB;
PHY_VARS_NR_UE *UE; PHY_VARS_NR_UE *UE;
RAN_CONTEXT_t RC; RAN_CONTEXT_t RC;
...@@ -153,8 +152,9 @@ int NB_UE_INST = 1; ...@@ -153,8 +152,9 @@ int NB_UE_INST = 1;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FILE *csv_file = NULL;
int c; char *filename_csv = NULL;
char c;
int i; int i;
double SNR, snr0 = -2.0, snr1 = 2.0; double SNR, snr0 = -2.0, snr1 = 2.0;
double sigma, sigma_dB; double sigma, sigma_dB;
...@@ -168,8 +168,6 @@ int main(int argc, char *argv[]) ...@@ -168,8 +168,6 @@ int main(int argc, char *argv[])
int trial, n_trials = 1, n_false_positive = 0, delay = 0; int trial, n_trials = 1, n_false_positive = 0, delay = 0;
double maxDoppler = 0.0; double maxDoppler = 0.0;
uint8_t n_tx = 1, n_rx = 1; uint8_t n_tx = 1, n_rx = 1;
//uint8_t transmission_mode = 1;
//uint16_t Nid_cell = 0;
channel_desc_t *UE2gNB; channel_desc_t *UE2gNB;
uint8_t extended_prefix_flag = 0; uint8_t extended_prefix_flag = 0;
//int8_t interf1 = -21, interf2 = -21; //int8_t interf1 = -21, interf2 = -21;
...@@ -235,14 +233,10 @@ int main(int argc, char *argv[]) ...@@ -235,14 +233,10 @@ int main(int argc, char *argv[])
/* initialize the sin-cos table */ /* initialize the sin-cos table */
InitSinLUT(); 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); printf("handling optarg %c\n",c);
switch (c) { switch (c) {
/*case 'd':
frame_type = 1;
break;*/
case 'a': case 'a':
start_symbol = atoi(optarg); start_symbol = atoi(optarg);
AssertFatal(start_symbol >= 0 && start_symbol < 13,"start_symbol %d is not in 0..12\n",start_symbol); AssertFatal(start_symbol >= 0 && start_symbol < 13,"start_symbol %d is not in 0..12\n",start_symbol);
...@@ -261,11 +255,11 @@ int main(int argc, char *argv[]) ...@@ -261,11 +255,11 @@ int main(int argc, char *argv[])
case 'd': case 'd':
delay = atoi(optarg); delay = atoi(optarg);
break; break;
case 'e': case 'e':
msg3_flag = 1; msg3_flag = 1;
break; break;
case 'f': case 'f':
scg_fd = fopen(optarg, "r"); scg_fd = fopen(optarg, "r");
...@@ -320,7 +314,7 @@ int main(int argc, char *argv[]) ...@@ -320,7 +314,7 @@ int main(int argc, char *argv[])
printf("Maximum Doppler Frequency: %.0f Hz\n", maxDoppler); printf("Maximum Doppler Frequency: %.0f Hz\n", maxDoppler);
} }
break; break;
case 'i': case 'i':
i=0; i=0;
do { do {
...@@ -334,10 +328,6 @@ int main(int argc, char *argv[]) ...@@ -334,10 +328,6 @@ int main(int argc, char *argv[])
openair0_cfg[0].threequarter_fs= 1; openair0_cfg[0].threequarter_fs= 1;
break; break;
case 'l':
nb_symb_sch = atoi(optarg);
break;
case 'm': case 'm':
Imcs = atoi(optarg); Imcs = atoi(optarg);
break; break;
...@@ -353,7 +343,7 @@ int main(int argc, char *argv[]) ...@@ -353,7 +343,7 @@ int main(int argc, char *argv[])
case 'o': case 'o':
ldpc_offload_flag = 1; ldpc_offload_flag = 1;
break; break;
case 'p': case 'p':
extended_prefix_flag = 1; extended_prefix_flag = 1;
break; break;
...@@ -365,7 +355,7 @@ int main(int argc, char *argv[]) ...@@ -365,7 +355,7 @@ int main(int argc, char *argv[])
case 'r': case 'r':
nb_rb = atoi(optarg); nb_rb = atoi(optarg);
break; break;
case 's': case 's':
snr0 = atof(optarg); snr0 = atof(optarg);
printf("Setting SNR0 to %f\n", snr0); printf("Setting SNR0 to %f\n", snr0);
...@@ -392,20 +382,6 @@ int main(int argc, char *argv[]) ...@@ -392,20 +382,6 @@ int main(int argc, char *argv[])
eff_tp_check = atof(optarg); eff_tp_check = atof(optarg);
break; 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': case 'y':
n_tx = atoi(optarg); n_tx = atoi(optarg);
if ((n_tx == 0) || (n_tx > 4)) { if ((n_tx == 0) || (n_tx > 4)) {
...@@ -413,7 +389,7 @@ int main(int argc, char *argv[]) ...@@ -413,7 +389,7 @@ int main(int argc, char *argv[])
exit(-1); exit(-1);
} }
break; break;
case 'z': case 'z':
n_rx = atoi(optarg); n_rx = atoi(optarg);
if ((n_rx == 0) || (n_rx > 8)) { if ((n_rx == 0) || (n_rx > 8)) {
...@@ -445,27 +421,23 @@ int main(int argc, char *argv[]) ...@@ -445,27 +421,23 @@ int main(int argc, char *argv[])
case 'M': case 'M':
ilbrm = atoi(optarg); ilbrm = atoi(optarg);
break; break;
case 'N':
// Nid_cell = atoi(optarg);
break;
case 'R': case 'R':
N_RB_DL = atoi(optarg); N_RB_DL = atoi(optarg);
N_RB_UL = N_RB_DL; N_RB_UL = N_RB_DL;
break; break;
case 'S': case 'S':
snr1 = atof(optarg); snr1 = atof(optarg);
snr1set = 1; snr1set = 1;
printf("Setting SNR1 to %f\n", snr1); printf("Setting SNR1 to %f\n", snr1);
break; break;
case 'P': case 'P':
print_perf=1; print_perf=1;
opp_enabled=1; opp_enabled=1;
break; break;
case 'L': case 'L':
loglvl = atoi(optarg); loglvl = atoi(optarg);
break; break;
...@@ -492,6 +464,11 @@ int main(int argc, char *argv[]) ...@@ -492,6 +464,11 @@ int main(int argc, char *argv[])
params_from_file = 1; params_from_file = 1;
break; break;
case 'X' :
filename_csv = strdup(optarg);
AssertFatal(filename_csv != NULL, "strdup() error: errno %d\n", errno);
break;
case 'Z': case 'Z':
transform_precoding = transformPrecoder_enabled; transform_precoding = transformPrecoder_enabled;
num_dmrs_cdm_grps_no_data = 2; num_dmrs_cdm_grps_no_data = 2;
...@@ -513,46 +490,47 @@ int main(int argc, char *argv[]) ...@@ -513,46 +490,47 @@ int main(int argc, char *argv[])
default: default:
case 'h': 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("%s -h(elp)\n", argv[0]);
//printf("-d Use TDD\n"); 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("-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("-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("-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("-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("-k 3/4 sampling\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("-m MCS value\n"); printf("-m MCS value\n");
printf("-n Number of trials to simulate\n"); printf("-n Number of trials to simulate\n");
printf("-o ldpc offload flag\n"); printf("-o ldpc offload flag\n");
printf("-p Use extended prefix mode\n"); printf("-p Use extended prefix mode\n");
printf("-q MCS table\n"); printf("-q MCS table\n");
printf("-r Number of allocated resource blocks for PUSCH\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("-u Set the numerology\n");
printf("-v Set the max rounds\n");
printf("-w Start PRB for PUSCH\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("-y Number of TX antennas used at UE\n");
printf("-z Number of RX antennas used at gNB\n"); printf("-z Number of RX antennas used at gNB\n");
printf("-v Set the max rounds\n"); printf("-C Specify the number of threads for the simulation\n");
printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); printf("-E {SRS: [0] Disabled, [1] Enabled} e.g. -E 1\n");
//printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
printf("-F Input filename (.txt format) for RX conformance testing\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("-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("-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("-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("-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("-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("-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("-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); exit(-1);
break; break;
...@@ -768,7 +746,7 @@ int main(int argc, char *argv[]) ...@@ -768,7 +746,7 @@ int main(int argc, char *argv[])
uint8_t crc_status = 0; uint8_t crc_status = 0;
unsigned char mod_order = nr_get_Qm_ul(Imcs, mcs_table); unsigned char mod_order = nr_get_Qm_ul(Imcs, mcs_table);
uint16_t code_rate = nr_get_code_rate_ul(Imcs, mcs_table); uint16_t code_rate = nr_get_code_rate_ul(Imcs, mcs_table);
uint8_t mapping_type = typeB; // Default Values uint8_t mapping_type = typeB; // Default Values
pusch_dmrs_type_t dmrs_config_type = pusch_dmrs_type1; // Default Values pusch_dmrs_type_t dmrs_config_type = pusch_dmrs_type1; // Default Values
...@@ -792,11 +770,11 @@ int main(int argc, char *argv[]) ...@@ -792,11 +770,11 @@ int main(int argc, char *argv[])
num_dmrs_cdm_grps_no_data = dmrs_arg[3]; num_dmrs_cdm_grps_no_data = dmrs_arg[3];
} }
uint8_t length_dmrs = pusch_len1; uint8_t length_dmrs = pusch_len1;
uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs, start_symbol, NR_MIB__dmrs_TypeA_Position_pos2); uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs, start_symbol, NR_MIB__dmrs_TypeA_Position_pos2);
uint16_t number_dmrs_symbols = get_dmrs_symbols_in_slot(l_prime_mask, nb_symb_sch); uint16_t number_dmrs_symbols = get_dmrs_symbols_in_slot(l_prime_mask, nb_symb_sch);
printf("num dmrs sym %d\n",number_dmrs_symbols); printf("num dmrs sym %d\n",number_dmrs_symbols);
uint8_t nb_re_dmrs = (dmrs_config_type == pusch_dmrs_type1) ? 6 : 4; uint8_t nb_re_dmrs = (dmrs_config_type == pusch_dmrs_type1) ? 6 : 4;
uint32_t tbslbrm = 0; uint32_t tbslbrm = 0;
if (ilbrm) if (ilbrm)
...@@ -813,17 +791,17 @@ int main(int argc, char *argv[]) ...@@ -813,17 +791,17 @@ int main(int argc, char *argv[])
int8_t index = get_index_for_dmrs_lowpapr_seq((NR_NB_SC_PER_RB/2) * nb_rb); int8_t index = get_index_for_dmrs_lowpapr_seq((NR_NB_SC_PER_RB/2) * nb_rb);
AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n"); AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n");
dmrs_config_type = pusch_dmrs_type1; dmrs_config_type = pusch_dmrs_type1;
nb_re_dmrs = 6; nb_re_dmrs = 6;
printf("[ULSIM]: TRANSFORM PRECODING ENABLED. Num RBs: %d, index for DMRS_SEQ: %d\n", nb_rb, index); printf("[ULSIM]: TRANSFORM PRECODING ENABLED. Num RBs: %d, index for DMRS_SEQ: %d\n", nb_rb, index);
} }
nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data; nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data;
unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, precod_nbr_layers); unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, precod_nbr_layers);
unsigned int TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers); unsigned int TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers);
printf("[ULSIM]: length_dmrs: %u, l_prime_mask: %u number_dmrs_symbols: %u, mapping_type: %u add_pos: %d \n", length_dmrs, l_prime_mask, number_dmrs_symbols, mapping_type, add_pos); printf("[ULSIM]: length_dmrs: %u, l_prime_mask: %u number_dmrs_symbols: %u, mapping_type: %u add_pos: %d \n", length_dmrs, l_prime_mask, number_dmrs_symbols, mapping_type, add_pos);
...@@ -842,7 +820,7 @@ int main(int argc, char *argv[]) ...@@ -842,7 +820,7 @@ int main(int argc, char *argv[])
uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, Imcs, mcs_table); uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, Imcs, mcs_table);
uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, nb_rb); uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, nb_rb);
int ptrs_symbols = 0; // to calculate total PTRS RE's in a slot int ptrs_symbols = 0; // to calculate total PTRS RE's in a slot
double ts = 1.0/(frame_parms->subcarrier_spacing * frame_parms->ofdm_symbol_size); double ts = 1.0/(frame_parms->subcarrier_spacing * frame_parms->ofdm_symbol_size);
...@@ -927,6 +905,20 @@ int main(int argc, char *argv[]) ...@@ -927,6 +905,20 @@ int main(int argc, char *argv[])
code_rate = nr_get_code_rate_ul(Imcs, mcs_table); 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; int ret = 1;
for (SNR = snr0; SNR <= snr1; SNR += snr_step) { for (SNR = snr0; SNR <= snr1; SNR += snr_step) {
...@@ -1549,6 +1541,10 @@ int main(int argc, char *argv[]) ...@@ -1549,6 +1541,10 @@ int main(int argc, char *argv[])
roundStats/=((float)n_trials); roundStats/=((float)n_trials);
effRate /= (double)n_trials; effRate /= (double)n_trials;
// -------csv file-------
// adding values into file
printf("*****************************************\n"); printf("*****************************************\n");
printf("SNR %f: n_errors (%d/%d", SNR, n_errors[0], round_trials[0]); printf("SNR %f: n_errors (%d/%d", SNR, n_errors[0], round_trials[0]);
for (int r = 1; r < max_rounds; r++) for (int r = 1; r < max_rounds; r++)
...@@ -1560,6 +1556,7 @@ int main(int argc, char *argv[]) ...@@ -1560,6 +1556,7 @@ int main(int argc, char *argv[])
printf(")\n"); printf(")\n");
printf("\n"); printf("\n");
for (int r = 0; r < max_rounds; r++) { for (int r = 0; r < max_rounds; r++) {
blerStats[r] = (double)n_errors[r] / round_trials[r]; blerStats[r] = (double)n_errors[r] / round_trials[r];
berStats[r] = (double)errors_scrambling[r] / available_bits/round_trials[r]; berStats[r] = (double)errors_scrambling[r] / available_bits/round_trials[r];
...@@ -1571,6 +1568,7 @@ int main(int argc, char *argv[]) ...@@ -1571,6 +1568,7 @@ int main(int argc, char *argv[])
printf(" Channel BER (%e", berStats[0]); printf(" Channel BER (%e", berStats[0]);
for (int r = 1; r < max_rounds; r++) for (int r = 1; r < max_rounds; r++)
printf(",%e", berStats[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(") 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", printf("DMRS-PUSCH delay estimation: min %i, max %i, average %f\n",
...@@ -1578,7 +1576,13 @@ int main(int argc, char *argv[]) ...@@ -1578,7 +1576,13 @@ int main(int argc, char *argv[])
printf("*****************************************\n"); printf("*****************************************\n");
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"); FILE *fd=fopen("nr_ulsim.log","w");
if (fd == NULL) { if (fd == NULL) {
printf("Problem with filename %s\n", "nr_ulsim.log"); printf("Problem with filename %s\n", "nr_ulsim.log");
...@@ -1628,7 +1632,6 @@ int main(int argc, char *argv[]) ...@@ -1628,7 +1632,6 @@ int main(int argc, char *argv[])
break; break;
} }
} // SNR loop } // SNR loop
printf("\n"); printf("\n");
printf( "Num RB:\t%d\n" printf( "Num RB:\t%d\n"
"Num symbols:\t%d\n" "Num symbols:\t%d\n"
...@@ -1660,5 +1663,11 @@ int main(int argc, char *argv[]) ...@@ -1660,5 +1663,11 @@ int main(int argc, char *argv[])
if (scg_fd) if (scg_fd)
fclose(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; 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