GNUnet debian-0.24.3-29-g453fda2cf
 
Loading...
Searching...
No Matches
gnunet-regex-profiler.c File Reference

Regex profiler for testing distributed regex use. More...

#include "platform.h"
#include "gnunet_applications.h"
#include "gnunet_util_lib.h"
#include "regex_internal_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_dht_service.h"
#include "gnunet_testbed_service.h"
Include dependency graph for gnunet-regex-profiler.c:

Go to the source code of this file.

Data Structures

struct  DLLOperation
 DLL of operations. More...
 
struct  RegexPeer
 Peer handles. More...
 

Macros

#define FIND_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90)
 

Enumerations

enum  State {
  STATE_INIT = 0 , STATE_SLAVES_STARTING , STATE_PEERS_CREATING , STATE_PEERS_STARTING ,
  STATE_PEERS_LINKING , STATE_SEARCH_REGEX , STATE_PEERS_DESTROYING
}
 Available states during profiling. More...
 

Functions

static void dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 DHT connect callback.
 
static void * dht_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 DHT connect adapter.
 
static void dht_da (void *cls, void *op_result)
 Adapter function called to destroy a connection to the DHT service.
 
static void stats_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 Function called by testbed once we are connected to stats service.
 
static void announce_next_regex (void *cls)
 Start announcing the next regex in the DHT.
 
static void do_shutdown (void *cls)
 Shutdown nicely.
 
static void do_abort (void *cls)
 abort task to run on test timed out
 
static void * stats_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Adapter function called to establish a connection to statistics service.
 
static void stats_da (void *cls, void *op_result)
 Adapter function called to destroy a connection to statistics service.
 
