diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
index 7ea9bacf34caa40538dec3b822d0baa152f05e88..f4e4e148fbefc946c5f07e4f647bfde80f190468 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
@@ -405,15 +405,14 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
                                &eNB->common_channels[CC_id].CCCH_pdu.payload[0],
                                rrc_sdu_length);
 
-#if defined(USER_MODE) && defined(OAI_EMU)
-                        if (oai_emulation.info.opt_enabled){
-                            trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0],
-                                      rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id),
-                                      eNB->subframe,0,0);
-                            LOG_D(OPT,"[eNB %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
-                                  module_idP, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length);
+                        if (opt_enabled==1){
+			  trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0],
+				    rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id),
+				    eNB->subframe,0,0);
+			  LOG_D(OPT,"[eNB %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
+				module_idP, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length);
                         }
-#endif
+
                         nprb[CC_id]= nprb[CC_id] + 3;
                         nCCE[CC_id] = nCCE[CC_id] + 4;
                     }
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
index ecd2ea4e29f202071aacc1e7c9ab49a4808f0c16..8b9be8faf91c156234b6f1fccf634603061f232f 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
@@ -148,8 +148,7 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi
 	}
       }
 
-#if defined(USER_MODE) && defined(OAI_EMU)
-      if (oai_emulation.info.opt_enabled) {
+      if (opt_enabled == 1) {
         trace_pdu(1,
                   &eNB->common_channels[CC_id].BCCH_pdu.payload[0],
                   bcch_sdu_length,
@@ -159,11 +158,10 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi
                   eNB->subframe,
                   0,
                   0);
-      }
-      LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n",
+	LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n",
 	    module_idP, frameP, 0xffff, bcch_sdu_length);
-#endif
-
+      }
+      
       if (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.frame_type == TDD) {
 	LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for SI %d bytes (mcs %d, rb 3, TBS %d)\n",
               frameP,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index eeb2200a8c026243192069eeded93285576efc2f..ce30a8de64310bdf4bfc58cd0705ac57d95d7093 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -991,16 +991,15 @@ void schedule_ue_spec(module_id_t   module_idP,
 	    UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff);
 	  //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff);
 	  
-#if defined(USER_MODE) && defined(OAI_EMU)
 	  /* Tracing of PDU is done on UE side */
-	  if (oai_emulation.info.opt_enabled)
+	  if (opt_enabled == 1){
 	    trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
 		      TBS, module_idP, 3, UE_RNTI(module_idP,UE_id),
 		      eNB->subframe,0,0);
-	  LOG_D(OPT,"[eNB %d][DLSCH] Frame %d  rnti %x  with size %d\n",
-		module_idP, frameP, UE_RNTI(module_idP,UE_id), TBS);
-#endif
-	  
+	    LOG_D(OPT,"[eNB %d][DLSCH] Frame %d  rnti %x  with size %d\n",
+		  module_idP, frameP, UE_RNTI(module_idP,UE_id), TBS);
+	  }
+	 	  
 	  aggregation = process_ue_cqi(module_idP,UE_id);
 	  nCCE[CC_id]-=(1<<aggregation); // adjust the remaining nCCE
 	  nCCE_used[CC_id]+=(1<<aggregation); // adjust the remaining nCCE
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c
index 87ab26da573dcba33c642ad5e23e20d239f2448d..487c5445fc7d8a343482be8b17599a8c9f2599e3 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c
@@ -534,15 +534,14 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
       for (j=0;j<(TBS-sdu_length_total-offset);j++)
         eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff);
 
-#if defined(USER_MODE) && defined(OAI_EMU)
       /* Tracing of PDU is done on UE side */
