From c76b846bebf524a4eefc38f4d82be7b83db6ce0b Mon Sep 17 00:00:00 2001
From: Navid Nikaein <navid.nikaein@eurecom.fr>
Date: Mon, 12 Jan 2015 23:54:15 +0000
Subject: [PATCH] * fix few bugs in oaisim and UL scheduling * update the CBA
 operation (non standard feature) * update OTG * add a set of templates for
 different combination of packet sizes and inter-departure time

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6351 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair1/PHY/LTE_TRANSPORT/dci_tools.c        |  22 +-
 openair1/PHY/LTE_TRANSPORT/proto.h            |   4 +-
 openair1/PHY/LTE_TRANSPORT/rar_tools.c        |   2 +-
 openair1/PHY/LTE_TRANSPORT/uci.h              |  26 +-
 openair1/PHY/LTE_TRANSPORT/uci_tools.c        | 144 +++++++-
 openair1/PHY/LTE_TRANSPORT/ulsch_coding.c     |   6 +-
 openair1/PHY/impl_defs_top.h                  |   2 +
 openair1/SCHED/defs.h                         |   3 -
 openair1/SCHED/phy_procedures_lte_common.c    |   6 +-
 openair1/SCHED/phy_procedures_lte_eNb.c       |  34 +-
 openair1/SCHED/phy_procedures_lte_ue.c        | 105 +++---
 openair2/COMMON/platform_constants.h          |   2 +-
 openair2/LAYER2/MAC/config.c                  |  14 +-
 openair2/LAYER2/MAC/defs.h                    |  80 ++--
 openair2/LAYER2/MAC/eNB_scheduler.c           |  10 +-
 openair2/LAYER2/MAC/eNB_scheduler_dlsch.c     |   2 +-
 .../LAYER2/MAC/eNB_scheduler_primitives.c     |  10 +-
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c     | 342 +++++++++++++-----
 openair2/LAYER2/MAC/pre_processor.c           |  47 ++-
 openair2/LAYER2/MAC/proto.h                   |  10 +-
 openair2/LAYER2/MAC/ue_procedures.c           | 154 ++++++--
 openair2/PHY_INTERFACE/defs.h                 |   5 +-
 openair2/RRC/LITE/defs.h                      |  23 ++
 openair2/RRC/LITE/rrc_eNB.c                   |   4 +
 openair2/UTIL/LOG/log.c                       |   4 +-
 openair2/UTIL/MATH/oml.c                      |   3 +-
 openair2/UTIL/OCG/OCG.h                       |   1 +
 openair2/UTIL/OTG/OTGplot                     |   2 +-
 openair2/UTIL/OTG/otg_kpi.c                   |  30 +-
 openair2/UTIL/OTG/otg_rx.c                    |  10 +-
 openair2/UTIL/OTG/otg_tx.c                    |   6 +-
 targets/RT/USER/lte-softmodem.c               |   2 +-
 .../SIMU/EXAMPLES/OSD/WEBXML/template_0.xml   |   6 +-
 .../SIMU/EXAMPLES/OSD/WEBXML/template_11.xml  |   6 +-
 .../SIMU/EXAMPLES/OSD/WEBXML/template_120.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_121.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_122.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_123.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_124.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_125.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_126.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_127.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_128.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_129.xml | 105 ++++++
 .../SIMU/EXAMPLES/OSD/WEBXML/template_22.xml  |  49 ++-
 .../SIMU/EXAMPLES/OSD/WEBXML/template_26.xml  |   8 +-
 .../SIMU/EXAMPLES/OSD/WEBXML/template_60.xml  |   8 +-
 targets/SIMU/USER/Makefile                    |   5 +-
 targets/SIMU/USER/oaisim_config.c             |  92 +++--
 targets/SIMU/USER/oaisim_config.h             |   2 +
 targets/SIMU/USER/oaisim_functions.c          | 105 +++---
 51 files changed, 2016 insertions(+), 430 deletions(-)
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_120.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_121.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_122.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_123.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_124.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_125.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_126.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_127.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_128.xml
 create mode 100644 targets/SIMU/EXAMPLES/OSD/WEBXML/template_129.xml

diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index 36fa86b77f9..8c29ce36506 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -5126,7 +5126,7 @@ uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t trans_mo
   return(cqivect);
 }
 
-void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,int N_RB_DL,uint16_t rnti, uint8_t trans_mode, double sinr_eff) {
+void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t harq_pid,int N_RB_DL,uint16_t rnti, uint8_t trans_mode, double sinr_eff) {
   
   //  msg("[PHY][UE] Filling CQI for eNB %d, meas->wideband_cqi_tot[%d] %d\n",
   //      eNB_id,eNB_id,meas->wideband_cqi_tot[eNB_id]);
@@ -5141,7 +5141,7 @@ void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,int N_
 
 
 
-  //LOG_I(PHY,"Filling CQI %f for eNB %d\n",sinr_tmp,eNB_id);
+  //LOG_I(PHY,"[UE][UCI] Filling CQI format %d for eNB %d N_RB_DL %d\n",uci_format,eNB_id,N_RB_DL);
 
   switch (N_RB_DL) {
 
@@ -5175,9 +5175,9 @@ void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,int N_
       break;
     case HLC_subband_cqi_mcs_CBA:
       // this is the cba mcs uci for cba transmission 
-      ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs     = 2; //fixme
+      ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs     = ulsch->harq_processes[harq_pid]->mcs;
       ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti  = rnti;
-      LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, 2);
+      LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs);
       break;
     case ue_selected:
       LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n");
@@ -5220,9 +5220,9 @@ void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,int N_
       break;
     case HLC_subband_cqi_mcs_CBA:
       // this is the cba mcs uci for cba transmission 
-      ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs     = 2; //fixme
+      ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs     = ulsch->harq_processes[harq_pid]->mcs;
       ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti  = rnti;
-      LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, 2);
+      LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs);
       break;
     case ue_selected:
       LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n");
@@ -5265,9 +5265,9 @@ void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,int N_
       break;
     case HLC_subband_cqi_mcs_CBA:
       // this is the cba mcs uci for cba transmission 
-      ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs     = 2; //fixme
+      ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs     = ulsch->harq_processes[harq_pid]->mcs; 
       ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti  = rnti;
-      LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, 2);
+      LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs);
       break;
     case ue_selected:
       LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n");
@@ -5310,9 +5310,9 @@ void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,int N_
       break;
     case HLC_subband_cqi_mcs_CBA:
       // this is the cba mcs uci for cba transmission 
-      ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs     = 2; //fixme
+      ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs     = ulsch->harq_processes[harq_pid]->mcs; 
       ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti  = rnti;
-      LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, 2);
+      LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs);
       break;
     case ue_selected:
       LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n");
@@ -5526,7 +5526,7 @@ int generate_ue_ulsch_params_from_dci(void *dci_pdu,
 
     // indicate that this process is to be serviced in subframe n+4
     if ((rnti >= cba_rnti) && (rnti < p_rnti))
-      ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1;
+      ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1; //+=1 this indicates the number of dci / cba group: not supported in the data struct
     else 
       ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1;
     
diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h
index b0ea8e08d56..e60b6abfe86 100644
--- a/openair1/PHY/LTE_TRANSPORT/proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/proto.h
@@ -1555,9 +1555,9 @@ uint8_t phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,u
 
 void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL);
 
-void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats,uint16_t * crnti, uint8_t * access_mode);
+void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats,uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode);
 
-void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id, int N_RB_DL, rnti_t rnti, uint8_t trans_mode,double sinr_eff);
+void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id, uint8_t harq_pid,int N_RB_DL, rnti_t rnti, uint8_t trans_mode,double sinr_eff);
 void reset_cba_uci(void *o);
 
 uint16_t quantize_subband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,int nb_subbands);
diff --git a/openair1/PHY/LTE_TRANSPORT/rar_tools.c b/openair1/PHY/LTE_TRANSPORT/rar_tools.c
index ab566536f23..8baf11497a1 100644
--- a/openair1/PHY/LTE_TRANSPORT/rar_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/rar_tools.c
@@ -264,7 +264,7 @@ int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *phy_vars_ue,
     else
       sinr_eff = meas->wideband_cqi_avg[eNB_id];
     */
-    fill_CQI(ulsch,meas,eNB_id,phy_vars_ue->lte_frame_parms.N_RB_DL,0, transmission_mode,phy_vars_ue->sinr_eff);
+    fill_CQI(ulsch,meas,eNB_id,0,phy_vars_ue->lte_frame_parms.N_RB_DL,0, transmission_mode,phy_vars_ue->sinr_eff);
 
     if (((phy_vars_ue->frame_tx % 100) == 0) || (phy_vars_ue->frame_tx < 10)) 
       print_CQI(ulsch->o,ulsch->uci_format,eNB_id,phy_vars_ue->lte_frame_parms.N_RB_DL);
diff --git a/openair1/PHY/LTE_TRANSPORT/uci.h b/openair1/PHY/LTE_TRANSPORT/uci.h
index 3ed37347239..6b191a6cadc 100644
--- a/openair1/PHY/LTE_TRANSPORT/uci.h
+++ b/openair1/PHY/LTE_TRANSPORT/uci.h
@@ -38,7 +38,7 @@ typedef enum {
   HLC_subband_cqi_rank1_2A, //HLC_subband_cqi_rank1_2A,
   HLC_subband_cqi_rank2_2A, //HLC_subband_cqi_rank2_2A,
   HLC_subband_cqi_modes123, //HLC_subband_cqi_modes123
-  HLC_subband_cqi_mcs_CBA,
+  HLC_subband_cqi_mcs_CBA, // MCS and RNTI, for contention-based acces
   unknown_cqi// 
 } UCI_format_t;
 
