Esempio n. 1
0
    /**
     * Generates a random covariance matrix.
     * \return A random covariance matrix.
     */
    point_type random_point() const 
    {
      boost::uniform_01<pp::global_rng_type&, double> uniform_rng(pp::get_global_rng());
      mat<value_type,mat_structure::diagonal> D(mat_size);
      for(size_type i = 0; i < mat_size; ++i)
	D(i,i) = uniform_rng() * max_eigenvalue;
      
      mat<value_type,mat_structure::skew_symmetric> S(mat_size);
      for(size_type i = 1; i < mat_size; ++i)
	for(size_type j = 0; j < i; ++j)
	  S(j,i) = uniform_rng() * value_type(10.0);
      mat<value_type,mat_structure::square> Q(S);
      exp_PadeSAS(S,Q,QR_linlsqsolver());
      
      return point_type(matrix_type(transpose_view(Q) * (D * Q)));
    };
Esempio n. 2
0
    inline double
    pareto_type_2_rng(double mu,
                      double lambda,
                      double alpha,
                      RNG& rng) {
      static const char* function("pareto_type_2_rng");

      check_positive(function, "scale parameter", lambda);
      double uniform_01 = uniform_rng(0.0, 1.0, rng);
      return (std::pow(1.0 - uniform_01, -1.0 / alpha) - 1.0) * lambda + mu;
    }
Esempio n. 3
0
/* 
 this function updates a given background stream
 input:		- bg-stream
			- current time
 output: 	
 */
void backgroundUpdateStream(backgroundStream_t *stream, int ctime){
  int numNewSessions, cnts, period;

  LOG_D(OTG,"BACKGROUND DEBUG: backgroundUpdateStream(stream*=%p,ctime=%d) called\n", stream, ctime);
  if(stream){
	period=ctime-stream->lastUpdateTime;
	numNewSessions=poisson_dist(stream->meanNumSessions/5710*period);
	for(cnts=0; cnts<BACKGROUND_NUM_ACTIVE_MAX; cnts++){
	  if(stream->activeSessions[cnts].endTime<ctime){
		if(numNewSessions>0){
		  stream->activeSessions[cnts].meanSessionRate=backgroundRateRnd();
		  stream->activeSessions[cnts].endTime=
			ctime-period*uniform_rng()+backgroundSessionDurationRnd(); /*ms*/
		  numNewSessions--;
		}else{
		  stream->activeSessions[cnts].meanSessionRate=0;
		  stream->activeSessions[cnts].endTime=-1;
		}
	  }
	}
	stream->lastUpdateTime=ctime;
	backgroundPrintStream (stream);
  }
}
Esempio n. 4
0
/* 
 this function initializes a background stream and allocates memory if needed
 input:		- the bg-stream (or zero if memory shall be allocated)
 			- the mean number of users (sessions) to be expected for this stream
 output: 	- the same bg-stream
 */
