oaisim_config.c 88.2 KB
Newer Older
1
/*******************************************************************************
2
    OpenAirInterface
3
    Copyright(c) 1999 - 2014 Eurecom
4

5 6 7 8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9 10


11 12 13 14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

16
    You should have received a copy of the GNU General Public License
17 18
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
19
    see <http://www.gnu.org/licenses/>.
20

21 22 23 24
   Contact Information
   OpenAirInterface Admin: openair_admin@eurecom.fr
   OpenAirInterface Tech : openair_tech@eurecom.fr
   OpenAirInterface Dev  : openair4g-devel@eurecom.fr
25

ghaddab's avatar
ghaddab committed
26
   Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27

28
 *******************************************************************************/
29 30 31 32 33 34 35 36 37 38 39 40

/*! \file oaisim_config.c
* \brief Configuration of oaisim
* \author Navid Nikaein & Andre Gomes (One source)
* \date 2014
* \version 1.0
* \company Eurecom
* \email: openair_tech@eurecom.fr
* \note
* \warning
*/

41 42 43 44 45 46 47 48 49 50 51
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>

#include "oaisim_config.h"
#include "OCG.h"
#include "OCG_extern.h"
#include "UTIL/OMG/omg.h"
52
#include "UTIL/OMG/grid.h"
53 54
#include "UTIL/OTG/otg_tx.h"
#include "UTIL/OTG/otg.h"
55
#include "UTIL/OTG/otg_externs.h"
winckel's avatar
winckel committed
56
#include "oml.h"
gauthier's avatar
gauthier committed
57
#include "msc.h"
58 59 60 61
#ifdef ENABLE_RAL
#include "lteRALenb.h"
#include "lteRALue.h"
#endif
62

63 64 65 66
#if defined(ENABLE_ITTI)
# include "intertask_interface_init.h"
#endif

67

68 69 70 71 72 73 74 75 76
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}
77
};
78
// subtypes for RWP in grid map
79
mapping omg_rwp_names[] = {
80 81 82 83 84 85
  {"MIN_RWP_TYPES", MIN_RWP_TYPES},
  {"RESTRICTED_RWP",RESTIRICTED_RWP},
  {"CONNECTED_DOMAIN", CONNECTED_DOMAIN},
  {"MAX_RWP_TYPES", MAX_RWP_TYPES},
  {NULL, -1}
};
86

87
void  ocg_config_proto(void);
88

89 90
void init_oai_emulation(void)
{
91 92

  int i;
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
  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;
120

121 122 123 124 125 126
  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";
127
  oai_emulation.topology_config.mobility.UE_mobility.grid_walk.grid_map.selected_option="MAX_RWP_TYPES";
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  //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";
144 145
  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;
146 147 148 149 150 151 152 153 154 155 156 157
  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);
158
  snprintf( oai_emulation.topology_config.mobility.UE_mobility.sumo_config.file, 256, "%s/UTIL/OMG/SUMO/SCENARIOS/scen.sumo.cfg", getenv("OPENAIR2_DIR") );
159 160 161 162 163 164
  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;
165

166
  oai_emulation.application_config.packet_gen_type = "substract_string";
167

168 169 170 171 172
  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;
173 174
    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);
175

176
    oai_emulation.application_config.predefined_traffic.destination_id[i] = 0;
177

178 179 180 181 182 183 184
    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;
185 186
    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);
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
    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;
  }
213

214 215
  /* protocol config */
  oai_emulation.protocol_config.eNB_mac_config.num_groups=1;
216 217


218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
  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;
233

234 235 236 237 238
  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
239

240
  oai_emulation.info.ocg_ok = 0;
241 242


243
  // phy related params :
244
  oai_emulation.info.n_frames=MAX_FRAME_NUMBER; // number of frames simulated by default
245
  oai_emulation.info.n_frames_flag=0; // if set, then let the emulation goes to infinity
246

247
  //status
248 249 250 251
  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;
252
  oai_emulation.info.nb_rn_remote=0;
