diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c
index 36bea7c9fb6ce0743bdf77dd646fd5b94aebcf57..e29190c81a23091ad554d3f52504a25c93ca0bbd 100644
--- a/openair1/PHY/TOOLS/time_meas.c
+++ b/openair1/PHY/TOOLS/time_meas.c
@@ -56,18 +56,29 @@ void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_ti
     
     if (first_time == 0) {
     first_time=1;
-      fprintf(stderr, "%25s  %25s  %25s  %20s %15s %6f\n","Name","Total","Average/Frame","Trials","CPU_F_GHz", cpu_freq_GHz);
+      if ((total_exec_time == NULL) || (sf_exec_time== NULL))
+	fprintf(stderr, "%25s  %25s  %25s  %25s %6f\n","Name","Total","Per Trials", "Num Trials","CPU_F_GHz", cpu_freq_GHz);
+      else
+	fprintf(stderr, "%25s  %25s  %25s  %20s %15s %6f\n","Name","Total","Average/Frame","Trials","CPU_F_GHz", cpu_freq_GHz);
     }
     if (ts->trials>0) {
       //printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials);
      
-      fprintf(stderr, "%25s:  %15.3f ms (%5.2f%%); %15.3f us (%5.2f%%); %15d;\n", 
-	      name, 
-	      (ts->diff/cpu_freq_GHz/1000000.0), 
-	      ((ts->diff/cpu_freq_GHz/1000000.0)/(total_exec_time->diff/cpu_freq_GHz/1000000.0))*100,  // percentage 
-	      (ts->diff/ts->trials/cpu_freq_GHz/1000.0), 
-	      ((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100,  // percentage 
-	      ts->trials);
+      if ((total_exec_time == NULL) || (sf_exec_time== NULL)){
+	fprintf(stderr, "%25s:  %15.3f ms ;  %15.3f us; %15d;\n", 
+		name, 	
+		(ts->diff/cpu_freq_GHz/1000000.0),
+		(ts->diff/ts->trials/cpu_freq_GHz/1000.0),	
+		ts->trials);
+      }else {
+	fprintf(stderr, "%25s:  %15.3f ms (%5.2f%%); %15.3f us (%5.2f%%); %15d;\n", 
+		name, 
+		(ts->diff/cpu_freq_GHz/1000000.0), 
+		((ts->diff/cpu_freq_GHz/1000000.0)/(total_exec_time->diff/cpu_freq_GHz/1000000.0))*100,  // percentage 
+		(ts->diff/ts->trials/cpu_freq_GHz/1000.0), 
+		((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100,  // percentage 
+		ts->trials);
+      }
     }
   }
   
diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h
index 99cb93efb778d5f3d53c295a86effcc4e7f7092f..245c8d0d203715bde96013efe78b56af8f193e5e 100755
--- a/openair1/PHY/defs.h
+++ b/openair1/PHY/defs.h
@@ -302,6 +302,11 @@ typedef struct PHY_VARS_eNB_s{
   time_stats_t phy_proc;
   time_stats_t phy_proc_tx;
   time_stats_t phy_proc_rx;
+  /*
+  time_stats_t phy_proc_sf[10]; // for each subframe
+  time_stats_t phy_proc_tx_sf[10]; 
+  time_stats_t phy_proc_rx_sf[10];
+  */
   time_stats_t rx_prach;
   
   time_stats_t ofdm_mod_stats;
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 7a3b5a159569aca9df6e6971606c0cc6648776b3..01f49b0b59f4ed805079d3f64bb7c961235fbe17 100755
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -43,6 +43,8 @@
 #include "log_extern.h"
 #include "assertions.h"
 #include "enb_config.h"
+#include "UTIL/OTG/otg.h"
+#include "UTIL/OTG/otg_externs.h"
 #if defined(OAI_EMU)
 # include "OCG.h"
 # include "OCG_extern.h"
@@ -162,6 +164,11 @@
 #define ENB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING             "annoying"
 #define ENB_CONFIG_STRING_ASN1_VERBOSITY_INFO                 "info"
 
+// OTG config per ENB-UE DL 
+#define ENB_CONF_STRING_OTG_CONFIG                          "otg_config"
+#define ENB_CONF_STRING_OTG_UE_ID                           "ue_id"
+#define ENB_CONF_STRING_OTG_APP_TYPE                        "app_type"
+#define ENB_CONF_STRING_OTG_BG_TRAFFIC                      "bg_traffic"
 
 // per eNB configuration 
 #define ENB_CONFIG_STRING_LOG_CONFIG                       "log_config"
@@ -185,8 +192,6 @@
 #define ENB_CONFIG_STRING_UDP_LOG_VERBOSITY                "udp_log_verbosity"
 
 
-
-
 #define KHz (1000UL)
 #define MHz (1000 * KHz)
 
@@ -345,7 +350,12 @@ static void enb_config_display(void) {
 	    printf( "\tue_TimersAndConstants_n311 for CC %d:\t%d:\n",j,enb_properties.properties[i]->ue_TimersAndConstants_n311[j]);
  
         }
-
+	for (j=0; j < enb_properties.properties[i]->num_otg_elements; j++){
+	  printf( "\n\tOTG Destination UE ID:  \t%d", enb_properties.properties[i]->otg_ue_id[j]);
+	  printf( "\n\tOTG App Type:  \t%d", enb_properties.properties[i]->otg_app_type[j]);
+	  printf( "\n\tOTG Background Traffic:  \t%s\n", (enb_properties.properties[i]->otg_bg_traffic[j]==1) ? "Enabled" : "Disabled");
+	}
+	
         printf( "\n\tGlobal log level:  \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->glog_level));
         printf( "\tHW log level:      \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->hw_log_level));
         printf( "\tPHY log level:     \t%s\n", map_int_to_str(log_level_names,enb_properties.properties[i]->phy_log_level));
@@ -420,10 +430,13 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) {
     config_setting_t *setting_mme_addresses         = NULL;
     config_setting_t *setting_mme_address           = NULL;
     config_setting_t *setting_enb                   = NULL;
+    config_setting_t *setting_otg                   = NULL;
+    config_setting_t *subsetting_otg                   = NULL;
     int               num_enb_properties            = 0;
     int               enb_properties_index          = 0;
     int               num_enbs;
     int               num_mme_address;
+    int               num_otg_elements              =0;
     int               num_component_carriers        =0;
     int               i;
     int               j;
@@ -523,6 +536,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) {
     char             *address                       = NULL;
     char             *cidr                          = NULL;
     char             *astring                       = NULL;
+    libconfig_int     otg_ue_id                     = 0;
+    char*             otg_app_type                  = NULL;
+    char*             otg_bg_traffic                = NULL;
     char*             glog_level                    = NULL;
     char*             glog_verbosity                = NULL;
     char*             hw_log_level                  = NULL;
@@ -1634,6 +1650,41 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) {
                             }
                         }
                     }
+
+		    // OTG _CONFIG
+		    setting_otg = config_setting_get_member (setting_enb, ENB_CONF_STRING_OTG_CONFIG);
+                    if(setting_otg != NULL) {	  
+		      num_otg_elements  = config_setting_length(setting_otg);
+		      printf("num otg elements %d \n", num_otg_elements);
+		      enb_properties.properties[enb_properties_index]->num_otg_elements = 0;
+		      for (j = 0; j < num_otg_elements; j++) {
+			subsetting_otg=config_setting_get_elem(setting_otg, j);
+			
+			if(config_setting_lookup_int(subsetting_otg, ENB_CONF_STRING_OTG_UE_ID, &otg_ue_id))
+			  enb_properties.properties[enb_properties_index]->otg_ue_id[j] = otg_ue_id;
+			else 
+			  enb_properties.properties[enb_properties_index]->otg_ue_id[j] = 1;
+			
+			if(config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_APP_TYPE, (const char **)&otg_app_type)){
+			  if ((enb_properties.properties[enb_properties_index]->otg_app_type[j] = map_str_to_int(otg_app_type_names,otg_app_type))== -1) 
+			    enb_properties.properties[enb_properties_index]->otg_app_type[j] = BCBR;
+			}else 
+			  enb_properties.properties[enb_properties_index]->otg_app_type[j] = NO_PREDEFINED_TRAFFIC; // 0
+			
+			if(config_setting_lookup_string(subsetting_otg, ENB_CONF_STRING_OTG_BG_TRAFFIC, (const char **)&otg_bg_traffic)){
+			 
+			  if ((enb_properties.properties[enb_properties_index]->otg_bg_traffic[j] = map_str_to_int(switch_names,otg_bg_traffic)) == -1){
+			    enb_properties.properties[enb_properties_index]->otg_bg_traffic[j]=0;
+	
+			  }
+			}else{ 
+			  enb_properties.properties[enb_properties_index]->otg_bg_traffic[j] = 0;
+			  printf("otg bg %s\n", otg_bg_traffic);
+			}
+			enb_properties.properties[enb_properties_index]->num_otg_elements+=1;
+			
+		      }
+		    }
                     // log_config
                     subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_LOG_CONFIG);
                     if(subsetting != NULL) {
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index 4a2739c7c9e2fe98d589ff487b8c89f249ab395c..a944fed5779cbe4f3f34ea96298f5389b871c0cc 100755
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -30,9 +30,9 @@
 /*
                                 enb_config.h
                              -------------------
-  AUTHOR  : Lionel GAUTHIER, Laurent Winckel
+  AUTHOR  : Lionel GAUTHIER, Navid Nikaein, Laurent Winckel
   COMPANY : EURECOM
-  EMAIL   : Lionel.Gauthier@eurecom.fr
+  EMAIL   : Lionel.Gauthier@eurecom.fr, navid.nikaein@eurecom.fr
 */
 
 #ifndef ENB_CONFIG_H_
@@ -42,6 +42,7 @@
 #include "commonDef.h"
 #include "platform_types.h"
 #include "PHY/impl_defs_lte.h"
+#include "PHY/impl_defs_top.h"
 #include "s1ap_messages_types.h"
 #include "RRC/LITE/MESSAGES/SystemInformationBlockType2.h"
 
@@ -181,7 +182,14 @@ typedef struct Enb_properties_s {
   char               *enb_interface_name_for_S1_MME;
   in_addr_t           enb_ipv4_address_for_S1_MME;
 
-  // log config
+  // otg config
+  /* Nb of OTG elements */
+  uint8_t            num_otg_elements;
+  /* element config*/
+  uint16_t            otg_ue_id[NUMBER_OF_UE_MAX+1];
+  uint8_t          otg_app_type[NUMBER_OF_UE_MAX+1];
+  uint8_t            otg_bg_traffic[NUMBER_OF_UE_MAX+1];
+   // log config
   int16_t           glog_level;
   int16_t           glog_verbosity;
   int16_t           hw_log_level;
diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c
index 8e48fabbb9e79d2034c5d7ce0aa94858916d778b..69140462eca5a2ae54a530873095d338d1f4de09 100644
--- a/openair2/RRC/LITE/rrc_UE.c
+++ b/openair2/RRC/LITE/rrc_UE.c
@@ -2627,37 +2627,36 @@ uint8_t check_trigger_meas_event(module_id_t ue_mod_idP,frame_t frameP, uint8_t
   //for (eNB_offset = 1;(eNB_offset<1+mac_xface->get_n_adj_cells(ue_mod_idP,0));eNB_offset++) {
       /* RHS: Verify that idx 0 corresponds to currentCellIndex in rsrp array */
 	  if((eNB_offset!=eNB_index)&&(eNB_offset<NB_eNB_INST)){
-		  if(eNB_offset<eNB_index){
-			  tmp_offset = eNB_offset;
-		  }
-		  else
-		  {
-			  tmp_offset = eNB_offset-1;
-		  }
-		  if(UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]+ofn+ocn-hys > UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_index]+ofs+ocs-1/*+a3_offset*/) {
-			  UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset] += 2; //Called every subframe = 2ms
-			  LOG_D(RRC,"[UE %d] Frame %d: Entry measTimer[%d][%d][%d]: %d currentCell: %d betterCell: %d \n",
-				  ue_mod_idP, frameP, ue_cnx_index,meas_index,tmp_offset,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset],currentCellIndex,eNB_offset);
-		  }
-		  else {
-			  UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset] = 0; //Exit condition: Resetting the measurement timer
-			  LOG_D(RRC,"[UE %d] Frame %d: Exit measTimer[%d][%d][%d]: %d currentCell: %d betterCell: %d \n",
-				  ue_mod_idP, frameP, ue_cnx_index,meas_index,tmp_offset,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset],currentCellIndex,eNB_offset);
-		  }
-		  if (UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset] >= ttt) {
-			  UE_rrc_inst->HandoverInfoUe.targetCellId = get_adjacent_cell_id(ue_mod_idP,tmp_offset); //WARNING!!!...check this!
-			  LOG_D(RRC,"[UE %d] Frame %d eNB %d: Handover triggered: targetCellId: %d currentCellId: %d eNB_offset: %d rsrp source: %3.1f rsrp target: %3.1f\n", \
-				  ue_mod_idP, frameP, eNB_index,
-				  UE_rrc_inst->HandoverInfoUe.targetCellId,ue_cnx_index,eNB_offset,
-				  (dB_fixed_times10(UE_rrc_inst[ue_mod_idP].rsrp_db[0])/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12),
-				  (dB_fixed_times10(UE_rrc_inst[ue_mod_idP].rsrp_db[eNB_offset])/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12));
-			  UE_rrc_inst->Info[0].handoverTarget = eNB_offset;
-	          //LOG_D(RRC,"PHY_ID: %d \n",UE_rrc_inst->HandoverInfoUe.targetCellId);
-			  return 1;
-		  }
-		 // else{
-		  //	LOG_D(RRC,"Condition does not hold\n");
-		 // }
+	    if(eNB_offset<eNB_index){
+	      tmp_offset = eNB_offset;
+	    }
+	    else {
+	      tmp_offset = eNB_offset-1;
+	    }
+	    if(UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_offset]+ofn+ocn-hys > UE_rrc_inst[ue_mod_idP].rsrp_db_filtered[eNB_index]+ofs+ocs-1/*+a3_offset*/) {
+	      UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset] += 2; //Called every subframe = 2ms
+	      LOG_D(RRC,"[UE %d] Frame %d: Entry measTimer[%d][%d][%d]: %d currentCell: %d betterCell: %d \n",
+		    ue_mod_idP, frameP, ue_cnx_index,meas_index,tmp_offset,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset],currentCellIndex,eNB_offset);
+	    }
+	    else {
+	      UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset] = 0; //Exit condition: Resetting the measurement timer
+	      LOG_D(RRC,"[UE %d] Frame %d: Exit measTimer[%d][%d][%d]: %d currentCell: %d betterCell: %d \n",
+		    ue_mod_idP, frameP, ue_cnx_index,meas_index,tmp_offset,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset],currentCellIndex,eNB_offset);
+	    }
+	    if (UE_rrc_inst->measTimer[ue_cnx_index][meas_index][tmp_offset] >= ttt) {
+	      UE_rrc_inst->HandoverInfoUe.targetCellId = get_adjacent_cell_id(ue_mod_idP,tmp_offset); //WARNING!!!...check this!
+	      LOG_D(RRC,"[UE %d] Frame %d eNB %d: Handover triggered: targetCellId: %d currentCellId: %d eNB_offset: %d rsrp source: %3.1f rsrp target: %3.1f\n", \
+		    ue_mod_idP, frameP, eNB_index,
+		    UE_rrc_inst->HandoverInfoUe.targetCellId,ue_cnx_index,eNB_offset,
+		    (dB_fixed_times10(UE_rrc_inst[ue_mod_idP].rsrp_db[0])/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12),
+		    (dB_fixed_times10(UE_rrc_inst[ue_mod_idP].rsrp_db[eNB_offset])/10.0)-mac_xface->get_rx_total_gain_dB(ue_mod_idP,0)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12));
+	      UE_rrc_inst->Info[0].handoverTarget = eNB_offset;
+	      //LOG_D(RRC,"PHY_ID: %d \n",UE_rrc_inst->HandoverInfoUe.targetCellId);
+	      return 1;
+	    }
+	    // else{
+	    //	LOG_D(RRC,"Condition does not hold\n");
+	    // }
 	  }
   }
   return 0;
diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h
index d462ef215ab7bc8f11c84a466c1ff1def5c37a84..a054e40469a0356b6c6c4c75838e2b7f061740f5 100644
--- a/openair2/UTIL/OPT/opt.h
+++ b/openair2/UTIL/OPT/opt.h
@@ -58,8 +58,8 @@ This header file must be included */
 #define project_include
 #include "UTIL/LOG/log_if.h"
 // #include "UTIL/LOG/log_extern.h"
-#include "PHY/defs.h"
-#include "PHY/extern.h"
+//#include "PHY/defs.h"
+//#include "PHY/extern.h"
 #include "PHY/impl_defs_lte.h"
 #endif
 
diff --git a/openair2/UTIL/OTG/otg_externs.h b/openair2/UTIL/OTG/otg_externs.h
index 437a01b6a5b3d4db2017f8115a40fa2e62c57bb7..d0ea7411bb4c12d25d1db0581209db447a5f958c 100644
--- a/openair2/UTIL/OTG/otg_externs.h
+++ b/openair2/UTIL/OTG/otg_externs.h
@@ -42,13 +42,30 @@
 #    define __OTG_EXTERNS_H__
 
 
-
-
 /*!< \brief main log variables */
 extern otg_t *g_otg; /*!< \brief global params */
 extern otg_multicast_t *g_otg_multicast; /*!< \brief global params */
 extern otg_info_t *otg_info; /*!< \brief info otg */
 extern otg_multicast_info_t *otg_multicast_info; /*!< \brief  info otg: measurements about the simulation  */
+extern otg_forms_info_t *otg_forms_info;
+
+extern mapping otg_multicast_app_type_names[] ;
+
+extern mapping otg_app_type_names[];
+
+extern mapping otg_transport_protocol_names[];
+
+extern mapping otg_ip_version_names[];
+
+extern mapping otg_multicast_app_type_names[];
+
+extern mapping otg_distribution_names[];
+
+extern mapping frame_type_names[];
+
+extern mapping switch_names[] ;
+
+extern mapping packet_gen_names[];
 
 #endif
 
diff --git a/openair2/UTIL/OTG/otg_form.c b/openair2/UTIL/OTG/otg_form.c
index 1583c62fc7be12c33045aa8e5a95e14e493e19de..558998177c37d8ea335e59d77444d277eb07cfe8 100644
--- a/openair2/UTIL/OTG/otg_form.c
+++ b/openair2/UTIL/OTG/otg_form.c
@@ -40,7 +40,7 @@
 */
 
 #include "otg_form.h"
-#include "otg_vars.h"
+#include "otg_externs.h"
 #include "otg_kpi.h"
 
 extern unsigned char NB_eNB_INST;
diff --git a/openair2/UTIL/OTG/otg_rx.c b/openair2/UTIL/OTG/otg_rx.c
index 41c062ea0cf54b41670ca4519ae74faf6e4e41b8..7aa2b970074bf8cf47ceed9bcce38ccebe569d88 100644
--- a/openair2/UTIL/OTG/otg_rx.c
+++ b/openair2/UTIL/OTG/otg_rx.c
@@ -39,7 +39,7 @@
 */
 
 #include "otg_rx.h"