static int stats_iterator (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Process statistic values.
 
static void stats_cb (void *cls, int success)
 Stats callback.
 
static void do_collect_stats (void *cls)
 Task to collect all statistics from all peers, will shutdown the profiler, when done.
 
static void find_string (void *cls)
 Start searching for the next string in the DHT.
 
static void regex_found_handler (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length)
 Method called when we've found a peer that announced a regex that matches our search string.
 
static void search_timed_out (void *cls)
 Connect by string timeout task.
 
static void find_timed_out (void *cls)
 Search timed out.
 
static void daemon_started (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 Callback called when testbed has started the daemon we asked for.
 
static void do_announce (void *cls)
 Task to start the daemons on each peer so that the regexes are announced into the DHT.
 
static void test_master (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers_, struct GNUNET_TESTBED_Peer **testbed_peers, unsigned int links_succeeded, unsigned int links_failed)
 Signature of a main function for a testcase.
 
static void master_controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Function that will be called whenever something in the testbed changes.
 
static int count_and_separate_strings (char *data, uint64_t data_size, unsigned int str_max)
 Process the text buffer counting the non-empty lines and separating them with NULL characters, for later ease of copy using (as)printf.
 
static int create_string_array (char *data, uint64_t data_size, char ***strings, unsigned int str_cnt)
 Allocate a string array and fill it with the prefixed strings from a pre-processed, NULL-separated memory region.
 
static int load_search_strings (const char *filename, char ***strings, unsigned int limit)
 Load search strings from given filename.
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
 Main function that will be run by the scheduler.
 
int main (int argc, char *const *argv)
 Main function.
 

Variables

static int in_shutdown
 Set when shutting down to avoid making more queries.
 
static struct RegexPeerpeers
 The array of peers; we fill this as the peers are given to us by the testbed.
 
static struct GNUNET_TESTBED_HostRegistrationHandle * reg_handle
 Host registration handle.
 
static struct GNUNET_TESTBED_ControllerProc * mc_proc
 Handle to the master controller process.
 
static struct GNUNET_TESTBED_Controller * mc
 Handle to the master controller.
 
static struct GNUNET_CONFIGURATION_Handlecfg
 Handle to global configuration.
 
static struct GNUNET_SCHEDULER_Taskabort_task
 Abort task identifier.
 
static struct GNUNET_SCHEDULER_Taskregister_hosts_task
 Host registration task identifier.
 
static uint64_t event_mask
 Global event mask for all testbed events.
 
static struct GNUNET_TIME_Absolute prof_start_time
 The starting time of a profiling step.
 
static struct GNUNET_TIME_Relative prof_time
 Duration profiling step has taken.
 
static unsigned int num_peers
 Number of peers to be started by the profiler.
 
static int result
 Global testing status.
 
enum State state
 current state of profiling
 
static char * policy_dir
 Folder where policy files are stored.
 
static char * hosts_file
 File with hostnames where to execute the test.
 
static char * strings_file
 File with the strings to look for.
 
static char ** search_strings
 Search strings (num_peers of them).
 
static long long unsigned int init_parallel_searches
 How many searches are we going to start in parallel.
 
static unsigned int parallel_searches
 How many searches are running in parallel.
 
static unsigned int strings_found
 Number of strings found in the published regexes.
 
static unsigned int next_search
 Index of peer to start next announce/search.
 
static struct GNUNET_SCHEDULER_Tasksearch_timeout_task
 Search timeout task identifier.
 
static struct GNUNET_TIME_Relative search_timeout_time = { 60000 }
 Search timeout in seconds.
 
static struct GNUNET_DISK_FileHandledata_file
 File to log statistics to.
 
static char * data_filename
 Filename to log statistics to.
 
static char * regex_prefix
 Prefix used for regex announcing.
 
static struct GNUNET_TIME_Relative reannounce_period_max
 What's the maximum regex reannounce period.
 

Detailed Description

Regex profiler for testing distributed regex use.

Author
Bartlomiej Polot
Maximilian Szengel

Definition in file gnunet-regex-profiler.c.

Macro Definition Documentation

◆ FIND_TIMEOUT

#define FIND_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90)

Definition at line 35 of file gnunet-regex-profiler.c.

41{
45 struct GNUNET_TESTBED_Operation *op;
46
50 void *cls;
51
55 struct DLLOperation *next;
56
60 struct DLLOperation *prev;
61};
62
63
67enum State
68{
72 STATE_INIT = 0,
73
78
83
88
93
98
104};
105
106
110struct RegexPeer
111{
115 unsigned int id;
116
121
125 struct GNUNET_TESTBED_Peer *peer_handle;
126
130 const char *search_str;
131
139
144
149
153 struct GNUNET_TESTBED_Operation *op_handle;
154
159
164
169
173 struct GNUNET_TESTBED_Operation *daemon_op;
174};
175
179static int in_shutdown;
180
184static struct RegexPeer *peers;
185
189static struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
190
194static struct GNUNET_TESTBED_ControllerProc *mc_proc;
195
199static struct GNUNET_TESTBED_Controller *mc;
200
204static struct GNUNET_CONFIGURATION_Handle *cfg;
205
209static struct GNUNET_SCHEDULER_Task *abort_task;
210
215
219static uint64_t event_mask;
220
225
229static struct GNUNET_TIME_Relative prof_time;
230
234static unsigned int num_peers;
235
239static int result;
240
244enum State state;
245
249static char *policy_dir;
250
254static char *hosts_file;
255
259static char *strings_file;
260
264static char **search_strings;
265
269static long long unsigned int init_parallel_searches;
270
274static unsigned int parallel_searches;
275
279static unsigned int strings_found;
280
284static unsigned int next_search;
285
290
294static struct GNUNET_TIME_Relative search_timeout_time = { 60000 };
295
299static struct GNUNET_DISK_FileHandle *data_file;
300
304static char *data_filename;
305
310static char *regex_prefix;
311
316
317
318/******************************************************************************/
319/****************************** DECLARATIONS ********************************/
320/******************************************************************************/
321
332static void
333dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
334 void *ca_result, const char *emsg);
335
344static void *
345dht_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg);
346
347
355static void
356dht_da (void *cls, void *op_result);
357
358
368static void
369stats_connect_cb (void *cls,
370 struct GNUNET_TESTBED_Operation *op,
371 void *ca_result,
372 const char *emsg);
373
374
380static void
381announce_next_regex (void *cls);
382
383
384/******************************************************************************/
385/******************************** SHUTDOWN **********************************/
386/******************************************************************************/
387
388
394static void
395do_shutdown (void *cls)
396{
397 struct RegexPeer *peer;
398 unsigned int peer_cnt;
399 unsigned int search_str_cnt;
400 char output_buffer[512];
401 size_t size;
402
403 if (NULL != abort_task)
404 {
406 abort_task = NULL;
407 }
408 if (NULL != register_hosts_task)
409 {
411 register_hosts_task = NULL;
412 }
413 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++)
414 {
415 peer = &peers[peer_cnt];
416
417 if ((GNUNET_YES != peer->search_str_matched) && (NULL != data_file) )
418 {
420 size =
421 GNUNET_snprintf (output_buffer,
422 sizeof(output_buffer),
423 "%p Search string not found: %s (%d)\n"
424 "%p On peer: %u (%p)\n"
425 "%p After: %s\n",
426 peer, peer->search_str, peer->search_str_matched,
427 peer, peer->id, peer,
428 peer,
430 GNUNET_NO));
431 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
432 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
433 }
434
435 if (NULL != peers[peer_cnt].op_handle)
436 GNUNET_TESTBED_operation_done (peers[peer_cnt].op_handle);
437 }
438
439 if (NULL != data_file)
440 {
442 data_file = NULL;
443 }
444 for (search_str_cnt = 0;
445 search_str_cnt < num_peers && NULL != search_strings;
446 search_str_cnt++)
447 {
448 GNUNET_free (search_strings[search_str_cnt]);
449 }
451 search_strings = NULL;
452
453 if (NULL != reg_handle)
454 {
455 GNUNET_TESTBED_cancel_registration (reg_handle);
456 reg_handle = NULL;
457 }
458 if (NULL != mc)
459 {
460 GNUNET_TESTBED_controller_disconnect (mc);
461 mc = NULL;
462 }
463 if (NULL != mc_proc)
464 {
465 GNUNET_TESTBED_controller_stop (mc_proc);
466 mc_proc = NULL;
467 }
468 if (NULL != cfg)
469 {
471 cfg = NULL;
472 }
473}
474
475
481static void
482do_abort (void *cls)
483{
484 unsigned long i = (unsigned long) cls;
485
487 "Aborting from line %lu...\n", i);
488 abort_task = NULL;
491}
492
493
494/******************************************************************************/
495/********************* STATISTICS SERVICE CONNECTIONS ***********************/
496/******************************************************************************/
497
508static void *
509stats_ca (void *cls,
510 const struct GNUNET_CONFIGURATION_Handle *cfg)
511{
512 return GNUNET_STATISTICS_create ("<driver>", cfg);
513}
514
515
523static void
524stats_da (void *cls, void *op_result)
525{
526 struct RegexPeer *peer = cls;
527
528 GNUNET_assert (op_result == peer->stats_handle);
529
531 peer->stats_handle = NULL;
532}
533
534
545static int
546stats_iterator (void *cls,
547 const char *subsystem,
548 const char *name,
549 uint64_t value, int is_persistent)
550{
551 struct RegexPeer *peer = cls;
552 char output_buffer[512];
553 size_t size;
554
555 if (NULL == data_file)
556 {
558 "%p -> %s [%s]: %llu\n",
559 peer,
560 subsystem,
561 name,
562 (unsigned long long) value);
563 return GNUNET_OK;
564 }
565 size =
566 GNUNET_snprintf (output_buffer,
567 sizeof(output_buffer),
568 "%p [%s] %llu %s\n",
569 peer,
570 subsystem,
571 (unsigned long long) value,
572 name);
573 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
575 "Unable to write to file!\n");
576
577 return GNUNET_OK;
578}
579
580
589static void
590stats_cb (void *cls,
591 int success)
592{
593 static unsigned int peer_cnt;
594 struct RegexPeer *peer = cls;
595
596 if (GNUNET_OK != success)
597 {
599 "Getting statistics for peer %u failed!\n",
600 peer->id);
601 return;
602 }
603
604 GNUNET_assert (NULL != peer->op_handle);
605
606 GNUNET_TESTBED_operation_done (peer->op_handle);
607 peer->op_handle = NULL;
608
609 peer_cnt++;
610 peer = &peers[peer_cnt];
611
612 fprintf (stderr, "s");
613 if (peer_cnt == num_peers)
614 {
616 "\nCollecting stats finished. Shutting down.\n");
619 }
620 else
621 {
622 peer->op_handle =
623 GNUNET_TESTBED_service_connect (NULL,
624 peer->peer_handle,
625 "statistics",
627 peer,
628 &stats_ca,
629 &stats_da,
630 peer);
631 }
632}
633
634
644static void
645stats_connect_cb (void *cls,
646 struct GNUNET_TESTBED_Operation *op,
647 void *ca_result,
648 const char *emsg)
649{
650 struct RegexPeer *peer = cls;
651
652 if ((NULL == ca_result) || (NULL != emsg))
653 {
655 "Failed to connect to statistics service on peer %u: %s\n",
656 peer->id, emsg);
657
658 peer->stats_handle = NULL;
659 return;
660 }
661
662 peer->stats_handle = ca_result;
663
664 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, NULL, NULL,
665 &stats_cb,
666 &stats_iterator, peer))
667 {
669 "Could not get statistics of peer %u!\n", peer->id);
670 }
671}
672
673
680static void
681do_collect_stats (void *cls)
682{
683 struct RegexPeer *peer = &peers[0];
684
685 GNUNET_assert (NULL != peer->peer_handle);
686
687 peer->op_handle =
688 GNUNET_TESTBED_service_connect (NULL,
689 peer->peer_handle,
690 "statistics",
692 peer,
693 &stats_ca,
694 &stats_da,
695 peer);
696}
697
698
699/******************************************************************************/
700/************************ REGEX FIND CONNECTIONS **************************/
701/******************************************************************************/
702
703
709static void
710find_string (void *cls);
711
712
724static void
725regex_found_handler (void *cls,
726 const struct GNUNET_PeerIdentity *id,
727 const struct GNUNET_DHT_PathElement *get_path,
728 unsigned int get_path_length,
729 const struct GNUNET_DHT_PathElement *put_path,
730 unsigned int put_path_length)
731{
732 struct RegexPeer *peer = cls;
733 char output_buffer[512];
734 size_t size;
735
736 if (GNUNET_YES == peer->search_str_matched)
737 {
739 "String %s on peer %u already matched!\n",
740 peer->search_str, peer->id);
741 return;
742 }
743
746
747 if (NULL != peer->timeout)
748 {
750 peer->timeout = NULL;
751 if (GNUNET_NO == in_shutdown)
753 }
754
755 if (NULL == id)
756 {
757 // FIXME not possible right now
759 "String matching timed out for string %s on peer %u (%i/%i)\n",
760 peer->search_str, peer->id, strings_found, num_peers);
762 }
763 else
764 {
766
768 "String %s found on peer %u after %s (%i/%i) (%u||)\n",
769 peer->search_str, peer->id,
772
774
775 if (NULL != data_file)
776 {
777 size =
778 GNUNET_snprintf (output_buffer,
779 sizeof(output_buffer),
780 "%p Peer: %u\n"
781 "%p Search string: %s\n"
782 "%p Search duration: %s\n\n",
783 peer, peer->id,
784 peer, peer->search_str,
785 peer,
787 GNUNET_NO));
788
789 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
790 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
791 }
792 }
793
794 GNUNET_TESTBED_operation_done (peer->op_handle);
795 peer->op_handle = NULL;
796
798 {
801 "All strings successfully matched in %s\n",
803
804 if (NULL != search_timeout_task)
805 {
807 search_timeout_task = NULL;
808 }
809
810 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n");
812 }
813}
814
815
822static void
823search_timed_out (void *cls)
824{
825 unsigned int i;
826
828 "Finding matches to all strings did not succeed after %s.\n",
830 GNUNET_NO));
832 "Found %i of %i strings\n", strings_found, num_peers);
833
835 "Search timed out after %s."
836 "Collecting stats and shutting down.\n",
838 GNUNET_NO));
839
841 for (i = 0; i < num_peers; i++)
842 {
843 if (NULL != peers[i].op_handle)
844 {
845 GNUNET_TESTBED_operation_done (peers[i].op_handle);
846 peers[i].op_handle = NULL;
847 }
848 }
850}
851
852
859static void
860find_timed_out (void *cls)
861{
862 struct RegexPeer *p = cls;
863
864 p->timeout = NULL;
866 "Searching for string \"%s\" on peer %d timed out.\n",
867 p->search_str,
868 p->id);
869 if (GNUNET_NO == in_shutdown)
871}
872
873
879static void
880find_string (void *cls)
881{
882 unsigned int search_peer = (unsigned int) (long) cls;
883
884 if ((search_peer >= num_peers) ||
886 return;
887
889 "Searching for string \"%s\" on peer %d (%u||)\n",
890 peers[search_peer].search_str,
891 search_peer,
893
894 peers[search_peer].op_handle =
895 GNUNET_TESTBED_service_connect (NULL,
896 peers[search_peer].peer_handle,
897 "dht",
899 &peers[search_peer],
900 &dht_ca,
901 &dht_da,
902 &peers[search_peer]);
903 GNUNET_assert (NULL != peers[search_peer].op_handle);
904 peers[search_peer].timeout
907 &peers[search_peer]);
908}
909
910
918static void
919daemon_started (void *cls,
920 struct GNUNET_TESTBED_Operation *op,
921 const char *emsg)
922{
923 struct RegexPeer *peer = (struct RegexPeer *) cls;
924 unsigned long search_peer;
925 unsigned int i;
926
927 GNUNET_TESTBED_operation_done (peer->daemon_op);
928 peer->daemon_op = NULL;
929 if (NULL != emsg)
930 {
932 "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg);
933 GNUNET_assert (0);
934 }
935 else
936 {
938 "Daemon %u started successfully\n", peer->id);
939 }
940
941 /* Find a peer to look for a string matching the regex announced */
943 num_peers);
944 for (i = 0; peers[search_peer].search_str != NULL; i++)
945 {
946 search_peer = (search_peer + 1) % num_peers;
947 if (i > num_peers)
948 GNUNET_assert (0); /* we ran out of peers, must be a bug */
949 }
950 peers[search_peer].search_str = search_strings[peer->id];
951 peers[search_peer].search_str_matched = GNUNET_NO;
954 2),
956 (void *) search_peer);
957}
958
959
966static void
967do_announce (void *cls)
968{
969 unsigned int i;
970
971 if (GNUNET_YES == in_shutdown)
972 return;
974 "Starting announce.\n");
975 for (i = 0; i < init_parallel_searches; i++)
976 {
978 " scheduling announce %u\n",
979 i);
981 }
982}
983
984
990static void
991announce_next_regex (void *cls)
992{
993 struct RegexPeer *peer;
994
995 if (GNUNET_YES == in_shutdown)
996 return;
997 if (next_search >= num_peers)
998 {
1000 {
1001 struct GNUNET_TIME_Relative new_delay;
1002 if (NULL != search_timeout_task)
1007 NULL);
1008 }
1009 return;
1010 }
1011
1012 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", next_search);
1013 peer = &peers[next_search];
1014 peer->daemon_op =
1015 GNUNET_TESTBED_peer_manage_service (NULL,
1016 peer->peer_handle,
1017 "regexprofiler",
1019 peer,
1020 1);
1021 next_search++;
1023}
1024
1025
1026static void
1027dht_connect_cb (void *cls,
1028 struct GNUNET_TESTBED_Operation *op,
1029 void *ca_result,
1030 const char *emsg)
1031{
1032 struct RegexPeer *peer = (struct RegexPeer *) cls;
1033
1034 if ((NULL != emsg) || (NULL == op) || (NULL == ca_result))
1035 {
1036 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg);
1037 GNUNET_assert (0);
1038 }
1039
1040 GNUNET_assert (NULL != peer->dht_handle);
1041 GNUNET_assert (peer->op_handle == op);
1042 GNUNET_assert (peer->dht_handle == ca_result);
1043
1046 peer->search_str,
1047 &regex_found_handler, peer,
1048 NULL);
1050}
1051
1052
1053static void *
1054dht_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
1055{
1056 struct RegexPeer *peer = cls;
1057
1058 peer->dht_handle = GNUNET_DHT_connect (cfg, 32);
1059
1060 return peer->dht_handle;
1061}
1062
1063
1064static void
1065dht_da (void *cls, void *op_result)
1066{
1067 struct RegexPeer *peer = (struct RegexPeer *) cls;
1068
1069 GNUNET_assert (peer->dht_handle == op_result);
1070
1071 if (NULL != peer->search_handle)
1072 {
1074 peer->search_handle = NULL;
1075 }
1076
1077 if (NULL != peer->dht_handle)
1078 {
1080 peer->dht_handle = NULL;
1081 }
1082}
1083
1084
1098static void
1099test_master (void *cls,
1100 struct GNUNET_TESTBED_RunHandle *h,
1101 unsigned int num_peers_,
1102 struct GNUNET_TESTBED_Peer **testbed_peers,
1103 unsigned int links_succeeded,
1104 unsigned int links_failed)
1105{
1106 unsigned int i;
1107
1108 GNUNET_assert (num_peers_ == num_peers);
1109
1112 "Testbed started in %s\n",
1114
1115 if (NULL != abort_task)
1116 {
1118 abort_task = NULL;
1119 }
1120
1121 for (i = 0; i < num_peers; i++)
1122 {
1123 peers[i].peer_handle = testbed_peers[i];
1124 }
1125 if (GNUNET_NO ==
1126 GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", "DISABLE_TRY_CONNECT"))
1127 {
1128 struct GNUNET_TIME_Relative settle_time;
1129
1130 settle_time =
1132 10 * num_peers);
1134 "Waiting for DHT for %s to settle new connections.\n\n",
1136 GNUNET_NO));
1137 GNUNET_SCHEDULER_add_delayed (settle_time, &do_announce, NULL);
1138 }
1139 else
1140 {
1142 }
1145}
1146
1147
1154static void
1155master_controller_cb (void *cls,
1156 const struct GNUNET_TESTBED_EventInformation *event)
1157{
1158 switch (event->type)
1159 {
1160 case GNUNET_TESTBED_ET_CONNECT:
1161 printf (".");
1162 break;
1163
1164 case GNUNET_TESTBED_ET_PEER_START:
1165 printf ("#");
1166 break;
1167
1168 default:
1169 break;
1170 }
1171 fflush (stdout);
1172}
1173
1174
1175/******************************************************************************/
1176/*************************** TESTBED PEER SETUP *****************************/
1177/******************************************************************************/
1178
1189static int
1191 uint64_t data_size,
1192 unsigned int str_max)
1193{
1194 char *buf; // Keep track of last string to skip blank lines
1195 unsigned int offset;
1196 unsigned int str_cnt;
1197
1198 buf = data;
1199 offset = 0;
1200 str_cnt = 0;
1201 while ((offset < (data_size - 1)) && (str_cnt < str_max))
1202 {
1203 offset++;
1204 if (((data[offset] == '\n')) &&
1205 (buf != &data[offset]))
1206 {
1207 data[offset] = '\0';
1208 str_cnt++;
1209 buf = &data[offset + 1];
1210 }
1211 else if ((data[offset] == '\n') ||
1212 (data[offset] == '\0'))
1213 buf = &data[offset + 1];
1214 }
1215 return str_cnt;
1216}
1217
1218
1232static int
1233create_string_array (char *data, uint64_t data_size,
1234 char ***strings, unsigned int str_cnt)
1235{
1236 uint64_t offset;
1237 uint64_t len;
1238 unsigned int i;
1239
1240 *strings = GNUNET_malloc (sizeof(char *) * str_cnt);
1241 offset = 0;
1242 for (i = 0; i < str_cnt; i++)
1243 {
1244 len = strlen (&data[offset]);
1245 if (offset + len >= data_size)
1246 {
1247 GNUNET_free (*strings);
1248 *strings = NULL;
1249 return GNUNET_SYSERR;
1250 }
1251 if (0 == len) // empty line
1252 {
1253 offset++;
1254 i--;
1255 continue;
1256 }
1257
1258 GNUNET_asprintf (&(*strings)[i],
1259 "%s%s",
1261 &data[offset]);
1262 offset += len + 1;
1263 }
1264 return GNUNET_OK;
1265}
1266
1267
1277static int
1278load_search_strings (const char *filename,
1279 char ***strings,
1280 unsigned int limit)
1281{
1282 char *data;
1283 uint64_t filesize;
1284 int str_cnt;
1285
1286 /* Sanity checks */
1287 if (NULL == filename)
1288 {
1289 return GNUNET_SYSERR;
1290 }
1292 {
1294 "Could not find search strings file %s\n", filename);
1295 return GNUNET_SYSERR;
1296 }
1297 if (GNUNET_OK !=
1299 &filesize,
1300 GNUNET_YES,
1301 GNUNET_YES))
1302 {
1304 "Search strings file %s cannot be read.\n",
1305 filename);
1306 return GNUNET_SYSERR;
1307 }
1308 if (0 == filesize)
1309 {
1311 "Search strings file %s is empty.\n",
1312 filename);
1313 return GNUNET_SYSERR;
1314 }
1315
1316 /* Read data into memory */
1317 data = GNUNET_malloc (filesize + 1);
1318 if (filesize != GNUNET_DISK_fn_read (filename,
1319 data,
1320 filesize))
1321 {
1322 GNUNET_free (data);
1324 "Could not read search strings file %s.\n",
1325 filename);
1326 return GNUNET_SYSERR;
1327 }
1328
1329 /* Process buffer and build array */
1330 str_cnt = count_and_separate_strings (data, filesize, limit);
1331 if (GNUNET_OK != create_string_array (data, filesize, strings, str_cnt))
1332 {
1333 str_cnt = GNUNET_SYSERR;
1334 }
1335 GNUNET_free (data);
1336 return str_cnt;
1337}
1338
1339
1348static void
1349run (void *cls,
1350 char *const *args,
1351 const char *cfgfile,
1352 const struct GNUNET_CONFIGURATION_Handle *config)
1353{
1354 unsigned int nsearchstrs;
1355 unsigned int i;
1356 struct GNUNET_TIME_Relative abort_time;
1357
1359
1360 /* Check config */
1361 if (NULL == config)
1362 {
1364 _ ("No configuration file given. Exiting\n"));
1366 return;
1367 }
1369 if (GNUNET_OK !=
1371 "REGEX_PREFIX",
1372 &regex_prefix))
1373 {
1375 "regexprofiler",
1376 "regex_prefix");
1378 return;
1379 }
1380 if (GNUNET_OK !=
1382 "PARALLEL_SEARCHES",
1384 {
1386 "Configuration option \"PARALLEL_SEARCHES\" missing."
1387 " Using default (%d)\n", 10);
1389 }
1390 if (GNUNET_OK !=
1391 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER",
1392 "REANNOUNCE_PERIOD_MAX",
1394 {
1396 "reannounce_period_max not given. Using 10 minutes.\n");
1399 }
1400
1401 /* Check arguments */
1402 if (NULL == policy_dir)
1403 {
1405 _ (
1406 "No policy directory specified on command line. Exiting.\n"));
1407 return;
1408 }
1410 {
1412 _ ("Specified policies directory does not exist. Exiting.\n"));
1414 return;
1415 }
1416 if (0 >= (int) (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL,
1417 NULL)))
1418 {
1420 _ ("No files found in `%s'\n"),
1421 policy_dir);
1422 return;
1423 }
1425 "POLICY_DIR", policy_dir);
1427 {
1429 _ ("No search strings file given. Exiting.\n"));
1431 return;
1432 }
1433 nsearchstrs = load_search_strings (strings_file,
1435 num_peers);
1436 if (num_peers != nsearchstrs)
1437 {
1439 "Error loading search strings.\n");
1441 "File (%s) does not contain enough strings (%u/%u).\n",
1442 strings_file, nsearchstrs, num_peers);
1444 return;
1445 }
1446 if ((0 == num_peers) || (NULL == search_strings))
1447 {
1449 _ ("Error loading search strings. Exiting.\n"));
1451 return;
1452 }
1453 for (i = 0; i < num_peers; i++)
1455 "search string: %s\n",
1456 search_strings[i]);
1457
1458 /* Check logfile */
1459 if ((NULL != data_filename) &&
1460 (NULL == (data_file =
1467 {
1469 "open",
1471 return;
1472 }
1473
1474 /* Initialize peers */
1475 peers = GNUNET_malloc (sizeof(struct RegexPeer) * num_peers);
1476 for (i = 0; i < num_peers; i++)
1477 peers[i].id = i;
1478
1480 "TESTBED", "OVERLAY_RANDOM_LINKS",
1481 num_peers * 20);
1483 "DHT", "FORCE_NSE",
1484 (long long unsigned)
1485 (log (num_peers) / log (2.0)));
1486 event_mask = 0LL;
1487/* For feedback about the start process activate these and pass master_cb */
1488 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
1489// event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
1490 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
1491// event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
1493 GNUNET_TESTBED_run (hosts_file,
1494 cfg,
1495 num_peers,
1496 event_mask,
1498 NULL, /* master_controller_cb cls */
1499 &test_master,
1500 NULL); /* test_master cls */
1501 if (GNUNET_OK !=
1503 "SETUP_TIMEOUT",
1504 &abort_time))
1505 {
1507 "SETUP_TIMEOUT not given. Using 15 minutes.\n");
1508 abort_time =
1510 }
1511 abort_time = GNUNET_TIME_relative_add (abort_time, GNUNET_TIME_UNIT_MINUTES);
1512 abort_task =
1513 GNUNET_SCHEDULER_add_delayed (abort_time,
1514 &do_abort,
1515 (void *) __LINE__);
1517 "setup_timeout: %s\n",
1519}
1520
1521
1529int
1530main (int argc, char *const *argv)
1531{
1534 'o',
1535 "output-file",
1536 "FILENAME",
1537 gettext_noop (
1538 "name of the file for writing statistics"),
1539 &data_filename),
1541 't',
1542 "matching-timeout",
1543 "TIMEOUT",
1544 gettext_noop (
1545 "wait TIMEOUT before ending the experiment"),
1548 'p',
1549 "policy-dir",
1550 "DIRECTORY",
1551 gettext_noop ("directory with policy files"),
1552 &policy_dir),
1554 's',
1555 "strings-file",
1556 "FILENAME",
1557 gettext_noop (
1558 "name of file with input strings"),
1559 &strings_file),
1561 'H',
1562 "hosts-file",
1563 "FILENAME",
1564 gettext_noop (
1565 "name of file with hosts' names"),
1566 &hosts_file),
1567
1569 };
1570 int ret;
1571
1573 ret =
1574 GNUNET_PROGRAM_run (argc, argv,
1575 "gnunet-regex-profiler",
1576 _ ("Profiler for regex"),
1577 options,
1578 &run, NULL);
1579 if (GNUNET_OK != ret)
1580 return ret;
1581 if (GNUNET_OK != result)
1582 return 1;
1583 return 0;
1584}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
int main()
Program to simulate results from GCP_get_desirability_of_path() for various plausible inputs.
#define gettext_noop(String)
Definition gettext.h:74
static struct GNUNET_ARM_Operation * op
Current operation.
Definition gnunet-arm.c:143
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static int ret
Final status code.
Definition gnunet-arm.c:93
static int do_shutdown
Set to GNUNET_YES if we are shutting down.
static char * data
The data to insert into the dht.
static char * filename
const struct GNUNET_CONFIGURATION_Handle * config
static char * name
Name (label) of the records to list.
static char * value
Value of the record to add/remove.
static size_t data_size
Number of bytes in data.
enum State state
current state of profiling
static unsigned int next_search
Index of peer to start next announce/search.
static char * data_filename
Filename to log statistics to.
static struct GNUNET_SCHEDULER_Task * abort_task
Abort task identifier.
static long long unsigned int init_parallel_searches
How many searches are we going to start in parallel.
static void stats_connect_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Function called by testbed once we are connected to stats service.
static int stats_iterator(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Process statistic values.
static int count_and_separate_strings(char *data, uint64_t data_size, unsigned int str_max)
Process the text buffer counting the non-empty lines and separating them with NULL characters,...
static void stats_cb(void *cls, int success)
Stats callback.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
static struct GNUNET_TIME_Relative reannounce_period_max
What's the maximum regex reannounce period.
static char * policy_dir
Folder where policy files are stored.
static unsigned int parallel_searches
How many searches are running in parallel.
static struct GNUNET_TIME_Relative prof_time
Duration profiling step has taken.
static void stats_da(void *cls, void *op_result)
Adapter function called to destroy a connection to statistics service.
static void * stats_ca(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Adapter function called to establish a connection to statistics service.
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers_, struct GNUNET_TESTBED_Peer **testbed_peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
State
Available states during profiling.
@ STATE_PEERS_CREATING
Creating peers.
@ STATE_SLAVES_STARTING
Starting slaves.
@ STATE_INIT
Initial state.
@ STATE_PEERS_LINKING
Linking peers.
@ STATE_SEARCH_REGEX
Matching strings against announced regexes.
@ STATE_PEERS_STARTING
Starting peers.
@ STATE_PEERS_DESTROYING
Destroying peers; we can do this as the controller takes care of stopping a peer if it is running.
static void do_abort(void *cls)
abort task to run on test timed out
static int in_shutdown
Set when shutting down to avoid making more queries.
static struct GNUNET_TIME_Absolute prof_start_time
The starting time of a profiling step.
static void do_announce(void *cls)
Task to start the daemons on each peer so that the regexes are announced into the DHT.
static struct GNUNET_SCHEDULER_Task * register_hosts_task
Host registration task identifier.
static struct GNUNET_CONFIGURATION_Handle * cfg
Handle to global configuration.
static uint64_t event_mask
Global event mask for all testbed events.
static char * hosts_file
File with hostnames where to execute the test.
static struct GNUNET_SCHEDULER_Task * search_timeout_task
Search timeout task identifier.
static unsigned int strings_found
Number of strings found in the published regexes.
static int result
Global testing status.
static void announce_next_regex(void *cls)
Start announcing the next regex in the DHT.
static void find_string(void *cls)
Start searching for the next string in the DHT.
static struct GNUNET_TIME_Relative search_timeout_time
Search timeout in seconds.
static char * strings_file
File with the strings to look for.
static void dht_connect_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
DHT connect callback.
static int load_search_strings(const char *filename, char ***strings, unsigned int limit)
Load search strings from given filename.
static struct GNUNET_TESTBED_ControllerProc * mc_proc
Handle to the master controller process.
static int create_string_array(char *data, uint64_t data_size, char ***strings, unsigned int str_cnt)
Allocate a string array and fill it with the prefixed strings from a pre-processed,...
static void dht_da(void *cls, void *op_result)
Adapter function called to destroy a connection to the DHT service.
static void daemon_started(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback called when testbed has started the daemon we asked for.
static void * dht_ca(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
DHT connect adapter.
static char ** search_strings
Search strings (num_peers of them).
#define FIND_TIMEOUT
static void do_collect_stats(void *cls)
Task to collect all statistics from all peers, will shutdown the profiler, when done.
static void master_controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Function that will be called whenever something in the testbed changes.
static struct GNUNET_TESTBED_HostRegistrationHandle * reg_handle
Host registration handle.
static void search_timed_out(void *cls)
Connect by string timeout task.
static void regex_found_handler(void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length)
Method called when we've found a peer that announced a regex that matches our search string.
static char * regex_prefix
Prefix used for regex announcing.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
Main function that will be run by the scheduler.
static unsigned int num_peers
Number of peers to be started by the profiler.
static struct GNUNET_DISK_FileHandle * data_file
File to log statistics to.
static struct RegexPeer * peers
The array of peers; we fill this as the peers are given to us by the testbed.
static void find_timed_out(void *cls)
Search timed out.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
static struct GNUNET_OS_Process * p
Helper process we started.
Definition gnunet-uri.c:38
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition dht_api.c:1030
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition dht_api.c:1053
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition disk.c:1258
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
Definition disk.c:533
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition disk.c:710
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition disk.c:235
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition disk.c:454
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition disk.c:1332
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition disk.c:687
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition disk.c:839
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a filename (automatically path expanded).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time).
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition program.c:407
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:567
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition scheduler.c:1304
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1277
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_STATISTICS_GetHandle * GNUNET_STATISTICS_get(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Iterator proc, void *cls)
Get statistic from the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
Definition time.c:533
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition strings.c:599
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition time.c:587
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486
static unsigned int size
Size of the "table".
Definition peer.c:68
#define _(String)
GNU gettext support macro.
Definition platform.h:179
void REGEX_INTERNAL_search_cancel(struct REGEX_INTERNAL_Search *h)
Cancel an ongoing regex search in the DHT and free all resources.
struct REGEX_INTERNAL_Search * REGEX_INTERNAL_search(struct GNUNET_DHT_Handle *dht, const char *string, REGEX_INTERNAL_Found callback, void *callback_cls, struct GNUNET_STATISTICS_Handle *stats)
Search for a peer offering a regex matching certain string in the DHT.
DLL of operations.
struct DLLOperation * next
The next pointer for DLL.
struct DLLOperation * prev
The prev pointer for DLL.
Connection to the DHT service.
Definition dht_api.c:235
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
Handle used to access files (and pipes).
Definition of a command line option.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition scheduler.c:136
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
Struct to keep information of searches of services described by a regex using a user-provided string ...
Peer handles.
int search_str_matched
Set to GNUNET_YES if the peer successfully matched the above search string.
const char * search_str
Peer's search string.
struct GNUNET_TESTBED_Operation * daemon_op
Daemon start.
struct GNUNET_TIME_Absolute prof_start_time
The starting time of a profiling step.
unsigned int id
Peer id.
struct GNUNET_STATISTICS_Handle * stats_handle
Peers's statistics handle.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer configuration handle.
struct GNUNET_TESTBED_Operation * op_handle
Testbed operation handle for DHT.
struct GNUNET_TESTBED_Peer * peer_handle
The actual testbed peer handle.
struct GNUNET_DHT_Handle * dht_handle
Peer's DHT handle.
struct REGEX_INTERNAL_Search * search_handle
Handle to a running regex search.
struct GNUNET_SCHEDULER_Task * timeout
Operation timeout.

Enumeration Type Documentation

◆ State

enum State

Available states during profiling.

Enumerator
STATE_INIT 

Initial state.

STATE_SLAVES_STARTING 

Starting slaves.

STATE_PEERS_CREATING 

Creating peers.

STATE_PEERS_STARTING 

Starting peers.

STATE_PEERS_LINKING 

Linking peers.

STATE_SEARCH_REGEX 

Matching strings against announced regexes.

STATE_PEERS_DESTROYING 

Destroying peers; we can do this as the controller takes care of stopping a peer if it is running.

Definition at line 68 of file gnunet-regex-profiler.c.

Function Documentation

◆ dht_connect_cb()

static void dht_connect_cb ( void *  cls,
struct GNUNET_TESTBED_Operation *  op,
void *  ca_result,
const char *  emsg 
)
static

DHT connect callback.

Called when we are connected to the dht service for the peer in 'cls'. If successful we connect to the stats service of this peer and then try to match the search string of this peer.

Parameters
clsinternal peer id.
opoperation handle.
ca_resultconnect adapter result.
emsgerror message.

Definition at line 1028 of file gnunet-regex-profiler.c.

1032{
1033 struct RegexPeer *peer = (struct RegexPeer *) cls;
1034
1035 if ((NULL != emsg) || (NULL == op) || (NULL == ca_result))
1036 {
1037 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg);
1038 GNUNET_assert (0);
1039 }
1040
1041 GNUNET_assert (NULL != peer->dht_handle);
1042 GNUNET_assert (peer->op_handle == op);
1043 GNUNET_assert (peer->dht_handle == ca_result);
1044
1047 peer->search_str,
1048 &regex_found_handler, peer,
1049 NULL);
1051}

References RegexPeer::dht_handle, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_TIME_absolute_get(), op, RegexPeer::op_handle, RegexPeer::prof_start_time, regex_found_handler(), REGEX_INTERNAL_search(), RegexPeer::search_handle, RegexPeer::search_str, and RegexPeer::search_str_matched.

Referenced by find_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_ca()

static void * dht_ca ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

DHT connect adapter.

Opens a connection to the DHT service.

Parameters
clsClosure (peer).
cfgConfiguration handle.
Returns

Definition at line 1055 of file gnunet-regex-profiler.c.

1056{
1057 struct RegexPeer *peer = cls;
1058
1059 peer->dht_handle = GNUNET_DHT_connect (cfg, 32);
1060
1061 return peer->dht_handle;
1062}

References cfg, RegexPeer::dht_handle, and GNUNET_DHT_connect().

Referenced by find_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_da()

static void dht_da ( void *  cls,
void *  op_result 
)
static

Adapter function called to destroy a connection to the DHT service.

Parameters
clsClosure
op_resultService handle returned from the connect adapter.

Definition at line 1066 of file gnunet-regex-profiler.c.

1067{
1068 struct RegexPeer *peer = (struct RegexPeer *) cls;
1069
1070 GNUNET_assert (peer->dht_handle == op_result);
1071
1072 if (NULL != peer->search_handle)
1073 {
1075 peer->search_handle = NULL;
1076 }
1077
1078 if (NULL != peer->dht_handle)
1079 {
1081 peer->dht_handle = NULL;
1082 }
1083}

References RegexPeer::dht_handle, GNUNET_assert, GNUNET_DHT_disconnect(), REGEX_INTERNAL_search_cancel(), and RegexPeer::search_handle.

Referenced by find_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stats_connect_cb()

static void stats_connect_cb ( void *  cls,
struct GNUNET_TESTBED_Operation *  op,
void *  ca_result,
const char *  emsg 
)
static

Function called by testbed once we are connected to stats service.

Get the statistics for the services of interest.

Parameters
clsthe 'struct RegexPeer' for which we connected to stats
opconnect operation handle
ca_resulthandle to stats service
emsgerror message on failure

Definition at line 646 of file gnunet-regex-profiler.c.

650{
651 struct RegexPeer *peer = cls;
652
653 if ((NULL == ca_result) || (NULL != emsg))
654 {
656 "Failed to connect to statistics service on peer %u: %s\n",
657 peer->id, emsg);
658
659 peer->stats_handle = NULL;
660 return;
661 }
662
663 peer->stats_handle = ca_result;
664
665 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, NULL, NULL,
666 &stats_cb,
667 &stats_iterator, peer))
668 {
670 "Could not get statistics of peer %u!\n", peer->id);
671 }
672}