253 254
  oai_emulation.info.first_ue_local=0;
  oai_emulation.info.first_enb_local=0;
255
  oai_emulation.info.first_rn_local=0;
256
  oai_emulation.info.master_id=0;
257
  oai_emulation.info.nb_ue_local= 1;//default 1 UE
258
  oai_emulation.info.nb_enb_local= 1;//default 1 eNB
259
  oai_emulation.info.nb_rn_local= 0;//default 0 RN : currently only applicable for eMBMS
260 261 262 263 264 265 266
  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
267
  oai_emulation.info.omv_enabled =0; // v flag
268
  oai_emulation.info.vcd_enabled=0;
269
  oai_emulation.info.opp_enabled=0;
270
  oai_emulation.info.oeh_enabled=0;
271

272
  oai_emulation.info.cba_group_active=0;
273
  oai_emulation.info.cba_backoff=30;
274
  oai_emulation.info.eMBMS_active_state=0;
275
  oai_emulation.info.handover_active=0;
276
  oai_emulation.info.omg_model_enb=STATIC; //default to static mobility model
277
  oai_emulation.info.omg_model_rn=STATIC; //default to static mobility model
278
  oai_emulation.info.omg_model_ue=STATIC; //default to static mobility model
279
  oai_emulation.info.omg_rwp_type = RESTIRICTED_RWP;
280
  oai_emulation.info.omg_model_ue_current=STATIC; //default to static mobility model
nikaeinn's avatar
nikaeinn committed
281
  oai_emulation.info.otg_traffic="no_predefined_traffic";
282
  oai_emulation.info.otg_bg_traffic_enabled = 0; // G flag
283 284
  oai_emulation.info.max_predefined_traffic_config_index = 0;
  oai_emulation.info.max_customized_traffic_config_index = 0;
285 286 287
  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
288 289 290 291
  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;
292 293 294

  oai_emulation.info.slot_isr = 0;
  oai_emulation.info.slot_sfd = -1;
295

296 297
  //for (i=0; i < oai_emulation.info.cli_num_enb; i++)
  for (i=0; i < NUMBER_OF_eNB_MAX; i++)
298
    oai_emulation.info.cli_start_enb[i]=1;
299 300 301 302

  // 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;
303

304 305
  for (i=0; i < NUMBER_OF_eNB_MAX+NUMBER_OF_UE_MAX; i++)
    oai_emulation.info.oai_ifup[i]=0;
306 307 308 309

  oai_emulation.info.nb_master       =0;
  oai_emulation.info.ethernet_id     =0;
  oai_emulation.info.multicast_group =0;
310
  oai_emulation.info.multicast_ifname=NULL;
311
  oai_emulation.info.g_log_level     = LOG_INFO;
312 313
  oai_emulation.info.g_log_verbosity = 0x15;
  oai_emulation.info.g_log_verbosity_option = "medium";
314

315
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
316 317 318 319 320 321 322 323
    oai_emulation.info.frame_type[CC_id]=TDD;
    oai_emulation.info.frame_type_name[CC_id]="TDD";
    oai_emulation.info.tdd_config[CC_id]=3;
    oai_emulation.info.tdd_config_S[CC_id]=0;
    oai_emulation.info.extended_prefix_flag[CC_id]=0;
    oai_emulation.info.N_RB_DL[CC_id]=25;
    oai_emulation.info.transmission_mode[CC_id]=2;
  }
324

325
  oai_emulation.profile = "EURECOM";
326 327 328
}


329 330
void oaisim_config(void)
{
331 332

  // init log gen first
333
  //initialize the log generator
334 335


336 337
  logInit();

338 339 340 341
#if defined(ENABLE_ITTI)
  itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, oai_emulation.info.itti_dump_file);
#endif

342
  // init ocg if enabled, otherwise take the params form the init_oai_emulation()
