Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
proper check for the -std=gnu++11 standard, and take in on clang too
[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_cm02.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 #include "surf/gtnets/gtnets_topology.h"
25
26 xbt_dict_t network_card_ids;
27
28 /***********
29  * Classes *
30  ***********/
31 class NetworkGTNetsModel;
32 typedef NetworkGTNetsModel *NetworkGTNetsModelPtr;
33
34 class NetworkGTNetsAction;
35 typedef NetworkGTNetsAction *NetworkGTNetsActionPtr;
36
37 class NetworkGTNetsActionLmm;
38 typedef NetworkGTNetsActionLmm *NetworkGTNetsActionLmmPtr;
39
40 /*********
41  * Model *
42  *********/
43 class NetworkGTNetsModel : public NetworkCm02Model {
44 public:
45   NetworkGTNetsModel() : NetworkCm02Model("constant time network") {};
46   int addLink(int id, double bandwidth, double latency);
47   int addOnehop_route(int src, int dst, int link);
48   int addRoute(int src, int dst, int *links, int nlink);
49   int addRouter(int id);
50   int createFlow(int src, int dst, long datasize, void *metadata);
51   double getTimeToNextFlowCompletion();
52   int runUntilNextFlowCompletion(void ***metadata,
53                                      int *number_of_flows);
54   int run(double deltat);
55   // returns the total received by the TCPServer peer of the given action
56   double gtNetsGetFlowRx(void *metadata);
57   void createGTNetsTopology();
58   void printTopology();
59   void setJitter(double);
60   void setJitterSeed(int);
61 private:
62   void addNodes();
63   void nodeConnect();
64
65   bool nodeInclude(int);
66   bool linkInclude(int);
67   Simulator *p_sim;
68   GTNETS_Topology *p_topo;
69   RoutingManual *p_rm;
70   REDQueue *p_redQueue;
71   int m_nnode;
72   int m_isTopology;
73   int m_nflow;
74   double m_jitter;
75   int m_jitterSeed;
76    map<int, Uniform*> p_uniformJitterGenerator;
77
78    map<int, TCPServer*> p_gtnetsServers;
79    map<int, TCPSend*> p_gtnetsClients;
80    map<int, GTLinkp2p*> p_gtnetsLinks_;
81    map<int, Node*> p_gtnetsNodes;
82    map<void*, int> p_gtnetsActionToFlow;
83
84    map <int, void*> p_gtnetsMetadata;
85
86    // From Topology
87    int m_nodeID;
88    map<int, GTNETS_Link*> p_links;
89    vector<GTNETS_Node*> p_nodes;
90    map<int, int> p_hosts;      //hostid->nodeid
91    set<int > p_routers;
92 };
93
94 /************
95  * Resource *
96  ************/
97 class NetworkGTNetsLink : public NetworkCm02Link {
98 public:
99   NetworkGTNetsLink(NetworkGTNetsModelPtr model, const char* name, double bw, double lat, xbt_dict_t properties);
100   /* Using this object with the public part of
101   model does not make sense */
102   double m_bwCurrent;
103   double m_latCurrent;
104   int m_id;
105 };
106
107 /**********
108  * Action *
109  **********/
110 class NetworkGTNetsAction : public NetworkCm02Action {
111 public:
112   NetworkGTNetsAction(NetworkGTNetsModelPtr model, double latency){};
113
114   double m_latency;
115   double m_latCurrent;
116   int m_lastRemains;
117   lmm_variable_t p_variable;
118   double m_rate;
119   int m_suspended;
120   RoutingEdgePtr src;
121   RoutingEdgePtr dst;
122 };
123
124 #endif /* NETWORK_GTNETS_HPP_ */