1 /* Copyright (c) 2004-2013. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "surf_interface.hpp"
8 #include "surf_routing.hpp"
10 #ifndef SURF_NETWORK_INTERFACE_HPP_
11 #define SURF_NETWORK_INTERFACE_HPP_
17 typedef NetworkModel *NetworkModelPtr;
20 typedef NetworkLink *NetworkLinkPtr;
23 typedef NetworkAction *NetworkActionPtr;
29 void net_define_callbacks(void);
34 /** @ingroup SURF_network_interface
35 * @brief SURF network model interface class
36 * @details A model is an object which handle the interactions between its Resources and its Actions
38 class NetworkModel : public Model {
41 * @brief NetworkModel constructor
43 NetworkModel() : Model("network") {
47 * @brief NetworkModel constructor
49 * @param name The name of the NetworkModel
51 NetworkModel(const char *name) : Model(name) {
52 f_networkSolve = lmm_solve;
57 * @brief The destructor of the NetworkModel
61 lmm_system_free(p_maxminSystem);
63 xbt_heap_free(p_actionHeap);
69 * @brief Create a NetworkLink
71 * @param name The name of the NetworkLink
72 * @param bw_initial The initial bandwidth of the NetworkLink in bytes per second
73 * @param bw_trace The trace associated to the NetworkLink bandwidth [TODO]
74 * @param lat_initial The initial latency of the NetworkLink in seconds
75 * @param lat_trace The trace associated to the NetworkLink latency [TODO]
76 * @param state_initial The initial NetworkLink (state)[e_surf_resource_state_t]
77 * @param state_trace The trace associated to the NetworkLink (state)[e_surf_resource_state_t] [TODO]
78 * @param policy The sharing policy of the NetworkLink
79 * @param properties Dictionary of properties associated to this Resource
80 * @return The created NetworkLink
82 virtual NetworkLinkPtr createResource(const char *name,
84 tmgr_trace_t bw_trace,
86 tmgr_trace_t lat_trace,
87 e_surf_resource_state_t state_initial,
88 tmgr_trace_t state_trace,
89 e_surf_link_sharing_policy_t policy,
90 xbt_dict_t properties)=0;
93 virtual void gapAppend(double /*size*/, const NetworkLinkPtr /*link*/, NetworkActionPtr /*action*/) {};
96 * @brief Create a communication between two [TODO]
99 * @param src The source [TODO]
100 * @param dst The destination [TODO]
101 * @param size The size of the communication in bytes
103 * @return The action representing the communication
105 virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
106 double size, double rate)=0;
109 * @brief Get the route between two RoutingEdge
115 * @return A xbt_dynar_t of [TODO]
117 virtual xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); //FIXME: kill field? That is done by the routing nowadays
120 * @brief Function pointer to the function to use to solve the lmm_system_t
122 * @param system The lmm_system_t to solve
124 void (*f_networkSolve)(lmm_system_t);
127 * @brief [brief description]
128 * @details [long description]
130 * @param size [description]
131 * @return [description]
133 virtual double latencyFactor(double size);
136 * @brief [brief description]
137 * @details [long description]
139 * @param size [description]
140 * @return [description]
142 virtual double bandwidthFactor(double size);
145 * @brief [brief description]
146 * @details [long description]
148 * @param rate [description]
149 * @param bound [description]
150 * @param size [description]
151 * @return [description]
153 virtual double bandwidthConstraint(double rate, double bound, double size);
160 /** @ingroup SURF_network_interface
161 * @brief SURF network link interface class
162 * @details A NetworkLink represent the link between two [Workstations](\ref Workstation)
164 class NetworkLink : public Resource {
167 * @brief NetworkLink constructor
169 * @param model The CpuModel associated to this NetworkLink
170 * @param name The name of the NetworkLink
171 * @param props Dictionary of properties associated to this NetworkLink
173 NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props);
176 * @brief NetworkLink constructor
178 * @param model The CpuModel associated to this NetworkLink
179 * @param name The name of the NetworkLink
180 * @param props Dictionary of properties associated to this NetworkLink
181 * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
182 * @param history [TODO]
183 * @param state_trace [TODO]
185 NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props,
186 lmm_constraint_t constraint,
187 tmgr_history_t history,
188 tmgr_trace_t state_trace);
191 * @brief Get the bandwidth in bytes per second of current NetworkLink
193 * @return The bandwith in bytes per second of the current NetworkLink
195 virtual double getBandwidth();
198 * @brief Get the latency in seconds of current NetworkLink
200 * @return The latency in seconds of the current NetworkLink
202 virtual double getLatency();
205 * @brief Check if the NetworkLink is shared
206 * @details [long description]
208 * @return true if the current NetwokrLink is shared, false otherwise
210 virtual bool isShared();
213 * @brief Check if the NetworkLink is used
215 * @return true if the current NetwokrLink is used, false otherwise
219 /* Using this object with the public part of
220 model does not make sense */
222 tmgr_trace_event_t p_latEvent;
225 tmgr_trace_event_t p_stateEvent;
226 s_surf_metric_t p_power;
232 /** @ingroup SURF_network_interface
233 * @brief SURF network action interface class
234 * @details A NetworkAction represent a communication bettween two [Workstations](\ref Workstation)
236 class NetworkAction : public Action {
239 * @brief NetworkAction constructor
241 * @param model The NetworkModel associated to this NetworkAction
242 * @param cost The cost of this NetworkAction in [TODO]
243 * @param failed [description]
245 NetworkAction(ModelPtr model, double cost, bool failed)
246 : Action(model, cost, failed) {}
249 * @brief NetworkAction constructor
251 * @param model The NetworkModel associated to this NetworkAction
252 * @param cost The cost of this NetworkAction in [TODO]
253 * @param failed [description]
254 * @param var The lmm variable associated to this Action if it is part of a LMM component
256 NetworkAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
257 : Action(model, cost, failed, var) {};
263 const char* p_senderLinkName;
266 xbt_fifo_item_t p_senderFifoItem;
267 #ifdef HAVE_LATENCY_BOUND_TRACKING
268 int m_latencyLimited;
273 #endif /* SURF_NETWORK_INTERFACE_HPP_ */