2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file experimentation/gnunet-daemon-experimentation.h
23 * @brief experimentation daemon
24 * @author Christian Grothoff
25 * @author Matthias Wachs
28 #include "gnunet_getopt_lib.h"
29 #include "gnunet_util_lib.h"
30 #include "gnunet_core_service.h"
31 #include "gnunet_statistics_service.h"
35 * Timeout between request and expected response
37 #define EXP_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
40 * Default experiment frequency
42 #define EXP_DEFAULT_EXP_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 6)
45 * Default experiment duration
47 #define EXP_DEFAULT_EXP_DUR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
50 * Statistics handle shared between components
52 extern struct GNUNET_STATISTICS_Handle *GED_stats;
56 * Configuration handle shared between components
58 extern struct GNUNET_CONFIGURATION_Handle *GED_cfg;
62 * Capability value shared between components
64 extern uint32_t GSE_node_capabilities;
67 extern uint32_t GSE_my_issuer_count;
69 extern struct Experimentation_Issuer *GSE_my_issuer;
72 * Capabilities a node has or an experiment requires
74 enum GNUNET_EXPERIMENTATION_capabilities
80 PLUGIN_HTTP_CLIENT = 8,
81 PLUGIN_HTTP_SERVER = 16,
82 PLUGIN_HTTPS_CLIENT = 32,
83 PLUGIN_HTTPS_SERVER = 64,
91 * Struct to store information about a specific experiment
96 /* ----------------- */
99 /* Experiment issuer */
100 struct GNUNET_PeerIdentity issuer;
102 /* Experiment version as timestamp of creation */
103 struct GNUNET_TIME_Absolute version;
108 /* Required capabilities */
109 uint32_t required_capabilities;
111 /* Experiment timing */
112 /* ----------------- */
114 /* When to start experiment */
115 struct GNUNET_TIME_Absolute start;
117 /* When to end experiment */
118 struct GNUNET_TIME_Absolute stop;
120 /* How often to run experiment */
121 struct GNUNET_TIME_Relative frequency;
123 /* How long to run each execution */
124 struct GNUNET_TIME_Relative duration;
127 /* Experiment itself */
128 /* ----------------- */
135 * A experimentation node
142 struct GNUNET_PeerIdentity id;
145 * Task for response timeout
147 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
150 * Core transmission handle
152 struct GNUNET_CORE_TransmitHandle *cth;
157 uint32_t capabilities;
159 /* Experiment version as timestamp of creation */
160 struct GNUNET_TIME_Absolute version;
162 uint32_t issuer_count;
165 * Array of fssuer ids
167 struct GNUNET_PeerIdentity *issuer_id;
169 struct NodeComCtx *e_req_head;
170 struct NodeComCtx *e_req_tail;
173 struct Experimentation_Issuer
175 struct GNUNET_PeerIdentity issuer_id;
178 GNUNET_NETWORK_STRUCT_BEGIN
181 * Experimentation request message
182 * Used to detect experimentation capability
184 * This struct is followed by issuer identities:
185 * (issuer_count * struct Experimentation_Request_Issuer)
188 struct Experimentation_Request
190 struct GNUNET_MessageHeader msg;
192 uint32_t capabilities;
194 uint32_t issuer_count;
198 * Experimentation response message
199 * Sent if peer is running the daemon
201 * This struct is followed by issuer identities:
202 * (issuer_count * struct Experimentation_Request_Issuer)
204 struct Experimentation_Response
206 struct GNUNET_MessageHeader msg;
208 uint32_t capabilities;
210 uint32_t issuer_count;
215 * Experiment start message
217 * struct is followed by string with length len_name
219 struct GED_start_message
221 struct GNUNET_MessageHeader header;
224 * String length of experiment name following the struct
228 /* Experiment issuer */
229 struct GNUNET_PeerIdentity issuer;
231 /* Experiment version as timestamp of creation */
232 struct GNUNET_TIME_AbsoluteNBO version_nbo;
235 struct GED_start_ack_message
237 struct GNUNET_MessageHeader header;
240 * String length of experiment name following the struct
244 /* Experiment issuer */
245 struct GNUNET_PeerIdentity issuer;
247 /* Experiment version as timestamp of creation */
248 struct GNUNET_TIME_AbsoluteNBO version_nbo;
251 struct GED_stop_message
253 struct GNUNET_MessageHeader header;
256 * String length of experiment name following the struct
260 /* Experiment issuer */
261 struct GNUNET_PeerIdentity issuer;
263 /* Experiment version as timestamp of creation */
264 struct GNUNET_TIME_AbsoluteNBO version_nbo;
267 GNUNET_NETWORK_STRUCT_END
271 GED_nodes_rts (struct Node *n);
274 GED_nodes_send_start (struct Node *n, struct Experiment *e);
277 * Confirm a experiment START with a node
279 * @return GNUNET_NO if core was busy with sending, GNUNET_OK otherwise
282 GED_nodes_send_start_ack (struct Node *n, struct Experiment *e);
285 * Start the nodes management
292 * Stop the nodes management
299 * Print a single capability value
301 * @param cap capability value
302 * @return the string to print
305 GED_capability_to_str (uint32_t cap);
309 * Are the capabilities provided?
311 * @param have bitstring containing the provided capabilities
312 * @param desired bitstring containing the desired capabilities\
313 * @return GNUNET_YES or GNUNET_NO
316 GED_capabilities_have (uint32_t have, uint32_t desired);
320 * Start the detecting capabilities
323 GED_capabilities_start ();
327 * Stop the detecting capabilities
330 GED_capabilities_stop ();
334 * Start experiments management
336 * @return GNUNET_YES or GNUNET_NO
339 GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID);
343 * Find an experiment based on issuer name and version
345 * @param issuer the issuer
346 * @param name experiment name
347 * @param version experiment version
348 * @return the experiment or NULL if not found
351 GED_experiments_find (const struct GNUNET_PeerIdentity *issuer,
353 const struct GNUNET_TIME_Absolute version);
356 typedef void (*GNUNET_EXPERIMENTATION_experiments_get_cb) (struct Node *n, struct Experiment *e);
360 GED_experiments_get (struct Node *n,
361 struct GNUNET_PeerIdentity *issuer,
362 GNUNET_EXPERIMENTATION_experiments_get_cb get_cb);
365 * Start experiments management
367 * @return GNUNET_OK on success, GNUNET_SYSERR on error
370 GED_experiments_start ();
374 * Stop experiments management
377 GED_experiments_stop ();
380 * Handle a START message from a remote node
383 * @param e the experiment
386 GED_scheduler_handle_start (struct Node *n, struct Experiment *e);
390 * Handle a START_ACL message from a remote node
393 * @param e the experiment
396 GED_scheduler_handle_start_ack (struct Node *n, struct Experiment *e);
399 * Handle a STOP message from a remote node
402 * @param e the experiment
405 GED_scheduler_handle_stop (struct Node *n, struct Experiment *e);
409 * Add a new experiment for a node
412 * @param e the experiment
413 * @param outbound are we initiator (GNUNET_YES) or client (GNUNET_NO)?
416 GED_scheduler_add (struct Node *n, struct Experiment *e, int outbound);
419 * Start the scheduler component
422 GED_scheduler_start ();
426 * Stop the scheduler component
429 GED_scheduler_stop ();
433 * Start the storage component
436 GED_storage_start ();
441 * Stop the storage component
447 /* end of gnunet-daemon-experimentation.h */