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
27 #ifndef GNUNET_DAEMON_EXPERIMENTATION_H
28 #define GNUNET_DAEMON_EXPERIMENTATION_H
30 #include "gnunet_getopt_lib.h"
31 #include "gnunet_util_lib.h"
32 #include "gnunet_core_service.h"
33 #include "gnunet_statistics_service.h"
37 * Timeout between request and expected response
39 #define EXP_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
42 * Default experiment frequency
44 #define EXP_DEFAULT_EXP_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 6)
47 * Default experiment duration
49 #define EXP_DEFAULT_EXP_DUR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
52 * Statistics handle shared between components
54 extern struct GNUNET_STATISTICS_Handle *GED_stats;
57 * Configuration handle shared between components
59 extern struct GNUNET_CONFIGURATION_Handle *GED_cfg;
62 * Capability value shared between components
64 extern uint32_t GSE_node_capabilities;
68 * Capabilities a node has or an experiment requires
70 enum GNUNET_EXPERIMENTATION_capabilities
76 PLUGIN_HTTP_CLIENT = 8,
77 PLUGIN_HTTP_SERVER = 16,
78 PLUGIN_HTTPS_CLIENT = 32,
79 PLUGIN_HTTPS_SERVER = 64,
87 * Struct to store information about a specific experiment
92 /* ----------------- */
98 struct GNUNET_CRYPTO_EddsaPublicKey issuer;
101 * Experiment version as timestamp of creation
103 struct GNUNET_TIME_Absolute version;
111 * Required capabilities
113 uint32_t required_capabilities;
115 /* Experiment timing */
116 /* ----------------- */
119 * When to start experiment
121 struct GNUNET_TIME_Absolute start;
124 * When to end experiment
126 struct GNUNET_TIME_Absolute stop;
129 * How often to run experiment
131 struct GNUNET_TIME_Relative frequency;
134 * How long to run each execution
136 struct GNUNET_TIME_Relative duration;
139 /* Experiment itself */
140 /* ----------------- */
147 * A experimentation node
154 struct GNUNET_PeerIdentity id;
157 * Task for response timeout
159 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
162 * Core transmission handle
164 struct GNUNET_CORE_TransmitHandle *cth;
169 uint32_t capabilities;
172 * Experiment version as timestamp of creation
174 struct GNUNET_TIME_Absolute version;
176 struct NodeComCtx *e_req_head;
178 struct NodeComCtx *e_req_tail;
181 * Array of issuers accepted by this neighbor.
183 struct GNUNET_CRYPTO_EddsaPublicKey *issuer_id;
185 unsigned int issuer_count;
190 GNUNET_NETWORK_STRUCT_BEGIN
193 * Experimentation request message
194 * Used to detect experimentation capability
196 * This struct is followed by issuer identities:
197 * (issuer_count * struct GNUNET_CRYPTO_EddsaPublicKey)
200 struct Experimentation_Request
202 struct GNUNET_MessageHeader msg;
204 uint32_t capabilities GNUNET_PACKED;
206 uint32_t issuer_count GNUNET_PACKED;
211 * Experimentation response message
212 * Sent if peer is running the daemon
214 * This struct is followed by issuer identities:
215 * (issuer_count * struct GNUNET_CRYPTO_EddsaPublicKey)
217 struct Experimentation_Response
219 struct GNUNET_MessageHeader msg;
221 uint32_t capabilities GNUNET_PACKED;
223 uint32_t issuer_count GNUNET_PACKED;
228 * Struct to store information about an experiment issuer
232 struct GNUNET_CRYPTO_EddsaPublicKey pubkey;
237 * Hashmap containing valid experiment issuers
238 * (the key is the hash of the respective public key,
239 * the values are of type `struct Issuer').
241 struct GNUNET_CONTAINER_MultiHashMap *valid_issuers;
244 * Experiment start message
246 * struct is followed by string with length len_name
248 struct GED_start_message
250 struct GNUNET_MessageHeader header;
253 * String length of experiment name following the struct
255 uint32_t len_name GNUNET_PACKED;
260 struct GNUNET_CRYPTO_EddsaPublicKey issuer;
263 * Experiment version as timestamp of creation
265 struct GNUNET_TIME_AbsoluteNBO version_nbo;
269 struct GED_start_ack_message
271 struct GNUNET_MessageHeader header;
274 * String length of experiment name following the struct
276 uint32_t len_name GNUNET_PACKED;
281 struct GNUNET_CRYPTO_EddsaPublicKey issuer;
284 * Experiment version as timestamp of creation
286 struct GNUNET_TIME_AbsoluteNBO version_nbo;
290 struct GED_stop_message
292 struct GNUNET_MessageHeader header;
295 * String length of experiment name following the struct
297 uint32_t len_name GNUNET_PACKED;
302 struct GNUNET_CRYPTO_EddsaPublicKey issuer;
305 * Experiment version as timestamp of creation
307 struct GNUNET_TIME_AbsoluteNBO version_nbo;
310 GNUNET_NETWORK_STRUCT_END
314 GED_nodes_rts (struct Node *n);
318 GED_nodes_send_start (struct Node *n, struct Experiment *e);
322 * Confirm a experiment START with a node
324 * @return #GNUNET_NO if core was busy with sending, #GNUNET_OK otherwise
327 GED_nodes_send_start_ack (struct Node *n, struct Experiment *e);
330 * Start the nodes management
333 GED_nodes_start (void);
337 * Stop the nodes management
340 GED_nodes_stop (void);
344 * Print a single capability value
346 * @param cap capability value
347 * @return the string to print
350 GED_capability_to_str (uint32_t cap);
354 * Are the capabilities provided?
356 * @param have bitstring containing the provided capabilities
357 * @param desired bitstring containing the desired capabilities\
358 * @return #GNUNET_YES or #GNUNET_NO
361 GED_capabilities_have (uint32_t have, uint32_t desired);
365 * Start the detecting capabilities
368 GED_capabilities_start (void);
372 * Stop the detecting capabilities
375 GED_capabilities_stop (void);
379 * Start experiments management
381 * @return #GNUNET_YES or #GNUNET_NO
384 GED_experiments_issuer_accepted (const struct GNUNET_CRYPTO_EddsaPublicKey *issuer_ID);
388 * Find an experiment based on issuer name and version
390 * @param issuer the issuer
391 * @param name experiment name
392 * @param version experiment version
393 * @return the experiment or NULL if not found
396 GED_experiments_find (const struct GNUNET_CRYPTO_EddsaPublicKey *issuer,
398 const struct GNUNET_TIME_Absolute version);
401 typedef void (*GNUNET_EXPERIMENTATION_experiments_get_cb) (struct Node *n,
402 struct Experiment *e);
406 GED_experiments_get (struct Node *n,
407 struct GNUNET_CRYPTO_EddsaPublicKey *issuer,
408 GNUNET_EXPERIMENTATION_experiments_get_cb get_cb);
412 * Start experiments management
414 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
417 GED_experiments_start (void);
421 * Stop experiments management
424 GED_experiments_stop (void);
428 * Handle a START message from a remote node
431 * @param e the experiment
434 GED_scheduler_handle_start (struct Node *n, struct Experiment *e);
438 * Handle a START_ACL message from a remote node
441 * @param e the experiment
444 GED_scheduler_handle_start_ack (struct Node *n, struct Experiment *e);
448 * Handle a STOP message from a remote node
451 * @param e the experiment
454 GED_scheduler_handle_stop (struct Node *n, struct Experiment *e);
458 * Add a new experiment for a node
461 * @param e the experiment
462 * @param outbound are we initiator (#GNUNET_YES) or client (#GNUNET_NO)?
465 GED_scheduler_add (struct Node *n,
466 struct Experiment *e,
471 * Start the scheduler component
474 GED_scheduler_start (void);
478 * Stop the scheduler component
481 GED_scheduler_stop (void);
485 * Start the storage component
488 GED_storage_start (void);
492 * Stop the storage component
495 GED_storage_stop (void);
498 #endif /* #ifndef GNUNET_DAEMON_EXPERIMENTATION_H */
499 /* end of gnunet-daemon-experimentation.h */