Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
* Cleanup the DTD by renaming:
[simgrid.git] / src / surf / network.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include "network_private.h"
9 #include "xbt/log.h"
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
12                                 "Logging specific to the SURF network module");
13
14 surf_network_model_t surf_network_model = NULL;
15 static lmm_system_t network_maxmin_system = NULL;
16 static void (*network_solve) (lmm_system_t) = NULL;
17
18 xbt_dict_t network_link_set = NULL;
19 xbt_dict_t network_card_set = NULL;
20
21 int card_number = 0;
22 network_link_CM02_t **routing_table = NULL;
23 int *routing_table_size = NULL;
24 static network_link_CM02_t loopback = NULL;
25
26 static void create_routing_table(void)
27 {
28   routing_table =
29       xbt_new0(network_link_CM02_t *, card_number * card_number);
30   routing_table_size = xbt_new0(int, card_number * card_number);
31 }
32
33 static void network_link_free(void *nw_link)
34 {
35   free(((network_link_CM02_t) nw_link)->name);
36   free(nw_link);
37 }
38
39 static network_link_CM02_t network_link_new(char *name,
40                                             double bw_initial,
41                                             tmgr_trace_t bw_trace,
42                                             double lat_initial,
43                                             tmgr_trace_t lat_trace,
44                                             e_surf_network_link_state_t
45                                             state_initial,
46                                             tmgr_trace_t state_trace,
47                                             e_surf_network_link_sharing_policy_t
48                                             policy, xbt_dict_t properties)
49 {
50   network_link_CM02_t nw_link = xbt_new0(s_network_link_CM02_t, 1);
51
52
53   nw_link->model = (surf_model_t) surf_network_model;
54   nw_link->name = name;
55   nw_link->bw_current = bw_initial;
56   if (bw_trace)
57     nw_link->bw_event =
58         tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
59   nw_link->lat_current = lat_initial;
60   if (lat_trace)
61     nw_link->lat_event =
62         tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
63   nw_link->state_current = state_initial;
64   if (state_trace)
65     nw_link->state_event =
66         tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
67
68   nw_link->constraint =
69       lmm_constraint_new(network_maxmin_system, nw_link,
70                          nw_link->bw_current);
71
72   if (policy == SURF_NETWORK_LINK_FATPIPE)
73     lmm_constraint_shared(nw_link->constraint);
74
75   nw_link->properties = properties;
76
77   current_property_set = properties;
78
79   xbt_dict_set(network_link_set, name, nw_link, network_link_free);
80
81   return nw_link;
82 }
83
84 static void network_card_free(void *nw_card)
85 {
86   free(((network_card_CM02_t) nw_card)->name);
87   free(nw_card);
88 }
89
90 static int network_card_new(const char *card_name)
91 {
92   network_card_CM02_t card =
93       xbt_dict_get_or_null(network_card_set, card_name);
94
95   if (!card) {
96     card = xbt_new0(s_network_card_CM02_t, 1);
97     card->name = xbt_strdup(card_name);
98     card->id = card_number++;
99     xbt_dict_set(network_card_set, card_name, card, network_card_free);
100   }
101   return card->id;
102 }
103
104 static void route_new(int src_id, int dst_id,
105                       network_link_CM02_t * link_list, int nb_link)
106 {
107   ROUTE_SIZE(src_id, dst_id) = nb_link;
108   ROUTE(src_id, dst_id) = link_list =
109       xbt_realloc(link_list, sizeof(network_link_CM02_t) * nb_link);
110 }
111
112 static void parse_network_link_init(void)
113 {
114   char *name_link;
115   double bw_initial;
116   tmgr_trace_t bw_trace;
117   double lat_initial;
118   tmgr_trace_t lat_trace;
119   e_surf_network_link_state_t state_initial_link = SURF_NETWORK_LINK_ON;
120   e_surf_network_link_sharing_policy_t policy_initial_link = SURF_NETWORK_LINK_SHARED;
121   tmgr_trace_t state_trace;
122
123   name_link = xbt_strdup(A_surfxml_link_id);
124   surf_parse_get_double(&bw_initial, A_surfxml_link_bandwidth);
125   surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file);
126   surf_parse_get_double(&lat_initial, A_surfxml_link_latency);
127   surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file);
128
129   xbt_assert0((A_surfxml_link_state ==
130                A_surfxml_link_state_ON)
131               || (A_surfxml_link_state ==
132                   A_surfxml_link_state_OFF), "Invalid state");
133   if (A_surfxml_link_state == A_surfxml_link_state_ON)
134     state_initial_link = SURF_NETWORK_LINK_ON;
135   else if (A_surfxml_link_state ==
136            A_surfxml_link_state_OFF)
137     state_initial_link = SURF_NETWORK_LINK_OFF;
138
139   if (A_surfxml_link_sharing_policy ==
140       A_surfxml_link_sharing_policy_SHARED)
141     policy_initial_link = SURF_NETWORK_LINK_SHARED;
142   else if (A_surfxml_link_sharing_policy ==
143            A_surfxml_link_sharing_policy_FATPIPE)
144     policy_initial_link = SURF_NETWORK_LINK_FATPIPE;
145
146   surf_parse_get_trace(&state_trace, A_surfxml_link_state_file);
147
148   network_link_new(name_link, bw_initial, bw_trace,
149                    lat_initial, lat_trace, state_initial_link, state_trace,
150                    policy_initial_link, xbt_dict_new());
151
152 }
153
154 static int nb_link;
155 static int link_list_capacity;
156 static network_link_CM02_t *link_list = NULL;
157 static int src_id = -1;
158 static int dst_id = -1;
159 /*
160 static int is_first = 0;
161 */
162
163 static void parse_route_set_endpoints(void)
164 {
165
166   src_id = network_card_new(A_surfxml_route_src);
167   dst_id = network_card_new(A_surfxml_route_dst);
168   nb_link = 0;
169   link_list_capacity = 20;
170   link_list = xbt_new(network_link_CM02_t, link_list_capacity);
171 }
172
173 static void parse_route_elem(void)
174 {
175
176   if (nb_link == link_list_capacity) {
177     link_list_capacity *= 2;
178     link_list =
179         xbt_realloc(link_list,
180                     (link_list_capacity) * sizeof(network_link_CM02_t));
181   }
182   link_list[nb_link++] =
183       xbt_dict_get_or_null(network_link_set, A_surfxml_link_c_ctn_id);
184 }
185
186 static void parse_route_set_route(void)
187 {
188   route_new(src_id, dst_id, link_list, nb_link);
189 }
190
191 static void parse_file(const char *file)
192 {
193   int i;
194 /*
195   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
196   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_network_link_init);
197   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
198   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
199   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
200 */
201   /* Figuring out the network links */
202   surf_parse_reset_parser();
203   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_network_link_init);
204   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
205   surf_parse_open(file);
206   xbt_assert1((!surf_parse()), "Parse error in %s", file);
207   surf_parse_close();
208
209   /* Figuring out the network cards used */
210   surf_parse_reset_parser();
211   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
212   surf_parse_open(file);
213   xbt_assert1((!surf_parse()), "Parse error in %s", file);
214   surf_parse_close();
215
216   create_routing_table();
217
218   /* Building the routes */
219   surf_parse_reset_parser();
220   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
221   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
222   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
223   surf_parse_open(file);
224   xbt_assert1((!surf_parse()), "Parse error in %s", file);
225   surf_parse_close();
226
227   /* Adding loopback if needed */
228
229   for (i = 0; i < card_number; i++)
230     if (!ROUTE_SIZE(i, i)) {
231       if (!loopback)
232         loopback = network_link_new(xbt_strdup("__MSG_loopback__"),
233                                     498000000, NULL, 0.000015, NULL,
234                                     SURF_NETWORK_LINK_ON, NULL,
235                                     SURF_NETWORK_LINK_FATPIPE,NULL);
236       ROUTE_SIZE(i, i) = 1;
237       ROUTE(i, i) = xbt_new0(network_link_CM02_t, 1);
238       ROUTE(i, i)[0] = loopback;
239     }
240 }
241
242 static void *name_service(const char *name)
243 {
244   network_card_CM02_t card = xbt_dict_get_or_null(network_card_set, name);
245   return card;
246 }
247
248 static const char *get_resource_name(void *resource_id)
249 {
250   return ((network_card_CM02_t) resource_id)->name;
251 }
252
253 static int resource_used(void *resource_id)
254 {
255   return lmm_constraint_used(network_maxmin_system,
256                              ((network_link_CM02_t) resource_id)->
257                              constraint);
258 }
259
260 static int action_free(surf_action_t action)
261 {
262   action->using--;
263   if (!action->using) {
264     xbt_swag_remove(action, action->state_set);
265     if (((surf_action_network_CM02_t) action)->variable)
266       lmm_variable_free(network_maxmin_system,
267                         ((surf_action_network_CM02_t) action)->variable);
268     free(action);
269     return 1;
270   }
271   return 0;
272 }
273
274 static void action_use(surf_action_t action)
275 {
276   action->using++;
277 }
278
279 static void action_cancel(surf_action_t action)
280 {
281   return;
282 }
283
284 static void action_recycle(surf_action_t action)
285 {
286   return;
287 }
288
289 static void action_change_state(surf_action_t action,
290                                 e_surf_action_state_t state)
291 {
292 /*   if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
293 /*     if(((surf_action_network_CM02_t)action)->variable) { */
294 /*       lmm_variable_disable(network_maxmin_system, ((surf_action_network_CM02_t)action)->variable); */
295 /*       ((surf_action_network_CM02_t)action)->variable = NULL; */
296 /*     } */
297
298   surf_action_change_state(action, state);
299   return;
300 }
301
302 static double share_resources(double now)
303 {
304   s_surf_action_network_CM02_t s_action;
305   surf_action_network_CM02_t action = NULL;
306   xbt_swag_t running_actions =
307       surf_network_model->common_public->states.running_action_set;
308   double min;
309
310   min = generic_maxmin_share_resources(running_actions,
311                                        xbt_swag_offset(s_action,
312                                                        variable),
313                                        network_maxmin_system,
314                                        network_solve);
315
316   xbt_swag_foreach(action, running_actions) {
317     if (action->latency > 0) {
318       if (min < 0)
319         min = action->latency;
320       else if (action->latency < min)
321         min = action->latency;
322     }
323   }
324
325   return min;
326 }
327
328 static void update_actions_state(double now, double delta)
329 {
330   double deltap = 0.0;
331   surf_action_network_CM02_t action = NULL;
332   surf_action_network_CM02_t next_action = NULL;
333   xbt_swag_t running_actions =
334       surf_network_model->common_public->states.running_action_set;
335   /*
336      xbt_swag_t failed_actions =
337      surf_network_model->common_public->states.failed_action_set;
338    */
339
340   xbt_swag_foreach_safe(action, next_action, running_actions) {
341     deltap = delta;
342     if (action->latency > 0) {
343       if (action->latency > deltap) {
344         double_update(&(action->latency), deltap);
345         deltap = 0.0;
346       } else {
347         double_update(&(deltap), action->latency);
348         action->latency = 0.0;
349       }
350       if ((action->latency == 0.0) && !(action->suspended))
351         lmm_update_variable_weight(network_maxmin_system, action->variable,
352                                    action->lat_current);
353     }
354     double_update(&(action->generic_action.remains),
355                   lmm_variable_getvalue(action->variable) * deltap);
356     if (action->generic_action.max_duration != NO_MAX_DURATION)
357       double_update(&(action->generic_action.max_duration), delta);
358
359     /*   if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
360
361     if ((action->generic_action.remains <= 0) &&
362         (lmm_get_variable_weight(action->variable) > 0)) {
363       action->generic_action.finish = surf_get_clock();
364       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
365     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
366                (action->generic_action.max_duration <= 0)) {
367       action->generic_action.finish = surf_get_clock();
368       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
369     } else {                    /* Need to check that none of the model has failed */
370       lmm_constraint_t cnst = NULL;
371       int i = 0;
372       network_link_CM02_t nw_link = NULL;
373
374       while ((cnst =
375               lmm_get_cnst_from_var(network_maxmin_system,
376                                     action->variable, i++))) {
377         nw_link = lmm_constraint_id(cnst);
378         if (nw_link->state_current == SURF_NETWORK_LINK_OFF) {
379           action->generic_action.finish = surf_get_clock();
380           action_change_state((surf_action_t) action, SURF_ACTION_FAILED);
381           break;
382         }
383       }
384     }
385   }
386
387   return;
388 }
389
390 static void update_resource_state(void *id,
391                                   tmgr_trace_event_t event_type,
392                                   double value)
393 {
394   network_link_CM02_t nw_link = id;
395   /*   printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
396   /*     "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
397   /*     value, event_type); */
398
399   if (event_type == nw_link->bw_event) {
400     nw_link->bw_current = value;
401     lmm_update_constraint_bound(network_maxmin_system, nw_link->constraint,
402                                 nw_link->bw_current);
403   } else if (event_type == nw_link->lat_event) {
404     double delta = value - nw_link->lat_current;
405     lmm_variable_t var = NULL;
406     surf_action_network_CM02_t action = NULL;
407
408     nw_link->lat_current = value;
409     while (lmm_get_var_from_cnst
410            (network_maxmin_system, nw_link->constraint, &var)) {
411       action = lmm_variable_id(var);
412       action->lat_current += delta;
413       if (action->rate < 0)
414         lmm_update_variable_bound(network_maxmin_system, action->variable,
415                                   SG_TCP_CTE_GAMMA / (2.0 *
416                                                       action->
417                                                       lat_current));
418       else
419         lmm_update_variable_bound(network_maxmin_system, action->variable,
420                                   min(action->rate,
421                                       SG_TCP_CTE_GAMMA / (2.0 *
422                                                           action->
423                                                           lat_current)));
424       if (!(action->suspended))
425         lmm_update_variable_weight(network_maxmin_system, action->variable,
426                                    action->lat_current);
427       lmm_update_variable_latency(network_maxmin_system, action->variable,
428                                   delta);
429     }
430   } else if (event_type == nw_link->state_event) {
431     if (value > 0)
432       nw_link->state_current = SURF_NETWORK_LINK_ON;
433     else
434       nw_link->state_current = SURF_NETWORK_LINK_OFF;
435   } else {
436     CRITICAL0("Unknown event ! \n");
437     xbt_abort();
438   }
439
440   return;
441 }
442
443 static surf_action_t communicate(void *src, void *dst, double size,
444                                  double rate)
445 {
446   surf_action_network_CM02_t action = NULL;
447   network_card_CM02_t card_src = src;
448   network_card_CM02_t card_dst = dst;
449   int route_size = ROUTE_SIZE(card_src->id, card_dst->id);
450   network_link_CM02_t *route = ROUTE(card_src->id, card_dst->id);
451   int i;
452
453   XBT_IN4("(%s,%s,%g,%g)", card_src->name, card_dst->name, size, rate);
454   xbt_assert2(route_size,
455               "You're trying to send data from %s to %s but there is no connexion between these two cards.",
456               card_src->name, card_dst->name);
457
458   action = xbt_new0(s_surf_action_network_CM02_t, 1);
459
460   action->generic_action.using = 1;
461   action->generic_action.cost = size;
462   action->generic_action.remains = size;
463   action->generic_action.max_duration = NO_MAX_DURATION;
464   action->generic_action.start = surf_get_clock();
465   action->generic_action.finish = -1.0;
466   action->generic_action.model_type =
467       (surf_model_t) surf_network_model;
468   action->suspended = 0;        /* Should be useless because of the 
469                                    calloc but it seems to help valgrind... */
470   action->generic_action.state_set =
471       surf_network_model->common_public->states.running_action_set;
472
473   xbt_swag_insert(action, action->generic_action.state_set);
474   action->rate = rate;
475
476   action->latency = 0.0;
477   for (i = 0; i < route_size; i++)
478     action->latency += route[i]->lat_current;
479   action->lat_current = action->latency;
480
481   if (action->latency > 0)
482     action->variable =
483         lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,
484                          route_size);
485   else
486     action->variable =
487         lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,
488                          route_size);
489
490   if (action->rate < 0) {
491     if (action->lat_current > 0)
492       lmm_update_variable_bound(network_maxmin_system, action->variable,
493                                 SG_TCP_CTE_GAMMA / (2.0 *
494                                                     action->lat_current));
495     else
496       lmm_update_variable_bound(network_maxmin_system, action->variable,
497                                 -1.0);
498   } else {
499     if (action->lat_current > 0)
500       lmm_update_variable_bound(network_maxmin_system, action->variable,
501                                 min(action->rate,
502                                     SG_TCP_CTE_GAMMA / (2.0 *
503                                                         action->
504                                                         lat_current)));
505     else
506       lmm_update_variable_bound(network_maxmin_system, action->variable,
507                                 action->rate);
508   }
509   lmm_update_variable_latency(network_maxmin_system, action->variable,
510                               action->latency);
511
512   for (i = 0; i < route_size; i++)
513     lmm_expand(network_maxmin_system, route[i]->constraint,
514                action->variable, 1.0);
515   XBT_OUT;
516
517   return (surf_action_t) action;
518 }
519
520 /* returns an array of network_link_CM02_t */
521 static const void **get_route(void *src, void *dst)
522 {
523   network_card_CM02_t card_src = src;
524   network_card_CM02_t card_dst = dst;
525   return (const void **) ROUTE(card_src->id, card_dst->id);
526 }
527
528 static int get_route_size(void *src, void *dst)
529 {
530   network_card_CM02_t card_src = src;
531   network_card_CM02_t card_dst = dst;
532   return ROUTE_SIZE(card_src->id, card_dst->id);
533 }
534
535 static const char *get_link_name(const void *link)
536 {
537   return ((network_link_CM02_t) link)->name;
538 }
539
540 static double get_link_bandwidth(const void *link)
541 {
542   return ((network_link_CM02_t) link)->bw_current;
543 }
544
545 static double get_link_latency(const void *link)
546 {
547   return ((network_link_CM02_t) link)->lat_current;
548 }
549
550 static xbt_dict_t get_link_property_list(void *link)
551 {
552  return ((network_link_CM02_t) link)->properties;
553 }
554
555 static void action_suspend(surf_action_t action)
556 {
557   ((surf_action_network_CM02_t) action)->suspended = 1;
558   lmm_update_variable_weight(network_maxmin_system,
559                              ((surf_action_network_CM02_t) action)->
560                              variable, 0.0);
561 }
562
563 static void action_resume(surf_action_t action)
564 {
565   if (((surf_action_network_CM02_t) action)->suspended) {
566     lmm_update_variable_weight(network_maxmin_system,
567                                ((surf_action_network_CM02_t) action)->
568                                variable,
569                                ((surf_action_network_CM02_t) action)->
570                                lat_current);
571     ((surf_action_network_CM02_t) action)->suspended = 0;
572   }
573 }
574
575 static int action_is_suspended(surf_action_t action)
576 {
577   return ((surf_action_network_CM02_t) action)->suspended;
578 }
579
580 static void action_set_max_duration(surf_action_t action, double duration)
581 {
582   action->max_duration = duration;
583 }
584
585 static void finalize(void)
586 {
587   int i, j;
588
589   xbt_dict_free(&network_card_set);
590   xbt_dict_free(&network_link_set);
591   xbt_swag_free(surf_network_model->common_public->states.
592                 ready_action_set);
593   xbt_swag_free(surf_network_model->common_public->states.
594                 running_action_set);
595   xbt_swag_free(surf_network_model->common_public->states.
596                 failed_action_set);
597   xbt_swag_free(surf_network_model->common_public->states.
598                 done_action_set);
599   free(surf_network_model->common_public);
600   free(surf_network_model->common_private);
601   free(surf_network_model->extension_public);
602
603   free(surf_network_model);
604   surf_network_model = NULL;
605
606   loopback = NULL;
607   for (i = 0; i < card_number; i++)
608     for (j = 0; j < card_number; j++)
609       free(ROUTE(i, j));
610   free(routing_table);
611   routing_table = NULL;
612   free(routing_table_size);
613   routing_table_size = NULL;
614   card_number = 0;
615 }
616
617 static void surf_network_model_init_internal(void)
618 {
619   s_surf_action_t action;
620
621   surf_network_model = xbt_new0(s_surf_network_model_t, 1);
622
623   surf_network_model->common_private =
624       xbt_new0(s_surf_model_private_t, 1);
625   surf_network_model->common_public =
626       xbt_new0(s_surf_model_public_t, 1);
627   surf_network_model->extension_public =
628       xbt_new0(s_surf_network_model_extension_public_t, 1);
629
630   surf_network_model->common_public->states.ready_action_set =
631       xbt_swag_new(xbt_swag_offset(action, state_hookup));
632   surf_network_model->common_public->states.running_action_set =
633       xbt_swag_new(xbt_swag_offset(action, state_hookup));
634   surf_network_model->common_public->states.failed_action_set =
635       xbt_swag_new(xbt_swag_offset(action, state_hookup));
636   surf_network_model->common_public->states.done_action_set =
637       xbt_swag_new(xbt_swag_offset(action, state_hookup));
638
639   surf_network_model->common_public->name_service = name_service;
640   surf_network_model->common_public->get_resource_name =
641       get_resource_name;
642   surf_network_model->common_public->action_get_state =
643       surf_action_get_state;
644   surf_network_model->common_public->action_get_start_time =
645       surf_action_get_start_time;
646   surf_network_model->common_public->action_get_finish_time =
647       surf_action_get_finish_time;
648   surf_network_model->common_public->action_free = action_free;
649   surf_network_model->common_public->action_use = action_use;
650   surf_network_model->common_public->action_cancel = action_cancel;
651   surf_network_model->common_public->action_recycle = action_recycle;
652   surf_network_model->common_public->action_change_state =
653       action_change_state;
654   surf_network_model->common_public->action_set_data =
655       surf_action_set_data;
656   surf_network_model->common_public->name = "network";
657
658   surf_network_model->common_private->resource_used = resource_used;
659   surf_network_model->common_private->share_resources = share_resources;
660   surf_network_model->common_private->update_actions_state =
661       update_actions_state;
662   surf_network_model->common_private->update_resource_state =
663       update_resource_state;
664   surf_network_model->common_private->finalize = finalize;
665
666   surf_network_model->common_public->suspend = action_suspend;
667   surf_network_model->common_public->resume = action_resume;
668   surf_network_model->common_public->is_suspended = action_is_suspended;
669   surf_cpu_model->common_public->set_max_duration =
670       action_set_max_duration;
671
672   surf_network_model->extension_public->communicate = communicate;
673   surf_network_model->extension_public->get_route = get_route;
674   surf_network_model->extension_public->get_route_size = get_route_size;
675   surf_network_model->extension_public->get_link_name = get_link_name;
676   surf_network_model->extension_public->get_link_bandwidth =
677       get_link_bandwidth;
678   surf_network_model->extension_public->get_link_latency =
679       get_link_latency;
680   /*for the props of the link*/
681   surf_network_model->common_public->get_link_properties =  get_link_property_list;
682
683   network_link_set = xbt_dict_new();
684   network_card_set = xbt_dict_new();
685
686   if (!network_maxmin_system)
687     network_maxmin_system = lmm_system_new();
688 }
689
690 /***************************************************************************/
691 /* The nice TCP sharing model designed by Loris Marchal and Henri Casanova */
692 /***************************************************************************/
693 /* @TechReport{      rr-lip2002-40, */
694 /*   author        = {Henri Casanova and Loris Marchal}, */
695 /*   institution   = {LIP}, */
696 /*   title         = {A Network Model for Simulation of Grid Application}, */
697 /*   number        = {2002-40}, */
698 /*   month         = {oct}, */
699 /*   year          = {2002} */
700 /* } */
701 void surf_network_model_init_CM02(const char *filename)
702 {
703
704   if (surf_network_model)
705     return;
706   surf_network_model_init_internal();
707   parse_file(filename);
708   xbt_dynar_push(model_list, &surf_network_model);
709   network_solve = lmm_solve;
710
711   update_model_description(surf_network_model_description,
712                               surf_network_model_description_size,
713                               "CM02",
714                               (surf_model_t) surf_network_model);
715 }
716
717 void surf_network_model_init_Reno(const char *filename)
718 {
719   if (surf_network_model)
720     return;
721   surf_network_model_init_internal();
722   parse_file(filename);
723
724   xbt_dynar_push(model_list, &surf_network_model);
725   lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
726                                     func_reno_fpi);
727   network_solve = lagrange_solve;
728
729   update_model_description(surf_network_model_description,
730                               surf_network_model_description_size,
731                               "Reno",
732                               (surf_model_t) surf_network_model);
733 }
734
735 void surf_network_model_init_Vegas(const char *filename)
736 {
737   if (surf_network_model)
738     return;
739   surf_network_model_init_internal();
740   parse_file(filename);
741
742   xbt_dynar_push(model_list, &surf_network_model);
743   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
744                                     func_vegas_fpi);
745   network_solve = lagrange_solve;
746
747   update_model_description(surf_network_model_description,
748                               surf_network_model_description_size,
749                               "Vegas",
750                               (surf_model_t) surf_network_model);
751 }
752
753 #ifdef HAVE_SDP
754 void surf_network_model_init_SDP(const char *filename)
755 {
756   if (surf_network_model)
757     return;
758   surf_network_model_init_internal();
759   parse_file(filename);
760
761   xbt_dynar_push(model_list, &surf_network_model);
762   network_solve = sdp_solve;
763
764   update_model_description(surf_network_model_description,
765                               surf_network_model_description_size,
766                               "SDP",
767                               (surf_model_t) surf_network_model);
768 }
769 #endif