backgroundStream_t *backgroundStreamInit(backgroundStream_t *stream, double lambda_n){
  int cnts, numactivenow;
  if(stream==0){
	stream=(backgroundStream_t*) malloc(sizeof(backgroundStream_t));
  }

  stream->meanNumSessions=lambda_n;
  stream->lastUpdateTime=0;
  numactivenow=poisson_dist(lambda_n); /*how many sessions are active (i.e., started before simulation)*/
  for(cnts=0; cnts<BACKGROUND_NUM_ACTIVE_MAX; cnts++){
	if(cnts<numactivenow){
	  /*these sessions are already active for unknown time and have therefore a random phaseshift in ds*/
	  stream->activeSessions[cnts].meanSessionRate=backgroundRateRnd();
	  stream->activeSessions[cnts].endTime=ceil((double)backgroundSessionDurationRnd()*uniform_rng()); /*ms*/
	}else{
	  stream->activeSessions[cnts].meanSessionRate=0;
	  stream->activeSessions[cnts].endTime=-1;
	}
  }

  LOG_D(OTG,"BACKGROUND_USERS DEBUG: backgroundStreamInit(%p) called\n", stream);
  backgroundPrintStream (stream);
  return stream;
}
Esempio n. 5
0
void init_config_otg(char *protocol, char *ip_version)
{

  int i, j, k;

  if (simu_time>0)
    SIMU_TIME=simu_time;

  printf("OTG :: INIT CONFIG\n");

  if (seed>0)
    g_otg->seed=seed;
  else
    g_otg->seed=ceil(uniform_rng()*67534);

  printf("duration %d, seeds %d \n", duration, g_otg->seed);


  for (i=0; i<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); i++) {



    if (duration>0)
      g_otg->duration[i]=duration;
    else
      g_otg->duration[i]=10000;


    g_otg->dst_port[i]=DST_PORT;
    g_otg->dst_ip[i]=(char*)malloc(100*sizeof(char*));
    g_otg->dst_ip[i]=DST_IP;
    g_otg->dst_ip[i]=DST_IP;

    //config ip version


    if (ip_version !=NULL) {
      if ((strcmp(ip_version,"IP4")==0) ||(strcmp(ip_version,"ip4")==0))
        g_otg->ip_v[i]=IPV4;
      else if ((strcmp(ip_version,"IP6")==0) ||(strcmp(ip_version,"ip6")==0))
        g_otg->ip_v[i]=IPV6;
    } else
      g_otg->ip_v[i]=IPV4;


    //config transport protocol version
    if (protocol!=NULL) {
      if ((strcmp(protocol,"TCP")==0) ||(strcmp(protocol,"tcp")==0))
        g_otg->trans_proto[i]=TCP;
      else if ((strcmp(protocol,"UDP")==0) ||(strcmp(protocol,"udp")==0))
        g_otg->trans_proto[i]=UDP;
    } else
      g_otg->trans_proto[i]=TCP;

    for (j=0; j<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); j++) {
      g_otg->application_type[i][j]=OPENARENA;

      for (k=0; k<MAX_NUM_TRAFFIC_STATE; k++) {
        LOG_I(OTG,"INIT CONFIG Source =%d, Destination =%d,State =%d \n",i, j, k);
        g_otg->idt_dist[i][j][k]=IDT_DIST;
        g_otg->idt_min[i][j][k]=IDT_MIN;
        g_otg->idt_max[i][j][k]=IDT_MAX;
        g_otg->idt_std_dev[i][j][k]=IDT_STD_DEV;
        g_otg->idt_lambda[i][j][k]=IDT_LAMBDA;
        g_otg->size_dist[i][j][k]=PKTS_SIZE_DIST;
        g_otg->size_min[i][j][k]=PKTS_SIZE_MIN;
        g_otg->size_max[i][j][k]=PKTS_SIZE_MAX;
        g_otg->size_std_dev[i][j][k]=PKTS_SIZE_STD_DEV;
        g_otg->size_lambda[i][j][k]=PKTS_SIZE_LAMBDA;
      }

    }


  }



}
Esempio n. 6
0
int main_below_ip()
{
  int i, j, k, l, rtt_owd ,rx_otg=0, simu_time=0, ctime=0, nb_round=0;
  float p;
  char *packet;
  int rx_packet_out;
  int pkt_size;
  printf(" max enb %d, max ue %d \n", NUMBER_OF_eNB_MAX, NUMBER_OF_UE_MAX);

  do {

    nb_round=nb_round+1;

    // for (stime=0; stime < SIMU_TIME; stime++) // discrete event generation : tick, stime generate the ctime
    for (i=0; i<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); i++) {

      for (j=0; j<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); j++) {

        for (k=0; k<MAX_NUM_TRAFFIC_STATE; k++) {
          LOG_I(OTG,"OTG emulation src=%d, dst=%d, state=%d \n", i, j, k);



          ctime=0; // set the ctime to 0

          do {

            if (simu_time> SIMU_TIME) {

              otg_info->ctime=SIMU_TIME;
              return(0);
            }

            LOG_I(OTG,"val :: ctime=%d\n", ctime);
            char *packet=NULL;
            /*packet=packet_gen(i, j, k, ctime);*/ packet=packet_gen(i, j, ctime, &pkt_size);



            if (packet!=NULL) {
              if ((ceil(g_otg->duration[i]*uniform_rng()))==ctime)  {
                printf("DROP PACKET (i=%d,j=%d) seq num=%d\n",i, j, otg_info->seq_num[i][j]);

              } else  {
                printf("SEND PACKET (i=%d,j=%d) seq num=%d\n",i, j, otg_info->seq_num[i][j]);

                rtt_owd=ceil(uniform_rng()*8.56);
                LOG_I(OTG,"one way delay= %d , (src=%d, dst=%d, state=%d)\n", rtt_owd, i, j, k);
                ctime+=rtt_owd;
                otg_info->rx_pkt_owd[i][j]=rtt_owd;
                simu_time+=rtt_owd;

                //rx_packet_out=check_packet(i, j, ctime, packet);
                rx_packet_out=otg_rx_pkt(i,j, ctime, packet, pkt_size);
                //if (rx_packet_out==NULL)
                //  LOG_I(OTG,"PKTS INFO:: DROPED\n");
                //else{
                //  if (rx_packet_out!=NULL){
                //    rx_packet_out=NULL;
                free(packet);
                //  }

                //}

                //Do not increase the ctime and simu_time with the one way delay.
                ctime-=rtt_owd;
                simu_time-=rtt_owd;


                LOG_I(OTG,"PKTS INFO:: (src=%d, dst=%d, state=%d),NB PKTS=%d  ,sequence NB=%d,  RTT (one way)ms= %d \n ",i, j, k, otg_info->tx_num_pkt[i][j], otg_info->seq_num[i][j], otg_info->rx_pkt_owd[i][j]);
              }
            } else
              printf("Node (i=%d,j=%d) seq num=%d, ctime %d, prb %lf\n",i, j, otg_info->seq_num[i][j], ctime,(ceil(g_otg->duration[i]*uniform_rng())));

            LOG_I(OTG,"Time:: ctime=%d, duration=%d, simu_time=%d, max=%d, (src=%d, dst=%d, state=%d) \n", ctime,  g_otg->duration[i],simu_time, SIMU_TIME, i, j,k);
            ctime+=1;
            simu_time+=1;
          } while (ctime<=g_otg->duration[i]) ;
        }



        if  (otg_info->tx_num_pkt[i][j]>otg_info->rx_num_pkt[i][j])
          LOG_I(OTG,"STAT: (LOSS):: (src=%d, dst=%d) NB packet TX= %d,  NB packet RX = %d, seq NUM=%d\n ",i, j, otg_info->tx_num_pkt[i][j], otg_info->rx_num_pkt[i][j],otg_info->seq_num[i][j] );
        else
          LOG_I(OTG,"STAT: :: (src=%d, dst=%d) NB packet TX= %d,  NB packet RX= %d, seq NUM=%d \n ",i, j, otg_info->tx_num_pkt[i][j], otg_info->rx_num_pkt[i][j], otg_info->seq_num[i][j]);



      }
    }



  } while (simu_time<=SIMU_TIME);

}