otg_kpi.c 39.4 KB
Newer Older
1
/*******************************************************************************
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

5 6 7 8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9 10


11 12 13 14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

16 17 18 19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
    see <http://www.gnu.org/licenses/>.
20 21

  Contact Information
22 23 24 25
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27 28 29 30 31

*******************************************************************************/

/*! \file otg_kpi.c main used funstions to compute KPIs
* \brief define KPIs to compute for performance analysis 
32
* \author Navid Nikaein and A. Hafsaoui
33 34 35
* \date 2012
* \version 0.1
* \company Eurecom
36
* \email: navid.nikaein@eurecom.fr
37 38 39 40 41
* \note
* \warning

*/

42 43 44 45 46
unsigned int start_log_latency=0;
unsigned int start_log_latency_bg=0;
unsigned int start_log_GP=0;
unsigned int start_log_GP_bg=0;
unsigned int start_log_jitter=0;
47 48 49 50 51 52 53 54 55

#include"otg_kpi.h"
#include"otg_externs.h"

extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;

void tx_throughput(int src, int dst, int application){
  
56 57 58 59 60 61 62 63 64 65 66 67 68 69
  if (otg_info->tx_num_bytes[src][dst][application]>0)
    otg_info->tx_throughput[src][dst][application]=((double)otg_info->tx_num_bytes[src][dst][application] *1000*8)/ (get_ctime()*1024); // unit Kbit/sec, if ctime in ms
  
  if (otg_info->tx_num_bytes_background[src][dst]>0)
    otg_info->tx_throughput_background[src][dst]=((double)otg_info->tx_num_bytes_background[src][dst]*1000*8)/ (get_ctime()*1024); // unit Kbit/sec, if ctime in ms
  
  if (otg_multicast_info->tx_num_bytes[src][dst][application]>0){
    if (application < 2)
      otg_multicast_info->tx_throughput[src][dst]=((double)otg_multicast_info->tx_num_bytes[src][dst][application]*1000*8)/ (get_ctime()*1024); // unit Kbit/sec, if ctime in ms
                                                       //otg_multicast_info->tx_num_bytes[src][dst][app] is 3 dimension param in otg_tx.c, only use [app]=0
    //    LOG_I(OTG,"DUY, get_ctime() [i=%d,j=%d,k=%d] = %.d\n", src,dst,application,get_ctime());
        LOG_I(OTG,"otg_multicast_info->tx_num_bytes[i=%d,j=%d,k=%d] = %.d\n", src,dst,application,otg_multicast_info->tx_num_bytes[src][dst][application]);
  }

70 71 72 73 74 75
}



void rx_goodput(int src, int dst, int application){

76 77 78 79 80 81 82 83 84 85
  if (otg_info->rx_num_bytes[src][dst][application]>0)
    otg_info->rx_goodput[src][dst][application]=((double)otg_info->rx_num_bytes[src][dst][application]*1000*8)/(get_ctime()*1024); // unit kB/sec, if ctime in ms 
  
  if (otg_info->rx_num_bytes_background[src][dst]>0)
    otg_info->rx_goodput_background[src][dst]=((double)otg_info->rx_num_bytes_background[src][dst] *1000*8)/(get_ctime()*1024); // unit kB/sec, if ctime in ms
  
  if (otg_multicast_info->rx_num_bytes[src][dst][application]>0){
    otg_multicast_info->rx_goodput[src][dst]=((double)otg_multicast_info->rx_num_bytes[src][dst][application] *1000*8)/(get_ctime()*1024); // unit kB/sec, if ctime in ms
        LOG_I(OTG,"otg_multicast_info->rx_num_bytes[i=%d,j=%d,k=%d] = %.d\n", src,dst,application,otg_multicast_info->rx_num_bytes[src][dst][application]);
  }
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
}




void rx_loss_rate_pkts(int src, int dst, int application){

  if (otg_info->rx_num_pkt[src][dst][application]<otg_info->tx_num_pkt[src][dst][application])
    otg_info->rx_loss_rate[src][dst][application]= 1 - ((double)otg_info->rx_num_pkt[src][dst][application]/otg_info->tx_num_pkt[src][dst][application]);
  else
    otg_info->rx_loss_rate[src][dst][application]=0;

  if (otg_info->rx_num_pkt_background[src][dst]<otg_info->tx_num_pkt_background[src][dst])
    otg_info->rx_loss_rate_background[src][dst]= 1 - ((double)otg_info->rx_num_pkt_background[src][dst]/otg_info->tx_num_pkt_background[src][dst]);
  else
    otg_info->rx_loss_rate_background[src][dst]=0;
  /*  
if (otg_info->rx_loss_rate[src][dst][application]>0)
LOG_I(OTG, "LOSS_RATE (src=%d, dst=%d, appli %d ):: = %lf(pkts) [TX %d] [RX %d], [NB UL %d] [NB DL %d]\n",src, dst, application, otg_info->rx_loss_rate[src][dst][application], otg_info->tx_num_pkt[src][dst][application],otg_info->rx_num_pkt[src][dst][application],otg_info->nb_loss_pkts_ul[src][dst][application], otg_info->nb_loss_pkts_dl[src][dst][application]);
  */

107 108 109 110 111
   if (otg_multicast_info->rx_num_pkt[src][dst] < otg_multicast_info->tx_num_pkt[src][dst])
    otg_multicast_info->rx_loss_rate[src][dst]= 1 - ((double)otg_multicast_info->rx_num_pkt[src][dst][application]/otg_multicast_info->tx_num_pkt[src][dst][0]);
  else
    otg_multicast_info->rx_loss_rate[src][dst]=0;

112 113 114 115 116 117 118 119 120 121 122 123 124
}


void rx_loss_rate_bytes(int src, int dst, int application){

  if (otg_info->rx_num_pkt[src][dst][application]<otg_info->tx_num_pkt[src][dst][application])
    otg_info->rx_loss_rate[src][dst][application]= 1 - ((double)otg_info->rx_num_bytes[src][dst][application]/otg_info->tx_num_bytes[src][dst][application]);
  else
    otg_info->rx_loss_rate[src][dst][application]=0;
  LOG_I(OTG, "loss rate (src=%d, dst=%d, appli %d ):: = %lf(bytes) \n",src, dst, application, otg_info->rx_loss_rate[src][dst][application]);

}

