From 437f83b6023aee92e2f0d618f186c0e3e42a8b43 Mon Sep 17 00:00:00 2001
From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr>
Date: Thu, 22 Aug 2013 08:15:34 +0000
Subject: [PATCH] bugfix in config of OTG in oaisim, extended eNB stats in
 oaisim to multiple eNBs

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4090 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 targets/SIMU/USER/oaisim.c        | 27 ++++++++++++++++-----------
 targets/SIMU/USER/oaisim_config.c |  5 +++--
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 442ce09f0a..2ca7dc54f0 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -388,8 +388,9 @@ int
 
 #ifdef PRINT_STATS
   int len;
-  FILE *UE_stats[NUMBER_OF_UE_MAX], *UE_stats_th[NUMBER_OF_UE_MAX], *eNB_stats, *eNB_avg_thr, *eNB_l2_stats;
+  FILE *UE_stats[NUMBER_OF_UE_MAX], *UE_stats_th[NUMBER_OF_UE_MAX], *eNB_stats[NUMBER_OF_eNB_MAX], *eNB_avg_thr, *eNB_l2_stats;
   char UE_stats_filename[255];
+  char eNB_stats_filename[255];
   char UE_stats_th_filename[255];
   char eNB_stats_th_filename[255];
  #endif
@@ -456,11 +457,13 @@ int
 
 #ifdef PRINT_STATS
   for (UE_id=0;UE_id<NB_UE_INST;UE_id++) {
-    sprintf(UE_stats_filename,"UE_stats%d_tx%d.txt",UE_id,oai_emulation.info.transmission_mode);
+    sprintf(UE_stats_filename,"UE_stats%d.txt",UE_id);
     UE_stats[UE_id] = fopen (UE_stats_filename, "w");
   }
-  eNB_stats = fopen ("eNB_stats.txt", "w");
-  printf ("UE_stats=%p, eNB_stats=%p\n", UE_stats, eNB_stats);
+  for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) {
+    sprintf(eNB_stats_filename,"eNB_stats%d.txt",eNB_id);
+    eNB_stats[eNB_id] = fopen (eNB_stats_filename, "w");
+  }
   
   if(abstraction_flag==0){
     for (UE_id=0;UE_id<NB_UE_INST;UE_id++) {
@@ -644,11 +647,11 @@ int
       	if(last_slot==9 && frame%10==0)
 	  if(eNB_avg_thr)
 	    fprintf(eNB_avg_thr,"%d %d\n",PHY_vars_eNB_g[eNB_id]->frame,(PHY_vars_eNB_g[eNB_id]->total_system_throughput)/((PHY_vars_eNB_g[eNB_id]->frame+1)*10));
-	if (eNB_stats) {
+	if (eNB_stats[eNB_id]) {
 	  len = dump_eNB_stats(PHY_vars_eNB_g[eNB_id], stats_buffer, 0);
-	  rewind (eNB_stats);
-	  fwrite (stats_buffer, 1, len, eNB_stats);
-	  fflush(eNB_stats);
+	  rewind (eNB_stats[eNB_id]);
+	  fwrite (stats_buffer, 1, len, eNB_stats[eNB_id]);
+	  fflush(eNB_stats[eNB_id]);
 	}
 #ifdef OPENAIR2
 	if (eNB_l2_stats) {
@@ -947,14 +950,16 @@ int
 #endif 
   
 #ifdef PRINT_STATS
-  for(UE_id=0;UE_id<NB_UE_INST;UE_id++) {
+  for (UE_id=0;UE_id<NB_UE_INST;UE_id++) {
     if (UE_stats[UE_id]) 
       fclose (UE_stats[UE_id]);
     if(UE_stats_th[UE_id])
       fclose (UE_stats_th[UE_id]);
   }
-  if (eNB_stats)
-    fclose (eNB_stats);
+  for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) {
+    if (eNB_stats[eNB_id])
+      fclose (eNB_stats[eNB_id]);
+  }
   if (eNB_avg_thr)
     fclose (eNB_avg_thr);
   if (eNB_l2_stats)
diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c
index 70491beda9..ece42c4313 100644
--- a/targets/SIMU/USER/oaisim_config.c
+++ b/targets/SIMU/USER/oaisim_config.c
@@ -49,7 +49,7 @@ mapping omg_model_names[] =
 };
 mapping otg_multicast_app_type_names[] = {
   {"no_predefined_multicast_traffic", 0},
-  {"mscbr", 1.},
+  {"mscbr", 1},
   {NULL, -1}
 }  ;
 
@@ -952,7 +952,8 @@ g_otg->application_idx[source_id_index][destination_id_index]+=1;
     LOG_I(OTG,"configure OTG through options %s\n", oai_emulation.info.otg_traffic);
     for (i=0; i<g_otg->num_nodes; i++){
       for (j=0; j<g_otg->num_nodes; j++){ 
-	for (k=0; k<4; k++){ 
+	g_otg->application_idx[i][j]=1;
+	for (k=0; k<g_otg->application_idx[i][j]; k++){ 
 	  
 	  g_otg->application_type[i][j][k] = map_str_to_int(otg_app_type_names, oai_emulation.info.otg_traffic);
 	  g_otg->background[i][j][k]=oai_emulation.info.otg_bg_traffic_enabled;
-- 
GitLab