@@ -91,11 +91,11 @@ typedef struct __attribute__((packed)) {
 #define sizeof_HLC_subband_cqi_modes123_1_5MHz 16
 
 typedef struct __attribute__((packed)) { 
-  uint32_t padding:12;
+  uint32_t padding:11;
   uint32_t crnti:16;   
-  uint32_t mcs:4;
+  uint32_t mcs:5;
 } HLC_subband_cqi_mcs_CBA_1_5MHz;
-#define sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz 20
+#define sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz 21
 
 
 // **********************************************5 MHz***************************************************************************
@@ -147,11 +147,11 @@ typedef struct __attribute__((packed)) {
 #define sizeof_HLC_subband_cqi_modes123_5MHz 18
 
 typedef struct __attribute__((packed)) { 
-  uint32_t padding:12;
+  uint32_t padding:11;
   uint32_t crnti:16;   
-  uint32_t mcs:4;
+  uint32_t mcs:5;
 } HLC_subband_cqi_mcs_CBA_5MHz;
-#define sizeof_HLC_subband_cqi_mcs_CBA_5MHz 20
+#define sizeof_HLC_subband_cqi_mcs_CBA_5MHz 21
 
 // **********************************************10 MHz***************************************************************************
 typedef struct __attribute__((packed)) {
@@ -202,11 +202,11 @@ typedef struct __attribute__((packed)) {
 #define sizeof_HLC_subband_cqi_modes123_10MHz 22
 
 typedef struct __attribute__((packed)) { 
-  uint32_t padding:12;
+  uint32_t padding:11;
   uint32_t crnti:16;   
-  uint32_t mcs:4;
+  uint32_t mcs:5;
 } HLC_subband_cqi_mcs_CBA_10MHz;
-#define sizeof_HLC_subband_cqi_mcs_CBA_10MHz 20
+#define sizeof_HLC_subband_cqi_mcs_CBA_10MHz 21
 
 // **********************************************20 MHz***************************************************************************
 typedef struct __attribute__((packed)) {
@@ -257,11 +257,11 @@ typedef struct __attribute__((packed)) {
 #define sizeof_HLC_subband_cqi_modes123_20MHz 30
 
 typedef struct __attribute__((packed)) { 
-  uint32_t padding:12;
+  uint32_t padding:11;
   uint32_t crnti:16;   
-  uint32_t mcs:4;
+  uint32_t mcs:5;
 } HLC_subband_cqi_mcs_CBA_20MHz;
-#define sizeof_HLC_subband_cqi_mcs_CBA_20MHz 20
+#define sizeof_HLC_subband_cqi_mcs_CBA_20MHz 21
 
 
 #define MAX_CQI_PAYLOAD (sizeof(HLC_subband_cqi_rank2_2A_20MHz)*8*20)
diff --git a/openair1/PHY/LTE_TRANSPORT/uci_tools.c b/openair1/PHY/LTE_TRANSPORT/uci_tools.c
index 9530a956d1a..b7928324cf5 100644
--- a/openair1/PHY/LTE_TRANSPORT/uci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/uci_tools.c
@@ -44,7 +44,8 @@
 #ifdef DEBUG_UCI_TOOLS
 #include "PHY/vars.h"
 #endif
-//#define DEBUG_UCI
+
+//#define DEBUG_UCI 1
 
 uint64_t pmi2hex_2Ar1(uint32_t pmi) {
 
@@ -159,13 +160,13 @@ void do_diff_cqi(uint8_t N_RB_DL,
   }
 }
 
-void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats, uint16_t * crnti, uint8_t * access_mode) {
+void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats, uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode) {
 
   //unsigned char rank;
   //UCI_format fmt;
-  uint8_t N_RB_DL = 25;
-  
-  *access_mode=SCHEDULED_ACCESS;
+  //uint8_t N_RB_DL = 25;
+  LOG_D(PHY,"[eNB][UCI] N_RB_DL %d uci format %d\n", N_RB_DL,uci_format);
+
   switch(N_RB_DL) {
   case 6:
     switch(uci_format){
@@ -211,18 +212,16 @@ void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats, uint16
     case HLC_subband_cqi_mcs_CBA:
       if ((*crnti == ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti) && (*crnti !=0)){
 	*access_mode=CBA_ACCESS;
-	LOG_D(PHY,"[eNB] UCI for CBA : mcs %d  crnti %x\n", 
+	LOG_N(PHY,"[eNB] UCI for CBA : mcs %d  crnti %x\n", 
 	      ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs, ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti);
       } else {
-	*access_mode=UNKNOWN_ACCESS;
-	LOG_N(PHY,"[eNB] UCI for CBA : rnti (enb context %x, rx uci %x) invalid, unknown access\n",
+	LOG_D(PHY,"[eNB] UCI for CBA : rnti (enb context %x, rx uci %x) invalid, unknown access\n",
 	      *crnti, ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti);
       }
       break;
     case unknown_cqi:
     default:
-      LOG_N(PHY,"[eNB][UCI] received unknown uci \n");
-      *access_mode=UNKNOWN_ACCESS;
+      LOG_N(PHY,"[eNB][UCI] received unknown uci (rb %d)\n",N_RB_DL);
       break;
     }
     break;
@@ -271,27 +270,136 @@ void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats, uint16
     case HLC_subband_cqi_mcs_CBA:
       if ((*crnti == ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti) && (*crnti !=0)){
 	*access_mode=CBA_ACCESS;
-	LOG_D(PHY,"[eNB] UCI for CBA : mcs %d  crnti %x\n", 
+	LOG_N(PHY,"[eNB] UCI for CBA : mcs %d  crnti %x\n", 
 	      ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs, ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti);
       } else {
-	*access_mode=UNKNOWN_ACCESS;
-	LOG_N(PHY,"[eNB] UCI for CBA : rnti (enb context %x, rx uci %x) invalid, unknown access\n",
+	LOG_D(PHY,"[eNB] UCI for CBA : rnti (enb context %x, rx uci %x) invalid, unknown access\n",
 	      *crnti, ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti);
       }
       break;
     case unknown_cqi:
     default:
-      LOG_N(PHY,"[eNB][UCI] received unknown uci \n");
-      *access_mode=UNKNOWN_ACCESS;
+      LOG_N(PHY,"[eNB][UCI] received unknown uci (rb %d)\n",N_RB_DL);
       break;
     }
     break;
   case 50:
-
+    switch(uci_format){
+    case wideband_cqi_rank1_2A:
+      stats->DL_cqi[0]     = (((wideband_cqi_rank1_2A_10MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;
+      stats->DL_pmi_single = ((wideband_cqi_rank1_2A_10MHz *)o)->pmi;   
+      break;
+    case wideband_cqi_rank2_2A:
+      stats->DL_cqi[0]     = (((wideband_cqi_rank2_2A_10MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;      
+      stats->DL_cqi[1]     = (((wideband_cqi_rank2_2A_10MHz *)o)->cqi2);
+      if (stats->DL_cqi[1] > 24)
+	stats->DL_cqi[1] = 24;      
+      stats->DL_pmi_dual   = ((wideband_cqi_rank2_2A_10MHz *)o)->pmi; 
+      break;
+    case HLC_subband_cqi_nopmi:
+      stats->DL_cqi[0]     = (((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;      
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1);
+      break;
+    case HLC_subband_cqi_rank1_2A:
+      stats->DL_cqi[0]     = (((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;     
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1));      
+      stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi;    
+      break;
+    case HLC_subband_cqi_rank2_2A:
+      stats->DL_cqi[0]     = (((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;      
+      stats->DL_cqi[1]     = (((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2);
+      if (stats->DL_cqi[1] > 24)
+	stats->DL_cqi[1] = 24;      
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1));      
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2));      
+      stats->DL_pmi_dual   = ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi; 
+      break;
+    case HLC_subband_cqi_mcs_CBA:
+      if ((*crnti == ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti) && (*crnti !=0)){
+	*access_mode=CBA_ACCESS;
+	LOG_N(PHY,"[eNB] UCI for CBA : mcs %d  crnti %x\n", 
+	      ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs, ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti);
+      } else {
+	LOG_D(PHY,"[eNB] UCI for CBA : rnti (enb context %x, rx uci %x) invalid, unknown access\n",
+	      *crnti, ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti);
+      }
+      break;
+    case unknown_cqi:
+    default:
+      LOG_N(PHY,"[eNB][UCI] received unknown uci (RB %d)\n",N_RB_DL);
+      break;
+    }
     break;
-
+   
   case 100:
-    
+    switch(uci_format){
+    case wideband_cqi_rank1_2A:
+      stats->DL_cqi[0]     = (((wideband_cqi_rank1_2A_20MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;
+      stats->DL_pmi_single = ((wideband_cqi_rank1_2A_20MHz *)o)->pmi;   
+      break;
+    case wideband_cqi_rank2_2A:
+      stats->DL_cqi[0]     = (((wideband_cqi_rank2_2A_20MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;      
+      stats->DL_cqi[1]     = (((wideband_cqi_rank2_2A_20MHz *)o)->cqi2);
+      if (stats->DL_cqi[1] > 24)
+	stats->DL_cqi[1] = 24;      
+      stats->DL_pmi_dual   = ((wideband_cqi_rank2_2A_20MHz *)o)->pmi; 
+      break;
+    case HLC_subband_cqi_nopmi:
+      stats->DL_cqi[0]     = (((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;      
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1);
+      break;
+    case HLC_subband_cqi_rank1_2A:
+      stats->DL_cqi[0]     = (((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;     
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1));      
+      stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi;    
+      break;
+    case HLC_subband_cqi_rank2_2A:
+      stats->DL_cqi[0]     = (((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1);
+      if (stats->DL_cqi[0] > 24)
+	stats->DL_cqi[0] = 24;      
+      stats->DL_cqi[1]     = (((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2);
+      if (stats->DL_cqi[1] > 24)
+	stats->DL_cqi[1] = 24;      
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1));      
+      do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2));      
+      stats->DL_pmi_dual   = ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi; 
+      break;
+    case HLC_subband_cqi_mcs_CBA:
+      if ((*crnti == ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti) && (*crnti !=0)){
+	*access_mode=CBA_ACCESS;
+	LOG_N(PHY,"[eNB] UCI for CBA : mcs %d  crnti %x\n", 
+	      ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs, ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti);
+      } else {
+	LOG_D(PHY,"[eNB] UCI for CBA : rnti (enb context %x, rx uci %x) invalid, unknown access\n",
+	      *crnti, ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti);
+      }
+      break;
+    case unknown_cqi:
+    default:
+      LOG_N(PHY,"[eNB][UCI] received unknown uci (RB %d)\n",N_RB_DL);
+      break;
+    }
+    break;
+  default:
+    LOG_N(PHY,"[eNB][UCI] unknown RB %d\n",N_RB_DL);
     break;
   }
 
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c
index 02066e61849..824d8b9714a 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c
@@ -256,7 +256,7 @@ uint32_t ulsch_encoding(uint8_t *a,
       sinr_eff = 0;
     */
     rnti = phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->crnti;
-    fill_CQI(ulsch,meas,0,phy_vars_ue->lte_frame_parms.N_RB_DL,rnti, tmode,phy_vars_ue->sinr_eff);
+    fill_CQI(ulsch,meas,0,harq_pid,phy_vars_ue->lte_frame_parms.N_RB_DL,rnti, tmode,phy_vars_ue->sinr_eff);
    
     LOG_D(PHY,"UE CQI\n");
     print_CQI(ulsch->o,ulsch->uci_format,0,phy_vars_ue->lte_frame_parms.N_RB_DL);
@@ -884,7 +884,7 @@ int ulsch_encoding_emul(uint8_t *ulsch_buffer,
 			uint8_t harq_pid,
 			uint8_t control_only_flag) {
 
-  LTE_UE_ULSCH_t *ulsch = phy_vars_ue->ulsch_ue[eNB_id];
+  LTE_UE_ULSCH_t *ulsch = phy_vars_ue->ulsch_ue[eNB_id]; 
   LTE_UE_DLSCH_t **dlsch = phy_vars_ue->dlsch_ue[eNB_id];
   PHY_MEASUREMENTS *meas = &phy_vars_ue->PHY_measurements;
   uint8_t tmode = phy_vars_ue->transmission_mode[eNB_id];
@@ -901,7 +901,7 @@ int ulsch_encoding_emul(uint8_t *ulsch_buffer,
       sinr_eff = meas->wideband_cqi_avg[eNB_id];
     */
    
-    fill_CQI(ulsch,meas,eNB_id,phy_vars_ue->lte_frame_parms.N_RB_DL,rnti,tmode,phy_vars_ue->sinr_eff);
+    fill_CQI(ulsch,meas,eNB_id,harq_pid,phy_vars_ue->lte_frame_parms.N_RB_DL,rnti,tmode,phy_vars_ue->sinr_eff);
        //LOG_D(PHY,"UE CQI\n");
     //    print_CQI(ulsch->o,ulsch->uci_format,eNB_id);
 
diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h
index 66857b9dc13..43695d4693e 100755
--- a/openair1/PHY/impl_defs_top.h
+++ b/openair1/PHY/impl_defs_top.h
@@ -323,10 +323,12 @@ typedef struct {
 #define NUMBER_OF_HARQ_PID_MAX 8
 
 #if defined(CBMIMO1) || defined(EXMIMO)
+#define MAX_FRAME_NUMBER 0x400
 #define NUMBER_OF_eNB_MAX 1
 #define NUMBER_OF_UE_MAX 2
 #define NUMBER_OF_CONNECTED_eNB_MAX 3
 #else
+#define MAX_FRAME_NUMBER 0xFFFF
 #ifdef LARGE_SCALE
 #define NUMBER_OF_eNB_MAX 2
 #define NUMBER_OF_UE_MAX 120
diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h
index 3fded06fceb..813c8d86c60 100644
--- a/openair1/SCHED/defs.h
+++ b/openair1/SCHED/defs.h
@@ -50,9 +50,6 @@ enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0,
 #define OPENAIR_THREAD_STACK_SIZE    8192 //4096 //RTL_PTHREAD_STACK_MIN*6
 //#define DLC_THREAD_STACK_SIZE        4096 //DLC stack size
 
-
-
-
 enum openair_SCHED_STATUS {
       openair_SCHED_STOPPED=1,
       openair_SCHED_STARTING,
diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c
index b40926dc99b..d603f06bdb3 100755
--- a/openair1/SCHED/phy_procedures_lte_common.c
+++ b/openair1/SCHED/phy_procedures_lte_common.c
@@ -376,7 +376,7 @@ uint8_t get_ack(LTE_DL_FRAME_PARMS *frame_parms,
 	else if (harq_ack[6].send_harq_status == 1)
 	  o_ACK[0] = harq_ack[6].ack;
 	status = harq_ack[5].send_harq_status + (harq_ack[6].send_harq_status<<1);
-	printf("Subframe 2, TDD config 3: harq_ack[5] = %d (%d),harq_ack[6] = %d (%d)\n",harq_ack[5].ack,harq_ack[5].send_harq_status,harq_ack[6].ack,harq_ack[6].send_harq_status);
+	//printf("Subframe 2, TDD config 3: harq_ack[5] = %d (%d),harq_ack[6] = %d (%d)\n",harq_ack[5].ack,harq_ack[5].send_harq_status,harq_ack[6].ack,harq_ack[6].send_harq_status);
       }
       else if (subframe == 3) {   // ACK subframes 7 and 8
 	if (harq_ack[7].send_harq_status == 1) {
@@ -388,7 +388,7 @@ uint8_t get_ack(LTE_DL_FRAME_PARMS *frame_parms,
 	  o_ACK[0] = harq_ack[8].ack;
 
 	status = harq_ack[7].send_harq_status + (harq_ack[8].send_harq_status<<1);
-	printf("Subframe 3, TDD config 3: harq_ack[7] = %d,harq_ack[8] = %d\n",harq_ack[7].ack,harq_ack[8].ack);
+	//printf("Subframe 3, TDD config 3: harq_ack[7] = %d,harq_ack[8] = %d\n",harq_ack[7].ack,harq_ack[8].ack);
 	//printf("status %d : o_ACK (%d,%d)\n", status,o_ACK[0],o_ACK[1]);
       }
       else if (subframe == 4) {  // ACK subframes 9 and 0
@@ -401,7 +401,7 @@ uint8_t get_ack(LTE_DL_FRAME_PARMS *frame_parms,
 	  o_ACK[0] = harq_ack[8].ack;
 
 	status = harq_ack[9].send_harq_status + (harq_ack[0].send_harq_status<<1);
-	printf("Subframe 4, TDD config 3: harq_ack[9] = %d,harq_ack[0] = %d\n",harq_ack[9].ack,harq_ack[0].ack);
+	//printf("Subframe 4, TDD config 3: harq_ack[9] = %d,harq_ack[0] = %d\n",harq_ack[9].ack,harq_ack[0].ack);
       }
       else {
 	LOG_E(PHY,"phy_procedures_lte.c: get_ack, illegal subframe %d for tdd_config %d\n",
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index a9ea37c7f91..e4650ce253e 100755
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -275,7 +275,7 @@ int get_ue_active_harq_pid(uint8_t Mod_id,uint8_t CC_id,uint16_t rnti,int frame,
 				  ulsch_frame,
 				  ulsch_subframe);
     *round    = ULSCH_ptr->harq_processes[*harq_pid]->round;
-    LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d subframe %d Checking HARQ, round %d\n",Mod_id,*harq_pid,frame,subframe,*round);
+    LOG_T(PHY,"[eNB %d][PUSCH %d] Frame %d subframe %d Checking HARQ, round %d\n",Mod_id,*harq_pid,frame,subframe,*round);
   }
   return(0);
 }
@@ -2990,7 +2990,11 @@ void phy_procedures_eNB_RX(unsigned char sched_subframe,PHY_VARS_eNB *phy_vars_e
 	//if (((phy_vars_eNB->proc[sched_subframe].frame_tx%10) == 0) || (phy_vars_eNB->proc[sched_subframe].frame_tx < 50)) 
 	print_CQI(phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o,phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->uci_format,0,phy_vars_eNB->lte_frame_parms.N_RB_DL);
 #endif
-	extract_CQI(phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o,phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->uci_format,&phy_vars_eNB->eNB_UE_stats[i], &rnti, &access_mode);
+	extract_CQI(phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o,
+		    phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->uci_format,
+		    &phy_vars_eNB->eNB_UE_stats[i], 
+		    phy_vars_eNB->lte_frame_parms.N_RB_DL,
+		    &rnti, &access_mode);
 	phy_vars_eNB->eNB_UE_stats[i].rank = phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o_RI[0];
       }
     
@@ -3622,7 +3626,12 @@ void phy_procedures_eNB_RX(unsigned char sched_subframe,PHY_VARS_eNB *phy_vars_e
 	//if (((phy_vars_eNB->proc[sched_subframe].frame_tx%10) == 0) || (phy_vars_eNB->proc[sched_subframe].frame_tx < 50)) 
 	print_CQI(phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o,phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->uci_format,0,phy_vars_eNB->lte_frame_parms.N_RB_DL);
 #endif
-	extract_CQI(phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o,phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->uci_format,&phy_vars_eNB->eNB_UE_stats[i], &rnti, &access_mode);
+	access_mode = UNKNOWN_ACCESS;
+	extract_CQI(phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o,
+		    phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->uci_format,
+		    &phy_vars_eNB->eNB_UE_stats[i], 
+		    phy_vars_eNB->lte_frame_parms.N_RB_DL,
+		    &rnti, &access_mode);
 	phy_vars_eNB->eNB_UE_stats[i].rank = phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->o_RI[0];
       }
       /*  LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d harq_pid %d resetting the sched_subframeuling_flag, total cba groups %d %d\n",
@@ -3688,17 +3697,23 @@ void phy_procedures_eNB_RX(unsigned char sched_subframe,PHY_VARS_eNB *phy_vars_e
 			      harq_pid,
 			      NULL);
 
-	    phy_vars_eNB->cba_last_reception[i%num_active_cba_groups]=1;//(subframe);
+	    phy_vars_eNB->cba_last_reception[i%num_active_cba_groups]+=1;//(subframe);
 	  } else {
-	    LOG_N(PHY,"[eNB %d] Frame %d subframe %d : CBA collision detected for UE%d for group %d, set the SR for this UE \n ",
+	    if (phy_vars_eNB->cba_last_reception[i%num_active_cba_groups] == 1 )
+	      LOG_N(PHY,"[eNB%d] Frame %d subframe %d : first CBA collision detected \n ",
+		    phy_vars_eNB->Mod_id,frame,subframe); 
+	    
+	    LOG_N(PHY,"[eNB%d] Frame %d subframe %d : CBA collision set SR for UE %d in group %d \n ",
 		  phy_vars_eNB->Mod_id,frame,subframe,
-		  i,i%num_active_cba_groups ); 
+		  phy_vars_eNB->cba_last_reception[i%num_active_cba_groups],i%num_active_cba_groups ); 
+	    
+	    phy_vars_eNB->cba_last_reception[i%num_active_cba_groups]+=1;
+	    
 	    mac_xface->SR_indication(phy_vars_eNB->Mod_id,
 				     phy_vars_eNB->CC_id,
 				     frame,
 				     phy_vars_eNB->dlsch_eNB[i][0]->rnti,subframe);
 	  }
-	  
 	}
       } // ULSCH CBA not in error 
     }
@@ -3941,9 +3956,10 @@ void phy_procedures_eNB_lte(unsigned char subframe,PHY_VARS_eNB **phy_vars_eNB,u
 
     phy_vars_eNB[CC_id]->proc[subframe].frame_tx++;
     phy_vars_eNB[CC_id]->proc[subframe].frame_rx++;
-    if (phy_vars_eNB[CC_id]->proc[subframe].frame_tx==1024)
+    
+    if (phy_vars_eNB[CC_id]->proc[subframe].frame_tx==MAX_FRAME_NUMBER) // defined in impl_defs_top.h
       phy_vars_eNB[CC_id]->proc[subframe].frame_tx=0;
-    if (phy_vars_eNB[CC_id]->proc[subframe].frame_rx==1024)
+    if (phy_vars_eNB[CC_id]->proc[subframe].frame_rx==MAX_FRAME_NUMBER)
       phy_vars_eNB[CC_id]->proc[subframe].frame_rx=0;
   }
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_LTE,0);
diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c
index 1d97be92057..08c066b96a3 100755
--- a/openair1/SCHED/phy_procedures_lte_ue.c
+++ b/openair1/SCHED/phy_procedures_lte_ue.c
@@ -950,58 +950,7 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstra
 	  phy_vars_ue->sr[subframe_tx]=0;
 	}
       } // ULSCH is active
-      else if ((phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->subframe_cba_scheduling_flag == 1) && 
-	       (phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->status == CBA_ACTIVE)) {
-	phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0;
-	//	phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->status= IDLE; 
-	first_rb = phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->first_rb;
-	nb_rb = phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->nb_rb;
-	input_buffer_length = phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->TBS/8;
-	access_mode=CBA_ACCESS;
-	
-	LOG_I(PHY,"[UE %d] Frame %d, subframe %d: CBA num dci %d \n", 
-	      Mod_id,frame_tx,subframe_tx,
-	      phy_vars_ue->ulsch_ue[eNB_id]->num_cba_dci[subframe_tx]);
-	
-	mac_xface->ue_get_sdu(Mod_id,
-			      CC_id,
-			      frame_tx,
-			      subframe_tx,
-			      eNB_id,
-			      ulsch_input_buffer,
-			      input_buffer_length,
-			      &access_mode);
-	
-	phy_vars_ue->ulsch_ue[eNB_id]->num_cba_dci[subframe_tx]=0;
-	
-	if (access_mode > UNKNOWN_ACCESS){
-
-	  if (abstraction_flag==0) {
-	    if (ulsch_encoding(ulsch_input_buffer,
-			       phy_vars_ue,
-			       harq_pid,
-			       eNB_id,
-			       phy_vars_ue->transmission_mode[eNB_id],0,
-			       0)!=0) {  //  Nbundled, to be updated!!!!
-	      LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n");
-              vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT);
-	      stop_meas(&phy_vars_ue->phy_proc_tx);
-	      return;
-	    }
-	  }
-#ifdef PHY_ABSTRACTION
-	  else {
-	    ulsch_encoding_emul(ulsch_input_buffer,phy_vars_ue,eNB_id,harq_pid,0);
-	  }
-#endif
-	} else {
-	  phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->status= IDLE; 
-	  //reset_cba_uci(phy_vars_ue->ulsch_ue[eNB_id]->o);
-	  LOG_N(PHY,"[UE %d] Frame %d, subframe %d: CBA transmission cancelled or postponed\n",
-		Mod_id, frame_tx,subframe_tx);
-	}
-      }
-
+      
 #ifdef PUCCH
       else if (phy_vars_ue->UE_mode[eNB_id] == PUSCH){  // check if we need to use PUCCH 1a/1b
 	//      debug_LOG_D(PHY,"[UE%d] Frame %d, subframe %d: Checking for PUCCH 1a/1b\n",Mod_id,frame_tx,subframe_tx);
@@ -1174,6 +1123,58 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstra
       }
 #endif  // PUCCH
 
+#ifdef CBA
+      if ((phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->subframe_cba_scheduling_flag >= 1) && 
+	  (phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->status == CBA_ACTIVE)) {
+	phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag=0; //-=1
+	//	phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->status= IDLE; 
+	first_rb = phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->first_rb;
+	nb_rb = phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->nb_rb;
+	//cba_mcs=phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->mcs;
+	input_buffer_length = phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->TBS/8;
+	access_mode=CBA_ACCESS;
+	
+	LOG_I(PHY,"[UE %d] Frame %d, subframe %d: CBA num dci %d\n", 
+	      Mod_id,frame_tx,subframe_tx,
+	      phy_vars_ue->ulsch_ue[eNB_id]->num_cba_dci[subframe_tx]);
+	
+	mac_xface->ue_get_sdu(Mod_id,
+			      CC_id,
+			      frame_tx,
+			      subframe_tx,
+			      eNB_id,
+			      ulsch_input_buffer,
+			      input_buffer_length,
+			      &access_mode);
+	
+	phy_vars_ue->ulsch_ue[eNB_id]->num_cba_dci[subframe_tx]=0;
+	
+	if (access_mode > UNKNOWN_ACCESS){
+
+	  if (abstraction_flag==0) {
+	    if (ulsch_encoding(ulsch_input_buffer,
+			       phy_vars_ue,
+			       harq_pid,
+			       eNB_id,
+			       phy_vars_ue->transmission_mode[eNB_id],0,
+			       0)!=0) {  //  Nbundled, to be updated!!!!
+	      LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n");
+	      return;
+	    }
+	  }
+#ifdef PHY_ABSTRACTION
+	  else {
+	    ulsch_encoding_emul(ulsch_input_buffer,phy_vars_ue,eNB_id,harq_pid,0);
+	  }
+#endif
+	} else {
+	  phy_vars_ue->ulsch_ue[eNB_id]->harq_processes[harq_pid]->status= IDLE; 
+	  //reset_cba_uci(phy_vars_ue->ulsch_ue[eNB_id]->o);
+	  LOG_N(PHY,"[UE %d] Frame %d, subframe %d: CBA transmission cancelled or postponed\n",
+		Mod_id, frame_tx,subframe_tx);
+	}
+      }
+#endif // end CBA
 
       if (abstraction_flag == 0) {
 	if (generate_ul_signal == 1 ) {
diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h
index 86e996e1b6c..922b72c52b6 100755
--- a/openair2/COMMON/platform_constants.h
+++ b/openair2/COMMON/platform_constants.h
@@ -62,7 +62,7 @@
 
 
 #ifdef JUMBO_FRAME
-#    define MAX_IP_PACKET_SIZE         9000
+#    define MAX_IP_PACKET_SIZE         10000 // 9000
 #else
 # if defined(OAI_NW_DRIVER_TYPE_ETHERNET)
 /* SR: When using ethernet network driver the packet size is 1512 :
diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c
index 0c02aa49adf..6df986f3647 100644
--- a/openair2/LAYER2/MAC/config.c
+++ b/openair2/LAYER2/MAC/config.c
@@ -118,7 +118,7 @@ int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,ui
 #endif
 ) {
 
-  int i,CC_id;
+  int i,CC_id=0;
 
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
 
@@ -442,22 +442,22 @@ int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,uint8_t UE_id,ui
           UE_mac_inst[Mod_id].cba_rnti[num_active_cba_groups-1] = cba_rnti;
           LOG_D(MAC,"[UE %d] configure CBA group %d RNTI %x for eNB %d (total active cba group %d)\n",
               Mod_id,Mod_id%num_active_cba_groups, cba_rnti,eNB_index,num_active_cba_groups);
-          mac_xface->phy_config_cba_rnti(Mod_id,eNB_flagP,eNB_index,cba_rnti,num_active_cba_groups-1, num_active_cba_groups);
+          mac_xface->phy_config_cba_rnti(Mod_id,CC_id,eNB_flagP,eNB_index,cba_rnti,num_active_cba_groups-1, num_active_cba_groups);
       }
   }else {
       if (cba_rnti) {
           LOG_D(MAC,"[eNB %d] configure CBA RNTI for UE  %d (total active cba groups %d)\n",
               Mod_id, UE_id, num_active_cba_groups);
-          eNB_mac_inst[Mod_id].num_active_cba_groups=num_active_cba_groups;
+          eNB_mac_inst[Mod_id].common_channels[CC_id].num_active_cba_groups=num_active_cba_groups;
           for (i=0; i < num_active_cba_groups; i ++){
-              if (eNB_mac_inst[Mod_id].cba_rnti[i] != cba_rnti + i)
-                eNB_mac_inst[Mod_id].cba_rnti[i] = cba_rnti + i;
+              if (eNB_mac_inst[Mod_id].common_channels[CC_id].cba_rnti[i] != cba_rnti + i)
+                eNB_mac_inst[Mod_id].common_channels[CC_id].cba_rnti[i] = cba_rnti + i;
               //only configure UE ids up to num_active_cba_groups
               //we use them as candidates for the transmission of dci format0)
               if (UE_id%num_active_cba_groups == i){
-                  mac_xface->phy_config_cba_rnti(Mod_id,eNB_flagP,UE_id,cba_rnti + i,i,num_active_cba_groups );
+		mac_xface->phy_config_cba_rnti(Mod_id,CC_id,eNB_flagP,UE_id,cba_rnti + i,i,num_active_cba_groups );
                   LOG_D(MAC,"[eNB %d] configure CBA groups %d with RNTI %x for UE  %d (total active cba groups %d)\n",
-                      Mod_id, i, eNB_mac_inst[Mod_id].cba_rnti[i],UE_id, num_active_cba_groups);
+                      Mod_id, i, eNB_mac_inst[Mod_id].common_channels[CC_id].cba_rnti[i],UE_id, num_active_cba_groups);
               }
           }
       }
diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
index 56e932e2248..53f029ff243 100644
--- a/openair2/LAYER2/MAC/defs.h
+++ b/openair2/LAYER2/MAC/defs.h
@@ -335,6 +335,15 @@ typedef enum {
   S_DL_NUM_STATUS
 } UE_DLSCH_STATUS;
 
+typedef enum {
+  CBA_ES=0, // equal share of RB among groups w
+  CBA_ES_S,  // equal share of RB among groups with small allocation
+  CBA_PF, // proportional fair (kind of) 
+  CBA_PF_S,  // proportional fair (kind of) with small RB allocation
+  CBA_RS // random allocation
+} CBA_POLICY;
+
+
 // temp struct for sched
 typedef struct {
   
@@ -419,6 +428,11 @@ typedef struct{
  //  total rb used for retransmission 
   uint32_t total_rbs_used_retx;
  
+  /// preassigned mcs after rate adaptation  
+  uint8_t ulsch_mcs1;
+  /// adjusted mcs 
+  uint8_t ulsch_mcs2;
+ 
 
   /// TX 
   /// Num pkt
@@ -452,6 +466,14 @@ typedef struct{
   //  uint32_t avg_pdu_size;
  
   /// RX 
+  /// estimated average pdu inter-departure time
+  uint32_t avg_pdu_idt;
+  /// estimated average pdu size
+  uint32_t avg_pdu_ps;
+  /// 
+  uint32_t aggregated_pdu_size;
+  uint32_t aggregated_pdu_arrival;
+  
   /// num rx pdu 
   uint32_t num_pdu_rx[NB_RB_MAX];
   /// num bytes rx 
@@ -512,9 +534,12 @@ typedef struct{
   /// total allocated RBs
   int8_t total_allocated_rbs;
   
-  /// assigned MCS by the ulsch preprocessor
+  /// pre-assigned MCS by the ulsch preprocessor
   uint8_t pre_assigned_mcs_ul;
-  
+
+  /// assigned MCS by the ulsch scheduler
+  uint8_t assigned_mcs_ul;
+
   /// DCI buffer for ULSCH
   uint8_t ULSCH_DCI[8][(MAX_DCI_SIZE_BITS>>3)+1];
 
@@ -576,31 +601,31 @@ typedef struct{
 } UE_TEMPLATE;
 
 typedef struct{
-		//UL transmission bandwidth in RBs
-		uint8_t ul_bandwidth[MAX_NUM_LCID];
-		//DL transmission bandwidth in RBs
-		uint8_t dl_bandwidth[MAX_NUM_LCID];
-
-		//To do GBR bearer
-		uint8_t min_ul_bandwidth[MAX_NUM_LCID];
-		
-		uint8_t min_dl_bandwidth[MAX_NUM_LCID];
-
-		//aggregated bit rate of non-gbr bearer per UE
-		uint64_t	ue_AggregatedMaximumBitrateDL;
-		//aggregated bit rate of non-gbr bearer per UE
-		uint64_t	ue_AggregatedMaximumBitrateUL;
-		//CQI scheduling interval in subframes.
-		uint16_t cqiSchedInterval;
-		//Contention resolution timer used during random access
-		uint8_t mac_ContentionResolutionTimer;
-		
-		uint16_t max_allowed_rbs[MAX_NUM_LCID];
-
-		uint8_t max_mcs[MAX_NUM_LCID];
-
-		uint16_t priority[MAX_NUM_LCID];
-	
+  //UL transmission bandwidth in RBs
+  uint8_t ul_bandwidth[MAX_NUM_LCID];
+  //DL transmission bandwidth in RBs
+  uint8_t dl_bandwidth[MAX_NUM_LCID];
+  
+  //To do GBR bearer
+  uint8_t min_ul_bandwidth[MAX_NUM_LCID];
+  
+  uint8_t min_dl_bandwidth[MAX_NUM_LCID];
+  
+  //aggregated bit rate of non-gbr bearer per UE
+  uint64_t	ue_AggregatedMaximumBitrateDL;
+  //aggregated bit rate of non-gbr bearer per UE
+  uint64_t	ue_AggregatedMaximumBitrateUL;
+  //CQI scheduling interval in subframes.
+  uint16_t cqiSchedInterval;
+  //Contention resolution timer used during random access
+  uint8_t mac_ContentionResolutionTimer;
+  
+  uint16_t max_allowed_rbs[MAX_NUM_LCID];
+  
+  uint8_t max_mcs[MAX_NUM_LCID];
+  
+  uint16_t priority[MAX_NUM_LCID];
+  
 } UE_sched_ctrl;
 
 typedef struct {
@@ -725,6 +750,7 @@ typedef struct{
 #ifdef CBA
   uint8_t num_active_cba_groups; 
   uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
+  uint8_t group_mcs[NUM_MAX_CBA_GROUP];
 #endif 
 }COMMON_channels_t;
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 2bec1a8842d..af7e862bf68 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -111,7 +111,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
   }
   // refresh UE list based on UEs dropped by PHY in previous subframe
   for (i=UE_list->head;i>0;i=UE_list->next[i]) {
-    LOG_I(MAC,"UE %d: rnti %x (%p)\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
+    LOG_T(MAC,"UE %d: rnti %x (%p)\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
     if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL)
       mac_remove_ue(module_idP,i,frameP);
   }
@@ -209,7 +209,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
   i=UE_list->head;
   while (i>=0) {
     next_i = UE_list->next[i];
-    LOG_D(MAC,"UE %d : rnti %x, stats %p\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
+    LOG_T(MAC,"UE %d : rnti %x, stats %p\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
     if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
       mac_remove_ue(module_idP,i,frameP);
     }
@@ -260,7 +260,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
     else {  //FDD
       schedule_ulsch(module_idP,frameP,cooperation_flag,1,5,nCCE);
         // schedule_ue_spec(module_idP,subframeP,nprb,nCCE,mbsfn_status);
-        // fill_DLSCH_dci(module_idP,subframeP,RBalloc,0,mbsfn_status);
+      //fill_DLSCH_dci(module_idP,subframeP,RBalloc,0,mbsfn_status);
     }
     break;
 
@@ -291,9 +291,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
         }
     }
     else { //FDD
-        //      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7,nCCE);
+      //      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7,nCCE);
         // schedule_ue_spec(module_idP,subframeP,0,0,mbsfn_status);
-        // fill_DLSCH_dci(module_idP,subframeP,RBalloc,0,mbsfn_status);
+      //fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
     }
     break;
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index 42ab173c93f..0db03f99b26 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -1885,7 +1885,7 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP
 
     // UE specific DCIs
     for (UE_id=UE_list->head;UE_id>=0;UE_id=UE_list->next[UE_id]) {
-      LOG_D(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status);
+      LOG_T(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status);
       if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) {
 
 	// clear scheduling flag
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 9a65a740055..3c193d9ebd6 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -169,6 +169,7 @@ unsigned char process_ue_cqi (module_id_t module_idP, int ue_idP) {
   return aggregation;
 }
 #ifdef CBA
+/*
 uint8_t find_num_active_UEs_in_cbagroup(module_id_t module_idP, int CC_id,unsigned char group_id){
 
   module_id_t    UE_id;
@@ -176,7 +177,7 @@ uint8_t find_num_active_UEs_in_cbagroup(module_id_t module_idP, int CC_id,unsign
   unsigned char nb_ue_in_pusch=0;
   LTE_eNB_UE_stats* eNB_UE_stats;
 
-  for (UE_id=group_id;UE_id<NUMBER_OF_UE_MAX;UE_id+=eNB_mac_inst[module_idP][CC_id].num_active_cba_groups) {
+  for (UE_id=group_id;UE_id<NUMBER_OF_UE_MAX;UE_id+=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups) {
 
       if (((rnti=eNB_mac_inst[module_idP][CC_id].UE_template[UE_id].rnti) !=0) &&
           (eNB_mac_inst[module_idP][CC_id].UE_template[UE_id].ul_active==TRUE)    &&
@@ -192,6 +193,7 @@ uint8_t find_num_active_UEs_in_cbagroup(module_id_t module_idP, int CC_id,unsign
   }
   return(nb_ue_in_pusch);
 }
+*/
 #endif
 
 void dump_ue_list(UE_list_t *listP, int ul_flag) {
@@ -220,7 +222,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) {
     UE_id = UE_list->avail;
     UE_list->avail = UE_list->next[UE_list->avail];
     UE_list->next[UE_id] = UE_list->head;
-    UE_list->next_ul[UE_id] = UE_list->head;
+    UE_list->next_ul[UE_id] = UE_list->head_ul;
     UE_list->head = UE_id;
     UE_list->head_ul = UE_id;
     UE_list->UE_template[cc_idP][UE_id].rnti       = rntiP;
@@ -612,7 +614,7 @@ void add_common_dci(DCI_PDU *DCI_pdu,
 
 
   DCI_pdu->Num_common_dci++;
-  LOG_D(MAC,"add common dci format %d for rnti %d \n",dci_fmt,rnti);
+  LOG_D(MAC,"add common dci format %d for rnti %x \n",dci_fmt,rnti);
 }
 
 void add_ue_spec_dci(DCI_PDU *DCI_pdu,void *pdu,rnti_t rnti,unsigned char dci_size_bytes,unsigned char aggregation,unsigned char dci_size_bits,unsigned char dci_fmt,uint8_t ra_flag) {
@@ -626,7 +628,7 @@ void add_ue_spec_dci(DCI_PDU *DCI_pdu,void *pdu,rnti_t rnti,unsigned char dci_si
 
   DCI_pdu->Num_ue_spec_dci++;
 
-  LOG_D(MAC,"add ue specific dci format %d for rnti %d \n",dci_fmt,rnti);
+  LOG_D(MAC,"add ue specific dci format %d for rnti %x \n",dci_fmt,rnti);
 }
 
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index dc7a1f013db..84090b89681 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -63,7 +63,7 @@
 # include "intertask_interface.h"
 #endif
 
-#define ENABLE_MAC_PAYLOAD_DEBUG
+#define ENABLE_MAC_PAYLOAD_DEBUG 
 #define DEBUG_eNB_SCHEDULER 1
 
 // This table holds the allowable PRB sizes for ULSCH transmissions
@@ -226,8 +226,8 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8
       
       //  This check is just to make sure we didn't get a bogus SDU length, to be removed ...
       if (rx_lengths[i]<CCCH_PAYLOAD_SIZE_MAX) {
-	LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d(%d) \n",
-	      enb_mod_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i], rx_lcids[i]);
+	LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n",
+	      enb_mod_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]);
 	
 	mac_rlc_data_ind(enb_mod_idP,UE_id, frameP,ENB_FLAG_YES,MBMS_FLAG_NO,
 			 rx_lcids[i],
@@ -251,8 +251,8 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8
       LOG_T(MAC,"\n");
 #endif
       
-      LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d (%d)\n",
-	    enb_mod_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i],rx_lcids[i]);
+      LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n",
+	    enb_mod_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i]);
       
       if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) &&  (rx_lengths[i] > 0) ) {   // MAX SIZE OF transport block
 	mac_rlc_data_ind(enb_mod_idP,UE_id, frameP,ENB_FLAG_YES,MBMS_FLAG_NO,
@@ -263,7 +263,6 @@ void rx_sdu(module_id_t enb_mod_idP,int CC_idP,frame_t frameP,rnti_t rntiP,uint8
 			 NULL);//(unsigned int*)crc_status);
 	UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1;
 	UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i];
-	  
       }
       //      }
       break;
@@ -535,7 +534,7 @@ void schedule_ulsch(module_id_t module_idP, frame_t frameP,unsigned char coopera
   schedule_ulsch_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe, nCCE, nCCE_available, first_rb);
     
 #ifdef CBA
-  schedule_ulsch_cba_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe, granted_UEs, nCCE, nCCE_available, first_rb);
+  schedule_ulsch_cba_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe, nCCE, nCCE_available, first_rb);
 #endif
 
 
@@ -613,7 +612,7 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 	continue; // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n");
       }
       if (nCCE_available[CC_id] < (1<<aggregation)){
-	LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,CC_id);
+	LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d CC %d: not enough nCCE (%d)\n", module_idP,frameP,subframeP,UE_id,CC_id,nCCE_available[CC_id]);
 	continue; // break;
       }
 	
@@ -630,13 +629,13 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 	  //should we continue or set harq_pid to 0?
 	  continue;
 	}else 
-	  LOG_D(MAC,"[eNB %d] Frame %d, subframeP %d, UE %d CC %d : got harq pid %d  round %d (nCCE %d, rnti %x,mode %s)\n",
+	  LOG_T(MAC,"[eNB %d] Frame %d, subframeP %d, UE %d CC %d : got harq pid %d  round %d (nCCE %d, rnti %x,mode %s)\n",
 		module_idP,frameP,subframeP,UE_id,CC_id, harq_pid, round,nCCE[CC_id],rnti,mode_string[eNB_UE_stats->mode]);
        
 
 
 #ifndef EXMIMO_IOT
-	if (((UE_is_to_be_scheduled(module_idP,CC_id,UE_id)>0)) || (round>0) || ((frameP%10)==0)) 
+	if (((UE_is_to_be_scheduled(module_idP,CC_id,UE_id)>0)) || (round>0))// || ((frameP%10)==0)) 
 	  // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames
 #else
 	  if (round==0)
@@ -679,12 +678,14 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 		ndi = 1-UE_template->oldNDI_UL[harq_pid];
 		UE_template->oldNDI_UL[harq_pid]=ndi;
 		//mcs = 10;
+		UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->pre_assigned_mcs_ul;
 		mcs = cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS
 		if (UE_template->pre_allocated_rb_table_index_ul >=0)
 		  rb_table_index=UE_template->pre_allocated_rb_table_index_ul;
-		else {// NN-->RK: check this condition
+		else {
 		  mcs=10;rb_table_index=5; // for PHR
 		}
+		UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs;
 		buffer_occupancy = UE_template->ul_total_buffer;
 		
 		while ((rb_table[rb_table_index]>(frame_parms->N_RB_UL-1-first_rb[CC_id])) && 
@@ -701,8 +702,8 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 		//store for possible retransmission
 		UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; 
 		
-		LOG_D(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframeP %d Scheduled UE (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n",
-		      module_idP,harq_pid,rnti,frameP,subframeP,mcs,
+		LOG_D(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n",
+		      module_idP,harq_pid,rnti,frameP,subframeP,UE_id,mcs,
 		      first_rb[CC_id],rb_table[rb_table_index],
 		      rb_table_index,TBS,harq_pid);
 		// Adjust BSR entries for LCGIDs 
@@ -956,47 +957,129 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
 }
 
 #ifdef CBA
-void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframeP, unsigned char sched_subframe, uint8_t granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, uint16_t *first_rb){
+void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframeP, unsigned char sched_subframe, unsigned int *nCCE, unsigned int *nCCE_available, uint16_t *first_rb){
 
-  DCI0_5MHz_TDD_1_6_t *ULSCH_dci_tdd16;
-  DCI0_5MHz_FDD_t *ULSCH_dci_fdd;
+  eNB_MAC_INST *eNB = &eNB_mac_inst[module_idP];
+  UE_list_t         *UE_list=&eNB->UE_list;
+  //UE_TEMPLATE       *UE_template;
+  void              *ULSCH_dci      = NULL;
   DCI_PDU *DCI_pdu;
   uint8_t CC_id=0;
   uint8_t rb_table_index=0, aggregation=2;
   uint32_t rballoc;
   uint8_t cba_group, cba_resources;
-  uint8_t required_rbs[NUM_MAX_CBA_GROUP], weight[NUM_MAX_CBA_GROUP], num_cba_resources[NUM_MAX_CBA_GROUP];
-  uint8_t available_rbs= ceil(mac_xface->lte_frame_parms->N_RB_UL-1-first_rb[CC_id]);
-  uint8_t remaining_rbs= available_rbs;
-  uint8_t allocated_rbs;
+  uint8_t required_rbs[NUM_MAX_CBA_GROUP];
+  int8_t num_cba_resources[NUM_MAX_CBA_GROUP];// , weight[NUM_MAX_CBA_GROUP]
+  // the following vars should become a vector [MAX_NUM_CCs]
+  LTE_DL_FRAME_PARMS   *frame_parms;
+  int8_t available_rbs=0;
+  uint8_t remaining_rbs=0;
+  uint8_t allocated_rbs=0;
+  uint8_t total_UEs=UE_list->num_UEs;
+  uint8_t active_UEs[NUM_MAX_CBA_GROUP];
+  uint8_t total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups;
+  int     min_rb_unit=2;
+  uint8_t cba_policy=CBA_ES;
+  int     UE_id;
+  uint8_t mcs[NUM_MAX_CBA_GROUP];
+  uint32_t total_cba_resources=0;
+  uint32_t total_rbs=0;
   // We compute the weight of each group and initialize some variables
 
-  
+  // loop over all active UEs
+  //  for (UE_id=UE_list->head_ul;UE_id>=0;UE_id=UE_list->next_ul[UE_id]) {
 
-  for (cba_group=0;cba_group<eNB_mac_inst[module_idP][CC_id].num_active_cba_groups;cba_group++) {
+  for (cba_group=0;cba_group<total_groups;cba_group++) {
     // UEs in PUSCH with traffic
-    weight[cba_group] = find_num_active_UEs_in_cbagroup(module_idP, cba_group);
+    //    weight[cba_group] = 0;
     required_rbs[cba_group] = 0;
     num_cba_resources[cba_group]=0;
+    active_UEs[cba_group]=0;
+    mcs[cba_group]=openair_daq_vars.target_ue_ul_mcs;
   }
   //LOG_D(MAC, "[eNB ] CBA granted ues are %d\n",granted_UEs );
 
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
-
-    if ((eNB_mac_inst[module_idP][CC_id].num_active_cba_groups > 0) && (nCCE[CC_id] == 0)) {
-      DCI_pdu = &eNB_mac_inst[module_idP][CC_id].DCI_pdu;
-
-      for (cba_group=0;cba_group<eNB_mac_inst[module_idP][CC_id].num_active_cba_groups  && (nCCE_available[CC_id] > (1<<aggregation));cba_group++) {
-	if (remaining_rbs <= 0 )
+    
+    frame_parms=mac_xface->get_lte_frame_parms(module_idP,CC_id); 
+    available_rbs=frame_parms->N_RB_DL-1-first_rb[CC_id];
+    remaining_rbs=available_rbs;
+    total_groups=eNB_mac_inst[module_idP].common_channels[CC_id].num_active_cba_groups;
+    min_rb_unit=get_min_rb_unit(module_idP,CC_id);
+    
+    if (available_rbs  < min_rb_unit )
+      continue;
+    
+    // remove this condition later
+    // cba group template uses the exisitng UE template, and thus if a UE
+    // is scheduled, the correspodning group can't be used for CBA 
+    // this can be fixed later
+    if ((total_groups > 0) && (nCCE[CC_id] == 0)) {
+      DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
+
+      for (cba_group=0;
+	   (cba_group<total_groups)  && (nCCE_available[CC_id]* (total_cba_resources+1) > (1<<aggregation));
+	   cba_group++) {
+	// equal weight 
+	//weight[cba_group] = floor(total_UEs/active_groups);//find_num_active_UEs_in_cbagroup(module_idP, cba_group);
+     
+	for (UE_id=UE_list->head_ul;UE_id>=0;UE_id=UE_list->next_ul[UE_id]) {
+	  if (UE_RNTI(module_idP,UE_id)==0) 
+	    continue;
+	  // simple UE identity based grouping 
+	  if ((UE_id % total_groups) == cba_group){ // this could be simplifed to  active_UEs[UE_id % total_groups]++;
+	    if ((mac_get_rrc_status(module_idP,1,UE_id) > RRC_CONNECTED) && 
+		(UE_is_to_be_scheduled(module_idP,CC_id,UE_id) == 0))
+	      active_UEs[cba_group]++;
+	  }
+	  if (UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul <= 2)
+	    mcs[cba_group]= 8; // apply fixed scheduling 
+	  else if ((UE_id % total_groups) == cba_group) 
+	    mcs[cba_group]= cmin(mcs[cba_group],UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul);
+	}
+	mcs[cba_group]= cmin(mcs[cba_group],openair_daq_vars.target_ue_ul_mcs);
+	
+	if (available_rbs < min_rb_unit )
 	  break;
 	// If the group needs some resource
-	if ((weight[cba_group] > 0) && eNB_mac_inst[module_idP][CC_id].cba_rnti[cba_group] != 0){
-	  // to be refined in case of : granted_UEs >> weight[cba_group]*available_rbs
-	  required_rbs[cba_group] = (uint8_t)ceil((weight[cba_group]*available_rbs)/granted_UEs);
-
-	  while (remaining_rbs < required_rbs[cba_group] )
+	// determine the total number of allocations (one or multiple DCIs): to be refined
+	if ((active_UEs[cba_group] > 0) && (eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group] != 0)){
+	  // to be refined in case of : total_UEs >> weight[cba_group]*available_rbs
+	  
+	  switch(cba_policy) {
+	  case CBA_ES:
+	    required_rbs[cba_group] = (uint8_t)floor(available_rbs/total_groups); // allocate equally among groups
+	    num_cba_resources[cba_group]=1;
+	    break;
+	    // can't have more than one allocation for the same group/UE
+	    /*  case CBA_ES_S: 
+	    required_rbs[cba_group] = (uint8_t)floor(available_rbs/total_groups); // allocate equally among groups
+	    if (required_rbs[cba_group] > min_rb_unit)
+	      num_cba_resources[cba_group]=(uint8_t)(required_rbs[cba_group]/ min_rb_unit);
+	      break;*/
+	  case CBA_PF:
+	    required_rbs[cba_group] = (uint8_t)floor((active_UEs[cba_group]*available_rbs)/total_UEs);
+	    num_cba_resources[cba_group]=1;
+	    break;
+	    /* case CBA_PF_S:
+	    required_rbs[cba_group] = (uint8_t)ceil((active_UEs[cba_group]*available_rbs)/total_UEs);
+	    if (required_rbs[cba_group] > min_rb_unit)
+	      num_cba_resources[cba_group]=(uint8_t) floor(required_rbs[cba_group] / min_rb_unit);
+	    break;*/
+	    
+	  default:
+	    LOG_W(MAC,"unknown CBA policy\n");
+	    break;
+	  }
+	  total_cba_resources+=num_cba_resources[cba_group];
+	  total_rbs+=required_rbs[cba_group]; 
+	  
+	  /*  while ((remaining_rbs < required_rbs[cba_group]) && 
+		 (required_rbs[cba_group] > 0) && 
+		 (required_rbs[cba_group] < min_rb_unit ))
 	    required_rbs[cba_group]--;
-
+	  */
+	  
 	  /*
 	    while (rb_table[rb_table_index] < required_rbs[cba_group])
 	    rb_table_index++;
@@ -1007,26 +1090,39 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
 	    remaining_rbs-=rb_table[rb_table_index];
 	    required_rbs[cba_group]=rb_table[rb_table_index];
 	  */
-	  // to be refined
-	  if (weight[cba_group] <  required_rbs[cba_group])
-	    num_cba_resources[cba_group]=(uint8_t)ceil(weight[cba_group]/2.0);
-	  else
-	    num_cba_resources[cba_group]=(uint8_t)ceil(required_rbs[cba_group]/2.0);
-
-	  while (nCCE[CC_id] + (1<<aggregation) * num_cba_resources[cba_group] > nCCE_available[CC_id])
-	    num_cba_resources[cba_group]--;
-
-	  LOG_N(MAC,"[eNB %d] Frame %d, subframeP %d: cba group %d weight/granted_ues %d/%d available/required rb (%d/%d), num resources %d->1 (*scaled down*) \n",
-		module_idP, frameP, subframeP, cba_group,
-		weight[cba_group], granted_UEs, available_rbs,required_rbs[cba_group],
-		num_cba_resources[cba_group]);
-
-	  num_cba_resources[cba_group]=1;
+	  //	  num_cba_resources[cba_group]=1;
 
 	}
       }
-      // phase 2
-      for (cba_group=0;cba_group<eNB_mac_inst[module_idP][CC_id].num_active_cba_groups;cba_group++) {
+      // phase 2 reduce the number of cba allocations among the groups
+      cba_group=0;
+      while  (nCCE[CC_id] + (1<<aggregation) * total_cba_resources >= nCCE_available[CC_id]){
+	num_cba_resources[cba_group%total_groups]--;
+	total_cba_resources--;
+	//	LOG_N(MAC,"reducing num cba resources to %d for group %d \n",	num_cba_resources[cba_group%total_groups], cba_group%total_groups );
+      	cba_group++;
+      }
+      
+      if (total_cba_resources <= 0)
+	return;
+      
+      // increase rb if any left: to be done 
+      cba_group=0;
+      while (total_rbs  < available_rbs - 1 ){
+	required_rbs[cba_group%total_groups]++;
+	total_rbs++;
+	cba_group++;
+      }
+
+      // phase 3: 
+      for (cba_group=0;cba_group<total_groups;cba_group++) {
+
+	LOG_N(MAC,"[eNB %d] Frame %d, subframe %d: cba group %d active_ues %d total groups %d mcs %d, available/required rb (%d/%d), num resources %d, ncce (%d/%d required %d \n",
+	      module_idP, frameP, subframeP, cba_group,active_UEs[cba_group],total_groups,
+	      mcs[cba_group], available_rbs,required_rbs[cba_group],
+	      num_cba_resources[cba_group],
+	      nCCE[CC_id],nCCE_available[CC_id],(1<<aggregation) * num_cba_resources[cba_group]);
+	
 	for (cba_resources=0; cba_resources < num_cba_resources[cba_group]; cba_resources++){
 	  rb_table_index =0;
 	  // check if there was an allocation for this group in the 1st phase
@@ -1047,58 +1143,118 @@ void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_f
 					  rb_table[rb_table_index]);
 
 	  first_rb[CC_id]+=rb_table[rb_table_index];
-	  LOG_D(MAC,"[eNB %d] Frame %d, subframeP %d: CBA %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), rballoc %d, nCCE (%d/%d)\n",
-		module_idP, frameP, subframeP, cba_group,eNB_mac_inst[module_idP][CC_id].cba_rnti[cba_group],
-		available_rbs, required_rbs[cba_group], allocated_rbs, remaining_rbs,rballoc,
-		nCCE_available[CC_id],nCCE[CC_id]);
-
-
-	  if (mac_xface->lte_frame_parms->frame_type == TDD) {
-	    ULSCH_dci_tdd16 = (DCI0_5MHz_TDD_1_6_t *)UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0];
-
-	    ULSCH_dci_tdd16->type     = 0;
-	    ULSCH_dci_tdd16->hopping  = 0;
-	    ULSCH_dci_tdd16->rballoc  = rballoc;
-	    ULSCH_dci_tdd16->mcs      = 2;
-	    ULSCH_dci_tdd16->ndi      = 1;
-	    ULSCH_dci_tdd16->TPC      = tpc;
-	    ULSCH_dci_tdd16->cshift   = cba_group;
-	    ULSCH_dci_tdd16->dai      = UE_list->UE_template[CC_id][cba_group].DAI_ul[sched_subframe];
-	    ULSCH_dci_tdd16->cqi_req  = 1;
-
+	  LOG_N(MAC,"[eNB %d] Frame %d, subframeP %d: schedule CBA access %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), mcs %d, rballoc %d, nCCE (%d/%d)\n",
+		module_idP, frameP, subframeP, cba_group,eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+		available_rbs, required_rbs[cba_group], allocated_rbs, remaining_rbs,
+		mcs[cba_group],rballoc,nCCE_available[CC_id],nCCE[CC_id]);
+
+	  switch (frame_parms->N_RB_UL) {
+	  case 6:
+	    mac_xface->macphy_exit("[MAC][eNB] CBA RB=6 not supported \n");
+	    break;
+	  case 25:
+	    if (frame_parms->frame_type == TDD) {
+	      ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0];
+	      
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->type     = 0;
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping  = 0;
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc  = rballoc;
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs      = mcs[cba_group];
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi      = 1;
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC      = 1;//tpc;
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift   = cba_group;
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->dai      = UE_list->UE_template[CC_id][cba_group].DAI_ul[sched_subframe];
+	      ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req  = 1;
+	      
+	      //add_ue_spec_dci
+	      add_common_dci(DCI_pdu,
+			     ULSCH_dci,
+			     eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+			     sizeof(DCI0_5MHz_TDD_1_6_t),
+			     aggregation,
+			     sizeof_DCI0_5MHz_TDD_1_6_t,
+			     format0,
+			     0);
+	    }
+	    else {
+	      ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0];
+
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->type     = 0;
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->hopping  = 0;
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->rballoc  = rballoc;
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->mcs      = mcs[cba_group];
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->ndi      = 1;
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->TPC      = 1;//tpc;
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cshift   = cba_group;
+	      ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cqi_req  = 1;
+	      
 	    //add_ue_spec_dci
 	    add_common_dci(DCI_pdu,
-			   ULSCH_dci_tdd16,
-			   eNB_mac_inst[module_idP][CC_id].cba_rnti[cba_group],
-			   sizeof(DCI0_5MHz_TDD_1_6_t),
+			   ULSCH_dci,
+			   eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+			   sizeof(DCI0_5MHz_FDD_t),
 			   aggregation,
-			   sizeof_DCI0_5MHz_TDD_1_6_t,
+			   sizeof_DCI0_5MHz_FDD_t,
 			   format0,
 			   0);
-	  }
-	  else {
-	    ULSCH_dci_fdd           = (DCI0_5MHz_FDD_t *)UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0];
-
-	    ULSCH_dci_fdd->type     = 0;
-	    ULSCH_dci_fdd->hopping  = 0;
-	    ULSCH_dci_fdd->rballoc  = rballoc;
-	    ULSCH_dci_fdd->mcs      = 2;
-	    ULSCH_dci_fdd->ndi      = 1;
-	    ULSCH_dci_fdd->TPC      = tpc;
-	    ULSCH_dci_fdd->cshift   = 0;
-	    ULSCH_dci_fdd->cqi_req  = 1;
-
+	    }
+	    LOG_D(MAC,"[eNB %d] Frame %d, subframeP %d: Generated ULSCH DCI for CBA group %d, RB 25 format 0\n", module_idP,frameP,subframeP,cba_group);
+	    break;
+	  case 50:
+	    if (frame_parms->frame_type == TDD) {
+	      ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0];
+	      
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->type     = 0;
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->hopping  = 0;
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->rballoc  = rballoc;
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->mcs      = mcs[cba_group];
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->ndi      = 1;
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->TPC      = 1;//tpc;
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cshift   = cba_group;
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->dai      = UE_list->UE_template[CC_id][cba_group].DAI_ul[sched_subframe];
+	      ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req  = 1;
+	      
+	      //add_ue_spec_dci
+	      add_common_dci(DCI_pdu,
+			     ULSCH_dci,
+			     eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+			     sizeof(DCI0_10MHz_TDD_1_6_t),
+			     aggregation,
+			     sizeof_DCI0_10MHz_TDD_1_6_t,
+			     format0,
+			     0);
+	    }
+	    else {
+	      ULSCH_dci = UE_list->UE_template[CC_id][cba_group].ULSCH_DCI[0];
+	      
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->type     = 0;
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->hopping  = 0;
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->rballoc  = rballoc;
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->mcs      = mcs[cba_group];
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->ndi      = 1;
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->TPC      = 1;//tpc;
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cshift   = cba_group;
+	      ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cqi_req  = 1;
+	      
 	    //add_ue_spec_dci
 	    add_common_dci(DCI_pdu,
-			   ULSCH_dci_fdd,
-			   eNB_mac_inst[module_idP][CC_id].cba_rnti[cba_group],
-			   sizeof(DCI0_5MHz_FDD_t),
+			   ULSCH_dci,
+			   eNB_mac_inst[module_idP].common_channels[CC_id].cba_rnti[cba_group],
+			   sizeof(DCI0_10MHz_FDD_t),
 			   aggregation,
-			   sizeof_DCI0_5MHz_FDD_t,
+			   sizeof_DCI0_10MHz_FDD_t,
 			   format0,
 			   0);
+	    }
+	    LOG_D(MAC,"[eNB %d] Frame %d, subframeP %d: Generated ULSCH DCI for CBA group %d, RB 50 format 0\n", module_idP,frameP,subframeP,cba_group);
+	    break;
+	  case 100:
+	    mac_xface->macphy_exit("[MAC][eNB] CBA RB=100 not supported \n");
+	    break;
+	  default:
+	    break;
 	  }
-	  nCCE[CC_id] = nCCE[CC_id] + (1<<aggregation) * num_cba_resources[cba_group];
+	  nCCE[CC_id] = nCCE[CC_id] + (1<<aggregation) ;
 	  nCCE_available[CC_id] = mac_xface->get_nCCE_max(module_idP,CC_id) - nCCE[CC_id];
 	  //      break;// for the moment only schedule one
 	}
diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index c652128da77..db2cadbe50b 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -474,14 +474,15 @@ void dlsch_scheduler_pre_processor (module_id_t   Mod_id,
 	else  // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round
 	  nb_rbs_required_remaining[CC_id][i] = nb_rbs_required[CC_id][i]-nb_rbs_required_remaining_1[CC_id][i]+nb_rbs_required_remaining[CC_id][i];
 
-	LOG_D(MAC,"round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d,  pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", 
-	      r1, CC_id, i, 
-	      nb_rbs_required_remaining[CC_id][i],
-	      nb_rbs_required_remaining_1[CC_id][i], 
-	      nb_rbs_required[CC_id][i],
-	      pre_nb_available_rbs[CC_id][i],
-	      N_RBG[CC_id],
-	      min_rb_unit[CC_id]);
+	if (nb_rbs_required[CC_id][i]> 0 )
+	  LOG_D(MAC,"round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d,  pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", 
+		r1, CC_id, i, 
+		nb_rbs_required_remaining[CC_id][i],
+		nb_rbs_required_remaining_1[CC_id][i], 
+		nb_rbs_required[CC_id][i],
+		pre_nb_available_rbs[CC_id][i],
+		N_RBG[CC_id],
+		min_rb_unit[CC_id]);
 	
       }
     }
@@ -630,15 +631,18 @@ void dlsch_scheduler_pre_processor (module_id_t   Mod_id,
     for (ii=0;ii<UE_num_active_CC(UE_list,UE_id);ii++) {
       CC_id = UE_list->ordered_CCids[ii][UE_id];
       //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id];
-      LOG_D(MAC,"******************DL Scheduling Information for UE%d ************************\n",UE_id);
-      LOG_D(MAC,"dl power offset UE%d = %d \n",UE_id,dl_pow_off[CC_id][UE_id]);
-      LOG_D(MAC,"***********RB Alloc for every subband for UE%d ***********\n",UE_id);
-      for(j=0;j<N_RBG[CC_id];j++){
-	//PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i];
-	LOG_D(MAC,"RB Alloc for UE%d and Subband%d = %d\n",UE_id,j,rballoc_sub_UE[CC_id][UE_id][j]);
+     
+      if (pre_nb_available_rbs[CC_id][UE_id] > 0 ){
+	LOG_D(MAC,"******************DL Scheduling Information for UE%d ************************\n",UE_id);
+	LOG_D(MAC,"dl power offset UE%d = %d \n",UE_id,dl_pow_off[CC_id][UE_id]);
+	LOG_D(MAC,"***********RB Alloc for every subband for UE%d ***********\n",UE_id);
+	for(j=0;j<N_RBG[CC_id];j++){
+	  //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i];
+	  LOG_D(MAC,"RB Alloc for UE%d and Subband%d = %d\n",UE_id,j,rballoc_sub_UE[CC_id][UE_id][j]);
+	}
+	//PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id];
+	LOG_D(MAC,"Total RBs allocated for UE%d = %d\n",UE_id,pre_nb_available_rbs[CC_id][UE_id]);
       }
-      //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id];
-      LOG_D(MAC,"Total RBs allocated for UE%d = %d\n",UE_id,pre_nb_available_rbs[CC_id][UE_id]);
     }
   }
 }
@@ -807,7 +811,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP,
     }
   }
   
-  LOG_D(MAC,"[eNB %d] Frame %d subframe %d: total ue %d, max num ue to be scheduled %d\n", 
+  LOG_D(MAC,"[eNB %d] Frame %d subframe %d: total ue to be scheduled %d/%d\n", 
 	module_idP, frameP, subframeP,total_ue_count, max_num_ue_to_be_scheduled);
 
   //LOG_D(MAC,"step3\n");
@@ -885,11 +889,14 @@ void store_ulsch_buffer(module_id_t module_idP, int frameP, sub_frame_t subframe
   
   for (UE_id=UE_list->head_ul;UE_id>=0;UE_id=UE_list->next_ul[UE_id]) {
     
+    
     UE_template = &UE_list->UE_template[UE_PCCID(module_idP,UE_id)][UE_id];
+    //LOG_I(MAC,"[UE %d next %d] SR is %d\n",UE_id, UE_list->next_ul[UE_id], UE_template->ul_SR); 
+      
     UE_template->ul_total_buffer=0;
     for (lcgid=0; lcgid<MAX_NUM_LCGID; lcgid++){
       UE_template->ul_buffer_info[lcgid]=BSR_TABLE[UE_template->bsr_info[lcgid]];
-      UE_template->ul_total_buffer+= UE_template->ul_buffer_info[lcgid];
+      UE_template->ul_total_buffer+= UE_template->ul_buffer_info[lcgid]; // apply traffic aggregtaion if packets are small
       //   UE_template->ul_buffer_creation_time_max=cmax(UE_template->ul_buffer_creation_time_max, frame_cycle*1024 + frameP-UE_template->ul_buffer_creation_time[lcgid]));
     }
     if ( UE_template->ul_total_buffer >0)
@@ -920,7 +927,9 @@ void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subfra
   rnti_t             rnti           = -1;
   int                mcs=cmin(16,openair_daq_vars.target_ue_ul_mcs); 
   int                rb_table_index=0,tbs,tx_power;
-  UE_list_t          *UE_list = &eNB_mac_inst[module_idP].UE_list; 
+  eNB_MAC_INST       *eNB = &eNB_mac_inst[module_idP];
+  UE_list_t          *UE_list = &eNB->UE_list; 
+  
   UE_TEMPLATE       *UE_template;
   LTE_DL_FRAME_PARMS   *frame_parms;
   
diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h
index c435d21b14e..20403d17087 100644
--- a/openair2/LAYER2/MAC/proto.h
+++ b/openair2/LAYER2/MAC/proto.h
@@ -94,7 +94,7 @@ int8_t ue_get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t mbsfn_sync_are
 */
 void schedule_ulsch(module_id_t module_idP,frame_t frameP,unsigned char cooperation_flag,sub_frame_t subframe,unsigned char sched_subframe,unsigned int *nCCE);
 
-/** \brief ULSCH Scheduling per RNTI TDD config (config 1-6).
+/** \brief ULSCH Scheduling per RNTI 
 @param Mod_id Instance ID of eNB
 @param frame Frame index
 @param subframe Subframe number on which to act
@@ -103,14 +103,14 @@ void schedule_ulsch(module_id_t module_idP,frame_t frameP,unsigned char cooperat
 */
 void schedule_ulsch_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, unsigned int *nCCE, unsigned int *nCCE_available, uint16_t *first_rb);
 
-/** \brief ULSCH Scheduling for CBA  RNTI TDD config (config 1-6).
+/** \brief ULSCH Scheduling for CBA  RNTI 
 @param Mod_id Instance ID of eNB
 @param frame Frame index
 @param subframe Subframe number on which to act
 @param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup)
 @param nCCE Pointer to current nCCE count
 */
-void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, uint8_t granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, uint16_t *first_rb);
+void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, unsigned int *nCCE, unsigned int *nCCE_available, uint16_t *first_rb);
 
 /** \brief Second stage of DLSCH scheduling, after schedule_SI, schedule_RA and schedule_dlsch have been called.  This routine first allocates random frequency assignments for SI and RA SDUs using distributed VRB allocations and adds the corresponding DCI SDU to the DCI buffer for PHY.  It then loops over the UE specific DCIs previously allocated and fills in the remaining DCI fields related to frequency allocation.  It assumes localized allocation of type 0 (DCI.rah=0).  The allocation is done for tranmission modes 1,2,4. 
 @param Mod_id Instance of eNB
@@ -500,7 +500,7 @@ void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, UE_TEMPLATE *UE_templat
 */
 UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t subframe, lte_subframe_t direction,uint8_t eNB_index,int CC_id);
 
-/*! \fn  int use_cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index);
+/*! \fn  int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen);
 \brief determine whether to use cba resource to transmit or not
 \param[in] Mod_id instance of the UE
 \param[in] frame the frame number
@@ -508,7 +508,7 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su
 \param[in] eNB_index instance of eNB
 \param[out] access(1) or postpone (0) 
 */
-int use_cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index);
+int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen);
 
 /*! \fn  int get_bsr_lcgid (module_id_t module_idP);
 \brief determine the lcgid for the bsr
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 4611088076d..c3212fd423c 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -127,6 +127,10 @@ void ue_init_mac(module_id_t module_idP){
         UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1;
       UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0;
   }
+#ifdef CBA
+  for (i=0; i <NUM_MAX_CBA_GROUP;i++) 
+    UE_mac_inst[module_idP].cba_last_access[i]= round(uniform_rngen(1,30));
+#endif 
 }
 
 
@@ -256,7 +260,7 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i
           UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=1;
       } else
         UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0;
-      LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d send SR_indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
+      LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
           module_idP,rnti,frameP,subframe,
           UE_mac_inst[module_idP].scheduling_info.SR_COUNTER,
           (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)),
@@ -1074,12 +1078,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
       LOG_D(MAC,"[UE %d] frameP %d subframe %d try CBA transmission\n",
           module_idP, frameP, subframe);
       //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY)
-      if (use_cba_access(module_idP,frameP,subframe,eNB_index)==0){
+      if (cba_access(module_idP,frameP,subframe,eNB_index,buflen)==0){
           *access_mode=POSTPONED_ACCESS;
           vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
           return;
       }
-      LOG_D(MAC,"[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n",
+      LOG_I(MAC,"[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n",
           module_idP, frameP, subframe,buflen);
   }
 #endif
@@ -1117,7 +1121,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
 
   if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] == LCID_NOT_EMPTY) {
 
-      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO,
+    rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
           DCCH,
           (buflen-dcch_header_len-bsr_len-phr_len));
       LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to "
@@ -1143,7 +1147,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
   // DCCH1
   if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] == LCID_NOT_EMPTY) {
 
-      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO,
+    rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
           DCCH1,
           (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total));
 
@@ -1177,7 +1181,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
     else
       dtch_header_len = 2;//sizeof(SCH_SUBHEADER_SHORT);
        */
-      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO,
+    rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
           DTCH,
           buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total);
 
@@ -1185,7 +1189,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
           module_idP,frameP, rlc_status.bytes_in_buffer,buflen,dtch_header_len,
           UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH]);
 
-      sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frameP, ENB_FLAG_NO, MBMS_FLAG_NO,
+      sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frameP, ENB_FLAG_NO, MBMS_FLAG_NO, // eNB_index
           DTCH,
           (char *)&ulsch_buff[sdu_length_total]);
 
@@ -1527,13 +1531,19 @@ UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t su
 
 // to be improved
 #ifdef CBA
+extern int cba_backoff;
 double uniform_rngen(int min, int max) {
   double random = (double)taus()/((double)0xffffffff);
   return (max - min) * random + min;
 }
 
-int use_cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index){
+int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen){
 
+  mac_rlc_status_resp_t rlc_status;
+  int header_offset=4;
+  int rv =0;
+
+  /*  
   if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64))   ||
       ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64))   ||
       ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) )
@@ -1542,11 +1552,11 @@ int use_cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, u
       //  LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe,
       //  UE_mac_inst[module_idP].cba_last_access[0] );
 
-      UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,10));
+      UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,40));
       LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff  %d UL active state %d \n", module_idP, frameP, subframe,
           UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
 
-      return 1;
+      rv=1;
   } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 ))   ||
       ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 ))   ||
       ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) )
@@ -1558,15 +1568,113 @@ int use_cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, u
           module_idP, frameP, subframe,
           UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
 
-  } /*else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 ))   &&
-	       ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 ))   &&
-	       ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] ==  0 )) )
-	     && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){
+  } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 ))   &&
+               ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 ))   &&
+               ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] ==  0 )) )
+             && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){
     UE_mac_inst[module_idP].cba_last_access[0]-=1;
     }*/
 
-  return 0;
+  if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]<64) )
+    return 0;
+ 
+  if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0 ) &&
+      (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0 ) &&
+      (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0 ) )
+    return 0;
+
+  if (cba_backoff == 0 ){ // apply probablisitc method
+    UE_mac_inst[module_idP].cba_last_access[0]= uniform_rngen(0,1);
+    if (uniform_rngen(0,1) > 0.6 ){
+      LOG_I(MAC,"[UE %d] Frame %d Subframe %d: CBA probability-based backoff (%d), UL active state %d \n", module_idP, frameP, subframe,
+	    cba_backoff,UE_mac_inst[module_idP].ul_active);
+   
+      rv=1;
+    }
+  }
+  else {
+    
+    if (UE_mac_inst[module_idP].cba_last_access[0] <= 0) {
+      UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff));
+      
+      LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff  %d/%d UL active state %d \n", module_idP, frameP, subframe,
+	    UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active);
+      
+      rv = 1; 
+      /*    
+	    rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
+	    DTCH,
+	    0);
+	    
+	    if ((
+	    //	(rlc_status.pdus_in_buffer > 0 )           && 
+	    // (UE_mac_inst[module_idP].ul_active == 0)  && // check if the ul is acrtive
+	    (rlc_status.head_sdu_is_segmented  == 0 )          &&	 
+	    ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen )
+	    )){
+	    rv = 1;
+	    
+	    UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30));
+	    LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff  %d UL active state %d \n", module_idP, frameP, subframe,
+	    UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+      */
+    } else {
+      UE_mac_inst[module_idP].cba_last_access[0]-=1;
+      LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n",
+	    module_idP, frameP, subframe,
+	    UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+    }	
+  }
+
+  return rv;
+  /*
+    if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64))   ||
+	  ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64))   ||
+	  ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) 
+	//  && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
+	&& (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) {
+  
+      UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff));
+      
+      LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff  %d/%d UL active state %d \n", module_idP, frameP, subframe,
+	    UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active);
+      
+      rv = 1; 
+  
+      rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
+				    DTCH,
+				    0);
+    
+    if ((
+	 //	(rlc_status.pdus_in_buffer > 0 )           && 
+	// (UE_mac_inst[module_idP].ul_active == 0)  && // check if the ul is acrtive
+	 (rlc_status.head_sdu_is_segmented  == 0 )          &&	 
+	 ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen )
+	 )){
+      rv = 1;
+      
+      UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30));
+      LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff  %d UL active state %d \n", module_idP, frameP, subframe,
+	    UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+    } else 
+      UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,5));
+  
 
+    } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 ))   ||
+		 ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 ))   ||
+		 ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) )
+	       // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
+	       && (UE_mac_inst[module_idP].cba_last_access[0]> 0) )
+      {
+	
+	UE_mac_inst[module_idP].cba_last_access[0]-=1;
+	LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n",
+	      module_idP, frameP, subframe,
+	      UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+      }
+  }
+*/  
+  
 }
 #endif
 
@@ -1631,15 +1739,15 @@ boolean_t  update_bsr(module_id_t module_idP, frame_t frameP, uint8_t lcid, uint
   //  for (lcid =0 ; lcid < MAX_NUM_LCID; lcid++) {
   if (UE_mac_inst[module_idP].scheduling_info.LCGID[lcid] == lcg_id) {
       rlc_status = mac_rlc_status_ind(0, module_idP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO,
-          lcid,
-          0);
+				      lcid,
+				      0);
       if (rlc_status.bytes_in_buffer > 0 ) {
-          sr_pending = TRUE;
-          UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY;
-          UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer);
-          UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer;
-          // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr
-          LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n",
+	sr_pending = TRUE;
+	UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY;
+	UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer);
+	UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer;
+	// UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr
+	LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n",
               module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id,  UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]);
       }
       else
diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h
index 4a7a8ad1cf6..5223c64a78d 100755
--- a/openair2/PHY_INTERFACE/defs.h
+++ b/openair2/PHY_INTERFACE/defs.h
@@ -127,12 +127,11 @@ typedef struct
 
 #ifdef Rel10
     /// Get MCH sdu and corresponding MCS for particular MBSFN subframe
-    MCH_PDU* (*get_mch_sdu)(module_id_t Mod_id, uint8_t CC_id, frame_t frameP,sub_frame_t subframe);
+    MCH_PDU* (*get_mch_sdu)(module_id_t Mod_id, int CC_id, frame_t frameP,sub_frame_t subframe);
 #endif
     // configure the cba rnti at the physical layer 
-    void (*phy_config_cba_rnti)(module_id_t Mod_id,eNB_flag_t eNB_flag, uint8_t index, uint16_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups);
+    void (*phy_config_cba_rnti)(module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, uint16_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups);
     /// get delta mcs for fast UL AMC
-    // uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id,
     int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs);
 
 
diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h
index 7a3aa306da2..d5f2733e652 100644
--- a/openair2/RRC/LITE/defs.h
+++ b/openair2/RRC/LITE/defs.h
@@ -92,6 +92,29 @@
 #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10
 #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11
 #endif
+/*
+#ifdef Rel10
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib12_v920
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib13_v920
+#endif 
+*/
+/*
+// This corrects something generated by asn1c which is different between Rel8 and Rel10
+#ifndef Rel10
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10
+#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11
+#endif
+
+*/
 
 //#include "L3_rrc_defs.h"
 #ifndef NO_RRM
diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c
index 395d9dc4406..a70aed8fdf5 100644
--- a/openair2/RRC/LITE/rrc_eNB.c
+++ b/openair2/RRC/LITE/rrc_eNB.c
@@ -842,7 +842,11 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration(
     DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional;
     DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
     DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
+#ifdef CBA
+    DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms5;//T_Reordering_ms25;
+#else 
     DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms25;
+#endif 
 #endif
 
     DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
diff --git a/openair2/UTIL/LOG/log.c b/openair2/UTIL/LOG/log.c
index d84ade04f19..88d63eeb368 100755
--- a/openair2/UTIL/LOG/log.c
+++ b/openair2/UTIL/LOG/log.c
@@ -235,7 +235,7 @@ int logInit (void)
     g_log->log_component[OTG_GP].interval =  1;
     g_log->log_component[OTG_GP].fd = 0;
     g_log->log_component[OTG_GP].filelog = 0;
-    g_log->log_component[OTG_GP].filelog_name = "/tmp/otg_GP.dat";
+    g_log->log_component[OTG_GP].filelog_name = "/tmp/otg_goodput.dat";
 
     g_log->log_component[OTG_GP_BG].name = "OTG_GP_BG";
     g_log->log_component[OTG_GP_BG].level = LOG_EMERG;
@@ -243,7 +243,7 @@ int logInit (void)
     g_log->log_component[OTG_GP_BG].interval =  1;
     g_log->log_component[OTG_GP_BG].fd = 0;
     g_log->log_component[OTG_GP_BG].filelog = 0;
-    g_log->log_component[OTG_GP_BG].filelog_name = "/tmp/otg_GP_bg.dat";
+    g_log->log_component[OTG_GP_BG].filelog_name = "/tmp/otg_goodput_bg.dat";
 
     g_log->log_component[OTG_JITTER].name = "OTG_JITTER";
     g_log->log_component[OTG_JITTER].level = LOG_EMERG;
diff --git a/openair2/UTIL/MATH/oml.c b/openair2/UTIL/MATH/oml.c
index 76d0c5ba7fe..a62c8473000 100644
--- a/openair2/UTIL/MATH/oml.c
+++ b/openair2/UTIL/MATH/oml.c
@@ -73,7 +73,8 @@ return random;
 double uniform_dist(int min, int max) {
   double uniform_rn;
   uniform_rn = (max - min) * uniform_rng() + min;
-  LOG_T(OTG,"Uniform Random Nb = %lf, (min %d, max %d)\n", uniform_rn, min, max);	
+  //  LOG_T(OTG,"Uniform Random Nb = %lf, (min %d, max %d)\n", uniform_rn, min, max);	
+  //printf("Uniform Random Nb = %lf, (min %d, max %d)\n", uniform_rn, min, max);	
   return uniform_rn;
 }
 
diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h
index 8d5265116f8..dcd61806683 100644
--- a/openair2/UTIL/OCG/OCG.h
+++ b/openair2/UTIL/OCG/OCG.h
@@ -706,6 +706,7 @@ The following diagram is based on graphviz (http://www.graphviz.org/), you need
     char *vcd_file;
     unsigned char eMBMS_active_state;
     unsigned char cba_group_active;
+    unsigned char cba_backoff;
     unsigned char handover_active;
     char * otg_traffic;
     unsigned char otg_bg_traffic_enabled;
diff --git a/openair2/UTIL/OTG/OTGplot b/openair2/UTIL/OTG/OTGplot
index 7318430b396..8dc720a7098 100755
--- a/openair2/UTIL/OTG/OTGplot
+++ b/openair2/UTIL/OTG/OTGplot
@@ -52,7 +52,7 @@ temp=split(strrep(inputf,"\\","/"),"/");
 outputf=split(deblank(temp(size(temp,1),:)),".");
 ylbl=outputf(1,:);
 
-ylbl(1,1)=toupper(ylbl(1,1));
+#ylbl(1,1)=toupper(ylbl(1,1));
 ylabel(ylbl);
 xlabel("Time (ms)");
 
diff --git a/openair2/UTIL/OTG/otg_kpi.c b/openair2/UTIL/OTG/otg_kpi.c
index b8212682fff..689b8b65d30 100644
--- a/openair2/UTIL/OTG/otg_kpi.c
+++ b/openair2/UTIL/OTG/otg_kpi.c
@@ -239,7 +239,7 @@ void kpi_gen() {
   int num_active_source=0;
  
   
-  int dl_ok=0,ul_ok=0;
+  int dl_ok=1,ul_ok=1;
 
 char traffic_type[12];
 char traffic[30];
@@ -637,9 +637,11 @@ if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
   LOG_I(OTG,"[DATA] Estimated E2E JITTER AVG ms= %lf \n", otg_info->average_jitter_dl_e2e/(float)num_active_source );
   LOG_I(OTG,"[DATA] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl*1000*8)/(otg_info->ctime*1024));
   LOG_I(OTG,"[DATA] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl*1000*8)/(otg_info->ctime*1024));
-  LOG_I(OTG,"[DATA] NB lost packet = %d \n", tx_total_pkts_dl - rx_total_pkts_dl );
-  if (tx_total_pkts_dl - rx_total_pkts_dl  <  (int) (tx_total_pkts_dl / 10) ) // below 10% of loss
-    dl_ok=1;
+  LOG_I(OTG,"[DATA] NB lost packet = %d \n", tx_total_pkts_dl - rx_total_pkts_dl);
+  if ( (tx_total_pkts_dl > 0) &&
+       ((10*(tx_total_pkts_dl - rx_total_pkts_dl))  >  tx_total_pkts_dl)) // below 10% of loss
+    dl_ok=0;
+    
  if ((g_otg->background_stats==1)&&(tx_total_pkts_dl_background>0)){
     LOG_I(OTG,"[BACKGROUND] Total packets(TX)= %d \n", tx_total_pkts_dl_background);
     LOG_I(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", tx_total_bytes_dl_background);
@@ -708,8 +710,9 @@ if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
   LOG_I(OTG,"[DATA] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul*1000*8)/(otg_info->ctime*1024));
   LOG_I(OTG,"[DATA] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul*1000*8)/(otg_info->ctime*1024));
   LOG_I(OTG,"[DATA] NB lost packet = %d \n", tx_total_pkts_ul - rx_total_pkts_ul );
-  if ((tx_total_pkts_ul - rx_total_pkts_ul)  < (int)(tx_total_pkts_ul / 10) )
-    ul_ok=1;
+  if ( (tx_total_pkts_ul > 0 ) &&
+       ((10*(tx_total_pkts_ul - rx_total_pkts_ul)) > tx_total_pkts_ul))
+    ul_ok=0;
   
   if ((g_otg->background_stats==1)&&(tx_total_pkts_ul_background>0)){
     LOG_I(OTG,"[BACKGROUND] Total packets(TX)= %d \n", tx_total_pkts_ul_background);
@@ -720,7 +723,7 @@ if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
     LOG_I(OTG,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
 
   }
-	LOG_F(OTG,"**************** TOTAL UL RESULTS ******************\n");
+  LOG_F(OTG,"**************** TOTAL UL RESULTS ******************\n");
   LOG_F(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
   LOG_F(OTG,"[DATA] Total packets(TX)= %d \n", tx_total_pkts_ul);
   LOG_F(OTG,"[DATA] Total packets(RX)= %d \n", rx_total_pkts_ul);
@@ -735,6 +738,7 @@ if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
   LOG_F(OTG,"[DATA] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul*1000*8)/(otg_info->ctime*1024));
   LOG_F(OTG,"[DATA] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul*1000*8)/(otg_info->ctime*1024));
   LOG_F(OTG,"[DATA] NB lost packet = %d \n", tx_total_pkts_ul - rx_total_pkts_ul );
+
   if ((g_otg->background_stats==1)&&(tx_total_pkts_ul_background>0)){
     LOG_F(OTG,"[BACKGROUND] Total packets(TX)= %d \n", tx_total_pkts_ul_background);
     LOG_F(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", tx_total_bytes_ul_background);
@@ -748,7 +752,7 @@ if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
   if ((dl_ok == 1 ) && (ul_ok ==1))
     LOG_I(OTG,"************ DL and UL loss rate below 10 *************\n");
   else 
-    LOG_I(OTG,"************ DL and UL loss rate above 10 *************\n");
+    LOG_I(OTG,"************ DL(%d) and UL(%d) loss rate above 10 *************\n",dl_ok,ul_ok);
 #endif
 }
 
@@ -781,7 +785,7 @@ void add_log_metric(int src, int dst, int ctime, double metric, unsigned int lab
    LOG_E(OTG, "File label unknown %d \n", label);
  }
 
- LOG_F(label,"%d  ", ctime);
+ LOG_F(label,"%d ", ctime);
   for (i=0; i<=(NB_eNB_INST + NB_UE_INST); i++){
     for (j=0; j<=(NB_eNB_INST + NB_UE_INST); j++){
     node_actif=0;
@@ -789,9 +793,9 @@ void add_log_metric(int src, int dst, int ctime, double metric, unsigned int lab
       node_actif=1;
     
     if ((node_actif>0) && ((i==src) && (j==dst)))
-          LOG_F(label,"  %f  ", metric);
+          LOG_F(label,"%f ", metric);
       if  ((node_actif>0) && ((i!=src) || (j!=dst)))
-          LOG_F(label,"  %d  ", 0);
+          LOG_F(label,"%d ", 0);
   }
  }
  LOG_F(label,"%f\n", metric);
@@ -806,14 +810,14 @@ void  add_log_label(unsigned int label, unsigned int * start_log_metric){
 
  if (*start_log_metric==0){
  *start_log_metric=1;
-   LOG_F(label,"Time   ");
+   LOG_F(label,"Time ");
    for (i=0; i<=(NB_eNB_INST + NB_UE_INST); i++){
      for (j=0; j<=(NB_eNB_INST + NB_UE_INST); j++){
        node_actif=0;
           if (g_otg->idt_dist[i][j][0][PE_STATE]>0 )
 	    node_actif++; 
       if (node_actif>0)
-        LOG_F(label,"%d->%d    ", i, j);  
+        LOG_F(label,"%d->%d ", i, j);  
     }
    }
    LOG_F(label,"Aggregated\n");
diff --git a/openair2/UTIL/OTG/otg_rx.c b/openair2/UTIL/OTG/otg_rx.c
index 7aa2b970074..27894598244 100644
--- a/openair2/UTIL/OTG/otg_rx.c
+++ b/openair2/UTIL/OTG/otg_rx.c
@@ -40,7 +40,7 @@
 
 #include "otg_rx.h"
 #include "otg_externs.h"
-#include "../UTIL/MATH/oml.h"
+#include "UTIL/MATH/oml.h"
 #include <math.h>
 #include "otg_form.h"
 #include "otg_kpi.h"
@@ -70,8 +70,7 @@ int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned int size)
   unsigned int seq_num_rx;
   unsigned int nb_loss_pkts;
   unsigned int lost_packet=0;
-  //int header_size;
-
+     
   if (buffer_tx!=NULL) {
     otg_hdr_info_rx = (otg_hdr_info_t *) (&buffer_tx[bytes_read]);
     bytes_read += sizeof (otg_hdr_info_t);
@@ -299,9 +298,10 @@ float owd_const_application_v=owd_const_application()/2;
 	/*measurements are done for the data and background traffic */
 
 	if (g_otg->latency_metric) {
-	  if (g_otg->owd_radio_access==0)
+	  if (g_otg->owd_radio_access==0){
 	    add_log_metric(src, dst, otg_hdr_rx->time, otg_info->rx_pkt_owd[src][dst], OTG_LATENCY);
-	  else {
+	    add_log_metric(src, dst, otg_hdr_rx->time, otg_info->rx_pkt_jitter_e2e[src][dst], OTG_JITTER);
+	  } else {
 	    add_log_metric(src, dst, otg_hdr_rx->time, otg_info->radio_access_delay[src][dst], OTG_LATENCY);
 	    add_log_metric(src, dst, otg_hdr_rx->time, otg_info->rx_pkt_jitter[src][dst], OTG_JITTER);
 	  }
diff --git a/openair2/UTIL/OTG/otg_tx.c b/openair2/UTIL/OTG/otg_tx.c
index 9864d8f75d5..9519ecebbc0 100644
--- a/openair2/UTIL/OTG/otg_tx.c
+++ b/openair2/UTIL/OTG/otg_tx.c
@@ -413,14 +413,14 @@ int check_data_transmit(int src,int dst, int app, int ctime){
 	  //g_ otg->flow_start_flag[src][dst][app]=1;
 	  LOG_T(OTG,"Flow start time not reached : do not generate packet for this pair of src=%d, dst =%d, start %d < ctime %d \n", 
 		src, dst,g_otg->flow_start[src][dst][app], ctime); 
-	  size+=0;	
+	  size=0;	
 	}else if (g_otg->flow_duration[src][dst][app] + g_otg->flow_start[src][dst][app] < ctime ){
 	  LOG_T(OTG,"Flow duration reached: do not generate packet for this pair of src=%d, dst =%d, duration %d < ctime %d + start %d\n", 
 		src, dst,g_otg->flow_duration[src][dst][app], ctime, g_otg->flow_start[src][dst][app]); 
-	  size+=0;	
+	  size=0;	
 	}else if ((g_otg->application_type[src][dst][app]==0)&&(g_otg->idt_dist[src][dst][app][PE_STATE]==0)){  
 	  LOG_T(OTG,"Do not generate packet for this pair of src=%d, dst =%d, IDT zero and app %d not specificed\n", src, dst, app); 
-	  size+=0;	 
+	  size=0;	 
 	}
 
 	else if ((g_otg->application_type[src][dst][app] >0) || (g_otg->idt_dist[src][dst][app][PE_STATE] > 0)) {
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 652cc96b12f..9e1f76c2642 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -2958,7 +2958,7 @@ int main(int argc, char **argv) {
   //  int *eNB_thread_status_rx[10],*eNB_thread_status_tx[10];
 #endif
   int i,aa,card;
-#if defined (XFORMS) || defined (EMOS)
+#if defined (XFORMS) || defined (EMOS) || defined(EXMIMO)
   void *status;
 #endif
   
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_0.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_0.xml
index 57320193933..3b41cc8ca37 100644
--- a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_0.xml
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_0.xml
@@ -125,10 +125,8 @@
 
 		<PERFORMANCE>
 			<METRICS>
-				<THROUGHPUT>1</THROUGHPUT>
-				<LATENCY>1</LATENCY>
-				<JITTER>1</JITTER>
-				<SIGNALLING_OVERHEAD>1</SIGNALLING_OVERHEAD>
+				<THROUGHPUT>enable</THROUGHPUT>
+				<LATENCY>disable</LATENCY>
 			      </METRICS>
 
 			<LAYER>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_11.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_11.xml
index f19fc68c0bc..189ecebeb72 100644
--- a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_11.xml
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_11.xml
@@ -107,9 +107,9 @@
     <EMULATION_TIME_ms>0</EMULATION_TIME_ms> <!--set to infinity--> 
     
     <PERFORMANCE_METRICS>
-      <THROUGHPUT>1</THROUGHPUT>
-      <LATENCY>1</LATENCY> <!-- include both OWD and RTT-->
-      <LOSS_RATE>1</LOSS_RATE>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY> <!-- include both OWD and RTT-->
+      <LOSS_RATE>enable</LOSS_RATE>
     </PERFORMANCE_METRICS>
     <LOG>  <!-- set the global log level -->
       <LEVEL>warning</LEVEL>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_120.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_120.xml
new file mode 100644
index 00000000000..8949160a4d1
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_120.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>1</IDT_MIN_ms>  
+      <IDT_MAX_ms>10</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>10</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>100</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_121.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_121.xml
new file mode 100644
index 00000000000..6f554aa2e6e
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_121.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>1</IDT_MIN_ms>  
+      <IDT_MAX_ms>10</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>100</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>500</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_122.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_122.xml
new file mode 100644
index 00000000000..19a10891df2
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_122.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>10</IDT_MIN_ms>  
+      <IDT_MAX_ms>100</IDT_MAX_ms>  
+      <SIZE_DIST>unifrom</SIZE_DIST>   
+      <SIZE_MIN_byte>10</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>100</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_123.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_123.xml
new file mode 100644
index 00000000000..00dc2a2c415
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_123.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>10</IDT_MIN_ms>  
+      <IDT_MAX_ms>100</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>100</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>1000</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_124.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_124.xml
new file mode 100644
index 00000000000..b6b208eb15f
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_124.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>10</IDT_MIN_ms>  
+      <IDT_MAX_ms>100</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>1000</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>6000</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_125.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_125.xml
new file mode 100644
index 00000000000..a19af48d887
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_125.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>100</IDT_MIN_ms>  
+      <IDT_MAX_ms>1000</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>10</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>100</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_126.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_126.xml
new file mode 100644
index 00000000000..e66a5a6211f
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_126.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>100</IDT_MIN_ms>  
+      <IDT_MAX_ms>1000</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>100</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>1000</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_127.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_127.xml
new file mode 100644
index 00000000000..86ac3c275b3
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_127.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>100</IDT_MIN_ms>  
+      <IDT_MAX_ms>1000</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>1000</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>9000</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_128.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_128.xml
new file mode 100644
index 00000000000..dd9dc1a453f
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_128.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>1000</IDT_MIN_ms>  
+      <IDT_MAX_ms>10000</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>10</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>100</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_129.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_129.xml
new file mode 100644
index 00000000000..309ebe5fedd
--- /dev/null
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_129.xml
@@ -0,0 +1,105 @@
+<OAI_EMULATION>
+  <ENVIRONMENT_SYSTEM_CONFIG>
+    <FADING>
+      <LARGE_SCALE>urban</LARGE_SCALE>
+      <FREE_SPACE_MODEL_PARAMETERS>
+	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
+      </FREE_SPACE_MODEL_PARAMETERS>
+      <SMALL_SCALE>AWGN</SMALL_SCALE>
+    </FADING>
+    <WALL_PENETRATION_LOSS_dB>5</WALL_PENETRATION_LOSS_dB>
+    <SYSTEM_BANDWIDTH_MB>7.68</SYSTEM_BANDWIDTH_MB>
+    <SYSTEM_FREQUENCY_GHz>1.9</SYSTEM_FREQUENCY_GHz>
+    <ANTENNA>
+      <eNB_ANTENNA>
+	<RX_NOISE_LEVEL_dB>5</RX_NOISE_LEVEL_dB>
+	<NUMBER_OF_SECTORS>1</NUMBER_OF_SECTORS>
+	<BEAM_WIDTH_dB>1.13</BEAM_WIDTH_dB>
+	<ANTENNA_GAIN_dBi>16</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>40</TX_POWER_dBm>
+      </eNB_ANTENNA>
+      <UE_ANTENNA>
+	<RX_NOISE_LEVEL_dB>1</RX_NOISE_LEVEL_dB>
+	<ANTENNA_GAIN_dBi>5</ANTENNA_GAIN_dBi>
+	<TX_POWER_dBm>20</TX_POWER_dBm>
+      </UE_ANTENNA>
+    </ANTENNA>
+  </ENVIRONMENT_SYSTEM_CONFIG>
+
+  <TOPOLOGY_CONFIG>	
+    <AREA>			
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
+    </AREA>
+    <MOBILITY> 
+      <UE_MOBILITY>
+	<RANDOM_UE_DISTRIBUTION>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
+	</RANDOM_UE_DISTRIBUTION>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
+      </UE_MOBILITY>
+      <eNB_MOBILITY>
+	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
+	<RANDOM_eNB_DISTRIBUTION>
+	  <NUMBER_OF_CELLS>1</NUMBER_OF_CELLS>
+	</RANDOM_eNB_DISTRIBUTION>
+	<eNB_MOBILITY_TYPE>STATIC</eNB_MOBILITY_TYPE>
+      </eNB_MOBILITY>
+    </MOBILITY>
+  </TOPOLOGY_CONFIG>
+
+  <APPLICATION_CONFIG>
+    <!-- DL 
+    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>0</SOURCE_ID> 
+   
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>1:9</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+    -->
+    <!-- UL --> 
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
+      <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+    </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>55000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>uniform</IDT_DIST>  
+      <IDT_MIN_ms>1000</IDT_MIN_ms>  
+      <IDT_MAX_ms>10000</IDT_MAX_ms>  
+      <SIZE_DIST>uniform</SIZE_DIST>   
+      <SIZE_MIN_byte>100</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>1000</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
+  </APPLICATION_CONFIG>
+
+  <EMULATION_CONFIG>
+    <EMULATION_TIME_ms>60000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <CURVE>disable</CURVE>
+    <PERFORMANCE_METRICS>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
+    </PERFORMANCE_METRICS>
+    <LOG>  <!-- set the global log level -->
+      <LEVEL>info</LEVEL>
+      <VERBOSITY>low</VERBOSITY>
+    </LOG>		
+    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    
+  </EMULATION_CONFIG>
+ 
+  <PROFILE>CBA_1</PROFILE>	
+
+</OAI_EMULATION>
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_22.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_22.xml
index 3db1aea9ab4..90685f8a605 100644
--- a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_22.xml
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_22.xml
@@ -4,7 +4,7 @@
       <LARGE_SCALE>urban</LARGE_SCALE>
       <FREE_SPACE_MODEL_PARAMETERS>
 	<PATHLOSS_EXPONENT>2</PATHLOSS_EXPONENT>
-	<PATHLOSS_0_dB>-108</PATHLOSS_0_dB><!--pathloss at 1km -->
+	<PATHLOSS_0_dB>-100</PATHLOSS_0_dB><!--pathloss at 1km -->
       </FREE_SPACE_MODEL_PARAMETERS>
       <SMALL_SCALE>AWGN</SMALL_SCALE>
     </FADING>
@@ -29,15 +29,15 @@
 
   <TOPOLOGY_CONFIG>	
     <AREA>			
-      <X_m>500</X_m>
-      <Y_m>500</Y_m>	
+      <X_m>2000</X_m>
+      <Y_m>2000</Y_m>	
     </AREA>
     <MOBILITY> 
       <UE_MOBILITY>
 	<RANDOM_UE_DISTRIBUTION>
-	  <NUMBER_OF_NODES>1</NUMBER_OF_NODES>
+	  <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
 	</RANDOM_UE_DISTRIBUTION>
-	<UE_MOBILITY_TYPE>RWP</UE_MOBILITY_TYPE>
+	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>
       </UE_MOBILITY>
       <eNB_MOBILITY>
 	<eNB_INITIAL_DISTRIBUTION>random</eNB_INITIAL_DISTRIBUTION>
@@ -59,27 +59,44 @@
     </PREDEFINED_TRAFFIC>
     -->
     <!-- UL --> 
-    <PREDEFINED_TRAFFIC>
-      <SOURCE_ID>1</SOURCE_ID> <!-- valid formats are "n:m" and "n,m" and "n" -->
-      <FLOW_START_ms>200</FLOW_START_ms> <!-- indicates the start time of the app or the actual duration of the traffic-->
+<!--    <PREDEFINED_TRAFFIC>
+      <SOURCE_ID>1</SOURCE_ID> 
+      <FLOW_START_ms>200</FLOW_START_ms> 
       <FLOW_DURATION_ms>600</FLOW_DURATION_ms>
-      <APPLICATION_TYPE>bcbr</APPLICATION_TYPE> 
-      <DESTINATION_ID>0</DESTINATION_ID> <!-- valid formats are "n:m" and "n,m" and "n"  -->
+      <APPLICATION_TYPE>scbr</APPLICATION_TYPE> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
     </PREDEFINED_TRAFFIC>
+-->
+     <CUSTOMIZED_TRAFFIC>	 
+      <SOURCE_ID>1:7</SOURCE_ID> 		
+      <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> 
+      <FLOW_START_ms>0</FLOW_START_ms> 
+      <FLOW_DURATION_ms>8000</FLOW_DURATION_ms>
+      <IP_VERSION>ipv4</IP_VERSION> 
+      <DESTINATION_ID>0</DESTINATION_ID> 
+      <IDT_DIST>fixed</IDT_DIST>  
+      <IDT_MIN_ms>30</IDT_MIN_ms>  
+      <IDT_MAX_ms>2000</IDT_MAX_ms>  
+      <SIZE_DIST>fixed</SIZE_DIST>   
+      <SIZE_MIN_byte>100</SIZE_MIN_byte>  
+      <SIZE_MAX_byte>200</SIZE_MAX_byte>  
+    </CUSTOMIZED_TRAFFIC>
+
   </APPLICATION_CONFIG>
 
   <EMULATION_CONFIG>
-    <EMULATION_TIME_ms>1000</EMULATION_TIME_ms> <!--set to infinity--> 
+    <EMULATION_TIME_ms>10000</EMULATION_TIME_ms> <!--set to infinity--> 
     <CURVE>disable</CURVE>
     <PERFORMANCE_METRICS>
-      <THROUGHPUT>1</THROUGHPUT>
-      <LATENCY>1</LATENCY>
+      <THROUGHPUT>enable</THROUGHPUT>
+      <LATENCY>enable</LATENCY>
+      <LOSS_RATE>enable</LOSS_RATE>
     </PERFORMANCE_METRICS>
     <LOG>  <!-- set the global log level -->
-      <LEVEL>debug</LEVEL>
-      <VERBOSITY>low</VERBOSITY>
+      <LEVEL>trace</LEVEL>
+      <VERBOSITY>medium</VERBOSITY>
     </LOG>		
-    <SEED_VALUE>2013</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
+    <SEED_VALUE>2014</SEED_VALUE>	 <!-- value 0 means randomly generated by OAI -->
     
   </EMULATION_CONFIG>
  
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_26.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_26.xml
index 0cadccd9768..e5bf79f26dd 100755
--- a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_26.xml
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_26.xml
@@ -20,7 +20,7 @@
     <MOBILITY> 
       <UE_MOBILITY>
 	<RANDOM_UE_DISTRIBUTION>
-    <NUMBER_OF_NODES>9</NUMBER_OF_NODES>
+    <NUMBER_OF_NODES>7</NUMBER_OF_NODES>
 	</RANDOM_UE_DISTRIBUTION>
 	<UE_MOBILITY_TYPE>STATIC</UE_MOBILITY_TYPE>  <!-- STATIC --> 
       </UE_MOBILITY>
@@ -40,7 +40,7 @@
       <SOURCE_ID>0</SOURCE_ID> 		
       <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> <!-- OPTIONS: tcp (default), udp -->
       <IP_VERSION>ipv6</IP_VERSION> <!-- OPTIONS: ipv4 (default), ipv6 -->
-      <DESTINATION_ID>1:9</DESTINATION_ID>
+      <DESTINATION_ID>1:7</DESTINATION_ID>
       <FLOW_START_ms>1000</FLOW_START_ms> <!-- indicates the start time of the app or the actual duration of the traffic-->
       <FLOW_DURATION_ms>10000</FLOW_DURATION_ms> <!-- indicates the start time of the app or the actual duration of the traffic-->
 
@@ -54,11 +54,11 @@
    </CUSTOMIZED_TRAFFIC>
 
    <CUSTOMIZED_TRAFFIC>	 
-      <SOURCE_ID>1:9</SOURCE_ID> 		
+      <SOURCE_ID>1:7</SOURCE_ID> 		
       <TRANSPORT_PROTOCOL>udp</TRANSPORT_PROTOCOL> <!-- OPTIONS: tcp (default), udp -->
       <IP_VERSION>ipv6</IP_VERSION> <!-- OPTIONS: ipv4 (default), ipv6 -->
       <DESTINATION_ID>0</DESTINATION_ID>
-      <FLOW_START_ms>1000</FLOW_START_ms> <!-- indicates the start time of the app or the actual duration of the traffic-->
+      <FLOW_START_ms>0</FLOW_START_ms> <!-- indicates the start time of the app or the actual duration of the traffic-->
       <FLOW_DURATION_ms>10000</FLOW_DURATION_ms> <!-- indicates the start time of the app or the actual duration of the traffic-->
       <BACKGROUND_TRAFFIC>disable</BACKGROUND_TRAFFIC> <!-- options: enable, disable. If enable, it generates a background traffic corresponding to the traffic direction-->
       <IDT_DIST>uniform</IDT_DIST>  <!-- available distributions: none (default), uniform, poission, gaussian, exponential,pareto, cauchy,fixed, weibull, gammav-->
diff --git a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_60.xml b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_60.xml
index 85c356f4253..2b853500972 100644
--- a/targets/SIMU/EXAMPLES/OSD/WEBXML/template_60.xml
+++ b/targets/SIMU/EXAMPLES/OSD/WEBXML/template_60.xml
@@ -81,10 +81,10 @@
 	<BACKGROUND_STATS>enable</BACKGROUND_STATS>
 	<CURVE>enable</CURVE>
 	<PERFORMANCE_METRICS>
-		    <THROUGHPUT>1</THROUGHPUT>
-		    <LATENCY>1</LATENCY>
-		    <LOSS_RATE>1</LOSS_RATE>
-		    <OWD_RADIO_ACESS>1</OWD_RADIO_ACESS>
+		    <THROUGHPUT>enable</THROUGHPUT>
+		    <LATENCY>enable</LATENCY>
+		    <LOSS_RATE>enable</LOSS_RATE>
+		    <OWD_RADIO_ACESS>enable</OWD_RADIO_ACESS>
 	</PERFORMANCE_METRICS>
 	<LOG>  <!-- set the global log level -->
       		<LEVEL>debug</LEVEL>
diff --git a/targets/SIMU/USER/Makefile b/targets/SIMU/USER/Makefile
index fcb02176614..ebc6cd84f53 100644
--- a/targets/SIMU/USER/Makefile
+++ b/targets/SIMU/USER/Makefile
@@ -46,6 +46,7 @@ endif
 
 ifndef OPENAIR_EMU
 export OPENAIR_EMU=1
+CFLAGS += -DOAISIM
 endif
 
 ifdef EMOS
@@ -475,11 +476,11 @@ otg_latency_bg:
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_latency_bg.dat" "[$(COL1):$(COL2)]"
 otg_gp:
 	export TITLE="Application Goodput(Kb/s)"
-	cp /tmp/otg_GP.dat /tmp/goodput.dat
+	cp /tmp/otg_goodput.dat /tmp/goodput.dat
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/goodput.dat" "[$(COL1):$(COL2)]"
 otg_gp_bg:
 	export TITLE="Background Goodput(Kb/s)"
-	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_GP_bg.dat" "[$(COL1):$(COL2)]"
+	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_goodput_bg.dat" "[$(COL1):$(COL2)]"
 otg_jitter:
 	export TITLE="Aplication Jitter(ms)"
 	$(OPENAIR2_DIR)/UTIL/OTG/OTGplot "/tmp/otg_jitter.dat" "[$(COL1):$(COL2)]"
diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c
index f5771187634..94f2b1529c2 100644
--- a/targets/SIMU/USER/oaisim_config.c
+++ b/targets/SIMU/USER/oaisim_config.c
@@ -168,8 +168,8 @@ void init_oai_emulation(void) {
     oai_emulation.application_config.predefined_traffic.application_type[i] = "no_predefined_traffic";
     oai_emulation.application_config.predefined_traffic.background[i] = "disable";
     oai_emulation.application_config.predefined_traffic.aggregation_level[i] = 1;
-    oai_emulation.application_config.predefined_traffic.flow_start[i] = (i+1)*25;
-    oai_emulation.application_config.predefined_traffic.flow_duration[i] = 0xffff;
+    oai_emulation.application_config.predefined_traffic.flow_start[i] = 0;
+    oai_emulation.application_config.predefined_traffic.flow_duration[i] = 1000;//uniform_dist((i+1)*100,0xffff);
     
     oai_emulation.application_config.predefined_traffic.destination_id[i] = 0;
     
@@ -180,8 +180,8 @@ void init_oai_emulation(void) {
     oai_emulation.application_config.customized_traffic.m2m[i] = "disable";
     oai_emulation.application_config.customized_traffic.ip_version[i] = "ipv4";
     oai_emulation.application_config.customized_traffic.aggregation_level[i] = 1;
-    oai_emulation.application_config.customized_traffic.flow_start[i] = (i+1)*25;
-    oai_emulation.application_config.customized_traffic.flow_duration[i] = 100;
+    oai_emulation.application_config.customized_traffic.flow_start[i] = 0;// (i+1)*30;
+    oai_emulation.application_config.customized_traffic.flow_duration[i] = 1000;// uniform_dist((i+1)*100,0xffff);
     oai_emulation.application_config.customized_traffic.idt_dist[i] = "uniform";
     oai_emulation.application_config.customized_traffic.idt_min_ms[i] = 100;
     oai_emulation.application_config.customized_traffic.idt_max_ms[i] = 1000;
@@ -238,7 +238,7 @@ void init_oai_emulation(void) {
   
   
   // phy related params :
-  oai_emulation.info.n_frames=0xffff; // number of frames simulated by default
+  oai_emulation.info.n_frames=MAX_FRAME_NUMBER; // number of frames simulated by default
   oai_emulation.info.n_frames_flag=0; // if set, then let the emulation goes to infinity
   
   //status
@@ -267,6 +267,7 @@ void init_oai_emulation(void) {
   oai_emulation.info.oeh_enabled=0;
 
   oai_emulation.info.cba_group_active=0;
+  oai_emulation.info.cba_backoff=30;
   oai_emulation.info.eMBMS_active_state=0;
   oai_emulation.info.handover_active=0;
   oai_emulation.info.omg_model_enb=STATIC; //default to static mobility model
@@ -610,7 +611,7 @@ int ocg_config_topo(void) {
 	  if (oai_emulation.topology_config.mobility.UE_mobility.sumo_config.end > 0 )
 	    omg_param_list[i].sumo_end = oai_emulation.topology_config.mobility.UE_mobility.sumo_config.end;
 	  else
-	    omg_param_list[i].sumo_end = (oai_emulation.info.n_frames_flag == 1 ) ?  oai_emulation.info.n_frames : 1024 ; // fixme: the else case is infinity
+	    omg_param_list[i].sumo_end = (oai_emulation.info.n_frames_flag == 1 ) ?  oai_emulation.info.n_frames : MAX_FRAME_NUMBER ; // fixme: the else case is infinity
 
 	  omg_param_list[i].sumo_step = oai_emulation.topology_config.mobility.UE_mobility.sumo_config.step=1; //  1000ms
 	  omg_param_list[i].sumo_host = (char*) malloc(40);
@@ -695,8 +696,11 @@ int ocg_config_app(void){
 	g_otg->trans_proto[i][j][k]=map_str_to_int(otg_transport_protocol_names, oai_emulation.application_config.customized_traffic.transport_protocol[i]);
 	g_otg->application_type[i][j][k]=map_str_to_int(otg_app_type_names, "no_predefined_traffic");
 	g_otg->aggregation_level[i][j][k]=oai_emulation.application_config.customized_traffic.aggregation_level[i];
-	g_otg->flow_start[i][j][k]=oai_emulation.application_config.customized_traffic.flow_start[i];
-	g_otg->flow_duration[i][j][k]=oai_emulation.application_config.customized_traffic.flow_duration[i];
+	
+	g_otg->flow_start[i][j][k]=flow_start_time(i,j,oai_emulation.info.n_frames,
+						   oai_emulation.application_config.customized_traffic.flow_start[i+j],
+						   oai_emulation.application_config.customized_traffic.flow_duration[i+j]);
+	g_otg->flow_duration[i][j][k]=oai_emulation.application_config.customized_traffic.flow_duration[i+j];
 	
 	for (l=0; l<MAX_NUM_TRAFFIC_STATE; l++){
 	  g_otg->idt_dist[i][j][k][l]=map_str_to_int(otg_distribution_names, "no_customized_traffic");
@@ -765,7 +769,7 @@ int ocg_config_app(void){
 
 	      g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names,oai_emulation.application_config.predefined_traffic.background[predefined_traffic_config_index]);
 	      g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.aggregation_level[predefined_traffic_config_index];
-	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index];
+	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=	flow_start_time(source_id_index,destination_id_index, oai_emulation.info.n_frames,oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index],oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]);	 
 	      g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index];
 
 	      LOG_I(OTG,"predef (1):: OCG_config_OTG [MAX UE=%d] [MAX eNB=%d]: FORMAT (%d:%d) source = %d, dest = %d, Application ID = %d background %d, Aggregation=%d , m2m= %d, flow start/duration %d/%d \n",
@@ -789,7 +793,7 @@ int ocg_config_app(void){
 	    g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_app_type_names, oai_emulation.application_config.predefined_traffic.application_type[predefined_traffic_config_index]);
 	    g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names,oai_emulation.application_config.predefined_traffic.background[predefined_traffic_config_index]);
 	    g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.aggregation_level[predefined_traffic_config_index];
-	    g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index];
+	    g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index, destination_id_index,oai_emulation.info.n_frames,oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index],oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]);	 
 	    g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index];
 	    g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	  }
@@ -819,7 +823,7 @@ int ocg_config_app(void){
 	      g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_app_type_names, oai_emulation.application_config.predefined_traffic.application_type[predefined_traffic_config_index]);
 	      g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] =map_str_to_int(switch_names,oai_emulation.application_config.predefined_traffic.background[predefined_traffic_config_index]);
 	      g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.aggregation_level[predefined_traffic_config_index];
-	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index];
+	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index,destination_id_index,oai_emulation.info.n_frames,oai_emulation.application_config.predefined_traffic.flow_start[predefined_traffic_config_index],oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index]);	 
 	      g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.predefined_traffic.flow_duration[predefined_traffic_config_index];
 	      
 	      LOG_I(OTG,"predef (2):: OCG_config_OTG: [MAX UE=%d] [MAX eNB=%d]: FORMAT (%d:%d) source = %d, dest = %d, Application ID %d, type %d, Background=%d, Aggregation=%d, m2m=%d, start/duration %d/%d\n", 
@@ -880,9 +884,10 @@ int ocg_config_app(void){
 	      g_otg->trans_proto[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_transport_protocol_names, oai_emulation.application_config.customized_traffic.transport_protocol[customized_traffic_config_index]);
 	      g_otg->ip_v[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_ip_version_names, oai_emulation.application_config.customized_traffic.ip_version[customized_traffic_config_index]);
 	      g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.aggregation_level[customized_traffic_config_index];
-	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index];
+	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]= flow_start_time(source_id_index,destination_id_index,oai_emulation.info.n_frames,oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index],oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]);	 
 	      g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index];
 	      g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]);
+	      //  printf("[OTG] config index %d dist %s\n", customized_traffic_config_index,oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]);
 	      g_otg->idt_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] =  oai_emulation.application_config.customized_traffic.idt_min_ms[customized_traffic_config_index];
 	      g_otg->idt_max[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] =  oai_emulation.application_config.customized_traffic.idt_max_ms[customized_traffic_config_index];
 	      g_otg->idt_std_dev[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] =  oai_emulation.application_config.customized_traffic.idt_standard_deviation[customized_traffic_config_index];
@@ -911,8 +916,15 @@ int ocg_config_app(void){
 	      g_otg->holding_time_off_pe[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.holding_time_off_pe[customized_traffic_config_index];
 	      g_otg->holding_time_pe_off[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.holding_time_pe_off[customized_traffic_config_index];
 
-	      LOG_I(OTG,"customized:: OCG_config_OTG: (1) FORMAT (%d:%d) source = %d, dest = %d, Application = %d, state %d, background %d IDT DIST %d \n", sid_start, sid_end, source_id_index, destination_id_index, g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], state,  g_otg->background[source_id_index][destination_id_index],  g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state]);
-g_otg->application_idx[source_id_index][destination_id_index]+=1;
+	      LOG_I(OTG,"customized:: OCG_config_OTG: (1) FORMAT (%d:%d) source = %d, dest = %d, Application = %d, state %d, background %d IDT DIST %d start/duration %d/%d\n", sid_start, sid_end, source_id_index, destination_id_index, 
+		    g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]], 
+		    state,
+		    g_otg->background[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]],
+		    g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state],
+		    g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]],
+		    g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]);
+	      
+	      g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	    }
 	  }
 	}
@@ -930,7 +942,7 @@ g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	    g_otg->trans_proto[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_transport_protocol_names, oai_emulation.application_config.customized_traffic.transport_protocol[customized_traffic_config_index]);
 	    g_otg->ip_v[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_ip_version_names, oai_emulation.application_config.customized_traffic.ip_version[customized_traffic_config_index]);
 	    g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.aggregation_level[customized_traffic_config_index];
-	    g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index];
+	    g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index,destination_id_index,oai_emulation.info.n_frames,oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index],oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]);	 
 	    g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index];
 	    g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]);
 	    g_otg->idt_min[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] =  oai_emulation.application_config.customized_traffic.idt_min_ms[customized_traffic_config_index];
