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;
55 * Configuration handle shared between components
57 extern struct GNUNET_CONFIGURATION_Handle *GED_cfg;
60 * Capability value shared between components
62 extern uint32_t GSE_node_capabilities;
66 * Capabilities a node has or an experiment requires
68 enum GNUNET_EXPERIMENTATION_capabilities
74 PLUGIN_HTTP_CLIENT = 8,
75 PLUGIN_HTTP_SERVER = 16,
76 PLUGIN_HTTPS_CLIENT = 32,
77 PLUGIN_HTTPS_SERVER = 64,
85 * Struct to store information about a specific experiment
90 /* ----------------- */
96 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
99 * Experiment version as timestamp of creation
101 struct GNUNET_TIME_Absolute version;
109 * Required capabilities
111 uint32_t required_capabilities;
113 /* Experiment timing */
114 /* ----------------- */
117 * When to start experiment
119 struct GNUNET_TIME_Absolute start;
122 * When to end experiment
124 struct GNUNET_TIME_Absolute stop;
127 * How often to run experiment
129 struct GNUNET_TIME_Relative frequency;
132 * How long to run each execution
134 struct GNUNET_TIME_Relative duration;
137 /* Experiment itself */
138 /* ----------------- */
145 * A experimentation node
152 struct GNUNET_PeerIdentity id;
155 * Task for response timeout
157 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
160 * Core transmission handle
162 struct GNUNET_CORE_TransmitHandle *cth;
167 uint32_t capabilities;
170 * Experiment version as timestamp of creation
172 struct GNUNET_TIME_Absolute version;
174 struct NodeComCtx *e_req_head;
176 struct NodeComCtx *e_req_tail;
180 GNUNET_NETWORK_STRUCT_BEGIN
183 * Experimentation request message
184 * Used to detect experimentation capability
186 * This struct is followed by issuer identities:
187 * (issuer_count * struct GNUNET_CRYPTO_EccPublicSignKey)
190 struct Experimentation_Request
192 struct GNUNET_MessageHeader msg;
194 uint32_t capabilities GNUNET_PACKED;
196 uint32_t issuer_count GNUNET_PACKED;
201 * Experimentation response message
202 * Sent if peer is running the daemon
204 * This struct is followed by issuer identities:
205 * (issuer_count * struct GNUNET_CRYPTO_EccPublicSignKey)
207 struct Experimentation_Response
209 struct GNUNET_MessageHeader msg;
211 uint32_t capabilities GNUNET_PACKED;
213 uint32_t issuer_count GNUNET_PACKED;
218 * Struct to store information about an experiment issuer
222 struct GNUNET_CRYPTO_EccPublicSignKey pubkey;
227 * Hashmap containing valid experiment issuers
228 * (the key is the hash of the respective public key,
229 * the values are of type `struct Issuer').
231 struct GNUNET_CONTAINER_MultiHashMap *valid_issuers;
234 * Experiment start message
236 * struct is followed by string with length len_name
238 struct GED_start_message
240 struct GNUNET_MessageHeader header;
243 * String length of experiment name following the struct
245 uint32_t len_name GNUNET_PACKED;
250 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
253 * Experiment version as timestamp of creation
255 struct GNUNET_TIME_AbsoluteNBO version_nbo;
259 struct GED_start_ack_message
261 struct GNUNET_MessageHeader header;
264 * String length of experiment name following the struct
266 uint32_t len_name GNUNET_PACKED;
271 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
274 * Experiment version as timestamp of creation
276 struct GNUNET_TIME_AbsoluteNBO version_nbo;
280 struct GED_stop_message
282 struct GNUNET_MessageHeader header;
285 * String length of experiment name following the struct
287 uint32_t len_name GNUNET_PACKED;
292 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
295 * Experiment version as timestamp of creation
297 struct GNUNET_TIME_AbsoluteNBO version_nbo;
300 GNUNET_NETWORK_STRUCT_END
304 GED_nodes_rts (struct Node *n);
308 GED_nodes_send_start (struct Node *n, struct Experiment *e);
312 * Confirm a experiment START with a node
314 * @return #GNUNET_NO if core was busy with sending, #GNUNET_OK otherwise
317 GED_nodes_send_start_ack (struct Node *n, struct Experiment *e);
320 * Start the nodes management
323 GED_nodes_start (void);
327 * Stop the nodes management
330 GED_nodes_stop (void);
334 * Print a single capability value
336 * @param cap capability value
337 * @return the string to print
340 GED_capability_to_str (uint32_t cap);
344 * Are the capabilities provided?
346 * @param have bitstring containing the provided capabilities
347 * @param desired bitstring containing the desired capabilities\
348 * @return #GNUNET_YES or #GNUNET_NO
351 GED_capabilities_have (uint32_t have, uint32_t desired);
355 * Start the detecting capabilities
358 GED_capabilities_start (void);
362 * Stop the detecting capabilities
365 GED_capabilities_stop (void);
369 * Start experiments management
371 * @return #GNUNET_YES or #GNUNET_NO
374 GED_experiments_issuer_accepted (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer_ID);
378 * Find an experiment based on issuer name and version
380 * @param issuer the issuer
381 * @param name experiment name
382 * @param version experiment version
383 * @return the experiment or NULL if not found
386 GED_experiments_find (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
388 const struct GNUNET_TIME_Absolute version);
391 typedef void (*GNUNET_EXPERIMENTATION_experiments_get_cb) (struct Node *n,
392 struct Experiment *e);
396 GED_experiments_get (struct Node *n,
397 struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
398 GNUNET_EXPERIMENTATION_experiments_get_cb get_cb);
402 * Start experiments management
404 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
407 GED_experiments_start (void);
411 * Stop experiments management
414 GED_experiments_stop (void);
418 * Handle a START message from a remote node
421 * @param e the experiment
424 GED_scheduler_handle_start (struct Node *n, struct Experiment *e);
428 * Handle a START_ACL message from a remote node
431 * @param e the experiment
434 GED_scheduler_handle_start_ack (struct Node *n, struct Experiment *e);
438 * Handle a STOP message from a remote node
441 * @param e the experiment
444 GED_scheduler_handle_stop (struct Node *n, struct Experiment *e);
448 * Add a new experiment for a node
451 * @param e the experiment
452 * @param outbound are we initiator (#GNUNET_YES) or client (#GNUNET_NO)?
455 GED_scheduler_add (struct Node *n,
456 struct Experiment *e,
461 * Start the scheduler component
464 GED_scheduler_start (void);
468 * Stop the scheduler component
471 GED_scheduler_stop (void);
475 * Start the storage component
478 GED_storage_start (void);
482 * Stop the storage component
485 GED_storage_stop (void);
488 /* end of gnunet-daemon-experimentation.h */