125
void otg_kpi_nb_loss_pkts(void){
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
unsigned int i,j,k;

otg_info->total_loss_dl=0;
otg_info->total_loss_ul=0;

  for (i=0; i<(NB_eNB_INST + NB_UE_INST); i++){
    for (j=0; j<(NB_eNB_INST + NB_UE_INST); j++){
      for (k=0; k<MAX_EMU_TRAFFIC; k++){
	if (i<NB_eNB_INST)
	  otg_info->total_loss_dl+=(otg_info->nb_loss_pkts_dl[i][j][k] + otg_info->nb_loss_pkts_background_dl[i][j]);
	else
	  otg_info->total_loss_ul+=(otg_info->nb_loss_pkts_ul[i][j][k] + otg_info->nb_loss_pkts_background_ul[i][j]);
      }
    }
  }
}

void average_pkt_jitter(int src, int dst, int application){
 
  otg_info->rx_jitter_avg[src][dst][application]/= otg_info->rx_jitter_sample[src][dst][application];

  if (otg_info->rx_jitter_avg[src][dst][application] > 0) {
    if (src<NB_eNB_INST)
      otg_info->average_jitter_dl+=otg_info->rx_jitter_avg[src][dst][application];
    else
      otg_info->average_jitter_ul+=otg_info->rx_jitter_avg[src][dst][application];
    
    LOG_T(OTG,"average_jitter_dl %lf average_jitter_ul %lf \n",otg_info->average_jitter_dl,otg_info->average_jitter_ul  );
  }
}

void average_total_jitter(){
unsigned int i,j,k;

otg_info->average_jitter_dl=0;
otg_info->average_jitter_ul=0;

  for (i=0; i<(NB_eNB_INST + NB_UE_INST); i++){
    for (j=0; j<(NB_eNB_INST + NB_UE_INST); j++){
      for (k=0; k<MAX_EMU_TRAFFIC; k++){
	if (i<NB_eNB_INST)
	  otg_info->average_jitter_dl+=otg_info->rx_jitter_avg[i][j][k];
	else
	  otg_info->average_jitter_ul+=otg_info->rx_jitter_avg[i][j][k];
      }
    }
  }
  LOG_I(OTG,"average_jitter_dl %d average_jitter_ul %lf \n",otg_info->average_jitter_dl,otg_info->average_jitter_ul  );
  //  otg_info->average_jitter_dl/= (float)NB_UE_INST;
  // otg_info->average_jitter_ul/= (float)NB_UE_INST;
}