-#include "otg_vars.h"
+#include "otg_externs.h"
 #include "../UTIL/MATH/oml.h"
 #include <math.h>
 #include "otg_form.h"
diff --git a/openair2/UTIL/OTG/otg_tx.c b/openair2/UTIL/OTG/otg_tx.c
index 4a1066f3dcfdf59ac3b8731ac87800da342c05b3..219e4b1892aee522beae03dbca033ff637318fef 100644
--- a/openair2/UTIL/OTG/otg_tx.c
+++ b/openair2/UTIL/OTG/otg_tx.c
@@ -41,11 +41,12 @@
 
 #include "UTIL/MATH/oml.h"
 #include "otg_tx.h" 
-#include "otg_vars.h"
+#include "otg_externs.h"
 
 extern unsigned char NB_eNB_INST;
 extern unsigned char NB_UE_INST;
 
+
 // char string for payload gen
 const char HEADER_STRING[] = "048717272261061594909177115977673656394812939088509638561159848103044447631759621785741859753883189837913087874397230808338408049820398430984093477437879374893649639479575023646394693665969273071047";
 const char PAYLOAD_STRING[] = "UVk5miARQfZGDFKf1wS0dt57kHigd0fXNrUZCjIhpyOS4pZWMHOP1GPdgXmlPtarLUjd3Rmkg05bhUZWtDDmdhrl5EzMZz6DkhIg0Uq7NlaU8ZGrt9EzgVLdr9SiBOLLXiTN3aMInMrlDYFYZ8n5WYbfZTnpz13lbMY4OBE4eWfIMLvBLLyzzzEqjUGILBVMfKGVccPi0VSCyg28RqAiR3z1P6zryk4FWFp0G78AUT1hZWhGcGOTDcKj9bCzny592m1Dj123KWczIm5KVLupO7AP83flqamimfLz6GtHrz5ZN2BAEVQjUhYSc35s5jDhofIlL2U4qPT3Ilsd7amTjaCl5zE0L89ZeIcPCWKSEuNdH5gG8sojuSvph1hU0gG4QOLhCk15IE8eCeMCz2LTL68U0hEQqeM6UmgmA9j7Eid7oPzQHbzj8A30HzGXGhWpt4CT3MSwWVvcCWSbYjkYGgOhHj5csTsONWyGAh5l3qquf8v3jGRSRu0nGXqYILCkw1SX9Na46qodrN6BnPl49djH2AuAaYKAStoR9oL7I1aZG6rVLFPMIZiAqF1tuDVcX9VWnyTVpTMXR6GtBp5bgfDyKuT4ZE9MDUASikGA5hoMfX5Gf2Ml7eLGBtEqZF4rouczHI0DRfgX4ev967n6dYFFkaXbFTvWdykN5bfMinzcrWeqVrmZhTvtUkvq3Rc9enM9qTNz6cDo0HHM0VD8EYtpaPH3yG2CYGDgogHlkaCcHaOyViyq8RH8wf4WQWoHuTNG1kWdkpgTrWic5Gv5p24O9YAPMOn6A1IsdvwpOF85qj8nPvj4nfIo385HOjGfadzfBXueruaKEa0lvbhLgS1bQWKv5fE7k2cMPzQ8USIpUyBhBGUHsLKaykvsr1qDTueAUWAGH8VqyozZZkyhWahjmFEEwU6hhcK1Z9wv9jOAAeqopQvbQFm4aQzzBwGIAhBqhZMiarIBwYPOFdPmK1hKHIa94GGtQbMZ0n83IGt6w8K3dqfOhmpQWqSRZscFwPuo4uhC0ByoC9hFpnizCBfoRZ7Gj9cGOzVLT2eMtD0XC8rUnDiR3p7Ke4ho6lWMLHmtCr7VWYIpY19dtiWoyU0FQ7VMlHoWeBhIUfuG54WVVX0h5Mvvvo0cnLQzh4knysVhAfQw9EhXq94mLrI9GydUaTihOvydQikfq2CrvLeNK81msBlYYoK0aT7OewTUI51YYufj7kYGkPVDf7t5n3VnMV3ShMERKwFyTNHQZyo9ccFibYdoT1FyMAfVeMDO89bUMKAD7RFaT9kUZpaIiH5W7dIbPcPPdSBSr1krKPtuQEeHVgf4OcQLfpOWtsEya4ftXpNw76RPCXmp4rjKt1mCh0pBiTYkQ5GDnj2khLZMzb1uua6R1ika8ACglrs1n0vDbnNjZEVpIMK4OGLFOXIOn9UBserI4Pa63PhUl49TGLNjiqQWdnAsolTKrcjnSklN1swcmyVU8B5gTO4Y3vhkG2U2";
diff --git a/openair2/UTIL/OTG/otg_vars.h b/openair2/UTIL/OTG/otg_vars.h
index 6563f4ff5fd7e5da971253a20a0fa8b79d409df3..2c31dae5e75e0c4ce1a4042b8befa53f058e0ef6 100644
--- a/openair2/UTIL/OTG/otg_vars.h
+++ b/openair2/UTIL/OTG/otg_vars.h
@@ -48,8 +48,113 @@ otg_info_t *otg_info; /*!< \brief  info otg: measurements about the simulation
 otg_multicast_info_t *otg_multicast_info; /*!< \brief  info otg: measurements about the simulation  */
 otg_forms_info_t *otg_forms_info;
 
+mapping otg_app_type_names[] =
+{
+  {"no_predefined_traffic", 0},
+  {"m2m", 1},
+  {"scbr", 2},
+  {"mcbr", 3},
+  {"bcbr", 4},
+  {"auto_pilot", 5},
+  {"bicycle_race", 6},
+  {"open_arena", 7},
+  {"team_fortress", 8},
+  {"full_buffer", 9},
+  {"m2m_traffic", 10},
+  {"auto_pilot_l",11},
+  {"auto_pilot_m", 12},
+  {"auto_pilot_h", 13},
+  {"auto_pilot_e", 14},
+  {"virtual_game_l", 15},
+  {"virtual_game_m", 16},
+  {"virtual_game_h", 17},
+  {"virtual_game_f", 18},
+  {"alarm_humidity", 19},
+  {"alarm_smoke",20},
+  {"alarm_temperature", 21},
+  {"openarena_dl", 22},
+  {"openarena_ul", 23},
+  {"voip_g711", 24},
+  {"voip_g729", 25},
+  {"iqsim_mango", 26},
+  {"iqsim_newsteo", 27},
+  {"openarena_dl_tarma", 28},
+  {"video_vbr_10mbps", 29},
+  {"video_vbr_4mbps", 30},
+  {"video_vbr_2mbps", 31},
+  {"video_vbr_768kbps", 32},
+  {"video_vbr_384kbps", 33},
+  {"video_vbr_192kpbs", 34},
+  {"background_users", 35},
+  {NULL, -1}
+};
+mapping otg_transport_protocol_names[] =
+{
+    {"no_proto", 0},
+    {"udp", 1},
+    {"tcp", 2},
+    {NULL, -1}
+};
+mapping otg_ip_version_names[] =
+{
+    {"no_ip", 0},
+    {"ipv4", 1},
+    {"ipv6", 2},
+    {NULL, -1}
+};
 
+mapping otg_multicast_app_type_names[] = {
+  {"no_predefined_multicast_traffic", 0},
+  {"mscbr", 1},
+  {"mmcbr", 2},
+  {"mbcbr", 3},
+  {"msvbr", 4},
+  {"mmvbr", 5},
+  {"mbvbr", 6},
+  {"mvideo_vbr_4mbps", 7},
+  {NULL, -1}
+}  ;
 
+mapping otg_distribution_names[] =
+{
+    {"no_customized_traffic", 0},
+    {"uniform", 1},
+    {"gaussian", 2},
+    {"exponential", 3},
+    {"poisson", 4},
+    {"fixed", 5},
+    {"weibull", 6},
+    {"pareto", 7},
+    {"gamma", 8},
+    {"cauchy",9},
+    {"log_normal",10},
+    {"tarma",11},
+    {"video",12},
+    {"background_dist",13},
+    {NULL, -1}
+};
+mapping frame_type_names[] =
+{
+    {"TDD", 1},
+    {"FDD", 0},
+    {NULL, -1}
+};
+
+mapping switch_names[] =
+{
+    {"disable", 0},
+    {"enable", 1},
+    {NULL, -1}
+};
+
+mapping packet_gen_names[] =
+{
+    {"repeat_string", 0},
+    {"substract_string", 1},
+    {"random_position", 2},
+    {"random_string", 3},
+    {NULL, -1}
+};
 //int ptime; /*!< \brief ptime is uses to compute the local simulation time */
 
 #endif
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.exmimo2.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.exmimo2.conf
index 970f594c1cf75b1dba4dfd88eb9325cb0140969f..5c12fb07108d1e4d29ec295507708ad4eea6c3e2 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.exmimo2.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.exmimo2.conf
@@ -120,7 +120,20 @@ eNBs =
         ENB_IPV4_ADDRESS_FOR_S1U                 = "192.168.13.82/24";
         ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
     };
