예제 #1
0
int ocg_config_topo() {

	// omg
	init_omg_global_params();

	// setup params for openair mobility generator
	//common params

	omg_param_list.min_X = 0;
	omg_param_list.max_X = oai_emulation.topology_config.area.x_km;
	omg_param_list.min_Y = 0;
	omg_param_list.max_Y = oai_emulation.topology_config.area.y_km;
	// init values
	omg_param_list.min_speed = 0.1;
	omg_param_list.max_speed = 20.0;
	omg_param_list.min_journey_time = 0.1;
	omg_param_list.max_journey_time = 10.0;
	omg_param_list.min_azimuth = 0; // ???
	omg_param_list.max_azimuth = 360; // ???
	omg_param_list.min_sleep = 0.1;
	omg_param_list.max_sleep = 8.0;
	

	// init OMG for eNB
	if (!strcmp(oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option, "STATIC")) {
		oai_emulation.info.omg_model_enb = STATIC;
	} else if (!strcmp(oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option, "RWP")) {
		oai_emulation.info.omg_model_enb = RWP; // set eNB to be random waypoint
	}
	omg_param_list.mobility_type = oai_emulation.info.omg_model_enb; 
		
	omg_param_list.nodes_type = eNB;  //eNB
	omg_param_list.nodes = oai_emulation.info.nb_enb_local;
 	omg_param_list.seed = oai_emulation.info.seed; // specific seed for enb and ue to avoid node overlapping
	
	omg_param_list.mobility_file = (char*) malloc(256);
	sprintf(omg_param_list.mobility_file,"%s/UTIL/OMG/mobility.txt",getenv("OPENAIR2_DIR")); // default trace-driven mobility file

	// at this moment, we use the above moving dynamics for mobile eNB
	if (omg_param_list.nodes >0 ) 
	  init_mobility_generator(omg_param_list);
	
	// init OMG for UE
	// input of OMG: STATIC: 0, RWP: 1, RWALK 2, or TRACE 3
	
	if ((oai_emulation.info.omg_model_ue = map_str_to_int(omg_model_names, oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option))== -1)
	  oai_emulation.info.omg_model_ue = STATIC; 
	omg_param_list.mobility_type    = oai_emulation.info.omg_model_ue; 

		
	omg_param_list.mobility_type = oai_emulation.info.omg_model_ue;

	omg_param_list.nodes_type = UE;//UE
	omg_param_list.nodes = oai_emulation.info.nb_ue_local;
	omg_param_list.seed = oai_emulation.info.seed; // specific seed for enb and ue to avoid node overlapping

	omg_param_list.min_speed = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_speed_mps == 0) ? 0.1 : oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_speed_mps;
	omg_param_list.max_speed = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_speed_mps == 0) ? 0.1 : oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_speed_mps;

	omg_param_list.min_journey_time = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_journey_time_ms == 0) ? 0.1 : oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_journey_time_ms;
	omg_param_list.max_journey_time = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_journey_time_ms == 0) ? 0.1 : oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_journey_time_ms;

	omg_param_list.min_azimuth = 0.1; // wait for advanced OSD
	omg_param_list.max_azimuth = 360;

	omg_param_list.min_sleep = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_sleep_ms == 0) ? 0.1 : oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.min_sleep_ms;
	omg_param_list.max_sleep = (oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_sleep_ms == 0) ? 0.1 : oai_emulation.topology_config.mobility.UE_mobility.UE_moving_dynamics.max_sleep_ms;
	
	omg_param_list.mobility_file = (char*) malloc(256);
	sprintf(omg_param_list.mobility_file,"%s/UTIL/OMG/mobility.txt",getenv("OPENAIR2_DIR")); // default trace-driven mobility file

	if (omg_param_list.nodes >0 ) 
	  init_mobility_generator(omg_param_list);
	