References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_STATISTICS_get(), RegexPeer::id, stats_cb(), RegexPeer::stats_handle, and stats_iterator().

Referenced by do_collect_stats(), and stats_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ announce_next_regex()

static void announce_next_regex ( void *  cls)
static

Start announcing the next regex in the DHT.

Parameters
clsIndex of the next peer in the peers array.
clsClosure (unused).

Definition at line 992 of file gnunet-regex-profiler.c.

993{
994 struct RegexPeer *peer;
995
996 if (GNUNET_YES == in_shutdown)
997 return;
998 if (next_search >= num_peers)
999 {
1000 if (strings_found != num_peers)
1001 {
1002 struct GNUNET_TIME_Relative new_delay;
1003 if (NULL != search_timeout_task)
1008 NULL);
1009 }
1010 return;
1011 }
1012
1013 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", next_search);
1014 peer = &peers[next_search];
1015 peer->daemon_op =
1016 GNUNET_TESTBED_peer_manage_service (NULL,
1017 peer->peer_handle,
1018 "regexprofiler",
1020 peer,
1021 1);
1022 next_search++;
1024}

References RegexPeer::daemon_op, daemon_started(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, in_shutdown, next_search, num_peers, parallel_searches, RegexPeer::peer_handle, peers, search_timed_out(), search_timeout_task, and strings_found.

Referenced by do_announce(), find_timed_out(), and regex_found_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Shutdown nicely.

Parameters
clsNULL

Definition at line 396 of file gnunet-regex-profiler.c.

397{
398 struct RegexPeer *peer;
399 unsigned int peer_cnt;
400 unsigned int search_str_cnt;
401 char output_buffer[512];
402 size_t size;
403
404 if (NULL != abort_task)
405 {
407 abort_task = NULL;
408 }
409 if (NULL != register_hosts_task)
410 {
412 register_hosts_task = NULL;
413 }
414 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++)
415 {
416 peer = &peers[peer_cnt];
417
418 if ((GNUNET_YES != peer->search_str_matched) && (NULL != data_file) )
419 {
421 size =
422 GNUNET_snprintf (output_buffer,
423 sizeof(output_buffer),
424 "%p Search string not found: %s (%d)\n"
425 "%p On peer: %u (%p)\n"
426 "%p After: %s\n",
427 peer, peer->search_str, peer->search_str_matched,
428 peer, peer->id, peer,
429 peer,
431 GNUNET_NO));
432 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
433 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
434 }
435
436 if (NULL != peers[peer_cnt].op_handle)
437 GNUNET_TESTBED_operation_done (peers[peer_cnt].op_handle);
438 }
439
440 if (NULL != data_file)
441 {
443 data_file = NULL;
444 }
445 for (search_str_cnt = 0;
446 search_str_cnt < num_peers && NULL != search_strings;
447 search_str_cnt++)
448 {
449 GNUNET_free (search_strings[search_str_cnt]);
450 }
452 search_strings = NULL;
453
454 if (NULL != reg_handle)
455 {
456 GNUNET_TESTBED_cancel_registration (reg_handle);
457 reg_handle = NULL;
458 }
459 if (NULL != mc)
460 {
461 GNUNET_TESTBED_controller_disconnect (mc);
462 mc = NULL;
463 }
464 if (NULL != mc_proc)
465 {
466 GNUNET_TESTBED_controller_stop (mc_proc);
467 mc_proc = NULL;
468 }
469 if (NULL != cfg)
470 {
472 cfg = NULL;
473 }
474}

