From 6be97a95bfc315fb9a582b0e1ee1d69a86f940e1 Mon Sep 17 00:00:00 2001
From: Lionel Gauthier <lionel.gauthier@eurecom.fr>
Date: Mon, 27 Jan 2014 11:40:06 +0000
Subject: [PATCH] Added configuration File, example in
 targets/PROJECTS/GENERIC-LTE-EPC

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4950 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 targets/SIMU/USER/Makefile           | 30 ++++++-----
 targets/SIMU/USER/oaisim_functions.c | 77 +++++++++++++++-------------
 2 files changed, 59 insertions(+), 48 deletions(-)

diff --git a/targets/SIMU/USER/Makefile b/targets/SIMU/USER/Makefile
index 88395667d43..a126d355104 100644
--- a/targets/SIMU/USER/Makefile
+++ b/targets/SIMU/USER/Makefile
@@ -74,7 +74,7 @@ ENABLE_DB = $(shell if [ `dpkg -l | grep libmysqlclient -c` = "0" ]; then  echo
 ifeq ($(ENABLE_DB), 1)
 CFLAGS +=-I/usr/include/mysql -L/usr/lib/mysql -DENABLE_DB_STATS
 DB_LDFLAGS = -lmysqlclient
-endif 
+endif
 endif
 
 ifdef PRINT_STATS
@@ -240,7 +240,7 @@ endif
 OAISIM_PAD_OBJS =  $(OPENAIR_TARGETS)/SIMU/USER/discrete_event_generator.o
 OAISIM_PAD_OBJS += $(OPENAIR_TARGETS)/SIMU/USER/threadpool.o
 OAISIM_PAD_OBJS += $(OPENAIR_TARGETS)/SIMU/USER/oaisim_pad.o
-#deactivate the log offloading 
+#deactivate the log offloading
 ifndef LOG_THREAD
 CFLAGS +=-DLOG_NO_THREAD
 endif
@@ -266,7 +266,7 @@ LIBS		+= $(PGM_LIBS)
 endif
 
 OBJ += $(PHY_OBJS) $(SIMULATION_OBJS) $(ETHERNET_TRANSPORT_OBJS) $(TOOLS_OBJS) $(SCHED_OBJS) $(STATS_OBJS) $(NAS_OBJS)
-OBJ += $(INT_OBJS) $(UTIL_OBJ) $(UTILS_OBJS) $(OAISIM_OBJS_COMMON) $(ENB_APP_OBJS) 
+OBJ += $(INT_OBJS) $(UTIL_OBJ) $(UTILS_OBJS) $(OAISIM_OBJS_COMMON) $(ENB_APP_OBJS)
 ifeq ($(OPENAIR2),1)
 OBJ += $(L2_OBJS)
 endif
@@ -298,6 +298,10 @@ printvars:
 	@echo CFLAGS: $(CFLAGS)
 	@echo Enable PGM: $(ENABLE_PGM)
 
+##UTIL_YAC_C = $(OPENAIR2_TOP)/UTIL/enb_parser.o
+##$(UTIL_LEX_C) = $(subst $(OPENAIR_HOME), $(OBJS_DIR), $(OBJ) $(OAISIM_OBJS) $(ASN1_MSG_OBJS1))
+
+
 OAISIM_COMPILED_OBJECTS = $(subst $(OPENAIR_HOME), $(OBJS_DIR), $(OBJ) $(OAISIM_OBJS) $(ASN1_MSG_OBJS1))
 
 -include $(ITTI_MESSAGES_XML:.xml=.d)
@@ -337,7 +341,7 @@ oaisim_pad: $(OBJ) $(OAISIM_PAD_OBJS) $(ASN1_MSG_OBJS1)
 oaisim: $(OAISIM_COMPILED_OBJECTS) $(SHARED_DEPENDENCIES)
 	@echo "Linking oaisim ..."
 	@$(CC) $(INCLUDES) $(S1AP_Incl) -o oaisim $(CFLAGS) $(EXTRA_CFLAGS) $(OAISIM_COMPILED_OBJECTS) \
-	-lpthread -llapack_atlas -lforms -lrt $(LIBS) $(DB_LDFLAGS)
+	-lpthread -llapack_atlas -lforms -lrt -lconfig $(LIBS) $(DB_LDFLAGS)
 
 ifeq ($(rrc_cellular_eNB),1)
 	mv oaisim oaisim_eNB
@@ -363,7 +367,7 @@ nasmesh_fix_install:
 	(cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && $(MAKE))
 	(cd $(OPENAIR2_DIR) && $(MAKE) nasmesh_netlink_address_fix.ko)
 	(sudo insmod $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko)
-	(cp $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko . )	
+	(cp $(OPENAIR2_DIR)/NAS/DRIVER/MESH/nasmesh.ko . )
 nasmesh_nl:
 	(cd $(OPENAIR2_DIR)/NAS/DRIVER/MESH/RB_TOOL && $(MAKE))
 	(cd $(OPENAIR2_DIR) && $(MAKE) nasmesh_netlink.ko)
@@ -387,7 +391,7 @@ rrm_std_cellular:
 
 cleanall: common-cleanall clean cleanasn1
 
-cleanalmostall: clean 
+cleanalmostall: clean
 	rm -f $(ASN1_MSG_OBJS1)
 
 clean: common-clean
@@ -456,21 +460,21 @@ otg_all: otg_latency otg_gp
 
 # need to check if the file exists before calling otgplot
 otg_latency:
-	export TITLE="Application OWD(ms)" 
-	cp /tmp/otg_latency.dat /tmp/onewaydelay.dat	
+	export TITLE="Application OWD(ms)"
+	cp /tmp/otg_latency.dat /tmp/onewaydelay.dat
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_latency.dat" "[$(COL1):$(COL2)]"
 otg_latency_bg:
-	export TITLE="Background OWD(ms)" 
+	export TITLE="Background OWD(ms)"
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_latency_bg.dat" "[$(COL1):$(COL2)]"
 otg_gp:
-	export TITLE="Application Goodput(Kb/s)" 
+	export TITLE="Application Goodput(Kb/s)"
 	cp /tmp/otg_GP.dat /tmp/goodput.dat
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/goodput.dat" "[$(COL1):$(COL2)]"
 otg_gp_bg:
-	export TITLE="Background Goodput(Kb/s)" 
+	export TITLE="Background Goodput(Kb/s)"
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_GP_bg.dat" "[$(COL1):$(COL2)]"
 otg_jitter:
-	export TITLE="Aplication Jitter(ms)" 
+	export TITLE="Aplication Jitter(ms)"
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_jitter.dat" "[$(COL1):$(COL2)]"
 
 pexpect = $(shell if [ `dpkg -l | grep pexpect -c` = "0" ]; then  echo "0" ; else  echo "1" ; fi )
@@ -478,7 +482,7 @@ pexpect = $(shell if [ `dpkg -l | grep pexpect -c` = "0" ]; then  echo "0" ; els
 pre-ci:
 	@echo "Pre-commit check"
 
-ifeq 	($(pexpect), 1) 
+ifeq 	($(pexpect), 1)
 ifndef	PW
 	@echo "Usage: make pre-ci PW=mypassword"
 	@echo "Password is used to access the local host through ssh."
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index e11e41d220f..464e2f27eb1 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -53,6 +53,7 @@ int otg_times = 0;
 int if_times = 0;
 int for_times = 0;
 
+char *g_conf_config_file_name = NULL;
 u16 Nid_cell = 0; //needed by init_lte_vars
 int nb_antennas_rx=2; // //
 u8 target_dl_mcs = 0;
@@ -117,6 +118,7 @@ void get_simulation_options(int argc, char *argv[]) {
   char c;
   int option_index;
   static struct option long_options[] = {
+    {"config-file",            required_argument, 0, 0},
     {"pdcp_period",            1,                 0, 0},
     {"omg_period",             1,                 0, 0},
     {"enb-ral-listening-port", required_argument, 0, 0},
@@ -139,7 +141,12 @@ void get_simulation_options(int argc, char *argv[]) {
   while ((c = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hHi:IJ:j:k:K:l:L:m:M:n:N:oO:p:P:Q:rR:s:S:t:T:u:U:vV:w:W:x:X:y:Y:z:Z:", long_options, &option_index)) != -1) {
     switch (c) {
     case 0:
-      if (! strcmp(long_options[option_index].name, "pdcp_period")) {
+      if (! strcmp(long_options[option_index].name, "config-file")) {
+          if (optarg) {
+              g_conf_config_file_name = strdup(optarg);
+              printf("config file is %s\n", g_conf_config_file_name);
+          }
+      } else if (! strcmp(long_options[option_index].name, "pdcp_period")) {
         if (optarg) {
           pdcp_period = atoi(optarg);
           printf("PDCP period is %d\n", pdcp_period);
@@ -240,8 +247,8 @@ void get_simulation_options(int argc, char *argv[]) {
       break;
     case 'Q':
       //eMBMS_active=1;
-      // 0 : not used (default), 1: eMBMS and RRC enabled, 2: eMBMS relaying and RRC enabled, 3: eMBMS enabled, RRC disabled, 4: eMBMS relaying enabled, RRC disabled 
-      oai_emulation.info.eMBMS_active_state = atoi (optarg); 
+      // 0 : not used (default), 1: eMBMS and RRC enabled, 2: eMBMS relaying and RRC enabled, 3: eMBMS enabled, RRC disabled, 4: eMBMS relaying enabled, RRC disabled
+      oai_emulation.info.eMBMS_active_state = atoi (optarg);
       break;
     case 'R':
       oai_emulation.info.N_RB_DL = atoi (optarg);
@@ -494,7 +501,7 @@ void check_and_adjust_params() {
     LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX);
     exit(EXIT_FAILURE);
   }
- 
+
   if (oai_emulation.info.nb_rn_local > NUMBER_OF_RN_MAX) {
     LOG_E(EMU,"Enter fewer than %d RNs for the moment or change the NUMBER_OF_RN_MAX\n", NUMBER_OF_RN_MAX);
     exit(EXIT_FAILURE);
@@ -537,7 +544,7 @@ void check_and_adjust_params() {
     }
   } // ethernet flag
 
-  // 
+  //
   NB_UE_INST = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_ue_remote;
   NB_eNB_INST = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_enb_remote;
   NB_RN_INST = oai_emulation.info.nb_rn_local + oai_emulation.info.nb_rn_remote;
@@ -548,8 +555,8 @@ void check_and_adjust_params() {
 
   if (NB_RN_INST > 0 ) {
     LOG_N(EMU,"Total number of RN %d (local %d, remote %d) mobility (the same as eNB) %s  \n", NB_RN_INST,oai_emulation.info.nb_rn_local,oai_emulation.info.nb_rn_remote, oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option);
-    
-    LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ", 
+
+    LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ",
 	  NB_eNB_INST, NB_eNB_INST+NB_RN_INST,
 	  NB_UE_INST, NB_UE_INST+NB_RN_INST);
     NB_eNB_INST+=NB_RN_INST;
@@ -559,9 +566,9 @@ void check_and_adjust_params() {
 	NB_UE_INST,oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local,oai_emulation.info.nb_ue_remote,
 	NB_RN_INST,
 	oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option);
-  
-  LOG_I(EMU,"Total number of eNB %d (local %d, remote %d, relay %d) mobility %s \n", 
-	NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote, 
+
+  LOG_I(EMU,"Total number of eNB %d (local %d, remote %d, relay %d) mobility %s \n",
+	NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote,
 	NB_RN_INST,
 	oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option);
 
@@ -581,7 +588,7 @@ void init_omv() {
     case -1 :
       perror("fork failed \n");
       break;
-      case 0 : // child is going to be the omv, it is the reader 
+      case 0 : // child is going to be the omv, it is the reader
       if(close(pfd[1]) == -1 ) // we close the write desc.
       perror("close on write\n" );
       sprintf(fdstr, "%d", pfd[0] );
@@ -594,12 +601,12 @@ void init_omv() {
       sprintf(nb_antenna, "%d", 4);
       sprintf(frame_type, "%s", (oai_emulation.info.frame_type == 0) ? "FDD" : "TDD");
       sprintf(tdd_config, "%d", oai_emulation.info.tdd_config);
-// execl is used to launch the visualisor 
+// execl is used to launch the visualisor
       execl(full_name,"OMV", fdstr, frames, num_enb, num_ue, x_area, y_area, z_area, nb_antenna, frame_type, tdd_config,NULL );
       perror( "error in execl the OMV" );
     }
     //parent
-if(close( pfd[0] ) == -1 ) // we close the write desc. 
+if(close( pfd[0] ) == -1 ) // we close the write desc.
       perror("close on read\n" );
   }
 }
@@ -691,10 +698,10 @@ void init_openair2() {
 #ifdef OPENAIR2
   s32 i;
   s32 UE_id;
- 
+
   l2_init (&PHY_vars_eNB_g[0]->lte_frame_parms,
-	   oai_emulation.info.eMBMS_active_state, 
-	   oai_emulation.info.cba_group_active, 
+	   oai_emulation.info.eMBMS_active_state,
+	   oai_emulation.info.cba_group_active,
 	   oai_emulation.info.handover_active);
 
    for (i = 0; i < NB_eNB_INST; i++)
@@ -716,7 +723,7 @@ void init_ocm() {
   LOG_I(OCM,"Running with frame_type %d, Nid_cell %d, N_RB_DL %d, EP %d, mode %d, target dl_mcs %d, rate adaptation %d, nframes %d, abstraction %d, channel %s\n", oai_emulation.info.frame_type, Nid_cell, oai_emulation.info.N_RB_DL, oai_emulation.info.extended_prefix_flag, oai_emulation.info.transmission_mode,target_dl_mcs,rate_adaptation_flag,oai_emulation.info.n_frames,abstraction_flag,oai_emulation.environment_system_config.fading.small_scale.selected_option);
 
  if (abstraction_flag) {
-    
+
     get_beta_map();
 #ifdef PHY_ABSTRACTION_UL
     get_beta_map_up();
@@ -859,9 +866,9 @@ void update_ocm() {
     //LOG_D(OMG," extracting position of UE...\n");
     //      if (oai_emulation.info.omg_model_ue == TRACE)
     extract_position(ue_node_list, ue_data, NB_UE_INST);
-        
+
     /* if (frame % 50 == 0)
-      LOG_N(OCM,"Path loss for TTI %d : \n", frame); 
+      LOG_N(OCM,"Path loss for TTI %d : \n", frame);
     */
     for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) {
       for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) {
@@ -899,24 +906,24 @@ void update_ocm() {
 
 #ifdef OPENAIR2
 void update_otg_eNB(int module_id, unsigned int ctime) {
-#if defined(USER_MODE) && defined(OAI_EMU) 
+#if defined(USER_MODE) && defined(OAI_EMU)
   if (oai_emulation.info.otg_enabled ==1 ) {
 
     int dst_id, app_id;
     Packet_otg_elt *otg_pkt;
-    
+
 
     for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) {
       for_times += 1;
       // generate traffic if the ue is rrc reconfigured state
       if (mac_get_rrc_status(module_id, 1/*eNB_flag*/, dst_id) > 2 /*RRC_CONNECTED*/ ) {
-        
+
 	for (app_id=0; app_id<MAX_NUM_APPLICATION; app_id++){
 	  otg_pkt = malloc (sizeof(Packet_otg_elt));
 	  if_times += 1;
-	  
+
 	  (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen(module_id, dst_id + NB_eNB_INST, app_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size));
-	  
+
 	  if ((otg_pkt->otg_pkt).sdu_buffer != NULL) {
 	    otg_times += 1;
 	    (otg_pkt->otg_pkt).rb_id = dst_id * NB_RB_MAX + DTCH; // app could be binded to a given DRB
@@ -926,7 +933,7 @@ void update_otg_eNB(int module_id, unsigned int ctime) {
 	    (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU;
 	    //Adding the packet to the OTG-PDCP buffer
 	    pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id]));
-	    LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n", 
+	    LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n",
 		  (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id, app_id);
 	  } else {
 	    //LOG_I(EMU, "OTG returns null \n");
@@ -936,19 +943,19 @@ void update_otg_eNB(int module_id, unsigned int ctime) {
 	}
 	//LOG_T(EMU,"[eNB %d] UE mod id %d is not connected\n", module_id, dst_id);
 	//LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", module_id, pkt_list_get_head(&(otg_pdcp_buffer[module_id])));
-	
+
       }
     }
 
 #ifdef Rel10
     int service_id, session_id, rb_id;
-    // MBSM multicast traffic 
+    // MBSM multicast traffic
     // if (frame >= 50) {// only generate when UE can receive MTCH (need to control this value)
       for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount
 	for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH
 	  //   LOG_I(OTG,"DUY:frame %d, pdcp_mbms_array[module_id][rb_id].instanciated_instance is %d\n",frame,pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance);
 	  if (pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance == module_id + 1){ // this service/session is configured
-	    
+
 	    otg_pkt = malloc (sizeof(Packet_otg_elt));
 	    // LOG_T(OTG,"multicast packet gen for (service/mch %d, session/lcid %d, rb_id %d)\n", service_id, session_id, service_id*maxSessionPerPMCH + session_id);
 	    rb_id = pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].rb_id;
@@ -961,7 +968,7 @@ void update_otg_eNB(int module_id, unsigned int ctime) {
 	      //Adding the packet to the OTG-PDCP buffer
 	      (otg_pkt->otg_pkt).mode = PDCP_TM;
 	      pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id]));
-	      LOG_I(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n", 
+	      LOG_I(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n",
 		    (otg_pkt->otg_pkt).module_id, otg_pkt, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
 	    } else {
 	      //LOG_I(EMU, "OTG returns null \n");
@@ -970,8 +977,8 @@ void update_otg_eNB(int module_id, unsigned int ctime) {
 	    }
 
 
-	    // old version	    
-	   /*	    // MBSM multicast traffic 
+	    // old version
+	   /*	    // MBSM multicast traffic
 #ifdef Rel10
 	    if (frame >= 46) {// only generate when UE can receive MTCH (need to control this value)
 	      for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount
@@ -993,7 +1000,7 @@ void update_otg_eNB(int module_id, unsigned int ctime) {
 		}
 	      }
 	    } // end multicast traffic
-#endif 		    
+#endif
       	    */
 
 
@@ -1001,8 +1008,8 @@ void update_otg_eNB(int module_id, unsigned int ctime) {
 	}
       }
       //    } // end multicast traffic
-#endif 	
-    
+#endif
+
     //LOG_I(EMU, "[eNB %d] update OTG nb_elts = %d \n", module_id, otg_pdcp_buffer[module_id].nb_elements);
 
     //free(otg_pkt);
@@ -1063,7 +1070,7 @@ void update_otg_UE(int UE_id, unsigned int ctime) {
 	  //Adding the packet to the OTG-PDCP buffer
 	  (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU;
 	  pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id]));
-	  LOG_I(EMU, "[UE %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d \n", 
+	  LOG_I(EMU, "[UE %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d \n",
 		(otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id);
 	} else {
 	  free(otg_pkt);
-- 
GitLab