diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c index 28879cae27..960ad10667 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c @@ -120,7 +120,7 @@ int lte_est_timing_advance_pusch(PHY_VARS_eNB *eNB,module_id_t UE_id) RU_t *ru; ru = RC.ru[UE_id]; LTE_DL_FRAME_PARMS *frame_parms = (eNB==NULL) ? &ru->frame_parms : &eNB->frame_parms; - LTE_eNB_PUSCH *eNB_pusch_vars = eNB->pusch_vars[UE_id]; + LTE_eNB_PUSCH *eNB_pusch_vars = (eNB!=NULL) ? eNB->pusch_vars[UE_id] : (LTE_eNB_PUSCH*)NULL; RU_CALIBRATION *calibration = &ru->calibration; int32_t **ul_ch_estimates_time = (eNB==NULL) ? calibration->drs_ch_estimates_time : eNB_pusch_vars->drs_ch_estimates_time; uint8_t cyclic_shift = 0; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 2730d65f6c..b44a04eb74 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -705,7 +705,7 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet #ifdef DEBUG_DLSCH_CODING - printf("encoding thinks this is a new packet for harq_pid %d (%p), A %d \n",harq_pid,dlsch,A); + printf("encoding thinks this is a new packet for harq_pid %d (%p), A %u \n",harq_pid,dlsch,A); #endif /* int i; diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index a4154a5277..ed5e3ea3e2 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -407,7 +407,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint PRACH_BLOCK_SIZE_BYTES); } } - if (frame == 0) LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, + if (*frame == 0) LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, dB_fixed(signal_energy((int*)&prach_rxsigF[0][0],839))); for (idx=0;idxnum_eNB;idx++) ru->wakeup_prach_eNB(ru->eNB_list[idx],ru,*frame,*subframe); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7728ace5dd..8538945eda 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -2528,7 +2528,7 @@ UE_is_to_be_scheduled(module_id_t module_idP, if (UE_template->scheduled_ul_bytes < UE_template->estimated_ul_buffer || UE_template->ul_SR > 0 || // uplink scheduling request - (UE_sched_ctl->ul_inactivity_timer > 20 && UE_sched_ctl->ul_scheduled == 0) || // every 2 frames when RRC_CONNECTED + (UE_sched_ctl->ul_inactivity_timer > 19 && UE_sched_ctl->ul_scheduled == 0) || // every 2 frames when RRC_CONNECTED (UE_sched_ctl->ul_inactivity_timer > 10 && UE_sched_ctl->ul_scheduled == 0 && mac_eNB_get_rrc_status(module_idP, diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c deleted file mode 100644 index f3636ee96a..0000000000 --- a/targets/SIMU/USER/channel_sim.c +++ /dev/null @@ -1,626 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include -#include -#include -#include -#include -#include - -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" -#include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "UTIL/LOG/log_if.h" -#include "UTIL/LOG/log_extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" -#include "UTIL/OCG/OCG.h" -#include "UTIL/OPT/opt.h" // to test OPT -#endif - -#include "UTIL/FIFO/types.h" - -#ifdef IFFT_FPGA -#include "PHY/LTE_REFSIG/mod_table.h" -#endif - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#ifdef XFORMS -#include "forms.h" -#include "phy_procedures_sim_form.h" -#endif - -#include "oaisim.h" - -#define RF -#define DEBUG_SIM -/* -#undef LOG_D -#define LOG_D(A,B,C...) printf(B,C) -*/ - -int number_rb_ul; -int first_rbUL ; - -extern Signal_buffers_t *signal_buffers_g; - - -double r_re_DL[NUMBER_OF_UE_MAX][2][30720]; -double r_im_DL[NUMBER_OF_UE_MAX][2][30720]; -double r_re_UL[NUMBER_OF_eNB_MAX][2][30720]; -double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; -int RU_output_mask[NUMBER_OF_UE_MAX]; -int UE_output_mask[NUMBER_OF_RU_MAX]; -pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; -pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; - -double ru_amp[NUMBER_OF_RU_MAX]; - -void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs], - node_desc_t *enb_data[NUMBER_OF_RU_MAX], - node_desc_t *ue_data[NUMBER_OF_UE_MAX], - uint16_t subframe, - uint32_t offset, - uint32_t length, - uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *ue_frame_parms, - uint8_t UE_id, - int CC_id) -{ - - int32_t att_eNB_id=-1; - int32_t **txdata,**rxdata; - - uint32_t eNB_id,ru_id=0; - double tx_pwr; - double rx_pwr; - int32_t rx_pwr2; - uint32_t i,aa; - uint32_t sf_offset; - - double min_path_loss=-200; - uint8_t hold_channel=0; - uint8_t nb_antennas_rx = RU2UE[0][0][CC_id]->nb_rx; // number of rx antennas at UE - uint8_t nb_antennas_tx = RU2UE[0][0][CC_id]->nb_tx; // number of tx antennas at eNB - - double s_re0[30720]; - double s_re1[30720]; - double *s_re[2]; - double s_im0[30720]; - double s_im1[30720]; - double *s_im[2]; - double r_re00[30720]; - double r_re01[30720]; - double *r_re0[2]; - double r_im00[30720]; - double r_im01[30720]; - double *r_im0[2]; - LTE_DL_FRAME_PARMS *frame_parms; - - s_re[0] = s_re0; - s_im[0] = s_im0; - s_re[1] = s_re1; - s_im[1] = s_im1; - - r_re0[0] = r_re00; - r_im0[0] = r_im00; - r_re0[1] = r_re01; - r_im0[1] = r_im01; - - if (subframe==0) - hold_channel = 0; - else - hold_channel = 1; - - if (abstraction_flag != 0) { - //for (UE_id=0;UE_idframe_parms; - - random_channel(RU2UE[ru_id][UE_id][CC_id],abstraction_flag); - /* - for (i=0;inb_taps;i++) - printf("RU2UE[%d][%d]->a[0][%d] = (%f,%f)\n",eNB_id,UE_id,i,RU2UE[eNB_id][UE_id]->a[0][i].x,RU2UE[eNB_id][UE_id]->a[0][i].y); - */ - freq_channel(RU2UE[ru_id][UE_id][CC_id], frame_parms->N_RB_DL,frame_parms->N_RB_DL*12+1); - } - - // find out which eNB the UE is attached to - /* - for (eNB_id=0; eNB_idpdcch_vars[0][0]->crnti,RC.eNB[eNB_id][CC_id])>=0) { - // UE with UE_id is connected to eNb with eNB_id - att_eNB_id=eNB_id; - LOG_D(OCM,"A: UE attached to eNB (UE%d->eNB%d)\n",UE_id,eNB_id); - } - } - */ - // if UE is not attached yet, find assume its the eNB with the smallest pathloss - if (att_eNB_id<0) { - for (eNB_id=0; eNB_idRU_list[ru]->idx; - if (min_path_losspath_loss_dB) { - min_path_loss = RU2UE[ru_id][UE_id][CC_id]->path_loss_dB; - att_eNB_id=eNB_id; - LOG_D(OCM,"B: UE attached to eNB (UE%d->eNB%d)\n",UE_id,eNB_id); - } - } - } - } - - if (att_eNB_id<0) { - LOG_E(OCM,"Cannot find eNB for UE %d, return\n",UE_id); - return; //exit(-1); - } - -#ifdef DEBUG_SIM - rx_pwr = signal_energy_fp2(RU2UE[att_eNB_id][UE_id][CC_id]->ch[0], - RU2UE[att_eNB_id][UE_id][CC_id]->channel_length)*RU2UE[att_eNB_id][UE_id][CC_id]->channel_length; - LOG_D(OCM,"Channel (CCid %d) eNB %d => UE %d : tx_power %d dBm, path_loss %f dB\n", - CC_id,att_eNB_id,UE_id, - frame_parms->pdsch_config_common.referenceSignalPower, - RU2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB); -#endif - - //dlsch_abstraction(PHY_vars_UE_g[UE_id]->sinr_dB, rb_alloc, 8); - // fill in perfect channel estimates - channel_desc_t *desc1 = RU2UE[att_eNB_id][UE_id][CC_id]; - int32_t **dl_channel_est = PHY_vars_UE_g[UE_id][CC_id]->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[0]; - // double scale = pow(10.0,(enb_data[att_eNB_id]->tx_power_dBm + RU2UE[att_eNB_id][UE_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id]->rx_total_gain_dB)/20.0); - double scale = pow(10.0,(frame_parms->pdsch_config_common.referenceSignalPower+RU2UE[att_eNB_id][UE_id][CC_id]->path_loss_dB + (double) PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB)/20.0); - LOG_D(OCM,"scale =%lf (%d dB)\n",scale,(int) (20*log10(scale))); - // freq_channel(desc1,frame_parms->N_RB_DL,nb_samples); - //write_output("channel.m","ch",desc1->ch[0],desc1->channel_length,1,8); - //write_output("channelF.m","chF",desc1->chF[0],nb_samples,1,8); - int count,count1,a_rx,a_tx; - - for(a_tx=0; a_txsymbols_per_tti/2;count++) - for (count=0; count<1; count++) { - for (count1=0; count1N_RB_DL*12; count1++) { - ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count1+(count*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=(int16_t)(desc1->chF[a_rx+(a_tx*nb_antennas_rx)][count1].x*scale); - ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count1+1+(count*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=(int16_t)(desc1->chF[a_rx+(a_tx*nb_antennas_rx)][count1].y*scale) ; - } - } - } - } - - // calculate the SNR for the attached eNB (this assumes eNB always uses PMI stored in eNB_UE_stats; to be improved) - init_snr(RU2UE[att_eNB_id][UE_id][CC_id], enb_data[att_eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB, &PHY_vars_UE_g[UE_id][CC_id]->N0, - PHY_vars_UE_g[UE_id][CC_id]->transmission_mode[att_eNB_id], RC.eNB[att_eNB_id][CC_id]->UE_stats[UE_id].DL_pmi_single, - RC.eNB[att_eNB_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off,RC.eNB[att_eNB_id][CC_id]->frame_parms.N_RB_DL); - - // calculate sinr here - for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - if (att_eNB_id != eNB_id) { - calculate_sinr(RU2UE[eNB_id][UE_id][CC_id], enb_data[eNB_id], ue_data[UE_id], PHY_vars_UE_g[UE_id][CC_id]->sinr_dB, - RC.eNB[att_eNB_id][CC_id]->frame_parms.N_RB_DL); - } - } - } // hold channel - } - else { //abstraction_flag - - - pthread_mutex_lock(&RU_output_mutex[UE_id]); - - if (RU_output_mask[UE_id] == 0) { // This is the first eNodeB for this UE, clear the buffer - for (aa=0; aaframe_parms.samples_per_tti)*sizeof(double)); - memset((void*)r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double)); - } - } - pthread_mutex_unlock(&RU_output_mutex[UE_id]); - - for (ru_id=0; ru_idcommon.txdata; - frame_parms = &RC.ru[ru_id]->frame_parms; - - sf_offset = (subframe*frame_parms->samples_per_tti) + offset; - LOG_D(EMU,">>>>>>>>>>>>>>>>>TXPATH: RU %d : DL_sig reading TX for subframe %d (sf_offset %d, length %d) from %p\n",ru_id,subframe,sf_offset,length,txdata[0]+sf_offset); - int length_meas = frame_parms->ofdm_symbol_size; - if (sf_offset+length <= frame_parms->samples_per_tti*10) { - - tx_pwr = dac_fixed_gain(s_re, - s_im, - txdata, - sf_offset, - nb_antennas_tx, - length, - sf_offset, - length_meas, - 14, - frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE - 0, - &ru_amp[ru_id], - frame_parms->N_RB_DL*12); - - } - else { - tx_pwr = dac_fixed_gain(s_re, - s_im, - txdata, - sf_offset, - nb_antennas_tx, - (frame_parms->samples_per_tti*10)-sf_offset, - sf_offset, - length_meas, - 14, - frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE - 0, - &ru_amp[ru_id], - frame_parms->N_RB_DL*12); - - tx_pwr = dac_fixed_gain(s_re, - s_im, - txdata, - sf_offset, - nb_antennas_tx, - length+sf_offset-(frame_parms->samples_per_tti*10), - sf_offset, - length_meas, - 14, - frame_parms->pdsch_config_common.referenceSignalPower, // dBm/RE - 0, - &ru_amp[ru_id], - frame_parms->N_RB_DL*12); - } -#ifdef DEBUG_SIM - LOG_D(PHY,"[SIM][DL] subframe %d: txp (time) %d dB\n", - subframe,dB_fixed(signal_energy(&txdata[0][sf_offset],length_meas))); - - LOG_D(OCM,"[SIM][DL] RU %d (CCid %d): tx_pwr %.1f dBm/RE (target %d dBm/RE), for subframe %d\n", - ru_id,CC_id, - 10*log10(tx_pwr), - frame_parms->pdsch_config_common.referenceSignalPower, - subframe); - -#endif - tx_pwr = signal_energy_fp(s_re,s_im,nb_antennas_tx, - lengthN_RB_DL); - - //RU2UE[eNB_id][UE_id]->path_loss_dB = 0; - multipath_channel(RU2UE[ru_id][UE_id][CC_id],s_re,s_im,r_re0,r_im0, - length,hold_channel); -#ifdef DEBUG_SIM - rx_pwr = signal_energy_fp2(RU2UE[ru_id][UE_id][CC_id]->ch[0], - RU2UE[ru_id][UE_id][CC_id]->channel_length)*RU2UE[ru_id][UE_id][CC_id]->channel_length; - LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): Channel gain %f dB (%f)\n",ru_id,UE_id,CC_id,10*log10(rx_pwr),rx_pwr); -#endif - - -#ifdef DEBUG_SIM - - for (i=0; ichannel_length; i++) - LOG_D(OCM,"channel(%d,%d)[%d] : (%f,%f)\n",ru_id,UE_id,i,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].x,RU2UE[ru_id][UE_id][CC_id]->ch[0][i].y); - -#endif - - LOG_D(OCM,"[SIM][DL] Channel RU %d => UE %d (CCid %d): tx_power %.1f dBm/RE, path_loss %1.f dB\n", - ru_id,UE_id,CC_id, - (double)frame_parms->pdsch_config_common.referenceSignalPower, - // enb_data[eNB_id]->tx_power_dBm, - RU2UE[ru_id][UE_id][CC_id]->path_loss_dB); - -#ifdef DEBUG_SIM - rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx, - lengthN_RB_DL); - LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr %f dBm/RE (%f dBm RSSI,tx %f dB)for subframe %d (length %d)\n",UE_id, - 10*log10(rx_pwr), - 10*log10(rx_pwr*(double)frame_parms->N_RB_DL*12), - 10*log10(tx_pwr),subframe, - lengthsampling_rate*1e6)-174, - 10*log10(RU2UE[ru_id][UE_id][CC_id]->sampling_rate*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174, - subframe); -#endif - - if (RU2UE[ru_id][UE_id][CC_id]->first_run == 1) - RU2UE[ru_id][UE_id][CC_id]->first_run = 0; - - - // RF model -#ifdef DEBUG_SIM - LOG_D(OCM,"[SIM][DL] UE %d (CCid %d): rx_gain %d dB (-ADC %f) for subframe %d\n",UE_id,CC_id,PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB, - PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB-66.227,subframe); -#endif - - rf_rx_simple(r_re0, - r_im0, - nb_antennas_rx, - length, - 1e3/RU2UE[ru_id][UE_id][CC_id]->sampling_rate, // sampling time (ns) - (double)PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later) - -#ifdef DEBUG_SIM - rx_pwr = signal_energy_fp(r_re0,r_im0, - nb_antennas_rx, - lengthN_RB_DL); - LOG_D(OCM,"[SIM][DL] UE %d : ADC in (RU %d) %f dBm/RE for subframe %d\n", - UE_id,ru_id, - 10*log10(rx_pwr),subframe); -#endif - - - pthread_mutex_lock(&RU_output_mutex[UE_id]); - for (i=0; isamples_per_tti; i++) { - for (aa=0; aaN_RB_DL); - LOG_D(OCM,"[SIM][DL] UE %d : ADC in %f dBm/RE for subframe %d\n",UE_id,10*log10(rx_pwr),subframe); -#endif - - rxdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.rxdata; - sf_offset = (subframe*frame_parms->samples_per_tti)+offset; - - - adc(r_re_p, - r_im_p, - 0, - sf_offset, - rxdata, - nb_antennas_rx, - length, - 12); - -#ifdef DEBUG_SIM - rx_pwr2 = signal_energy(rxdata[0]+sf_offset,lengthN_RB_DL); - LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (ADC out) %f dB/RE (%d) for subframe %d, writing to %p, length %d\n",UE_id, 10*log10((double)rx_pwr2),rx_pwr2,subframe,rxdata,lengthN_RB_DL) ,subframe); -#else - UNUSED_VARIABLE(rx_pwr2); - UNUSED_VARIABLE(tx_pwr); - UNUSED_VARIABLE(rx_pwr); -#endif - - } // RU_output_mask - pthread_mutex_unlock(&RU_output_mutex[UE_id]); - } // ru_id - - } - -} - - -void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs], - node_desc_t *enb_data[NUMBER_OF_RU_MAX],node_desc_t *ue_data[NUMBER_OF_UE_MAX], - uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms, - uint32_t frame,int ru_id,uint8_t CC_id) -{ - - int32_t **txdata,**rxdata; - uint8_t UE_id=0; - - uint8_t nb_antennas_rx = UE2RU[0][0][CC_id]->nb_rx; // number of rx antennas at eNB - uint8_t nb_antennas_tx = UE2RU[0][0][CC_id]->nb_tx; // number of tx antennas at UE - - double tx_pwr, rx_pwr; - int32_t rx_pwr2; - uint32_t i,aa; - uint32_t sf_offset; - - uint8_t hold_channel=0; - - double s_re0[30720]; - double s_re1[30720]; - double *s_re[2]; - double s_im0[30720]; - double s_im1[30720]; - double *s_im[2]; - double r_re00[30720]; - double r_re01[30720]; - double *r_re0[2]; - double r_im00[30720]; - double r_im01[30720]; - double *r_im0[2]; - - s_re[0] = s_re0; - s_im[0] = s_im0; - s_re[1] = s_re1; - s_im[1] = s_im1; - - r_re0[0] = r_re00; - r_im0[0] = r_im00; - r_re0[1] = r_re01; - r_im0[1] = r_im01; - - if (abstraction_flag!=0) { - } else { //without abstraction - - pthread_mutex_lock(&UE_output_mutex[ru_id]); - // Clear RX signal for eNB = eNB_id - for (i=0; isamples_per_tti; i++) { - for (aa=0; aacommon_vars.txdata; - AssertFatal(txdata != NULL,"txdata is null\n"); - sf_offset = subframe*frame_parms->samples_per_tti; - if (((double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe] + - UE2RU[UE_id][ru_id][CC_id]->path_loss_dB) <= -125.0) { - // don't simulate a UE that is too weak - LOG_D(PHY,"[SIM][UL] ULPOWERS UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n", - UE_id, - PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], - PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe], - subframe,sf_offset); - } else { - tx_pwr = dac_fixed_gain((double**)s_re, - (double**)s_im, - txdata, - sf_offset, - nb_antennas_tx, - frame_parms->samples_per_tti, - sf_offset, - frame_parms->ofdm_symbol_size, - 14, - (double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe]-10*log10((double)PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]), - 1, - NULL, - PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]); // This make the previous argument the total power - LOG_D(PHY,"[SIM][UL] ULPOWERS UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n", - UE_id, - 10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]), - PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], - PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe], - subframe,sf_offset); - - - multipath_channel(UE2RU[UE_id][ru_id][CC_id],s_re,s_im,r_re0,r_im0, - frame_parms->samples_per_tti,hold_channel); - - - rx_pwr = signal_energy_fp2(UE2RU[UE_id][ru_id][CC_id]->ch[0], - UE2RU[UE_id][ru_id][CC_id]->channel_length)*UE2RU[UE_id][ru_id][CC_id]->channel_length; - - LOG_D(OCM,"[SIM][UL] subframe %d Channel UE %d => RU %d : %f dB (hold %d,length %d, PL %f)\n",subframe,UE_id,ru_id,10*log10(rx_pwr), - hold_channel,UE2RU[UE_id][ru_id][CC_id]->channel_length, - UE2RU[UE_id][ru_id][CC_id]->path_loss_dB); - - rx_pwr = signal_energy_fp(r_re0,r_im0,nb_antennas_rx,frame_parms->samples_per_tti,0); - LOG_D(OCM,"[SIM][UL] RU %d (%d/%d rx antennas) : rx_pwr %f dBm (tx_pwr - PL %f) for subframe %d, sptti %d\n", - ru_id,nb_antennas_rx,UE2RU[UE_id][ru_id][CC_id]->nb_rx,10*log10(rx_pwr),10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe])+UE2RU[UE_id][ru_id][CC_id]->path_loss_dB,subframe,frame_parms->samples_per_tti); - /* - if (abs(10*log10(rx_pwr)-10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe])-UE2RU[UE_id][ru_id][CC_id]->path_loss_dB)>3) { - write_output("txsig_re.m","s_re",s_re[0],frame_parms->samples_per_tti,1,7); - write_output("txsig_im.m","s_im",s_im[0],frame_parms->samples_per_tti,1,7); - write_output("rxsig_re.m","r_re",r_re0[0],frame_parms->samples_per_tti,1,7); - write_output("rxsig_im.m","r_im",r_im0[0],frame_parms->samples_per_tti,1,7); - exit(-1); - }*/ - - if (UE2RU[UE_id][ru_id][CC_id]->first_run == 1) - UE2RU[UE_id][ru_id][CC_id]->first_run = 0; - - - pthread_mutex_lock(&UE_output_mutex[ru_id]); - for (aa=0; aasamples_per_tti; i++) { - r_re_UL[ru_id][aa][i]+=r_re0[aa][i]; - r_im_UL[ru_id][aa][i]+=r_im0[aa][i]; - } - } - pthread_mutex_unlock(&UE_output_mutex[ru_id]); - } - } //UE_id - - double *r_re_p[2] = {r_re_UL[ru_id][0],r_re_UL[ru_id][1]}; - double *r_im_p[2] = {r_im_UL[ru_id][0],r_im_UL[ru_id][1]}; - - rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0); - LOG_D(OCM,"[SIM][UL] RU %d (%d/%d rx antennas) : rx_pwr %f dBm (before RF) for subframe %d, gain %f\n", - ru_id,nb_antennas_rx,nb_antennas_rx,10*log10(rx_pwr),subframe, - (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx - 66.227); - rf_rx_simple(r_re_p, - r_im_p, - nb_antennas_rx, - frame_parms->samples_per_tti, - 1e3/UE2RU[0][ru_id][CC_id]->sampling_rate, // sampling time (ns) - (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later) - - //#ifdef DEBUG_SIM - rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,frame_parms->samples_per_tti,0);//*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL; - LOG_D(OCM,"[SIM][UL] rx_pwr (ADC in) %f dB for subframe %d (rx_gain %f)\n",10*log10(rx_pwr),subframe, - (double)RC.ru[ru_id]->max_rxgain-(double)RC.ru[ru_id]->att_rx); - //#endif - - rxdata = RC.ru[ru_id]->common.rxdata; - sf_offset = subframe*frame_parms->samples_per_tti; - - - adc(r_re_p, - r_im_p, - 0, - sf_offset, - rxdata, - nb_antennas_rx, - frame_parms->samples_per_tti, - 12); - -#ifdef DEBUG_SIM - rx_pwr2 = signal_energy(rxdata[0]+sf_offset,frame_parms->samples_per_tti)*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL); - LOG_D(OCM,"[SIM][UL] RU %d rx_pwr (ADC out) %f dB (%d) for subframe %d (offset %d) = %p\n",ru_id,10*log10((double)rx_pwr2),rx_pwr2,subframe,sf_offset,rxdata[0]+sf_offset); -#else - UNUSED_VARIABLE(tx_pwr); - UNUSED_VARIABLE(rx_pwr); - UNUSED_VARIABLE(rx_pwr2); -#endif - - } // abstraction_flag==0 - -} - - -void init_channel_vars(LTE_DL_FRAME_PARMS *frame_parms, double ***s_re,double ***s_im,double ***r_re,double ***r_im,double ***r_re0,double ***r_im0) -{ - - int i; - - memset(RU_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX); - for (i=0;i -#include -#include -#include -#include -#include -#include -#include -#include - -#include "event_handler.h" -#include "SIMULATION/RF/defs.h" -#include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/vars.h" - -#include "SIMULATION/ETH_TRANSPORT/proto.h" - -//#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/vars.h" -#include "pdcp.h" -#include "RRC/LITE/vars.h" -#include "RRC/NAS/nas_config.h" - -#include "SCHED/defs.h" -#include "SCHED/vars.h" -#include "system.h" - - -#include "PHY/TOOLS/lte_phy_scope.h" - - -#ifdef SMBV -// Rohde&Schwarz SMBV100A vector signal generator -#include "PHY/TOOLS/smbv.h" -char smbv_fname[] = "smbv_config_file.smbv"; -unsigned short smbv_nframes = 4; // how many frames to configure 1,..,4 -unsigned short config_frames[4] = {2,9,11,13}; -unsigned char smbv_frame_cnt = 0; -uint8_t config_smbv = 0; -char smbv_ip[16]; -#endif - -#include "flexran_agent.h" - - -#include "oaisim_functions.h" - -#include "oaisim.h" -#include "oaisim_config.h" -#include "UTIL/OCG/OCG_extern.h" -#include "cor_SF_sim.h" -#include "UTIL/OMG/omg_constants.h" -#include "UTIL/FIFO/pad_list.h" -#include "enb_app.h" - -#include "../PROC/interface.h" -#include "../PROC/channel_sim_proc.h" -#include "../PROC/Tsync.h" -#include "../PROC/Process.h" - -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "UTIL/OTG/otg_kpi.h" -#include "assertions.h" - -#if defined(ENABLE_ITTI) -# include "intertask_interface.h" -# include "create_tasks.h" -#endif - -#include "T.h" - -/* - DCI0_5MHz_TDD0_t UL_alloc_pdu; - DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; - DCI2_5MHz_2A_L10PRB_TDD_t DLSCH_alloc_pdu1; - DCI2_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu2; -*/ - -#define UL_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,24) -#define CCCH_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,3) -#define RA_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,3) -#define DLSCH_RB_ALLOC 0x1fff - -#define DECOR_DIST 100 -#define SF_VAR 10 - -//constant for OAISIM soft realtime calibration -//#define SF_DEVIATION_OFFSET_NS 100000 /*= 0.1ms : should be as a number of UE */ -//#define SLEEP_STEP_US 100 /* = 0.01ms could be adaptive, should be as a number of UE */ -//#define K 2 /* averaging coefficient */ -//#define TARGET_SF_TIME_NS 1000000 /* 1ms = 1000000 ns */ - -uint8_t usim_test = 0; - -frame_t frame = 0; -char stats_buffer[16384]; -channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; -channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -//Added for PHY abstraction -node_desc_t *enb_data[NUMBER_OF_RU_MAX]; -node_desc_t *ue_data[NUMBER_OF_UE_MAX]; - -pthread_cond_t sync_cond; -pthread_mutex_t sync_mutex; -int sync_var=-1; - -pthread_mutex_t subframe_mutex; -int subframe_ru_mask=0,subframe_UE_mask=0; - -openair0_config_t openair0_cfg[MAX_CARDS]; -uint32_t downlink_frequency[MAX_NUM_CCs][4]; -int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; -openair0_rf_map rf_map[MAX_NUM_CCs]; - -#if defined(ENABLE_ITTI) -volatile int start_eNB = 0; -volatile int start_UE = 0; -#endif -volatile int oai_exit = 0; - - -//int32_t **rxdata; -//int32_t **txdata; - -uint16_t sf_ahead=4; -uint8_t nfapi_mode = 0; - -// Added for PHY abstraction -extern node_list* ue_node_list; -extern node_list* enb_node_list; -extern int pdcp_period, omg_period; - -extern double **s_re, **s_im, **r_re, **r_im, **r_re0, **r_im0; -int map1, map2; -extern double **ShaF; -double snr_dB, sinr_dB, snr_direction; //,sinr_direction; -extern double snr_step; -extern uint8_t set_sinr; -extern uint8_t ue_connection_test; -extern uint8_t set_seed; -extern uint8_t target_dl_mcs; -extern uint8_t target_ul_mcs; -extern uint8_t abstraction_flag; -extern uint8_t ethernet_flag; -extern uint16_t Nid_cell; - - -double cpuf; -#include "threads_t.h" -threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; - -//#ifdef XFORMS -int otg_enabled; -int xforms=0; -//#endif - -time_stats_t oaisim_stats; -time_stats_t oaisim_stats_f; -time_stats_t dl_chan_stats; -time_stats_t ul_chan_stats; - -int emulate_rf = 0; -int numerology = 0; -int codingw = 0; -int fepw = 0; - -// this should reflect the channel models in openair1/SIMULATION/TOOLS/defs.h -mapping small_scale_names[] = { - { "custom", custom }, { "SCM_A", SCM_A }, - { "SCM_B", SCM_B }, { "SCM_C", SCM_C }, - { "SCM_D", SCM_D }, { "EPA", EPA }, - { "EVA", EVA }, { "ETU", ETU }, - { "MBSFN", MBSFN }, { "Rayleigh8", Rayleigh8 }, - { "Rayleigh1", Rayleigh1 }, { "Rayleigh1_800", Rayleigh1_800 }, - { "Rayleigh1_corr", Rayleigh1_corr }, { "Rayleigh1_anticorr", Rayleigh1_anticorr }, - { "Rice8", Rice8 }, { "Rice1", Rice1 }, { "Rice1_corr", Rice1_corr }, - { "Rice1_anticorr", Rice1_anticorr }, { "AWGN", AWGN }, { NULL,-1 } -}; -#if !defined(ENABLE_ITTI) -static void * -sigh (void *arg); -#endif -void -oai_shutdown (void); - -void reset_opp_meas_oaisim (void); - -void wait_eNBs(void) -{ - return; -} - -void -help (void) -{ - printf ("Usage: oaisim -h -a -F -C tdd_config -K [log_file] -V [vcd_file] -R N_RB_DL -e -x transmission_mode -m target_dl_mcs -r(ate_adaptation) -n n_frames -s snr_dB -k ricean_factor -t max_delay -f forgetting factor -A channel_model -z cooperation_flag -u nb_local_ue -U UE mobility -b nb_local_enb -B eNB_mobility -M ethernet_flag -p nb_master -g multicast_group -l log_level -c ocg_enable -T traffic model -D multicast network device\n"); - - printf ("-h provides this help message!\n"); - printf ("-a Activates PHY abstraction mode\n"); - printf ("-A set the multipath channel simulation, options are: SCM_A, SCM_B, SCM_C, SCM_D, EPA, EVA, ETU, Rayleigh8, Rayleigh1, Rayleigh1_corr,Rayleigh1_anticorr, Rice8,, Rice1, AWGN \n"); - printf ("-b Set the number of local eNB\n"); - printf ("-B Set the mobility model for eNB, options are: STATIC, RWP, RWALK, \n"); - printf ("-c [1,2,3,4] Activate the config generator (OCG) to process the scenario descriptor, or give the scenario manually: -c template_1.xml \n"); - printf ("-C [0-6] Sets TDD configuration\n"); - printf ("-e Activates extended prefix mode\n"); - printf ("-E Random number generator seed\n"); - printf ("-f Set the forgetting factor for time-variation\n"); - printf ("-F Activates FDD transmission (TDD is default)\n"); - printf ("-g Set multicast group ID (0,1,2,3) - valid if M is set\n"); - printf ("-G Enable background traffic \n"); - printf ("-H Enable handover operation (default disabled) \n"); - printf ("-I Enable CLI interface (to connect use telnet localhost 1352)\n"); - printf ("-k Set the Ricean factor (linear)\n"); - printf ("-K [log_file] Enable ITTI logging into log_file\n"); - printf ("-l Set the global log level (8:trace, 7:debug, 6:info, 4:warn, 3:error) \n"); - printf ("-L [0-1] 0 to disable new link adaptation, 1 to enable new link adapatation\n"); - printf ("-m Gives a fixed DL mcs for eNB scheduler\n"); - printf ("-M Set the machine ID for Ethernet-based emulation\n"); - printf ("-n Set the number of frames for the simulation. 0 for no limit\n"); - printf ("-O [enb_conf_file] eNB configuration file name\n"); - printf ("-p Set the total number of machine in emulation - valid if M is set\n"); - printf ("-P [trace type] Enable protocol analyzer. Possible values for OPT:\n"); - printf (" - wireshark: Enable tracing of layers above PHY using an UDP socket\n"); - printf (" - pcap: Enable tracing of layers above PHY to a pcap file\n"); - printf (" - tshark: Not implemented yet\n"); - printf ("-q Enable Openair performance profiler \n"); - printf ("-Q Activate and set the MBMS service: 0 : not used (default eMBMS disabled), 1: eMBMS and RRC Connection enabled, 2: eMBMS relaying and RRC Connection enabled, 3: eMBMS enabled, RRC Connection disabled, 4: eMBMS relaying enabled, RRC Connection disabled\n"); - printf ("-R [6,15,25,50,75,100] Sets N_RB_DL\n"); - printf ("-r Activates rate adaptation (DL for now)\n"); - printf ("-s snr_dB set a fixed (average) SNR, this deactivates the openair channel model generator (OCM)\n"); - printf ("-S snir_dB set a fixed (average) SNIR, this deactivates the openair channel model generator (OCM)\n"); - printf ("-t Gives a fixed UL mcs for eNB scheduler\n"); - printf ("-T activate the traffic generator. Valide options are m2m,scbr,mcbr,bcbr,auto_pilot,bicycle_race,open_arena,team_fortress,m2m_traffic,auto_pilot_l,auto_pilot_m,auto_pilot_h,auto_pilot_e,virtual_game_l,virtual_game_m,virtual_game_h,virtual_game_f,alarm_humidity,alarm_smoke,alarm_temperature,openarena_dl,openarena_ul,voip_g711,voip_g729,video_vbr_10mbps,video_vbr_4mbps,video_vbr_2mbp,video_vbr_768kbps,video_vbr_384kbps,video_vbr_192kpbs,background_users\n"); - printf ("-u Set the number of local UE\n"); - printf ("-U Set the mobility model for UE, options are: STATIC, RWP, RWALK\n"); - printf ("-V [vcd_file] Enable VCD dump into vcd_file\n"); - printf ("-w number of CBA groups, if not specified or zero, CBA is inactive\n"); -#ifdef SMBV - printf ("-W IP address to connect to Rohde&Schwarz SMBV100A and configure SMBV from config file. -W0 uses default IP 192.168.12.201\n"); -#else - printf ("-W [Rohde&Schwarz SMBV100A functions disabled. Recompile with SMBV=1]\n"); -#endif - printf ("-x deprecated. Set the transmission mode in config file!\n"); - printf ("-y Set the number of receive antennas at the UE (1 or 2)\n"); - printf ("-Y Set the global log verbosity (none, low, medium, high, full) \n"); - printf ("-z Set the cooperation flag (0 for no cooperation, 1 for delay diversity and 2 for distributed alamouti\n"); - printf ("-Z Reserved\n"); - printf ("--xforms Activate the grapical scope\n"); - -#if T_TRACER - printf ("--T_port [port] use given port\n"); - printf ("--T_nowait don't wait for tracer, start immediately\n"); - printf ("--T_dont_fork to ease debugging with gdb\n"); -#endif -} - -pthread_t log_thread; - -void -log_thread_init (void) -{ - //create log_list - //log_list_init(&log_list); -#ifndef LOG_NO_THREAD - - log_shutdown = 0; - - if ((pthread_mutex_init (&log_lock, NULL) != 0) - || (pthread_cond_init (&log_notify, NULL) != 0)) { - return; - } - - if (pthread_create (&log_thread, NULL, log_thread_function, (void*) NULL) - != 0) { - log_thread_finalize (); - return; - } - -#endif - -} - -//Call it after the last LOG call -int -log_thread_finalize (void) -{ - int err = 0; - -#ifndef LOG_NO_THREAD - - if (pthread_mutex_lock (&log_lock) != 0) { - return -1; - } - - log_shutdown = 1; - - /* Wake up LOG thread */ - if ((pthread_cond_broadcast (&log_notify) != 0) - || (pthread_mutex_unlock (&log_lock) != 0)) { - err = -1; - } - - if (pthread_join (log_thread, NULL) != 0) { - err = -1; - } - - if (pthread_mutex_unlock (&log_lock) != 0) { - err = -1; - } - - if (!err) { - //log_list_free(&log_list); - pthread_mutex_lock (&log_lock); - pthread_mutex_destroy (&log_lock); - pthread_cond_destroy (&log_notify); - } - -#endif - - return err; -} - -#if defined(ENABLE_ITTI) -static void set_cli_start(module_id_t module_idP, uint8_t start) -{ - if (module_idP < NB_eNB_INST) { - oai_emulation.info.cli_start_enb[module_idP] = start; - } else { - oai_emulation.info.cli_start_ue[module_idP - NB_eNB_INST] = start; - } -} -#endif - -#ifdef OPENAIR2 -int omv_write(int pfd, node_list* enb_node_list, node_list* ue_node_list, Data_Flow_Unit omv_data) -{ - module_id_t i; - omv_data.end = 0; - - //omv_data.total_num_nodes = NB_UE_INST + NB_eNB_INST; - for (i = 0; i < NB_eNB_INST; i++) { - if (enb_node_list != NULL) { - omv_data.geo[i].x = (enb_node_list->node->x_pos < 0.0) ? 0.0 : enb_node_list->node->x_pos; - omv_data.geo[i].y = (enb_node_list->node->y_pos < 0.0) ? 0.0 : enb_node_list->node->y_pos; - omv_data.geo[i].z = 1.0; - omv_data.geo[i].mobility_type = oai_emulation.info.omg_model_enb; - omv_data.geo[i].node_type = 0; //eNB - enb_node_list = enb_node_list->next; - omv_data.geo[i].Neighbors = 0; -/* - for (j = NB_RU; j < NB_UE_INST + NB_RU; j++) { - if (is_UE_active (i, j - NB_RU) == 1) { - omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; - omv_data.geo[i].Neighbors++; - LOG_D( - OMG, - "[RU %d][UE %d] is_UE_active(i,j) %d geo (x%d, y%d) num neighbors %d\n", i, j-NB_RU, is_UE_active(i,j-NB_RU), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); - } - } -*/ - } - } - - for (i = NB_RU; i < NB_UE_INST + NB_RU; i++) { - if (ue_node_list != NULL) { - omv_data.geo[i].x = (ue_node_list->node->x_pos < 0.0) ? 0.0 : ue_node_list->node->x_pos; - omv_data.geo[i].y = (ue_node_list->node->y_pos < 0.0) ? 0.0 : ue_node_list->node->y_pos; - omv_data.geo[i].z = 1.0; - omv_data.geo[i].mobility_type = oai_emulation.info.omg_model_ue; - omv_data.geo[i].node_type = 1; //UE - //trial - omv_data.geo[i].state = 1; - omv_data.geo[i].rnti = 88; - omv_data.geo[i].connected_eNB = 0; - omv_data.geo[i].RSRP = 66; - omv_data.geo[i].RSRQ = 55; - omv_data.geo[i].Pathloss = 44; - omv_data.geo[i].RSSI[0] = 33; - omv_data.geo[i].RSSI[1] = 22; - - if ((sizeof(omv_data.geo[0].RSSI) / sizeof(omv_data.geo[0].RSSI[0])) > 2) { - omv_data.geo[i].RSSI[2] = 11; - } - - ue_node_list = ue_node_list->next; - omv_data.geo[i].Neighbors = 0; -/* - for (j = 0; j < NB_RU; j++) { - if (is_UE_active (j, i - NB_RU) == 1) { - omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; - omv_data.geo[i].Neighbors++; - LOG_D( - OMG, - "[UE %d][RU %d] is_UE_active %d geo (x%d, y%d) num neighbors %d\n", i-NB_RU, j, is_UE_active(j,i-NB_RU), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); - } - } -*/ - } - } - - LOG_E(OMG, "pfd %d \n", pfd); - - if (write (pfd, &omv_data, sizeof(struct Data_Flow_Unit)) == -1) - perror ("write omv failed"); - - return 1; -} - -void omv_end(int pfd, Data_Flow_Unit omv_data) -{ - omv_data.end = 1; - - if (write (pfd, &omv_data, sizeof(struct Data_Flow_Unit)) == -1) - perror ("write omv failed"); -} -#endif - -#ifdef OPENAIR2 -int pfd[2]; // fd for omv : fixme: this could be a local var -#endif - -#ifdef OPENAIR2 -static Data_Flow_Unit omv_data; -#endif //ALU -static module_id_t UE_inst = 0; -static module_id_t eNB_inst = 0; -static module_id_t ru_id; - -Packet_OTG_List_t *otg_pdcp_buffer; - -typedef enum l2l1_task_state_e { - L2L1_WAITTING, L2L1_RUNNING, L2L1_TERMINATED, -} l2l1_task_state_t; - -l2l1_task_state_t l2l1_state = L2L1_WAITTING; - -extern openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -extern openair0_timestamp current_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; -extern openair0_timestamp last_eNB_rx_timestamp[NUMBER_OF_eNB_MAX][MAX_NUM_CCs]; -extern openair0_timestamp last_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; - -/*------------------------------------------------------------------------------*/ -void * -l2l1_task (void *args_p) -{ - - int CC_id; - - // Framing variables - int32_t sf; - - //char fname[64], vname[64]; - - //#ifdef XFORMS - // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) - // at eNB 0, an UL scope for every UE - FD_lte_phy_scope_ue *form_ue[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - FD_lte_phy_scope_enb *form_enb[NUMBER_OF_UE_MAX]; - char title[255]; - char xname[32] = "oaisim"; - int xargc = 1; - char *xargv[1]; - //#endif - -#undef PRINT_STATS /* this undef is to avoid gcc warnings */ -#define PRINT_STATS -#ifdef PRINT_STATS - //int len; - FILE *UE_stats[NUMBER_OF_UE_MAX]; - FILE *UE_stats_th[NUMBER_OF_UE_MAX]; - FILE *eNB_stats[NUMBER_OF_eNB_MAX]; - FILE *eNB_avg_thr; - FILE *eNB_l2_stats; - char UE_stats_filename[255]; - char eNB_stats_filename[255]; - char UE_stats_th_filename[255]; - char eNB_stats_th_filename[255]; -#endif - - - if (xforms==1) { - xargv[0] = xname; - fl_initialize (&xargc, xargv, NULL, 0, 0); - eNB_inst = 0; - for (UE_inst = 0; UE_inst < NB_UE_INST; UE_inst++) { - for (CC_id=0;CC_idlte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - - if (PHY_vars_UE_g[UE_inst][CC_id]->use_ia_receiver == 1) { - fl_set_button(form_ue[CC_id][UE_inst]->button_0,1); - fl_set_object_label(form_ue[CC_id][UE_inst]->button_0, "IA Receiver ON"); - fl_set_object_color(form_ue[CC_id][UE_inst]->button_0, FL_GREEN, FL_GREEN); - } - - } - } - } - - -#ifdef PRINT_STATS - - for (UE_inst=0; UE_inst 0) && - (oai_emulation.info.node_function[0] < NGFI_RAU_IF4p5)) { - /* Wait for the initialize message */ - do { - if (message_p != NULL) { - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - - itti_receive_msg (TASK_L2L1, &message_p); - msg_name = ITTI_MSG_NAME (message_p); - LOG_I(EMU, "TASK_L2L1 received %s in state L2L1_WAITTING\n", msg_name); - - switch (ITTI_MSG_ID(message_p)) { - case INITIALIZE_MESSAGE: - l2l1_state = L2L1_RUNNING; - start_eNB = 1; - break; - - case ACTIVATE_MESSAGE: - set_cli_start(ITTI_MSG_INSTANCE (message_p), 1); - break; - - case DEACTIVATE_MESSAGE: - set_cli_start(ITTI_MSG_INSTANCE (message_p), 0); - break; - - case TERMINATE_MESSAGE: - l2l1_state = L2L1_TERMINATED; - break; - - default: - LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); - break; - } - } while (l2l1_state == L2L1_WAITTING); - - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - -#endif - module_id_t UE_id; - - if (abstraction_flag == 1) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) - dl_phy_sync_success (UE_id, 0, 0,1); //UE_id%NB_eNB_INST); - } - - start_meas (&oaisim_stats); - - for (frame = 0; - (l2l1_state != L2L1_TERMINATED) && - ((oai_emulation.info.n_frames_flag == 0) || - (frame < oai_emulation.info.n_frames)); - frame++) { - -#if defined(ENABLE_ITTI) - - do { - // Checks if a message has been sent to L2L1 task - itti_poll_msg (TASK_L2L1, &message_p); - - if (message_p != NULL) { - msg_name = ITTI_MSG_NAME (message_p); - LOG_I(EMU, "TASK_L2L1 received %s\n", msg_name); - - switch (ITTI_MSG_ID(message_p)) { - case ACTIVATE_MESSAGE: - set_cli_start(ITTI_MSG_INSTANCE (message_p), 1); - break; - - case DEACTIVATE_MESSAGE: - set_cli_start(ITTI_MSG_INSTANCE (message_p), 0); - break; - - case TERMINATE_MESSAGE: - l2l1_state = L2L1_TERMINATED; - break; - - case MESSAGE_TEST: - break; - - default: - LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); - break; - } - - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - } while(message_p != NULL); - -#endif - - //Run the aperiodic user-defined events - if (oai_emulation.info.oeh_enabled == 1) - execute_events (frame); - - if (ue_connection_test == 1) { - if ((frame % 20) == 0) { - snr_dB += snr_direction; - sinr_dB -= snr_direction; - } - - if (snr_dB == -20) { - snr_direction = snr_step; - } else if (snr_dB == 20) { - snr_direction = -snr_step; - } - } - - oai_emulation.info.frame = frame; - //oai_emulation.info.time_ms += 1; - oai_emulation.info.time_s += 0.01; // emu time in s, each frame lasts for 10 ms // JNote: TODO check the coherency of the time and frame (I corrected it to 10 (instead of 0.01) - - update_omg (frame); // frequency is defined in the omg_global params configurable by the user - update_omg_ocm (); - -#ifdef OPENAIR2 - - // check if pipe is still open - if ((oai_emulation.info.omv_enabled == 1)) { - omv_write (pfd[1], enb_node_list, ue_node_list, omv_data); - } - -#endif - - - - for (sf = 0; sf < 10; sf++) { - LOG_D(EMU,"************************* Subframe %d\n",sf); - start_meas (&oaisim_stats_f); - - wait_for_slot_isr (); - -#if defined(ENABLE_ITTI) - itti_update_lte_time(frame % MAX_FRAME_NUMBER, sf<<1); -#endif - - oai_emulation.info.time_ms = frame * 10 + sf; - -#ifdef PROC - - if(Channel_Flag==1) - Channel_Func(s_re2,s_im2,r_re2,r_im2,r_re02,r_im02,r_re0_d,r_im0_d,r_re0_u,r_im0_u,RU2UE,UE2RU,enb_data,ue_data,abstraction_flag,frame_parms,sf<<1); - - if(Channel_Flag==0) -#endif - { // SUBFRAME INNER PART -#if defined(ENABLE_ITTI) - log_set_instance_type (LOG_INSTANCE_ENB); -#endif - - - CC_id=0; - int all_done=0; - while (all_done==0) { - - pthread_mutex_lock(&subframe_mutex); - int subframe_ru_mask_local = (subframe_select(&RC.ru[0]->frame_parms,(sf+4)%10)!=SF_UL) ? subframe_ru_mask : ((1<frame_parms,(sf+4)%10)!=SF_DL) ? subframe_UE_mask : ((1<frame_parms.frame_type == FDD || subframe_select(&RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? subframe_UE_mask : ((1<frame_parms.samples_per_tti; - LOG_D(EMU,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,current_ru_rx_timestamp[ru_id][CC_id]); - } - for (UE_inst = 0; UE_instframe_parms.samples_per_tti; - LOG_D(EMU,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,current_UE_rx_timestamp[UE_inst][CC_id]); - } - - for (eNB_inst = oai_emulation.info.first_enb_local; - (eNB_inst - < (oai_emulation.info.first_enb_local - + oai_emulation.info.nb_enb_local)); - eNB_inst++) { - if (oai_emulation.info.cli_start_enb[eNB_inst] != 0) { - - /* - LOG_D(EMU, - "PHY procedures eNB %d for frame %d, subframe %d TDD %d/%d Nid_cell %d\n", - eNB_inst, - frame % MAX_FRAME_NUMBER, - sf, - PHY_vars_eNB_g[eNB_inst][0]->frame_parms.frame_type, - PHY_vars_eNB_g[eNB_inst][0]->frame_parms.tdd_config, - PHY_vars_eNB_g[eNB_inst][0]->frame_parms.Nid_cell); - - */ -#ifdef OPENAIR2 - //Application: traffic gen - update_otg_eNB (eNB_inst, oai_emulation.info.time_ms); - - //IP/OTG to PDCP and PDCP to IP operation - // pdcp_run (frame, 1, 0, eNB_inst); //PHY_vars_eNB_g[eNB_id]->Mod_id -#endif - - -#ifdef PRINT_STATS - - if((sf==9) && frame%10==0) - if(eNB_avg_thr) - fprintf(eNB_avg_thr,"%d %d\n",RC.eNB[eNB_inst][0]->proc.proc_rxtx[sf&1].frame_tx, - (RC.eNB[eNB_inst][0]->total_system_throughput)/((RC.eNB[eNB_inst][0]->proc.proc_rxtx[sf&1].frame_tx+1)*10)); - /* - if (eNB_stats[eNB_inst]) { - len = dump_eNB_stats(RC.eNB[eNB_inst][0], stats_buffer, 0); - rewind (eNB_stats[eNB_inst]); - fwrite (stats_buffer, 1, len, eNB_stats[eNB_inst]); - fflush(eNB_stats[eNB_inst]); - } -#ifdef OPENAIR2 - if (eNB_l2_stats) { - len = dump_eNB_l2_stats (stats_buffer, 0); - rewind (eNB_l2_stats); - fwrite (stats_buffer, 1, len, eNB_l2_stats); - fflush(eNB_l2_stats); - } - -#endif -*/ -#endif - } - }// eNB_inst loop - - -#if defined(ENABLE_ITTI) - log_set_instance_type (LOG_INSTANCE_UE); -#endif - - - if ((sf == 0) && ((frame % MAX_FRAME_NUMBER) == 0) && (abstraction_flag == 0) - && (oai_emulation.info.n_frames == 1)) { - - write_output ("dlchan0.m", - "dlch0", - &(PHY_vars_UE_g[0][0]->common_vars.common_vars_rx_data_per_thread[0].dl_ch_estimates[0][0][0]), - (6 - * (PHY_vars_UE_g[0][0]->frame_parms.ofdm_symbol_size)), - 1, 1); - write_output ("dlchan1.m", - "dlch1", - &(PHY_vars_UE_g[0][0]->common_vars.common_vars_rx_data_per_thread[0].dl_ch_estimates[1][0][0]), - (6 - * (PHY_vars_UE_g[0][0]->frame_parms.ofdm_symbol_size)), - 1, 1); - write_output ("dlchan2.m", - "dlch2", - &(PHY_vars_UE_g[0][0]->common_vars.common_vars_rx_data_per_thread[0].dl_ch_estimates[2][0][0]), - (6 - * (PHY_vars_UE_g[0][0]->frame_parms.ofdm_symbol_size)), - 1, 1); - write_output ("pbch_rxF_comp0.m", - "pbch_comp0", - PHY_vars_UE_g[0][0]->pbch_vars[0]->rxdataF_comp[0], - 6 * 12 * 4, 1, 1); - write_output ("pbch_rxF_llr.m", "pbch_llr", - PHY_vars_UE_g[0][0]->pbch_vars[0]->llr, - (PHY_vars_UE_g[0][0]->frame_parms.Ncp == 0) ? 1920 : 1728, 1, - 4); - } - - stop_meas (&oaisim_stats_f); - } // SUBFRAME INNER PART - - - } - update_ocm (); - /* - if ((frame >= 10) && (frame <= 11) && (abstraction_flag == 0) -#ifdef PROC - &&(Channel_Flag==0) -#endif - ) { - sprintf (fname, "UEtxsig%d.m", frame % MAX_FRAME_NUMBER); - sprintf (vname, "txs%d", frame % MAX_FRAME_NUMBER); - write_output (fname, - vname, - PHY_vars_UE_g[0][0]->common_vars.txdata[0], - PHY_vars_UE_g[0][0]->frame_parms.samples_per_tti - * 10, - 1, 1); - sprintf (fname, "eNBtxsig%d.m", frame % MAX_FRAME_NUMBER); - sprintf (vname, "txs%d", frame % MAX_FRAME_NUMBER); - write_output (fname, - vname, - PHY_vars_eNB_g[0][0]->common_vars.txdata[0][0], - PHY_vars_UE_g[0][0]->frame_parms.samples_per_tti - * 10, - 1, 1); - sprintf (fname, "eNBtxsigF%d.m", frame % MAX_FRAME_NUMBER); - sprintf (vname, "txsF%d", frame % MAX_FRAME_NUMBER); - write_output (fname, - vname, - PHY_vars_eNB_g[0][0]->common_vars.txdataF[0][0], - PHY_vars_eNB_g[0][0]->frame_parms.symbols_per_tti - * PHY_vars_eNB_g[0][0]->frame_parms.ofdm_symbol_size, - 1, 1); - sprintf (fname, "UErxsig%d.m", frame % MAX_FRAME_NUMBER); - sprintf (vname, "rxs%d", frame % MAX_FRAME_NUMBER); - write_output (fname, - vname, - PHY_vars_UE_g[0][0]->common_vars.rxdata[0], - PHY_vars_UE_g[0][0]->frame_parms.samples_per_tti - * 10, - 1, 1); - sprintf (fname, "eNBrxsig%d.m", frame % MAX_FRAME_NUMBER); - sprintf (vname, "rxs%d", frame % MAX_FRAME_NUMBER); - write_output (fname, - vname, - PHY_vars_eNB_g[0][0]->common_vars.rxdata[0][0], - PHY_vars_UE_g[0][0]->frame_parms.samples_per_tti - * 10, - 1, 1); - } - */ - - //#ifdef XFORMS - if (xforms==1) { - eNB_inst = 0; - - for (UE_inst = 0; UE_inst < NB_UE_INST; UE_inst++) { - for (CC_id=0;CC_id0) { - pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); - } - - // copy frame parameters from RU to UEs - for (i=0;iframe_parms.N_RB_DL = RC.ru[0]->frame_parms.N_RB_DL; - PHY_vars_UE_g[i][0]->frame_parms.N_RB_UL = RC.ru[0]->frame_parms.N_RB_UL; - PHY_vars_UE_g[i][0]->frame_parms.nb_antennas_tx = 1; - PHY_vars_UE_g[i][0]->frame_parms.nb_antennas_rx = 1; - // set initially to 2, it will be revised after initial synchronization - PHY_vars_UE_g[i][0]->frame_parms.nb_antenna_ports_eNB = 2; - PHY_vars_UE_g[i][0]->frame_parms.tdd_config = 1; - PHY_vars_UE_g[i][0]->frame_parms.dl_CarrierFreq = RC.ru[0]->frame_parms.dl_CarrierFreq; - PHY_vars_UE_g[i][0]->frame_parms.ul_CarrierFreq = RC.ru[0]->frame_parms.ul_CarrierFreq; - PHY_vars_UE_g[i][0]->frame_parms.eutra_band = RC.ru[0]->frame_parms.eutra_band; - LOG_I(PHY,"Initializing UE %d frame parameters from RU information: N_RB_DL %d, p %d, dl_Carrierfreq %u, ul_CarrierFreq %u, eutra_band %d\n", - i, - PHY_vars_UE_g[i][0]->frame_parms.N_RB_DL, - PHY_vars_UE_g[i][0]->frame_parms.nb_antenna_ports_eNB, - PHY_vars_UE_g[i][0]->frame_parms.dl_CarrierFreq, - PHY_vars_UE_g[i][0]->frame_parms.ul_CarrierFreq, - PHY_vars_UE_g[i][0]->frame_parms.eutra_band); - - current_UE_rx_timestamp[i][0] = RC.ru[0]->frame_parms.samples_per_tti + RC.ru[0]->frame_parms.ofdm_symbol_size + RC.ru[0]->frame_parms.nb_prefix_samples0; - - } - - - - - for (ru_id=0;ru_idframe_parms.samples_per_tti; - - printf("RUs are ready, let's go\n"); -} - -void init_UE(int,int,int,int); -void init_RU(const char*); - -void set_UE_defaults(int nb_ue) { - - for (int UE_id = 0;UE_idpdcch_vars[i][0]->dciFormat = 0; - PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[i][0]->agregationLevel = 0xFF; - } - PHY_vars_UE_g[UE_id][CC_id]->current_dlsch_cqi[0] = 10; - PHY_vars_UE_g[UE_id][CC_id]->tx_power_max_dBm = 23; - } - } -} - - -static void print_current_directory(void) -{ - char dir[8192]; /* arbitrary size (should be big enough) */ - if (getcwd(dir, 8192) == NULL) - printf("ERROR getting working directory\n"); - else - printf("working directory: %s\n", dir); -} - -void init_devices(void); - -int main (int argc, char **argv) -{ - - clock_t t; - - print_current_directory(); - - start_background_system(); - -#ifdef SMBV - // Rohde&Schwarz SMBV100A vector signal generator - strcpy(smbv_ip,DEFAULT_SMBV_IP); -#endif - -#ifdef PROC - int node_id; - int port,Process_Flag=0,wgt,Channel_Flag=0,temp; -#endif - - //default parameters - oai_emulation.info.n_frames = MAX_FRAME_NUMBER; //1024; //10; - oai_emulation.info.n_frames_flag = 0; //fixme - snr_dB = 30; - - //Default values if not changed by the user in get_simulation_options(); - pdcp_period = 1; - omg_period = 1; - //Clean ip rule table - for(int i =0; iframe_parms); -#endif - - /* #if defined (FLEXRAN_AGENT_SB_IF) - flexran_agent_start(); - #endif */ - - // add events to future event list: Currently not used - //oai_emulation.info.oeh_enabled = 1; - if (oai_emulation.info.oeh_enabled == 1) - schedule_events (); - - // oai performance profiler is enabled - if (oai_emulation.info.opp_enabled == 1) - reset_opp_meas_oaisim (); - - cpuf=get_cpu_freq_GHz(); - - init_time (); - - init_slot_isr (); - - t = clock (); - - LOG_N(EMU, - ">>>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU initialization done <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); - -#ifndef PACKAGE_VERSION -# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" -#endif - LOG_I(EMU, "Version: %s\n", PACKAGE_VERSION); - -#if defined(ENABLE_ITTI) - - // Handle signals until all tasks are terminated - itti_wait_tasks_end(); - -#else - - if (oai_emulation.info.nb_enb_local > 0) { - eNB_app_task (NULL); // do nothing for the moment - } - - l2l1_task (NULL); -#endif - t = clock () - t; - LOG_I(EMU, "Duration of the simulation: %f seconds\n", - ((float) t) / CLOCKS_PER_SEC); - - LOG_N(EMU, - ">>>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU Ending <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); - - raise (SIGINT); - // oai_shutdown (); - - return (0); -} - -void -reset_opp_meas_oaisim (void) -{ - uint8_t eNB_id = 0, UE_id = 0; - - reset_meas (&oaisim_stats); - reset_meas (&oaisim_stats_f); // frame - - // init time stats here (including channel) - reset_meas (&dl_chan_stats); - reset_meas (&ul_chan_stats); - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - reset_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc[0]); - reset_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc[1]); - reset_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_rx[0]); - reset_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_rx[1]); - reset_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_tx); - - // reset_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_demod_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->rx_dft_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_channel_estimation_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_freq_offset_estimation_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_decoding_stats[0]); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_decoding_stats[1]); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_rate_unmatching_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_turbo_decoding_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_deinterleaving_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_llr_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_unscrambling_stats); - - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_init_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_alpha_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_beta_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_gamma_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_ext_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_intl1_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_intl2_stats); - - reset_meas (&PHY_vars_UE_g[UE_id][0]->tx_prach); - - reset_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_mod_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_encoding_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_modulation_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_segmentation_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_rate_matching_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_turbo_encoding_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_interleaving_stats); - reset_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_multiplexing_stats); - - - /* - * L2 functions - */ - - // UE MAC - reset_meas (&UE_mac_inst[UE_id].ue_scheduler); // total - reset_meas (&UE_mac_inst[UE_id].tx_ulsch_sdu); // inlcude rlc_data_req + mac header gen - reset_meas (&UE_mac_inst[UE_id].rx_dlsch_sdu); // include mac_rrc_data_ind or mac_rlc_status_ind+mac_rlc_data_ind and mac header parser - reset_meas (&UE_mac_inst[UE_id].ue_query_mch); - reset_meas (&UE_mac_inst[UE_id].rx_mch_sdu); // include rld_data_ind+ parse mch header - reset_meas (&UE_mac_inst[UE_id].rx_si); // include rlc_data_ind + mac header parser - - reset_meas (&UE_pdcp_stats[UE_id].pdcp_run); - reset_meas (&UE_pdcp_stats[UE_id].data_req); - reset_meas (&UE_pdcp_stats[UE_id].data_ind); - reset_meas (&UE_pdcp_stats[UE_id].apply_security); - reset_meas (&UE_pdcp_stats[UE_id].validate_security); - reset_meas (&UE_pdcp_stats[UE_id].pdcp_ip); - reset_meas (&UE_pdcp_stats[UE_id].ip_pdcp); - - - } - - for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - reset_meas (&RU2UE[eNB_id][UE_id][0]->random_channel); - reset_meas (&RU2UE[eNB_id][UE_id][0]->interp_time); - reset_meas (&RU2UE[eNB_id][UE_id][0]->interp_freq); - reset_meas (&RU2UE[eNB_id][UE_id][0]->convolution); - reset_meas (&UE2RU[UE_id][eNB_id][0]->random_channel); - reset_meas (&UE2RU[UE_id][eNB_id][0]->interp_time); - reset_meas (&UE2RU[UE_id][eNB_id][0]->interp_freq); - reset_meas (&UE2RU[UE_id][eNB_id][0]->convolution); - } - - reset_meas (&RC.eNB[eNB_id][0]->phy_proc); - reset_meas (&RC.eNB[eNB_id][0]->phy_proc_rx); - reset_meas (&RC.eNB[eNB_id][0]->phy_proc_tx); - reset_meas (&RC.eNB[eNB_id][0]->rx_prach); - - reset_meas (&RC.eNB[eNB_id][0]->ofdm_mod_stats); - reset_meas (&RC.eNB[eNB_id][0]->dlsch_encoding_stats); - reset_meas (&RC.eNB[eNB_id][0]->dlsch_modulation_stats); - reset_meas (&RC.eNB[eNB_id][0]->dlsch_scrambling_stats); - reset_meas (&RC.eNB[eNB_id][0]->dlsch_rate_matching_stats); - reset_meas (&RC.eNB[eNB_id][0]->dlsch_turbo_encoding_stats); - reset_meas (&RC.eNB[eNB_id][0]->dlsch_interleaving_stats); - - // reset_meas (&RC.eNB[eNB_id][0]->ofdm_demod_stats); - //reset_meas(&RC.eNB[eNB_id]->rx_dft_stats); - //reset_meas(&RC.eNB[eNB_id]->ulsch_channel_estimation_stats); - //reset_meas(&RC.eNB[eNB_id]->ulsch_freq_offset_estimation_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_decoding_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_demodulation_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_rate_unmatching_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_turbo_decoding_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_deinterleaving_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_demultiplexing_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_llr_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_init_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_alpha_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_beta_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_gamma_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_ext_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl1_stats); - reset_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl2_stats); -#ifdef LOCALIZATION - reset_meas(&RC.eNB[eNB_id][0]->localization_stats); -#endif - - /* - * L2 functions - */ - // eNB MAC - reset_meas (&RC.mac[eNB_id]->eNB_scheduler); // total - reset_meas (&RC.mac[eNB_id]->schedule_si); // only schedule + tx - reset_meas (&RC.mac[eNB_id]->schedule_ra); // only ra - reset_meas (&RC.mac[eNB_id]->schedule_ulsch); // onlu ulsch - reset_meas (&RC.mac[eNB_id]->fill_DLSCH_dci); // only dci - reset_meas (&RC.mac[eNB_id]->schedule_dlsch_preprocessor); // include rlc_data_req + MAC header gen - reset_meas (&RC.mac[eNB_id]->schedule_dlsch); // include rlc_data_req + MAC header gen + pre-processor - reset_meas (&RC.mac[eNB_id]->schedule_mch); // only embms - reset_meas (&RC.mac[eNB_id]->rx_ulsch_sdu); // include rlc_data_ind + mac header parser - - reset_meas (&eNB_pdcp_stats[eNB_id].pdcp_run); - reset_meas (&eNB_pdcp_stats[eNB_id].data_req); - reset_meas (&eNB_pdcp_stats[eNB_id].data_ind); - reset_meas (&eNB_pdcp_stats[eNB_id].apply_security); - reset_meas (&eNB_pdcp_stats[eNB_id].validate_security); - reset_meas (&eNB_pdcp_stats[eNB_id].pdcp_ip); - reset_meas (&eNB_pdcp_stats[eNB_id].ip_pdcp); - - } -} - -void -print_opp_meas_oaisim (void) -{ - - uint8_t eNB_id = 0, UE_id = 0; - - print_meas (&oaisim_stats, "[OAI][total_exec_time]", &oaisim_stats, - &oaisim_stats); - print_meas (&oaisim_stats_f, "[OAI][SF_exec_time]", &oaisim_stats, - &oaisim_stats_f); - - print_meas (&dl_chan_stats, "[DL][chan_stats]", &oaisim_stats, - &oaisim_stats_f); - print_meas (&ul_chan_stats, "[UL][chan_stats]", &oaisim_stats, - &oaisim_stats_f); - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - for (ru_id = 0; ru_id < NB_RU; ru_id++) { - print_meas (&RU2UE[ru_id][UE_id][0]->random_channel, - "[DL][random_channel]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RU2UE[ru_id][UE_id][0]->interp_time, - "[DL][interp_time]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RU2UE[ru_id][UE_id][0]->interp_freq, - "[DL][interp_freq]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RU2UE[ru_id][UE_id][0]->convolution, - "[DL][convolution]", &oaisim_stats, &oaisim_stats_f); - - print_meas (&UE2RU[UE_id][ru_id][0]->random_channel, - "[UL][random_channel]", &oaisim_stats, &oaisim_stats_f); - print_meas (&UE2RU[UE_id][ru_id][0]->interp_time, - "[UL][interp_time]", &oaisim_stats, &oaisim_stats_f); - print_meas (&UE2RU[UE_id][ru_id][0]->interp_freq, - "[UL][interp_freq]", &oaisim_stats, &oaisim_stats_f); - print_meas (&UE2RU[UE_id][ru_id][0]->convolution, - "[UL][convolution]", &oaisim_stats, &oaisim_stats_f); - } - } - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - print_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc[0], "[UE][total_phy_proc[0]]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc[1], "[UE][total_phy_proc[1]]", - &oaisim_stats, &oaisim_stats_f); - - - print_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_rx[0], - "[UE][total_phy_proc_rx[0]]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_rx[1], - "[UE][total_phy_proc_rx[1]]", &oaisim_stats, &oaisim_stats_f); - // print_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_demod_stats, - // "[UE][ofdm_demod]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->rx_dft_stats, "[UE][rx_dft]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_channel_estimation_stats, - "[UE][channel_est]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_freq_offset_estimation_stats, - "[UE][freq_offset]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_llr_stats, "[UE][llr]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_unscrambling_stats, - "[UE][unscrambling]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_decoding_stats[0], - "[UE][decoding[0]]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_decoding_stats[1], - "[UE][decoding[1]]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_rate_unmatching_stats, - "[UE][rate_unmatching]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_deinterleaving_stats, - "[UE][deinterleaving]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_turbo_decoding_stats, - "[UE][turbo_decoding]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_init_stats, - "[UE][ |_tc_init]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_alpha_stats, - "[UE][ |_tc_alpha]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_beta_stats, - "[UE][ |_tc_beta]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_gamma_stats, - "[UE][ |_tc_gamma]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_ext_stats, - "[UE][ |_tc_ext]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_intl1_stats, - "[UE][ |_tc_intl1]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->dlsch_tc_intl2_stats, - "[UE][ |_tc_intl2]", &oaisim_stats, &oaisim_stats_f); - - print_meas (&PHY_vars_UE_g[UE_id][0]->phy_proc_tx, - "[UE][total_phy_proc_tx]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ofdm_mod_stats, "[UE][ofdm_mod]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_modulation_stats, - "[UE][modulation]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_encoding_stats, - "[UE][encoding]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_segmentation_stats, - "[UE][segmentation]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_rate_matching_stats, - "[UE][rate_matching]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_turbo_encoding_stats, - "[UE][turbo_encoding]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_interleaving_stats, - "[UE][interleaving]", &oaisim_stats, &oaisim_stats_f); - print_meas (&PHY_vars_UE_g[UE_id][0]->ulsch_multiplexing_stats, - "[UE][multiplexing]", &oaisim_stats, &oaisim_stats_f); - - } - - for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - print_meas (&RC.eNB[eNB_id][0]->phy_proc, - "[eNB][total_phy_proc]", &oaisim_stats, &oaisim_stats_f); - - print_meas (&RC.eNB[eNB_id][0]->phy_proc_tx, - "[eNB][total_phy_proc_tx]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ofdm_mod_stats, - "[eNB][ofdm_mod]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->dlsch_modulation_stats, - "[eNB][modulation]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->dlsch_scrambling_stats, - "[eNB][scrambling]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->dlsch_encoding_stats, - "[eNB][encoding]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->dlsch_interleaving_stats, - "[eNB][|_interleaving]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->dlsch_rate_matching_stats, - "[eNB][|_rate_matching]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->dlsch_turbo_encoding_stats, - "[eNB][|_turbo_encoding]", &oaisim_stats, &oaisim_stats_f); - - print_meas (&RC.eNB[eNB_id][0]->phy_proc_rx, - "[eNB][total_phy_proc_rx]", &oaisim_stats, &oaisim_stats_f); - // print_meas (&RC.eNB[eNB_id][0]->ofdm_demod_stats, - // "[eNB][ofdm_demod]", &oaisim_stats, &oaisim_stats_f); - //print_meas(&RC.eNB[eNB_id][0]->ulsch_channel_estimation_stats,"[eNB][channel_est]"); - //print_meas(&RC.eNB[eNB_id][0]->ulsch_freq_offset_estimation_stats,"[eNB][freq_offset]"); - //print_meas(&RC.eNB[eNB_id][0]->rx_dft_stats,"[eNB][rx_dft]"); - print_meas (&RC.eNB[eNB_id][0]->ulsch_demodulation_stats, - "[eNB][demodulation]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_decoding_stats, - "[eNB][decoding]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_deinterleaving_stats, - "[eNB][|_deinterleaving]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_demultiplexing_stats, - "[eNB][|_demultiplexing]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_rate_unmatching_stats, - "[eNB][|_rate_unmatching]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_turbo_decoding_stats, - "[eNB][|_turbo_decoding]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_init_stats, - "[eNB][ |_tc_init]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_alpha_stats, - "[eNB][ |_tc_alpha]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_beta_stats, - "[eNB][ |_tc_beta]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_gamma_stats, - "[eNB][ |_tc_gamma]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_ext_stats, - "[eNB][ |_tc_ext]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl1_stats, - "[eNB][ |_tc_intl1]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.eNB[eNB_id][0]->ulsch_tc_intl2_stats, - "[eNB][ |_tc_intl2]", &oaisim_stats, &oaisim_stats_f); - - print_meas (&RC.eNB[eNB_id][0]->rx_prach, "[eNB][rx_prach]", - &oaisim_stats, &oaisim_stats_f); - -#ifdef LOCALIZATION - print_meas(&RC.eNB[eNB_id][0]->localization_stats, "[eNB][LOCALIZATION]",&oaisim_stats,&oaisim_stats_f); -#endif - } - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - - print_meas (&UE_mac_inst[UE_id].ue_scheduler, "[UE][mac_scheduler]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_mac_inst[UE_id].tx_ulsch_sdu, "[UE][tx_ulsch_sdu]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_mac_inst[UE_id].rx_dlsch_sdu, "[UE][rx_dlsch_sdu]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_mac_inst[UE_id].ue_query_mch, "[UE][query_MCH]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_mac_inst[UE_id].rx_mch_sdu, "[UE][rx_mch_sdu]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_mac_inst[UE_id].rx_si, "[UE][rx_si]", &oaisim_stats, - &oaisim_stats_f); - - print_meas (&UE_pdcp_stats[UE_id].pdcp_run, "[UE][total_pdcp_run]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_pdcp_stats[UE_id].data_req, "[UE][DL][pdcp_data_req]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_pdcp_stats[UE_id].data_ind, "[UE][UL][pdcp_data_ind]", - &oaisim_stats, &oaisim_stats_f); - - print_meas (&UE_pdcp_stats[UE_id].apply_security, - "[UE][DL][apply_security]", &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_pdcp_stats[UE_id].validate_security, - "[UE][UL][validate_security]", &oaisim_stats, - &oaisim_stats_f); - print_meas (&UE_pdcp_stats[UE_id].ip_pdcp, "[UE][DL][ip_pdcp]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&UE_pdcp_stats[UE_id].pdcp_ip, "[UE][UL][pdcp_ip]", - &oaisim_stats, &oaisim_stats_f); - - } - - for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - - print_meas (&RC.mac[eNB_id]->eNB_scheduler, "[eNB][mac_scheduler]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->schedule_si, "[eNB][DL][SI]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->schedule_ra, "[eNB][DL][RA]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->fill_DLSCH_dci, - "[eNB][DL/UL][fill_DCI]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->schedule_dlsch_preprocessor, - "[eNB][DL][preprocessor]", &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->schedule_dlsch, - "[eNB][DL][schedule_tx_dlsch]", &oaisim_stats, - &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->schedule_mch, "[eNB][DL][mch]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->schedule_ulsch, "[eNB][UL][ULSCH]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&RC.mac[eNB_id]->rx_ulsch_sdu, - "[eNB][UL][rx_ulsch_sdu]", &oaisim_stats, &oaisim_stats_f); - - print_meas (&eNB_pdcp_stats[eNB_id].pdcp_run, "[eNB][pdcp_run]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&eNB_pdcp_stats[eNB_id].data_req, - "[eNB][DL][pdcp_data_req]", &oaisim_stats, &oaisim_stats_f); - print_meas (&eNB_pdcp_stats[eNB_id].data_ind, - "[eNB][UL][pdcp_data_ind]", &oaisim_stats, &oaisim_stats_f); - - print_meas (&eNB_pdcp_stats[eNB_id].apply_security, - "[eNB][DL][apply_security]", &oaisim_stats, - &oaisim_stats_f); - print_meas (&eNB_pdcp_stats[eNB_id].validate_security, - "[eNB][UL][validate_security]", &oaisim_stats, - &oaisim_stats_f); - print_meas (&eNB_pdcp_stats[eNB_id].ip_pdcp, "[eNB][DL][ip_pdcp]", - &oaisim_stats, &oaisim_stats_f); - print_meas (&eNB_pdcp_stats[eNB_id].pdcp_ip, "[eNB][UL][pdcp_ip]", - &oaisim_stats, &oaisim_stats_f); - - } - -} - -#if !defined(ENABLE_ITTI) -static void * -sigh (void *arg) -{ - - int signum; - sigset_t sigcatch; - sigemptyset (&sigcatch); - sigaddset (&sigcatch, SIGHUP); - sigaddset (&sigcatch, SIGINT); - sigaddset (&sigcatch, SIGTERM); - sigaddset (&sigcatch, SIGQUIT); - - for (;;) { - sigwait (&sigcatch, &signum); - - //sigwait(&sigblock, &signum); - switch (signum) { - case SIGHUP: - case SIGINT: - case SIGTERM: - case SIGQUIT: - fprintf (stderr, "received signal %d \n", signum); - // no need for mutx: when ITTI not used, this variable is only accessed by this function - l2l1_state = L2L1_TERMINATED; - break; - - default: - fprintf (stderr, "Unexpected signal %d \n", signum); - exit (-1); - break; - } - } - - pthread_exit (NULL); -} -#endif /* !defined(ENABLE_ITTI) */ - -void -oai_shutdown (void) -{ - static int done = 0; - - if (done) - return; - - free (otg_pdcp_buffer); - otg_pdcp_buffer = 0; - -#ifdef SMBV - - // Rohde&Schwarz SMBV100A vector signal generator - if (config_smbv) { - smbv_send_config (smbv_fname,smbv_ip); - } - -#endif - - //Perform KPI measurements - if (oai_emulation.info.otg_enabled == 1){ - LOG_N(EMU,"calling OTG kpi gen .... \n"); - kpi_gen (); - } - if (oai_emulation.info.opp_enabled == 1) - print_opp_meas_oaisim (); - - -#ifdef PROC - - if (abstraction_flag == 0 && Channel_Flag==0 && Process_Flag==0) -#else - if (abstraction_flag == 0) -#endif - { - /* - #ifdef IFFT_FPGA - free(txdataF2[0]); - free(txdataF2[1]); - free(txdataF2); - free(txdata[0]); - free(txdata[1]); - free(txdata); - #endif - */ - /* - for (int i = 0; i < 2; i++) { - free (s_re[i]); - free (s_im[i]); - free (r_re[i]); - free (r_im[i]); - } - - free (s_re); - free (s_im); - free (r_re); - free (r_im); - s_re = 0; - s_im = 0; - r_re = 0; - r_im = 0;*/ - - lte_sync_time_free (); - } - - // added for PHY abstraction - if (oai_emulation.info.ocm_enabled == 1) { - for (eNB_inst = 0; eNB_inst < NUMBER_OF_eNB_MAX; eNB_inst++) { - free (enb_data[eNB_inst]); - enb_data[eNB_inst] = 0; - } - - for (UE_inst = 0; UE_inst < NUMBER_OF_UE_MAX; UE_inst++) { - free (ue_data[UE_inst]); - ue_data[UE_inst] = 0; - } - } //End of PHY abstraction changes - - - // stop OMG - stop_mobility_generator (omg_param_list); //omg_param_list.mobility_type -#ifdef OPENAIR2 - - if (oai_emulation.info.omv_enabled == 1) - omv_end (pfd[1], omv_data); - -#endif - - if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0) - && (ShaF != NULL)) { - destroyMat (ShaF, map1, map2); - ShaF = 0; - } - - if (opt_enabled == 1) - terminate_opt (); - - if (oai_emulation.info.cli_enabled) - cli_server_cleanup (); - - for (int i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++) - if (oai_emulation.info.oai_ifup[i] == 1) { - char interfaceName[8]; - snprintf (interfaceName, sizeof(interfaceName), "oai%d", i); - bringInterfaceUp (interfaceName, 0); - } - - log_thread_finalize (); - logClean (); - VCD_SIGNAL_DUMPER_CLOSE (); - - done = 1; // prevent next invokation of this function - - LOG_N(EMU, - ">>>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU shutdown <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); -} - -eNB_MAC_INST* -get_eNB_mac_inst (module_id_t module_idP) -{ - return (RC.mac[module_idP]); -} - -OAI_Emulation* -get_OAI_emulation () -{ - return &oai_emulation; -} - - -// dummy function declarations - -void *rrc_enb_task(void *args_p) -{ - return NULL; -} - diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c deleted file mode 100644 index 6188d49004..0000000000 --- a/targets/SIMU/USER/oaisim_config.c +++ /dev/null @@ -1,1349 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file oaisim_config.c -* \brief Configuration of oaisim -* \author Navid Nikaein -* \date 2013-2015 -* \version 1.0 -* \company Eurecom -* \email: openair_tech@eurecom.fr -* \note -* \warning -*/ - -#include -#include -#include -#include -#include -#include - -#include "oaisim_config.h" -#include "OCG.h" -#include "OCG_extern.h" -#include "UTIL/OMG/omg.h" -#include "UTIL/OMG/grid.h" -#include "UTIL/OTG/otg_tx.h" -#include "UTIL/OTG/otg.h" -#include "UTIL/OTG/otg_externs.h" -#include "oml.h" -#include "msc.h" -#if ENABLE_RAL -#include "lteRALenb.h" -#include "lteRALue.h" -#endif - -#if defined(ENABLE_ITTI) -# include "intertask_interface_init.h" -#endif - - -mapping omg_model_names[] = { - {"STATIC", STATIC}, - {"RWP", RWP}, - {"RWALK", RWALK}, - {"TRACE", TRACE}, - {"SUMO", SUMO}, - {"STEADY_RWP", STEADY_RWP}, - {"MAX_NUM_MOB_TYPES", MAX_NUM_MOB_TYPES}, - {NULL, -1} -}; -// subtypes for RWP in grid map -mapping omg_rwp_names[] = { - {"MIN_RWP_TYPES", MIN_RWP_TYPES}, - {"RESTRICTED_RWP",RESTIRICTED_RWP}, - {"CONNECTED_DOMAIN", CONNECTED_DOMAIN}, - {"MAX_RWP_TYPES", MAX_RWP_TYPES}, - {NULL, -1} -}; - -void ocg_config_proto(void); - -void init_oai_emulation(void) -{ - - int i; - int CC_id; - - oai_emulation.environment_system_config.fading.large_scale.selected_option = "free_space"; - oai_emulation.environment_system_config.fading.free_space_model_parameters.pathloss_exponent = 3.00; - oai_emulation.environment_system_config.fading.free_space_model_parameters.pathloss_0_dB = -100; - oai_emulation.environment_system_config.fading.small_scale.selected_option = "AWGN"; - oai_emulation.environment_system_config.fading.ricean_8tap.rice_factor_dB = 0; - oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m = 0; - oai_emulation.environment_system_config.fading.shadowing.variance_dB = 0; - oai_emulation.environment_system_config.fading.shadowing.inter_site_correlation = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.number_of_sectors = 1; - oai_emulation.environment_system_config.antenna.eNB_antenna.beam_width_dB = 1.13; - oai_emulation.environment_system_config.antenna.eNB_antenna.alpha_rad[0] = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.alpha_rad[1] = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.alpha_rad[2] = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.antenna_gain_dBi = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.tx_power_dBm = 15; - oai_emulation.environment_system_config.antenna.eNB_antenna.rx_noise_level_dB = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.antenna_orientation_degree[0] = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.antenna_orientation_degree[1] = 0; - oai_emulation.environment_system_config.antenna.eNB_antenna.antenna_orientation_degree[2] = 0; - oai_emulation.environment_system_config.antenna.UE_antenna.antenna_gain_dBi = 0; - oai_emulation.environment_system_config.antenna.UE_antenna.tx_power_dBm = 20; - oai_emulation.environment_system_config.antenna.UE_antenna.rx_noise_level_dB = 0; // noise figure - oai_emulation.environment_system_config.wall_penetration_loss_dB = 5; - oai_emulation.environment_system_config.system_bandwidth_MB = 7.68; - oai_emulation.environment_system_config.system_frequency_GHz = 1.9; - - oai_emulation.topology_config.area.x_m = 1000; - oai_emulation.topology_config.area.y_m = 1000; - oai_emulation.topology_config.network_type.selected_option = "homogeneous"; - oai_emulation.topology_config.cell_type.selected_option = "macrocell"; - oai_emulation.topology_config.relay.number_of_relays = 0; - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option = "STATIC"; - oai_emulation.topology_config.mobility.UE_mobility.grid_walk.grid_map.selected_option="MAX_RWP_TYPES"; - //oai_emulation.topology_config.mobility.UE_mobility.grid_walk.grid_map.horizontal_grid = 1; - //oai_emulation.topology_config.mobility.UE_mobility.grid_walk.grid_map.vertical_grid = 1; - oai_emulation.topology_config.mobility.UE_mobility.grid_walk.grid_trip_type.selected_option = "random_destination"; - oai_emulation.topology_config.mobility.UE_mobility.UE_initial_distribution.selected_option = "random"; - oai_emulation.topology_config.mobility.UE_mobility.random_UE_distribution.number_of_nodes = 1; - oai_emulation.topology_config.mobility.UE_mobility.concentrated_UE_distribution.number_of_nodes = 1; - oai_emulation.topology_config.mobility.UE_mobility.grid_UE_distribution.random_grid.number_of_nodes = 1; - oai_emulation.topology_config.mobility.UE_mobility.grid_UE_distribution.border_grid.number_of_nodes = 1; - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_speed_mps = 0.1; - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_speed_mps = 20.0; - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_sleep_ms = 0.1; - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_sleep_ms = 5.0; - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_journey_time_ms = 0.1; - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_journey_time_ms = 10.0; - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option = "STATIC"; - oai_emulation.topology_config.mobility.eNB_mobility.eNB_initial_distribution.selected_option = "random"; - oai_emulation.topology_config.mobility.eNB_mobility.fixed_eNB_distribution.pos_x = 1; - oai_emulation.topology_config.mobility.eNB_mobility.fixed_eNB_distribution.pos_y = 1; - oai_emulation.topology_config.mobility.eNB_mobility.random_eNB_distribution.number_of_cells = 1; - oai_emulation.topology_config.mobility.eNB_mobility.hexagonal_eNB_distribution.number_of_cells = 1; - oai_emulation.topology_config.mobility.eNB_mobility.hexagonal_eNB_distribution.inter_eNB_distance_km = 1; - oai_emulation.topology_config.mobility.eNB_mobility.grid_eNB_distribution.number_of_grid_x = 1; - oai_emulation.topology_config.mobility.eNB_mobility.grid_eNB_distribution.number_of_grid_y = 1; - oai_emulation.topology_config.mobility.eNB_mobility.trace_config.trace_mobility_file = (char*) malloc(256); - sprintf(oai_emulation.topology_config.mobility.eNB_mobility.trace_config.trace_mobility_file,"static_1enb.tr"); - oai_emulation.topology_config.mobility.UE_mobility.trace_config.trace_mobility_file = (char*) malloc(256); - sprintf(oai_emulation.topology_config.mobility.UE_mobility.trace_config.trace_mobility_file,"static_2ues.tr"); - oai_emulation.topology_config.mobility.UE_mobility.sumo_config.command = (char*) malloc(20); - sprintf(oai_emulation.topology_config.mobility.UE_mobility.sumo_config.command,"sumo"); - oai_emulation.topology_config.mobility.UE_mobility.sumo_config.file = (char*) malloc(256); - snprintf( oai_emulation.topology_config.mobility.UE_mobility.sumo_config.file, 256, "%s/UTIL/OMG/SUMO/SCENARIOS/scen.sumo.cfg", getenv("OPENAIR2_DIR") ); - oai_emulation.topology_config.mobility.UE_mobility.sumo_config.start=0; - oai_emulation.topology_config.mobility.UE_mobility.sumo_config.end=0; - oai_emulation.topology_config.mobility.UE_mobility.sumo_config.step=1; // 1000ms - oai_emulation.topology_config.mobility.UE_mobility.sumo_config.hip = (char*) malloc(40); - sprintf(oai_emulation.topology_config.mobility.UE_mobility.sumo_config.hip,"127.0.1.1"); - oai_emulation.topology_config.mobility.UE_mobility.sumo_config.hport = 8883; - - oai_emulation.application_config.packet_gen_type = "substract_string"; - - for (i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++) { - oai_emulation.application_config.predefined_traffic.source_id[i] = "1:10"; - oai_emulation.application_config.predefined_traffic.application_type[i] = "no_predefined_traffic"; - oai_emulation.application_config.predefined_traffic.background[i] = "disable"; - oai_emulation.application_config.predefined_traffic.aggregation_level[i] = 1; - oai_emulation.application_config.predefined_traffic.flow_start[i] = 0; - oai_emulation.application_config.predefined_traffic.flow_duration[i] = 1000;//uniform_dist((i+1)*100,0xffff); - - oai_emulation.application_config.predefined_traffic.destination_id[i] = 0; - - oai_emulation.application_config.customized_traffic.source_id[i] = "1"; - oai_emulation.application_config.customized_traffic.destination_id[i] = "2"; - oai_emulation.application_config.customized_traffic.transport_protocol[i] = "udp"; - oai_emulation.application_config.customized_traffic.background[i] = "disable"; - oai_emulation.application_config.customized_traffic.m2m[i] = "disable"; - oai_emulation.application_config.customized_traffic.ip_version[i] = "ipv4"; - oai_emulation.application_config.customized_traffic.aggregation_level[i] = 1; - oai_emulation.application_config.customized_traffic.flow_start[i] = 0;// (i+1)*30; - oai_emulation.application_config.customized_traffic.flow_duration[i] = 1000;// uniform_dist((i+1)*100,0xffff); - oai_emulation.application_config.customized_traffic.idt_dist[i] = "uniform"; - oai_emulation.application_config.customized_traffic.idt_min_ms[i] = 100; - oai_emulation.application_config.customized_traffic.idt_max_ms[i] = 1000; - oai_emulation.application_config.customized_traffic.idt_standard_deviation[i] = 1; - oai_emulation.application_config.customized_traffic.idt_lambda[i] = 1; - oai_emulation.application_config.customized_traffic.size_dist[i] = "uniform"; - oai_emulation.application_config.customized_traffic.size_min_byte[i] = 200; - oai_emulation.application_config.customized_traffic.size_max_byte[i] = 500; - oai_emulation.application_config.customized_traffic.size_standard_deviation[i] = 1; - oai_emulation.application_config.customized_traffic.size_lambda[i] = 1; - oai_emulation.application_config.customized_traffic.stream[i] = 1; - oai_emulation.application_config.customized_traffic.destination_port[i] = 8080; - oai_emulation.application_config.customized_traffic.prob_off_pu[i]= 0; - oai_emulation.application_config.customized_traffic.prob_off_ed[i]= 0; - oai_emulation.application_config.customized_traffic.prob_off_pe[i]= 0; - oai_emulation.application_config.customized_traffic.prob_pu_ed[i]= 0; - oai_emulation.application_config.customized_traffic.prob_pu_pe[i]= 0; - oai_emulation.application_config.customized_traffic.prob_ed_pe[i]= 0; - oai_emulation.application_config.customized_traffic.prob_ed_pu[i]= 0; - oai_emulation.application_config.customized_traffic.holding_time_off_ed[i]= 0; - oai_emulation.application_config.customized_traffic.holding_time_off_pu[i]= 0; - oai_emulation.application_config.customized_traffic.holding_time_off_pe[i]= 0; - oai_emulation.application_config.customized_traffic.holding_time_pe_off[i]= 0; - oai_emulation.application_config.customized_traffic.pu_size_pkts[i]= 0; - oai_emulation.application_config.customized_traffic.ed_size_pkts[i]= 0; - } - - /* protocol config */ - oai_emulation.protocol_config.eNB_mac_config.num_groups=1; - - - oai_emulation.emulation_config.emulation_time_ms = 0; - oai_emulation.emulation_config.curve = "disable"; - oai_emulation.emulation_config.background_stats = "disable"; - oai_emulation.emulation_config.performance_metrics.throughput = "disable"; - oai_emulation.emulation_config.performance_metrics.latency ="disable"; - oai_emulation.emulation_config.performance_metrics.loss_rate ="disable"; - oai_emulation.emulation_config.performance_metrics.owd_radio_access = "disable"; - oai_emulation.emulation_config.layer.phy = 0; - oai_emulation.emulation_config.layer.mac = 0; - oai_emulation.emulation_config.layer.rlc = 0; - oai_emulation.emulation_config.layer.pdcp = 0; - oai_emulation.emulation_config.layer.rrc = 0; - oai_emulation.emulation_config.layer.omg = 0; - oai_emulation.emulation_config.layer.otg = 0; - oai_emulation.emulation_config.layer.emu = 1; - - oai_emulation.emulation_config.log_emu.level = "debug"; - oai_emulation.emulation_config.log_emu.verbosity = "low"; - oai_emulation.emulation_config.log_emu.interval = 1; - oai_emulation.emulation_config.packet_trace.enabled = 0; - oai_emulation.emulation_config.seed.value = 0; // 0 means randomly generated by OAI - - oai_emulation.info.ocg_ok = 0; - - - // phy related params : - oai_emulation.info.n_frames=MAX_FRAME_NUMBER; // number of frames simulated by default - oai_emulation.info.n_frames_flag=0; // if set, then let the emulation goes to infinity - - //status - oai_emulation.info.is_primary_master=0; - oai_emulation.info.master_list=0; - oai_emulation.info.nb_ue_remote=0; - oai_emulation.info.nb_enb_remote=0; - oai_emulation.info.nb_rn_remote=0; - oai_emulation.info.first_ue_local=0; - oai_emulation.info.first_enb_local=0; - oai_emulation.info.first_rn_local=0; - oai_emulation.info.master_id=0; - oai_emulation.info.nb_ue_local= 1;//default 1 UE - oai_emulation.info.nb_enb_local= 0;//default 0 eNB (to be loaded from config) - oai_emulation.info.nb_ru_local= 0;//default 0 ru (to be loaded from config) - oai_emulation.info.nb_rn_local= 0;//default 0 RN : currently only applicable for eMBMS - oai_emulation.info.ethernet_flag=0; - oai_emulation.info.ocm_enabled=1;// flag ? - oai_emulation.info.ocg_enabled=0;// flag c - oai_emulation.info.otg_enabled=0;// flag T - oai_emulation.info.opt_enabled=0; // P flag - oai_emulation.info.opt_mode=-1; // arg for P flag - oai_emulation.info.cli_enabled=0;// I flag - oai_emulation.info.omv_enabled =0; // v flag - oai_emulation.info.vcd_enabled=0; - oai_emulation.info.opp_enabled=0; - oai_emulation.info.oeh_enabled=0; - - oai_emulation.info.cba_group_active=0; - oai_emulation.info.cba_backoff=30; - oai_emulation.info.eMBMS_active_state=0; - oai_emulation.info.handover_active=0; - oai_emulation.info.omg_model_enb=STATIC; //default to static mobility model - oai_emulation.info.omg_model_rn=STATIC; //default to static mobility model - oai_emulation.info.omg_model_ue=STATIC; //default to static mobility model - oai_emulation.info.omg_rwp_type = RESTIRICTED_RWP; - oai_emulation.info.omg_model_ue_current=STATIC; //default to static mobility model - oai_emulation.info.otg_traffic="no_predefined_traffic"; - oai_emulation.info.otg_bg_traffic_enabled = 0; // G flag - oai_emulation.info.max_predefined_traffic_config_index = 0; - oai_emulation.info.max_customized_traffic_config_index = 0; - oai_emulation.info.frame = 0; // frame counter of emulation - oai_emulation.info.time_s = 0; // time of emulation - oai_emulation.info.time_ms = 0; // time of emulation - oai_emulation.info.seed = time(NULL); // time-based random seed , , included in ocg report - - oai_emulation.info.cli_num_enb= NUMBER_OF_eNB_MAX; - oai_emulation.info.cli_num_ue= NUMBER_OF_UE_MAX; - - oai_emulation.info.slot_isr = 0; - oai_emulation.info.slot_sfd = -1; - - //for (i=0; i < oai_emulation.info.cli_num_enb; i++) - for (i=0; i < NUMBER_OF_eNB_MAX; i++) - oai_emulation.info.cli_start_enb[i]=1; - - // for (i=0; i < oai_emulation.info.cli_num_ue; i++) - for (i=0; i < NUMBER_OF_UE_MAX; i++) - oai_emulation.info.cli_start_ue[i]=1; - - for (i=0; i < NUMBER_OF_eNB_MAX+NUMBER_OF_UE_MAX; i++) - oai_emulation.info.oai_ifup[i]=0; - - oai_emulation.info.nb_master =0; - oai_emulation.info.ethernet_id =0; - oai_emulation.info.multicast_group =0; - oai_emulation.info.multicast_ifname=NULL; - oai_emulation.info.g_log_level = LOG_INFO; - oai_emulation.info.g_log_verbosity = 0x15; - oai_emulation.info.g_log_verbosity_option = "medium"; - - for (CC_id=0; CC_idlog_component[OTG].filelog=1; - g_log->log_component[OTG_LATENCY].filelog=1; - g_log->log_component[OTG_OWD].filelog = 1;*/ - ocg_config_app(); // packet generator - } - - // add a var to control this, and pass this var to OMG - set_component_filelog(OMG); - LOG_I(OMG,"setting OMG file log \n"); - -} - -int olg_config(void) -{ - int comp; - int ocg_log_level = map_str_to_int(log_level_names, oai_emulation.emulation_config.log_emu.level); - int ocg_log_verbosity = map_str_to_int(log_verbosity_names, oai_emulation.emulation_config.log_emu.verbosity); - // fix me: - oai_emulation.info.g_log_level = ((oai_emulation.info.ocg_enabled == 1) && (ocg_log_level != -1)) ? ocg_log_level : oai_emulation.info.g_log_level; - oai_emulation.info.g_log_verbosity = (((oai_emulation.info.ocg_enabled == 1) && (ocg_log_verbosity != -1)) ? ocg_log_verbosity : - map_str_to_int(log_verbosity_names, oai_emulation.info.g_log_verbosity_option)); - set_glog(oai_emulation.info.g_log_level, oai_emulation.info.g_log_verbosity ); //g_glog - - // component, log level, log interval - for (comp = PHY; comp < MAX_LOG_COMPONENTS ; comp++) - set_comp_log(comp, - oai_emulation.info.g_log_level, - oai_emulation.info.g_log_verbosity, - oai_emulation.emulation_config.log_emu.interval); - - LOG_I(EMU, "OCG log level %d, oai log level%d \n ",ocg_log_level, oai_emulation.info.g_log_level); - LOG_N(EMU,"global log level is set to (%s,%d) with vebosity (%s, 0x%x) and frequency %d\n", - map_int_to_str (log_level_names, oai_emulation.info.g_log_level), - oai_emulation.info.g_log_level, - map_int_to_str (log_verbosity_names,oai_emulation.info.g_log_verbosity), - oai_emulation.info.g_log_verbosity, - oai_emulation.emulation_config.log_emu.interval ); - - - /* - // if perf eval then reset the otg log level - set_comp_log(PHY, LOG_EMERG, 0x15,1); - set_comp_log(EMU, LOG_EMERG, 0x15,1); - set_comp_log(OCG, LOG_EMERG, 0x15,1); - set_comp_log(OCM, LOG_EMERG, 0x15,1); - set_comp_log(OTG, LOG_EMERG, 0x15,1); - set_comp_log(MAC, LOG_EMERG, 0x15,1); - set_comp_log(OMG, LOG_EMERG, 0x15,1); - set_comp_log(OPT, LOG_EMERG, 0x15,1); - set_comp_log(PDCP, LOG_DEBUG, LOG_MED,1); - set_comp_log(RLC, LOG_DEBUG, LOG_MED,1); - set_comp_log(RRC, LOG_DEBUG, LOG_MED,1); - */ -#if defined(ENABLE_USE_MME) - set_comp_log(UDP_, LOG_DEBUG, LOG_MED,1); - set_comp_log(GTPU, LOG_DEBUG, LOG_MED,1); - set_comp_log(SPGW, LOG_DEBUG, LOG_MED,1); - set_comp_log(S1AP, LOG_DEBUG, LOG_MED,1); - set_comp_log(SCTP, LOG_DEBUG, LOG_MED,1); -#endif - -#if ENABLE_RAL - set_comp_log(RAL_ENB, LOG_TRACE, LOG_MED,1); - set_comp_log(RAL_UE, LOG_TRACE, LOG_MED,1); - set_log(RAL_ENB, LOG_DEBUG, 1); - set_log(RAL_UE, LOG_DEBUG, 1); -#endif - - - //set_log(OCG, LOG_DEBUG, 1); - //set_log(EMU, LOG_INFO, 20); - set_log(MAC, LOG_DEBUG, 1); - set_log(RLC, LOG_TRACE, 1); - //set_log(PHY, LOG_DEBUG, 1); - set_log(PDCP, LOG_TRACE, 1); - set_log(RRC, LOG_DEBUG, 1); - //set_log(OCM, LOG_INFO, 20); - //set_log(OTG, LOG_INFO, 1); - set_comp_log(OCG, LOG_ERR, 0x15,1); - set_comp_log(EMU, LOG_INFO, 0x15,20); - set_comp_log(MAC, LOG_TRACE, 0x15,1); - set_comp_log(RLC, LOG_TRACE, 0x15,1); - set_comp_log(PHY, LOG_TRACE, 0x15, 1); - set_comp_log(PDCP, LOG_DEBUG, 0x15,1); - set_comp_log(RRC, LOG_DEBUG, 0x15,1); - set_comp_log(OCM, LOG_INFO, 0x15,20); - set_comp_log(OTG, LOG_DEBUG, 0x15,1); - set_comp_log(OMG, LOG_NOTICE, 0x15,1); - set_comp_log(OPT, LOG_ERR, 0x15,1); - - - // set_comp_log(MAC, LOG_TRACE, LOG_FULL,1); - return 1; -} - -int ocg_config_env(void) -{ - // int func related to channel desc from oaisim.c could be moved here - int CC_id; - - if (oai_emulation.info.ocg_enabled) { - for (CC_id=0; CC_id 6) || (oai_emulation.info.tdd_config[CC_id] < 0)) { - LOG_E(EMU,"TDD config %d out of range, set it to 3\n",oai_emulation.info.tdd_config[CC_id]); - oai_emulation.info.tdd_config[CC_id]=3; - } else - LOG_I(EMU,"TDD config is set to %d\n",oai_emulation.info.tdd_config[CC_id]); - } - } - } - - return 1; -} -int ocg_config_topo(void) -{ - - int i; - // omg - init_omg_global_params(); - - // setup params for openair mobility generator - //common params - for(i=0; i < MAX_NUM_NODE_TYPES; i++) { - - omg_param_list[i].min_x = 0; - omg_param_list[i].max_x = oai_emulation.topology_config.area.x_m; - omg_param_list[i].min_y = 0; - omg_param_list[i].max_y= oai_emulation.topology_config.area.y_m; - // init values - omg_param_list[i].min_speed = 0.1; - omg_param_list[i].max_speed = 20.0; - omg_param_list[i].min_journey_time = 0.1; - omg_param_list[i].max_journey_time = 10.0; - omg_param_list[i].min_azimuth = 0; // ??? - omg_param_list[i].max_azimuth = 360; // ??? - omg_param_list[i].min_sleep = 0.1; - omg_param_list[i].max_sleep = 8.0; - omg_param_list[i].nodes_type = i; - omg_param_list[i].nodes=0; - omg_param_list[i].mobility_type=STATIC; - - // init OMG for eNBs - - if(i==eNB) { - if ((oai_emulation.info.omg_model_enb = map_str_to_int(omg_model_names, oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option))== -1) - oai_emulation.info.omg_model_enb = STATIC; - - LOG_I(OMG,"eNB mobility model is (%s, %d)\n", - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option, - oai_emulation.info.omg_model_enb); - - omg_param_list[i].mobility_type = oai_emulation.info.omg_model_enb; - omg_param_list[i].nodes = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local; - omg_param_list[i].seed = oai_emulation.info.seed; // specific seed for enb and ue to avoid node overlapping - - - if (oai_emulation.info.omg_model_enb == TRACE) { - omg_param_list[i].mobility_file = (char*) malloc(256);// user-specific trace file "%s/UTIL/OMG/mobility.txt",getenv("OPENAIR2_DIR") - //memset(oai_emulation.topology_config.mobility.UE_mobility.trace_config.trace_mobility_file,0,256); - //sprintf(omg_param_list.mobility_file,"%s",oai_emulation.topology_config.mobility.UE_mobility.trace_config.trace_mobility_file); - sprintf(omg_param_list[i].mobility_file,"%s/UTIL/OMG/TRACE/%s", - getenv("OPENAIR2_DIR"), - oai_emulation.topology_config.mobility.eNB_mobility.trace_config.trace_mobility_file); - LOG_I(OMG,"TRACE file at %s\n", omg_param_list[i].mobility_file); - // notify the user if the file is not found - } - - - - if (strcmp(oai_emulation.topology_config.mobility.eNB_mobility.eNB_initial_distribution.selected_option, "fixed") == 0) { - omg_param_list[i].user_fixed = true; - omg_param_list[i].fixed_x = (double)oai_emulation.topology_config.mobility.eNB_mobility.fixed_eNB_distribution.pos_x; - omg_param_list[i].fixed_y = (double)oai_emulation.topology_config.mobility.eNB_mobility.fixed_eNB_distribution.pos_y; - } - - /*// at this moment, we use the above moving dynamics for mobile eNB - if (omg_param_list.nodes >0 ) - init_mobility_generator(omg_param_list);*/ - - } else if (i== UE) { // init OMG for UE - - - // input of OMG: STATIC: 0, RWP: 1, RWALK 2, or TRACE 3, or SUMO or STEADY_RWP - if ((oai_emulation.info.omg_model_ue = map_str_to_int(omg_model_names, oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option))== -1) - oai_emulation.info.omg_model_ue = STATIC; - - LOG_I(OMG,"UE mobility model is (%s, %d)\n", - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option, - oai_emulation.info.omg_model_ue); - - if (oai_emulation.info.omg_model_ue == RWP) { - oai_emulation.info.omg_rwp_type = map_str_to_int(omg_rwp_names,oai_emulation.topology_config.mobility.UE_mobility.grid_walk.grid_map.selected_option); - - if (oai_emulation.info.omg_rwp_type == -1) { - LOG_I(OMG,"Apply standard RWP model \n"); - } else { - LOG_I(OMG,"Apply %s mobility model (%d) \n", oai_emulation.topology_config.mobility.UE_mobility.grid_walk.grid_map.selected_option, - oai_emulation.info.omg_rwp_type); - omg_param_list[i].rwp_type= oai_emulation.info.omg_rwp_type; - omg_param_list[i].max_vertices = - max_vertices_ongrid (omg_param_list[i]); - - omg_param_list[i].max_block_num = - max_connecteddomains_ongrid (omg_param_list[i]); - } - } - - omg_param_list[i].mobility_type = oai_emulation.info.omg_model_ue; - omg_param_list[i].nodes = oai_emulation.info.nb_ue_local+ oai_emulation.info.nb_rn_local; - omg_param_list[i].seed = oai_emulation.info.seed + oai_emulation.info.nb_ue_local; //fixme: specific seed for enb and ue to avoid node overlapping - - omg_param_list[i].min_speed = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_speed_mps == 0) ? 0.1 : - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_speed_mps; - - omg_param_list[i].max_speed = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_speed_mps == 0) ? 0.1 : - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_speed_mps; - - omg_param_list[i].min_journey_time = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_journey_time_ms == 0) ? 0.1 : - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_journey_time_ms; - - omg_param_list[i].max_journey_time = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_journey_time_ms == 0) ? 0.1 : - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_journey_time_ms; - - omg_param_list[i].min_azimuth = 0.1; // wait for advanced OSD - omg_param_list[i].max_azimuth = 360; - - omg_param_list[i].min_sleep = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_sleep_ms == 0) ? 0.1 : - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_sleep_ms; - - omg_param_list[i].max_sleep = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_sleep_ms == 0) ? 0.1 : - oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_sleep_ms; - - - if (oai_emulation.info.omg_model_ue == TRACE) { - omg_param_list[i].mobility_file = (char*) malloc(256);// user-specific trace file "%s/UTIL/OMG/mobility.txt",getenv("OPENAIR2_DIR") - //memset(oai_emulation.topology_config.mobility.UE_mobility.trace_config.trace_mobility_file,0,256); - //sprintf(omg_param_list.mobility_file,"%s",oai_emulation.topology_config.mobility.UE_mobility.trace_config.trace_mobility_file); - snprintf( omg_param_list[i].mobility_file, 256, "%s/UTIL/OMG/TRACE/%s", - getenv("OPENAIR2_DIR"), - oai_emulation.topology_config.mobility.UE_mobility.trace_config.trace_mobility_file); - LOG_I(OMG,"TRACE file at %s\n", omg_param_list[i].mobility_file); - - } else if (oai_emulation.info.omg_model_ue == SUMO) { - omg_param_list[i].sumo_command = (char*) malloc(20); - sprintf(omg_param_list[i].sumo_command, "%s", oai_emulation.topology_config.mobility.UE_mobility.sumo_config.command); - omg_param_list[i].sumo_config = (char*) malloc(256); - sprintf(omg_param_list[i].sumo_config, "%s", oai_emulation.topology_config.mobility.UE_mobility.sumo_config.file); - omg_param_list[i].sumo_start = oai_emulation.topology_config.mobility.UE_mobility.sumo_config.start; - - if (oai_emulation.topology_config.mobility.UE_mobility.sumo_config.end > 0 ) - omg_param_list[i].sumo_end = oai_emulation.topology_config.mobility.UE_mobility.sumo_config.end; - else - omg_param_list[i].sumo_end = (oai_emulation.info.n_frames_flag == 1 ) ? oai_emulation.info.n_frames : MAX_FRAME_NUMBER ; // fixme: the else case is infinity - - omg_param_list[i].sumo_step = oai_emulation.topology_config.mobility.UE_mobility.sumo_config.step=1; // 1000ms - omg_param_list[i].sumo_host = (char*) malloc(40); - sprintf(omg_param_list[i].sumo_host,"%s",oai_emulation.topology_config.mobility.UE_mobility.sumo_config.hip); - omg_param_list[i].sumo_port = oai_emulation.topology_config.mobility.UE_mobility.sumo_config.hport ; - LOG_D(OMG, "opt (%s,%d) cmd (%s,%s) config_file (%s,%s) hip (%s,%s) \n", - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option,oai_emulation.info.omg_model_ue, - omg_param_list[i].sumo_command, oai_emulation.topology_config.mobility.UE_mobility.sumo_config.command, - omg_param_list[i].sumo_config, oai_emulation.topology_config.mobility.UE_mobility.sumo_config.file, - omg_param_list[i].sumo_host, oai_emulation.topology_config.mobility.UE_mobility.sumo_config.hip); - } - - } - - if (oai_emulation.topology_config.omv == 1 ) - oai_emulation.info.omv_enabled = 1; - - }//for - - - init_mobility_generator(omg_param_list); - - return 1; -} - - - -int ocg_config_app(void) -{ - - char colon[] = ":"; - char comma[] = ","; - char tmp_source_id[128]; - char tmp_destination_id[128]; - char *check_format1; - char *check_format2; - char *check_format1_dst; - char *source_id_start = NULL; - char *source_id_end = NULL; - char *destination_id_start; - char *destination_id_end; - int sid_start; - int sid_end; - int did_start; - int did_end; - char *per_source_id; - int source_id_index; - int destination_id_index; - int i,j,k,l; - - int predefined_traffic_config_index; - int customized_traffic_config_index; - unsigned int state; - - init_all_otg(oai_emulation.info.n_frames); - g_otg->seed= oai_emulation.info.seed; - g_otg->num_nodes = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_ue_local; - g_otg->throughput_metric =map_str_to_int(switch_names,oai_emulation.emulation_config.performance_metrics.throughput); - g_otg->latency_metric =map_str_to_int(switch_names,oai_emulation.emulation_config.performance_metrics.latency); - g_otg->loss_metric =map_str_to_int(switch_names,oai_emulation.emulation_config.performance_metrics.loss_rate); - g_otg->owd_radio_access =map_str_to_int(switch_names,oai_emulation.emulation_config.performance_metrics.owd_radio_access); - g_otg->curve=map_str_to_int(switch_names,oai_emulation.emulation_config.curve); - g_otg->background_stats=map_str_to_int(switch_names,oai_emulation.emulation_config.background_stats); - - g_otg->packet_gen_type=map_str_to_int(packet_gen_names,oai_emulation.application_config.packet_gen_type); - - LOG_I(OTG,"Metrics: Throuput %s(%d), One-way latency %s(%d) for %s, loss rate %s(%d), online curves %s(%d)\n", - oai_emulation.emulation_config.performance_metrics.throughput,g_otg->throughput_metric, - oai_emulation.emulation_config.performance_metrics.latency,g_otg->latency_metric, - (g_otg->owd_radio_access==1)? "Radio Access Network" : "End to End", - oai_emulation.emulation_config.performance_metrics.loss_rate,g_otg->loss_metric, - oai_emulation.emulation_config.curve,g_otg->curve ); - - for (i=0; inum_nodes; i++) { - - for (j=0; jnum_nodes; j++) { - // g_otg->duration[i][j]=oai_emulation.emulation_config.emulation_time_ms; - g_otg->dst_port[i][j]=oai_emulation.application_config.customized_traffic.destination_port[i]; - g_otg->dst_ip[i][j]=oai_emulation.application_config.customized_traffic.destination_id[i]; - - for (k=0; kip_v[i][j][k]=map_str_to_int(otg_ip_version_names, oai_emulation.application_config.customized_traffic.ip_version[i]); - g_otg->trans_proto[i][j][k]=map_str_to_int(otg_transport_protocol_names, oai_emulation.application_config.customized_traffic.transport_protocol[i]); - g_otg->application_type[i][j][k]=map_str_to_int(otg_app_type_names, "no_predefined_traffic"); - g_otg->aggregation_level[i][j][k]=oai_emulation.application_config.customized_traffic.aggregation_level[i]; - - g_otg->flow_start[i][j][k]=flow_start_time(i,j,oai_emulation.info.n_frames, - oai_emulation.application_config.customized_traffic.flow_start[i+j], - oai_emulation.application_config.customized_traffic.flow_duration[i+j]); - g_otg->flow_duration[i][j][k]=oai_emulation.application_config.customized_traffic.flow_duration[i+j]; - - for (l=0; lidt_dist[i][j][k][l]=map_str_to_int(otg_distribution_names, "no_customized_traffic"); - g_otg->idt_min[i][j][k][l]=oai_emulation.application_config.customized_traffic.idt_min_ms[i]; - g_otg->idt_max[i][j][k][l]=oai_emulation.application_config.customized_traffic.idt_max_ms[i]; - g_otg->idt_std_dev[i][j][k][l]=oai_emulation.application_config.customized_traffic.idt_standard_deviation[i]; - g_otg->idt_lambda[i][j][k][l]=oai_emulation.application_config.customized_traffic.idt_lambda[i]; - g_otg->idt_scale[i][j][k][l]=oai_emulation.application_config.customized_traffic.idt_scale[i]; - g_otg->idt_shape[i][j][k][l]=oai_emulation.application_config.customized_traffic.idt_shape[i]; - g_otg->size_dist[i][j][k][l]=map_str_to_int(otg_distribution_names, "no_customized_traffic"); - g_otg->size_min[i][j][k][l]=oai_emulation.application_config.customized_traffic.size_min_byte[i]; - g_otg->size_max[i][j][k][l]=oai_emulation.application_config.customized_traffic.size_max_byte[i]; - g_otg->size_std_dev[i][j][k][l]=oai_emulation.application_config.customized_traffic.size_standard_deviation[i]; - g_otg->size_lambda[i][j][k][l]=oai_emulation.application_config.customized_traffic.size_lambda[i]; - g_otg->size_scale[i][j][k][l]=oai_emulation.application_config.customized_traffic.size_scale[i]; - g_otg->size_shape[i][j][k][l]=oai_emulation.application_config.customized_traffic.size_shape[i]; - } - } - } - } - - LOG_D(OTG,"initializing the RNG with %s %d\n",(g_otg->seed==0)?"Random Seed" : "Fixed Seed", g_otg->seed); - init_seeds(g_otg->seed); // initialize all the nodes, then configure the nodes the user specifically did in the XML in the following - - LOG_I(OTG,"oai_emulation.info.max_predefined_traffic_config_index = %d\n", oai_emulation.info.max_predefined_traffic_config_index); - LOG_I(OTG,"oai_emulation.info.max_customized_traffic_config_index = %d\n", oai_emulation.info.max_customized_traffic_config_index); - - - if (oai_emulation.info.ocg_ok) { - ///// for the predefined traffic - for (predefined_traffic_config_index = 1; - predefined_traffic_config_index <= oai_emulation.info.max_predefined_traffic_config_index; - predefined_traffic_config_index++) { - - LOG_I(OTG,"OCG_config_OTG: predefined no. %d\n", predefined_traffic_config_index); - - //strcpy(tmp_source_id, oai_emulation.application_config.predefined_traffic.source_id[predefined_traffic_config_index]); - //strcpy(tmp_destination_id, oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - strncpy(tmp_source_id, oai_emulation.application_config.predefined_traffic.source_id[predefined_traffic_config_index], sizeof(tmp_source_id)); - tmp_source_id[sizeof(tmp_source_id) - 1] = 0; // terminate string - strncpy(tmp_destination_id, oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index], sizeof(tmp_destination_id)); - tmp_destination_id[sizeof(tmp_destination_id) - 1] = 0; // terminate string - check_format1 = strstr(tmp_source_id, colon); - check_format2 = strstr(tmp_source_id, comma); - check_format1_dst = strstr(tmp_destination_id, colon); - - - if (check_format1 != NULL) { // format 1:10 - source_id_start = strtok(tmp_source_id, colon); - source_id_end = strtok(NULL, colon); - - sid_start = atoi(source_id_start); - sid_end = atoi(source_id_end); - - //destination_id_index = atoi(oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - if (check_format1_dst != NULL) { // format 1:10 - destination_id_start = strtok(tmp_destination_id, colon); - destination_id_end = strtok(NULL, colon); - - did_start = atoi(destination_id_start); - did_end = atoi(destination_id_end); - } else { - did_start = atoi(oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - did_end = atoi(oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - } - - for (destination_id_index = did_start; destination_id_index <= did_end; destination_id_index++) { - for (source_id_index = sid_start; source_id_index <= sid_end; source_id_index++) { - if (g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] == 0) { // no app is defined for this pair src.dst - g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_app_type_names, - oai_emulation.application_config.predefined_traffic.application_type[predefined_traffic_config_index]); - - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.predefined_traffic.background[predefined_traffic_config_index]); - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.predefined_traffic.aggregation_level[predefined_traffic_config_index]; - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= flow_start_time(source_id_index,destination_id_index, - oai_emulation.info.n_frames,oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index], - oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]); - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]; - - LOG_I(OTG,"predef (1):: OCG_config_OTG [MAX UE=%d] [MAX eNB=%d]: FORMAT (%d:%d) source = %d, dest = %d, Application ID = %d background %d, Aggregation=%d , m2m= %d, flow start/duration %d/%d \n", - oai_emulation.info.nb_ue_local, oai_emulation.info.nb_enb_local, sid_start, sid_end, source_id_index, destination_id_index, - g_otg->application_idx[source_id_index][destination_id_index], - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->m2m[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]); - g_otg->application_idx[source_id_index][destination_id_index]+=1; - } - } - } - } else if (check_format2 != NULL) { // format 1,2,3,5 - per_source_id = strtok(tmp_source_id, comma); - destination_id_index = atoi(oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - - while (per_source_id != NULL) { - source_id_index = atoi(per_source_id); - - if (g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] == 0) { // no app is defined for this pair src.dst - g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_app_type_names, - oai_emulation.application_config.predefined_traffic.application_type[predefined_traffic_config_index]); - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.predefined_traffic.background[predefined_traffic_config_index]); - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.predefined_traffic.aggregation_level[predefined_traffic_config_index]; - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index, destination_id_index, - oai_emulation.info.n_frames,oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index], - oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]); - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]; - g_otg->application_idx[source_id_index][destination_id_index]+=1; - } - - per_source_id = strtok(NULL, comma); - - } - } else { // single node configuration - source_id_index = atoi(oai_emulation.application_config.predefined_traffic.source_id[predefined_traffic_config_index]); - //destination_id_index = atoi(oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - sid_start = atoi(oai_emulation.application_config.predefined_traffic.source_id[predefined_traffic_config_index]); - sid_end = atoi(oai_emulation.application_config.predefined_traffic.source_id[predefined_traffic_config_index]); - - if (check_format1_dst != NULL) { // format 1:10 - destination_id_start = strtok(tmp_destination_id, colon); - destination_id_end = strtok(NULL, colon); - - did_start = atoi(destination_id_start); - did_end = atoi(destination_id_end); - } else { - did_start = atoi(oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - did_end = atoi(oai_emulation.application_config.predefined_traffic.destination_id[predefined_traffic_config_index]); - } - - for (destination_id_index = did_start; destination_id_index <= did_end; destination_id_index++) { - for (source_id_index = sid_start; source_id_index <= sid_end; source_id_index++) { - if (g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] == 0) { // no app is defined for this pair src.dst - g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_app_type_names, - oai_emulation.application_config.predefined_traffic.application_type[predefined_traffic_config_index]); - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.predefined_traffic.background[predefined_traffic_config_index]); - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.predefined_traffic.aggregation_level[predefined_traffic_config_index]; - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index,destination_id_index, - oai_emulation.info.n_frames,oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index], - oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]); - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]; - - LOG_I(OTG,"predef (2):: OCG_config_OTG: [MAX UE=%d] [MAX eNB=%d]: FORMAT (%d:%d) source = %d, dest = %d, Application ID %d, type %d, Background=%d, Aggregation=%d, m2m=%d, start/duration %d/%d\n", - oai_emulation.info.nb_ue_local, oai_emulation.info.nb_enb_local, sid_start, sid_end, source_id_index, destination_id_index, - g_otg->application_idx[source_id_index][destination_id_index], - g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->m2m[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]); - g_otg->application_idx[source_id_index][destination_id_index]+=1; - } - } - } - } - - init_predef_traffic(oai_emulation.info.nb_ue_local, oai_emulation.info.nb_enb_local); - } - - ///////// for the customized traffic - for (customized_traffic_config_index = 1; - customized_traffic_config_index <= oai_emulation.info.max_customized_traffic_config_index; - customized_traffic_config_index++) { - - LOG_I(OTG,"OCG_config_OTG: customized no. %d, max_customized %d \n", customized_traffic_config_index, oai_emulation.info.max_customized_traffic_config_index); - strcpy(tmp_source_id, oai_emulation.application_config.customized_traffic.source_id[customized_traffic_config_index]); - - check_format1 = strstr(tmp_source_id, colon); - check_format2 = strstr(tmp_source_id, comma); - - strcpy(tmp_destination_id, oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]); - check_format1_dst = strstr(tmp_destination_id, colon); - state=PE_STATE; - - if (check_format1 != NULL) { // format 1:10 - source_id_start = strtok(tmp_source_id, colon); - source_id_end = strtok(NULL, colon) ; - - sid_start = atoi(source_id_start); - sid_end = atoi(source_id_end); - - if (check_format1_dst != NULL) { // format 1:10 - destination_id_start = strtok(tmp_destination_id, colon); - destination_id_end = strtok(NULL, colon); - - did_start = atoi(destination_id_start); - did_end = atoi(destination_id_end); - } else { - did_start = atoi(oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]); - did_end = atoi(oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]); - } - - for (destination_id_index = did_start; destination_id_index <= did_end; destination_id_index++) { - for (source_id_index = sid_start; source_id_index <= sid_end; source_id_index++) { - if (g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] == 0) { // no app is defined for this pair src.dst - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(switch_names, - oai_emulation.application_config.customized_traffic.background[customized_traffic_config_index]); - g_otg->m2m[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.customized_traffic.m2m[customized_traffic_config_index]); - g_otg->trans_proto[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_transport_protocol_names, - oai_emulation.application_config.customized_traffic.transport_protocol[customized_traffic_config_index]); - g_otg->ip_v[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_ip_version_names, - oai_emulation.application_config.customized_traffic.ip_version[customized_traffic_config_index]); - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.aggregation_level[customized_traffic_config_index]; - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= flow_start_time(source_id_index,destination_id_index, - oai_emulation.info.n_frames,oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index], - oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]); - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]; - g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, - oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]); - // printf("[OTG] config index %d dist %s\n", customized_traffic_config_index,oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]); - g_otg->idt_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_min_ms[customized_traffic_config_index]; - g_otg->idt_max[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_max_ms[customized_traffic_config_index]; - g_otg->idt_std_dev[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_standard_deviation[customized_traffic_config_index]; - g_otg->idt_lambda[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_lambda[customized_traffic_config_index]; - g_otg->idt_scale[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_scale[customized_traffic_config_index]; - g_otg->idt_shape[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_shape[customized_traffic_config_index]; - g_otg->size_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, - oai_emulation.application_config.customized_traffic.size_dist[customized_traffic_config_index]); - g_otg->size_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_min_byte[customized_traffic_config_index]; - g_otg->size_max[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_max_byte[customized_traffic_config_index]; - g_otg->size_std_dev[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_standard_deviation[customized_traffic_config_index]; - g_otg->size_lambda[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_lambda[customized_traffic_config_index]; - g_otg->size_scale[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_scale[customized_traffic_config_index]; - g_otg->size_shape[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_shape[customized_traffic_config_index]; - g_otg->dst_port[source_id_index][destination_id_index] = oai_emulation.application_config.customized_traffic.destination_port[customized_traffic_config_index]; - g_otg->pu_size_pkts[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.pu_size_pkts[customized_traffic_config_index]; - g_otg->ed_size_pkts[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.ed_size_pkts[customized_traffic_config_index]; - g_otg->prob_off_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_pu[customized_traffic_config_index]; - g_otg->prob_off_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_ed[customized_traffic_config_index]; - g_otg->prob_off_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_pe[customized_traffic_config_index]; - g_otg->prob_pu_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_pu_ed[customized_traffic_config_index]; - g_otg->prob_pu_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_pu_pe[customized_traffic_config_index]; - g_otg->prob_ed_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_ed_pe[customized_traffic_config_index]; - g_otg->prob_ed_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_ed_pu[customized_traffic_config_index]; - g_otg->holding_time_off_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_ed[customized_traffic_config_index]; - g_otg->holding_time_off_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_pu[customized_traffic_config_index]; - g_otg->holding_time_off_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_pe[customized_traffic_config_index]; - g_otg->holding_time_pe_off[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_pe_off[customized_traffic_config_index]; - - LOG_I(OTG,"customized:: OCG_config_OTG: (1) FORMAT (%d:%d) source = %d, dest = %d, Application = %d, state %d, background %d IDT DIST %d start/duration %d/%d\n", sid_start, sid_end, source_id_index, - destination_id_index, - g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - state, - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state], - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]); - - g_otg->application_idx[source_id_index][destination_id_index]+=1; - } - } - } - - } else if (check_format2 != NULL) { // format 1,2,3,5 - per_source_id = strtok(tmp_source_id, comma); - destination_id_index = atoi(oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]); - - while (per_source_id != NULL) { - source_id_index = atoi(per_source_id); - - if (g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] == 0) { // no app is defined for this pair src.dst - - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.customized_traffic.background[customized_traffic_config_index]); - g_otg->m2m[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.customized_traffic.m2m[customized_traffic_config_index]); - g_otg->trans_proto[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_transport_protocol_names, - oai_emulation.application_config.customized_traffic.transport_protocol[customized_traffic_config_index]); - g_otg->ip_v[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_ip_version_names, - oai_emulation.application_config.customized_traffic.ip_version[customized_traffic_config_index]); - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.aggregation_level[customized_traffic_config_index]; - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index,destination_id_index, - oai_emulation.info.n_frames,oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index], - oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]); - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]; - g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, - oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]); - g_otg->idt_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_min_ms[customized_traffic_config_index]; - g_otg->idt_max[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_max_ms[customized_traffic_config_index]; - g_otg->idt_std_dev[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_standard_deviation[customized_traffic_config_index]; - g_otg->idt_lambda[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_lambda[customized_traffic_config_index]; - g_otg->idt_scale[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_scale[customized_traffic_config_index]; - g_otg->idt_shape[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_shape[customized_traffic_config_index]; - g_otg->size_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, - oai_emulation.application_config.customized_traffic.size_dist[customized_traffic_config_index]); - g_otg->size_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_min_byte[customized_traffic_config_index]; - g_otg->size_max[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_max_byte[customized_traffic_config_index]; - g_otg->size_std_dev[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_standard_deviation[customized_traffic_config_index]; - g_otg->size_lambda[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_lambda[customized_traffic_config_index]; - g_otg->size_scale[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_scale[customized_traffic_config_index]; - g_otg->size_shape[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_shape[customized_traffic_config_index]; - g_otg->dst_port[source_id_index][destination_id_index] = oai_emulation.application_config.customized_traffic.destination_port[customized_traffic_config_index]; - g_otg->pu_size_pkts[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.pu_size_pkts[customized_traffic_config_index]; - g_otg->ed_size_pkts[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.ed_size_pkts[customized_traffic_config_index]; - g_otg->prob_off_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_pu[customized_traffic_config_index]; - g_otg->prob_off_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_ed[customized_traffic_config_index]; - g_otg->prob_off_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_pe[customized_traffic_config_index]; - g_otg->prob_pu_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_pu_ed[customized_traffic_config_index]; - g_otg->prob_pu_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_pu_pe[customized_traffic_config_index]; - g_otg->prob_ed_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_ed_pe[customized_traffic_config_index]; - g_otg->prob_ed_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_ed_pu[customized_traffic_config_index]; - g_otg->holding_time_off_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_ed[customized_traffic_config_index]; - g_otg->holding_time_off_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_pu[customized_traffic_config_index]; - g_otg->holding_time_off_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_pe[customized_traffic_config_index]; - g_otg->holding_time_pe_off[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_pe_off[customized_traffic_config_index]; - - - LOG_I(OTG,"customized:: OCG_config_OTG: (2) FORMAT (%s:%s) source = %d, dest = %d, dist type for size = %d [TODO: check code, printed value may not be correct, checks the indexes of the arry access] start/duration %d/%d\n", source_id_start, source_id_end, source_id_index, - destination_id_index, g_otg->size_dist[source_id_index][destination_id_index][0][0], - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]); - per_source_id = strtok(NULL, comma); - g_otg->application_idx[source_id_index][destination_id_index]+=1; - } - } - } else { // single node configuration - source_id_index = atoi(oai_emulation.application_config.customized_traffic.source_id[customized_traffic_config_index]); - //destination_id_index = atoi(oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]); - - sid_start = atoi(oai_emulation.application_config.customized_traffic.source_id[customized_traffic_config_index]); - sid_end = atoi(oai_emulation.application_config.customized_traffic.source_id[customized_traffic_config_index]); - - if (check_format1_dst != NULL) { // format 1:10 - destination_id_start = strtok(tmp_destination_id, colon); - destination_id_end = strtok(NULL, colon); - - did_start = atoi(destination_id_start); - did_end = atoi(destination_id_end); - } else { - did_start = atoi(oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]); - did_end = atoi(oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]); - } - - for (destination_id_index = did_start; destination_id_index <= did_end; destination_id_index++) { - for (source_id_index = sid_start; source_id_index <= sid_end; source_id_index++) { - - if (g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] == 0) { // no app is defined for this pair src.dst - - g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.customized_traffic.background[customized_traffic_config_index]); - g_otg->m2m[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names, - oai_emulation.application_config.customized_traffic.m2m[customized_traffic_config_index]); - - /* LOG_I(OTG, "[src %d][dst %d][app %d]test_m2m %d \n",source_id_index, destination_id_index , g_otg->application_idx[source_id_index][destination_id_index] , g_otg->m2m[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] ); - */ - - g_otg->trans_proto[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_transport_protocol_names, - oai_emulation.application_config.customized_traffic.transport_protocol[customized_traffic_config_index]); - g_otg->ip_v[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_ip_version_names, - oai_emulation.application_config.customized_traffic.ip_version[customized_traffic_config_index]); - g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.aggregation_level[customized_traffic_config_index]; - - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index,destination_id_index, - oai_emulation.info.n_frames,oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index], - oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]); - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]; - - g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, - oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]); - g_otg->idt_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_min_ms[customized_traffic_config_index]; - g_otg->idt_max[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_max_ms[customized_traffic_config_index]; - g_otg->idt_std_dev[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_standard_deviation[customized_traffic_config_index]; - g_otg->idt_lambda[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_lambda[customized_traffic_config_index]; - g_otg->idt_scale[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_scale[customized_traffic_config_index]; - g_otg->idt_shape[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.idt_shape[customized_traffic_config_index]; - g_otg->size_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, - oai_emulation.application_config.customized_traffic.size_dist[customized_traffic_config_index]); - g_otg->size_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_min_byte[customized_traffic_config_index]; - g_otg->size_max[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_max_byte[customized_traffic_config_index]; - g_otg->size_std_dev[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_standard_deviation[customized_traffic_config_index]; - g_otg->size_lambda[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_lambda[customized_traffic_config_index]; - g_otg->size_scale[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_scale[customized_traffic_config_index]; - g_otg->size_shape[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = - oai_emulation.application_config.customized_traffic.size_shape[customized_traffic_config_index]; - g_otg->dst_port[source_id_index][destination_id_index] = oai_emulation.application_config.customized_traffic.destination_port[customized_traffic_config_index]; - g_otg->pu_size_pkts[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.pu_size_pkts[customized_traffic_config_index]; - g_otg->ed_size_pkts[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.ed_size_pkts[customized_traffic_config_index]; - g_otg->prob_off_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_pu[customized_traffic_config_index]; - g_otg->prob_off_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_ed[customized_traffic_config_index]; - g_otg->prob_off_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_off_pe[customized_traffic_config_index]; - g_otg->prob_pu_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_pu_ed[customized_traffic_config_index]; - g_otg->prob_pu_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_pu_pe[customized_traffic_config_index]; - g_otg->prob_ed_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_ed_pe[customized_traffic_config_index]; - g_otg->prob_ed_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.prob_ed_pu[customized_traffic_config_index]; - g_otg->holding_time_off_ed[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_ed[customized_traffic_config_index]; - g_otg->holding_time_off_pu[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_pu[customized_traffic_config_index]; - g_otg->holding_time_off_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_off_pe[customized_traffic_config_index]; - g_otg->holding_time_pe_off[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= - oai_emulation.application_config.customized_traffic.holding_time_pe_off[customized_traffic_config_index]; - - LOG_I(OTG,"OCG_config_OTG (single node config): source = %d, dest = %d\n", source_id_index, destination_id_index); - LOG_I(OTG,"customized:: OCG_config_OTG:(3) FORMAT (%d:%d) source = %d, dest = %d, Application = %d, IDT dist %d flow start %d duration %d \n", - did_start, did_end, source_id_index, destination_id_index, - g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state], - g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], - g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]); - g_otg->application_idx[source_id_index][destination_id_index]+=1; - - } - } - } - } - } - } - - - if ((oai_emulation.info.max_predefined_traffic_config_index == 0) && - (oai_emulation.info.max_customized_traffic_config_index == 0) && - (oai_emulation.info.otg_enabled==1)) { // OCG not used to configure OTG, but -T option is used, so config here - LOG_I(OTG,"configure OTG through options %s\n", oai_emulation.info.otg_traffic); - - for (i=0; inum_nodes; i++) { - for (j=0; jnum_nodes; j++) { - g_otg->application_idx[i][j]=1; - - for (k=0; kapplication_idx[i][j]; k++) { - - g_otg->application_type[i][j][k] = map_str_to_int(otg_app_type_names, oai_emulation.info.otg_traffic); - g_otg->background[i][j][k]=oai_emulation.info.otg_bg_traffic_enabled; - g_otg->packet_gen_type=SUBSTRACT_STRING; - g_otg->flow_start[i][j][k]=flow_start_time(i,j,oai_emulation.info.n_frames, - oai_emulation.application_config.customized_traffic.flow_start[i+j], - oai_emulation.application_config.customized_traffic.flow_duration[i+j]); - g_otg->flow_duration[i][j][k]=oai_emulation.application_config.customized_traffic.flow_duration[i+j]; - LOG_I(OTG,"predefined traffic:: source = %d, dest = %d, Application = %d, start %d duration %d \n", - i,j, g_otg->application_type[i][j][k],g_otg->flow_start[i][j][k],g_otg->flow_duration[i][j][k]); - } - } - } - - init_predef_traffic(oai_emulation.info.nb_ue_local, oai_emulation.info.nb_enb_local); - - for (i=0; iapplication_type[i][j][k] = map_str_to_int( otg_multicast_app_type_names, oai_emulation.info.otg_traffic); - } - } - } - - init_predef_multicast_traffic(); - LOG_I(OTG,"initilizae multicast traffic %s\n",oai_emulation.info.otg_traffic); - - } - - return 1; -} - -int flow_start_time(int sid, int did, uint32_t n_frames, uint32_t start, uint32_t duration) -{ - - int offset0=uniform_dist(1,10); - int offset1=uniform_dist(10,100); - int offset2=uniform_dist(100,1000); - int interval = 300; - int flow_start_margin_1=0; - int flow_start_margin_2=0; - - // return user-defined flow start time - if (start > 0 ) - return start; - - //determine the flow start time - start = (sid+did+1)*interval; - flow_start_margin_1 = 10*n_frames - (start + offset1 + duration); - flow_start_margin_2 = 10*n_frames - (start + offset2 + duration); - - //LOG_I(OTG,"nframes %d start %d margin_1 %d margin_2 %d\n",n_frames, start,flow_start_margin_1, flow_start_margin_2); - if (flow_start_margin_2 > 0 ) - return uniform_dist(start, start+offset2); - else if (flow_start_margin_1 > 0 ) - return uniform_dist(start, start+offset1); - else - return uniform_dist(start, start+offset0); - -} - - -int ocg_config_emu(void) -{ - - if (oai_emulation.emulation_config.emulation_time_ms != 0) { - oai_emulation.info.n_frames = (int) oai_emulation.emulation_config.emulation_time_ms / 10; // configure the number of frame - oai_emulation.info.n_frames_flag = 1; - } - - if (oai_emulation.info.n_frames_flag) { - LOG_I(OCG, "number of frames in emulation is set to %d\n", oai_emulation.info.n_frames); - } else { - LOG_I(OCG, "number of frames in emulation is set to infinity\n"); - } - - oai_emulation.info.seed = (oai_emulation.emulation_config.seed.value == 0) ? oai_emulation.info.seed : oai_emulation.emulation_config.seed.value; - LOG_I (OCG,"The seed value is set to %d \n", oai_emulation.info.seed ); - - if (oai_emulation.info.cli_enabled == 1) { - if (cli_server_init(cli_server_recv) < 0) { - LOG_E(EMU,"cli server init failed \n"); - exit(-1); - } - - LOG_I(EMU, "OAI CLI is enabled\n"); - LOG_I(EMU,"eNB start state is %d, UE start state %d\n", - oai_emulation.info.cli_start_enb[0], - oai_emulation.info.cli_start_ue[0]); - } - - if (oai_emulation.info.opp_enabled) - opp_enabled = 1; - - //bin/LOG_I(OCG, "OPT output file directory = %s\n", oai_emulation.info.output_path); - oai_emulation.info.opt_enabled = ( oai_emulation.emulation_config.packet_trace.enabled == 0) ? oai_emulation.info.opt_enabled : oai_emulation.emulation_config.packet_trace.enabled; - - if (oai_emulation.info.opt_enabled == 1) { - radio_type_t radio_type; - opt_enabled = 1; - - if (oai_emulation.info.frame_type[0] == FDD) { - radio_type = RADIO_TYPE_FDD; - } else { - radio_type = RADIO_TYPE_TDD; - } - - opt_type = oai_emulation.info.opt_mode; - - if (init_opt(NULL, NULL, NULL, radio_type) == -1) { - LOG_E(OPT,"failed to run OPT \n"); - } - } - - return 1; -} - -void ocg_config_proto(void) -{ - - LOG_I(MAC,"num groups is set to %d\n",oai_emulation.protocol_config.eNB_mac_config.num_groups); - -} - diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c deleted file mode 100644 index 967ef8974a..0000000000 --- a/targets/SIMU/USER/oaisim_functions.c +++ /dev/null @@ -1,1831 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file oaisim_functions.c -* \brief function primitives of oaisim -* \author Navid Nikaein -* \date 2013-2015 -* \version 1.0 -* \company Eurecom -* \email: openair_tech@eurecom.fr -* \note -* \warning -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "assertions.h" -#include "oaisim_functions.h" - -#include "PHY/extern.h" -#include "LAYER2/MAC/extern.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/proto.h" -#endif -#include "LAYER2/PDCP_v10.1.0/pdcp.h" -#include "LAYER2/PDCP_v10.1.0/pdcp_primitives.h" -#include "RRC/LITE/extern.h" -#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "PHY_INTERFACE/extern.h" -//#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h" -#include "SCHED/extern.h" -#include "SIMULATION/ETH_TRANSPORT/proto.h" -#include "UTIL/OCG/OCG_extern.h" -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "UTIL/OPT/opt.h" -#include "UTIL/OTG/otg_config.h" -#include "UTIL/OTG/otg_tx.h" -#if ENABLE_RAL -#include "lteRALenb.h" -#include "lteRALue.h" -#endif - -#include "cor_SF_sim.h" -#include "enb_config.h" - -#if defined(ENABLE_ITTI) -# include "intertask_interface.h" -#endif - -#if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -#endif - -#include "../../ARCH/COMMON/common_lib.h" -#include "../../ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" - -#include "ENB_APP/enb_paramdef.h" -#include "common/config/config_userapi.h" - -#ifdef SMBV -extern uint8_t config_smbv; -extern char smbv_ip[16]; -#endif - -//constant for OAISIM soft realtime calibration -#define SF_DEVIATION_OFFSET_NS 100000 //= 0.1ms : should be as a number of UE -#define SLEEP_STEP_US 100 // = 0.01ms could be adaptive, should be as a number of UE -#define K 2 // averaging coefficient -#define TARGET_SF_TIME_NS 1000000 // 1ms = 1000000 ns - - -int otg_times = 0; -int if_times = 0; -int for_times = 0; - -uint16_t Nid_cell = 0; //needed by init_lte_vars -int nb_antennas_rx_ue = 1; // // -uint8_t target_dl_mcs = 16; // max mcs used by MAC scheduler -uint8_t rate_adaptation_flag = 0; -uint8_t set_snr = 0; -uint8_t set_sinr = 0; -double snr_dB=0, sinr_dB=0; -uint8_t set_seed = 0; -uint8_t cooperation_flag; // for cooperative communication -uint8_t abstraction_flag = 0; -uint8_t ethernet_flag = 0; -double snr_step = 1.0; -uint8_t ue_connection_test = 0; -double forgetting_factor = 0.0; -uint8_t beta_ACK = 0; -uint8_t beta_RI = 0; -uint8_t beta_CQI = 2; -uint8_t target_ul_mcs = 16; -//LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; -int map1,map2; -double **ShaF = NULL; -// pointers signal buffers (s = transmit, r,r0 = receive) -double **s_re, **s_im, **r_re, **r_im, **r_re0, **r_im0; -node_list* ue_node_list = NULL; -node_list* enb_node_list = NULL; -int omg_period = 10000; -int pdcp_period = 0; -int cba_backoff = 30; -// time calibration for soft realtime mode -struct timespec time_spec; -unsigned long time_last = 0; -unsigned long time_now = 0; -int td = 0; -int td_avg = 0; -int sleep_time_us = 0; - -int phy_test = 0; - -#ifdef OPENAIR2 -// omv related info -//pid_t omv_pid; -char full_name[200]; -extern int pfd[2]; // fd for omv : fixme: this could be a local var -char fdstr[10]; -char frames[10]; -char num_enb[10]; -char num_ue[10]; -//area_x, area_y and area_z for omv -char x_area[20]; -char y_area[20]; -char z_area[20]; -char nb_antenna[20]; -char frame_type[10]; -char tdd_config[10]; -#endif - -Packet_OTG_List_t *otg_pdcp_buffer = NULL; - -extern node_desc_t *enb_data[NUMBER_OF_RU_MAX]; -extern node_desc_t *ue_data[NUMBER_OF_UE_MAX]; -extern channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; -extern channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - -extern mapping small_scale_names[]; -#if defined(Rel10) || defined(Rel14) -extern pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH]; -extern pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH]; -#endif - -extern time_stats_t dl_chan_stats; -extern time_stats_t ul_chan_stats; - -extern int xforms; - - -extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; -extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; - -int oaisim_flag=1; - - -void RCConfig_sim(void) { - - paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; - - - // Get num RU instances - config_getlist( &RUParamList,NULL,0, NULL); - RC.nb_RU = RUParamList.numelt; - - -} - -void get_simulation_options(int argc, char *argv[]) -{ - int option; - - enum long_option_e { - LONG_OPTION_START = 0x100, /* Start after regular single char options */ - - LONG_OPTION_ENB_CONF, - - LONG_OPTION_PDNC_PERIOD, - LONG_OPTION_OMG_PERIOD, - LONG_OPTION_OEH_ENABLED, - - LONG_OPTION_ENB_RAL_LISTENING_PORT, - LONG_OPTION_ENB_RAL_IP_ADDRESS, - LONG_OPTION_ENB_RAL_LINK_ID, - LONG_OPTION_ENB_RAL_LINK_ADDRESS, - - LONG_OPTION_ENB_MIHF_REMOTE_PORT, - LONG_OPTION_ENB_MIHF_IP_ADDRESS, - LONG_OPTION_ENB_MIHF_ID, - - LONG_OPTION_UE_RAL_LISTENING_PORT, - LONG_OPTION_UE_RAL_IP_ADDRESS, - LONG_OPTION_UE_RAL_LINK_ID, - LONG_OPTION_UE_RAL_LINK_ADDRESS, - - LONG_OPTION_UE_MIHF_REMOTE_PORT, - LONG_OPTION_UE_MIHF_IP_ADDRESS, - LONG_OPTION_UE_MIHF_ID, - - LONG_OPTION_MALLOC_TRACE_ENABLED, - - LONG_OPTION_CBA_BACKOFF_TIMER, - - LONG_OPTION_PHYTEST, - LONG_OPTION_XFORMS, - -#if T_TRACER - LONG_OPTION_T_PORT, - LONG_OPTION_T_NOWAIT, - LONG_OPTION_T_DONT_FORK, -#endif - }; - - static struct option long_options[] = { - {"enb-conf", required_argument, 0, LONG_OPTION_ENB_CONF}, - - {"pdcp-period", required_argument, 0, LONG_OPTION_PDNC_PERIOD}, - {"omg-period", required_argument, 0, LONG_OPTION_OMG_PERIOD}, - {"oeh-enabled", no_argument, 0, LONG_OPTION_OEH_ENABLED}, - - {"enb-ral-listening-port", required_argument, 0, LONG_OPTION_ENB_RAL_LISTENING_PORT}, - {"enb-ral-ip-address", required_argument, 0, LONG_OPTION_ENB_RAL_IP_ADDRESS}, - {"enb-ral-link-id", required_argument, 0, LONG_OPTION_ENB_RAL_LINK_ID}, - {"enb-ral-link-address", required_argument, 0, LONG_OPTION_ENB_RAL_LINK_ADDRESS}, - - {"enb-mihf-remote-port", required_argument, 0, LONG_OPTION_ENB_MIHF_REMOTE_PORT}, - {"enb-mihf-ip-address", required_argument, 0, LONG_OPTION_ENB_MIHF_IP_ADDRESS}, - {"enb-mihf-id", required_argument, 0, LONG_OPTION_ENB_MIHF_ID}, - - {"ue-ral-listening-port", required_argument, 0, LONG_OPTION_UE_RAL_LISTENING_PORT}, - {"ue-ral-ip-address", required_argument, 0, LONG_OPTION_UE_RAL_IP_ADDRESS}, - {"ue-ral-link-id", required_argument, 0, LONG_OPTION_UE_RAL_LINK_ID}, - {"ue-ral-link-address", required_argument, 0, LONG_OPTION_UE_RAL_LINK_ADDRESS}, - - {"ue-mihf-remote-port", required_argument, 0, LONG_OPTION_UE_MIHF_REMOTE_PORT}, - {"ue-mihf-ip-address", required_argument, 0, LONG_OPTION_UE_MIHF_IP_ADDRESS}, - {"ue-mihf-id", required_argument, 0, LONG_OPTION_UE_MIHF_ID}, - - {"malloc-trace-enabled", no_argument, 0, LONG_OPTION_MALLOC_TRACE_ENABLED}, - - {"cba-backoff", required_argument, 0, LONG_OPTION_CBA_BACKOFF_TIMER}, - - {"phy-test", no_argument, NULL, LONG_OPTION_PHYTEST}, - {"xforms", no_argument, 0, LONG_OPTION_XFORMS}, - -#if T_TRACER - {"T_port", required_argument, 0, LONG_OPTION_T_PORT}, - {"T_nowait", no_argument, 0, LONG_OPTION_T_NOWAIT}, - {"T_dont_fork", no_argument, 0, LONG_OPTION_T_DONT_FORK}, -#endif - - {NULL, 0, NULL, 0} - }; - - while ((option = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hHi:IJ:j:k:K:l:L:m:M:n:N:oO:p:P:qQ:rR:s:S:t:T:u:U:vV:w:W:x:X:y:Y:z:Z:", long_options, NULL)) != -1) { - switch (option) { - case LONG_OPTION_PHYTEST: - phy_test = 1; - break; - - case LONG_OPTION_ENB_CONF: - if (optarg) { - free(RC.config_file_name); // prevent memory leak if option is used multiple times - RC.config_file_name = strdup(optarg); - printf("eNB configuration file is %s\n", RC.config_file_name); - } - - break; - - case LONG_OPTION_PDNC_PERIOD: - if (optarg) { - pdcp_period = atoi(optarg); - printf("PDCP period is %d\n", pdcp_period); - } - - break; - - case LONG_OPTION_OMG_PERIOD: - if (optarg) { - omg_period = atoi(optarg); - printf("OMG period is %d\n", omg_period); - } - - break; - - case LONG_OPTION_OEH_ENABLED: - oai_emulation.info.oeh_enabled = 1; - break; - - case LONG_OPTION_MALLOC_TRACE_ENABLED: - mtrace(); - break; - - case LONG_OPTION_CBA_BACKOFF_TIMER: - oai_emulation.info.cba_backoff=atoi(optarg); - cba_backoff=atoi(optarg); - printf("setting CBA backoff to %d\n", cba_backoff); - break; - -#if ENABLE_RAL - - case LONG_OPTION_ENB_RAL_LISTENING_PORT: - if (optarg) { - g_conf_enb_ral_listening_port = strdup(optarg); - printf("eNB RAL listening port is %s\n", g_conf_enb_ral_listening_port); - } - - break; - - case LONG_OPTION_ENB_RAL_IP_ADDRESS: - if (optarg) { - g_conf_enb_ral_ip_address = strdup(optarg); - printf("eNB RAL IP address is %s\n", g_conf_enb_ral_ip_address); - } - - break; - - case LONG_OPTION_ENB_RAL_LINK_ADDRESS: - if (optarg) { - g_conf_enb_ral_link_address = strdup(optarg); - printf("eNB RAL link address is %s\n", g_conf_enb_ral_link_address); - } - - break; - - case LONG_OPTION_ENB_RAL_LINK_ID: - if (optarg) { - g_conf_enb_ral_link_id = strdup(optarg); - printf("eNB RAL link id is %s\n", g_conf_enb_ral_link_id); - } - - break; - - case LONG_OPTION_ENB_MIHF_REMOTE_PORT: - if (optarg) { - g_conf_enb_mihf_remote_port = strdup(optarg); - printf("eNB MIH-F remote port is %s\n", g_conf_enb_mihf_remote_port); - } - - break; - - case LONG_OPTION_ENB_MIHF_IP_ADDRESS: - if (optarg) { - g_conf_enb_mihf_ip_address = strdup(optarg); - printf("eNB MIH-F IP address is %s\n", g_conf_enb_mihf_ip_address); - } - - break; - - case LONG_OPTION_ENB_MIHF_ID: - if (optarg) { - g_conf_enb_mihf_id = strdup(optarg); - printf("eNB MIH-F id is %s\n", g_conf_enb_mihf_id); - } - - break; - - case LONG_OPTION_UE_RAL_LISTENING_PORT: - if (optarg) { - g_conf_ue_ral_listening_port = strdup(optarg); - printf("UE RAL listening port is %s\n", g_conf_ue_ral_listening_port); - } - - break; - - case LONG_OPTION_UE_RAL_IP_ADDRESS: - if (optarg) { - g_conf_ue_ral_ip_address = strdup(optarg); - printf("UE RAL IP address is %s\n", g_conf_ue_ral_ip_address); - } - - break; - - case LONG_OPTION_UE_RAL_LINK_ID: - if (optarg) { - g_conf_ue_ral_link_id = strdup(optarg); - printf("UE RAL link id is %s\n", g_conf_ue_ral_link_id); - } - - break; - - case LONG_OPTION_UE_RAL_LINK_ADDRESS: - if (optarg) { - g_conf_ue_ral_link_address = strdup(optarg); - printf("UE RAL link address is %s\n", g_conf_ue_ral_link_address); - } - - break; - - case LONG_OPTION_UE_MIHF_REMOTE_PORT: - if (optarg) { - g_conf_ue_mihf_remote_port = strdup(optarg); - printf("UE MIH-F remote port is %s\n", g_conf_ue_mihf_remote_port); - } - - break; - - case LONG_OPTION_UE_MIHF_IP_ADDRESS: - if (optarg) { - g_conf_ue_mihf_ip_address = strdup(optarg); - printf("UE MIH-F IP address is %s\n", g_conf_ue_mihf_ip_address); - } - - break; - - case LONG_OPTION_UE_MIHF_ID: - if (optarg) { - g_conf_ue_mihf_id = strdup(optarg); - printf("UE MIH-F id is %s\n", g_conf_ue_mihf_id); - } - - break; -#endif - - case LONG_OPTION_XFORMS: - xforms=1; - break; - -#if T_TRACER - case LONG_OPTION_T_PORT: { - extern int T_port; - if (optarg == NULL) abort(); /* should not happen */ - T_port = atoi(optarg); - break; - } - - case LONG_OPTION_T_NOWAIT: { - extern int T_wait; - T_wait = 0; - break; - } - - case LONG_OPTION_T_DONT_FORK: { - extern int T_dont_fork; - T_dont_fork = 1; - break; - } -#endif - - case 'a': - abstraction_flag = 1; - printf("FATAL: -a flag not functional for the moment.\nWe are working on fixing the abstraction mode.\n"); - exit(1); - break; - - case 'A': - - //oai_emulation.info.ocm_enabled=1; - if (optarg == NULL) - oai_emulation.environment_system_config.fading.small_scale.selected_option="AWGN"; - else - oai_emulation.environment_system_config.fading.small_scale.selected_option= optarg; - - //awgn_flag = 1; - break; - - case 'b': - oai_emulation.info.nb_enb_local = atoi (optarg); - break; - - case 'B': - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option = optarg; - //oai_emulation.info.omg_model_enb = atoi (optarg); - break; - - case 'c': - //strcpy(oai_emulation.info.local_server, optarg); - strncpy(oai_emulation.info.local_server, optarg, sizeof(oai_emulation.info.local_server)); - oai_emulation.info.local_server[sizeof(oai_emulation.info.local_server) - 1] = 0; // terminate string - oai_emulation.info.ocg_enabled=1; - break; - - case 'C': - oai_emulation.info.tdd_config[0] = atoi (optarg); - AssertFatal (oai_emulation.info.tdd_config[0] <= TDD_Config__subframeAssignment_sa6, "Illegal tdd_config %d (should be 0-%d)!", - oai_emulation.info.tdd_config[0], TDD_Config__subframeAssignment_sa6); - break; - - case 'D': - oai_emulation.info.multicast_ifname = strdup(optarg); - break; - - case 'e': - oai_emulation.info.extended_prefix_flag[0] = 1; - break; - - case 'E': - set_seed = 1; - oai_emulation.info.seed = atoi (optarg); - break; - - case 'f': - forgetting_factor = atof (optarg); - break; - - case 'F': // set FDD - printf("Setting Frame to FDD\n"); - oai_emulation.info.frame_type[0] = 0; - oai_emulation.info.frame_type_name[0] = "FDD"; - break; - - case 'g': - oai_emulation.info.multicast_group = atoi (optarg); - break; - - case 'G' : - oai_emulation.info.otg_bg_traffic_enabled = 1; - break; - - case 'h': - help (); - exit (1); - break; - - case 'H': - oai_emulation.info.handover_active=1; - printf("Activate the handover procedure at RRC\n"); - break; - - case 'i': -#ifdef PROC - Process_Flag=1; - node_id = wgt+atoi(optarg); - port+=atoi(optarg); -#endif - break; - - case 'I': - oai_emulation.info.cli_enabled = 1; - break; - - case 'j' : - // number of relay nodes: currently only applicable to eMBMS - oai_emulation.info.nb_rn_local = atoi (optarg); - break; - - case 'J': - ue_connection_test=1; - oai_emulation.info.ocm_enabled=0; - snr_step = atof(optarg); - break; - - case 'k': - //ricean_factor = atof (optarg); - printf("[SIM] Option k is no longer supported on the command line. Please specify your channel model in the xml template\n"); - exit(-1); - break; - - case 'K': - oai_emulation.info.itti_dump_file = optarg; - break; - - case 'l': - oai_emulation.info.g_log_level = atoi(optarg); - break; - - case 'L': // set FDD - flag_LA = atoi(optarg); - break; - - case 'm': - target_dl_mcs = atoi (optarg); - printf("Max target downlink MCS used by MAC scheduler is set to %d\n", target_dl_mcs); - break; - - case 'M': - abstraction_flag = 1; - ethernet_flag = 1; - oai_emulation.info.ethernet_id = atoi (optarg); - oai_emulation.info.master_id = oai_emulation.info.ethernet_id; - oai_emulation.info.ethernet_flag = 1; - break; - - case 'n': - oai_emulation.info.n_frames = atoi (optarg); - oai_emulation.emulation_config.emulation_time_ms= oai_emulation.info.n_frames * 10; // 10 ms frame - //n_frames = (n_frames >1024) ? 1024: n_frames; // adjust the n_frames if higher that 1024 - oai_emulation.info.n_frames_flag = 1; - break; - - case 'N': - Nid_cell = atoi (optarg); - - if (Nid_cell > 503) { - printf("Illegal Nid_cell %d (should be 0 ... 503)\n", Nid_cell); - exit(-1); - } - - break; - - case 'O': - if (optarg) { - free(RC.config_file_name); // prevent memory leak if option is used multiple times - RC.config_file_name = strdup(optarg); - } - - break; - - case 'o': - oai_emulation.info.slot_isr = 1; - break; - - case 'p': - oai_emulation.info.nb_master = atoi (optarg); - break; - - case 'P': - oai_emulation.info.opt_enabled = 1; - opt_enabled = 1; - - if (strcmp(optarg, "wireshark") == 0) { - opt_type = OPT_WIRESHARK; - printf("Enabling OPT for wireshark\n"); - } else if (strcmp(optarg, "pcap") == 0) { - opt_type = OPT_PCAP; - printf("Enabling OPT for pcap\n"); - } else { - printf("Unrecognized option for OPT module. -> Disabling it\n"); - printf("Possible values are either wireshark or pcap\n"); - opt_type = OPT_NONE; - oai_emulation.info.opt_enabled = 0; - opt_enabled = 0; - } - - oai_emulation.info.opt_mode = opt_type; - break; - - case 'q': - // openair performane profiler - oai_emulation.info.opp_enabled = 1; // this var is used for OCG - opp_enabled = 1; // this is the global var used by oaisim - break; - - case 'Q': - //eMBMS_active=1; - // 0 : not used (default), 1: eMBMS and RRC enabled, 2: eMBMS relaying and RRC enabled, 3: eMBMS enabled, RRC disabled, 4: eMBMS relaying enabled, RRC disabled - oai_emulation.info.eMBMS_active_state = atoi (optarg); - break; - - case 'r': - rate_adaptation_flag = 1; - break; - - case 'R': - oai_emulation.info.N_RB_DL[0] = atoi (optarg); - - if ((oai_emulation.info.N_RB_DL[0] != 6) && (oai_emulation.info.N_RB_DL[0] != 15) && (oai_emulation.info.N_RB_DL[0] != 25) - && (oai_emulation.info.N_RB_DL[0] != 50) && (oai_emulation.info.N_RB_DL[0] != 75) && (oai_emulation.info.N_RB_DL[0] != 100)) { - printf("Illegal N_RB_DL %d (should be one of 6,15,25,50,75,100)\n", oai_emulation.info.N_RB_DL[0]); - exit (-1); - } - - break; - - case 's': - snr_dB = atoi (optarg); - // set_snr = 1; - oai_emulation.info.ocm_enabled=0; - break; - - case 'S': - sinr_dB = atoi (optarg); - set_sinr = 1; - oai_emulation.info.ocm_enabled=0; - break; - - case 't': - target_ul_mcs = atoi (optarg); - printf("Max target uplink MCS used by MAC scheduler is set to %d\n", target_ul_mcs); - break; - - case 'T': - oai_emulation.info.otg_enabled = 1; - oai_emulation.info.otg_traffic = optarg; - break; - - case 'u': - oai_emulation.info.nb_ue_local = atoi (optarg); - break; - - case 'U': - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option = optarg; - break; - - case 'v': - oai_emulation.info.omv_enabled = 1; - break; - - case 'V': - ouput_vcd = 1; - oai_emulation.info.vcd_enabled = 1; - oai_emulation.info.vcd_file = optarg; - break; - - case 'w': - oai_emulation.info.cba_group_active = atoi (optarg); - break; - - case 'W': -#ifdef SMBV - config_smbv = 1; - - if(atoi(optarg)!=0) - strcpy(smbv_ip,optarg); - -#endif - break; - - case 'x': - /* - oai_emulation.info.transmission_mode[0] = atoi (optarg); - - if ((oai_emulation.info.transmission_mode[0] != 1) && (oai_emulation.info.transmission_mode[0] != 2) && - (oai_emulation.info.transmission_mode[0] != 3) && (oai_emulation.info.transmission_mode[0] != 4) && - (oai_emulation.info.transmission_mode[0] != 5) && (oai_emulation.info.transmission_mode[0] != 6)) && (oai_emulation.info.transmission_mode[0] !=7)) { - printf("Unsupported transmission mode %d\n",oai_emulation.info.transmission_mode[0]); - exit(-1); - } - */ - printf("Option -x deprecated. Please set transmission mode in eNB config file\n"); - exit(-1); - - break; - - case 'X': -#ifdef PROC - temp=atoi(optarg); - - if(temp==0) { - port=CHANNEL_PORT; - Channel_Flag=1; - Process_Flag=0; - wgt=0; - } else if(temp==1) { - port=eNB_PORT; - wgt=0; - } else { - port=UE_PORT; - wgt=MAX_eNB; - } - -#endif - break; - - case 'y': - nb_antennas_rx_ue=atoi(optarg); - - if (nb_antennas_rx_ue>4) { - printf("Cannot have more than 4 antennas\n"); - exit(-1); - } - - break; - - case 'Y': - oai_emulation.info.g_log_verbosity_option = strdup(optarg); - break; - - case 'z': - cooperation_flag = atoi (optarg); - break; - - case 'Z': - /* Sebastien ROUX: Reserved for future use (currently used in ltenow branch) */ - break; - - default: - help (); - exit (-1); - break; - } - } - - if ( load_configmodule(argc,argv) == NULL) { - exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); - } - - if (RC.config_file_name != NULL) { - /* Read eNB configuration file */ - RCConfig_sim(); - printf("returned with %d eNBs, %d rus\n",RC.nb_inst,RC.nb_RU); - oai_emulation.info.nb_enb_local = RC.nb_inst; - oai_emulation.info.nb_ru_local = RC.nb_RU; - - /* - for (int j=0; jnb_ru; j++) { - - // local_remote_radio = BBU_REMOTE_RADIO_HEAD; - (eth_params+j)->local_if_name = enb_properties->ru_config[j]->ru_if_name; - (eth_params+j)->my_addr = enb_properties->ru_config[j]->local_address; - (eth_params+j)->my_port = enb_properties->ru_config[j]->local_port; - (eth_params+j)->remote_addr = enb_properties->ru_config[j]->remote_address; - (eth_params+j)->remote_port = enb_properties->ru_config[j]->remote_port; - - if (enb_properties->ru_config[j]->raw == 1) { - (eth_params+j)->transp_preference = ETH_RAW_MODE; - ru_if_in[j] = REMOTE_IF5; - node_function[j] = NGFI_RRU_IF5; - } else if (enb_properties->ru_config[j]->rawif4p5 == 1) { - (eth_params+j)->transp_preference = ETH_RAW_IF4p5_MODE; - ru_if_in[j] = REMOTE_IF4p5; - node_function[j] = NGFI_RRU_IF4p5; - } else if (enb_properties->ru_config[j]->udpif4p5 == 1) { - (eth_params+j)->transp_preference = ETH_UDP_IF4p5_MODE; - ru_if_in[j] = REMOTE_IF4p5; - node_function[j] = NGFI_RRU_IF4p5; - } else if (enb_properties->ru_config[j]->rawif5_mobipass == 1) { - (eth_params+j)->transp_preference = ETH_RAW_IF5_MOBIPASS; - ru_if_in[j] = REMOTE_IF5; - LOG_E(EMU,"Don't use 8-bit IF5 format with oaisim, please change in configuration file\n"); - } else { - (eth_params+j)->transp_preference = ETH_UDP_MODE; - ru_if_in[j] = REMOTE_IF5; - node_function[j] = NGFI_RRU_IF5; - } - node_timing[j] = synch_to_ext_device; - - if (enb_properties->number > 0) { - //Update some simulation parameters - oai_emulation.info.frame_type[0] = enb_properties->properties[0]->frame_type[0]; - oai_emulation.info.tdd_config[0] = enb_properties->properties[0]->tdd_config[0]; - oai_emulation.info.tdd_config_S[0] = enb_properties->properties[0]->tdd_config_s[0]; - oai_emulation.info.extended_prefix_flag[0] = enb_properties->properties[0]->prefix_type[0]; - - oai_emulation.info.node_function[0] = enb_properties->properties[0]->cc_node_function[0]; - oai_emulation.info.node_timing[0] = enb_properties->properties[0]->cc_node_timing[0]; - downlink_frequency[0][0] = enb_properties->properties[0]->downlink_frequency[0]; - uplink_frequency_offset[0][0] = enb_properties->properties[0]->uplink_frequency_offset[0]; - oai_emulation.info.N_RB_DL[0] = enb_properties->properties[0]->N_RB_DL[0]; - LOG_E(EMU,"Please use only RRU with oaisim, remove eNB descriptors in configuration file\n"); - exit(-1); - } - }*/ - } - else { - printf("Please provide a configuration file\n"); - exit(-1); - } -} - -void check_and_adjust_params(void) -{ - - int32_t ret; - //int i,j; - - if (oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local > NUMBER_OF_UE_MAX) { - LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_UE_MAX); - exit(EXIT_FAILURE); - } - - if (oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local > NUMBER_OF_eNB_MAX) { - LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX); - exit(EXIT_FAILURE); - } - - if (oai_emulation.info.nb_rn_local > NUMBER_OF_RN_MAX) { - LOG_E(EMU,"Enter fewer than %d RNs for the moment or change the NUMBER_OF_RN_MAX\n", NUMBER_OF_RN_MAX); - exit(EXIT_FAILURE); - } - - // fix ethernet and abstraction with RRC_CELLULAR Flag -#ifdef RRC_CELLULAR - abstraction_flag = 1; - ethernet_flag = 1; -#endif - - if (set_sinr == 0) - sinr_dB = snr_dB - 20; - - // setup netdevice interface (netlink socket) - LOG_I(EMU,"[INIT] Starting NAS netlink interface\n"); - ret = netlink_init(); - - if (ret < 0) - LOG_W(EMU,"[INIT] Netlink not available, careful ...\n"); - /* - if (ethernet_flag == 1) { - oai_emulation.info.master[oai_emulation.info.master_id].nb_ue = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local; - oai_emulation.info.master[oai_emulation.info.master_id].nb_enb = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local; - - if (oai_emulation.info.nb_rn_local>0) - LOG_N(EMU,"Ethernet emulation is not yet tested with the relay nodes\n"); - - if (!oai_emulation.info.master_id) - oai_emulation.info.is_primary_master = 1; - - j = 1; - - for (i = 0; i < oai_emulation.info.nb_master; i++) { - if (i != oai_emulation.info.master_id) - oai_emulation.info.master_list = oai_emulation.info.master_list + j; - - LOG_I (EMU, "Index of master id i=%d MASTER_LIST %d\n", i, oai_emulation.info.master_list); - j *= 2; - } - - LOG_I (EMU, " Total number of master %d my master id %d\n", oai_emulation.info.nb_master, oai_emulation.info.master_id); - // init_bypass (); - - while (emu_tx_status != SYNCED_TRANSPORT) { - LOG_I (EMU, " Waiting for EMU Transport to be synced\n"); - emu_transport_sync (); //emulation_tx_rx(); - } - } // ethernet flag - */ - // - NB_UE_INST = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_ue_remote; - NB_eNB_INST = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_enb_remote; - NB_RN_INST = oai_emulation.info.nb_rn_local + oai_emulation.info.nb_rn_remote; - NB_RU = oai_emulation.info.nb_ru_local + oai_emulation.info.nb_ru_remote; - -#if defined(PDCP_USE_NETLINK_QUEUES) && defined(OPENAIR2) - pdcp_netlink_init(); -#endif - - if (NB_RN_INST > 0 ) { - LOG_N(EMU,"Total number of RN %d (local %d, remote %d) mobility (the same as eNB) %s \n", NB_RN_INST,oai_emulation.info.nb_rn_local,oai_emulation.info.nb_rn_remote, - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); - - LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ", - NB_eNB_INST, NB_eNB_INST+NB_RN_INST, - NB_UE_INST, NB_UE_INST+NB_RN_INST); - NB_eNB_INST+=NB_RN_INST; - NB_UE_INST+=NB_RN_INST; - } - - LOG_I(EMU,"Total number of UE %d (first local %d , num local %d, remote %d, relay %d) mobility %s \n", - NB_UE_INST,oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local,oai_emulation.info.nb_ue_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option); - - LOG_I(EMU,"Total number of eNB %d (local %d, remote %d, relay %d) mobility %s \n", - NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); - -} - -#ifdef OPENAIR2 -void init_omv(void) -{ - if (oai_emulation.info.omv_enabled == 1) { - - if(pipe(pfd) == -1) - perror("pipe error \n"); - - snprintf( full_name, sizeof(full_name), "%s/UTIL/OMV/OMV",getenv("OPENAIR2_DIR") ); - LOG_I(EMU,"Stating the OMV path %s pfd[0] %d pfd[1] %d \n", full_name, pfd[0],pfd[1]); - - switch(fork()) { - case -1 : - perror("fork failed \n"); - break; - - case 0 : // child is going to be the omv, it is the reader - if(close(pfd[1]) == -1 ) // we close the write desc. - perror("close on write\n" ); - - sprintf(fdstr, "%d", pfd[0] ); - sprintf(num_enb, "%d", NB_eNB_INST); - sprintf(num_ue, "%d", NB_UE_INST); - sprintf(x_area, "%f", oai_emulation.topology_config.area.x_m ); - sprintf(y_area, "%f", oai_emulation.topology_config.area.y_m ); - sprintf(z_area, "%f", 200.0 ); - sprintf(frames, "%d", oai_emulation.info.n_frames); - sprintf(nb_antenna, "%d", 4); - sprintf(frame_type, "%s", (oai_emulation.info.frame_type[0] == 0) ? "FDD" : "TDD"); - sprintf(tdd_config, "%d", oai_emulation.info.tdd_config[0]); - // execl is used to launch the visualisor - execl(full_name,"OMV", fdstr, frames, num_enb, num_ue, x_area, y_area, z_area, nb_antenna, frame_type, tdd_config,NULL ); - perror( "error in execl the OMV" ); - } - - //parent - if(close( pfd[0] ) == -1 ) // we close the write desc. - perror("close on read\n" ); - } -} -#endif - -void init_seed(uint8_t set_seed) -{ - - if(set_seed) { - - randominit (oai_emulation.info.seed); - set_taus_seed (oai_emulation.info.seed); - - } else { - randominit (0); - set_taus_seed (0); - } -} - -openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -openair0_timestamp current_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; -openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -openair0_timestamp last_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; - -int ru_trx_start(openair0_device *device) { - return(0); -} - -void ru_trx_end(openair0_device *device) { - return; -} - -int ru_trx_stop(openair0_device *device) { - return(0); -} -int UE_trx_start(openair0_device *device) { - return(0); -} -void UE_trx_end(openair0_device *device) { - return; -} -int UE_trx_stop(openair0_device *device) { - return(0); -} -int ru_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) { - return(0); -} -int ru_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { - return(0); -} -int UE_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) { - return(0); -} -int UE_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { - return(0); -} - -extern pthread_mutex_t subframe_mutex; -extern int subframe_ru_mask,subframe_UE_mask; - - -int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - - int ru_id = device->Mod_id; - int CC_id = device->CC_id; - - int subframe; - int sample_count=0; - - *ptimestamp = last_ru_rx_timestamp[ru_id][CC_id]; - - - LOG_D(PHY,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, - (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id], - (unsigned long long)last_ru_rx_timestamp[ru_id][CC_id], - (int)((*ptimestamp/RC.ru[ru_id]->frame_parms.samples_per_tti)%10)); - // if we're at a subframe boundary generate UL signals for this ru - - while (sample_countframe_parms.samples_per_tti)%10; - - if (RC.ru[ru_id]->frame_parms.frame_type == FDD || - subframe_select(&RC.ru[ru_id]->frame_parms,subframe) != SF_DL) { - LOG_D(PHY,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - - //if (subframe_select(&RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms.frame_type == FDD) { - //LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id]); - - do_UL_sig(UE2RU, - enb_data, - ue_data, - subframe, - 0, // abstraction_flag - &RC.ru[ru_id]->frame_parms, - 0, // frame is only used for abstraction - ru_id, - CC_id); - } - last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms.samples_per_tti; - sample_count += RC.ru[ru_id]->frame_parms.samples_per_tti; - } - - - return(nsamps); -} - -int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) -{ - int UE_id = device->Mod_id; - int CC_id = device->CC_id; - - int subframe; - int sample_count=0; - int read_size; - int sptti = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti; - - *ptimestamp = last_UE_rx_timestamp[UE_id][CC_id]; - - LOG_D(EMU,"UE %d DL simulation 0: UE_trx_read nsamps %d TS %llu (%llu, offset %d) antenna %d\n", - UE_id, - nsamps, - (unsigned long long)current_UE_rx_timestamp[UE_id][CC_id], - (unsigned long long)last_UE_rx_timestamp[UE_id][CC_id], - (int)(last_UE_rx_timestamp[UE_id][CC_id]%sptti), - cc); - - - if (nsamps < sptti) - read_size = nsamps; - else - read_size = sptti; - - while (sample_countframe_parms, - UE_id, - CC_id); - LOG_D(EMU,"UE %d: DL simulation 6: UE_trx_read @ TS %"PRIi64" (%"PRIi64")=> frame %d, subframe %d\n", - UE_id, current_UE_rx_timestamp[UE_id][CC_id], - last_UE_rx_timestamp[UE_id][CC_id], - (int)((last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023), - subframe); - - last_UE_rx_timestamp[UE_id][CC_id] += read_size; - sample_count += read_size; - - - - - } - - - return(nsamps); -} - -extern double ru_amp[NUMBER_OF_RU_MAX]; - -int ru_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - - int ru_id = device->Mod_id; - - LTE_DL_FRAME_PARMS *frame_parms = &RC.ru[ru_id]->frame_parms; - - pthread_mutex_lock(&subframe_mutex); - LOG_D(EMU,"[TXPATH] ru_trx_write: RU %d mask %d\n",ru_id,subframe_ru_mask); - pthread_mutex_unlock(&subframe_mutex); - - // compute amplitude of TX signal from first symbol in subframe - // note: assumes that the packet is an entire subframe - - ru_amp[ru_id] = 0; - for (int aa=0; aanb_tx; aa++) { - ru_amp[ru_id] += (double)signal_energy((int32_t*)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL); - } - ru_amp[ru_id] = sqrt(ru_amp[ru_id]); - - LOG_D(EMU,"Setting amp for RU %d to %f (%d)\n",ru_id,ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t*)buff[0],frame_parms->ofdm_symbol_size))); - // tell top-level we are done - pthread_mutex_lock(&subframe_mutex); - subframe_ru_mask|=(1<N_RB_DL == 100) { - if (frame_parms[0]->threequarter_fs) { - openair0_cfg[card].sample_rate=23.04e6; - openair0_cfg[card].samples_per_frame = 230400; - openair0_cfg[card].tx_bw = 10e6; - openair0_cfg[card].rx_bw = 10e6; - } - else { - openair0_cfg[card].sample_rate=30.72e6; - openair0_cfg[card].samples_per_frame = 307200; - openair0_cfg[card].tx_bw = 10e6; - openair0_cfg[card].rx_bw = 10e6; - } - } else if(frame_parms[0]->N_RB_DL == 50) { - openair0_cfg[card].sample_rate=15.36e6; - openair0_cfg[card].samples_per_frame = 153600; - openair0_cfg[card].tx_bw = 5e6; - openair0_cfg[card].rx_bw = 5e6; - } else if (frame_parms[0]->N_RB_DL == 25) { - openair0_cfg[card].sample_rate=7.68e6; - openair0_cfg[card].samples_per_frame = 76800; - openair0_cfg[card].tx_bw = 2.5e6; - openair0_cfg[card].rx_bw = 2.5e6; - } else if (frame_parms[0]->N_RB_DL == 6) { - openair0_cfg[card].sample_rate=1.92e6; - openair0_cfg[card].samples_per_frame = 19200; - openair0_cfg[card].tx_bw = 1.5e6; - openair0_cfg[card].rx_bw = 1.5e6; - } - - if (frame_parms[0]->frame_type==TDD) - openair0_cfg[card].duplex_mode = duplex_mode_TDD; - else //FDD - openair0_cfg[card].duplex_mode = duplex_mode_FDD; - - - openair0_cfg[card].remote_addr = (eth_params+card)->remote_addr; - openair0_cfg[card].remote_port = (eth_params+card)->remote_port; - openair0_cfg[card].my_addr = (eth_params+card)->my_addr; - openair0_cfg[card].my_port = (eth_params+card)->my_port; - - - printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card, - RC.ru[0]->nb_tx, - RC.ru[0]->nb_rx); - openair0_cfg[card].Mod_id = 0; - - - - openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; - openair0_cfg[card].tx_num_channels=min(2,RC.ru[0]->nb_tx); - openair0_cfg[card].rx_num_channels=min(2,RC.ru[0]->nb_rx); - - for (i=0; i<4; i++) { - - openair0_cfg[card].rx_gain[i] = RC.ru[0]->rx_total_gain_dB; - - printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", - card,i, openair0_cfg[card].tx_gain[i], - openair0_cfg[card].rx_gain[i], - openair0_cfg[card].tx_freq[i], - openair0_cfg[card].rx_freq[i]); - } - } -} -*/ - -void init_devices(void){ - - - module_id_t UE_id, ru_id; - uint8_t CC_id; - RU_t *ru; - - // allocate memory for RU if not already done - if (RC.ru==NULL) RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*)); - - for (ru_id=0;ru_idrfdevice.Mod_id = ru_id; - ru->rfdevice.CC_id = 0; - ru->rfdevice.trx_start_func = ru_trx_start; - ru->rfdevice.trx_read_func = ru_trx_read; - ru->rfdevice.trx_write_func = ru_trx_write; - ru->rfdevice.trx_end_func = ru_trx_end; - ru->rfdevice.trx_stop_func = ru_trx_stop; - ru->rfdevice.trx_set_freq_func = ru_trx_set_freq; - ru->rfdevice.trx_set_gains_func = ru_trx_set_gains; - last_ru_rx_timestamp[ru_id][0] = 0; - - } - if (PHY_vars_UE_g==NULL) { - PHY_vars_UE_g = (PHY_VARS_UE ***)malloc((1+NB_UE_INST)*sizeof(PHY_VARS_UE*)); - for (UE_id=0;UE_idrfdevice.Mod_id = UE_id; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.CC_id = CC_id; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_start_func = UE_trx_start; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_read_func = UE_trx_read; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_write_func = UE_trx_write; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_end_func = UE_trx_end; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_stop_func = UE_trx_stop; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_freq_func = UE_trx_set_freq; - PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_gains_func = UE_trx_set_gains; - last_UE_rx_timestamp[UE_id][CC_id] = 0; - } - } - } -} - -void init_ocm(void) -{ - module_id_t UE_id, ru_id; - int CC_id; - - /* Added for PHY abstraction */ - - /* TODO: frame_type is unused, is it intended? */ - //char* frame_type = "unknown"; - LTE_DL_FRAME_PARMS *fp = &RC.ru[0]->frame_parms; - -#if 0 - switch (fp->frame_type) { - case FDD: - frame_type = "FDD"; - break; - - case TDD: - frame_type = "TDD"; - break; - } -#endif - - if (abstraction_flag) { - - get_beta_map(); - get_MIESM_param(); - - //load_pbch_desc(); - } - - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - enb_data[ru_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_enb(enb_data[ru_id],oai_emulation.environment_system_config.antenna.eNB_antenna); - } - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - ue_data[UE_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_ue(ue_data[UE_id],oai_emulation.environment_system_config.antenna.UE_antenna); - } - - if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 ) && - (oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m>0) && - (oai_emulation.environment_system_config.fading.shadowing.variance_dB>0)) { - - // init SF map here!!! - map1 =(int)oai_emulation.topology_config.area.x_m; - map2 =(int)oai_emulation.topology_config.area.y_m; - ShaF = init_SF(map1,map2,oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m,oai_emulation.environment_system_config.fading.shadowing.variance_dB); - - // size of area to generate shadow fading map - LOG_D(EMU,"Simulation area x=%f, y=%f\n", - oai_emulation.topology_config.area.x_m, - oai_emulation.topology_config.area.y_m); - } - - if (abstraction_flag == 0) - init_channel_vars (fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); - - // initialize channel descriptors - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - for (CC_id=0; CC_idnb_tx, - PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, - map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms.N_RB_DL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms.N_RB_DL), - forgetting_factor, - 0, - 0); - random_channel(RU2UE[ru_id][UE_id][CC_id],abstraction_flag); - LOG_D(OCM,"[SIM] Initializing channel (%s, %d) from UE %d to ru %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, - map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option),UE_id, ru_id); - - - UE2RU[UE_id][ru_id][CC_id] = - new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, - RC.ru[ru_id]->nb_rx, - map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option), - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms.N_RB_UL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms.N_RB_UL), - forgetting_factor, - 0, - 0); - - random_channel(UE2RU[UE_id][ru_id][CC_id],abstraction_flag); - - // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. - //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id]; - } - } - } -} - -void init_otg_pdcp_buffer(void) -{ - module_id_t i; - otg_pdcp_buffer = malloc((NB_UE_INST + NB_eNB_INST) * sizeof(Packet_OTG_List_t)); - - for (i = 0; i < NB_UE_INST + NB_eNB_INST; i++) { - pkt_list_init(&(otg_pdcp_buffer[i])); - //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", i, pkt_list_get_head(&(otg_pdcp_buffer[i]))); - } -} - -void update_omg (frame_t frameP) -{ - module_id_t UE_id, eNB_id; - int new_omg_model; - - if ((frameP % omg_period) == 0 ) { // call OMG every 10ms - update_nodes(oai_emulation.info.time_s); - display_node_list(enb_node_list); - display_node_list(ue_node_list); - - if (oai_emulation.info.omg_model_ue >= MAX_NUM_MOB_TYPES) { // mix mobility model - for(UE_id=oai_emulation.info.first_ue_local; UE_id<(oai_emulation.info.first_ue_local+oai_emulation.info.nb_ue_local); UE_id++) { - new_omg_model = randomgen(STATIC,RWALK); - LOG_D(OMG, "[UE] Node of ID %d is changing mobility generator ->%d \n", UE_id, new_omg_model); - // reset the mobility model for a specific node - set_new_mob_type (UE_id, UE, new_omg_model, oai_emulation.info.time_s); - } - } - - if (oai_emulation.info.omg_model_enb >= MAX_NUM_MOB_TYPES) { // mix mobility model - for (eNB_id = oai_emulation.info.first_enb_local; eNB_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); eNB_id++) { - new_omg_model = randomgen (STATIC, RWALK); - LOG_D (OMG,"[eNB] Node of ID %d is changing mobility generator ->%d \n", eNB_id, new_omg_model); - // reset the mobility model for a specific node - set_new_mob_type (eNB_id, eNB, new_omg_model, oai_emulation.info.time_s); - } - } - } -} - -void update_omg_ocm() -{ - - enb_node_list=get_current_positions(oai_emulation.info.omg_model_enb, eNB, oai_emulation.info.time_s); - ue_node_list=get_current_positions(oai_emulation.info.omg_model_ue, UE, oai_emulation.info.time_s); - -} - -void update_ocm() -{ - module_id_t UE_id, ru_id; - int CC_id; - - - - /* check if the openair channel model is activated used for PHY abstraction : path loss*/ - if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 )) { - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) - enb_data[ru_id]->tx_power_dBm = RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) - ue_data[UE_id]->tx_power_dBm = PHY_vars_UE_g[UE_id][0]->tx_power_dBm[0]; - - //LOG_D(OMG," extracting position of eNb...\n"); - //display_node_list(enb_node_list); - // display_node_list(ue_node_list); - //extract_position(enb_node_list, enb_data, RC.nb_RU); - //extract_position_fixed_enb(enb_data, NB_eNB_INST,frame); - //LOG_D(OMG," extracting position of UE...\n"); - // if (oai_emulation.info.omg_model_ue == TRACE) - //extract_position(ue_node_list, ue_data, NB_UE_INST); - - /* if (frame % 50 == 0) - LOG_N(OCM,"Path loss for TTI %d : \n", frame); - */ - for (CC_id=0; CC_idpath_loss_dB = RU2UE[ru_id][UE_id][CC_id]->path_loss_dB; - // if (frame % 50 == 0) - LOG_D(OCM,"Path loss (CCid %d) between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f, angle %f\n", - CC_id,ru_id,enb_data[ru_id]->x,enb_data[ru_id]->y,UE_id,ue_data[UE_id]->x,ue_data[UE_id]->y, - RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, RU2UE[ru_id][UE_id][CC_id]->aoa); - //double dx, dy, distance; - //dx = enb_data[ru_id]->x - ue_data[UE_id]->x; - //dy = enb_data[ru_id]->y - ue_data[UE_id]->y; - //distance = sqrt(dx * dx + dy * dy); - /*LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n", - ru_id, enb_data[ru_id]->x,enb_data[ru_id]->y, - UE_id, ue_data[UE_id]->x,ue_data[UE_id]->y, - distance);*/ - } - } - } - } - - else { - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - for (CC_id=0; CC_idpath_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; - UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; - } else { - RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; - UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; - } - - LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower,snr_dB); - - } - } - } - } -} - -#ifdef OPENAIR2 -void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) -{ - -#if defined(USER_MODE) && defined(OAI_EMU) - - //int rrc_state=0; -/* - if (oai_emulation.info.otg_enabled ==1 ) { - - int dst_id, app_id; - Packet_otg_elt_t *otg_pkt; - - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { - for_times += 1; - - // generate traffic if the ue is rrc reconfigured state - //if ((rrc_state=mac_eNB_get_rrc_status(enb_module_idP, dst_id)) > 2 //RRC_CONNECTED - { - if (mac_eNB_get_rrc_status(enb_module_idP, oai_emulation.info.eNB_ue_module_id_to_rnti[enb_module_idP][dst_id]) > 2 ){ - if_times += 1; - - for (app_id=0; app_idotg_pkt).sdu_buffer = (uint8_t*) packet_gen(enb_module_idP, dst_id + NB_eNB_INST, app_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); - - if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { - otg_times += 1; - (otg_pkt->otg_pkt).rb_id = DTCH-2; // app could be binded to a given DRB - (otg_pkt->otg_pkt).module_id = enb_module_idP; - (otg_pkt->otg_pkt).dst_id = dst_id; - (otg_pkt->otg_pkt).is_ue = 0; - (otg_pkt->otg_pkt).mode = PDCP_TRANSMISSION_MODE_DATA; - //Adding the packet to the OTG-PDCP buffer - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[enb_module_idP])); - LOG_D(EMU,"[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n", - (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id, app_id); - } else { - free(otg_pkt); - otg_pkt=NULL; - } - } - } - } - -#if defined(Rel10) || defined(Rel14) - mbms_service_id_t service_id; - mbms_session_id_t session_id; - rb_id_t rb_id; - - // MBSM multicast traffic - if (ctime >= 500 ) {// only generate when UE can receive MTCH (need to control this value) - for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount - for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH - if (pdcp_mbms_array_eNB[enb_module_idP][service_id][session_id].instanciated_instance == TRUE) { // this service/session is configured - - otg_pkt = malloc (sizeof(Packet_otg_elt_t)); - // LOG_T(OTG,"multicast packet gen for (service/mch %d, session/lcid %d, rb_id %d)\n", service_id, session_id, service_id*maxSessionPerPMCH + session_id); - rb_id = pdcp_mbms_array_eNB[enb_module_idP][service_id][session_id].rb_id; - (otg_pkt->otg_pkt).sdu_buffer = (uint8_t*) packet_gen_multicast(enb_module_idP, session_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); - - if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { - (otg_pkt->otg_pkt).rb_id = rb_id; - (otg_pkt->otg_pkt).module_id = enb_module_idP; - (otg_pkt->otg_pkt).dst_id = session_id; - (otg_pkt->otg_pkt).is_ue = FALSE; - //Adding the packet to the OTG-PDCP buffer - (otg_pkt->otg_pkt).mode = PDCP_TRANSMISSION_MODE_TRANSPARENT; - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[enb_module_idP])); - LOG_D(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n", - (otg_pkt->otg_pkt).module_id, otg_pkt, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); - } else { - //LOG_I(EMU, "OTG returns null \n"); - free(otg_pkt); - otg_pkt=NULL; - } - -*/ - // old version - /* // MBSM multicast traffic - #if defined(Rel10) || defined(Rel14) - if (frame >= 46) {// only generate when UE can receive MTCH (need to control this value) - for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount - for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH - // LOG_I(OTG,"DUY:frame %d, pdcp_mbms_array[module_id][rb_id].instanciated_instance is %d\n",frame,pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance); - if ((pdcp_mbms_array[module_idP][service_id*maxSessionPerPMCH + session_id].instanciated_instance== module_idP + 1) && (eNB_flag == 1)){ // this service/session is configured - // LOG_T(OTG,"multicast packet gen for (service/mch %d, session/lcid %d)\n", service_id, session_id); - // Duy add - LOG_I(OTG, "frame %d, multicast packet gen for (service/mch %d, session/lcid %d, rb_id %d)\n",frame, service_id, session_id,service_id*maxSessionPerPMCH + session_id); - // end Duy add - rb_id = pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].rb_id; - otg_pkt=(uint8_t*) packet_gen_multicast(module_idP, session_id, ctime, &pkt_size); - if (otg_pkt != NULL) { - LOG_D(OTG,"[eNB %d] sending a multicast packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", eNB_index, module_idP, rb_id, module_idP, session_id, pkt_size); - pdcp_data_req(module_id, frame, eNB_flag, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt,PDCP_TM); - free(otg_pkt); - } - } - } - } - } // end multicast traffic - #endif - */ -/* - - } - } - } - - } // end multicast traffic -*/ - -#endif - } - -#else -#if 0 // defined(EXMIMO) || defined(OAI_USRP) - if (otg_enabled==1) { - ctime = frame * 100; - - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { - if (mac_get_rrc_status(eNB_index, eNB_flag, dst_id ) > 2) { - otg_pkt = malloc (sizeof(Packet_otg_elt_t)); - (otg_pkt->otg_pkt).sdu_buffer = packet_gen(module_instP, dst_id, ctime, &pkt_size); - - if (otg_pkt != NULL) { - rb_id = DTCH-2; - (otg_pkt->otg_pkt).rb_id = rb_id; - (otg_pkt->otg_pkt).module_id = module_idP; - (otg_pkt->otg_pkt).is_ue = FALSE; - (otg_pkt->otg_pkt).mode = PDCP_TRANSMISSION_MODE_DATA; - //Adding the packet to the OTG-PDCP buffer - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_idP])); - LOG_D(EMU, "[eNB %d] ADD pkt to OTG buffer for dst %d on rb_id %d\n", (otg_pkt->otg_pkt).module_id, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); - } else { - //LOG_I(EMU, "OTG returns null \n"); - free(otg_pkt); - otg_pkt=NULL; - } - } - } - } -#endif -} - -void update_otg_UE(module_id_t ue_mod_idP, unsigned int ctime) -{ -} -#endif - -int init_slot_isr(void) -{ - if (oai_emulation.info.slot_isr) { - struct itimerspec its; - - int sfd; - - sfd = timerfd_create(CLOCK_REALTIME, 0); - - if (sfd == -1) { - LOG_E(EMU, "Failed in timerfd_create (%d:%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - /* Start the timer */ - its.it_value.tv_sec = 0; - its.it_value.tv_nsec = 500 * 1000; - its.it_interval.tv_sec = its.it_value.tv_sec; - its.it_interval.tv_nsec = its.it_value.tv_nsec; - - if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) { - LOG_E(EMU, "Failed in timer_settime (%d:%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - oai_emulation.info.slot_sfd = sfd; - } - - return 0; -} - -void wait_for_slot_isr(void) -{ - uint64_t exp; - ssize_t res; - - if (oai_emulation.info.slot_sfd > 0) { - res = read(oai_emulation.info.slot_sfd, &exp, sizeof(exp)); - - if ((res < 0) || (res != sizeof(exp))) { - LOG_E(EMU, "Failed in read (%d:%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } - } -} - -void exit_fun(const char* s) -{ - void *array[10]; - size_t size; - - size = backtrace(array, 10); - backtrace_symbols_fd(array, size, 2); - - fprintf(stderr, "Error: %s. Exiting!\n",s); - exit (-1); -} - -void init_time() -{ - clock_gettime (CLOCK_REALTIME, &time_spec); - time_now = (unsigned long) time_spec.tv_nsec; - td_avg = 0; - sleep_time_us = SLEEP_STEP_US; - td_avg = TARGET_SF_TIME_NS; -} - -// dummy function -int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) { - - return(0); - -} - -/* -int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params) { - - return(0); - - -} - -int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cfg) { - - return(0); -} -*/