-    
+ /*
+    otg_config = (
+    	         {	      	
+    	      	 ue_id				=1;
+	     	 app_type			="scbr";
+	      	 bg_traffic			="disable";
+	      	 },
+	      	 {	      	
+    	      	 ue_id				=2;
+	      	 app_type			="bcbr";
+	      	 bg_traffic			="enable";
+	      	 }
+	      );
+*/
     log_config : 
     {
 	global_log_level                      ="info"; 
diff --git a/targets/RT/USER/Makefile b/targets/RT/USER/Makefile
index 98df836da70aafca233aaf18bced3b8b82fc71e4..a0228ee51466c7367c2634d7f016d9033d90a2e5 100644
--- a/targets/RT/USER/Makefile
+++ b/targets/RT/USER/Makefile
@@ -18,6 +18,16 @@ ifeq "$(GCCVERSION)" "4.6.1"
     CFLAGS += -Wno-packed-bitfield-compat
 endif
 
+KERNEL_VERSION=$(shell echo `uname -r | cut -d. -f-2`)
+KERNEL_TYPE=$(shell echo `uname -r | cut -d. -f-3 | cut -d- -f3`)
+LOWLATENCY_KERNEL=$(shell if [ $(KERNEL_TYPE) = "lowlatency" ]; then echo "1" ; else echo "0" ; fi)
+
+ifdef LOWLATENCY # this ifdef is to be removed after the debugging
+ifeq ($(LOWLATENCY_KERNEL),1)
+CFLAGS+=-DLOWLATENCY
+endif 
+endif 
+
 ifndef USRP
 USRP=0
 endif
@@ -115,7 +125,7 @@ OBJ += $(LOG_OBJS)
 
 ifeq ($(OPENAIR2),1)
 ASN1_MSG_OBJS1=$(addprefix $(OPENAIR2_DIR)/RRC/LITE/MESSAGES/, $(ASN1_MSG_OBJS))
-OBJ += $(L2_OBJS) $(LIST_OBJ) $(TIMER_OBJ) $(MEM_OBJ) $(OTG_OBJS) $(MATH_OBJS)  $(OSA_OBJS)  
+OBJ += $(L2_OBJS) $(LIST_OBJ) $(TIMER_OBJ) $(MEM_OBJ) $(OTG_OBJS) $(MATH_OBJS)  $(OSA_OBJS) $(OPT_OBJS) 
 OBJ += $(OPENAIR1_DIR)/SIMULATION/ETH_TRANSPORT/netlink_init.o
 #OBJ += $(PDCP_DIR)/pdcp_thread.o
 CFLAGS += -DOPENAIR2 -DNO_RRM -DPUCCH -DMAC_CONTEXT=1
@@ -404,6 +414,7 @@ show:
 	@echo IS_REL10 is $(IS_REL10)
 	@echo openssl $(OPENSSL_FOUND) 
 	@echo nettle $(NETTLE_FOUND)
+	@echo lowlatency kernel: $(LOWLATENCY_KERNEL)
 
 beautiful:
 	astyle --style=gnu -s2 $(SRC)
diff --git a/targets/RT/USER/eNB.gtkw b/targets/RT/USER/eNB.gtkw
index 4222e53fc1bac99ebb5955c3faab1ba66b438983..d448406e0a276366722df09a5f080e5ce5defefe 100644
--- a/targets/RT/USER/eNB.gtkw
+++ b/targets/RT/USER/eNB.gtkw
@@ -5,7 +5,7 @@
 [dumpfile] "/tmp/openair_dump_eNB.vcd"
 [dumpfile_mtime] "Wed Sep 17 09:52:33 2014"
 [dumpfile_size] 53042998
-[savefile] "/homes/knopp/Devel/openair4G/trunk/targets/RT/USER/eNB.gtkw"
+[savefile] "$OPENAIR_TARGETS/RT/USER/eNB.gtkw"
 [timestart] 13048857000
 [size] 1005 600
 [pos] -1 -1
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index cecadf94b4eeb8b0eaf9873b54f96b05c007b136..bf5e757599b8327762f6fb25c5dd2f5815da28f7 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -48,9 +48,11 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sched.h>
+#include <linux/sched.h>
 #include <signal.h>
 #include <execinfo.h>
 #include <getopt.h>
+#include <syscall.h>
 
 #include "rt_wrapper.h"
 #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
@@ -92,7 +94,6 @@ static int hw_subframe;
 #endif
 
 #ifdef OPENAIR2
-#include "otg_tx.h"
 #include "LAYER2/MAC/defs.h"
 #include "LAYER2/MAC/vars.h"
 #include "LAYER2/MAC/proto.h"
@@ -108,9 +109,10 @@ unsigned short config_frames[4] = {2,9,11,13};
 #endif
 #include "UTIL/LOG/log_extern.h"
 #include "UTIL/OTG/otg.h"
-#include "UTIL/OTG/otg_vars.h"
+#include "UTIL/OTG/otg_externs.h"
 #include "UTIL/MATH/oml.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
+#include "UTIL/OPT/opt.h"
 #include "enb_config.h"
 
 #if defined(ENABLE_ITTI)
@@ -178,7 +180,9 @@ static SEM *sync_sem; // to sync rx & tx streaming
 pthread_t                       main_eNB_thread;
 pthread_t                       main_ue_thread;
 pthread_attr_t                  attr_dlsch_threads;
+#ifndef LOWLATENCY
 struct sched_param              sched_param_dlsch;
+#endif 
 
 pthread_cond_t sync_cond;
 pthread_mutex_t sync_mutex;
@@ -190,14 +194,16 @@ RTIME T0;
 pthread_attr_t                  attr_UE_init_synch;
 pthread_attr_t                  attr_UE_thread_tx;
 pthread_attr_t                  attr_UE_thread_rx;
-pthread_attr_t                  attr_eNB_proc_tx[MAX_NUM_CCs][10];
-pthread_attr_t                  attr_eNB_proc_rx[MAX_NUM_CCs][10];
 struct sched_param              sched_param_UE_init_synch;
 struct sched_param              sched_param_UE_thread_tx;
 struct sched_param              sched_param_UE_thread_rx;
+
+pthread_attr_t                  attr_eNB_proc_tx[MAX_NUM_CCs][10];
+pthread_attr_t                  attr_eNB_proc_rx[MAX_NUM_CCs][10];
+#ifndef LOWLATENCY
 struct sched_param              sched_param_eNB_proc_tx[MAX_NUM_CCs][10];
 struct sched_param              sched_param_eNB_proc_rx[MAX_NUM_CCs][10];
-
+#endif
 #ifdef XFORMS
 static pthread_t                forms_thread; //xforms
 #endif
@@ -336,7 +342,13 @@ static LTE_DL_FRAME_PARMS      *frame_parms[MAX_NUM_CCs];
 int multi_thread=1;
 uint32_t target_dl_mcs = 28; //maximum allowed mcs
 uint32_t target_ul_mcs = 10;
+uint8_t exit_missed_slots=1;
+uint64_t num_missed_slots=0; // counter for the number of missed slots
 
+time_stats_t softmodem_stats_mt; // main thread
+time_stats_t softmodem_stats_hw; //  hw acquisation
+time_stats_t softmodem_stats_tx_sf[10]; // total tx time 
+time_stats_t softmodem_stats_rx_sf[10]; // total rx time 
 int transmission_mode=1;
 
 int16_t           glog_level         = LOG_DEBUG;
@@ -369,6 +381,18 @@ unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe)
   return (dcoff_i_rxfe + (dcoff_q_rxfe<<8));
 }
 
+#ifdef LOWLATENCY
+int sched_setattr(pid_t pid, const struct sched_attr *attr, unsigned int flags) {
+
+  return syscall(__NR_sched_setattr, pid, attr, flags);
+}
+
+
+int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned int flags){
+
+  return syscall(__NR_sched_getattr, pid, attr, size, flags);
+}
+#endif 
 #if !defined(ENABLE_ITTI)
 void signal_handler(int sig)
 {
@@ -394,7 +418,7 @@ void signal_handler(int sig)
 void exit_fun(const char* s)
 {
   if (s != NULL) {
-    printf("%s %s() Exiting: %s\n",__FILE__, __FUNCTION__, s);
+    printf("%s %s() Exiting OAI softmodem: %s\n",__FILE__, __FUNCTION__, s);
   }
 
   oai_exit = 1;
@@ -909,7 +933,12 @@ static void * eNB_thread_tx(void *param) {
 #ifdef RTAI
   RT_TASK *task;
   char task_name[8];
+#else 
+#ifdef LOWLATENCY
+  struct sched_attr attr;
+  unsigned int flags = 0;
 #endif
+#endif 
 
  
 /*#if defined(ENABLE_ITTI)
@@ -932,9 +961,29 @@ static void * eNB_thread_tx(void *param) {
 	  task);
   }
 #else
-  //  LOG_I(PHY,
-  printf("[SCHED][eNB] eNB TX thread %d started on CPU %d\n",
-	 proc->subframe,sched_getcpu());
+#ifdef LOWLATENCY
+  attr.size = sizeof(attr);
+  attr.sched_flags = 0;
+  attr.sched_nice = 0;
+  attr.sched_priority = 0;
+  
+  /* This creates a 10ms/30ms reservation */
+  attr.sched_policy = SCHED_DEADLINE;
+  attr.sched_runtime = 1 * 1000000;  // each tx thread requires 1ms to finish its job
+  attr.sched_deadline =1 * 1000000; // each tx thread will finish within 1ms
+  attr.sched_period = 1 * 10000000; // each tx thread has a period of 10ms from the starting point
+  
+  if (sched_setattr(0, &attr, flags) < 0 ){
+  perror("[SCHED] eNB tx thread: sched_setattr failed\n");
+  exit(-1);
+}
+  LOG_I(HW,"[SCHED] eNB TX deadline thread %d(id %ld) started on CPU %d\n",
+    proc->subframe, gettid(),sched_getcpu());
+#else 
+  LOG_I(HW,"[SCHED] eNB TX thread %d started on CPU %d\n",
+	  proc->subframe,sched_getcpu());
+#endif
+
 #endif
 
   mlockall(MCL_CURRENT | MCL_FUTURE);
@@ -950,7 +999,6 @@ static void * eNB_thread_tx(void *param) {
     
     vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),0);
     
-    
     //LOG_I(PHY,"Locking mutex for eNB proc %d (IC %d,mutex %p)\n",proc->subframe,proc->instance_cnt,&proc->mutex);
     //    printf("Locking mutex for eNB proc %d (subframe_tx %d))\n",proc->subframe,proc->subframe_tx);
 
@@ -974,7 +1022,8 @@ static void * eNB_thread_tx(void *param) {
     }
     vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),1);    
     vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX_ENB, proc->frame_tx);