void kpi_gen() {
  int i, j,k;
  
  int tx_total_bytes_dl=0;
  int tx_total_pkts_dl=0;
  int rx_total_bytes_dl=0;
  int rx_total_pkts_dl=0;
  int tx_total_bytes_ul=0;
  int tx_total_pkts_ul=0;
  int rx_total_bytes_ul=0;
  int rx_total_pkts_ul=0;
189 190 191 192

  float min_owd_dl=0;
  float max_owd_dl=0;

193 194 195 196 197 198 199 200
  int tx_total_bytes_dl_background=0;
  int tx_total_pkts_dl_background=0;
  int rx_total_bytes_dl_background=0;
  int rx_total_pkts_dl_background=0;
  int tx_total_bytes_ul_background=0;
  int tx_total_pkts_ul_background=0;
  int rx_total_bytes_ul_background=0;
  int rx_total_pkts_ul_background=0;
201

202 203 204
  float min_owd_ul=0;
  float max_owd_ul=0;  

205 206 207 208 209 210 211

  int tx_total_bytes_dl_multicast=0;
  int tx_total_pkts_dl_multicast=0;
  int rx_total_bytes_dl_multicast=0;
  int rx_total_pkts_dl_multicast=0;


212 213
  int num_active_source=0;
 
Navid Nikaein's avatar
Navid Nikaein committed
214 215
  
  int dl_ok=0,ul_ok;
216

217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
char traffic_type[12];
char traffic[30];

#ifdef STANDALONE	
  FILE *file;
  file = fopen("log_OTG.txt", "w"); 
#else   // Maybe to do modifo log function in order to clear file before a new write !!!! 
FILE *fc;
fc=fopen("/tmp/otg.log","w");;
  if(fc!=0) 
    fclose(fc);
#endif



  for (i=0; i<(NB_eNB_INST + NB_UE_INST); i++){
    for (j=0; j<(NB_eNB_INST + NB_UE_INST); j++){

/*background stats*/
236 237 238 239 240 241 242 243 244 245 246 247
      if (i<NB_eNB_INST){
	tx_total_bytes_dl_background+=otg_info->tx_num_bytes_background[i][j];
	tx_total_pkts_dl_background+=otg_info->tx_num_pkt_background[i][j];	
	rx_total_bytes_dl_background+=otg_info->rx_num_bytes_background[i][j];
	rx_total_pkts_dl_background+=otg_info->rx_num_pkt_background[i][j];
      }
      else{
	tx_total_bytes_ul_background+=otg_info->tx_num_bytes_background[i][j];
	tx_total_pkts_ul_background+=otg_info->tx_num_pkt_background[i][j];	
	rx_total_bytes_ul_background+=otg_info->rx_num_bytes_background[i][j];
	rx_total_pkts_ul_background+=otg_info->rx_num_pkt_background[i][j];
      }
248
      
249 250 251 252 253 254
      for (k=0; k<MAX_EMU_TRAFFIC; k++) {    
	
	tx_throughput(i,j,k);
	rx_goodput(i,j,k);
	rx_loss_rate_pkts(i,j,k);
	average_pkt_jitter(i,j,k);
255

256
	//	LOG_I(OTG,"KPI: (src=%d, dst=%d, traffic=%d) NB packet TX= %d,  NB packet RX= %d\n ",i, j,  k,otg_info->tx_num_pkt[i][j][k],  otg_info->rx_num_pkt[i][j][k]);
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
	
	if (otg_multicast_info->tx_throughput[i][j]>0)  { 
	  //multicast
	  tx_total_bytes_dl_multicast+=otg_multicast_info->tx_num_bytes[i][j][k];
	  tx_total_pkts_dl_multicast+=otg_multicast_info->tx_num_pkt[i][j][k];	
	  rx_total_bytes_dl_multicast+=otg_multicast_info->rx_num_bytes[i][j][k];
	  rx_total_pkts_dl_multicast+=otg_multicast_info->rx_num_pkt[i][j][k];
	  
#ifdef STANDALONE
	  LOG_I(OTG,"No stats for multicast ");       // do nothing
#else
	  // Multicast 
	  //no multicast_status
	  if (otg_multicast_info->tx_num_bytes[i][j][k]>0){
	    LOG_I(OTG,"----------------------------------------------------------\n");
	    LOG_I(OTG,"Total Time (multicast) (ms)= %d \n", otg_info->ctime+1);
	    
	    //	 LOG_I(OTG,"[%s] Multicast [eNB:%d -> UE:%d] \n",traffic_type, i, j);
	    
	    LOG_I(OTG,"[MULTICAST] Total packets(TX)= %d \n", otg_multicast_info->tx_num_pkt[i][j][k]);
	    LOG_I(OTG,"[MULTICAST] Total bytes(TX)= %d \n", otg_multicast_info->tx_num_bytes[i][j][k]);
	    LOG_I(OTG,"[MULTICAST] Total packets(RX)= %d \n", otg_multicast_info->rx_num_pkt[i][j][k]);
	    LOG_I(OTG,"[MULTICAST] Total bytes(RX)= %d \n", otg_multicast_info->rx_num_bytes[i][j][k]);
	    
	    LOG_I(OTG,"[MULTICAST] TX throughput = %.7f (Kbit/s) \n", otg_multicast_info->tx_throughput[i][j]);
	    LOG_I(OTG,"[MULTICAST] RX goodput = %.7f (Kbit/s) \n", otg_multicast_info->rx_goodput[i][j]);
	    //	 if (otg_multicast_info->rx_loss_rate[i][j]>0){
	    //  LOG_I(OTG,"[MULTICAST] Loss rate = %lf \n", (otg_multicast_info->rx_loss_rate[i][j]));
	    //  LOG_I(OTG,"[MULTICAST] NB Lost  packets=%d \n", (otg_multicast_info->tx_num_pkt[i][j][k]-otg_multicast_info->rx_num_pkt[i][j][k]));
	    //}
	    
	    // if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
	    LOG_F(OTG,"----------------------------------------------------------\n");
	    LOG_F(OTG,"Total Time (multicast) (ms)= %d \n", otg_info->ctime+1);
	    //  if (i<NB_eNB_INST){
	    LOG_F(OTG,"[%s] DL [eNB:%d -> UE:%d] \n",traffic_type ,i, j);
	    //else
	    //		LOG_F(OTG,"[%s] UL [Ue:%d -> eNB:%d] \n",traffic_type, i, j);
	    LOG_F(OTG,"[MULTICAST] Total packets(TX)= %d \n", otg_multicast_info->tx_num_pkt[i][j][k]);
	    LOG_F(OTG,"[MULTICAST] Total bytes(TX)= %d \n", otg_multicast_info->tx_num_bytes[i][j][k]);
	    LOG_F(OTG,"[MULTICAST] TX throughput = %.7f(Kbit/s) \n", otg_multicast_info->tx_throughput[i][j]);
	    LOG_F(OTG,"[MULTICAST] RX goodput= %.7f (Kbit/s) \n", otg_multicast_info->rx_goodput[i][j]);
	    if (otg_multicast_info->rx_loss_rate[i][j]>0){
	      LOG_F(OTG,"[MULTICAST] Loss rate = %lf \n", (otg_multicast_info->rx_loss_rate[i][j]));
	      LOG_F(OTG,"[MULTICAST] NB Lost  packets=%d \n", (otg_multicast_info->tx_num_pkt[i][j][k]-otg_multicast_info->rx_num_pkt[i][j][k]));
	    }
	  }
#endif
	  
	}// end for multicast
	
	if ((otg_info->tx_throughput[i][j][k]>0)||((otg_info->tx_throughput_background[i][j]>0) && (otg_info->tx_num_bytes[i][j][k]>0)))  {
	  
	  num_active_source+=1;
	  
	  if (i<NB_eNB_INST){ // DL
	    tx_total_bytes_dl+=otg_info->tx_num_bytes[i][j][k];
	    tx_total_pkts_dl+=otg_info->tx_num_pkt[i][j][k];	
	    rx_total_bytes_dl+=otg_info->rx_num_bytes[i][j][k];
	    rx_total_pkts_dl+=otg_info->rx_num_pkt[i][j][k];
	    /*tx_total_bytes_dl_background+=otg_info->tx_num_bytes_background[i][j];
	      tx_total_pkts_dl_background+=otg_info->tx_num_pkt_background[i][j];	
	      rx_total_bytes_dl_background+=otg_info->rx_num_bytes_background[i][j];
	      rx_total_pkts_dl_background+=otg_info->rx_num_pkt_background[i][j]; */
	    
	    if ((min_owd_dl>otg_info->rx_owd_min[i][j][k]) || (min_owd_dl==0))
	      min_owd_dl=otg_info->rx_owd_min[i][j][k];
	    if ((max_owd_dl<otg_info->rx_owd_max[i][j][k]) || (max_owd_dl==0))
	      max_owd_dl=otg_info->rx_owd_max[i][j][k];
	  }
	  else { // UL
	    tx_total_bytes_ul+=otg_info->tx_num_bytes[i][j][k];
	    tx_total_pkts_ul+=otg_info->tx_num_pkt[i][j][k];	
	    rx_total_bytes_ul+=otg_info->rx_num_bytes[i][j][k];
	    rx_total_pkts_ul+=otg_info->rx_num_pkt[i][j][k];
	    /*tx_total_bytes_ul_background+=otg_info->tx_num_bytes_background[i][j];
	      tx_total_pkts_ul_background+=otg_info->tx_num_pkt_background[i][j];	
	      rx_total_bytes_ul_background+=otg_info->rx_num_bytes_background[i][j];
	      rx_total_pkts_ul_background+=otg_info->rx_num_pkt_background[i][j];*/
	    if ((min_owd_ul>otg_info->rx_owd_min[i][j][k]) || (min_owd_ul==0))
	      min_owd_ul=otg_info->rx_owd_min[i][j][k];
	    if ((max_owd_ul<otg_info->rx_owd_max[i][j][k]) || (max_owd_ul==0))
	      max_owd_ul=otg_info->rx_owd_max[i][j][k];
	  }
	  
	  //LOG_D(OTG,"KPI: (src=%d, dst=%d, appli %d) NB packet TX= %d,  NB packet RX= %d\n ",i, j,  otg_info->tx_num_pkt[i][j][k],  otg_info->rx_num_pkt[i][j][k]);
	  
	  if (g_otg->application_idx[i][j]>1)
	    strcpy(traffic_type,"GATEWAY");
	  else
	    strcpy(traffic_type,"APPLICATION");
	  
	  
	  switch  (k) {
	  case  0 : 
	    strcpy(traffic,"CUSTOMIZED TRAFFIC ");
	    break;
	  case 1 :
	    strcpy(traffic,"M2M");
	    break;
	  case 2 :
	    strcpy(traffic,"SCBR");
	    break;
	  case 3 :
	    strcpy(traffic,"MCBR");
	    break;
	  case 4 :
	    strcpy(traffic,"BCBR");
	    break;
	  case 5 :
	    strcpy(traffic,"AUTO_PILOT");
	    break;
	  case 6 :
	    strcpy(traffic,"BICYCLE_RACE");
	    break;
	  case 7 :
	    strcpy(traffic,"OPENARENA");
	    break;
	  case 8 :
	    strcpy(traffic,"TEAM_FORTRESS");
	    break;
	  case 9 :
	    strcpy(traffic,"FULL_BUFFER");
	    break;
	  case 10 :
	    strcpy(traffic,"M2M_TRAFFIC");
	    break;
	  case 11 :
	    strcpy(traffic,"AUTO_PILOT_L");
	    break;
	  case 12 :
	    strcpy(traffic,"AUTO_PILOT_M");
	    break;
	  case 13 :
	    strcpy(traffic,"AUTO_PILOT_H");
	    break;
	  case 14 :
	    strcpy(traffic,"AUTO_PILOT_E");
	    break;
	  case 15 :
	    strcpy(traffic,"VIRTUAL_GAME_L");
	    break;
	  case 16 :
	    strcpy(traffic,"VIRTUAL_GAME_M");
	    break;
	  case 17 :
	    strcpy(traffic,"VIRTUAL_GAME_H");
	    break;
	  case 18 :
	    strcpy(traffic,"VIRTUAL_GAME_F"); 
	    break;
	  case 19 :
	    strcpy(traffic,"ALARM_HUMIDITY"); 
	    break;
	  case 20 :
	    strcpy(traffic,"ALARM_SMOKE"); 
	    break;
	  case 21 :
	    strcpy(traffic,"ALARM_TEMPERATURE"); 
	    break;
	  case 22 :
	    strcpy(traffic,"OPENARENA_DL"); 
	    break;
	  case 23 :
	    strcpy(traffic,"OPENARENA_UL"); 
	    break;
	  case 24 :
	    strcpy(traffic,"VOIP_G711"); 
	    break;
	  case 25 :
	    strcpy(traffic,"VOIP_G729"); 
	    break;
	  case 26 :
	    strcpy(traffic,"IQSIM_MANGO"); 
	    break;
	  case 27 :
	    strcpy(traffic,"IQSIM_NEWSTEO"); 
	    break;
	  case 28 :
	    strcpy(traffic,"OPEMARENA_DL_TARMA"); 
	    break;
	  case 29 :
	    strcpy(traffic,"VIDEO_VBR_10MBPS"); 
	    break;
	  case 30 :
	    strcpy(traffic,"VIDEO_VBR_4MBPS"); 
	    break;
	  case 31 :
	    strcpy(traffic,"VIDEO_VBR_2MBPS"); 
	    break;
	  case 32 :
	    strcpy(traffic,"VIDEO_VBR_768KBPS"); 
	    break;
	  case 33 :
	    strcpy(traffic,"VIDEO_VBR_384KBPS"); 
	    break;
	  case 34 :
	    strcpy(traffic,"VIDEO_VBR_192KBPS"); 
	    break;
	  default:
	    strcpy(traffic,"UKNOWN TRAFFIC"); 
	    break;
	  }
	  
	  
462 463 464 465 466 467 468 469 470 471 472



#ifdef STANDALONE
	
	fprintf(file,"----------------------------------------------------------\n");	
  fprintf(file,"Total Time (ms)= %d \n", otg_info->ctime+1);
  if (i<NB_eNB_INST){
		fprintf(file,"[%s] DL [eNB:%d, UE:%d][%s] \n", traffic_type,i,j,traffic);}
	else
		fprintf(file,"[%s] UL [eNB:%d, UE:%d][%s] \n",traffic_type,j,i,traffic);
473 474 475 476 477 478 479 480 481 482 483
  fprintf(file,"[%s] Total packets(TX)= %d \n",traffic_type, otg_info->tx_num_pkt[i][j][k]);
  fprintf(file,"[%s] Total bytes(TX)= %d \n",traffic_type, otg_info->tx_num_bytes[i][j][k]);
  fprintf(file,"[%s] OWD MIN (one way)ms= %.2f \n",traffic_type, otg_info->rx_owd_min[i][j][k]);
  fprintf(file,"[%s] OWD MAX (one way)ms= %.2f \n",traffic_type, otg_info->rx_owd_max[i][j][k]);
  fprintf(file,"[%s] TX throughput = %.7f(Kbit/s) \n",traffic_type, otg_info->tx_throughput[i][j][k]);
  fprintf(file,"[%s] RX goodput= %.7f (K/s) \n",traffic_type, otg_info->rx_goodput[i][j][k]);
  if (otg_info->rx_loss_rate[i][j[k]]>0){
    fprintf(file,"[%s] Loss rate = %.2f \n",traffic_type, (otg_info->rx_loss_rate[i][j][k]));
    fprintf(file,"[%s] NB Lost  packets=%d \n",traffic_type, (otg_info->tx_num_pkt[i][j][k]-otg_info->rx_num_pkt[i][j][k]));
    //fprintf(file,"[%s] NB Lost [OTG] packets=%d \n",traffic_type, otg_info->nb_loss_pkts_otg[i][j]);
  }
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566

 /* if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
    fprintf(file,"[BACKGROUND] Total packets(TX)= %d \n", otg_info->tx_num_pkt_background[i][j]);
	  fprintf(file,"[BACKGROUND] Total bytes(TX)= %d \n", otg_info->tx_num_bytes_background[i][j]);
	  fprintf(file,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", otg_info->tx_throughput_background[i][j]);
	  fprintf(file,"[BACKGROUND] RX goodput= %.7f (Kbit/s) \n", otg_info->rx_goodput_background[i][j]);
	  if (otg_info->rx_loss_rate_background[i][j]>0){
	    fprintf(file,"[BACKGROUND] Loss rate(percentage)= %lf \n", (otg_info->rx_loss_rate_background[i][j]*100));
	    fprintf(file,"[BACKGROUND] NB Lost  packets=%d \n", (otg_info->tx_num_pkt_background[i][j]-otg_info->rx_num_pkt_background[i][j]));
	  }
	}
*/


#else
  LOG_I(OTG,"----------------------------------------------------------\n");
  LOG_I(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
  if (i<NB_eNB_INST)
    LOG_I(OTG,"[%s] DL [eNB:%d -> UE:%d][%s] \n",traffic_type, i, j, traffic);
  else
    LOG_I(OTG,"[%s] UL [UE:%d -> eNB:%d][%s] \n",traffic_type, i, j, traffic);
  LOG_I(OTG,"[%s] Total packets(TX)= %d \n",traffic_type, otg_info->tx_num_pkt[i][j][k]);
  LOG_I(OTG,"[%s] Total packets(RX)= %d \n",traffic_type, otg_info->rx_num_pkt[i][j][k]);
  LOG_I(OTG,"[%s] Total bytes(TX)= %d \n",traffic_type, otg_info->tx_num_bytes[i][j][k]);
  LOG_I(OTG,"[%s] Total bytes(RX)= %d \n",traffic_type, otg_info->rx_num_bytes[i][j][k]);
  LOG_I(OTG,"[%s] OWD MIN (one way)ms= %.2f \n",traffic_type, otg_info->rx_owd_min[i][j][k]);
  LOG_I(OTG,"[%s] OWD MAX (one way)ms= %.2f \n",traffic_type, otg_info->rx_owd_max[i][j][k]);
  LOG_I(OTG,"[%s] JITTER AVG ms= %.2f \n",traffic_type, otg_info->rx_jitter_avg[i][j][k]);
  LOG_I(OTG,"[%s] JITTER MIN ms= %.2f \n",traffic_type, otg_info->rx_jitter_min[i][j][k]);
  LOG_I(OTG,"[%s] JITTER MAX ms= %.2f \n",traffic_type, otg_info->rx_jitter_max[i][j][k]);
  LOG_I(OTG,"[%s] TX throughput = %.7f(Kbit/s) \n",traffic_type, otg_info->tx_throughput[i][j][k]);
  LOG_I(OTG,"[%s] RX goodput= %.7f (Kbit/s) \n",traffic_type, otg_info->rx_goodput[i][j][k]);
  if (otg_info->rx_loss_rate[i][j][k]>0){
    LOG_I(OTG,"[%s] Loss rate = %lf \n",traffic_type, (otg_info->rx_loss_rate[i][j][k]));
    LOG_I(OTG,"[%s] NB Lost packets= %d \n",traffic_type, (otg_info->tx_num_pkt[i][j][k]-otg_info->rx_num_pkt[i][j][k]));
    //LOG_D(OTG,"[%s] NB Lost [OTG] packets=%d \n",traffic_type, otg_info->nb_loss_pkts_otg[i][j]);
  }
/*  if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
    LOG_I(OTG,"[BACKGROUND] Total packets(TX)= %d \n", otg_info->tx_num_pkt_background[i][j]);
	  LOG_I(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", otg_info->tx_num_bytes_background[i][j]);
	  LOG_I(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", otg_info->tx_throughput_background[i][j]);
	  LOG_I(OTG,"[BACKGROUND] RX goodput= %.7f (Kbit/s) \n", otg_info->rx_goodput_background[i][j]);
	  if (otg_info->rx_loss_rate_background[i][j]>0){
	    LOG_I(OTG,"[BACKGROUND] Loss rate(percentage)= %.2f \n", (otg_info->rx_loss_rate_background[i][j]*100));
	    LOG_I(OTG,"[BACKGROUND] NB Lost  packets=%d \n", (otg_info->tx_num_pkt_background[i][j]-otg_info->rx_num_pkt_background[i][j]));
	  }
	}
*/
	LOG_F(OTG,"----------------------------------------------------------\n");
	LOG_F(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
	if (i<NB_eNB_INST){
		LOG_F(OTG,"[%s] DL [eNB:%d -> UE:%d][%s] \n",traffic_type ,i, j, traffic);}
	else
		LOG_F(OTG,"[%s] UL [UE:%d -> eNB:%d][%s] \n",traffic_type, i, j,traffic);
	LOG_F(OTG,"[%s] Total packets(TX)= %d \n",traffic_type, otg_info->tx_num_pkt[i][j][k]);
	LOG_F(OTG,"[%s] Total packets(RX)= %d \n",traffic_type, otg_info->rx_num_pkt[i][j][k]);
	LOG_F(OTG,"[%s] Total bytes(TX)= %d \n",traffic_type, otg_info->tx_num_bytes[i][j][k]);
	LOG_F(OTG,"[%s] Total bytes(RX)= %d \n",traffic_type, otg_info->rx_num_bytes[i][j][k]);
	LOG_F(OTG,"[%s] OWD MIN (one way)ms= %.2f \n",traffic_type, otg_info->rx_owd_min[i][j][k]);
	LOG_F(OTG,"[%s] OWD MAX (one way)ms= %.2f \n",traffic_type, otg_info->rx_owd_max[i][j][k]);
	LOG_F(OTG,"[%s] JITTER AVG ms= %.2f \n",traffic_type, otg_info->rx_jitter_avg[i][j][k]);
	LOG_F(OTG,"[%s] JITTER MIN ms= %.2f \n",traffic_type, otg_info->rx_jitter_min[i][j][k]);
	LOG_F(OTG,"[%s] JITTER MAX ms= %.2f \n",traffic_type, otg_info->rx_jitter_max[i][j][k]);
	LOG_F(OTG,"[%s] TX throughput = %.7f(Kbit/s) \n",traffic_type, otg_info->tx_throughput[i][j][k]);
	LOG_F(OTG,"[%s] RX goodput= %.7f (Kbit/s) \n",traffic_type, otg_info->rx_goodput[i][j][k]);
	if (otg_info->rx_loss_rate[i][j][k]>0){
	  LOG_F(OTG,"[%s] Loss rate = %lf \n",traffic_type, (otg_info->rx_loss_rate[i][j][k]));
	  LOG_F(OTG,"[%s] NB Lost  packets= %d \n",traffic_type,(otg_info->tx_num_pkt[i][j][k]-otg_info->rx_num_pkt[i][j][k]));
    //LOG_D(OTG,"[%s] NB Lost [OTG] packets=%d \n",traffic_type, otg_info->nb_loss_pkts_otg[i][j]);
	}
/*  if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
  	LOG_F(OTG,"[BACKGROUND] Total packets(TX)= %d \n", otg_info->tx_num_pkt_background[i][j]);
	  LOG_F(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", otg_info->tx_num_bytes_background[i][j]);
	  LOG_F(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", otg_info->tx_throughput_background[i][j]);
	  LOG_F(OTG,"[BACKGROUND] RX goodput= %.7f (Kbit/s) \n", otg_info->rx_goodput_background[i][j]);
	  if (otg_info->rx_loss_rate_background[i][j]>0){
	    LOG_F(OTG,"[BACKGROUND] Loss rate(percentage)= %.2f \n", (otg_info->rx_loss_rate_background[i][j]*100));
	    LOG_F(OTG,"[BACKGROUND] NB Lost  packets=%d \n", (otg_info->tx_num_pkt_background[i][j]-otg_info->rx_num_pkt_background[i][j]));
	  }
	}
*/
#endif 

567 568 569 570 571 572
     }
     
     //     if ((otg_multicast_info->tx_throughput[i][j]>0) && (otg_info->tx_num_bytes[i][j][k]>0))  {

     }// end loop of k

573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595


#ifdef STANDALONE

if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
	fprintf(file,"----------------------------------------------------------\n");	
 fprintf(file,"Total Time (ms)= %d \n", otg_info->ctime+1);
  if (i<NB_eNB_INST){
		fprintf(file,"[%s] DL [eNB:%d, UE:%d] \n", traffic_type,i,j);}
	else
		fprintf(file,"[%s] UL [eNB:%d, UE:%d] \n",traffic_type,j,i);

    fprintf(file,"[BACKGROUND] Total packets(TX)= %d \n", otg_info->tx_num_pkt_background[i][j]);
	  fprintf(file,"[BACKGROUND] Total bytes(TX)= %d \n", otg_info->tx_num_bytes_background[i][j]);
	  fprintf(file,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", otg_info->tx_throughput_background[i][j]);
	  fprintf(file,"[BACKGROUND] RX goodput= %.7f (Kbit/s) \n", otg_info->rx_goodput_background[i][j]);
	  if (otg_info->rx_loss_rate_background[i][j]>0){
	    fprintf(file,"[BACKGROUND] Loss rate = %lf \n", (otg_info->rx_loss_rate_background[i][j]));
	    fprintf(file,"[BACKGROUND] NB Lost  packets=%d \n", (otg_info->tx_num_pkt_background[i][j]-otg_info->rx_num_pkt_background[i][j]));
	  }
	}
#else

596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
 if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
   LOG_I(OTG,"----------------------------------------------------------\n");
   LOG_I(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
   if (i<NB_eNB_INST){
     LOG_I(OTG,"[%s] DL [eNB:%d -> UE:%d] \n",traffic_type, i, j);}
   else
     LOG_I(OTG,"[%s] UL [UE:%d -> eNB:%d] \n",traffic_type, i, j);

   LOG_I(OTG,"[BACKGROUND] Total packets(TX)= %d \n", otg_info->tx_num_pkt_background[i][j]);
   LOG_I(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", otg_info->tx_num_bytes_background[i][j]);
   LOG_I(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", otg_info->tx_throughput_background[i][j]);
   LOG_I(OTG,"[BACKGROUND] RX goodput= %.7f (Kbit/s) \n", otg_info->rx_goodput_background[i][j]);
   if (otg_info->rx_loss_rate_background[i][j]>0){
     LOG_I(OTG,"[BACKGROUND] Loss rate = %lf \n", (otg_info->rx_loss_rate_background[i][j]));
     LOG_I(OTG,"[BACKGROUND] NB Lost  packets=%d \n", (otg_info->tx_num_pkt_background[i][j]-otg_info->rx_num_pkt_background[i][j]));
   }
 }
 
 if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
   LOG_F(OTG,"----------------------------------------------------------\n");
   LOG_F(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
   if (i<NB_eNB_INST){
     LOG_F(OTG,"[%s] DL [eNB:%d -> UE:%d] \n",traffic_type ,i, j);}
   else
620
		LOG_F(OTG,"[%s] UL [UE:%d -> eNB:%d] \n",traffic_type, i, j);
621 622 623 624 625 626 627 628 629 630
   
   LOG_F(OTG,"[BACKGROUND] Total packets(TX)= %d \n", otg_info->tx_num_pkt_background[i][j]);
   LOG_F(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", otg_info->tx_num_bytes_background[i][j]);
   LOG_F(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", otg_info->tx_throughput_background[i][j]);
   LOG_F(OTG,"[BACKGROUND] RX goodput= %.7f (Kbit/s) \n", otg_info->rx_goodput_background[i][j]);
   if (otg_info->rx_loss_rate_background[i][j]>0){
     LOG_F(OTG,"[BACKGROUND] Loss rate = %lf \n", (otg_info->rx_loss_rate_background[i][j]));
     LOG_F(OTG,"[BACKGROUND] NB Lost  packets=%d \n", (otg_info->tx_num_pkt_background[i][j]-otg_info->rx_num_pkt_background[i][j]));
   }
 }
631 632 633
#endif


634 635 636
    }// end loop of j	
  }// end loop of i

637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
  
  //  average_total_jitter();
  
#ifdef STANDALONE
  fprintf (file,"**************** TOTAL DL RESULTS ******************\n");
  fprintf(file,"Total Time= %d \n", otg_info->ctime+1);
  fprintf(file,"[DATA] Total packets(TX)= %d \n", tx_total_pkts_dl);
  fprintf(file,"[DATA] Total bytes(TX)= %d \n", tx_total_bytes_dl);
  fprintf(file,"[DATA] Total packets(RX)= %d \n", rx_total_pkts_dl);
  fprintf(file,"[DATA] Total bytes(RX)= %d \n", rx_total_bytes_dl);
  fprintf(file,"[DATA] OWD MIN (one way)ms= %.2f \n", min_owd_dl);
  fprintf(file,"[DATA] OWD MAX (one way)ms= %.2f \n", max_owd_dl);
  fprintf(file,"[DATA] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl*1000*8)/(otg_info->ctime*1024));
  fprintf(file,"[DATA] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl*1000*8)/(otg_info->ctime*1024));
  if ((g_otg->background_stats==1)&&(tx_total_pkts_dl_background>0)){
    fprintf(file,"[BACKGROUND] Total packets(TX)= %d \n", tx_total_pkts_dl_background);
    fprintf(file,"[BACKGROUND] Total bytes(TX)= %d \n", tx_total_bytes_dl_background);
    fprintf(file,"[BACKGROUND] Total packets(RX)= %d \n", rx_total_pkts_dl_background);
    fprintf(file,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_dl_background);
    fprintf(file,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl_background*1000*8)/(otg_info->ctime*1024));
    fprintf(file,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl_background*1000*8)/(otg_info->ctime*1024));
  }
  fprintf (file,"**************** TOTAL UL RESULTS ******************\n");
  fprintf(file,"Total Time (ms)= %d \n", otg_info->ctime+1);
  fprintf(file,"[DATA] Total packets(TX)= %d \n", tx_total_pkts_ul);
  fprintf(file,"[DATA] Total bytes(TX)= %d \n", tx_total_bytes_ul);
  fprintf(file,"[DATA] Total packets(RX)= %d \n", rx_total_pkts_ul);
  fprintf(file,"[DATA] Total bytes(RX)= %d \n", rx_total_bytes_ul);
  fprintf(file,"[DATA] OWD MIN (one way)ms= %.2f \n", min_owd_ul);
  fprintf(file,"[DATA] OWD MAX (one way)ms= %.2f \n", max_owd_ul);
  fprintf(file,"[DATA] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul*1000*8)/(otg_info->ctime*1024));
  fprintf(file,"[DATA] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul*1000*8)/(otg_info->ctime*1024));
  if ((g_otg->background_stats==1)&&(tx_total_pkts_ul_background>0)){
    fprintf(file,"[BACKGROUND] Total packets(TX)= %d \n", tx_total_pkts_ul_background);
    fprintf(file,"[BACKGROUND] Total bytes(TX)= %d \n", tx_total_bytes_ul_background);
    fprintf(file,"[BACKGROUND] Total packets(RX)= %d \n", rx_total_pkts_ul_background);
    fprintf(file,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_ul_background);
    fprintf(file,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
    fprintf(file,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
  }
  fclose(file);
#else
  LOG_I(OTG,"**************** TOTAL DL RESULTS ******************\n");
  LOG_I(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
  LOG_I(OTG,"[DATA] Total packets(TX)= %d \n", tx_total_pkts_dl);
  LOG_I(OTG,"[DATA] Total packets(RX)= %d \n", rx_total_pkts_dl);
  LOG_I(OTG,"[DATA] Total bytes(TX)= %d \n", tx_total_bytes_dl);
  LOG_I(OTG,"[DATA] Total bytes(RX)= %d \n", rx_total_bytes_dl);
  LOG_I(OTG,"[DATA] OWD MIN (one way)ms= %.2f \n", min_owd_dl);
  LOG_I(OTG,"[DATA] OWD MAX (one way)ms= %.2f \n", max_owd_dl);
  LOG_I(OTG,"[DATA] JITTER AVG ms= %lf \n", otg_info->average_jitter_dl/(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 );
Navid Nikaein's avatar
Navid Nikaein committed
691 692 693
  if (tx_total_pkts_dl - rx_total_pkts_dl  <  (int) (tx_total_pkts_dl / 10) ) // below 10% of loss
    dl_ok=1;
 if ((g_otg->background_stats==1)&&(tx_total_pkts_dl_background>0)){
694 695 696 697 698 699
    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);
    LOG_I(OTG,"[BACKGROUND] Total packets(RX)= %d \n", rx_total_pkts_dl_background);
    LOG_I(OTG,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_dl_background);
    LOG_I(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl_background*1000*8)/(otg_info->ctime*1024));
    LOG_I(OTG,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl_background*1000*8)/(otg_info->ctime*1024));
700
 }
701 702 703 704 705 706 707 708
  if (tx_total_pkts_dl_multicast>0){
    LOG_I(OTG,"[MULTICAST] Total packets(TX)= %d \n", tx_total_pkts_dl_multicast);
    LOG_I(OTG,"[MULTICAST] Total bytes(TX)= %d \n", tx_total_bytes_dl_multicast);
    LOG_I(OTG,"[MULTICAST] Total packets(RX)= %d \n", rx_total_pkts_dl_multicast);
    LOG_I(OTG,"[MULTICAST] Total bytes(RX)= %d \n", rx_total_bytes_dl_multicast);
    LOG_I(OTG,"[MULTICAST] otg_multicast_info->ctime = %d \n", otg_multicast_info->ctime);
    LOG_I(OTG,"[MULTICAST] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl_multicast*1000*8)/(otg_info->ctime*1024));
    LOG_I(OTG,"[MULTICAST] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl_multicast*1000*8)/(otg_info->ctime*1024));
709
  }
710
 
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731

  LOG_F(OTG,"**************** TOTAL DL 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_dl);
  LOG_F(OTG,"[DATA] Total packets(RX)= %d \n", rx_total_pkts_dl);
  LOG_F(OTG,"[DATA] Total bytes(TX)= %d \n", tx_total_bytes_dl);
  LOG_F(OTG,"[DATA] Total bytes(RX)= %d \n", rx_total_bytes_dl);
  LOG_F(OTG,"[DATA] OWD MIN (one way)ms= %.2f \n", min_owd_dl);
  LOG_F(OTG,"[DATA] OWD MAX (one way)ms= %.2f \n", max_owd_dl);
  LOG_F(OTG,"[DATA] JITTER AVG ms= %lf \n",  otg_info->average_jitter_dl/(float)num_active_source);
  LOG_F(OTG,"[DATA] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl*1000*8)/(otg_info->ctime*1024));
  LOG_F(OTG,"[DATA] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl*1000*8)/(otg_info->ctime*1024));
  LOG_F(OTG,"[DATA] NB lost packet = %d \n", tx_total_pkts_dl - rx_total_pkts_dl );
  if ((g_otg->background_stats==1)&&(tx_total_pkts_dl_background>0)){
    LOG_F(OTG,"[BACKGROUND] Total packets(TX)= %d \n", tx_total_pkts_dl_background);
    LOG_F(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", tx_total_bytes_dl_background);
    LOG_F(OTG,"[BACKGROUND] Total packets(RX)= %d \n", rx_total_pkts_dl_background);
    LOG_F(OTG,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_dl_background);
    LOG_F(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl_background*1000*8)/(otg_info->ctime*1024));
    LOG_F(OTG,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl_background*1000*8)/(otg_info->ctime*1024));
	}
732 733 734 735 736 737 738 739 740
  if (tx_total_pkts_dl_multicast>0){
    LOG_F(OTG,"[MULTICAST] Total packets(TX)= %d \n", tx_total_pkts_dl_multicast);
    LOG_F(OTG,"[MULTICAST] Total bytes(TX)= %d \n", tx_total_bytes_dl_multicast);
    LOG_F(OTG,"[MULTICAST] Total packets(RX)= %d \n", rx_total_pkts_dl_multicast);
    LOG_F(OTG,"[MULTICAST] Total bytes(RX)= %d \n", rx_total_bytes_dl_multicast);
    LOG_F(OTG,"[MULTICAST] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_dl_multicast*1000*8)/(otg_info->ctime*1024));
    LOG_F(OTG,"[MULTICAST] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl_multicast*1000*8)/(otg_info->ctime*1024));
	}
 
741 742 743 744 745 746 747 748 749 750 751 752 753

  
	LOG_I(OTG,"**************** TOTAL UL RESULTS ******************\n");
  LOG_I(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
  LOG_I(OTG,"[DATA] Total packets(TX)= %d \n", tx_total_pkts_ul);
  LOG_I(OTG,"[DATA] Total packets(RX)= %d \n", rx_total_pkts_ul);
  LOG_I(OTG,"[DATA] Total bytes(TX)= %d \n", tx_total_bytes_ul);
  LOG_I(OTG,"[DATA] Total bytes(RX)= %d \n", rx_total_bytes_ul);
  LOG_I(OTG,"[DATA] OWD MIN (one way)ms= %.2f \n", min_owd_ul);
  LOG_I(OTG,"[DATA] OWD MAX (one way)ms= %.2f \n", max_owd_ul);
  LOG_I(OTG,"[DATA] JITTER AVG ms= %lf \n",  otg_info->average_jitter_ul/(float)num_active_source);
  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));
Navid Nikaein's avatar
Navid Nikaein committed
754 755 756 757
  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;
  
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777
  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);
    LOG_I(OTG,"[BACKGROUND] Total bytes(TX)= %d \n", tx_total_bytes_ul_background);
    LOG_I(OTG,"[BACKGROUND] Total packets(RX)= %d \n", rx_total_pkts_ul_background);
    LOG_I(OTG,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_ul_background);
    LOG_I(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
    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 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);
  LOG_F(OTG,"[DATA] Total bytes(TX)= %d \n", tx_total_bytes_ul);
  LOG_F(OTG,"[DATA] Total bytes(RX)= %d \n", rx_total_bytes_ul);
  LOG_F(OTG,"[DATA] OWD MIN (one way)ms= %.2f \n", min_owd_ul);
  LOG_F(OTG,"[DATA] OWD MAX (one way)ms= %.2f \n", max_owd_ul);
  LOG_F(OTG,"[DATA] JITTER AVG ms= %lf \n",  otg_info->average_jitter_ul/(float)num_active_source);
  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));
Navid Nikaein's avatar
Navid Nikaein committed
778
  LOG_F(OTG,"[DATA] NB lost packet = %d \n", tx_total_pkts_ul - rx_total_pkts_ul );
779 780 781 782 783 784 785 786 787 788
  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);
    LOG_F(OTG,"[BACKGROUND] Total packets(RX)= %d \n", rx_total_pkts_ul_background);
    LOG_F(OTG,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_ul_background);
    LOG_F(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
    LOG_F(OTG,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));

  }

Navid Nikaein's avatar
Navid Nikaein committed
789 790 791 792
  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");
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
#endif
}


void add_log_metric(int src, int dst, int ctime, double metric, unsigned int label){
 unsigned int i;
 unsigned int j;
 unsigned int node_actif=0;

 //LOG_I(OTG,"[%d][%d] LOGG_ADDED ctime=%d, metric=%.2f  \n", src, dst, ctime, metric);

 switch (label) {
 case OTG_LATENCY:
   add_log_label(label, &start_log_latency);
   break;
 case OTG_LATENCY_BG:
   add_log_label(label, &start_log_latency_bg);
   break;
 case OTG_GP:
   add_log_label(label, &start_log_GP);
   break;
 case OTG_GP_BG:
   add_log_label(label, &start_log_GP_bg);
   break;
817 818 819 820
 case OTG_JITTER:
   add_log_label(label, &start_log_GP_bg);
   break;
    
821
 default:
822
   LOG_E(OTG, "File label unknown %d \n", label);
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863
 }

 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;
    if ((g_otg->idt_dist[i][j][0][PE_STATE]>0) || (g_otg->application_type[i][j][0] >0))
      node_actif=1;
    
    if ((node_actif>0) && ((i==src) && (j==dst)))
          LOG_F(label,"  %f  ", metric);
      if  ((node_actif>0) && ((i!=src) || (j!=dst)))
          LOG_F(label,"  %d  ", 0);
  }
 }
 LOG_F(label,"%f\n", metric);
}



void  add_log_label(unsigned int label, unsigned int * start_log_metric){
 unsigned int i;
 unsigned int j;
 unsigned int node_actif=0;

 if (*start_log_metric==0){
 *start_log_metric=1;
   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,"Aggregated\n");
 }
}