References abort_task, cfg, data_file, GNUNET_CONFIGURATION_destroy(), GNUNET_DISK_file_close(), GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_snprintf(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, RegexPeer::id, mc, mc_proc, num_peers, RegexPeer::op_handle, peers, RegexPeer::prof_start_time, prof_time, reg_handle, register_hosts_task, RegexPeer::search_str, RegexPeer::search_str_matched, search_strings, and size.

Here is the call graph for this function:

◆ do_abort()

static void do_abort ( void *  cls)
static

abort task to run on test timed out

Parameters
clsNULL

Definition at line 483 of file gnunet-regex-profiler.c.

484{
485 unsigned long i = (unsigned long) cls;
486
488 "Aborting from line %lu...\n", i);
489 abort_task = NULL;
492}

References abort_task, do_shutdown, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, and result.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stats_ca()

static void * stats_ca ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Adapter function called to establish a connection to statistics service.

Parameters
clsclosure
cfgconfiguration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect()
Returns
service handle to return in 'op_result', NULL on error

Definition at line 510 of file gnunet-regex-profiler.c.

512{
513 return GNUNET_STATISTICS_create ("<driver>", cfg);
514}

References cfg, and GNUNET_STATISTICS_create().

Referenced by do_collect_stats(), and stats_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stats_da()