-    
+    start_meas(&softmodem_stats_tx_sf[proc->subframe]);
+
     if (oai_exit) break;
 
     
@@ -1009,6 +1058,7 @@ static void * eNB_thread_tx(void *param) {
       proc->frame_tx=0;
 
   }    
+  stop_meas(&softmodem_stats_tx_sf[proc->subframe]);
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),0);        
 #ifdef HARD_RT
   rt_make_soft_real_time();
@@ -1039,6 +1089,11 @@ static void * eNB_thread_rx(void *param) {
 #ifdef RTAI
   RT_TASK *task;
   char task_name[8];
+#else
+#ifdef LOWLATENCY
+  struct sched_attr attr;
+  unsigned int flags = 0;
+#endif
 #endif
 
 /*#if defined(ENABLE_ITTI)
@@ -1061,8 +1116,29 @@ static void * eNB_thread_rx(void *param) {
 	  task); /*,rtai_cpuid()*/
   }
 #else
-  LOG_I(PHY,"[SCHED][eNB] eNB RX thread %d started on CPU %d\n",
-	proc->subframe,sched_getcpu());
+#ifdef LOWLATENCY
+  attr.size = sizeof(attr);
+  attr.sched_flags = 0;
+  attr.sched_nice = 0;
+  attr.sched_priority = 0;
+  
+  /* This creates a 10ms/30ms reservation */
+  attr.sched_policy = SCHED_DEADLINE;
+  attr.sched_runtime = 1 * 2000000;  // each rx thread must finish its job in the worst case in 2ms
+  attr.sched_deadline =1 * 2000000; // each rx thread will finish within 2ms
+  attr.sched_period = 1 * 10000000; // each rx thread has a period of 10ms from the starting point
+  
+  if (sched_setattr(0, &attr, flags) < 0 ){
+    perror("[SCHED] eNB RX sched_setattr failed\n");
+    exit(-1);
+  }
+  LOG_I(HW,"[SCHED] eNB RX deadline thread %d(id %ld) started on CPU %d\n",
+	  proc->subframe, gettid(),sched_getcpu());
+#else 
+  LOG_I(HW,"[SCHED][eNB] eNB RX thread %d started on CPU %d\n",
+	  proc->subframe,sched_getcpu());
+#endif
+ 
 #endif
 
   mlockall(MCL_CURRENT | MCL_FUTURE);
@@ -1096,7 +1172,8 @@ static void * eNB_thread_rx(void *param) {
     }
     vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RX0+(2*proc->subframe),1);    
     vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX_ENB, proc->frame_rx);
