Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fd646bb78f3cfb23cac06abd113a10bb24142f87
[simgrid.git] / src / surf / network_interface.hpp
1 /*
2  * network_interface.hpp
3  *
4  *  Created on: Nov 29, 2013
5  *      Author: bedaride
6  */
7 #include "surf_interface.hpp"
8 #include "surf_routing.hpp"
9
10 #ifndef SURF_NETWORK_INTERFACE_HPP_
11 #define SURF_NETWORK_INTERFACE_HPP_
12
13 /***********
14  * Classes *
15  ***********/
16 class NetworkModel;
17 typedef NetworkModel *NetworkModelPtr;
18
19 class NetworkLink;
20 typedef NetworkLink *NetworkLinkPtr;
21
22 class NetworkAction;
23 typedef NetworkAction *NetworkActionPtr;
24
25 /*********
26  * Tools *
27  *********/
28
29 void net_define_callbacks(void);
30
31 /*********
32  * Model *
33  *********/
34 class NetworkModel : public Model {
35 public:
36   NetworkModel() : Model("network") {
37   };
38   NetworkModel(const char *name) : Model(name) {
39         f_networkSolve = lmm_solve;
40         m_haveGap = false;
41   };
42   ~NetworkModel() {
43         if (p_maxminSystem)
44           lmm_system_free(p_maxminSystem);
45         if (p_actionHeap)
46           xbt_heap_free(p_actionHeap);
47         if (p_modifiedSet)
48           delete p_modifiedSet;
49   }
50
51   virtual NetworkLinkPtr createResource(const char *name,
52                                    double bw_initial,
53                                    tmgr_trace_t bw_trace,
54                                    double lat_initial,
55                                    tmgr_trace_t lat_trace,
56                                    e_surf_resource_state_t state_initial,
57                                    tmgr_trace_t state_trace,
58                                    e_surf_link_sharing_policy_t policy,
59                                    xbt_dict_t properties)=0;
60
61   virtual void gapAppend(double /*size*/, const NetworkLinkPtr /*link*/, NetworkActionPtr /*action*/) {};
62   virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
63                                            double size, double rate)=0;
64   virtual xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); //FIXME: kill field? That is done by the routing nowadays
65   void (*f_networkSolve)(lmm_system_t);
66   virtual double latencyFactor(double size);
67   virtual double bandwidthFactor(double size);
68   virtual double bandwidthConstraint(double rate, double bound, double size);
69   bool m_haveGap;
70 };
71
72 /************
73  * Resource *
74  ************/
75
76 class NetworkLink : public Resource {
77 public:
78   NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props);
79   NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props,
80                       lmm_constraint_t constraint,
81                   tmgr_history_t history,
82                   tmgr_trace_t state_trace);
83   virtual double getBandwidth();
84   virtual double getLatency();
85   virtual bool isShared();
86   bool isUsed();
87
88   /* Using this object with the public part of
89     model does not make sense */
90   double m_latCurrent;
91   tmgr_trace_event_t p_latEvent;
92
93   /* LMM */
94   tmgr_trace_event_t p_stateEvent;
95   s_surf_metric_t p_power;
96 };
97
98 /**********
99  * Action *
100  **********/
101 class NetworkAction : public Action {
102 public:
103   NetworkAction(ModelPtr model, double cost, bool failed)
104   : Action(model, cost, failed) {}
105   NetworkAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
106   : Action(model, cost, failed, var) {};
107   double m_latency;
108   double m_latCurrent;
109   double m_weight;
110   double m_rate;
111   const char* p_senderLinkName;
112   double m_senderGap;
113   double m_senderSize;
114   xbt_fifo_item_t p_senderFifoItem;
115 #ifdef HAVE_LATENCY_BOUND_TRACKING
116   int m_latencyLimited;
117 #endif
118
119 };
120
121 #endif /* SURF_NETWORK_INTERFACE_HPP_ */
122
123