int
start_steadystaterwp_generator (omg_global_param omg_param_list)
{
  static int n_id = 0;
  int id;
  double cur_time = 0.0, pause_p;
  node_struct *node = NULL;
  mobility_struct *mobility = NULL;
  pair_struct *pair = NULL;

  pause_p = pause_probability (omg_param_list);

  srand (omg_param_list.seed + RWP);

  LOG_I (OMG, "STEADY_RWP mobility model for %d %d nodes\n",
         omg_param_list.nodes, omg_param_list.nodes_type);

  for (id = n_id; id < (omg_param_list.nodes + n_id); id++) {

    node = create_node ();
    mobility = create_mobility ();

    node->id = id;
    node->type = omg_param_list.nodes_type;
    node->mob = mobility;
    node->generator = STEADY_RWP;
    node->event_num = 0;
    place_rwp_node (node);  //initial positions

    pair = (pair_struct *) malloc (sizeof (struct pair_struct));
    pair->b = node;
    //pause probability...some of the nodes start at pause & the other on move

    if (randomgen (0, 1) < pause_p)
      sleep_steadystaterwp_node (pair, cur_time); //sleep
    else
      move_steadystaterwp_node (pair, cur_time);

    job_vector_end[STEADY_RWP] = add_job (pair, job_vector_end[STEADY_RWP]);

    if (job_vector[STEADY_RWP] == NULL)
      job_vector[STEADY_RWP] = job_vector_end[STEADY_RWP];

    job_vector_len[STEADY_RWP]++;
  }

  n_id += omg_param_list.nodes;



  if (job_vector[STEADY_RWP] == NULL)
    LOG_E (OMG, "[STEADY_RWP] Job Vector is NULL\n");

  return (0);
}
Example #2
0
int
start_rwalk_generator (omg_global_param omg_param_list)
{

  int id;
  static int n_id = 0;
  double cur_time = 0.0, pause_p, mean_pause, mean_travel;
  node_struct *node = NULL;
  mobility_struct *mobility = NULL;
  pair_struct *pair = NULL;

  srand (omg_param_list.seed + RWALK);

  mean_pause = (omg_param_list.max_sleep - omg_param_list.min_sleep) / 2;
  mean_travel =
    (omg_param_list.max_journey_time - omg_param_list.min_journey_time) / 2;
  pause_p = mean_pause / (mean_travel + mean_pause);

  LOG_I (OMG, "#RWALK mobility model for %d %d nodes\n", omg_param_list.nodes,
         omg_param_list.nodes_type);

  for (id = n_id; id < (omg_param_list.nodes + n_id); id++) {

    node = create_node ();
    mobility = create_mobility ();

    node->id = id;
    node->type = omg_param_list.nodes_type;
    node->mob = mobility;
    node->generator = RWALK;
    node->event_num = 0;
    place_rwalk_node (node);  //initial positions

    pair = (pair_struct *) malloc (sizeof (struct pair_struct));
    pair->b = node;
    // sleep_rwalk_node (pair, cur_time); //sleep
    //pause probability...some of the nodes start at pause & the other on move

    if (randomgen (0, 1) < pause_p)
      sleep_steadystaterwp_node (pair, cur_time); //sleep
    else
      move_steadystaterwp_node (pair, cur_time);


    job_vector_end[RWALK] = add_job (pair, job_vector_end[RWALK]);

    if (job_vector[RWALK] == NULL)
      job_vector[RWALK] = job_vector_end[RWALK];

    job_vector_len[RWALK]++;
  }

  n_id += omg_param_list.nodes;



  if (job_vector[RWALK] == NULL)
    LOG_E (OMG, "[RWP] Job Vector is NULL\n");

  return (0);
}
Example #3
0
/*set new mobility for a node*/
void
set_new_mob_type (int id, int node_t, int mob_t, double cur_time)
{

  int prev_mob;
  node_list *tmp;
  //job_list *tmp2, *prev_job;
  pair_struct *pair;
  double pause_p;

  //find previous mobility type
  tmp = node_vector[node_t];

  while (tmp != NULL) {
    if (tmp->node->id == id && tmp->node->type == node_t) {
      prev_mob = tmp->node->generator;
      break;
    }

    tmp = tmp->next;
  }

  //end

  if (tmp != NULL && prev_mob != mob_t) {

    //initialize node position
    if (mob_t == STATIC || mob_t == RWP || mob_t == RWALK || mob_t == STEADY_RWP) {
      tmp->node->x_pos =
        (double) ((int)
                  (randomgen
                   (omg_param_list[node_t].min_x,
                    omg_param_list[node_t].max_x) * 100)) / 100;
      tmp->node->mob->x_from = tmp->node->x_pos;
      tmp->node->mob->x_to = tmp->node->x_pos;
      tmp->node->y_pos =
        (double) ((int)
                  (randomgen
                   (omg_param_list[node_t].min_y,
                    omg_param_list[node_t].max_y) * 100)) / 100;
      tmp->node->mob->y_from = tmp->node->y_pos;
      tmp->node->mob->y_to = tmp->node->y_pos;
      tmp->node->mob->speed = 0.0;
      tmp->node->generator = mob_t;

      if (prev_mob != STATIC)
        job_vector[prev_mob] =
          remove_job (job_vector[prev_mob], id, node_t);
    }

    //end

    switch (mob_t) {

    case STATIC:

      break;

    case RWP:
      pair = (pair_struct *) malloc (sizeof (struct pair_struct));
      pair->b = tmp->node;
      sleep_rwp_node (pair, cur_time);
      job_vector[RWP] = addjob (pair, job_vector[RWP]);
      break;

    case RWALK:
      pair = (pair_struct *) malloc (sizeof (struct pair_struct));
      pair->b = tmp->node;
      sleep_rwalk_node (pair, cur_time);
      job_vector[RWALK] = addjob (pair, job_vector[RWALK]);
      break;

    case STEADY_RWP:
      tmp->node->event_num = 0;
      pair = (pair_struct *) malloc (sizeof (struct pair_struct));
      pair->b = tmp->node;
      pause_p = pause_probability (omg_param_list[node_t]);

      if (randomgen (0, 1) < pause_p)
        sleep_steadystaterwp_node (pair, cur_time);
      else
        move_steadystaterwp_node (pair, cur_time);

      break;
#ifdef SUMO_IF
    case SUMO:
      LOG_E (OMG, "not possible to change mobility type to sumo \n");
      break;
#endif
    case TRACE:
      LOG_E (OMG, "not possible to change mobility type to trace \n");
      break;

    default:
      LOG_E (OMG, " Unsupported generator \n");
    }

  }


}