-
+    start_meas(&softmodem_stats_rx_sf[proc->subframe]);
+    
     if (oai_exit) break;
     
     if ((((PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms.frame_type == TDD )&&(subframe_select(&PHY_vars_eNB_g[0][proc->CC_id]->lte_frame_parms,proc->subframe_rx)==SF_UL)) ||
@@ -1123,6 +1200,7 @@ static void * eNB_thread_rx(void *param) {
       proc->frame_rx=0;
     
   }
+  stop_meas(&softmodem_stats_rx_sf[proc->subframe]);
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RX0+(2*proc->subframe),0);        
 #ifdef HARD_RT
   rt_make_soft_real_time();
@@ -1154,19 +1232,25 @@ void init_eNB_proc(void) {
 
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
     for (i=0;i<10;i++) {
+      /*set the stack sizw */ 
       pthread_attr_init (&attr_eNB_proc_tx[CC_id][i]);
-      pthread_attr_setstacksize(&attr_eNB_proc_tx[CC_id][i],OPENAIR_THREAD_STACK_SIZE);
+      if (pthread_attr_setstacksize(&attr_eNB_proc_tx[CC_id][i],OPENAIR_THREAD_STACK_SIZE) != 0)
+	perror("[ENB_PROC_TX] setting thread stack size failed\n");
+
+      pthread_attr_init (&attr_eNB_proc_rx[CC_id][i]);
+      if (pthread_attr_setstacksize(&attr_eNB_proc_rx[CC_id][i],OPENAIR_THREAD_STACK_SIZE) != 0)
+	perror("[ENB_PROC_RX] setting thread stack size failed\n");
+      /* set the kernel scheduling policy and priority */
+#ifndef LOWLATENCY
       //attr_dlsch_threads.priority = 1;
       sched_param_eNB_proc_tx[CC_id][i].sched_priority = sched_get_priority_max(SCHED_FIFO)-1; //OPENAIR_THREAD_PRIORITY;
       pthread_attr_setschedparam  (&attr_eNB_proc_tx[CC_id][i], &sched_param_eNB_proc_tx[CC_id][i]);
       pthread_attr_setschedpolicy (&attr_eNB_proc_tx[CC_id][i], SCHED_FIFO);
-      
-      pthread_attr_init (&attr_eNB_proc_rx[CC_id][i]);
-      pthread_attr_setstacksize(&attr_eNB_proc_rx[CC_id][i],OPENAIR_THREAD_STACK_SIZE);
       //attr_dlsch_threads.priority = 1;
       sched_param_eNB_proc_rx[CC_id][i].sched_priority = sched_get_priority_max(SCHED_FIFO)-1; //OPENAIR_THREAD_PRIORITY;
       pthread_attr_setschedparam  (&attr_eNB_proc_rx[CC_id][i], &sched_param_eNB_proc_rx[CC_id][i]);
       pthread_attr_setschedpolicy (&attr_eNB_proc_rx[CC_id][i], SCHED_FIFO);
+#endif       
       
       PHY_vars_eNB_g[0][CC_id]->proc[i].instance_cnt_tx=-1;
       PHY_vars_eNB_g[0][CC_id]->proc[i].instance_cnt_rx=-1;
@@ -1261,7 +1345,14 @@ static void *eNB_thread(void *arg)
 {
 #ifdef RTAI
   RT_TASK *task;
+#else 
+#ifdef LOWLATENCY
+  struct sched_attr attr;
+  unsigned int flags = 0;
+  unsigned long mask = 1; /* processor 0 */
+#endif
 #endif
+
 #ifdef EXMIMO
   unsigned char slot=0;
 #else
@@ -1298,14 +1389,40 @@ static void *eNB_thread(void *arg)
   */
 
 #ifdef RTAI
-  task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF);
+   task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF);
+#else 
+#ifdef LOWLATENCY
+   attr.size = sizeof(attr);
+   attr.sched_flags = 0;
+   attr.sched_nice = 0;
+   attr.sched_priority = 0;
+   
+   /* This creates a 10ms/30ms reservation */
+   attr.sched_policy = SCHED_DEADLINE;
+   attr.sched_runtime = 1 * 500000;
+   attr.sched_deadline =1 * 500000;
+   attr.sched_period = 1 * 1000000;
+   
+   /* pin the eNB main thread to CPU0*/
+   /* if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) {
+        perror("[MAIN_ENB_THREAD] pthread_setaffinity_np failed\n");
+	}*/
+   
+   if (sched_setattr(0, &attr, flags) < 0 ){
+     perror("[SCHED] main eNB thread: sched_setattr failed\n");
+     exit_fun(-1);
+   } else {
+     LOG_I(HW,"[SCHED][eNB] eNB main deadline thread %ld started on CPU %d\n",
+	    gettid(),sched_getcpu());
+   }
+#endif
 #endif
 
   if (!oai_exit) {
 #ifdef RTAI
-    printf("[SCHED][eNB] Started eNB thread (id %p)\n",task);
+    printf("[SCHED][eNB] Started eNB main thread (id %p)\n",task);
 #else
-    printf("[SCHED][eNB] Started eNB thread on CPU %d\n",
+    printf("[SCHED][eNB] Started eNB main thread on CPU %d\n",
 	   sched_getcpu());
 #endif
 
@@ -1334,7 +1451,7 @@ static void *eNB_thread(void *arg)
     //    printf("starting eNB thread @ %llu\n",get_usrp_time(&openair0));
 
     while (!oai_exit) {
-
+      start_meas(&softmodem_stats_mt);
 #ifdef EXMIMO
       hw_slot = (((((volatile unsigned int *)DAQ_MBOX)[0]+1)%150)<<1)/15;
       //        LOG_D(HW,"eNB frame %d, time %llu: slot %d, hw_slot %d (mbox %d)\n",frame,rt_get_time_ns(),slot,hw_slot,((unsigned int *)DAQ_MBOX)[0]);
@@ -1364,8 +1481,13 @@ static void *eNB_thread(void *arg)
 	// at the eNB, even slots have double as much time since most of the processing is done here and almost nothing in odd slots
 	LOG_D(HW,"eNB Frame %d, time %llu: missed slot, proceeding with next one (slot %d, hw_slot %d, mbox_current %d, mbox_target %d, diff %d)\n",frame, rt_get_time_ns(), slot, hw_slot, mbox_current, mbox_target, diff);
 	slot++;
-	//if (frame > 0)
-	exit_fun("[HW][eNB] missed slot");
+	if (exit_missed_slots==1){
+	  stop_meas(&softmodem_stats_mt);
+	  exit_fun("[HW][eNB] missed slot");
+	}else{
+	  num_missed_slots++;
+	  LOG_W(HW,"[eNB] just missed slot (total missed slots %ld)\n", num_missed_slots);
+	}
       }
       if (diff>8)
 	LOG_D(HW,"eNB Frame %d, time %llu: skipped slot, waiting for hw to catch up (slot %d, hw_slot %d, mbox_current %d, mbox_target %d, diff %d)\n",frame, rt_get_time_ns(), slot, hw_slot, mbox_current, mbox_target, diff);
@@ -1388,6 +1510,7 @@ static void *eNB_thread(void *arg)
 	//LOG_D(HW,"eNB Frame %d : hw_slot %d, time %llu\n",frame,hw_slot,rt_get_time_ns());
 	delay_cnt++;
 	if (delay_cnt == 10) {
+	  stop_meas(&softmodem_stats_mt);
 	  LOG_D(HW,"eNB Frame %d: HW stopped ... \n",frame);
 	  exit_fun("[HW][eNB] HW stopped");
 	}
@@ -1417,13 +1540,13 @@ static void *eNB_thread(void *arg)
 
 	for (i=0;i<PHY_vars_eNB_g[0][0]->lte_frame_parms.nb_antennas_rx;i++)
 	  rxp[i] = (void*)&rxdata[i][rx_cnt*samples_per_packets];
-
+	start_meas(&softmodem_stats_hw);
 	rxs = openair0.trx_read_func(&openair0, 
 				     &timestamp, 
 				     rxp, 
 				     samples_per_packets,
 				     PHY_vars_eNB_g[0][0]->lte_frame_parms.nb_antennas_rx);
-
+	stop_meas(&softmodem_stats_hw);
 	if (rxs != samples_per_packets)
 	  oai_exit=1;
  
@@ -1443,7 +1566,7 @@ static void *eNB_thread(void *arg)
 				PHY_vars_eNB_g[0][0]->lte_frame_parms.nb_antennas_tx,
 				1);
 
-	
+	stop_meas(&softmodem_stats_mt);
 	vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE,0);
 #else
 	rt_sleep_ns(1000000);
@@ -2178,8 +2301,14 @@ static void *UE_thread(void *arg) {
 	
       if (diff2 <(-7)) {
 	LOG_D(HW,"UE Frame %d: missed slot, proceeding with next one (slot %d, hw_slot %d, diff %d)\n",frame, slot, hw_slot, diff2);
-	if (frame>0)
-	  exit_fun("[HW][UE] missed slot");
+	if (frame>0){
+	  if (exit_missed_slots==1)
+	    exit_fun("[HW][UE] missed slot");
+	  else{
+	    num_missed_slots++;
+	    LOG_W(HW,"[UE] just missed slot (total missed slots %ld)\n", num_missed_slots);
+	  }
+	}
 	slot++;
 	if (slot==20) {
 	  slot=0;
@@ -2426,7 +2555,7 @@ static void get_options (int argc, char **argv) {
     {"no-L2-connect",   no_argument,        NULL, LONG_OPTION_NO_L2_CONNECT},
     {NULL, 0, NULL, 0}};
   
-  while ((c = getopt_long (argc, argv, "C:dK:g:F:G:qO:m:SUVRMr:s:t:x:",long_options,NULL)) != -1) {
+  while ((c = getopt_long (argc, argv, "C:dK:g:F:G:qO:m:SUVRMr:P:s:t:x:",long_options,NULL)) != -1) {
     switch (c) {
     case LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS:
       ULSCH_max_consecutive_errors = atoi(optarg);
@@ -2500,6 +2629,22 @@ static void get_options (int argc, char **argv) {
     case 't':
       target_ul_mcs = atoi (optarg);
       break;
+    case 'P':
+      /* enable openair packet tracer (OPT)*/
+      if ((strcmp(optarg, "wireshark") == 0) || 
+	  (strcmp(optarg, "WIRESHARK") == 0)) {
+	opt_type = OPT_WIRESHARK;
+	printf("Enabling OPT for wireshark\n");
+      } else if ((strcmp(optarg, "pcap") == 0) ||
+		 (strcmp(optarg, "PCAP") == 0)){
+	opt_type = OPT_PCAP;
+	printf("Enabling OPT for pcap\n");
+      } else {
+	opt_type = OPT_NONE;
+	printf("Unrecognized option for OPT module\n");
+	printf("Possible values are either wireshark or pcap\n");
+      }
+      break;  
       
     case 'V':
       ouput_vcd = 1;
@@ -2551,6 +2696,10 @@ static void get_options (int argc, char **argv) {
       printf("Note: -s not defined for ExpressMIMO2\n");
 #endif
       break;
+    case 'S':
+      exit_missed_slots=0;
+      printf("Skip exit for missed slots\n");
+      break;
     case 'g':
       glog_level=atoi(optarg); // value between 1 - 9
       break;
@@ -2593,7 +2742,7 @@ static void get_options (int argc, char **argv) {
   }
   
   if ((UE_flag == 0) && (conf_config_file_name != NULL)) {
-    int i;
+    int i,j;
     
     NB_eNB_INST = 1;
     
@@ -2625,6 +2774,26 @@ static void get_options (int argc, char **argv) {
 	//} // j
       }
 
+      
+#ifdef OPENAIR2
+      
+      init_all_otg(0);
+      g_otg->seed = 0;
+      init_seeds(g_otg->seed);
+      for (k=0; k<enb_properties->properties[i]->num_otg_elements; k++){
+	j=enb_properties->properties[i]->otg_ue_id[k]; // ue_id
+	g_otg->application_idx[i][j] = 1;
+	//g_otg->packet_gen_type=SUBSTRACT_STRING;
+	g_otg->background[i][j][0] =enb_properties->properties[i]->otg_bg_traffic[k];
+	g_otg->application_type[i][j][0] =enb_properties->properties[i]->otg_app_type[k];// BCBR; //MCBR, BCBR
+      
+	printf("[OTG] configuring traffic type %d for  eNB %d UE %d (Background traffic is %s)\n",
+	       g_otg->application_type[i][j][0], i, j,(g_otg->background[i][j][0]==1)?"Enabled":"Disabled");
+      }
+      init_predef_traffic(enb_properties->properties[i]->num_otg_elements, 1);
+  
+#endif
+      
       glog_level                     = enb_properties->properties[i]->glog_level;
       glog_verbosity                 = enb_properties->properties[i]->glog_verbosity;
       hw_log_level                   = enb_properties->properties[i]->hw_log_level;
@@ -2722,15 +2891,16 @@ int main(int argc, char **argv) {
     frame_parms[CC_id]->num_MBSFN_config    = 0;
   }
 
-  get_options (argc, argv); //Command-line options
+  // initialize the log (see log.h for details)
+  logInit();
+  set_glog(glog_level, glog_verbosity);
 
   //randominit (0);
   set_taus_seed (0);
 
-  // initialize the log (see log.h for details)
-  logInit();
+  get_options (argc, argv); //Command-line options
+  
 
-  set_glog(glog_level, glog_verbosity);
   if (UE_flag==1)
     {
       printf("configuring for UE\n");
@@ -2793,7 +2963,20 @@ int main(int argc, char **argv) {
     else
       vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd");
   }
-
+  
+  if (opp_enabled ==1)
+    reset_opp_meas();
+
+  if (opt_type != OPT_NONE) {
+    radio_type_t radio_type;
+    if (frame_parms[0]->frame_type == FDD)
+      radio_type = RADIO_TYPE_FDD;
+    else 
+      radio_type = RADIO_TYPE_TDD;
+    if (init_opt(NULL, NULL, NULL, radio_type) == -1)
+      LOG_E(OPT,"failed to run OPT \n");
+  }
+  
 #if defined(ENABLE_ITTI)
   if (UE_flag == 1) {
     log_set_instance_type (LOG_INSTANCE_UE);
@@ -3125,7 +3308,7 @@ int main(int argc, char **argv) {
   printf("ITTI tasks created\n");
 #endif
 
-#ifdef OPENAIR2
+  /* #ifdef OPENAIR2
   //if (otg_enabled) {
   init_all_otg(0);
   g_otg->seed = 0;
@@ -3141,7 +3324,7 @@ int main(int argc, char **argv) {
   }
   init_predef_traffic(UE_flag ? 1 : 0, UE_flag ? 0 : 1);
   //  }
-#endif
+  #endif */
 
   number_of_cards = openair0_num_detected_cards;
 
@@ -3312,10 +3495,12 @@ int main(int argc, char **argv) {
 #ifndef RTAI
   pthread_attr_init (&attr_dlsch_threads);
   pthread_attr_setstacksize(&attr_dlsch_threads,OPENAIR_THREAD_STACK_SIZE);
+
+#ifndef LOWLATENCY
   sched_param_dlsch.sched_priority = sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY;
   pthread_attr_setschedparam  (&attr_dlsch_threads, &sched_param_dlsch);
   pthread_attr_setschedpolicy (&attr_dlsch_threads, SCHED_FIFO);
-
+#endif 
   pthread_attr_init (&attr_UE_init_synch);
   pthread_attr_setstacksize(&attr_UE_init_synch,OPENAIR_THREAD_STACK_SIZE);
   sched_param_UE_init_synch.sched_priority = sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY;
@@ -3498,6 +3683,9 @@ int main(int argc, char **argv) {
   if (ouput_vcd)
     vcd_signal_dumper_close();
 
+  if (opt_type != OPT_NONE)
+    terminate_opt();
+
   logClean();
 
   return 0;
@@ -3705,3 +3893,22 @@ int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_c
   return(0);
 }
 
+void reset_opp_meas(void){
+  int sfn;
+  reset_meas(&softmodem_stats_mt);
+  reset_meas(&softmodem_stats_hw);
+  for (sfn=0; sfn < 10; sfn++) {
+    reset_meas(&softmodem_stats_tx_sf[sfn]);
+    reset_meas(&softmodem_stats_rx_sf[sfn]);
+  }
+}
+
+void print_opp_meas(void){
+  int sfn=0;
+  print_meas(&softmodem_stats_mt, "Main ENB Thread", NULL, NULL);
+  print_meas(&softmodem_stats_hw, "HW Acquisation", NULL, NULL);
+  for (sfn=0; sfn < 10; sfn++) {
+    print_meas(&softmodem_stats_tx_sf[sfn],"[eNB][total_phy_proc_tx]",NULL, NULL);
+    print_meas(&softmodem_stats_rx_sf[sfn],"[eNB][total_phy_proc_rx]",NULL,NULL);
+  }
+}
diff --git a/targets/RT/USER/rt_wrapper.h b/targets/RT/USER/rt_wrapper.h
index d76faa874e578978281da73c90d3c01fb3ca8e91..19ad531df1926d882609c7483e75e75fd514b4cc 100644
--- a/targets/RT/USER/rt_wrapper.h
+++ b/targets/RT/USER/rt_wrapper.h
@@ -28,14 +28,14 @@
  *******************************************************************************/
 
 /*! \file rt_wrapper.h
-* \brief provides a wrapper for the timing function for real-time opeartions depending on weather RTAI is used or not
-* \author F. Kaltenberger
+* \brief provides a wrapper for the timing function for real-time opeartions depending on weather RTAI is used or not. It also implements an API for the SCHED_DEADLINE kernel scheduler.
+* \author F. Kaltenberger and Navid Nikaein
 * \date 2013
 * \version 0.1
 * \company Eurecom
-* \email: florian.kaltenberger@eurecom.fr
+* \email: florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr
 * \note
-* \warning
+* \warning This code will be removed when a legacy libc API becomes available.
 */
 
 #ifndef RTAI
@@ -43,6 +43,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <pthread.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
 
 #define RTIME long long int
 
@@ -54,6 +56,51 @@ int rt_sleep_ns (RTIME x);
 
 void check_clock(void);
 
+/**
+ * see https://www.kernel.org/doc/Documentation/scheduler/sched-deadline.txt  or
+ * http://www.blaess.fr/christophe/2014/04/05/utiliser-un-appel-systeme-inconnu-de-la-libc/
+ */
+#ifdef LOWLATENCY
+
+#define gettid() syscall(__NR_gettid)
+
+#define SCHED_DEADLINE	6
+
+ /* XXX use the proper syscall numbers */
+#ifdef __x86_64__
+ #define __NR_sched_setattr		314 
+ #define __NR_sched_getattr		315
+#endif
+
+#ifdef __i386__
+ #define __NR_sched_setattr		351
+ #define __NR_sched_getattr		352
+#endif
+
+struct sched_attr {
+  __u32 size;
+  
+  __u32 sched_policy;
+  __u64 sched_flags;
+  
+  /* SCHED_NORMAL, SCHED_BATCH */
+  __s32 sched_nice;
+  
+  /* SCHED_FIFO, SCHED_RR */
+  __u32 sched_priority;
+  
+  /* SCHED_DEADLINE (nsec) */
+  __u64 sched_runtime;
+  __u64 sched_deadline;
+  __u64 sched_period;
+};
+
+int sched_setattr(pid_t pid, const struct sched_attr *attr, unsigned int flags);
+
+int sched_getattr(pid_t pid,struct sched_attr *attr,unsigned int size, unsigned int flags);
+
+#endif 
+
 #else
 #include <rtai_hal.h>
 #include <rtai_lxrt.h>
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 6186d4a3b1e3c16f492e095005c019551caaabd1..1b20386c2700ebe400126bd491da208456ff1002 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -565,8 +565,7 @@ void *l2l1_task(void *args_p) {
   start_meas(&oaisim_stats);
   for (frame = 0; (l2l1_state != L2L1_TERMINATED) && (frame < oai_emulation.info.n_frames); frame++) {
 
-    start_meas(&oaisim_stats_f);
-
+ 
 #if defined(ENABLE_ITTI)
     do {
       // Checks if a message has been sent to L2L1 task
@@ -660,7 +659,9 @@ void *l2l1_task(void *args_p) {
     update_ocm ();
 
     for (slot = 0; slot < 20; slot++) {
-	
+      if (slot%2==0)
+	start_meas(&oaisim_stats_f);
+
       wait_for_slot_isr ();
 
 #if defined(ENABLE_ITTI)
@@ -977,7 +978,8 @@ void *l2l1_task(void *args_p) {
 	    }
 	  */
 	} // if Channel_Flag==0
-    
+      if (slot%2==1)
+	stop_meas(&oaisim_stats_f);
     }//end of slot
 
     if ((frame >= 10) && (frame <= 11) && (abstraction_flag == 0)
@@ -1028,8 +1030,9 @@ void *l2l1_task(void *args_p) {
       smbv_frame_cnt++;
     }
 #endif
+ 
   }
-  stop_meas(&oaisim_stats_f);
+  
     //end of frame
       
   stop_meas(&oaisim_stats);
@@ -1267,75 +1270,81 @@ void *l2l1_task(void *args_p) {
       reset_meas(&UE_pdcp_stats[UE_id].pdcp_ip);
       reset_meas(&UE_pdcp_stats[UE_id].ip_pdcp);
     
-      for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->phy_proc);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->phy_proc_rx);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->phy_proc_tx);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->rx_prach);
-    
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ofdm_mod_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_encoding_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_modulation_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_scrambling_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_rate_matching_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_turbo_encoding_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_interleaving_stats);
-    
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ofdm_demod_stats);
-	//reset_meas(&PHY_vars_eNB_g[eNB_id]->rx_dft_stats);
-	//reset_meas(&PHY_vars_eNB_g[eNB_id]->ulsch_channel_estimation_stats);
-	//reset_meas(&PHY_vars_eNB_g[eNB_id]->ulsch_freq_offset_estimation_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_decoding_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_demodulation_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_rate_unmatching_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_turbo_decoding_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_deinterleaving_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_demultiplexing_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_llr_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_init_stats);    
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_alpha_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_beta_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_gamma_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_ext_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl1_stats);
-	reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl2_stats);
-    
-	reset_meas(&eNB2UE[eNB_id][UE_id][0]->random_channel);
-	reset_meas(&eNB2UE[eNB_id][UE_id][0]->interp_time);
-	reset_meas(&eNB2UE[eNB_id][UE_id][0]->interp_freq);
-	reset_meas(&eNB2UE[eNB_id][UE_id][0]->convolution);
-	reset_meas(&UE2eNB[UE_id][eNB_id][0]->random_channel);
-	reset_meas(&UE2eNB[UE_id][eNB_id][0]->interp_time);
-	reset_meas(&UE2eNB[UE_id][eNB_id][0]->interp_freq);
-	reset_meas(&UE2eNB[UE_id][eNB_id][0]->convolution);
-	/* 
-	 * L2 functions 
-	 */
-	// eNB MAC
-	reset_meas(&eNB_mac_inst[eNB_id].eNB_scheduler); // total 
-	reset_meas(&eNB_mac_inst[eNB_id].schedule_si); // only schedule + tx
-	reset_meas(&eNB_mac_inst[eNB_id].schedule_ra); // only ra
-	reset_meas(&eNB_mac_inst[eNB_id].schedule_ulsch); // onlu ulsch
-	reset_meas(&eNB_mac_inst[eNB_id].fill_DLSCH_dci);// only dci
-	reset_meas(&eNB_mac_inst[eNB_id].schedule_dlsch_preprocessor); // include rlc_data_req + MAC header gen
-	reset_meas(&eNB_mac_inst[eNB_id].schedule_dlsch); // include rlc_data_req + MAC header gen + pre-processor
-	reset_meas(&eNB_mac_inst[eNB_id].schedule_mch); // only embms 
-	reset_meas(&eNB_mac_inst[eNB_id].rx_ulsch_sdu); // include rlc_data_ind + mac header parser
-     
-	reset_meas(&eNB_pdcp_stats[eNB_id].pdcp_run);
-	reset_meas(&eNB_pdcp_stats[eNB_id].data_req);
-	reset_meas(&eNB_pdcp_stats[eNB_id].data_ind);
-	reset_meas(&eNB_pdcp_stats[eNB_id].apply_security);
-	reset_meas(&eNB_pdcp_stats[eNB_id].validate_security);
-	reset_meas(&eNB_pdcp_stats[eNB_id].pdcp_ip);
-	reset_meas(&eNB_pdcp_stats[eNB_id].ip_pdcp);
       
+    }
+    for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) {
+      
+      for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
+	  reset_meas(&eNB2UE[eNB_id][UE_id][0]->random_channel);
+	  reset_meas(&eNB2UE[eNB_id][UE_id][0]->interp_time);
+	  reset_meas(&eNB2UE[eNB_id][UE_id][0]->interp_freq);
+	  reset_meas(&eNB2UE[eNB_id][UE_id][0]->convolution);
+	  reset_meas(&UE2eNB[UE_id][eNB_id][0]->random_channel);
+	  reset_meas(&UE2eNB[UE_id][eNB_id][0]->interp_time);
+	  reset_meas(&UE2eNB[UE_id][eNB_id][0]->interp_freq);
+	  reset_meas(&UE2eNB[UE_id][eNB_id][0]->convolution);
       }
+
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->phy_proc);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->phy_proc_rx);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->phy_proc_tx);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->rx_prach);
+      
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ofdm_mod_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_encoding_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_modulation_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_scrambling_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_rate_matching_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_turbo_encoding_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->dlsch_interleaving_stats);
+      
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ofdm_demod_stats);
+      //reset_meas(&PHY_vars_eNB_g[eNB_id]->rx_dft_stats);
+      //reset_meas(&PHY_vars_eNB_g[eNB_id]->ulsch_channel_estimation_stats);
+      //reset_meas(&PHY_vars_eNB_g[eNB_id]->ulsch_freq_offset_estimation_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_decoding_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_demodulation_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_rate_unmatching_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_turbo_decoding_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_deinterleaving_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_demultiplexing_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_llr_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_init_stats);    
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_alpha_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_beta_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_gamma_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_ext_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl1_stats);
+      reset_meas(&PHY_vars_eNB_g[eNB_id][0]->ulsch_tc_intl2_stats);
+      
+      /* 
+       * L2 functions 
+       */
+      // eNB MAC
+      reset_meas(&eNB_mac_inst[eNB_id].eNB_scheduler); // total 
+      reset_meas(&eNB_mac_inst[eNB_id].schedule_si); // only schedule + tx
+      reset_meas(&eNB_mac_inst[eNB_id].schedule_ra); // only ra
+      reset_meas(&eNB_mac_inst[eNB_id].schedule_ulsch); // onlu ulsch
+      reset_meas(&eNB_mac_inst[eNB_id].fill_DLSCH_dci);// only dci
+      reset_meas(&eNB_mac_inst[eNB_id].schedule_dlsch_preprocessor); // include rlc_data_req + MAC header gen
+      reset_meas(&eNB_mac_inst[eNB_id].schedule_dlsch); // include rlc_data_req + MAC header gen + pre-processor
+      reset_meas(&eNB_mac_inst[eNB_id].schedule_mch); // only embms 
+      reset_meas(&eNB_mac_inst[eNB_id].rx_ulsch_sdu); // include rlc_data_ind + mac header parser
+      
+      reset_meas(&eNB_pdcp_stats[eNB_id].pdcp_run);
+      reset_meas(&eNB_pdcp_stats[eNB_id].data_req);
+      reset_meas(&eNB_pdcp_stats[eNB_id].data_ind);
+      reset_meas(&eNB_pdcp_stats[eNB_id].apply_security);
+      reset_meas(&eNB_pdcp_stats[eNB_id].validate_security);
+      reset_meas(&eNB_pdcp_stats[eNB_id].pdcp_ip);
+      reset_meas(&eNB_pdcp_stats[eNB_id].ip_pdcp);
+      
     }
   }
 