-      if (oai_emulation.info.opt_enabled)
+      if (opt_enabled ==1 ){
         trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload,
-            TBS, module_idP, 6, 0xffff,  // M_RNTI = 6 in wirehsark
-            eNB_mac_inst[module_idP].subframe,0,0);
-      LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n",
-          module_idP, frameP, TBS);
-#endif
+		  TBS, module_idP, 6, 0xffff,  // M_RNTI = 6 in wirehsark
+		  eNB_mac_inst[module_idP].subframe,0,0);
+	LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n",
+	      module_idP, frameP, TBS);
+      }
       /*
    for (j=0;j<sdu_length_total;j++)
       printf("%2x.",eNB_mac_inst[module_idP].MCH_pdu.payload[j+offset]);
diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c
index 4e4699a927e5d617e7ca37e6ac740cbc3bc830d9..cf07a3f40bf445e453f06e1e884ce2304a6f4238 100644
--- a/openair2/LAYER2/MAC/ra_procedures.c
+++ b/openair2/LAYER2/MAC/ra_procedures.c
@@ -211,14 +211,13 @@ void Msg1_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id
 
   // start contention resolution timer
   UE_mac_inst[module_idP].RA_attempt_number++;
-#if defined(USER_MODE) && defined(OAI_EMU)
-  if (oai_emulation.info.opt_enabled) {
+  if (opt_enabled == 1) {
       trace_pdu(0, NULL, 0, module_idP, 3, UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex,
           UE_mac_inst[module_idP].subframe, 0, UE_mac_inst[module_idP].RA_attempt_number);
       LOG_D(OPT,"[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x  with size %d\n",
           module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size);
   }
-#endif
+
 }
 
 
@@ -235,14 +234,14 @@ void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id
   UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0;
   UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1;
 
-#if defined(USER_MODE) && defined(OAI_EMU)
-  if (oai_emulation.info.opt_enabled) { // msg3
-      trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size,
-          module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0);
-      LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d   with size %d\n",
-          module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size);
+  // msg3
+  if (opt_enabled == 1 ) {
+    trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size,
+	      module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0);
+    LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d   with size %d\n",
+	  module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size);
   }
-#endif
+  
 }
 
 
diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c
index 3414c8633ef5b4236f6d26511634036fb5921315..4bffc92637fbb04d974a1f08b6b9095dcd5a807e 100644
--- a/openair2/LAYER2/MAC/rar_tools.c
+++ b/openair2/LAYER2/MAC/rar_tools.c
@@ -118,15 +118,14 @@ unsigned short fill_rar(module_id_t module_idP,
       rarh->RAPID,eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0].preamble_index,
       eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset);
 
-#if defined(USER_MODE) && defined(OAI_EMU)
-  if (oai_emulation.info.opt_enabled){
-      trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1,
-          eNB_mac_inst[module_idP].subframe, 0, 0);
-      LOG_I(OPT,"[eNB %d][RAPROC] RAR Frame %d trace pdu for rnti %x and  rapid %d size %d\n",
+  if (opt_enabled == 1){
+    trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1,
+	      eNB_mac_inst[module_idP].subframe, 0, 0);
+    LOG_D(OPT,"[eNB %d][RAPROC] RAR Frame %d trace pdu for rnti %x and  rapid %d size %d\n",
           module_idP, frameP, eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti,
           rarh->RAPID, input_buffer_length);
-  } 
-#endif 
+  }
+  
   return(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti);
 }
 
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 07a5db675d86d8119fab13eb22c22762a82c0ce3..785a892f10ec2f03e1aabb69dd94f082705c323c 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -293,12 +293,10 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *s
 
   LOG_T(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]);
 
-#if defined(USER_MODE) && defined(OAI_EMU)
-  if (oai_emulation.info.opt_enabled) {
-      trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti,
-          UE_mac_inst[module_idP].subframe, 0, 0);
+  if (opt_enabled == 1) {
+    trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti,
+	      UE_mac_inst[module_idP].subframe, 0, 0);
   }
-#endif
 
   payload_ptr = parse_header(sdu,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_len);
 
@@ -1298,12 +1296,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
   for (j=0;j<(buflen-sdu_length_total-payload_offset);j++)
     ulsch_buffer[payload_offset+sdu_length_total+j] = (char)(taus()&0xff);
 
-#if defined(USER_MODE) && defined(OAI_EMU)
-  if (oai_emulation.info.opt_enabled)
+  if (opt_enabled==1){
     trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, subframe, 0, 0);
-  LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x  with size %d\n",
+    
+    LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x  with size %d\n",
       module_idP, frameP, UE_mac_inst[module_idP].crnti, buflen);
-#endif
+  }
 
   LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n",
       module_idP,payload_offset, sdu_length_total);
diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h
index a054e40469a0356b6c6c4c75838e2b7f061740f5..8605a79d0ceea99c76e929164ae31c704d01ad99 100644
--- a/openair2/UTIL/OPT/opt.h
+++ b/openair2/UTIL/OPT/opt.h
@@ -77,6 +77,8 @@ typedef enum radio_type_e {
 } radio_type_t;
 
 extern trace_mode_t opt_type;
+extern char in_ip[40];
+extern char in_path[100];
 
 /**
  * function def
@@ -90,6 +92,7 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p);
 
 void terminate_opt(void);
 
+extern int opt_enabled;
 //double *timing_analyzer(int index, int direction );
 
 #endif /* OPT_H_ */
diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c
index 38fcaac387e20c096f0de46de09d21137faf4a1d..b4c09e74ad8cf67ad4f9bf2d3a962bd39ee65b3d 100644
--- a/openair2/UTIL/OPT/probe.c
+++ b/openair2/UTIL/OPT/probe.c
@@ -123,6 +123,8 @@ what about the implementation
 
 #include "opt.h"
 