@@ -962,7 +974,9 @@ g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	    g_otg->holding_time_pe_off[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.holding_time_pe_off[customized_traffic_config_index];
 
 
-	    LOG_I(OTG,"customized:: OCG_config_OTG: (2) FORMAT (%d:%d) source = %d, dest = %d, dist type for size = %d\n", source_id_start, source_id_end, source_id_index, destination_id_index, g_otg->size_dist[source_id_index][destination_id_index][0]);
+	    LOG_I(OTG,"customized:: OCG_config_OTG: (2) FORMAT (%d:%d) source = %d, dest = %d, dist type for size = %d start/duration %d/%d\n", source_id_start, source_id_end, source_id_index, destination_id_index, g_otg->size_dist[source_id_index][destination_id_index][0],
+		  g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]],
+		  g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]);
 	    per_source_id = strtok(NULL, comma);
 	    g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	  }
@@ -1000,7 +1014,7 @@ g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	      g_otg->ip_v[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]] = map_str_to_int(otg_ip_version_names, oai_emulation.application_config.customized_traffic.ip_version[customized_traffic_config_index]);
 	      g_otg->aggregation_level[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.aggregation_level[customized_traffic_config_index];
 
-	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index];
+	      g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=flow_start_time(source_id_index,destination_id_index, oai_emulation.info.n_frames,oai_emulation.application_config.customized_traffic.flow_start[customized_traffic_config_index],oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index]);	 
 	      g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.flow_duration[customized_traffic_config_index];
 
 	      g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state] = map_str_to_int(otg_distribution_names, oai_emulation.application_config.customized_traffic.idt_dist[customized_traffic_config_index]);