343 344
  //  and command line options given by the user
  if (oai_emulation.info.ocg_enabled == 1) { // activate OCG: xml-based scenario parser
345
    OCG_main(oai_emulation.info.local_server);// eurecom or portable
346 347

    if (oai_emulation.info.ocg_ok != 1) {
348 349 350
      LOG_E(OCG, "Error found by OCG; emulation not launched.\n");
      LOG_E(OCG, "Please find more information in the OCG_report.xml located at %s.\n", oai_emulation.info.output_path);
      exit (-1);
351 352 353 354
    }
  }

  // init other comps
gauthier's avatar
gauthier committed
355
  MSC_INIT(MSC_E_UTRAN);
356 357 358 359
#ifdef ENABLE_RAL
  mRAL_init_default_values();
  eRAL_init_default_values();
#endif
360
  olg_config();
361
  ocg_config_emu();
362 363
  ocg_config_env();// mobility gen
  ocg_config_topo(); // packet tracer using wireshark
364
  ocg_config_proto();
365

366
  // if T is set or ocg enabled
367 368 369 370 371 372 373 374 375 376
  if (oai_emulation.info.otg_enabled ) {
    set_component_filelog(OTG);
    set_component_filelog(OTG_LATENCY);
    set_component_filelog(OTG_GP);
    set_component_filelog(OTG_LATENCY_BG);
    set_component_filelog(OTG_GP_BG);
    set_component_filelog(OTG_JITTER);
    /* g_log->log_component[OTG].filelog=1;
    g_log->log_component[OTG_LATENCY].filelog=1;
    g_log->log_component[OTG_OWD].filelog = 1;*/
377
    ocg_config_app(); // packet generator
378
  }
379

380 381 382
  // add a var to control this, and pass this var to OMG
  set_component_filelog(OMG);
  LOG_I(OMG,"setting OMG file log \n");
383

384 385
}

386 387
int olg_config(void)
{
388
  int comp;
389 390 391 392 393
  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 :
394
                                        map_str_to_int(log_verbosity_names, oai_emulation.info.g_log_verbosity_option));
395
  set_glog(oai_emulation.info.g_log_level, oai_emulation.info.g_log_verbosity ); //g_glog
396

397 398
  // component, log level, log interval
  for (comp = PHY; comp < MAX_LOG_COMPONENTS ; comp++)
399 400 401 402
    set_comp_log(comp,
                 oai_emulation.info.g_log_level,
                 oai_emulation.info.g_log_verbosity,
                 oai_emulation.emulation_config.log_emu.interval);
403

404
  LOG_I(EMU, "OCG log level %d, oai log level%d \n ",ocg_log_level, oai_emulation.info.g_log_level);
405
  LOG_N(EMU,"global log level is set to (%s,%d) with vebosity (%s, 0x%x) and frequency %d\n",
406 407 408 409 410
        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 );
411 412


413
  /*
414
  // if perf eval then reset the otg log level
415 416 417 418 419
  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);
420
  set_comp_log(MAC,  LOG_EMERG, 0x15,1);
421 422
  set_comp_log(OMG,  LOG_EMERG, 0x15,1);
  set_comp_log(OPT,  LOG_EMERG, 0x15,1);
423 424 425
  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);
426
  */
gauthier's avatar
gauthier committed
427 428 429 430 431 432 433
#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
434

435 436 437 438 439 440
#if defined(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
gauthier's avatar
gauthier committed
441

442

443 444 445 446 447 448 449 450 451 452 453
   //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_ERR,  0x15,20);
454 455 456
   set_comp_log(MAC,  LOG_TRACE, 0x15,1);
   set_comp_log(RLC,  LOG_TRACE, 0x15,1);
   set_comp_log(PHY,  LOG_TRACE, 0x15, 1);
457 458 459 460 461 462
   set_comp_log(PDCP, LOG_DEBUG, 0x15,1);
   set_comp_log(RRC,  LOG_DEBUG, 0x15,1);
   set_comp_log(OCM,  LOG_ERR, 0x15,20);
   set_comp_log(OTG,  LOG_ERR, 0x15,1);
   set_comp_log(OMG,  LOG_ERR, 0x15,1);
   set_comp_log(OPT,  LOG_ERR, 0x15,1);
463

gauthier's avatar
gauthier committed
464

