scheduling
[oweals/gnunet.git] / src / experimentation / gnunet-daemon-experimentation.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file experimentation/gnunet-daemon-experimentation.h
23  * @brief experimentation daemon
24  * @author Christian Grothoff
25  * @author Matthias Wachs
26  */
27 #include "platform.h"
28 #include "gnunet_getopt_lib.h"
29 #include "gnunet_util_lib.h"
30 #include "gnunet_core_service.h"
31 #include "gnunet_statistics_service.h"
32
33
34 /**
35  * Timeout between request and expected response
36  */
37 #define EXP_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
38
39 /**
40  * Default experiment frequency
41  */
42 #define EXP_DEFAULT_EXP_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 6)
43
44 /**
45  * Default experiment duration
46  */
47 #define EXP_DEFAULT_EXP_DUR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
48
49 /**
50  * Statistics handle shared between components
51  */
52 extern struct GNUNET_STATISTICS_Handle *GSE_stats;
53
54
55 /**
56  * Configuration handle shared between components
57  */
58 extern struct GNUNET_CONFIGURATION_Handle *GSE_cfg;
59
60
61 /**
62  * Capability value shared between components
63  */
64 extern uint32_t GSE_node_capabilities;
65
66
67 /**
68  * Capabilities a node has or an experiment requires
69  */
70 enum GNUNET_EXPERIMENTATION_capabilities
71 {
72         NONE = 0,
73         PLUGIN_TCP = 1,
74         PLUGIN_UDP = 2,
75         PLUGIN_UNIX = 4,
76         PLUGIN_HTTP_CLIENT = 8,
77         PLUGIN_HTTP_SERVER = 16,
78         PLUGIN_HTTPS_CLIENT = 32,
79         PLUGIN_HTTPS_SERVER = 64,
80         PLUGIN_WLAN = 128,
81         HAVE_IPV6 = 256,
82         BEHIND_NAT = 512
83 };
84
85
86 /**
87  * Struct to store information about a specific experiment
88  */
89 struct Experiment
90 {
91         /* Header */
92         /* ----------------- */
93         char *name;
94
95         /* Experiment issuer */
96         struct GNUNET_PeerIdentity issuer;
97
98         /* Experiment version as timestamp of creation */
99         struct GNUNET_TIME_Absolute version;
100
101         /* Description */
102         char *description;
103
104         /* Required capabilities  */
105         uint32_t required_capabilities;
106
107         /* Experiment timing */
108         /* ----------------- */
109
110         /* When to start experiment */
111         struct GNUNET_TIME_Absolute start;
112
113         /* When to end experiment */
114         struct GNUNET_TIME_Absolute stop;
115
116         /* How often to run experiment */
117         struct GNUNET_TIME_Relative frequency;
118
119         /* How long to run each execution  */
120         struct GNUNET_TIME_Relative duration;
121
122
123         /* Experiment itself */
124         /* ----------------- */
125
126         /* TBD */
127 };
128
129
130 /**
131  * A experimentation node
132  */
133 struct Node
134 {
135         /**
136          * Peer id
137          */
138         struct GNUNET_PeerIdentity id;
139
140         /**
141          * Task for response timeout
142          */
143         GNUNET_SCHEDULER_TaskIdentifier timeout_task;
144
145         /**
146          * Core transmission handle
147          */
148         struct GNUNET_CORE_TransmitHandle *cth;
149
150         uint32_t capabilities;
151 };
152
153 /**
154  * Experimentation request message
155  * Used to detect experimentation capability
156  */
157 struct Experimentation_Request
158 {
159         struct GNUNET_MessageHeader msg;
160
161         uint32_t capabilities;
162 };
163
164 /**
165  * Experimentation response message
166  * Sent if peer is running the daemon
167  */
168 struct Experimentation_Response
169 {
170         struct GNUNET_MessageHeader msg;
171
172         uint32_t capabilities;
173 };
174
175
176 /**
177  * Start the nodes management
178  */
179 void
180 GNUNET_EXPERIMENTATION_nodes_start ();
181
182
183 /**
184  * Stop the nodes management
185  */
186 void
187 GNUNET_EXPERIMENTATION_nodes_stop ();
188
189
190 /**
191  * Print a single capability value
192  *
193  * @param cap capability value
194  * @return the string to print
195  */
196 const char *
197 GNUNET_EXPERIMENTATION_capability_to_str (uint32_t cap);
198
199
200 /**
201  * Are the capabilities provided?
202  *
203  * @param have bitstring containing the provided capabilities
204  * @param desired bitstring containing the desired capabilities\
205  * @return GNUNET_YES or GNUNET_NO
206  */
207 int
208 GNUNET_EXPERIMENTATION_capabilities_have (uint32_t have, uint32_t desired);
209
210
211 /**
212  * Start the detecting capabilities
213  */
214 void
215 GNUNET_EXPERIMENTATION_capabilities_start ();
216
217
218 /**
219  * Stop the detecting capabilities
220  */
221 void
222 GNUNET_EXPERIMENTATION_capabilities_stop ();
223
224
225 /**
226  * Start experiments management
227  *
228  * @return GNUNET_YES or GNUNET_NO
229  */
230 int
231 GNUNET_EXPERIMENTATION_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID);
232
233
234 /**
235  * Start experiments management
236  *
237  * @return GNUNET_OK on success, GNUNET_SYSERR on error
238  */
239 int
240 GNUNET_EXPERIMENTATION_experiments_start ();
241
242
243 /**
244  * Stop experiments management
245  */
246 void
247 GNUNET_EXPERIMENTATION_experiments_stop ();
248
249
250 /**
251  * Start the scheduler component
252  */
253 void
254 GNUNET_EXPERIMENTATION_scheduler_add (struct Experiment *e);
255
256 /**
257  * Start the scheduler component
258  */
259 void
260 GNUNET_EXPERIMENTATION_scheduler_start ();
261
262
263 /**
264  * Stop the scheduler component
265  */
266 void
267 GNUNET_EXPERIMENTATION_scheduler_stop ();
268
269
270 /**
271  * Start the storage component
272  */
273 void
274 GNUNET_EXPERIMENTATION_storage_start ();
275
276
277
278 /**
279  * Stop the storage component
280  */
281 void
282 GNUNET_EXPERIMENTATION_storage_stop ();
283
284
285 /* end of gnunet-daemon-experimentation.h */