return 1;
}
예제 #2
0
int
main (int argc, char *argv[])
{
  int i, node_type;
  double cur_time = 0.0;
  double ms = 0.0;
  node_list *current_positions = NULL;
  node_struct *my_node = NULL;
  int my_id = 0, time_s;
  double emu_info_time;
  char full_name[200];
  int pfd[2];     // fd for omv : fixme: this could be a local var
  char fdstr[10];
  char frames[10];
  char num_enb[10];
  char num_ue[10];
  //area_x, area_y and area_z for omv
  char x_area[20];
  char y_area[20];
  char z_area[20];
  char fname[64], vname[64];
  Data_Flow_Unit omv_data;

  //default parameters
  for (node_type = eNB; node_type < MAX_NUM_NODE_TYPES; node_type++) {


    if (node_type == UE)
      omg_param_list[node_type].nodes = 5;
    else
      omg_param_list[node_type].nodes = 0;

    omg_param_list[node_type].min_x = 0;
    omg_param_list[node_type].max_x = 100;
    omg_param_list[node_type].min_y = 0;
    omg_param_list[node_type].max_y = 100;
    omg_param_list[node_type].min_speed = 0.1;
    omg_param_list[node_type].max_speed = 20.0;
    omg_param_list[node_type].min_journey_time = 0.1;
    omg_param_list[node_type].max_journey_time = 20.0;
    omg_param_list[node_type].min_azimuth = 0;
    omg_param_list[node_type].max_azimuth = 360;
    omg_param_list[node_type].min_sleep = 0.1;
    omg_param_list[node_type].max_sleep = 5.0;
    omg_param_list[node_type].mobility_file = "TRACE/mobility_3ues.tr";
    omg_param_list[node_type].mobility_type = STATIC;
    omg_param_list[node_type].nodes_type = node_type;
    //omg_param_list.sumo_config = "SUMO/SCENARIOS/traci.koln.sumo.cfg";
    omg_param_list[node_type].sumo_command = "sumo-gui";
    omg_param_list[node_type].sumo_config =
      "SUMO/SCENARIOS/traci.scen.sumo.cfg";
    omg_param_list[node_type].sumo_start = 0; //25900;
    omg_param_list[node_type].sumo_end = 200; //26200;
    omg_param_list[node_type].sumo_step = 1;
    omg_param_list[node_type].sumo_host = "localhost";
    omg_param_list[node_type].sumo_port = 8890;
  }


  init_omg_global_params ();  //initialize global paramaters

  get_options (argc, argv); // overwrite the default params if any input parameter

  for (node_type = eNB; node_type < MAX_NUM_NODE_TYPES; node_type++) {
    omg_param_list[node_type].max_vertices =
      max_vertices_ongrid (omg_param_list[node_type]);

    omg_param_list[node_type].max_block_num =
      max_connecteddomains_ongrid (omg_param_list[node_type]);

  }



  init_mobility_generator (omg_param_list); //initialize choosen mobility generator

  // ****************init omv********************
  if (omv_enabled == 1) {
    if (pipe (pfd) == -1)
      perror ("pipe error \n");

    sprintf (full_name, "%s/UTIL/OMV/OMV", getenv ("OPENAIR2_DIR"));
    LOG_I (EMU, "Stating the OMV path %s pfd[0] %d pfd[1] %d \n", full_name,
           pfd[0], pfd[1]);





    switch (fork ()) {
    case -1:
      perror ("fork failed \n");
      break;

    case 0:
      if (close (pfd[1]) == -1)
        perror ("close on write\n");

      sprintf (fdstr, "%d", pfd[0]);
      sprintf (num_enb, "%d", 1);
      sprintf (num_ue, "%d", omg_param_list[UE].nodes);
      sprintf (x_area, "%f", omg_param_list[UE].max_x);
      sprintf (y_area, "%f", omg_param_list[UE].max_y);
      sprintf (z_area, "%f", 200.0);
      sprintf (frames, "%d", (int) n_frames);

      execl (full_name, "OMV", fdstr, frames, num_enb, num_ue, x_area,
             y_area, z_area, NULL);
      perror ("error in execl the OMV");
    }

    //parent
    if (close (pfd[0]) == -1)
      perror ("close on read\n");
  }

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

  for (emu_info_time = 0.0; emu_info_time <= n_frames; emu_info_time += 0.1) {

    update_nodes (emu_info_time);
    time_s = round (emu_info_time * 1000.0);

    //printf("%d \n",time_s);
    for (node_type = eNB; node_type < MAX_NUM_NODE_TYPES; node_type++) {
      current_positions =
        get_current_positions (omg_param_list[node_type].mobility_type,
                               node_type, emu_info_time);

      if (current_positions != NULL)

        display_job_list (emu_info_time,
                          job_vector[omg_param_list
                                     [node_type].mobility_type]);

      /*if(current_positions!= NULL && time_s %1000==0)
         LOG_D(OMG, "%.2f  %d\n",emu_info_time,
         nodes_avgspeed(job_vector[omg_param_list [node_type].mobility_type])); */
    }


    //display current postion of nodes
    if (omv_enabled == 1)
      omv_write (pfd[1], node_vector[SUMO], omv_data);


  }

  /*LOG_I(OMG,"#-----event average-----\n");
     for (i=0;i<100;i++)
     {
     if(events[i]!=0)
     LOG_D(OMG,"%d %d \n",i,event_sum[i]/events[i]);
     } */

  stop_mobility_generator (omg_param_list);

  if (omv_enabled == 1)
    omv_end (pfd[1], omv_data);

  //clear_mem();

  return 0;
}