X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9f31e0d16a04b8da74182a1228ec872b191aa6d5..5a148272eff516debc28acb5d13fa97c5afe20ab:/src/surf/platf_generator.c diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index 889c14765e..895e9f8dc2 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -4,6 +4,8 @@ #include "platf_generator_private.h" #include "xbt.h" #include "xbt/RngStream.h" +#include "surf/simgrid_dtd.h" +#include "surf_private.h" #include static xbt_graph_t platform_graph = NULL; @@ -64,6 +66,7 @@ void platf_node_connect(xbt_node_t node1, xbt_node_t node2) { context_edge_t edge_data = NULL; edge_data = xbt_new0(s_context_edge_t, 1); edge_data->id = ++last_link_id; + edge_data->length = platf_node_distance(node1, node2); edge_data->labeled = FALSE; xbt_graph_new_edge(platform_graph, node1, node2, (void*)edge_data); } @@ -224,6 +227,58 @@ void platf_graph_interconnect_exponential(double alpha) { } } +void platf_graph_interconnect_waxman(double alpha, double beta) { + /* Create a topology where the probability follows the model of Waxman + * (see Waxman, Routing of Multipoint Connections, IEEE J. on Selected Areas in Comm., 1988) + * + * Number of edges increases with alpha + * edge length heterogeneity increases with beta + */ + xbt_dynar_t dynar_nodes = NULL; + xbt_node_t first_node = NULL; + xbt_node_t second_node = NULL; + unsigned int i,j; + double L = sqrt(2.0); /* L = c*sqrt(2); c=side of placement square */ + dynar_nodes = xbt_graph_get_nodes(platform_graph); + xbt_dynar_foreach(dynar_nodes, i, first_node) { + xbt_dynar_foreach(dynar_nodes, j, second_node) { + if(j>=i) + break; + double d = platf_node_distance(first_node, second_node); + if(RngStream_RandU01(rng_stream) < alpha*exp(-d/(L*beta))) { + platf_node_connect(first_node, second_node); + } + } + } +} + +void platf_graph_interconnect_zegura(double alpha, double beta, double r) { + /* Create a topology where the probability follows the model of Zegura + * (see Zegura, Calvert, Donahoo, A quantitative comparison of graph-based models + * for Internet topology, IEEE/ACM Transactions on Networking, 1997.) + * + * alpha : Probability of connexion for short edges + * beta : Probability of connexion for long edges + * r : Limit between long and short edges (between 0 and sqrt(2) since nodes are placed on the unit square) + */ + xbt_dynar_t dynar_nodes = NULL; + xbt_node_t first_node = NULL; + xbt_node_t second_node = NULL; + unsigned int i,j; + dynar_nodes = xbt_graph_get_nodes(platform_graph); + xbt_dynar_foreach(dynar_nodes, i, first_node) { + xbt_dynar_foreach(dynar_nodes, j, second_node) { + if(j>=i) + break; + double d = platf_node_distance(first_node, second_node); + double proba = d < r ? alpha : beta; + if(RngStream_RandU01(rng_stream) < proba) { + platf_node_connect(first_node, second_node); + } + } + } +} + void platf_graph_interconnect_barabasi(void) { /* Create a topology constructed according to the Barabasi-Albert algorithm (follows power laws) (see Barabasi and Albert, Emergence of scaling in random networks, Science 1999, num 59, p509­-512.) */ @@ -309,6 +364,59 @@ void platf_do_label(void) { } } +void platf_generate(void) { + + xbt_dynar_t nodes = NULL; + xbt_node_t graph_node = NULL; + context_node_t node_data = NULL; + unsigned int i; + + unsigned int last_host = 0; + unsigned int last_router = 0; + //unsigned int last_cluster = 0; + + sg_platf_host_cbarg_t host_parameters; + s_sg_platf_router_cbarg_t router_parameters; /* This one is not a pointer! */ + sg_platf_cluster_cbarg_t cluster_parameters; + + router_parameters.coord = NULL; + + nodes = xbt_graph_get_nodes(platform_graph); + + sg_platf_init(); + sg_platf_begin(); + surf_parse_init_callbacks(); + routing_register_callbacks(); + + + sg_platf_new_AS_begin("random platform", A_surfxml_AS_routing_Floyd); + + xbt_dynar_foreach(nodes, i, graph_node) { + node_data = xbt_graph_node_get_data(graph_node); + switch(node_data->kind) { + case HOST: + host_parameters = &node_data->host_parameters; + if(host_parameters->id == NULL) { + host_parameters->id = bprintf("host-%d", ++last_host); + } + sg_platf_new_host(host_parameters); + break; + case CLUSTER: + cluster_parameters = &node_data->cluster_parameters; + //TODO: handle NULL IDs for clusters + sg_platf_new_cluster(cluster_parameters); + break; + case ROUTER: + router_parameters.id = bprintf("router-%d", ++last_router); + sg_platf_new_router(&router_parameters); + } + } + + + sg_platf_new_AS_end(); + sg_platf_end(); +} + /* Functions used to generate interesting random values */ double random_pareto(double min, double max, double K, double P, double ALPHA) {