465
  // set_comp_log(MAC, LOG_TRACE, LOG_FULL,1);
466
  return 1;
467 468
}

469 470 471
int ocg_config_env(void)
{
  // int func related to channel desc from oaisim.c could be moved here
472
  int CC_id;
473

474 475
  if (oai_emulation.info.ocg_enabled) {
    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
476
      oai_emulation.info.frame_type[CC_id] = map_str_to_int(frame_type_names, oai_emulation.info.frame_type_name[CC_id]);
477 478 479 480 481 482 483 484 485 486 487 488 489

      if (oai_emulation.info.frame_type[CC_id] == -1) {
        LOG_E(EMU,"frame type incorrect %s, set it to TDD \n",oai_emulation.info.frame_type_name);
        oai_emulation.info.frame_type[CC_id]=TDD;
      } else
        LOG_I(EMU,"Frame type is %s \n",oai_emulation.info.frame_type_name[CC_id]);

      if (oai_emulation.info.frame_type[CC_id] == TDD ) {
        if ((oai_emulation.info.tdd_config[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 \n",oai_emulation.info.tdd_config[CC_id]);
490
      }
491
    }
492
  }
493

494
  return 1;
495
}
496 497
int ocg_config_topo(void)
{
498

499 500 501
  int i;
  // omg
  init_omg_global_params();
502

503 504 505
  // setup params for openair mobility generator
  //common params
  for(i=0; i < MAX_NUM_NODE_TYPES; i++) {
506

507 508 509 510 511 512 513 514 515 516 517 518 519
    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;
520
    omg_param_list[i].nodes_type = i;
521 522
    omg_param_list[i].nodes=0;
    omg_param_list[i].mobility_type=STATIC;
523

524
    // init OMG for eNBs
525

526 527
    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)
528 529
        oai_emulation.info.omg_model_enb = STATIC;

530
      LOG_I(OMG,"eNB mobility model is (%s, %d)\n",
531 532 533 534
            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;
535 536
      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
537 538


539
      if (oai_emulation.info.omg_model_enb == TRACE) {
540 541 542 543 544 545 546 547 548 549 550 551
        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
      }



552
      if (strcmp(oai_emulation.topology_config.mobility.eNB_mobility.eNB_initial_distribution.selected_option, "fixed") == 0) {
553 554 555
        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;
556
      }
557

558
      /*// at this moment, we use the above moving dynamics for mobile eNB
559 560 561 562 563 564
      if (omg_param_list.nodes >0 )
      init_mobility_generator(omg_param_list);*/

    } else if (i== UE) {      // init OMG for UE


565 566
      // 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)
567 568
        oai_emulation.info.omg_model_ue = STATIC;

569
      LOG_I(OMG,"UE mobility model is (%s, %d)\n",
570 571 572
            oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option,
            oai_emulation.info.omg_model_ue);

573
      if (oai_emulation.info.omg_model_ue == RWP) {
574 575 576 577 578 579 580 581 582 583 584 585 586 587
        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]);
        }
588
      }
589

590
      omg_param_list[i].mobility_type    = oai_emulation.info.omg_model_ue;
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
      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);
      }

648
    }
649

650 651
    if (oai_emulation.topology_config.omv == 1 )
      oai_emulation.info.omv_enabled =  1;
652

653
  }//for
654 655


656
  init_mobility_generator(omg_param_list);
657

658
  return 1;
659 660 661 662
}



663 664
int ocg_config_app(void)
{
665 666 667 668 669 670 671 672

  char colon[] = ":";
  char comma[] = ",";
  char tmp_source_id[128];
  char tmp_destination_id[128];
  char *check_format1;
  char *check_format2;
  char *check_format1_dst;
673 674
  char *source_id_start = NULL;
  char *source_id_end = NULL;
675 676 677 678 679 680 681 682 683 684
  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;
685

686 687
  int predefined_traffic_config_index;
  int customized_traffic_config_index;
688 689
  unsigned int state;

690 691 692 693 694 695 696 697 698
  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);
699