static void stats_da ( void *  cls,
void *  op_result 
)
static

Adapter function called to destroy a connection to statistics service.

Parameters
clsclosure
op_resultservice handle returned from the connect adapter

Definition at line 525 of file gnunet-regex-profiler.c.

526{
527 struct RegexPeer *peer = cls;
528
529 GNUNET_assert (op_result == peer->stats_handle);
530
532 peer->stats_handle = NULL;
533}

References GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_destroy(), and RegexPeer::stats_handle.

Referenced by do_collect_stats(), and stats_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stats_iterator()

static int stats_iterator ( void *  cls,
const char *  subsystem,
const char *  name,
uint64_t  value,
int  is_persistent 
)
static

Process statistic values.

Write all values to global 'data_file', if present.

Parameters
clsclosure
subsystemname of subsystem that created the statistic
namethe name of the datum
valuethe current value
is_persistentGNUNET_YES if the value is persistent, GNUNET_NO if not
Returns
GNUNET_OK to continue, GNUNET_SYSERR to abort iteration

Definition at line 547 of file gnunet-regex-profiler.c.

551{
552 struct RegexPeer *peer = cls;
553 char output_buffer[512];
554 size_t size;
555
556 if (NULL == data_file)
557 {
559 "%p -> %s [%s]: %llu\n",
560 peer,
561 subsystem,
562 name,
563 (unsigned long long) value);
564 return GNUNET_OK;
565 }
566 size =
567 GNUNET_snprintf (output_buffer,
568 sizeof(output_buffer),
569 "%p [%s] %llu %s\n",
570 peer,
571 subsystem,
572 (unsigned long long) value,
573 name);
574 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
576 "Unable to write to file!\n");
577
578 return GNUNET_OK;
579}

References data_file, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_snprintf(), name, size, subsystem, and value.

Referenced by stats_connect_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stats_cb()

static void stats_cb ( void *  cls,
int  success 
)
static

Stats callback.

Finish the stats testbed operation and when all stats have been iterated, shutdown the profiler.

Parameters
clsclosure
successGNUNET_OK if statistics were successfully obtained, GNUNET_SYSERR if not.

Definition at line 591 of file gnunet-regex-profiler.c.

593{
594 static unsigned int peer_cnt;
595 struct RegexPeer *peer = cls;
596
597 if (GNUNET_OK != success)
598 {
600 "Getting statistics for peer %u failed!\n",
601 peer->id);
602 return;
603 }
604
605 GNUNET_assert (NULL != peer->op_handle);
606
607 GNUNET_TESTBED_operation_done (peer->op_handle);
608 peer->op_handle = NULL;
609
610 peer_cnt++;
611 peer = &peers[peer_cnt];
612
613 fprintf (stderr, "s");
614 if (peer_cnt == num_peers)
615 {
617 "\nCollecting stats finished. Shutting down.\n");
620 }
621 else
622 {
623 peer->op_handle =
624 GNUNET_TESTBED_service_connect (NULL,
625 peer->peer_handle,
626 "statistics",
628 peer,
629 &stats_ca,
630 &stats_da,
631 peer);
632 }
633}

References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), RegexPeer::id, num_peers, RegexPeer::op_handle, RegexPeer::peer_handle, peers, result, stats_ca(), stats_connect_cb(), and stats_da().

Referenced by stats_connect_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_collect_stats()

static void do_collect_stats ( void *  cls)
static

Task to collect all statistics from all peers, will shutdown the profiler, when done.

Parameters
clsNULL

Definition at line 682 of file gnunet-regex-profiler.c.

683{
684 struct RegexPeer *peer = &peers[0];
685
686 GNUNET_assert (NULL != peer->peer_handle);
687
688 peer->op_handle =
689 GNUNET_TESTBED_service_connect (NULL,
690 peer->peer_handle,
691 "statistics",
693 peer,
694 &stats_ca,
695 &stats_da,
696 peer);
697}

References GNUNET_assert, RegexPeer::op_handle, RegexPeer::peer_handle, peers, stats_ca(), stats_connect_cb(), and stats_da().

Referenced by regex_found_handler(), and search_timed_out().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_string()

static void find_string ( void *  cls)
static

Start searching for the next string in the DHT.

Start searching for a string in the DHT.

Parameters
clsIndex of the next peer in the peers array.

Definition at line 881 of file gnunet-regex-profiler.c.

882{
883 unsigned int search_peer = (unsigned int) (long) cls;
884
885 if ((search_peer >= num_peers) ||
887 return;
888
890 "Searching for string \"%s\" on peer %d (%u||)\n",
891 peers[search_peer].search_str,
892 search_peer,
894
895 peers[search_peer].op_handle =
896 GNUNET_TESTBED_service_connect (NULL,
897 peers[search_peer].peer_handle,
898 "dht",
900 &peers[search_peer],
901 &dht_ca,
902 &dht_da,
903 &peers[search_peer]);
904 GNUNET_assert (NULL != peers[search_peer].op_handle);
905 peers[search_peer].timeout
908 &peers[search_peer]);
909}

References dht_ca(), dht_connect_cb(), dht_da(), find_timed_out(), FIND_TIMEOUT, GNUNET_assert, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, in_shutdown, num_peers, RegexPeer::op_handle, parallel_searches, RegexPeer::peer_handle, peers, RegexPeer::search_str, and RegexPeer::timeout.

Referenced by daemon_started().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ regex_found_handler()

static void regex_found_handler ( void *  cls,
const struct GNUNET_PeerIdentity id,
const struct GNUNET_DHT_PathElement get_path,
unsigned int  get_path_length,
const struct GNUNET_DHT_PathElement put_path,
unsigned int  put_path_length 
)
static