-  void print_opp_meas(void){
-    uint8_t eNB_id=0,UE_id=0;
+void print_opp_meas(void){
+  
+  uint8_t eNB_id=0,UE_id=0;
 
     print_meas(&oaisim_stats,"[OAI][total_exec_time]", &oaisim_stats,&oaisim_stats);
     print_meas(&oaisim_stats_f,"[OAI][SF_exec_time]", &oaisim_stats,&oaisim_stats_f);
diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c
index 2d8d67bccf61348c5147187090b8ae587b1cef3b..93fcfd8f7e3fb4793c6c4cda54025663af861f60 100644
--- a/targets/SIMU/USER/oaisim_config.c
+++ b/targets/SIMU/USER/oaisim_config.c
@@ -52,7 +52,7 @@
 #include "UTIL/OMG/grid.h"
 #include "UTIL/OTG/otg_tx.h"
 #include "UTIL/OTG/otg.h"
-#include "UTIL/OTG/otg_vars.h"
+#include "UTIL/OTG/otg_externs.h"
 #include "oml.h"
 #ifdef ENABLE_RAL
 #include "lteRALenb.h"
@@ -84,115 +84,7 @@ mapping omg_rwp_names[] =
   {"MAX_RWP_TYPES", MAX_RWP_TYPES},
   {NULL, -1}
 };
-mapping otg_multicast_app_type_names[] = {
-  {"no_predefined_multicast_traffic", 0},
-  {"mscbr", 1},
-  {"mmcbr", 2},
-  {"mbcbr", 3},
-  {"msvbr", 4},
-  {"mmvbr", 5},
-  {"mbvbr", 6},
-  {"mvideo_vbr_4mbps", 7},
-  {NULL, -1}
-}  ;
-
-mapping otg_app_type_names[] =
-{
-  {"no_predefined_traffic", 0},
-  {"m2m", 1},
-  {"scbr", 2},
-  {"mcbr", 3},
-  {"bcbr", 4},
-  {"auto_pilot", 5},
-  {"bicycle_race", 6},
-  {"open_arena", 7},
-  {"team_fortress", 8},
-  {"full_buffer", 9},
-  {"m2m_traffic", 10},
-  {"auto_pilot_l",11},
-  {"auto_pilot_m", 12},
-  {"auto_pilot_h", 13},
-  {"auto_pilot_e", 14},
-  {"virtual_game_l", 15},
-  {"virtual_game_m", 16},
-  {"virtual_game_h", 17},
-  {"virtual_game_f", 18},
-  {"alarm_humidity", 19},
-  {"alarm_smoke",20},
-  {"alarm_temperature", 21},
-  {"openarena_dl", 22},
-  {"openarena_ul", 23},
-  {"voip_g711", 24},
-  {"voip_g729", 25},
-  {"iqsim_mango", 26},
-  {"iqsim_newsteo", 27},
-  {"openarena_dl_tarma", 28},
-  {"video_vbr_10mbps", 29},
-  {"video_vbr_4mbps", 30},
-  {"video_vbr_2mbps", 31},
-  {"video_vbr_768kbps", 32},
-  {"video_vbr_384kbps", 33},
-  {"video_vbr_192kpbs", 34},
-  {"background_users", 35},
-  {NULL, -1}
-};
-
-mapping otg_transport_protocol_names[] =
-{
-    {"no_proto", 0},
-    {"udp", 1},
-    {"tcp", 2},
-    {NULL, -1}
-};
 
-mapping otg_ip_version_names[] =
-{
-    {"no_ip", 0},
-    {"ipv4", 1},
-    {"ipv6", 2},
-    {NULL, -1}
-};
-
-mapping otg_distribution_names[] =
-{
-    {"no_customized_traffic", 0},
-    {"uniform", 1},
-    {"gaussian", 2},
-    {"exponential", 3},
-    {"poisson", 4},
-    {"fixed", 5},
-    {"weibull", 6},
-    {"pareto", 7},
-    {"gamma", 8},
-    {"cauchy",9},
-    {"log_normal",10},
-    {"tarma",11},
-    {"video",12},
-    {"background_dist",13},
-    {NULL, -1}
-};
-mapping frame_type_names[] =
-{
-    {"TDD", 1},
-    {"FDD", 0},
-    {NULL, -1}
-};
-
-mapping switch_names[] =
-{
-    {"disable", 0},
-    {"enable", 1},
-    {NULL, -1}
-};
-
-mapping packet_gen_names[] =
-{
-    {"repeat_string", 0},
-    {"substract_string", 1},
-    {"random_position", 2},
-    {"random_string", 3},
-    {NULL, -1}
-};
 
 void init_oai_emulation(void) {
 
diff --git a/targets/SIMU/USER/oaisim_config.h b/targets/SIMU/USER/oaisim_config.h
index fc83ed0c486d7da8ed5fbaa4027bc25bc5ff32b1..01d4771b9ac860b7448da3f346a54e3dc32ab1ae 100644
--- a/targets/SIMU/USER/oaisim_config.h
+++ b/targets/SIMU/USER/oaisim_config.h
@@ -58,6 +58,8 @@ The current sturcture of oaisim is shown by the figure.
 #include "UTIL/OPT/opt.h" // to test OPT
 #include "UTIL/OMG/omg.h"
 #include "UTIL/CLI/cli_if.h"
+#include "PHY/defs.h"
+#include "PHY/extern.h"
 #include "SIMULATION/ETH_TRANSPORT/defs.h"
 #include "PHY/defs.h"
 
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 887551a0006147fa1e36e066cec40f9384e1a17f..c6c045a69963ce3f4fb7c4027f24046fb81e3f43 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -811,7 +811,18 @@ void init_openair1(void) {
 #endif
   // change the nb_connected_eNB
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
-    init_lte_vars (&frame_parms[CC_id], oai_emulation.info.frame_type[CC_id], oai_emulation.info.tdd_config[CC_id], oai_emulation.info.tdd_config_S[CC_id],oai_emulation.info.extended_prefix_flag[CC_id],oai_emulation.info.N_RB_DL[CC_id], Nid_cell, cooperation_flag, oai_emulation.info.transmission_mode[CC_id], abstraction_flag,nb_antennas_rx, oai_emulation.info.eMBMS_active_state);
+    init_lte_vars (&frame_parms[CC_id], 
+		   oai_emulation.info.frame_type[CC_id], 
+		   oai_emulation.info.tdd_config[CC_id], 
+		   oai_emulation.info.tdd_config_S[CC_id],
+		   oai_emulation.info.extended_prefix_flag[CC_id],
+		   oai_emulation.info.N_RB_DL[CC_id], 
+		   Nid_cell, 
+		   cooperation_flag, 
+		   oai_emulation.info.transmission_mode[CC_id], 
+		   abstraction_flag,
+		   nb_antennas_rx, 
+		   oai_emulation.info.eMBMS_active_state);
   }
 
   for (eNB_id=0; eNB_id<NB_eNB_INST;eNB_id++){
@@ -830,10 +841,11 @@ void init_openair1(void) {
       }
   }
 
-  printf ("AFTER init: Nid_cell %d\n", PHY_vars_eNB_g[0][0]->lte_frame_parms.Nid_cell);
-  printf ("AFTER init: frame_type %d,tdd_config %d\n",
-      PHY_vars_eNB_g[0][0]->lte_frame_parms.frame_type,
-      PHY_vars_eNB_g[0][0]->lte_frame_parms.tdd_config);
+   printf ("AFTER init: MAX_NUM_CCs %d, Nid_cell %d frame_type %d,tdd_config %d\n",
+	  MAX_NUM_CCs,
+	  PHY_vars_eNB_g[0][0]->lte_frame_parms.Nid_cell,
+	  PHY_vars_eNB_g[0][0]->lte_frame_parms.frame_type,
+	  PHY_vars_eNB_g[0][0]->lte_frame_parms.tdd_config);
 
   number_of_cards = 1;