+int opt_enabled=0;
+
 #define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999)
 
 typedef uint8_t  guint8;
@@ -139,8 +141,8 @@ static unsigned char g_frameBuffer[1600];
 //static unsigned char g_fileBuffer[1600];
 static unsigned int g_frameOffset;
 
-static char in_ip[40];
-static char in_path[100];
+char in_ip[40];
+char in_path[100];
 static uint16_t in_port;
 FILE *file_fd = NULL;
 
@@ -501,7 +503,7 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p)
         strncpy( in_path, path, sizeof(in_path) );
         in_path[sizeof(in_path) - 1] = 0; // terminate string
     } else {
-        strcpy( in_path, "oai_opt.pcap" );
+        strcpy( in_path, "/tmp/oai_opt.pcap" );
     }
     if (ip != NULL) {
         strncpy( in_ip, ip, sizeof(in_ip) );
@@ -553,9 +555,13 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p)
             opt_type = OPT_NONE;
             break;
     }
-    LOG_D(OPT,"mode %s init ip %s port %u path %s\n",
-          (opt_type == OPT_WIRESHARK)? "wireshark" : "pcap", in_ip, in_port, in_path);
-
+    if ( opt_type == OPT_WIRESHARK )
+      LOG_G(OPT,"mode Wireshark: ip %s port %d\n", in_ip, in_port);
+    else if (opt_type == OPT_PCAP)
+      LOG_G(OPT,"mode PCAB : path is %s \n",in_path);
+    else
+      LOG_G(OPT,"Unsupported or unknown mode %d \n", opt_type);
+    
     //  mac_info = (mac_info*)malloc16(sizeof(mac_lte_info));
     // memset(mac_info, 0, sizeof(mac_lte_info)+pdu_buffer_size + 8);
     return (1);
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index bf2a5cf90a922586cc17433c56bdb276762e7fc3..1eb679c2654886574b9041cc753d70d5f4a9b7f9 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -335,6 +335,9 @@ int16_t           pdcp_log_level     = LOG_INFO;
 int16_t           pdcp_log_verbosity = LOG_MED;
 int16_t           rrc_log_level      = LOG_INFO;
 int16_t           rrc_log_verbosity  = LOG_MED;
+int16_t           opt_log_level      = LOG_INFO;
+int16_t           opt_log_verbosity  = LOG_MED;
+
 # if defined(ENABLE_USE_MME)
 int16_t           gtpu_log_level     = LOG_DEBUG;
 int16_t           gtpu_log_verbosity = LOG_MED;
@@ -1802,7 +1805,7 @@ static void get_options (int argc, char **argv) {
     {"ue_rxgain",   required_argument,  NULL, LONG_OPTION_RXGAIN},
     {NULL, 0, NULL, 0}};
   