Method called when we've found a peer that announced a regex that matches our search string.

Now get the statistics.

Parameters
clsClosure provided in REGEX_INTERNAL_search.
idPeer providing a regex that matches the string.
get_pathPath of the get request.
get_path_lengthLength of get_path.
put_pathPath of the put request.
put_path_lengthLength of the put_path.

Definition at line 726 of file gnunet-regex-profiler.c.

732{
733 struct RegexPeer *peer = cls;
734 char output_buffer[512];
735 size_t size;
736
737 if (GNUNET_YES == peer->search_str_matched)
738 {
740 "String %s on peer %u already matched!\n",
741 peer->search_str, peer->id);
742 return;
743 }
744
747
748 if (NULL != peer->timeout)
749 {
751 peer->timeout = NULL;
752 if (GNUNET_NO == in_shutdown)
754 }
755
756 if (NULL == id)
757 {
758 // FIXME not possible right now
760 "String matching timed out for string %s on peer %u (%i/%i)\n",
761 peer->search_str, peer->id, strings_found, num_peers);
763 }
764 else
765 {
767
769 "String %s found on peer %u after %s (%i/%i) (%u||)\n",
770 peer->search_str, peer->id,
773
775
776 if (NULL != data_file)
777 {
778 size =
779 GNUNET_snprintf (output_buffer,
780 sizeof(output_buffer),
781 "%p Peer: %u\n"
782 "%p Search string: %s\n"
783 "%p Search duration: %s\n\n",
784 peer, peer->id,
785 peer, peer->search_str,
786 peer,
788 GNUNET_NO));
789
790 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
791 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
792 }
793 }
794
795 GNUNET_TESTBED_operation_done (peer->op_handle);
796 peer->op_handle = NULL;
797
799 {
802 "All strings successfully matched in %s\n",
804
805 if (NULL != search_timeout_task)
806 {
808 search_timeout_task = NULL;
809 }
810
811 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n");
813 }
814}

References announce_next_regex(), data_file, do_collect_stats(), GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_snprintf(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), GNUNET_YES, RegexPeer::id, in_shutdown, num_peers, RegexPeer::op_handle, parallel_searches, RegexPeer::prof_start_time, prof_start_time, prof_time, RegexPeer::search_str, RegexPeer::search_str_matched, search_timeout_task, size, strings_found, and RegexPeer::timeout.

Referenced by dht_connect_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_timed_out()

static void search_timed_out ( void *  cls)
static

Connect by string timeout task.

This will cancel the profiler after the specified timeout 'search_timeout'.

Parameters
clsNULL

Definition at line 824 of file gnunet-regex-profiler.c.

825{
826 unsigned int i;
827
829 "Finding matches to all strings did not succeed after %s.\n",
831 GNUNET_NO));
833 "Found %i of %i strings\n", strings_found, num_peers);
834
836 "Search timed out after %s."
837 "Collecting stats and shutting down.\n",
839 GNUNET_NO));
840
842 for (i = 0; i < num_peers; i++)
843 {
844 if (NULL != peers[i].op_handle)
845 {
846 GNUNET_TESTBED_operation_done (peers[i].op_handle);
847 peers[i].op_handle = NULL;
848 }
849 }
851}

References do_collect_stats(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, in_shutdown, num_peers, RegexPeer::op_handle, peers, search_timeout_time, and strings_found.

Referenced by announce_next_regex(), and test_master().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_timed_out()

static void find_timed_out ( void *  cls)
static

Search timed out.

It might still complete in the future, but we should start another one.

Parameters
clsIndex of the next peer in the peers array.

Definition at line 861 of file gnunet-regex-profiler.c.

862{
863 struct RegexPeer *p = cls;
864
865 p->timeout = NULL;
867 "Searching for string \"%s\" on peer %d timed out.\n",
868 p->search_str,
869 p->id);
870 if (GNUNET_NO == in_shutdown)
872}

References announce_next_regex(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), in_shutdown, and p.

Referenced by find_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ daemon_started()

static void daemon_started ( void *  cls,
struct GNUNET_TESTBED_Operation *  op,
const char *  emsg 
)
static

Callback called when testbed has started the daemon we asked for.

Parameters
clsNULL
opthe operation handle
emsgNULL on success; otherwise an error description

Definition at line 920 of file gnunet-regex-profiler.c.

923{
924 struct RegexPeer *peer = (struct RegexPeer *) cls;
925 unsigned long search_peer;
926 unsigned int i;
927
928 GNUNET_TESTBED_operation_done (peer->daemon_op);
929 peer->daemon_op = NULL;
930 if (NULL != emsg)
931 {
933 "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg);
934 GNUNET_assert (0);
935 }
936 else
937 {
939 "Daemon %u started successfully\n", peer->id);
940 }
941
942 /* Find a peer to look for a string matching the regex announced */
944 num_peers);
945 for (i = 0; peers[search_peer].search_str != NULL; i++)
946 {
947 search_peer = (search_peer + 1) % num_peers;
948 if (i > num_peers)
949 GNUNET_assert (0); /* we ran out of peers, must be a bug */
950 }
951 peers[search_peer].search_str = search_strings[peer->id];
952 peers[search_peer].search_str_matched = GNUNET_NO;
955 2),
957 (void *) search_peer);
958}

References RegexPeer::daemon_op, find_string(), GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative_saturating_multiply(), RegexPeer::id, num_peers, peers, reannounce_period_max, RegexPeer::search_str, RegexPeer::search_str_matched, and search_strings.

Referenced by announce_next_regex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_announce()

static void do_announce ( void *  cls)
static

Task to start the daemons on each peer so that the regexes are announced into the DHT.

Parameters
clsNULL

Definition at line 968 of file gnunet-regex-profiler.c.

969{
970 unsigned int i;
971
972 if (GNUNET_YES == in_shutdown)
973 return;
975 "Starting announce.\n");
976 for (i = 0; i < init_parallel_searches; i++)
977 {
979 " scheduling announce %u\n",
980 i);
982 }
983}

References announce_next_regex(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_YES, in_shutdown, and init_parallel_searches.

Referenced by test_master().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_master()

static void test_master ( void *  cls,
struct GNUNET_TESTBED_RunHandle *  h,
unsigned int  num_peers_,
struct GNUNET_TESTBED_Peer **  testbed_peers,
unsigned int  links_succeeded,
unsigned int  links_failed 
)
static

Signature of a main function for a testcase.

Parameters
clsNULL
hthe run handle
num_peers_number of peers in 'peers'
testbed_peershandle to peers run in the testbed. NULL upon timeout (see GNUNET_TESTBED_test_run()).
links_succeededthe number of overlay link connection attempts that succeeded
links_failedthe number of overlay link connection attempts that failed

Definition at line 1100 of file gnunet-regex-profiler.c.

1106{
1107 unsigned int i;
1108
1109 GNUNET_assert (num_peers_ == num_peers);
1110
1113 "Testbed started in %s\n",
1115
1116 if (NULL != abort_task)
1117 {
1119 abort_task = NULL;
1120 }
1121
1122 for (i = 0; i < num_peers; i++)
1123 {
1124 peers[i].peer_handle = testbed_peers[i];
1125 }
1126 if (GNUNET_NO ==
1127 GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", "DISABLE_TRY_CONNECT"))
1128 {
1129 struct GNUNET_TIME_Relative settle_time;
1130
1131 settle_time =
1133 10 * num_peers);
1135 "Waiting for DHT for %s to settle new connections.\n\n",
1137 GNUNET_NO));
1138 GNUNET_SCHEDULER_add_delayed (settle_time, &do_announce, NULL);
1139 }
1140 else
1141 {
1143 }
1146}

References abort_task, cfg, do_announce(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, num_peers, RegexPeer::peer_handle, peers, prof_start_time, prof_time, search_timed_out(), search_timeout_task, and search_timeout_time.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ master_controller_cb()

static void master_controller_cb ( void *  cls,
const struct GNUNET_TESTBED_EventInformation *  event 
)
static

Function that will be called whenever something in the testbed changes.

Parameters
clsclosure, NULL
eventinformation on what is happening

Definition at line 1156 of file gnunet-regex-profiler.c.

1158{
1159 switch (event->type)
1160 {
1161 case GNUNET_TESTBED_ET_CONNECT:
1162 printf (".");
1163 break;
1164
1165 case GNUNET_TESTBED_ET_PEER_START:
1166 printf ("#");
1167 break;
1168
1169 default:
1170 break;
1171 }
1172 fflush (stdout);
1173}

Referenced by run().

Here is the caller graph for this function:

◆ count_and_separate_strings()

static int count_and_separate_strings ( char *  data,
uint64_t  data_size,
unsigned int  str_max 
)
static

Process the text buffer counting the non-empty lines and separating them with NULL characters, for later ease of copy using (as)printf.

Parameters
dataMemory buffer with strings.
data_sizeSize of the data buffer in bytes.
str_maxMaximum number of strings to return.
Returns
Positive number of lines found in the buffer, GNUNET_SYSERR otherwise.

Definition at line 1191 of file gnunet-regex-profiler.c.

1194{
1195 char *buf; // Keep track of last string to skip blank lines
1196 unsigned int offset;
1197 unsigned int str_cnt;
1198
1199 buf = data;
1200 offset = 0;
1201 str_cnt = 0;
1202 while ((offset < (data_size - 1)) && (str_cnt < str_max))
1203 {
1204 offset++;
1205 if (((data[offset] == '\n')) &&
1206 (buf != &data[offset]))
1207 {
1208 data[offset] = '\0';
1209 str_cnt++;
1210 buf = &data[offset + 1];
1211 }
1212 else if ((data[offset] == '\n') ||
1213 (data[offset] == '\0'))
1214 buf = &data[offset + 1];
1215 }
1216 return str_cnt;
1217}

References data, and data_size.

Referenced by load_search_strings().

Here is the caller graph for this function:

◆ create_string_array()

static int create_string_array ( char *  data,
uint64_t  data_size,
char ***  strings,
unsigned int  str_cnt 
)
static

Allocate a string array and fill it with the prefixed strings from a pre-processed, NULL-separated memory region.

Parameters
dataPreprocessed memory with strings
data_sizeSize of the data buffer in bytes.
stringsAddress of the string array to be created. Must be freed by caller if function end in success.
str_cntString count. The data buffer should contain at least this many NULL-separated strings.
Returns
GNUNET_OK in ase of success, GNUNET_SYSERR otherwise. In case of error strings must not be freed.

Definition at line 1234 of file gnunet-regex-profiler.c.

1236{
1237 uint64_t offset;
1238 uint64_t len;
1239 unsigned int i;
1240
1241 *strings = GNUNET_malloc (sizeof(char *) * str_cnt);
1242 offset = 0;
1243 for (i = 0; i < str_cnt; i++)
1244 {
1245 len = strlen (&data[offset]);
1246 if (offset + len >= data_size)
1247 {
1248 GNUNET_free (*strings);
1249 *strings = NULL;
1250 return GNUNET_SYSERR;
1251 }
1252 if (0 == len) // empty line
1253 {
1254 offset++;
1255 i--;
1256 continue;
1257 }
1258
1259 GNUNET_asprintf (&(*strings)[i],
1260 "%s%s",
1262 &data[offset]);
1263 offset += len + 1;
1264 }
1265 return GNUNET_OK;
1266}

References data, data_size, GNUNET_asprintf(), GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, and regex_prefix.

Referenced by load_search_strings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_search_strings()

static int load_search_strings ( const char *  filename,
char ***  strings,
unsigned int  limit 
)
static

Load search strings from given filename.

One search string per line.

Parameters
filenamefilename of the file containing the search strings.
stringsset of strings loaded from file. Caller needs to free this if number returned is greater than zero.
limitupper limit on the number of strings read from the file
Returns
number of strings found in the file. GNUNET_SYSERR on error.

Definition at line 1279 of file gnunet-regex-profiler.c.

1282{
1283 char *data;
1284 uint64_t filesize;
1285 int str_cnt;
1286
1287 /* Sanity checks */
1288 if (NULL == filename)
1289 {
1290 return GNUNET_SYSERR;
1291 }
1293 {
1295 "Could not find search strings file %s\n", filename);
1296 return GNUNET_SYSERR;
1297 }
1298 if (GNUNET_OK !=
1300 &filesize,
1301 GNUNET_YES,
1302 GNUNET_YES))
1303 {
1305 "Search strings file %s cannot be read.\n",
1306 filename);
1307 return GNUNET_SYSERR;
1308 }
1309 if (0 == filesize)
1310 {
1312 "Search strings file %s is empty.\n",
1313 filename);
1314 return GNUNET_SYSERR;
1315 }
1316
1317 /* Read data into memory */
1318 data = GNUNET_malloc (filesize + 1);
1319 if (filesize != GNUNET_DISK_fn_read (filename,
1320 data,
1321 filesize))
1322 {
1323 GNUNET_free (data);
1325 "Could not read search strings file %s.\n",
1326 filename);
1327 return GNUNET_SYSERR;
1328 }
1329
1330 /* Process buffer and build array */
1331 str_cnt = count_and_separate_strings (data, filesize, limit);
1332 if (GNUNET_OK != create_string_array (data, filesize, strings, str_cnt))
1333 {
1334 str_cnt = GNUNET_SYSERR;
1335 }
1336 GNUNET_free (data);
1337 return str_cnt;
1338}

