- char *cluster_prefix = A_surfxml_cluster_prefix;
- char *cluster_suffix = A_surfxml_cluster_suffix;
- char *cluster_radical = A_surfxml_cluster_radical;
- char *cluster_bb_bw = A_surfxml_cluster_bb_bw;
- char *cluster_bb_lat = A_surfxml_cluster_bb_lat;
- char *cluster_bw = A_surfxml_cluster_bw;
- char *cluster_lat = A_surfxml_cluster_lat;
- char *groups = NULL;
-
- int start, end, i;
- unsigned int iter;
-
- xbt_dynar_t radical_elements;
- xbt_dynar_t radical_ends;
- xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL);
-
- char *router_id,*host_id;
-
- radical_elements = xbt_str_split(cluster_radical, ",");
- xbt_dynar_foreach(radical_elements, iter, groups) {
- radical_ends = xbt_str_split(groups, "-");
-
- switch (xbt_dynar_length(radical_ends)) {
- case 1:
- surf_parse_get_int(&start,xbt_dynar_get_as(radical_ends, 0, char *));
- xbt_dynar_push_as(tab_elements_num, int, start);
- router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix);
- xbt_lib_set(host_lib,
- router_id,
- NS3_HOST_LEVEL,
- ns3_add_host_cluster(router_id)
- );
- XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
- free(router_id);
- break;
-
- case 2:
- surf_parse_get_int(&start,xbt_dynar_get_as(radical_ends, 0, char *));
- surf_parse_get_int(&end, xbt_dynar_get_as(radical_ends, 1, char *));
- for (i = start; i <= end; i++){
- xbt_dynar_push_as(tab_elements_num, int, i);
- router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix);
- xbt_lib_set(host_lib,
- router_id,
- NS3_HOST_LEVEL,
- ns3_add_host_cluster(router_id)
- );
- XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
- free(router_id);
- }
- break;
-
- default:
- XBT_DEBUG("Malformed radical");
- }
- }
-
- //Create links
- unsigned int cpt;
- int elmts;
- char * lat = xbt_strdup(cluster_lat);
- char * bw = xbt_strdup(cluster_bw);
- replace_lat_ns3(&lat);
- replace_bdw_ns3(&bw);
-
- xbt_dynar_foreach(tab_elements_num,cpt,elmts)
- {
- host_id = bprintf("%s%d%s", cluster_prefix, elmts, cluster_suffix);
- router_id = bprintf("ns3_%s%d%s", cluster_prefix, elmts, cluster_suffix);
- XBT_DEBUG("Create link from '%s' to '%s'",host_id,router_id);
-
- ns3_nodes_t host_src = xbt_lib_get_or_null(host_lib,host_id, NS3_HOST_LEVEL);
- ns3_nodes_t host_dst = xbt_lib_get_or_null(host_lib,router_id,NS3_HOST_LEVEL);
-
- if(host_src && host_dst){}
- else xbt_die("\tns3_add_link from %d to %d",host_src->node_num,host_dst->node_num);
-
- ns3_add_link(host_src->node_num,host_dst->node_num,bw,lat);
-
- free(router_id);
- free(host_id);
- }
- xbt_dynar_free(&tab_elements_num);
-
-
- //Create link backbone
- lat = xbt_strdup(cluster_bb_lat);
- bw = xbt_strdup(cluster_bb_bw);
- replace_lat_ns3(&lat);
- replace_bdw_ns3(&bw);
- ns3_add_cluster(bw,lat,A_surfxml_cluster_id);
- xbt_free(lat);
- xbt_free(bw);
+ const char *cluster_prefix = cluster->prefix;
+ const char *cluster_suffix = cluster->suffix;
+ const char *cluster_radical = cluster->radical;
+ const char *cluster_bb_bw = bprintf("%f",cluster->bb_bw);
+ const char *cluster_bb_lat = bprintf("%f",cluster->bb_lat);
+ const char *cluster_bw = bprintf("%f",cluster->bw);
+ const char *cluster_lat = bprintf("%f",cluster->lat);
+ const char *groups = NULL;
+
+ int start, end, i;
+ unsigned int iter;
+
+ xbt_dynar_t radical_elements;
+ xbt_dynar_t radical_ends;
+ xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL);
+
+ char *router_id,*host_id;
+
+ radical_elements = xbt_str_split(cluster_radical, ",");
+ xbt_dynar_foreach(radical_elements, iter, groups) {
+ radical_ends = xbt_str_split(groups, "-");
+
+ switch (xbt_dynar_length(radical_ends)) {
+ case 1:
+ start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+ xbt_dynar_push_as(tab_elements_num, int, start);
+ router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix);
+ xbt_lib_set(host_lib,
+ router_id,
+ NS3_HOST_LEVEL,
+ ns3_add_host_cluster(router_id)
+ );
+ XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
+ free(router_id);
+ break;
+
+ case 2:
+ start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+ end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
+ for (i = start; i <= end; i++){
+ xbt_dynar_push_as(tab_elements_num, int, i);
+ router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix);
+ xbt_lib_set(host_lib,
+ router_id,
+ NS3_HOST_LEVEL,
+ ns3_add_host_cluster(router_id)
+ );
+ XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
+ free(router_id);
+ }
+ break;
+
+ default:
+ XBT_DEBUG("Malformed radical");
+ }
+ }
+
+ //Create links
+ unsigned int cpt;
+ int elmts;
+ char * lat = xbt_strdup(cluster_lat);
+ char * bw = xbt_strdup(cluster_bw);
+ replace_lat_ns3(&lat);
+ replace_bdw_ns3(&bw);
+
+ xbt_dynar_foreach(tab_elements_num,cpt,elmts)
+ {
+ host_id = bprintf("%s%d%s", cluster_prefix, elmts, cluster_suffix);
+ router_id = bprintf("ns3_%s%d%s", cluster_prefix, elmts, cluster_suffix);
+ XBT_DEBUG("Create link from '%s' to '%s'",host_id,router_id);
+
+ ns3_nodes_t host_src = xbt_lib_get_or_null(host_lib,host_id, NS3_HOST_LEVEL);
+ ns3_nodes_t host_dst = xbt_lib_get_or_null(host_lib,router_id,NS3_HOST_LEVEL);
+
+ if(host_src && host_dst){}
+ else xbt_die("\tns3_add_link from %d to %d",host_src->node_num,host_dst->node_num);
+
+ ns3_add_link(host_src->node_num,host_src->type,
+ host_dst->node_num,host_dst->type,
+ bw,lat);
+
+ free(router_id);
+ free(host_id);
+ }
+ xbt_dynar_free(&tab_elements_num);
+
+
+ //Create link backbone
+ lat = xbt_strdup(cluster_bb_lat);
+ bw = xbt_strdup(cluster_bb_bw);
+ replace_lat_ns3(&lat);
+ replace_bdw_ns3(&bw);
+ ns3_add_cluster(bw,lat,cluster->id);
+ xbt_free(lat);
+ xbt_free(bw);