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;
179 * Array of issuers accepted by this neighbor.
181 struct GNUNET_CRYPTO_EccPublicSignKey *issuer_id;
183 unsigned int issuer_count;
188 GNUNET_NETWORK_STRUCT_BEGIN
191 * Experimentation request message
192 * Used to detect experimentation capability
194 * This struct is followed by issuer identities:
195 * (issuer_count * struct GNUNET_CRYPTO_EccPublicSignKey)
198 struct Experimentation_Request
200 struct GNUNET_MessageHeader msg;
202 uint32_t capabilities GNUNET_PACKED;
204 uint32_t issuer_count GNUNET_PACKED;
209 * Experimentation response message
210 * Sent if peer is running the daemon
212 * This struct is followed by issuer identities:
213 * (issuer_count * struct GNUNET_CRYPTO_EccPublicSignKey)
215 struct Experimentation_Response
217 struct GNUNET_MessageHeader msg;
219 uint32_t capabilities GNUNET_PACKED;
221 uint32_t issuer_count GNUNET_PACKED;
226 * Struct to store information about an experiment issuer
230 struct GNUNET_CRYPTO_EccPublicSignKey pubkey;
235 * Hashmap containing valid experiment issuers
236 * (the key is the hash of the respective public key,
237 * the values are of type `struct Issuer').
239 struct GNUNET_CONTAINER_MultiHashMap *valid_issuers;
242 * Experiment start message
244 * struct is followed by string with length len_name
246 struct GED_start_message
248 struct GNUNET_MessageHeader header;
251 * String length of experiment name following the struct
253 uint32_t len_name GNUNET_PACKED;
258 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
261 * Experiment version as timestamp of creation
263 struct GNUNET_TIME_AbsoluteNBO version_nbo;
267 struct GED_start_ack_message
269 struct GNUNET_MessageHeader header;
272 * String length of experiment name following the struct
274 uint32_t len_name GNUNET_PACKED;
279 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
282 * Experiment version as timestamp of creation
284 struct GNUNET_TIME_AbsoluteNBO version_nbo;
288 struct GED_stop_message
290 struct GNUNET_MessageHeader header;
293 * String length of experiment name following the struct
295 uint32_t len_name GNUNET_PACKED;
300 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
303 * Experiment version as timestamp of creation
305 struct GNUNET_TIME_AbsoluteNBO version_nbo;
308 GNUNET_NETWORK_STRUCT_END
312 GED_nodes_rts (struct Node *n);
316 GED_nodes_send_start (struct Node *n, struct Experiment *e);
320 * Confirm a experiment START with a node
322 * @return #GNUNET_NO if core was busy with sending, #GNUNET_OK otherwise
325 GED_nodes_send_start_ack (struct Node *n, struct Experiment *e);
328 * Start the nodes management
331 GED_nodes_start (void);
335 * Stop the nodes management
338 GED_nodes_stop (void);
342 * Print a single capability value
344 * @param cap capability value
345 * @return the string to print
348 GED_capability_to_str (uint32_t cap);
352 * Are the capabilities provided?
354 * @param have bitstring containing the provided capabilities
355 * @param desired bitstring containing the desired capabilities\
356 * @return #GNUNET_YES or #GNUNET_NO
359 GED_capabilities_have (uint32_t have, uint32_t desired);
363 * Start the detecting capabilities
366 GED_capabilities_start (void);
370 * Stop the detecting capabilities
373 GED_capabilities_stop (void);
377 * Start experiments management
379 * @return #GNUNET_YES or #GNUNET_NO
382 GED_experiments_issuer_accepted (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer_ID);
386 * Find an experiment based on issuer name and version
388 * @param issuer the issuer
389 * @param name experiment name
390 * @param version experiment version
391 * @return the experiment or NULL if not found
394 GED_experiments_find (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
396 const struct GNUNET_TIME_Absolute version);
399 typedef void (*GNUNET_EXPERIMENTATION_experiments_get_cb) (struct Node *n,
400 struct Experiment *e);
404 GED_experiments_get (struct Node *n,
405 struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
406 GNUNET_EXPERIMENTATION_experiments_get_cb get_cb);
410 * Start experiments management
412 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
415 GED_experiments_start (void);
419 * Stop experiments management
422 GED_experiments_stop (void);
426 * Handle a START message from a remote node
429 * @param e the experiment
432 GED_scheduler_handle_start (struct Node *n, struct Experiment *e);
436 * Handle a START_ACL message from a remote node
439 * @param e the experiment
442 GED_scheduler_handle_start_ack (struct Node *n, struct Experiment *e);
446 * Handle a STOP message from a remote node
449 * @param e the experiment
452 GED_scheduler_handle_stop (struct Node *n, struct Experiment *e);
456 * Add a new experiment for a node
459 * @param e the experiment
460 * @param outbound are we initiator (#GNUNET_YES) or client (#GNUNET_NO)?
463 GED_scheduler_add (struct Node *n,
464 struct Experiment *e,
469 * Start the scheduler component
472 GED_scheduler_start (void);
476 * Stop the scheduler component
479 GED_scheduler_stop (void);
483 * Start the storage component
486 GED_storage_start (void);
490 * Stop the storage component
493 GED_storage_stop (void);
496 /* end of gnunet-daemon-experimentation.h */