-  while ((c = getopt_long (argc, argv, "C:dK:g:F:G:qO:m:SUVRM:r:P:s:t:x:",long_options,NULL)) != -1) {
+  while ((c = getopt_long (argc, argv, "C:dK:g:F:G:qO:m:SUVRM:r:P:Ws:t:x:",long_options,NULL)) != -1) {
     switch (c) {
     case LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS:
       ULSCH_max_consecutive_errors = atoi(optarg);
@@ -1884,23 +1887,35 @@ static void get_options (int argc, char **argv) {
       target_ul_mcs = atoi (optarg);
       break;
 #ifdef OPENAIR2
+    case 'W':
+      opt_enabled=1;
+      opt_type = OPT_WIRESHARK;
+      strncpy(in_ip, "127.0.0.1", sizeof(in_ip));
+      in_ip[sizeof(in_ip) - 1] = 0; // terminate string
+      printf("Enabling OPT for wireshark for local interface");
+      /*
+	if (optarg == NULL){
+	in_ip[0] =NULL;
+	printf("Enabling OPT for wireshark for local interface");
+      } else {
+	strncpy(in_ip, optarg, sizeof(in_ip));
+	in_ip[sizeof(in_ip) - 1] = 0; // terminate string
+	printf("Enabling OPT for wireshark with %s \n",in_ip);
+      }
+      */
+      break;
     case 'P':
-#ifdef OPENAIR2
-      /* 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");
+      opt_type = OPT_PCAP;
+      opt_enabled=1;
+      if (optarg == NULL){
+	strncpy(in_path, "/tmp/oai_opt.pcap", sizeof(in_path));
+	in_path[sizeof(in_path) - 1] = 0; // terminate string
+	printf("Enabling OPT for PCAP with the following path /tmp/oai_opt.pcap");
       } else {
-	opt_type = OPT_NONE;
-	printf("Unrecognized option for OPT module\n");
-	printf("Possible values are either wireshark or pcap\n");
+	strncpy(in_path, optarg, sizeof(in_path));
+	in_path[sizeof(in_path) - 1] = 0; // terminate string
+	printf("Enabling OPT for PCAP  with the following file %s \n",in_path);
       }
-#endif
       break;  
 #endif
     case 'V':
@@ -2202,6 +2217,8 @@ int main(int argc, char **argv) {
       set_comp_log(HW,      hw_log_level, hw_log_verbosity, 1);
 #ifdef OPENAIR2
       set_comp_log(PHY,     phy_log_level,   phy_log_verbosity, 1);
+      if (opt_enabled == 1 ) 
+	set_comp_log(OPT,   opt_log_level,      opt_log_verbosity, 1);
 #else
       set_comp_log(PHY,     LOG_INFO,   LOG_HIGH, 1);
 #endif
@@ -2242,17 +2259,6 @@ int main(int argc, char **argv) {
   
   if (opp_enabled ==1)
     reset_opp_meas();
-#ifdef OPENAIR2
-  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");
-  }
-#endif
   
 #if defined(ENABLE_ITTI)
   if (UE_flag == 1) {
@@ -2264,7 +2270,17 @@ int main(int argc, char **argv) {
 
   itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
 #endif
-
+#ifdef OPENAIR2
+  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(in_path, in_ip, NULL, radio_type) == -1)
+      LOG_E(OPT,"failed to run OPT \n");
+  }
+#endif
 #ifdef NAS_NETLINK
   netlink_init();
 #endif
@@ -2991,7 +3007,7 @@ int main(int argc, char **argv) {
     vcd_signal_dumper_close();
 
 #ifdef OPENAIR2
-  if (opt_type != OPT_NONE)
+  if (opt_enabled == 1)
     terminate_opt();
 #endif
 
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 2cefa82e5032de881f87dbdb494a169623549afb..19efd1bfd3d88d184847dd4ad8d9cd3082f15df1 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -1785,7 +1785,7 @@ oai_shutdown (void) {
         ShaF = 0;
     }
 
-    if ((oai_emulation.info.opt_enabled == 1))
+    if (opt_enabled == 1)
         terminate_opt ();
 
     if (oai_emulation.info.cli_enabled)
diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c
index 747519c56d42cd35ef35db78b82bce2f5a062404..a0bc38fff954caee2e0f463c3a20d94c3d5374fd 100644
--- a/targets/SIMU/USER/oaisim_config.c
+++ b/targets/SIMU/USER/oaisim_config.c
@@ -1168,7 +1168,7 @@ int ocg_config_emu(void){
   oai_emulation.info.opt_enabled = ( oai_emulation.emulation_config.packet_trace.enabled == 0) ? oai_emulation.info.opt_enabled :  oai_emulation.emulation_config.packet_trace.enabled;
   if (oai_emulation.info.opt_enabled == 1) {
     radio_type_t radio_type;
-
+    opt_enabled = 1;
     if (oai_emulation.info.frame_type[0] == FDD) {
         radio_type = RADIO_TYPE_FDD;
     } else {
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index eb1cbc8e6bdd54caf827dc41d3cf6baf89d064dc..9d2ad318b98d31c8bc02e222c018fd47c3055093 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -527,7 +527,7 @@ void get_simulation_options(int argc, char *argv[]) {
 
       case 'P':
         oai_emulation.info.opt_enabled = 1;
-
+	opt_enabled = 1;
         if (strcmp(optarg, "wireshark") == 0) {
             opt_type = OPT_WIRESHARK;
             printf("Enabling OPT for wireshark\n");
@@ -539,6 +539,7 @@ void get_simulation_options(int argc, char *argv[]) {
             printf("Possible values are either wireshark or pcap\n");
             opt_type = OPT_NONE;
             oai_emulation.info.opt_enabled = 0;
+	    opt_enabled = 0;
         }
         oai_emulation.info.opt_mode = opt_type;
         break;
diff --git a/targets/SIMU/USER/oaisim_pad.c b/targets/SIMU/USER/oaisim_pad.c
index f6c0aaa787e11b1ba8b72d4ed1e7f4576a52000a..c6120f8b7bb5d4e68ecb3061a6b26c17119c9498 100644
--- a/targets/SIMU/USER/oaisim_pad.c
+++ b/targets/SIMU/USER/oaisim_pad.c
@@ -998,7 +998,7 @@ void run(int argc, char *argv[]) {
   if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0) && (ShaF != NULL))
     destroyMat(ShaF,map1, map2);
 
-  if ((oai_emulation.info.opt_enabled == 1) )
+  if (opt_enabled == 1 )
     terminate_opt();
 
   if (oai_emulation.info.cli_enabled)