@@ -1033,19 +1047,22 @@ g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	      g_otg->holding_time_pe_off[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]=oai_emulation.application_config.customized_traffic.holding_time_pe_off[customized_traffic_config_index];
 
 	      LOG_I(OTG,"OCG_config_OTG (single node config): source = %d, dest = %d\n", source_id_index, destination_id_index);
-	      LOG_I(OTG,"customized:: OCG_config_OTG:(3) FORMAT (%d:%d) source = %d, dest = %d, Application = %d, IDT dist %d \n", 
+	      LOG_I(OTG,"customized:: OCG_config_OTG:(3) FORMAT (%d:%d) source = %d, dest = %d, Application = %d, IDT dist %d flow start %d duration %d \n", 
 		    did_start, did_end, source_id_index, destination_id_index, 
 		    g_otg->application_type[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]],
-		    g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state]);
+		    g_otg->idt_dist[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]][state],
+		    g_otg->flow_start[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]],
+		    g_otg->flow_duration[source_id_index][destination_id_index][g_otg->application_idx[source_id_index][destination_id_index]]);
 	      g_otg->application_idx[source_id_index][destination_id_index]+=1;
 
 	    }
 	  }
 	}
-
       }
     }
-  }
+  } 
+  
+
   if ((oai_emulation.info.max_predefined_traffic_config_index == 0)  &&
       (oai_emulation.info.max_customized_traffic_config_index == 0) &&
       (oai_emulation.info.otg_enabled==1)){  // OCG not used to configure OTG, but -T option is used, so config here
@@ -1058,6 +1075,12 @@ g_otg->application_idx[source_id_index][destination_id_index]+=1;
 	  g_otg->application_type[i][j][k] = map_str_to_int(otg_app_type_names, oai_emulation.info.otg_traffic);
 	  g_otg->background[i][j][k]=oai_emulation.info.otg_bg_traffic_enabled;
 	  g_otg->packet_gen_type=SUBSTRACT_STRING;
+	  g_otg->flow_start[i][j][k]=flow_start_time(i,j,oai_emulation.info.n_frames,
+						     oai_emulation.application_config.customized_traffic.flow_start[i+j],
+						     oai_emulation.application_config.customized_traffic.flow_duration[i+j]);
+	  g_otg->flow_duration[i][j][k]=oai_emulation.application_config.customized_traffic.flow_duration[i+j];
+	  LOG_I(OTG,"predefined traffic:: source = %d, dest = %d, Application = %d, start %d duration %d \n", 
+		i,j, g_otg->application_type[i][j][k],g_otg->flow_start[i][j][k],g_otg->flow_duration[i][j][k]);
 	}
       }
     }
