experimentation timing
[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, 10)
38
39 /**
40  * Default experiment frequency
41  */
42 #define EXP_DEFAULT_EXP_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
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  * A experimentation node
88  */
89 struct Node
90 {
91         /**
92          * Peer id
93          */
94         struct GNUNET_PeerIdentity id;
95
96         /**
97          * Task for response timeout
98          */
99         GNUNET_SCHEDULER_TaskIdentifier timeout_task;
100
101         /**
102          * Core transmission handle
103          */
104         struct GNUNET_CORE_TransmitHandle *cth;
105
106         uint32_t capabilities;
107 };
108
109 /**
110  * Experimentation request message
111  * Used to detect experimentation capability
112  */
113 struct Experimentation_Request
114 {
115         struct GNUNET_MessageHeader msg;
116
117         uint32_t capabilities;
118 };
119
120 /**
121  * Experimentation response message
122  * Sent if peer is running the daemon
123  */
124 struct Experimentation_Response
125 {
126         struct GNUNET_MessageHeader msg;
127
128         uint32_t capabilities;
129 };
130
131
132 /**
133  * Start the nodes management
134  */
135 void
136 GNUNET_EXPERIMENTATION_nodes_start ();
137
138
139 /**
140  * Stop the nodes management
141  */
142 void
143 GNUNET_EXPERIMENTATION_nodes_stop ();
144
145
146 /**
147  * Print a single capability value
148  *
149  * @param cap capability value
150  * @return the string to print
151  */
152 const char *
153 GNUNET_EXPERIMENTATION_capability_to_str (uint32_t cap);
154
155
156 /**
157  * Are the capabilities provided?
158  *
159  * @param have bitstring containing the provided capabilities
160  * @param desired bitstring containing the desired capabilities\
161  * @return GNUNET_YES or GNUNET_NO
162  */
163 int
164 GNUNET_EXPERIMENTATION_capabilities_have (uint32_t have, uint32_t desired);
165
166
167 /**
168  * Start the detecting capabilities
169  */
170 void
171 GNUNET_EXPERIMENTATION_capabilities_start ();
172
173
174 /**
175  * Stop the detecting capabilities
176  */
177 void
178 GNUNET_EXPERIMENTATION_capabilities_stop ();
179
180
181 /**
182  * Start experiments management
183  *
184  * @return GNUNET_YES or GNUNET_NO
185  */
186 int
187 GNUNET_EXPERIMENTATION_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID);
188
189
190 /**
191  * Start experiments management
192  *
193  * @return GNUNET_OK on success, GNUNET_SYSERR on error
194  */
195 int
196 GNUNET_EXPERIMENTATION_experiments_start ();
197
198
199 /**
200  * Stop experiments management
201  */
202 void
203 GNUNET_EXPERIMENTATION_experiments_stop ();
204
205
206 /**
207  * Start the scheduler component
208  */
209 void
210 GNUNET_EXPERIMENTATION_scheduler_start ();
211
212
213 /**
214  * Stop the scheduler component
215  */
216 void
217 GNUNET_EXPERIMENTATION_scheduler_stop ();
218
219
220 /**
221  * Start the storage component
222  */
223 void
224 GNUNET_EXPERIMENTATION_storage_start ();
225
226
227
228 /**
229  * Stop the storage component
230  */
231 void
232 GNUNET_EXPERIMENTATION_storage_stop ();
233
234
235 /* end of gnunet-daemon-experimentation.h */