- 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 = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(host_lib,host_id, NS3_HOST_LEVEL));
- ns3_nodes_t host_dst = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(host_lib,router_id,NS3_HOST_LEVEL));