-static lmm_system_t network_maxmin_system = NULL;
-static void (*network_solve) (lmm_system_t) = NULL;
-
-static int card_number = 0;
-static int host_number = 0;
-static link_Constant_t **routing_table = NULL;
-static int *routing_table_size = NULL;
-static link_Constant_t loopback = NULL;
-
-#define ROUTE(i,j) routing_table[(i)+(j)*card_number]
-#define ROUTE_SIZE(i,j) routing_table_size[(i)+(j)*card_number]
-
-static void create_routing_table(void)
-{
- routing_table =
- xbt_new0(link_Constant_t *, /*card_number * card_number */ host_number * host_number);
- routing_table_size = xbt_new0(int, /*card_number * card_number*/ host_number * host_number);
-}
-
-static void link_free(void *nw_link)
-{
- free(((link_Constant_t) nw_link)->name);
- free(nw_link);
-}
-
-static link_Constant_t link_new(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_link_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties)
-{
- link_Constant_t nw_link = xbt_new0(s_link_Constant_t, 1);
- xbt_assert1(!xbt_dict_get_or_null(link_set, name),
- "Link '%s' declared several times in the platform file.", name);
-
- nw_link->model = (surf_model_t) surf_network_model;
- nw_link->name = name;
- nw_link->bw_current = bw_initial;
- if (bw_trace)
- nw_link->bw_event =
- tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
- nw_link->lat_current = lat_initial;
- if (lat_trace)
- nw_link->lat_event =
- tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
- nw_link->state_current = state_initial;
- if (state_trace)
- nw_link->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
-
- nw_link->constraint =
- lmm_constraint_new(network_maxmin_system, nw_link,
- nw_link->bw_current);
-
- if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(nw_link->constraint);
-
- nw_link->properties = properties;
-
- current_property_set = properties;
-
- xbt_dict_set(link_set, name, nw_link, link_free);
-
- return nw_link;
-}
-
-static void network_card_free(void *nw_card)
-{
- free(((network_card_Constant_t) nw_card)->name);
- free(nw_card);
-}
-
-static int network_card_new(const char *card_name)
-{
- network_card_Constant_t card =
- xbt_dict_get_or_null(network_card_set, card_name);
-
- if (!card) {
- card = xbt_new0(s_network_card_Constant_t, 1);
- card->name = xbt_strdup(card_name);
- card->id = card_number++;
- xbt_dict_set(network_card_set, card_name, card, network_card_free);
- }
- return card->id;
-}
-
-static void route_new(int src_id, int dst_id,
- link_Constant_t * link_list, int nb_link)
-{
- ROUTE_SIZE(src_id, dst_id) = nb_link;
- ROUTE(src_id, dst_id) = link_list =
- xbt_realloc(link_list, sizeof(link_Constant_t) * nb_link);
-}
-
-static void parse_link_init(void)
-{
- char *name_link;
- double bw_initial;
- tmgr_trace_t bw_trace;
- double lat_initial;
- tmgr_trace_t lat_trace;
- e_surf_link_state_t state_initial_link = SURF_LINK_ON;
- e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
- tmgr_trace_t state_trace;
-
- name_link = xbt_strdup(A_surfxml_link_id);
- surf_parse_get_double(&bw_initial, A_surfxml_link_bandwidth);
- surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file);
- surf_parse_get_double(&lat_initial, A_surfxml_link_latency);
- surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file);
-
- xbt_assert0((A_surfxml_link_state ==
- A_surfxml_link_state_ON)
- || (A_surfxml_link_state ==
- A_surfxml_link_state_OFF), "Invalid state");
- if (A_surfxml_link_state == A_surfxml_link_state_ON)
- state_initial_link = SURF_LINK_ON;
- else if (A_surfxml_link_state ==
- A_surfxml_link_state_OFF)
- state_initial_link = SURF_LINK_OFF;
-
- if (A_surfxml_link_sharing_policy ==
- A_surfxml_link_sharing_policy_SHARED)
- policy_initial_link = SURF_LINK_SHARED;
- else if (A_surfxml_link_sharing_policy ==
- A_surfxml_link_sharing_policy_FATPIPE)
- policy_initial_link = SURF_LINK_FATPIPE;
-
- surf_parse_get_trace(&state_trace, A_surfxml_link_state_file);
-
- link_new(name_link, bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial_link, state_trace,
- policy_initial_link, xbt_dict_new());
-
-}
-
-static int src_id = -1;
-static int dst_id = -1;
-
-static void parse_route_set_endpoints(void)
-{
- src_id = network_card_new(A_surfxml_route_src);
- dst_id = network_card_new(A_surfxml_route_dst);
- route_action = A_surfxml_route_action;
- route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
-}
-
-static void parse_route_set_route(void)
-{
- char *name;
- if (src_id != -1 && dst_id != -1) {
- name = bprintf("%x#%x",src_id, dst_id);
- manage_route(route_table, name, route_action, 0);
- free(name);
- }
-}
-
-static void add_loopback(void)
-{
- int i;
- /* Adding loopback if needed */
- for (i = 0; i < host_number; i++)
- if (!ROUTE_SIZE(i, i)) {
- if (!loopback)
- loopback = link_new(xbt_strdup("__MSG_loopback__"),
- 498000000, NULL, 0.000015, NULL,
- SURF_LINK_ON, NULL,
- SURF_LINK_FATPIPE,NULL);
- ROUTE_SIZE(i, i) = 1;
- ROUTE(i, i) = xbt_new0(link_Constant_t, 1);
- ROUTE(i, i)[0] = loopback;
- }