@@ -1077,7 +1100,32 @@ g_otg->application_idx[source_id_index][destination_id_index]+=1;
   return 1;
 }
 
-
+int flow_start_time(int sid, int did, uint32_t n_frames, uint32_t start, uint32_t duration){
+  
+  int offset0=uniform_dist(1,10);
+  int offset1=uniform_dist(10,100);
+  int offset2=uniform_dist(100,1000);
+  int interval = 300;
+  int flow_start_margin_1=0;
+  int flow_start_margin_2=0;
+  
+  // return user-defined flow start time
+  if (start > 0 )
+    return start;
+ 
+ //determine the flow start time
+  start = (sid+did+1)*interval;
+  flow_start_margin_1 = 10*n_frames - (start + offset1 + duration);
+  flow_start_margin_2 = 10*n_frames - (start + offset2 + duration);
+  //LOG_I(OTG,"nframes %d start %d margin_1 %d margin_2 %d\n",n_frames, start,flow_start_margin_1, flow_start_margin_2);
+  if (flow_start_margin_2 > 0 )
+    return uniform_dist(start, start+offset2);
+  else if (flow_start_margin_1 > 0 )
+    return uniform_dist(start, start+offset1);
+  else 
+    return uniform_dist(start, start+offset0);
+ 
+}
 
 
 int ocg_config_emu(void){
diff --git a/targets/SIMU/USER/oaisim_config.h b/targets/SIMU/USER/oaisim_config.h
index 01d4771b9ac..d592aff91c6 100644
--- a/targets/SIMU/USER/oaisim_config.h
+++ b/targets/SIMU/USER/oaisim_config.h
@@ -88,5 +88,7 @@ int ocg_config_omg(void);
 int ocg_config_topo(void);
 int ocg_config_app(void);
 int ocg_config_emu(void);
+
+int flow_start_time(int sid, int did, uint32_t n_frames, uint32_t start, uint32_t duration);
 /* @}*/
 
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 6ebc33c91c1..049d2de9a70 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -116,7 +116,7 @@ node_list*     ue_node_list          = NULL;
 node_list*     enb_node_list         = NULL;
 int           omg_period            = 0;
 int           pdcp_period           = 0;
-
+int           cba_backoff           = 30;
 // time calibration for soft realtime mode
 struct timespec time_spec;
 unsigned long   time_last           = 0;
@@ -191,6 +191,8 @@ void get_simulation_options(int argc, char *argv[]) {
     LONG_OPTION_UE_MIHF_ID,
 
     LONG_OPTION_MALLOC_TRACE_ENABLED,
+
+    LONG_OPTION_CBA_BACKOFF_TIMER,
   };
 
   static struct option long_options[] = {
@@ -219,6 +221,9 @@ void get_simulation_options(int argc, char *argv[]) {
       {"ue-mihf-id",             required_argument, 0, LONG_OPTION_UE_MIHF_ID},
 
       {"malloc-trace-enabled",   no_argument,       0, LONG_OPTION_MALLOC_TRACE_ENABLED},
+
+      {"cba-backoff",            required_argument, 0, LONG_OPTION_CBA_BACKOFF_TIMER},
+
       {NULL, 0, NULL, 0}
   };
 
@@ -240,119 +245,125 @@ void get_simulation_options(int argc, char *argv[]) {
 
       case LONG_OPTION_OMG_PERIOD:
         if (optarg) {
-            omg_period = atoi(optarg);
+	  omg_period = atoi(optarg);
             printf("OMG period is %d\n", omg_period);
         }
         break;
       
       case LONG_OPTION_OEH_ENABLED:
-	      oai_emulation.info.oeh_enabled = 1;
-	    break;
+	oai_emulation.info.oeh_enabled = 1;
+	break;
 
       case LONG_OPTION_MALLOC_TRACE_ENABLED:
     	 mtrace();
-	     break;
+	 break;
+
+      case LONG_OPTION_CBA_BACKOFF_TIMER:
+	oai_emulation.info.cba_backoff=atoi(optarg);
+	cba_backoff=atoi(optarg);
+	printf("setting CBA backoff to %d\n", cba_backoff);
+	break;
 
 #if defined(ENABLE_RAL)
       case LONG_OPTION_ENB_RAL_LISTENING_PORT:
         if (optarg) {
-            g_conf_enb_ral_listening_port = strdup(optarg);
-            printf("eNB RAL listening port is %s\n", g_conf_enb_ral_listening_port);
+	  g_conf_enb_ral_listening_port = strdup(optarg);
+	  printf("eNB RAL listening port is %s\n", g_conf_enb_ral_listening_port);
         }
         break;
-
+	
       case LONG_OPTION_ENB_RAL_IP_ADDRESS:
         if (optarg) {
-            g_conf_enb_ral_ip_address = strdup(optarg);
-            printf("eNB RAL IP address is %s\n", g_conf_enb_ral_ip_address);
+	  g_conf_enb_ral_ip_address = strdup(optarg);
+	  printf("eNB RAL IP address is %s\n", g_conf_enb_ral_ip_address);
         }
         break;
-
+	
       case LONG_OPTION_ENB_RAL_LINK_ADDRESS:
         if (optarg) {
-            g_conf_enb_ral_link_address = strdup(optarg);
-            printf("eNB RAL link address is %s\n", g_conf_enb_ral_link_address);
+	  g_conf_enb_ral_link_address = strdup(optarg);
+	  printf("eNB RAL link address is %s\n", g_conf_enb_ral_link_address);
         }
         break;
-
+	
       case LONG_OPTION_ENB_RAL_LINK_ID:
         if (optarg) {
-            g_conf_enb_ral_link_id = strdup(optarg);
-            printf("eNB RAL link id is %s\n", g_conf_enb_ral_link_id);
+	  g_conf_enb_ral_link_id = strdup(optarg);
+	  printf("eNB RAL link id is %s\n", g_conf_enb_ral_link_id);
         }
         break;
-
+	
       case LONG_OPTION_ENB_MIHF_REMOTE_PORT:
         if (optarg) {
-            g_conf_enb_mihf_remote_port = strdup(optarg);
-            printf("eNB MIH-F remote port is %s\n", g_conf_enb_mihf_remote_port);
+	  g_conf_enb_mihf_remote_port = strdup(optarg);
+	  printf("eNB MIH-F remote port is %s\n", g_conf_enb_mihf_remote_port);
         }
         break;
-
+	
       case LONG_OPTION_ENB_MIHF_IP_ADDRESS:
         if (optarg) {
-            g_conf_enb_mihf_ip_address = strdup(optarg);
-            printf("eNB MIH-F IP address is %s\n", g_conf_enb_mihf_ip_address);
+	  g_conf_enb_mihf_ip_address = strdup(optarg);
+	  printf("eNB MIH-F IP address is %s\n", g_conf_enb_mihf_ip_address);
         }
         break;
-
+	
       case LONG_OPTION_ENB_MIHF_ID:
         if (optarg) {
-            g_conf_enb_mihf_id = strdup(optarg);
-            printf("eNB MIH-F id is %s\n", g_conf_enb_mihf_id);
+	  g_conf_enb_mihf_id = strdup(optarg);
+	  printf("eNB MIH-F id is %s\n", g_conf_enb_mihf_id);
         }
         break;
-
+	
       case LONG_OPTION_UE_RAL_LISTENING_PORT:
         if (optarg) {
-            g_conf_ue_ral_listening_port = strdup(optarg);
-            printf("UE RAL listening port is %s\n", g_conf_ue_ral_listening_port);
+	  g_conf_ue_ral_listening_port = strdup(optarg);
+	  printf("UE RAL listening port is %s\n", g_conf_ue_ral_listening_port);
         }
         break;
-
+	
       case LONG_OPTION_UE_RAL_IP_ADDRESS:
         if (optarg) {
-            g_conf_ue_ral_ip_address = strdup(optarg);
-            printf("UE RAL IP address is %s\n", g_conf_ue_ral_ip_address);
+	  g_conf_ue_ral_ip_address = strdup(optarg);
+	  printf("UE RAL IP address is %s\n", g_conf_ue_ral_ip_address);
         }
         break;
-
+	
       case LONG_OPTION_UE_RAL_LINK_ID:
         if (optarg) {
-            g_conf_ue_ral_link_id = strdup(optarg);
-            printf("UE RAL link id is %s\n", g_conf_ue_ral_link_id);
+	  g_conf_ue_ral_link_id = strdup(optarg);
+	  printf("UE RAL link id is %s\n", g_conf_ue_ral_link_id);
         }
         break;
-
+	
       case LONG_OPTION_UE_RAL_LINK_ADDRESS:
         if (optarg) {
-            g_conf_ue_ral_link_address = strdup(optarg);
-            printf("UE RAL link address is %s\n", g_conf_ue_ral_link_address);
+	  g_conf_ue_ral_link_address = strdup(optarg);
+	  printf("UE RAL link address is %s\n", g_conf_ue_ral_link_address);
         }
         break;
-
+	
       case LONG_OPTION_UE_MIHF_REMOTE_PORT:
         if (optarg) {
-            g_conf_ue_mihf_remote_port = strdup(optarg);
-            printf("UE MIH-F remote port is %s\n", g_conf_ue_mihf_remote_port);
+	  g_conf_ue_mihf_remote_port = strdup(optarg);
+	  printf("UE MIH-F remote port is %s\n", g_conf_ue_mihf_remote_port);
         }
         break;
-
+	
       case LONG_OPTION_UE_MIHF_IP_ADDRESS:
         if (optarg) {
-            g_conf_ue_mihf_ip_address = strdup(optarg);
-            printf("UE MIH-F IP address is %s\n", g_conf_ue_mihf_ip_address);
+	  g_conf_ue_mihf_ip_address = strdup(optarg);
+	  printf("UE MIH-F IP address is %s\n", g_conf_ue_mihf_ip_address);
         }
         break;
 
       case LONG_OPTION_UE_MIHF_ID:
         if (optarg) {
-            g_conf_ue_mihf_id = strdup(optarg);
-            printf("UE MIH-F id is %s\n", g_conf_ue_mihf_id);
+	  g_conf_ue_mihf_id = strdup(optarg);
+	  printf("UE MIH-F id is %s\n", g_conf_ue_mihf_id);
         }
         break;
 #endif
-
+	
       case 'a':
         abstraction_flag = 1;
         break;
@@ -406,6 +417,7 @@ void get_simulation_options(int argc, char *argv[]) {
       case 'F':                   // set FDD
         printf("Setting Frame to FDD\n");
         oai_emulation.info.frame_type[0] = 0;
+	oai_emulation.info.frame_type_name[0] = "FDD";
         break;
 
       case 'g':
@@ -482,6 +494,7 @@ void get_simulation_options(int argc, char *argv[]) {
 
       case 'n':
         oai_emulation.info.n_frames = atoi (optarg);
+	oai_emulation.emulation_config.emulation_time_ms= oai_emulation.info.n_frames * 10; // 10 ms frame
         //n_frames = (n_frames >1024) ? 1024: n_frames; // adjust the n_frames if higher that 1024
         oai_emulation.info.n_frames_flag = 1;
         break;
-- 
GitLab