References count_and_separate_strings(), create_string_array(), data, filename, GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, and GNUNET_YES.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle config 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
configconfiguration

Definition at line 1350 of file gnunet-regex-profiler.c.

1354{
1355 unsigned int nsearchstrs;
1356 unsigned int i;
1357 struct GNUNET_TIME_Relative abort_time;
1358
1360
1361 /* Check config */
1362 if (NULL == config)
1363 {
1365 _ ("No configuration file given. Exiting\n"));
1367 return;
1368 }
1370 if (GNUNET_OK !=
1372 "REGEX_PREFIX",
1373 &regex_prefix))
1374 {
1376 "regexprofiler",
1377 "regex_prefix");
1379 return;
1380 }
1381 if (GNUNET_OK !=
1383 "PARALLEL_SEARCHES",
1385 {
1387 "Configuration option \"PARALLEL_SEARCHES\" missing."
1388 " Using default (%d)\n", 10);
1390 }
1391 if (GNUNET_OK !=
1392 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER",
1393 "REANNOUNCE_PERIOD_MAX",
1395 {
1397 "reannounce_period_max not given. Using 10 minutes.\n");
1400 }
1401
1402 /* Check arguments */
1403 if (NULL == policy_dir)
1404 {
1406 _ (
1407 "No policy directory specified on command line. Exiting.\n"));
1408 return;
1409 }
1411 {
1413 _ ("Specified policies directory does not exist. Exiting.\n"));
1415 return;
1416 }
1417 if (0 >= (int) (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL,
1418 NULL)))
1419 {
1421 _ ("No files found in `%s'\n"),
1422 policy_dir);
1423 return;
1424 }
1426 "POLICY_DIR", policy_dir);
1428 {
1430 _ ("No search strings file given. Exiting.\n"));
1432 return;
1433 }
1434 nsearchstrs = load_search_strings (strings_file,
1436 num_peers);
1437 if (num_peers != nsearchstrs)
1438 {
1440 "Error loading search strings.\n");
1442 "File (%s) does not contain enough strings (%u/%u).\n",
1443 strings_file, nsearchstrs, num_peers);
1445 return;
1446 }
1447 if ((0 == num_peers) || (NULL == search_strings))
1448 {
1450 _ ("Error loading search strings. Exiting.\n"));
1452 return;
1453 }
1454 for (i = 0; i < num_peers; i++)
1456 "search string: %s\n",
1457 search_strings[i]);
1458
1459 /* Check logfile */
1460 if ((NULL != data_filename) &&
1461 (NULL == (data_file =
1468 {
1470 "open",
1472 return;
1473 }
1474
1475 /* Initialize peers */
1476 peers = GNUNET_malloc (sizeof(struct RegexPeer) * num_peers);
1477 for (i = 0; i < num_peers; i++)
1478 peers[i].id = i;
1479
1481 "TESTBED", "OVERLAY_RANDOM_LINKS",
1482 num_peers * 20);
1484 "DHT", "FORCE_NSE",
1485 (long long unsigned)
1486 (log (num_peers) / log (2.0)));
1487 event_mask = 0LL;
1488/* For feedback about the start process activate these and pass master_cb */
1489 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
1490// event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
1491 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
1492// event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
1494 GNUNET_TESTBED_run (hosts_file,
1495 cfg,
1496 num_peers,
1497 event_mask,
1499 NULL, /* master_controller_cb cls */
1500 &test_master,
1501 NULL); /* test_master cls */
1502 if (GNUNET_OK !=
1504 "SETUP_TIMEOUT",
1505 &abort_time))
1506 {
1508 "SETUP_TIMEOUT not given. Using 15 minutes.\n");
1509 abort_time =
1511 }
1512 abort_time = GNUNET_TIME_relative_add (abort_time, GNUNET_TIME_UNIT_MINUTES);
1513 abort_task =
1514 GNUNET_SCHEDULER_add_delayed (abort_time,
1515 &do_abort,
1516 (void *) __LINE__);
1518 "setup_timeout: %s\n",
1520}

References _, abort_task, cfg, config, data_file, data_filename, do_abort(), do_shutdown, event_mask, GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_set_value_number(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_DISK_file_open(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_config_missing(), GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_add(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, hosts_file, in_shutdown, init_parallel_searches, load_search_strings(), master_controller_cb(), num_peers, peers, policy_dir, prof_start_time, reannounce_period_max, regex_prefix, search_strings, strings_file, and test_master().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Main function.

Parameters
argcargument count
argvargument values
Returns
0 on success

Definition at line 1531 of file gnunet-regex-profiler.c.

1532{
1535 'o',
1536 "output-file",
1537 "FILENAME",
1538 gettext_noop (
1539 "name of the file for writing statistics"),
1540 &data_filename),
1542 't',
1543 "matching-timeout",
1544 "TIMEOUT",
1545 gettext_noop (
1546 "wait TIMEOUT before ending the experiment"),
1549 'p',
1550 "policy-dir",
1551 "DIRECTORY",
1552 gettext_noop ("directory with policy files"),
1553 &policy_dir),
1555 's',
1556 "strings-file",
1557 "FILENAME",
1558 gettext_noop (
1559 "name of file with input strings"),
1560 &strings_file),
1562 'H',
1563 "hosts-file",
1564 "FILENAME",
1565 gettext_noop (
1566 "name of file with hosts' names"),
1567 &hosts_file),
1568
1570 };
1571 int ret;
1572
1574 ret =
1575 GNUNET_PROGRAM_run (argc, argv,
1576 "gnunet-regex-profiler",
1577 _ ("Profiler for regex"),
1578 options,
1579 &run, NULL);
1580 if (GNUNET_OK != ret)
1581 return ret;
1582 if (GNUNET_OK != result)
1583 return 1;
1584 return 0;
1585}