700
  g_otg->packet_gen_type=map_str_to_int(packet_gen_names,oai_emulation.application_config.packet_gen_type);
701

702
  LOG_I(OTG,"Metrics: Throuput %s(%d), One-way latency %s(%d) for %s, loss rate %s(%d), online curves %s(%d)\n",
703 704 705 706 707
        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 );
708

709
  for (i=0; i<g_otg->num_nodes; i++) {
710

711
    for (j=0; j<g_otg->num_nodes; j++) {
712 713 714
      // 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];
715

716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742
      for (k=0; k<MAX_NUM_APPLICATION; k++) {
        g_otg->ip_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; l<MAX_NUM_TRAFFIC_STATE; l++) {
          g_otg->idt_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];
        }
743 744 745
      }
    }
  }
746

747 748
  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
749

750
  LOG_I(OTG,"oai_emulation.info.max_predefined_traffic_config_index = %d\n", oai_emulation.info.max_predefined_traffic_config_index);
751
  LOG_I(OTG,"oai_emulation.info.max_customized_traffic_config_index = %d\n", oai_emulation.info.max_customized_traffic_config_index);
752

753 754 755

  if (oai_emulation.info.ocg_ok) {
    ///// for the predefined traffic
756
    for (predefined_traffic_config_index = 1;
757 758
         predefined_traffic_config_index <= oai_emulation.info.max_predefined_traffic_config_index;
         predefined_traffic_config_index++) {
759

760
      LOG_I(OTG,"OCG_config_OTG: predefined no. %d\n", predefined_traffic_config_index);
761

nikaeinn's avatar
nikaeinn committed
762 763 764 765 766 767
      //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
768 769 770
      check_format1 = strstr(tmp_source_id, colon);
      check_format2 = strstr(tmp_source_id, comma);
      check_format1_dst = strstr(tmp_destination_id, colon);
771 772


773
      if (check_format1 != NULL) { // format 1:10
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819
        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;
            }
          }
        }
820
      } else if (check_format2 != NULL) { // format 1,2,3,5
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
        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);

        }
845
      } else { // single node configuration
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
        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;
            }
          }
        }
890
      }
891

892 893
      init_predef_traffic(oai_emulation.info.nb_ue_local, oai_emulation.info.nb_enb_local);
    }
894

895
    ///////// for the customized traffic
896
    for (customized_traffic_config_index = 1;
897 898
         customized_traffic_config_index <= oai_emulation.info.max_customized_traffic_config_index;
         customized_traffic_config_index++) {
899

900 901
      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]);
902

903 904
      check_format1 = strstr(tmp_source_id, colon);
      check_format2 = strstr(tmp_source_id, comma);
905

906 907
      strcpy(tmp_destination_id, oai_emulation.application_config.customized_traffic.destination_id[customized_traffic_config_index]);
      check_format1_dst = strstr(tmp_destination_id, colon);
908 909
      state=PE_STATE;

910
      if (check_format1 != NULL) { // format 1:10
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
        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;
            }
          }
        }
1016

1017
      } else if (check_format2 != NULL) { // format 1,2,3,5
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
        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 (%d:%d) source = %d, dest = %d, dist type for size = %d 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],
                  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;
          }
        }
1106
      } else { // single node configuration
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217
        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;

            }
          }
        }
1218
      }
1219
    }
1220 1221
  }

1222

1223
  if ((oai_emulation.info.max_predefined_traffic_config_index == 0)  &&
1224
      (oai_emulation.info.max_customized_traffic_config_index == 0) &&
1225
      (oai_emulation.info.otg_enabled==1)) { // OCG not used to configure OTG, but -T option is used, so config here
1226
    LOG_I(OTG,"configure OTG through options %s\n", oai_emulation.info.otg_traffic);
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243

    for (i=0; i<g_otg->num_nodes; i++) {
      for (j=0; j<g_otg->num_nodes; j++) {
        g_otg->application_idx[i][j]=1;

        for (k=0; k<g_otg->application_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]);
        }
1244 1245
      }
    }
1246