Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check return value for posix_memalign.
[simgrid.git] / src / surf / network_gtnets.hpp
1 /* Copyright (c) 2013-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "network.hpp"
8
9 #ifndef NETWORK_GTNETS_HPP_
10 #define NETWORK_GTNETS_HPP_
11
12 #include "simulator.h"          // Definitions for the Simulator Object
13 #include "node.h"               // Definitions for the Node Object
14 #include "linkp2p.h"            // Definitions for point-to-point link objects
15 #include "ratetimeparse.h"      // Definitions for Rate and Time objects
16 #include "application-tcpserver.h"      // Definitions for TCPServer application
17 #include "application-tcpsend.h"        // Definitions for TCP Sending application
18 #include "tcp-tahoe.h"          // Definitions for TCP Tahoe
19 #include "tcp-reno.h"
20 #include "tcp-newreno.h"
21 #include "event.h"
22 #include "routing-manual.h"
23 #include "red.h"
24
25 xbt_dict_t network_card_ids;
26
27 /***********
28  * Classes *
29  ***********/
30 class NetworkGTNetsModel;
31 typedef NetworkGTNetsModel *NetworkGTNetsModelPtr;
32
33 class NetworkGTNetsLink;
34 typedef NetworkGTNetsLink *NetworkGTNetsLinkPtr;
35
36 class NetworkGTNetsAction;
37 typedef NetworkGTNetsAction *NetworkGTNetsActionPtr;
38
39 class NetworkGTNetsActionLmm;
40 typedef NetworkGTNetsActionLmm *NetworkGTNetsActionLmmPtr;
41
42 /*********
43  * Model *
44  *********/
45 class NetworkGTNetsModel : public NetworkCm02Model {
46 public:
47   NetworkGTNetsModel() : NetworkCm02Model("constant time network") {};
48   int addLink(int id, double bandwidth, double latency);
49   int addOnehop_route(int src, int dst, int link);
50   int addRoute(int src, int dst, int *links, int nlink);
51   int addRouter(int id);
52   int createFlow(int src, int dst, long datasize, void *metadata);
53   double getTimeToNextFlowCompletion();
54   int runUntilNextFlowCompletion(void ***metadata,
55                                      int *number_of_flows);
56   int run(double deltat);
57   // returns the total received by the TCPServer peer of the given action
58   double gtNetsGetFlowRx(void *metadata);
59   void createGTNetsTopology();
60   void printTopology();
61   void setJitter(double);
62   void setJitterSeed(int);
63 private:
64   void addNodes();
65   void nodeConnect();
66
67   bool nodeInclude(int);
68   bool linkInclude(int);
69   Simulator *p_sim;
70   GTNETS_Topology *p_topo;
71   RoutingManual *p_rm;
72   REDQueue *p_redQueue;
73   int m_nnode;
74   int m_isTopology;
75   int m_nflow;
76   double m_jitter;
77   int m_jitterSeed;
78    map<int, Uniform*> p_uniformJitterGenerator;
79
80    map<int, TCPServer*> p_gtnetsServers;
81    map<int, TCPSend*> p_gtnetsClients;
82    map<int, Linkp2p*> p_gtnetsLinks_;
83    map<int, Node*> p_gtnetsNodes;
84    map<void*, int> p_gtnetsActionToFlow;
85
86    map <int, void*> p_gtnetsMetadata;
87
88    // From Topology
89    int m_nodeID;
90    map<int, GTNETS_Link*> p_links;
91    vector<GTNETS_Node*> p_nodes;
92    map<int, int> p_hosts;      //hostid->nodeid
93    set<int > p_routers;
94 };
95
96 /************
97  * Resource *
98  ************/
99 class NetworkGTNetsLink : public NetworkCm02Link {
100 public:
101   NetworkGTNetsLink(NetworkGTNetsModelPtr model, const char* name, double bw, double lat, xbt_dict_t properties);
102   /* Using this object with the public part of
103   model does not make sense */
104   double m_bwCurrent;
105   double m_latCurrent;
106   int m_id;
107 };
108
109 /**********
110  * Action *
111  **********/
112 class NetworkGTNetsAction : public NetworkCm02Action {
113 public:
114   NetworkGTNetsAction(NetworkGTNetsModelPtr model, double latency){};
115
116   double m_latency;
117   double m_latCurrent;
118 #ifdef HAVE_TRACING
119   int m_lastRemains;
120 #endif
121   lmm_variable_t p_variable;
122   double m_rate;
123   int m_suspended;
124 #ifdef HAVE_TRACING
125   RoutingEdgePtr src;
126   RoutingEdgePtr dst;
127 #endif //HAVE_TRACING
128 };
129
130 #endif /* NETWORK_GTNETS_HPP_ */