References _, data_filename, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_filename(), GNUNET_GETOPT_option_relative_time(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_SYSERR, hosts_file, options, policy_dir, result, ret, run(), search_timeout_time, and strings_file.

Here is the call graph for this function:

Variable Documentation

◆ in_shutdown

int in_shutdown
static

Set when shutting down to avoid making more queries.

Definition at line 180 of file gnunet-regex-profiler.c.

Referenced by announce_next_regex(), do_announce(), find_string(), find_timed_out(), regex_found_handler(), run(), and search_timed_out().

◆ peers

struct RegexPeer* peers
static

The array of peers; we fill this as the peers are given to us by the testbed.

Definition at line 185 of file gnunet-regex-profiler.c.

Referenced by announce_next_regex(), daemon_started(), do_collect_stats(), do_shutdown(), find_string(), run(), search_timed_out(), stats_cb(), and test_master().

◆ reg_handle

struct GNUNET_TESTBED_HostRegistrationHandle* reg_handle
static

Host registration handle.

Definition at line 190 of file gnunet-regex-profiler.c.

Referenced by do_shutdown().

◆ mc_proc

struct GNUNET_TESTBED_ControllerProc* mc_proc
static

Handle to the master controller process.

Definition at line 195 of file gnunet-regex-profiler.c.

Referenced by do_shutdown().

◆ mc

◆ cfg

struct GNUNET_CONFIGURATION_Handle* cfg
static

Handle to global configuration.

Definition at line 205 of file gnunet-regex-profiler.c.

Referenced by dht_ca(), do_shutdown(), run(), stats_ca(), and test_master().

◆ abort_task

struct GNUNET_SCHEDULER_Task* abort_task
static

Abort task identifier.

Definition at line 210 of file gnunet-regex-profiler.c.

Referenced by do_abort(), do_shutdown(), run(), and test_master().

◆ register_hosts_task

struct GNUNET_SCHEDULER_Task* register_hosts_task
static

Host registration task identifier.

Definition at line 215 of file gnunet-regex-profiler.c.

Referenced by do_shutdown().

◆ event_mask

uint64_t event_mask
static

Global event mask for all testbed events.

Definition at line 220 of file gnunet-regex-profiler.c.

Referenced by run(), and run().

◆ prof_start_time

struct GNUNET_TIME_Absolute prof_start_time
static

The starting time of a profiling step.

Definition at line 225 of file gnunet-regex-profiler.c.

Referenced by regex_found_handler(), run(), and test_master().

◆ prof_time

struct GNUNET_TIME_Relative prof_time
static

Duration profiling step has taken.

Definition at line 230 of file gnunet-regex-profiler.c.

Referenced by do_shutdown(), regex_found_handler(), and test_master().

◆ num_peers

unsigned int num_peers
static

Number of peers to be started by the profiler.

Definition at line 235 of file gnunet-regex-profiler.c.

Referenced by announce_next_regex(), daemon_started(), do_shutdown(), find_string(), regex_found_handler(), run(), search_timed_out(), stats_cb(), and test_master().

◆ result

int result
static

Global testing status.

Definition at line 240 of file gnunet-regex-profiler.c.

Referenced by _nss_gns_gethostbyaddr_r(), _nss_gns_gethostbyname2_r(), _nss_gns_gethostbyname_r(), auto_config_cb(), block_create2(), check_proof_of_work(), check_search_response(), clear_msg(), close_srv_handle_room(), compare_member_public_keys(), confirm_epoch_announcement_member(), confirm_epoch_group_member(), convert_from_ed_to_curve(), create_internal(), database_shutdown(), database_shutdown(), database_shutdown(), database_shutdown(), decode_message(), decode_private_ecdsa_key(), decrypt_message(), decrypt_secret_message(), delete_store_message(), dns_value_to_string(), do_abort(), do_reconnect(), ecdsa_symmetric_decrypt(), ecdsa_symmetric_encrypt(), eddsa_symmetric_decrypt(), eddsa_symmetric_encrypt(), ego_sign_data_cb(), elligator_direct_map(), encrypt_message(), encrypt_secret_message(), evaluate_nfa(), expand_dollar(), extract_abs_time(), extract_abs_time(), extract_abs_time_nbo(), extract_array_generic(), extract_blind_sign_priv(), extract_blind_sign_pub(), extract_blinded_sig(), extract_bool(), extract_fixed_blob(), extract_fixed_blob(), extract_int64(), extract_rel_time(), extract_result_cb(), extract_rsa_pub(), extract_rsa_public_key(), extract_rsa_sig(), extract_rsa_signature(), extract_string(), extract_timestamp(), extract_timestamp_nbo(), extract_uint16(), extract_uint16(), extract_uint32(), extract_uint32(), extract_uint64(), extract_uint64(), extract_unblinded_sig(), extract_utf8_string(), extract_var_blob(), extract_varsize_blob(), find_linked_hash(), find_op_by_id(), find_proof(), find_proof(), GCC_latency_observed(), generate_initiator_finished(), generate_responder_finished(), get_cont(), get_epoch_member_position(), get_epoch_membership_member_hash(), get_service_peer_identity(), GNUNET_BIO_read(), GNUNET_BIO_read_spec_object(), GNUNET_BIO_read_spec_string(), GNUNET_BIO_read_string(), GNUNET_CRYPTO_ecdhe_elligator_encoding(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_eddsa_private_key_derive(), GNUNET_CRYPTO_eddsa_public_key_derive(), GNUNET_CRYPTO_edx25519_private_key_derive(), GNUNET_CRYPTO_edx25519_public_key_derive(), GNUNET_CRYPTO_hash_create_random(), GNUNET_CRYPTO_hash_difference(), GNUNET_CRYPTO_hash_from_string2(), GNUNET_CRYPTO_hash_sum(), GNUNET_CRYPTO_hash_to_enc(), GNUNET_CRYPTO_hash_xor(), GNUNET_CRYPTO_hkdf_expand(), GNUNET_CRYPTO_hkdf_expand_v(), GNUNET_CRYPTO_hkdf_gnunet(), GNUNET_CRYPTO_hkdf_gnunet_v(), GNUNET_CRYPTO_kdf(), GNUNET_CRYPTO_kdf_v(), GNUNET_CRYPTO_mpi_scan_unsigned(), GNUNET_CRYPTO_paillier_hom_add(), GNUNET_CRYPTO_pow_hash(), GNUNET_CRYPTO_rsa_private_key_get_public(), GNUNET_CRYPTO_sign_by_peer_identity(), GNUNET_CRYPTO_symmetric_decrypt(), GNUNET_CRYPTO_symmetric_encrypt(), GNUNET_DISK_file_read(), GNUNET_DISK_fn_read(), GNUNET_FS_directory_scan_get_result(), GNUNET_FS_read_meta_data(), GNUNET_FS_read_spec_meta_data(), GNUNET_GNSRECORD_block_create(), GNUNET_GNSRECORD_block_create2(), GNUNET_GNSRECORD_block_create_unsigned(), GNUNET_GNSRECORD_check_pow(), GNUNET_GNSRECORD_pow_round(), GNUNET_HELLO_build_url(), GNUNET_HELLO_builder_to_url(), GNUNET_HELLO_builder_to_url2(), GNUNET_HELLO_parser_to_url(), GNUNET_HOSTLIST_client_start(), GNUNET_PQ_eval_prepared_multi_select(), GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_eval_prepared_singleton_select(), GNUNET_PQ_eval_result(), GNUNET_PQ_event_notify(), GNUNET_PQ_exec_statements(), GNUNET_PQ_extract_result(), GNUNET_RECLAIM_attribute_list_dup(), GNUNET_RECLAIM_attribute_list_serialize(), GNUNET_RECLAIM_attribute_serialize(), GNUNET_RECLAIM_credential_list_dup(), GNUNET_RECLAIM_credential_list_serialize(), GNUNET_RECLAIM_credential_serialize(), GNUNET_RECLAIM_presentation_list_dup(), GNUNET_RECLAIM_presentation_list_serialize(), GNUNET_RECLAIM_presentation_serialize(), GNUNET_SETI_create(), GNUNET_SETU_create(), GNUNET_SQ_extract_result(), GNUNET_STRINGS_parse_ipv4_policy(), GNUNET_STRINGS_parse_ipv6_policy(), GNUNET_try_compression(), GNUNET_xmalloc_unchecked_(), GSF_consider_forwarding(), GSF_request_plan_reference_get_last_transmission_(), handle_arm_result(), handle_external_ip(), handle_gns_response(), handle_results(), handle_search_response(), handle_search_result(), hkdf_expand(), init_callback(), init_cb(), ip_try_connect(), is_epoch_member_in_any_group(), is_epoch_member_in_room(), is_epoch_subgroup_of_any_group(), it_find_announcement_with_most_members(), it_find_group_with_most_members(), iterate_find_room(), libgnunet_plugin_datacache_sqlite_done(), link_room_message(), load_message_store_attribute(), main(), manage_subscribe(), numeric_reverse(), OIDC_generate_id_token_hmac(), OIDC_generate_id_token_rsa(), open_service_room(), pils_sign_addr_cb(), process_keys(), process_result_message(), put_store_message(), read_from_buffer(), read_from_file(), read_spec_handler_int32(), read_spec_handler_int64(), read_spec_handler_meta_data(), read_spec_handler_string(), recalculate_path_desirability(), reconnect(), reconnect(), reconnect(), reconnect(), REGEX_INTERNAL_eval(), regex_next_edge(), regex_result_iterator(), request_room_message_step(), request_srv_room_message(), requester_callback(), ret_string(), rsa_sign_mpi(), send_finished(), sign_pow_identity(), signal_result(), sq_prepare(), sql_exec(), sql_prepare(), start_callback(), start_p2p_processing(), state_set_compare(), stats_cb(), stop_callback(), stop_cb(), stun_msg2str(), term_callback(), test_report_cb(), time_between(), and upnp_addr_change_cb().

◆ state

enum State state

current state of profiling

Definition at line 245 of file gnunet-regex-profiler.c.

◆ policy_dir

char* policy_dir
static

Folder where policy files are stored.

Definition at line 250 of file gnunet-regex-profiler.c.

Referenced by main(), run(), and run().

◆ hosts_file

char* hosts_file
static

File with hostnames where to execute the test.

Definition at line 255 of file gnunet-regex-profiler.c.

Referenced by main(), and run().

◆ strings_file

char* strings_file
static

File with the strings to look for.

Definition at line 260 of file gnunet-regex-profiler.c.

Referenced by main(), and run().

◆ search_strings

char** search_strings
static

Search strings (num_peers of them).

Definition at line 265 of file gnunet-regex-profiler.c.

Referenced by daemon_started(), do_shutdown(), and run().

◆ init_parallel_searches

long long unsigned int init_parallel_searches
static

How many searches are we going to start in parallel.

Definition at line 270 of file gnunet-regex-profiler.c.

Referenced by do_announce(), and run().

◆ parallel_searches

unsigned int parallel_searches
static

How many searches are running in parallel.

Definition at line 275 of file gnunet-regex-profiler.c.

Referenced by announce_next_regex(), find_string(), and regex_found_handler().

◆ strings_found

unsigned int strings_found
static

Number of strings found in the published regexes.

Definition at line 280 of file gnunet-regex-profiler.c.

Referenced by announce_next_regex(), regex_found_handler(), and search_timed_out().

◆ next_search

unsigned int next_search
static

Index of peer to start next announce/search.

Definition at line 285 of file gnunet-regex-profiler.c.

Referenced by announce_next_regex().

◆ search_timeout_task

struct GNUNET_SCHEDULER_Task* search_timeout_task
static

Search timeout task identifier.

Definition at line 290 of file gnunet-regex-profiler.c.

Referenced by announce_next_regex(), regex_found_handler(), and test_master().

◆ search_timeout_time

struct GNUNET_TIME_Relative search_timeout_time = { 60000 }
static

Search timeout in seconds.

Definition at line 295 of file gnunet-regex-profiler.c.

295{ 60000 };

Referenced by main(), search_timed_out(), and test_master().

◆ data_file

struct GNUNET_DISK_FileHandle* data_file
static

File to log statistics to.

Definition at line 300 of file gnunet-regex-profiler.c.

Referenced by do_shutdown(), regex_found_handler(), run(), and stats_iterator().

◆ data_filename

char* data_filename
static

Filename to log statistics to.

Definition at line 305 of file gnunet-regex-profiler.c.

Referenced by main(), and run().

◆ regex_prefix

char* regex_prefix
static

Prefix used for regex announcing.

We need to prefix the search strings with it, in order to find something.

Definition at line 311 of file gnunet-regex-profiler.c.

Referenced by create_string_array(), and run().

◆ reannounce_period_max

struct GNUNET_TIME_Relative reannounce_period_max
static

What's the maximum regex reannounce period.

Definition at line 316 of file gnunet-regex-profiler.c.

Referenced by daemon_started(), and run().