2 This file is part of GNUnet.
3 (C) 2011, 2012 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 mesh/gnunet-regex-profiler.c
23 * @brief Regex profiler for testing distributed regex use.
32 #include "gnunet_applications.h"
33 #include "gnunet_util_lib.h"
34 #include "gnunet_mesh_service.h"
35 #include "gnunet_stream_lib.h"
36 #include "gnunet_testbed_service.h"
44 * The testbed operation handle
46 struct GNUNET_TESTBED_Operation *op;
54 * The next pointer for DLL
56 struct DLLOperation *next;
59 * The prev pointer for DLL
61 struct DLLOperation *prev;
66 * Available states during profiling
78 STATE_SLAVES_STARTING,
101 * Matching strings against announced regexes
106 * Destroying peers; we can do this as the controller takes care of stopping a
107 * peer if it is running
109 STATE_PEERS_DESTROYING
114 * An array of hosts loaded from the hostkeys file
116 static struct GNUNET_TESTBED_Host **hosts;
129 * The actual testbed peer handle.
131 struct GNUNET_TESTBED_Peer *peer_handle;
134 * Host on which the peer is running.
136 struct GNUNET_TESTBED_Host *host_handle;
139 * Filename of the peer's policy file.
144 * Peers search string.
146 const char *search_str;
149 * Peer's mesh handle.
151 struct GNUNET_MESH_Handle *mesh_handle;
154 * Peer's mesh tunnel handle.
156 struct GNUNET_MESH_Tunnel *mesh_tunnel_handle;
159 * Testbed operation handle for the mesh service.
161 struct GNUNET_TESTBED_Operation *mesh_op_handle;
164 * Peers's statistics handle.
166 struct GNUNET_STATISTICS_Handle *stats_handle;
169 * Testbed operation handle for the statistics service.
171 struct GNUNET_TESTBED_Operation *stats_op_handle;
174 * The starting time of a profiling step.
176 struct GNUNET_TIME_Absolute prof_start_time;
180 * Array of peer handles used to pass to
181 * GNUNET_TESTBED_overlay_configure_topology
183 struct GNUNET_TESTBED_Peer **peer_handles;
186 * The array of peers; we fill this as the peers are given to us by the testbed
188 static struct RegexPeer *peers;
191 * Host registration handle
193 static struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
196 * Handle to the master controller process
198 struct GNUNET_TESTBED_ControllerProc *mc_proc;
201 * Handle to the master controller
203 struct GNUNET_TESTBED_Controller *mc;
206 * Handle to global configuration
208 struct GNUNET_CONFIGURATION_Handle *cfg;
211 * Head of the operations list
213 struct DLLOperation *dll_op_head;
216 * Tail of the operations list
218 struct DLLOperation *dll_op_tail;
221 * Peer linking - topology operation
223 struct GNUNET_TESTBED_Operation *topology_op;
226 * Abort task identifier
228 static GNUNET_SCHEDULER_TaskIdentifier abort_task;
231 * Host registration task identifier
233 static GNUNET_SCHEDULER_TaskIdentifier register_hosts_task;
236 * Global event mask for all testbed events
241 * The starting time of a profiling step
243 struct GNUNET_TIME_Absolute prof_start_time;
246 * Duration profiling step has taken
248 struct GNUNET_TIME_Relative prof_time;
253 unsigned int peer_id;
256 * Number of peers to be started by the profiler
258 static unsigned int num_peers;
261 * Number of hosts in the hosts array
263 static unsigned int num_hosts;
266 * Factor of number of links. num_links = num_peers * linking_factor.
268 static unsigned int linking_factor;
271 * Number of random links to be established between peers
273 static unsigned int num_links;
276 * Number of timeout failures to tolerate
278 static unsigned int num_cont_fails;
281 * Number of times we try overlay connect operations
283 static unsigned int retry_links;
286 * Continuous failures during overlay connect operations
288 static unsigned int cont_fails;
291 * Global testing status
296 * current state of profiling
301 * Folder where policy files are stored.
303 static char * policy_dir;
308 static char **search_strings;
311 * Number of search strings.
313 static int num_search_strings;
316 * Number of peers found with search strings.
318 static unsigned int peers_found;
321 * Search task identifier
323 static GNUNET_SCHEDULER_TaskIdentifier search_task;
326 * Search timeout task identifier.
328 static GNUNET_SCHEDULER_TaskIdentifier search_timeout_task;
331 * Search timeout in seconds.
333 static struct GNUNET_TIME_Relative search_timeout = { 60000 };
336 * How long do we wait before starting the search?
339 static struct GNUNET_TIME_Relative search_delay = { 60000 };
342 * Delay before setting mesh service op as done.
344 static struct GNUNET_TIME_Relative mesh_done_delay = { 1000 };
347 * Delay to wait before starting to configure the overlay topology
349 static struct GNUNET_TIME_Relative conf_topo_delay = { 10000 };
352 * File to log statistics to.
354 static struct GNUNET_DISK_FileHandle *data_file;
357 * Filename to log statistics to.
359 static char *data_filename;
362 * Maximal path compression length.
364 static unsigned int max_path_compression;
366 /******************************************************************************/
367 /****************************** DECLARATIONS ********************************/
368 /******************************************************************************/
372 * Method called whenever a peer has connected to the tunnel.
375 * @param peer_id peer identity the tunnel was created to, NULL on timeout
376 * @param atsi performance data for the connection
380 mesh_peer_connect_handler (void *cls,
381 const struct GNUNET_PeerIdentity* peer_id,
382 const struct GNUNET_ATS_Information * atsi);
386 * Method called whenever a peer has disconnected from the tunnel.
387 * Implementations of this callback must NOT call
388 * GNUNET_MESH_tunnel_destroy immediately, but instead schedule those
389 * to run in some other task later. However, calling
390 * "GNUNET_MESH_notify_transmit_ready_cancel" is allowed.
393 * @param peer_id peer identity the tunnel stopped working with
396 mesh_peer_disconnect_handler (void *cls,
397 const struct GNUNET_PeerIdentity * peer_id);
400 * Mesh connect callback.
402 * @param cls internal peer id.
403 * @param op operation handle.
404 * @param ca_result connect adapter result.
405 * @param emsg error message.
408 mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
409 void *ca_result, const char *emsg);
412 * Mesh connect adapter.
414 * @param cls not used.
415 * @param cfg configuration handle.
420 mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg);
424 * Adapter function called to destroy a connection to
428 * @param op_result service handle returned from the connect adapter
431 mesh_da (void *cls, void *op_result);
434 /******************************************************************************/
435 /******************************** SHUTDOWN **********************************/
436 /******************************************************************************/
443 * @param tc the task context
446 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
448 struct DLLOperation *dll_op;
450 unsigned int peer_cnt;
451 unsigned int search_str_cnt;
453 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++)
455 if (NULL != peers[peer_cnt].mesh_op_handle)
456 GNUNET_TESTBED_operation_done (peers[peer_cnt].mesh_op_handle);
457 if (NULL != peers[peer_cnt].stats_op_handle)
458 GNUNET_TESTBED_operation_done (peers[peer_cnt].stats_op_handle);
460 for (search_str_cnt = 0; search_str_cnt < num_search_strings; search_str_cnt++)
462 GNUNET_free (search_strings[search_str_cnt]);
464 GNUNET_free (search_strings);
465 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
466 GNUNET_SCHEDULER_cancel (abort_task);
467 if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task)
468 GNUNET_SCHEDULER_cancel (register_hosts_task);
469 if (NULL != reg_handle)
470 GNUNET_TESTBED_cancel_registration (reg_handle);
471 if (NULL != topology_op)
472 GNUNET_TESTBED_operation_done (topology_op);
473 for (nhost = 0; nhost < num_hosts; nhost++)
474 if (NULL != hosts[nhost])
475 GNUNET_TESTBED_host_destroy (hosts[nhost]);
476 GNUNET_free_non_null (hosts);
477 while (NULL != (dll_op = dll_op_head))
479 GNUNET_TESTBED_operation_done (dll_op->op);
480 GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op);
481 GNUNET_free (dll_op);
484 GNUNET_TESTBED_controller_disconnect (mc);
486 GNUNET_TESTBED_controller_stop (mc_proc);
488 GNUNET_CONFIGURATION_destroy (cfg);
489 if (NULL != data_file)
490 GNUNET_DISK_file_close (data_file);
492 GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */
497 * abort task to run on test timed out
500 * @param tc the task context
503 do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
505 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting\n");
506 abort_task = GNUNET_SCHEDULER_NO_TASK;
507 result = GNUNET_SYSERR;
508 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
512 /******************************************************************************/
513 /********************* STATISTICS SERVICE CONNECTIONS ***********************/
514 /******************************************************************************/
517 * Adapter function called to establish a connection to
518 * statistics service.
521 * @param cfg configuration of the peer to connect to; will be available until
522 * GNUNET_TESTBED_operation_done() is called on the operation returned
523 * from GNUNET_TESTBED_service_connect()
524 * @return service handle to return in 'op_result', NULL on error
527 stats_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
529 return GNUNET_STATISTICS_create ("<driver>", cfg);
534 * Adapter function called to destroy a connection to
535 * statistics service.
538 * @param op_result service handle returned from the connect adapter
541 stats_da (void *cls, void *op_result)
543 GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
548 * Process statistic values.
551 * @param subsystem name of subsystem that created the statistic
552 * @param name the name of the datum
553 * @param value the current value
554 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
555 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
558 stats_iterator (void *cls, const char *subsystem, const char *name,
559 uint64_t value, int is_persistent)
561 struct RegexPeer *peer = cls;
562 char output_buffer[512];
565 if (NULL == data_file)
567 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
568 "%p -> %s [%s]: %llu\n",
569 peer, subsystem, name, value);
573 GNUNET_snprintf (output_buffer,
574 sizeof (output_buffer),
577 subsystem, value, name);
578 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
579 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
589 * @param success GNUNET_OK if statistics were
590 * successfully obtained, GNUNET_SYSERR if not.
596 static unsigned int peer_cnt;
597 struct RegexPeer *peer = cls;
599 if (GNUNET_OK != success)
601 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
602 "Getting statistics for peer %u failed!\n",
607 GNUNET_TESTBED_operation_done (peer->stats_op_handle);
608 peer->stats_op_handle = NULL;
610 if (++peer_cnt == num_search_strings)
612 struct GNUNET_TIME_Relative delay = { 100 };
613 GNUNET_SCHEDULER_add_delayed (delay, &do_shutdown, NULL);
619 * Function called by testbed once we are connected to stats service.
621 * @param cls the 'struct RegexPeer' for which we connected to stats
622 * @param op connect operation handle
623 * @param ca_result handle to stats service
624 * @param emsg error message on failure
627 stats_connect_cb (void *cls,
628 struct GNUNET_TESTBED_Operation *op,
632 struct RegexPeer *peer = cls;
634 if (NULL == ca_result || NULL != emsg)
636 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
637 "Failed to connect to statistics service on peer %u: %s\n",
640 peer->stats_handle = NULL;
644 GNUNET_assert (NULL != peer->mesh_handle);
646 peer->stats_handle = ca_result;
648 peer->mesh_tunnel_handle = GNUNET_MESH_tunnel_create (peer->mesh_handle,
650 &mesh_peer_connect_handler,
651 &mesh_peer_disconnect_handler,
654 peer->prof_start_time = GNUNET_TIME_absolute_get ();
656 GNUNET_MESH_peer_request_connect_by_string (peer->mesh_tunnel_handle,
661 /******************************************************************************/
662 /************************ MESH SERVICE CONNECTIONS **************************/
663 /******************************************************************************/
666 * Method called whenever another peer has added us to a tunnel
667 * the other peer initiated.
668 * Only called (once) upon reception of data with a message type which was
669 * subscribed to in GNUNET_MESH_connect. A call to GNUNET_MESH_tunnel_destroy
670 * causes te tunnel to be ignored and no further notifications are sent about
674 * @param tunnel new handle to the tunnel
675 * @param initiator peer that started the tunnel
676 * @param atsi performance information for the tunnel
677 * @return initial tunnel context for the tunnel
678 * (can be NULL -- that's not an error)
681 mesh_inbound_tunnel_handler (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
682 const struct GNUNET_PeerIdentity *initiator,
683 const struct GNUNET_ATS_Information *atsi)
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh inbound tunnel handler.\n");
692 * Function called whenever an inbound tunnel is destroyed. Should clean up
693 * any associated state. This function is NOT called if the client has
694 * explicitly asked for the tunnel to be destroyed using
695 * GNUNET_MESH_tunnel_destroy. It must NOT call GNUNET_MESH_tunnel_destroy on
698 * @param cls closure (set from GNUNET_MESH_connect)
699 * @param tunnel connection to the other end (henceforth invalid)
700 * @param tunnel_ctx place where local state associated
701 * with the tunnel is stored
704 mesh_tunnel_end_handler (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh tunnel end handler.\n");
712 * Method called whenever a peer has disconnected from the tunnel.
713 * Implementations of this callback must NOT call
714 * GNUNET_MESH_tunnel_destroy immediately, but instead schedule those
715 * to run in some other task later. However, calling
716 * "GNUNET_MESH_notify_transmit_ready_cancel" is allowed.
719 * @param peer_id peer identity the tunnel stopped working with
722 mesh_peer_disconnect_handler (void *cls,
723 const struct GNUNET_PeerIdentity * peer_id)
725 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh peer disconnect handler.\n");
730 * Method called whenever a peer has connected to the tunnel.
733 * @param peer_id peer identity the tunnel was created to, NULL on timeout
734 * @param atsi performance data for the connection
738 mesh_peer_connect_handler (void *cls,
739 const struct GNUNET_PeerIdentity* peer_id,
740 const struct GNUNET_ATS_Information * atsi)
742 struct RegexPeer *peer = cls;
743 char output_buffer[512];
750 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
751 "String matching timed out for string %s on peer %u (%i/%i)\n",
752 peer->search_str, peer->id, peers_found, num_search_strings);
754 printf ("String matching timed out for string %s on peer %u (%i/%i)\n",
755 peer->search_str, peer->id, peers_found, num_search_strings);
759 prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time);
760 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
761 "String %s successfully matched on peer %u after %s (%i/%i)\n",
762 peer->search_str, peer->id, GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
763 peers_found, num_search_strings);
765 printf ("String %s successfully matched on peer %u after %s (%i/%i)\n",
766 peer->search_str, peer->id, GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
767 peers_found, num_search_strings);
770 if (NULL != data_file)
773 GNUNET_snprintf (output_buffer,
774 sizeof (output_buffer),
775 "Peer: %u (%p)\nHost: %s\nPolicy file: %s\nSearch string: %s\nSearch duration: %s\n\n",
778 GNUNET_TESTBED_host_get_hostname (peer->host_handle),
781 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
783 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
784 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
787 if (NULL == peer->stats_handle)
789 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
790 "Cannot get statistics for peer %u, stats handle is NULL!\n");
794 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, "mesh", NULL,
795 GNUNET_TIME_UNIT_FOREVER_REL,
797 &stats_iterator, peer))
799 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
800 "Could not get mesh statistics of peer %u!\n", peer->id);
802 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, "transport", NULL,
803 GNUNET_TIME_UNIT_FOREVER_REL,
805 &stats_iterator, peer))
807 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
808 "Could not get transport statistics of peer %u!\n", peer->id);
810 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, "dht", NULL,
811 GNUNET_TIME_UNIT_FOREVER_REL,
813 &stats_iterator, peer))
815 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
816 "Could not get dht statistics of peer %u!\n", peer->id);
820 if (peers_found == num_search_strings)
822 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
823 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
824 "All strings successfully matched in %s\n",
825 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
826 printf ("All strings successfully matched. Shutting down.\n");
829 if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
830 GNUNET_SCHEDULER_cancel (search_timeout_task);
836 * Connect by string timeout task
839 * @param tc the task context
842 do_connect_by_string_timeout (void *cls,
843 const struct GNUNET_SCHEDULER_TaskContext * tc)
845 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
846 "Finding matches to all strings did not succeed after %s.\n",
847 GNUNET_STRINGS_relative_time_to_string (search_timeout, GNUNET_NO));
848 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
849 "Found %i of %i strings\n", peers_found, num_search_strings);
851 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
856 * Connect by string task that is run to search for a string in the NFA
859 * @param tc the task context
862 do_connect_by_string (void *cls,
863 const struct GNUNET_SCHEDULER_TaskContext * tc)
865 unsigned int search_cnt;
866 struct RegexPeer *peer;
868 printf ("Starting string search.\n");
871 for (search_cnt = 0; search_cnt < num_search_strings; search_cnt++)
873 peer = &peers[search_cnt % num_peers];
874 peer->search_str = search_strings[search_cnt];
876 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
877 "Searching for string \"%s\" on peer %d with file %s\n",
878 peer->search_str, (search_cnt % num_peers), peer->policy_file);
880 /* First connect to mesh service, then connect to stats service
881 and then try connecting by string in stats_connect_cb */
882 peer->mesh_op_handle =
883 GNUNET_TESTBED_service_connect (NULL,
893 search_timeout_task = GNUNET_SCHEDULER_add_delayed (search_timeout,
894 &do_connect_by_string_timeout, NULL);
899 * Delayed operation done for mesh service disconnects.
902 * @param tc the task context
905 do_mesh_op_done (void *cls,
906 const struct GNUNET_SCHEDULER_TaskContext * tc)
908 struct RegexPeer *peer = cls;
909 static unsigned int peer_cnt;
910 GNUNET_TESTBED_operation_done (peer->mesh_op_handle);
911 peer->mesh_op_handle = NULL;
913 if (++peer_cnt < num_peers)
915 peers[peer_cnt].mesh_op_handle =
916 GNUNET_TESTBED_service_connect (NULL,
917 peers[peer_cnt].peer_handle,
929 * Mesh connect callback.
931 * @param cls internal peer id.
932 * @param op operation handle.
933 * @param ca_result connect adapter result.
934 * @param emsg error message.
937 mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
938 void *ca_result, const char *emsg)
940 struct RegexPeer *peer = (struct RegexPeer *) cls;
947 if (NULL != emsg || NULL == op || NULL == ca_result)
949 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Mesh connect failed: %s\n", emsg);
953 GNUNET_assert (peer->mesh_handle != NULL);
954 GNUNET_assert (peer->mesh_op_handle == op);
955 GNUNET_assert (peer->mesh_handle == ca_result);
956 GNUNET_assert (NULL != peer->policy_file);
960 case STATE_ANNOUNCE_REGEX:
962 static unsigned int num_files_announced;
964 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
965 "Announcing regexes for peer %u with file %s\n",
966 peer->id, peer->policy_file);
968 if (GNUNET_YES != GNUNET_DISK_file_test (peer->policy_file))
970 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
971 "Could not find policy file %s\n", peer->policy_file);
974 if (GNUNET_OK != GNUNET_DISK_file_size (peer->policy_file, &filesize, GNUNET_YES, GNUNET_YES))
978 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Policy file %s is empty.\n", peer->policy_file);
981 data = GNUNET_malloc (filesize);
982 if (filesize != GNUNET_DISK_fn_read (peer->policy_file, data, filesize))
985 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not read policy file %s.\n",
992 while (offset < (filesize - 1))
995 if (((data[offset] == '\n')) && (buf != &data[offset]))
999 GNUNET_assert (NULL != regex);
1000 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing regex: %s on peer %u \n",
1002 GNUNET_MESH_announce_regex (peer->mesh_handle, regex, max_path_compression);
1003 buf = &data[offset + 1];
1005 else if ((data[offset] == '\n') || (data[offset] == '\0'))
1006 buf = &data[offset + 1];
1010 GNUNET_SCHEDULER_add_delayed (mesh_done_delay, &do_mesh_op_done, peer);
1012 if (++num_files_announced == num_peers)
1014 state = STATE_SEARCH_REGEX;
1016 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
1018 printf ("All files announced in %s.\n",
1019 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
1020 printf ("Waiting %s before starting to search.\n",
1021 GNUNET_STRINGS_relative_time_to_string (search_delay, GNUNET_YES));
1024 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1025 "All regexes announced in %s. Waiting %s before starting to search.\n",
1026 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
1027 GNUNET_STRINGS_relative_time_to_string (search_delay, GNUNET_NO));
1029 search_task = GNUNET_SCHEDULER_add_delayed (search_delay,
1030 &do_connect_by_string, NULL);
1034 case STATE_SEARCH_REGEX:
1036 /* First connect to the stats service, then start to search */
1037 peer->stats_op_handle =
1038 GNUNET_TESTBED_service_connect (NULL,
1055 * Mesh connect adapter.
1057 * @param cls not used.
1058 * @param cfg configuration handle.
1063 mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
1065 GNUNET_MESH_ApplicationType app;
1066 struct RegexPeer *peer = cls;
1068 static struct GNUNET_MESH_MessageHandler handlers[] = {
1072 app = (GNUNET_MESH_ApplicationType)0;
1075 GNUNET_MESH_connect (cfg, cls, NULL, NULL, handlers, &app);
1077 return peer->mesh_handle;
1082 * Adapter function called to destroy a connection to
1085 * @param cls closure
1086 * @param op_result service handle returned from the connect adapter
1089 mesh_da (void *cls, void *op_result)
1091 struct RegexPeer *peer = (struct RegexPeer *) cls;
1093 GNUNET_assert (peer->mesh_handle == op_result);
1095 if (NULL != peer->mesh_tunnel_handle)
1097 GNUNET_MESH_tunnel_destroy (peer->mesh_tunnel_handle);
1098 peer->mesh_tunnel_handle = NULL;
1101 if (NULL != peer->mesh_handle)
1103 GNUNET_MESH_disconnect (peer->mesh_handle);
1104 peer->mesh_handle = NULL;
1109 /******************************************************************************/
1110 /*************************** TESTBED PEER SETUP *****************************/
1111 /******************************************************************************/
1115 * Configure the peer overlay topology.
1118 * @param tc the task context
1121 do_configure_topology (void *cls,
1122 const struct GNUNET_SCHEDULER_TaskContext * tc)
1125 if (0 == linking_factor)
1127 num_links = linking_factor * num_peers;
1129 /* num_links = num_peers - 1; */
1130 num_links = linking_factor;
1132 /* Do overlay connect */
1133 prof_start_time = GNUNET_TIME_absolute_get ();
1135 GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peer_handles,
1136 GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
1138 GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY,
1139 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
1140 if (NULL == topology_op)
1142 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1143 "Cannot create topology, op handle was NULL\n");
1150 * Functions of this signature are called when a peer has been successfully
1151 * started or stopped.
1153 * @param cls the closure from GNUNET_TESTBED_peer_start/stop()
1154 * @param emsg NULL on success; otherwise an error description
1157 peer_churn_cb (void *cls, const char *emsg)
1159 struct DLLOperation *dll_op = cls;
1160 struct GNUNET_TESTBED_Operation *op;
1161 static unsigned int started_peers;
1162 unsigned int peer_cnt;
1165 GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op);
1166 GNUNET_free (dll_op);
1169 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1170 _("An operation has failed while starting peers\n"));
1171 GNUNET_TESTBED_operation_done (op);
1172 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
1173 GNUNET_SCHEDULER_cancel (abort_task);
1174 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
1177 GNUNET_TESTBED_operation_done (op);
1178 if (++started_peers == num_peers)
1180 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
1181 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1182 "All peers started successfully in %s\n",
1183 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
1186 peer_handles = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * num_peers);
1187 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++)
1188 peer_handles[peer_cnt] = peers[peer_cnt].peer_handle;
1190 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1191 "Waiting %s before starting to link peers\n",
1192 GNUNET_STRINGS_relative_time_to_string (conf_topo_delay, GNUNET_YES));
1194 printf ("Waiting %s before starting to link peers\n",
1195 GNUNET_STRINGS_relative_time_to_string (conf_topo_delay, GNUNET_YES));
1198 state = STATE_PEERS_LINKING;
1199 GNUNET_SCHEDULER_add_delayed (conf_topo_delay, &do_configure_topology, NULL);
1205 * Functions of this signature are called when a peer has been successfully
1208 * @param cls the closure from GNUNET_TESTBED_peer_create()
1209 * @param peer the handle for the created peer; NULL on any error during
1211 * @param emsg NULL if peer is not NULL; else MAY contain the error description
1214 peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
1216 struct DLLOperation *dll_op = cls;
1217 struct RegexPeer *peer_ptr;
1218 static unsigned int created_peers;
1219 unsigned int peer_cnt;
1223 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1224 _("Creating a peer failed. Error: %s\n"), emsg);
1225 GNUNET_TESTBED_operation_done (dll_op->op);
1226 GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op);
1227 GNUNET_free (dll_op);
1228 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
1229 GNUNET_SCHEDULER_cancel (abort_task);
1230 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
1234 peer_ptr = dll_op->cls;
1235 GNUNET_assert (NULL == peer_ptr->peer_handle);
1236 peer_ptr->peer_handle = peer;
1237 GNUNET_TESTBED_operation_done (dll_op->op);
1238 GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op);
1239 GNUNET_free (dll_op);
1241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %i created on host %s\n",
1243 GNUNET_TESTBED_host_get_hostname (peer_ptr->host_handle));
1245 if (++created_peers == num_peers)
1247 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
1248 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1249 "All peers created successfully in %s\n",
1250 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
1251 /* Now peers are to be started */
1252 state = STATE_PEERS_STARTING;
1253 prof_start_time = GNUNET_TIME_absolute_get ();
1254 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++)
1256 dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
1257 dll_op->op = GNUNET_TESTBED_peer_start (dll_op, peers[peer_cnt].peer_handle,
1258 &peer_churn_cb, dll_op);
1259 GNUNET_CONTAINER_DLL_insert_tail (dll_op_head, dll_op_tail, dll_op);
1265 * Function called with a filename.
1267 * @param cls closure
1268 * @param filename complete filename (absolute path)
1269 * @return GNUNET_OK to continue to iterate,
1270 * GNUNET_SYSERR to abort iteration with error!
1273 policy_filename_cb (void *cls, const char *filename)
1275 static unsigned int peer_cnt;
1276 struct DLLOperation *dll_op;
1277 struct RegexPeer *peer = &peers[peer_cnt];
1279 GNUNET_assert (NULL != peer);
1281 peer->id = peer_cnt;
1282 peer->policy_file = GNUNET_strdup (filename);
1283 /* Do not start peers on hosts[0] (master controller) */
1284 peer->host_handle = hosts[1 + (peer_cnt % (num_hosts -1))];
1285 peer->mesh_handle = NULL;
1286 peer->mesh_tunnel_handle = NULL;
1287 peer->stats_handle = NULL;
1288 peer->stats_op_handle = NULL;
1290 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Creating peer %i on host %s for policy file %s\n",
1292 GNUNET_TESTBED_host_get_hostname (peer->host_handle),
1295 dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
1296 dll_op->cls = &peers[peer_cnt];
1297 dll_op->op = GNUNET_TESTBED_peer_create (mc,
1302 GNUNET_CONTAINER_DLL_insert_tail (dll_op_head, dll_op_tail, dll_op);
1310 * Controller event callback.
1313 * @param event the controller event
1316 controller_event_cb (void *cls,
1317 const struct GNUNET_TESTBED_EventInformation *event)
1319 struct DLLOperation *dll_op;
1320 struct GNUNET_TESTBED_Operation *op;
1324 case STATE_SLAVES_STARTING:
1325 switch (event->type)
1327 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
1329 static unsigned int slaves_started;
1331 dll_op = event->details.operation_finished.op_cls;
1332 GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op);
1333 GNUNET_free (dll_op);
1334 op = event->details.operation_finished.operation;
1335 if (NULL != event->details.operation_finished.emsg)
1337 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1338 _("An operation has failed while starting slaves\n"));
1339 GNUNET_TESTBED_operation_done (op);
1340 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
1341 GNUNET_SCHEDULER_cancel (abort_task);
1342 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
1345 GNUNET_TESTBED_operation_done (op);
1346 /* Proceed to start peers */
1347 if (++slaves_started == num_hosts - 1)
1349 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1350 "All slaves started successfully\n");
1352 state = STATE_PEERS_CREATING;
1353 prof_start_time = GNUNET_TIME_absolute_get ();
1355 num_peers = GNUNET_DISK_directory_scan (policy_dir,
1358 peers = GNUNET_malloc (sizeof (struct RegexPeer) * num_peers);
1360 GNUNET_DISK_directory_scan (policy_dir,
1361 &policy_filename_cb,
1370 case STATE_PEERS_STARTING:
1371 switch (event->type)
1373 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
1374 /* Control reaches here when peer start fails */
1375 case GNUNET_TESTBED_ET_PEER_START:
1376 /* we handle peer starts in peer_churn_cb */
1382 case STATE_PEERS_LINKING:
1383 switch (event->type)
1385 static unsigned int established_links;
1386 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
1387 /* Control reaches here when a peer linking operation fails */
1388 if (NULL != event->details.operation_finished.emsg)
1390 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1391 _("An operation has failed while linking\n"));
1396 if (++cont_fails > num_cont_fails)
1398 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1399 "We have a very high peer linking failure rate: %u (threshold: %u)\n",
1404 /* We do no retries, consider this link as established */
1406 case GNUNET_TESTBED_ET_CONNECT:
1408 char output_buffer[512];
1411 if (0 == established_links)
1412 printf ("Establishing links .");
1418 if (++established_links == num_links)
1421 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
1422 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1423 "%u links established in %s\n",
1425 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
1427 GNUNET_free (peer_handles);
1429 if (NULL != data_file)
1432 GNUNET_snprintf (output_buffer,
1433 sizeof (output_buffer),
1434 "# of peers: %u\n# of links established: %u\n"
1435 "Time to establish links: %s\nLinking failures: %u\n"
1436 "path compression length: %u\n# of search strings: %u\n",
1438 (established_links - cont_fails),
1439 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
1441 max_path_compression,
1442 num_search_strings);
1444 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
1445 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
1448 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1449 "Connecting to mesh service and start announcing regex...\n");
1450 printf ("\nStarting to connect to mesh services and announce regex\n");
1453 prof_start_time = GNUNET_TIME_absolute_get ();
1454 peers[0].mesh_op_handle =
1455 GNUNET_TESTBED_service_connect (NULL,
1456 peers[0].peer_handle,
1463 state = STATE_ANNOUNCE_REGEX;
1471 case STATE_ANNOUNCE_REGEX:
1473 /* Handled in service connect callback */
1476 case STATE_SEARCH_REGEX:
1478 /* Handled in service connect callback */
1484 case STATE_PEERS_CREATING:
1485 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create peer\n");
1488 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1489 "Unexpected controller_cb with state %i!\n", state);
1497 * Task to register all hosts available in the global host list
1500 * @param tc the scheduler task context
1503 register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
1507 * Callback which will be called to after a host registration succeeded or failed
1509 * @param cls the closure
1510 * @param emsg the error message; NULL if host registration is successful
1513 host_registration_completion (void *cls, const char *emsg)
1518 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1519 _("Host registration failed for a host. Error: %s\n"), emsg);
1520 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
1521 GNUNET_SCHEDULER_cancel (abort_task);
1522 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
1525 register_hosts_task = GNUNET_SCHEDULER_add_now (®ister_hosts, NULL);
1530 * Task to register all hosts available in the global host list
1533 * @param tc the scheduler task context
1536 register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1538 struct DLLOperation *dll_op;
1539 static unsigned int reg_host;
1542 register_hosts_task = GNUNET_SCHEDULER_NO_TASK;
1543 if (reg_host == num_hosts - 1)
1545 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1546 "All hosts successfully registered\n");
1548 state = STATE_SLAVES_STARTING;
1549 for (slave = 1; slave < num_hosts; slave++)
1551 dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
1552 dll_op->op = GNUNET_TESTBED_controller_link (dll_op,
1558 GNUNET_CONTAINER_DLL_insert_tail (dll_op_head, dll_op_tail, dll_op);
1562 reg_handle = GNUNET_TESTBED_register_host (mc, hosts[++reg_host],
1563 host_registration_completion,
1569 * Callback to signal successfull startup of the controller process
1571 * @param cls the closure from GNUNET_TESTBED_controller_start()
1572 * @param config the configuration with which the controller has been started;
1573 * NULL if status is not GNUNET_OK
1574 * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
1575 * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
1578 status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int status)
1580 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
1581 GNUNET_SCHEDULER_cancel (abort_task);
1582 if (GNUNET_OK != status)
1585 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
1589 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
1590 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
1591 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
1592 event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
1593 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
1594 mc = GNUNET_TESTBED_controller_connect (config, hosts[0], event_mask,
1595 &controller_event_cb, NULL);
1598 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1599 _("Unable to connect to master controller -- Check config\n"));
1600 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
1603 register_hosts_task = GNUNET_SCHEDULER_add_now (®ister_hosts, NULL);
1604 abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1610 * Load search strings from given filename. One search string per line.
1612 * @param filename filename of the file containing the search strings.
1613 * @param strings set of strings loaded from file. Caller needs to free this
1614 * if number returned is greater than zero.
1615 * @param limit upper limit on the number of strings read from the file
1616 * @return number of strings found in the file. GNUNET_SYSERR on error.
1619 load_search_strings (const char *filename, char ***strings, unsigned int limit)
1624 unsigned int offset;
1628 if (NULL == filename)
1630 return GNUNET_SYSERR;
1633 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
1635 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1636 "Could not find search strings file %s\n", filename);
1637 return GNUNET_SYSERR;
1639 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &filesize, GNUNET_YES, GNUNET_YES))
1643 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Search strings file %s is empty.\n", filename);
1644 return GNUNET_SYSERR;
1646 data = GNUNET_malloc (filesize);
1647 if (filesize != GNUNET_DISK_fn_read (filename, data, filesize))
1650 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not read search strings file %s.\n",
1652 return GNUNET_SYSERR;
1657 while (offset < (filesize - 1) && str_cnt < limit)
1660 if (((data[offset] == '\n')) && (buf != &data[offset]))
1662 data[offset] = '\0';
1664 buf = &data[offset + 1];
1666 else if ((data[offset] == '\n') || (data[offset] == '\0'))
1667 buf = &data[offset + 1];
1669 *strings = GNUNET_malloc (sizeof (char *) * str_cnt);
1671 for (i = 0; i < str_cnt; i++)
1673 (*strings)[i] = GNUNET_strdup (&data[offset]);
1674 offset += strlen ((*strings)[i]) + 1;
1682 * Main function that will be run by the scheduler.
1684 * @param cls closure
1685 * @param args remaining command-line arguments
1686 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
1687 * @param config configuration
1690 run (void *cls, char *const *args, const char *cfgfile,
1691 const struct GNUNET_CONFIGURATION_Handle *config)
1695 if (NULL == args[0])
1697 fprintf (stderr, _("No hosts-file specified on command line. Exiting.\n"));
1700 if (NULL == args[1])
1702 fprintf (stderr, _("No policy directory specified on command line. Exiting.\n"));
1705 num_hosts = GNUNET_TESTBED_hosts_load_from_file (args[0], &hosts);
1708 fprintf (stderr, _("No hosts loaded. Need at least one host\n"));
1711 for (nhost = 0; nhost < num_hosts; nhost++)
1713 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], config))
1715 fprintf (stderr, _("Host %s cannot start testbed\n"),
1716 GNUNET_TESTBED_host_get_hostname (hosts[nhost]));
1720 if (num_hosts != nhost)
1722 fprintf (stderr, _("Exiting\n"));
1723 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1728 fprintf (stderr, _("No configuration file given. Exiting\n"));
1729 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1732 if ( (NULL != data_filename) &&
1733 (NULL == (data_file =
1734 GNUNET_DISK_file_open (data_filename,
1735 GNUNET_DISK_OPEN_READWRITE |
1736 GNUNET_DISK_OPEN_TRUNCATE |
1737 GNUNET_DISK_OPEN_CREATE,
1738 GNUNET_DISK_PERM_USER_READ |
1739 GNUNET_DISK_PERM_USER_WRITE))) )
1740 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
1743 if (GNUNET_YES != GNUNET_DISK_directory_test (args[1]))
1745 fprintf (stderr, _("Specified policies directory does not exist. Exiting.\n"));
1746 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1749 policy_dir = args[1];
1750 if (GNUNET_YES != GNUNET_DISK_file_test (args[2]))
1752 fprintf (stderr, _("No search strings file given. Exiting.\n"));
1753 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1756 if (num_search_strings != load_search_strings (args[2], &search_strings, num_search_strings))
1758 fprintf (stderr, _("Error loading search strings. Given file does not contain enough strings. Exiting.\n"));
1759 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1762 if (0 >= num_search_strings || NULL == search_strings)
1764 fprintf (stderr, _("Error loading search strings. Exiting.\n"));
1765 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1769 for (i = 0; i < num_search_strings; i++)
1770 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "search string: %s\n", search_strings[i]);
1771 cfg = GNUNET_CONFIGURATION_dup (config);
1773 GNUNET_TESTBED_controller_start (GNUNET_TESTBED_host_get_hostname
1780 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
1781 (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort,
1789 * @param argc argument count
1790 * @param argv argument values
1791 * @return 0 on success
1794 main (int argc, char *const *argv)
1796 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
1797 {'d', "details", "FILENAME",
1798 gettext_noop ("name of the file for writing statistics"),
1799 1, &GNUNET_GETOPT_set_string, &data_filename},
1800 {'n', "linking-factor", "FACTOR",
1801 gettext_noop ("create FACTOR times number of peers random links"),
1802 GNUNET_YES, &GNUNET_GETOPT_set_uint, &linking_factor },
1803 {'e', "num-errors", "COUNT",
1804 gettext_noop ("tolerate COUNT number of continious timeout failures"),
1805 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails },
1806 {'t', "matching-timeout", "TIMEOUT",
1807 gettext_noop ("wait TIMEOUT before considering a string match as failed"),
1808 GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_timeout },
1809 {'s', "search-delay", "DELAY",
1810 gettext_noop ("wait DELAY before starting string search"),
1811 GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_delay },
1812 {'a', "num-search-strings", "COUNT",
1813 gettext_noop ("number of search strings to read from search strings file"),
1814 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_search_strings },
1815 {'p', "max-path-compression", "MAX_PATH_COMPRESSION",
1816 gettext_noop ("maximum path compression length"),
1817 1, &GNUNET_GETOPT_set_uint, &max_path_compression},
1818 GNUNET_GETOPT_OPTION_END
1822 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1825 result = GNUNET_SYSERR;
1827 GNUNET_PROGRAM_run (argc, argv, "gnunet-regex-profiler [OPTIONS] hosts-file policy-dir search-strings-file",
1828 _("Profiler for regex/mesh"),
1829 options, &run, NULL);
1830 if (GNUNET_OK != ret)
1832 if (GNUNET_OK != result)