/* ************************************************** */ int setnode(call_t *c, void *params) { struct entitydata *entitydata = get_entity_private_data(c); struct nodedata *nodedata = malloc(sizeof(struct nodedata)); char str[128]; int id, dst, n_hop; /* extract routing table from file */ nodedata->routes = hadas_create(route_hash, route_equal); /* extract routing table from file */ fseek(entitydata->file, 0L, SEEK_SET); while (fgets(str, 128, entitydata->file) != NULL) { if (sscanf(str, "%d %d %d\n", &id, &dst, &n_hop) != 3) { fprintf(stderr, "filestatic: unable to read route in setnode()\n"); goto error; } if (id == c->node) { struct route *route = (struct route *) malloc(sizeof(struct route)); route->dst = dst; route->n_hop = n_hop; hadas_insert(nodedata->routes, (void *) ((unsigned long) (route->dst)), (void *) route); } } nodedata->overhead = -1; set_node_private_data(c, nodedata); return 0; error: free(entitydata); return -1; }
/* ************************************************** */ int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); param_t *param; uint64_t min_pausetime, max_pausetime; /* default values */ get_node_position(c->node)->x = get_random_x_position(); get_node_position(c->node)->y = get_random_y_position(); get_node_position(c->node)->z = get_random_z_position(); nodedata->pausetime = 2000000000; min_pausetime = 0; max_pausetime = 0; /* get parameters */ das_init_traverse(params); while ((param = (param_t *) das_traverse(params)) != NULL) { if (!strcmp(param->key, "x")) { if (get_param_x_position(param->value, &(get_node_position(c->node)->x))) { goto error; } } if (!strcmp(param->key, "y")) { if (get_param_y_position(param->value, &(get_node_position(c->node)->y))) { goto error; } } if (!strcmp(param->key, "z")) { if (get_param_z_position(param->value, &(get_node_position(c->node)->z))) { goto error; } } if (!strcmp(param->key, "pausetime")) { if (get_param_time(param->value, &(nodedata->pausetime))) { goto error; } } if (!strcmp(param->key, "min-pausetime")) { if (get_param_time(param->value, &min_pausetime)) { goto error; } } if (!strcmp(param->key, "max-pausetime")) { if (get_param_time(param->value, &max_pausetime)) { goto error; } } } if (min_pausetime < max_pausetime ) { nodedata->pausetime = get_random_time_range(min_pausetime, max_pausetime); } set_node_private_data(c, nodedata); return 0; error: free(nodedata); return -1; }
/* ************************************************** */ int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); param_t *param; /* default values */ nodedata->neighbors = das_create(); nodedata->overhead = -1; nodedata->hello_tx = 0; nodedata->hello_rx = 0; nodedata->data_tx = 0; nodedata->data_rx = 0; nodedata->data_noroute = 0; nodedata->data_hop = 0; nodedata->start = 0; nodedata->hop = 32; nodedata->period = 1000000000; nodedata->timeout = 2500000000ull; /* get params */ das_init_traverse(params); while ((param = (param_t *) das_traverse(params)) != NULL) { if (!strcmp(param->key, "start")) { if (get_param_time(param->value, &(nodedata->start))) { goto error; } } if (!strcmp(param->key, "period")) { if (get_param_time(param->value, &(nodedata->period))) { goto error; } } if (!strcmp(param->key, "hop")) { if (get_param_integer(param->value, &(nodedata->hop))) { goto error; } } if (!strcmp(param->key, "timeout")) { if (get_param_time(param->value, &(nodedata->timeout))) { goto error; } } } set_node_private_data(c, nodedata); return 0; error: free(nodedata); return -1; }
/* ************************************************** */ int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); param_t *param; /* Find all the neighbors for this node */ nodedata->neighbors = das_create(); nodedata->curr_dst = -1; nodedata->curr_nexthop = NULL; /* default values */ nodedata->overhead = -1; nodedata->hop = 32; nodedata->range = 1; nodedata->random_nexthop = 0; /* Get parameters from config file */ das_init_traverse(params); while ((param = (param_t *) das_traverse(params)) != NULL) { /* Hop-limit */ if (!strcmp(param->key, "hop")) { if (get_param_integer(param->value, &(nodedata->hop))) { goto error; } } /* Range in which neighbors are selected */ if (!strcmp(param->key, "range")) { if (get_param_double(param->value, &(nodedata->range))) { goto error; } } /* Randomize the choice of the next hop. 0 means never (always * take the nearest one from the destination), and a value >= 1 * randomizes the next hop every "value" time */ if (!strcmp(param->key, "random")) { if (get_param_integer(param->value, &(nodedata->random_nexthop))) { goto error; } } } nodedata->random_counter = nodedata->random_nexthop; set_node_private_data(c, nodedata); return 0; error: free(nodedata); return -1; }
/* ************************************************** */ int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); param_t *param; /* default values */ nodedata->Ts = 91; nodedata->channel = 0; nodedata->power = 0; nodedata->modulation = -1; nodedata->mindBm = -92; nodedata->sleep = 0; /* get parameters */ das_init_traverse(params); while ((param = (param_t *) das_traverse(params)) != NULL) { if (!strcmp(param->key, "sensibility")) { if (get_param_double(param->value, &(nodedata->mindBm))) { goto error; } } if (!strcmp(param->key, "T_s")) { if (get_param_time(param->value, &(nodedata->Ts))) { goto error; } } if (!strcmp(param->key, "channel")) { if (get_param_integer(param->value, &(nodedata->channel))) { goto error; } } if (!strcmp(param->key, "dBm")) { if (get_param_double(param->value, &(nodedata->power))) { goto error; } } if (!strcmp(param->key, "modulation")) { if (get_param_entity(param->value, &(nodedata->modulation))) { goto error; } } } set_node_private_data(c, nodedata); return 0; error: free(nodedata); return -1; }
/* ************************************************** */ int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); param_t *param; /* default values */ nodedata->noise = 0; nodedata->gain_tx = 0; nodedata->gain_rx = 0; nodedata->angle.xy = get_random_double_range(0, 2 * M_PI); nodedata->angle.z = get_random_double_range(0, 2 * M_PI); /* get parameters */ das_init_traverse(params); while ((param = (param_t *) das_traverse(params)) != NULL) { if (!strcmp(param->key, "gain-tx")) { if (get_param_double(param->value, &(nodedata->gain_tx))) { goto error; } } if (!strcmp(param->key, "gain-rx")) { if (get_param_double(param->value, &(nodedata->gain_rx))) { goto error; } } if (!strcmp(param->key, "loss")) { if (get_param_double(param->value, &(nodedata->noise))) { goto error; } } if (!strcmp(param->key, "angle-xy")) { if (get_param_double_range(param->value, &(nodedata->angle.xy), 0, 2*M_PI)) { goto error; } } if (!strcmp(param->key, "angle-z")) { if (get_param_double_range(param->value, &(nodedata->angle.z), 0, 2*M_PI)) { goto error; } } } set_node_private_data(c, nodedata); return 0; error: free(nodedata); return -1; }
//INITIALISATION DE NOEUD DE FICHIER XML int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); nodedata->overhead = -1; nodedata->range = -1; //les packets nodedata->paquets = Nullptr(list_PACKET); //les voisinages nodedata->oneHopNeighbourhood = Nullptr(listeNodes); nodedata->RNG = Nullptr(list); //STATS nodedata->nbr_evenement = 0; set_node_private_data(c, nodedata); SHOW_GRAPH("N: %d %lf %f\n",c->node,get_node_position(c->node)->x,get_node_position(c->node)->y); return 0; }
int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); int i = MAX_METADATA; int j = MAX_SOURCE; int k = MAX_SINK; /* init values */ while (i--) { nodedata->d_source[i] = -1; nodedata->d_value[i] = -1; nodedata->d_seq[i] = -1; } while (j--) { nodedata->s_seq[j] = -1; } while (k--) { nodedata->r_seq[k] = -1; } set_node_private_data(c, nodedata); return 0; }
// initialisation des noeuds a partir du fichier xml int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); struct protocoleData *entitydata = malloc(sizeof(struct protocoleData)); nodedata->overhead = -1; nodedata->oneHopNeighbourhood = 0; nodedata->twoHopNeighbourhood = 0; nodedata->g2hop = malloc(sizeof(graphe)); initGraphe(nodedata->g2hop, c->node); nodedata->BIP_tree = 0; nodedata->nbr_evenement = 0; //STATS nodedata->lastIDs = malloc(get_node_count()*sizeof(int)); nodedata->energiesRem = malloc(get_node_count()*sizeof(double)); set_node_private_data(c, nodedata); SHOW_GRAPH("N: %d %lf %f\n",c->node,get_node_position(c->node)->x,get_node_position(c->node)->y); // printf("Node %d at ( %.1lf ; %.1lf ; %.1lf )\n", c->node,get_node_position(c->node)->x,get_node_position(c->node)->y,get_node_position(c->node)->z); return 0; }
int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); param_t *param; int i = MAX_METADATA; int j = MAX_SOURCE; int k = MAX_SINK; /* default values */ nodedata->h_start = 0; nodedata->h_period = 1000000000; nodedata->h_timeout = nodedata->h_period * 2.5; nodedata->h_nbr = -1; nodedata->neighbors = das_create(); while (i--) { nodedata->d_source[i] = -1; nodedata->d_value[i] = -1; nodedata->d_seq[i] = -1; nodedata->d_hop[i] = -1; nodedata->d_time[i] = -1; } while (j--) { nodedata->s_seq[j] = -1; } while (k--) { nodedata->r_seq[k] = -1; } /* get parameters */ das_init_traverse(params); while ((param = (param_t *) das_traverse(params)) != NULL) { if (!strcmp(param->key, "hello-start")) { if (get_param_time(param->value, &(nodedata->h_start))) { fprintf(stderr,"[XY] Error while reading the hello-start parameter ! (%s)\n",param->value); goto error; } } if (!strcmp(param->key, "hello-period")) { if (get_param_time(param->value, &(nodedata->h_period))) { fprintf(stderr,"[XY] Error while reading the hello-period parameter ! (%s)\n",param->value); goto error; } } if (!strcmp(param->key, "hello-timeout")) { if (get_param_time(param->value, &(nodedata->h_timeout))) { fprintf(stderr,"[XY] Error while reading the hello-timeout parameter ! (%s)\n",param->value); goto error; } } if (!strcmp(param->key, "hello-nbr")) { if (get_param_integer(param->value, &(nodedata->h_nbr))) { fprintf(stderr,"[XY] Error while reading the hello-nbr parameter ! (%s)\n",param->value); goto error; } } } set_node_private_data(c, nodedata); return 0; error: free(nodedata); return -1; }
/* ************************************************** */ int setnode(call_t *c, void *params) { struct nodedata *nodedata = malloc(sizeof(struct nodedata)); param_t *param; nodedata->clock = 0; nodedata->state = STATE_IDLE; nodedata->packets = das_create(); nodedata->txbuf = NULL; nodedata->cca = 1; nodedata->cs = 1; nodedata->EDThreshold = EDThresholdMin; nodedata->MaxCSMABackoffs = macMaxCSMABackoffs; nodedata->MaxBE = macMaxBE; nodedata->MinBE = macMinBE; das_init_traverse(params); while ((param = (param_t *) das_traverse(params)) != NULL) { if (!strcmp(param->key, "cca")) { if (get_param_integer(param->value, &(nodedata->cca))) { goto error; } } if (!strcmp(param->key, "cs")) { if (get_param_integer(param->value, &(nodedata->cs))) { goto error; } } if (!strcmp(param->key, "max-csma-backoffs")) { if (get_param_integer(param->value, &(nodedata->MaxCSMABackoffs))) { goto error; } } if (!strcmp(param->key, "max-backoff-exponent")) { if (get_param_integer(param->value, &(nodedata->MaxBE))) { goto error; } } if (!strcmp(param->key, "min-backoff-exponent")) { if (get_param_integer(param->value, &(nodedata->MinBE))) { goto error; } } if (!strcmp(param->key, "cca-threshold")) { if (get_param_double(param->value, &(nodedata->EDThreshold))) { goto error; } } } if (nodedata->EDThreshold < EDThresholdMin) { nodedata->EDThreshold = EDThresholdMin; } if ((nodedata->MaxCSMABackoffs < macMaxCSMABackoffsMin) || (nodedata->MaxCSMABackoffs > macMaxCSMABackoffsMax)) { nodedata->MaxCSMABackoffs = macMaxCSMABackoffs; } if ((nodedata->MaxBE < macMaxBEMin) || (nodedata->MaxBE > macMaxBEMax)) { nodedata->MaxBE = macMaxBE; } if ((nodedata->MinBE < macMinBEMin) || (nodedata->MinBE > nodedata->MaxBE)) { nodedata->MinBE = macMinBE; } set_node_private_data(c, nodedata); return 0; error: free(nodedata); return -1; }