2 This file is part of GNUnet.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file sensor/gnunet-sensor-profiler.c
23 * @brief Profiler for the sensor service
24 * @author Omar Tarabai
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testbed_service.h"
29 #include "gnunet_peerstore_service.h"
30 #include "gnunet_sensor_service.h"
31 #include "gnunet_sensor_util_lib.h"
32 #include "gnunet_transport_service.h"
35 * Time to wait for the peer to startup completely
37 #define PEER_STARTUP_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
40 * Information about a single peer
48 struct GNUNET_PeerIdentity peer_id;
53 struct GNUNET_TESTBED_Peer *testbed_peer;
56 * Index of this peer within our list
62 struct DisconnectionContext
65 struct DisconnectionContext *prev;
67 struct DisconnectionContext *next;
73 struct GNUNET_TESTBED_Operation *p1_transport_op;
75 struct GNUNET_TRANSPORT_Blacklist *blacklist;
81 * Name of the configuration file used
83 static const char *cfg_filename = "gnunet-sensor-profiler.conf";
86 * Directory to read sensor definitions from
88 static const char *sensor_src_dir = "sensors";
91 * Directory to write new sensor definitions to
93 static const char *sensor_dst_dir = "/tmp/gnunet-sensor-profiler";
96 * Scheduled task to shutdown
98 static GNUNET_SCHEDULER_TaskIdentifier shutdown_task = GNUNET_SCHEDULER_NO_TASK;
101 * GNUnet configuration
103 static struct GNUNET_CONFIGURATION_Handle *cfg;
106 * Number of peers to run (Option -p)
108 static unsigned int num_peers = 0;
111 * Set sensors running interval to this value (Option -i)
113 static unsigned int sensors_interval = 0;
116 * Path to topology file (Option -t)
118 static char *topology_file;
121 * Array of peer info for all peers
123 static struct PeerInfo *all_peers_info;
126 * Number of peers that we already collected and start their info
128 static int peers_known = 0;
131 * TESTBED operation connecting us to peerstore service on collection point
133 static struct GNUNET_TESTBED_Operation *peerstore_op;
136 * Handle to peerstore service on collection point
138 static struct GNUNET_PEERSTORE_Handle *peerstore;
141 * Dashboard service on collection point started?
143 static int dashboard_service_started = GNUNET_NO;
146 * Number of peers started the sensor service successfully
148 static int sensor_services_started = 0;
151 * Array of sensor names to be used for watching peerstore records
153 static char **sensor_names;
156 * Size of 'sensor_names' array
158 static unsigned int sensor_names_size = 0;
161 * Task run after any waiting period
163 static GNUNET_SCHEDULER_TaskIdentifier delayed_task = GNUNET_SCHEDULER_NO_TASK;
166 * Head of list of disconnection contexts
168 static struct DisconnectionContext *dc_head;
171 * Tail of list of disconnection contexts
173 static struct DisconnectionContext *dc_tail;
177 * Copy directory recursively
179 * @param src Path to source directory
180 * @param dst Destination directory, will be created if it does not exist
181 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
184 copy_dir (const char *src, const char *dst);
188 * Prompt the user to disconnect two peers
191 prompt_peer_disconnection ();
195 * Do clean up and shutdown scheduler
198 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
201 struct DisconnectionContext *dc;
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down.\n");
204 if (GNUNET_SCHEDULER_NO_TASK != delayed_task)
206 GNUNET_SCHEDULER_cancel (delayed_task);
207 delayed_task = GNUNET_SCHEDULER_NO_TASK;
212 GNUNET_CONTAINER_DLL_remove (dc_head, dc_tail, dc);
213 if (NULL != dc->blacklist)
215 GNUNET_TRANSPORT_blacklist_cancel (dc->blacklist);
216 dc->blacklist = NULL;
218 if (NULL != dc->p1_transport_op)
220 GNUNET_TESTBED_operation_done (dc->p1_transport_op);
221 dc->p1_transport_op = NULL;
226 if (NULL != peerstore_op)
228 GNUNET_TESTBED_operation_done (peerstore_op);
231 if (NULL != all_peers_info)
233 GNUNET_free (all_peers_info);
234 all_peers_info = NULL;
238 GNUNET_CONFIGURATION_destroy (cfg);
241 if (NULL != sensor_names)
243 for (i = 0; i < sensor_names_size; i++)
244 GNUNET_free (sensor_names[i]);
245 GNUNET_array_grow (sensor_names, sensor_names_size, 0);
247 GNUNET_SCHEDULER_shutdown ();
251 /*****************************************************************************/
252 /****************************** DISCONNECT PEERS *****************************/
253 /*****************************************************************************/
257 * Function to call with result of the TRANSPORT try disconnect request.
260 * @param result #GNUNET_OK if message was transmitted to transport service
261 * #GNUNET_SYSERR if message was not transmitted to transport service
264 transport_disconnect_cb (void *cls, const int result)
266 struct DisconnectionContext *dc = cls;
268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
269 "Peer disconnection request sent: %d,%d\n", dc->p1->index,
275 * Callback to be called when transport service connect operation is completed
277 * @param cls the callback closure from functions generating an operation
278 * @param op the operation that has been finished
279 * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
280 * @param emsg error message in case the operation has failed; will be NULL if
281 * operation has executed successfully.
284 transport_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
285 void *ca_result, const char *emsg)
287 struct DisconnectionContext *dc = cls;
288 struct GNUNET_TRANSPORT_Handle *transport = ca_result;
292 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg);
295 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transport_connect_cb().\n");
296 GNUNET_TRANSPORT_try_disconnect (transport, &dc->p2->peer_id,
297 &transport_disconnect_cb, dc);
302 * Callback from TRANSPORT service to ask if the given peer ID is blacklisted.
304 * @param cls closure, DisconnectionContext
305 * @param pid peer to approve or disapproave
306 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
309 blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *pid)
311 struct DisconnectionContext *dc = cls;
313 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&dc->p2->peer_id, pid))
314 return GNUNET_SYSERR;
320 * Adapter function called to establish a connection to transport service.
323 * @param cfg configuration of the peer to connect to; will be available until
324 * GNUNET_TESTBED_operation_done() is called on the operation returned
325 * from GNUNET_TESTBED_service_connect()
326 * @return service handle to return in 'op_result', NULL on error
329 transport_connect_adapter (void *cls,
330 const struct GNUNET_CONFIGURATION_Handle *cfg)
332 struct DisconnectionContext *dc = cls;
333 struct GNUNET_TRANSPORT_Handle *transport;
335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transport_connect_adapter().\n");
336 dc->blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_cb, dc);
337 GNUNET_assert (NULL != dc->blacklist);
338 transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL);
339 GNUNET_assert (NULL != transport);
345 * Adapter function called to destroy a connection to transport service.
348 * @param op_result service handle returned from the connect adapter
351 transport_disconnect_adapter (void *cls, void *op_result)
353 struct GNUNET_TRANSPORT_Handle *transport = op_result;
355 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transport_disconnect_adapter().\n");
356 GNUNET_TRANSPORT_disconnect (transport);
361 * Kill any connection between two peers. Has no effect if the peers are not
365 disconnect_peers (struct PeerInfo *p1, struct PeerInfo *p2)
367 struct DisconnectionContext *dc;
369 GNUNET_assert (p1 != p2);
370 dc = GNUNET_new (struct DisconnectionContext);
374 GNUNET_CONTAINER_DLL_insert (dc_head, dc_tail, dc);
375 dc->p1_transport_op =
376 GNUNET_TESTBED_service_connect (NULL, p1->testbed_peer, "transport",
377 &transport_connect_cb, dc,
378 &transport_connect_adapter,
379 &transport_disconnect_adapter, dc);
383 /*****************************************************************************/
384 /**************************** END DISCONNECT PEERS ***************************/
385 /*****************************************************************************/
389 * Function called with each file/folder inside a directory that is being copied.
391 * @param cls closure, destination directory
392 * @param filename complete filename (absolute path)
393 * @return #GNUNET_OK to continue to iterate.
394 * #GNUNET_SYSERR to abort iteration with error
397 copy_dir_scanner (void *cls, const char *filename)
403 GNUNET_asprintf (&dst, "%s%s%s", dst_dir, DIR_SEPARATOR_STR,
404 GNUNET_STRINGS_get_short_name (filename));
405 if (GNUNET_YES == GNUNET_DISK_directory_test (filename, GNUNET_YES))
406 copy_result = copy_dir (filename, dst);
409 if (GNUNET_YES == GNUNET_DISK_file_test (dst))
410 GNUNET_DISK_directory_remove (dst);
411 copy_result = GNUNET_DISK_file_copy (filename, dst);
412 if (GNUNET_OK == copy_result)
413 GNUNET_DISK_fix_permissions (dst, GNUNET_NO, GNUNET_NO);
421 * Copy directory recursively
423 * @param src Path to source directory
424 * @param dst Destination directory, will be created if it does not exist
425 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
428 copy_dir (const char *src, const char *dst)
430 if (GNUNET_YES != GNUNET_DISK_directory_test (src, GNUNET_YES))
431 return GNUNET_SYSERR;
432 if (GNUNET_OK != GNUNET_DISK_directory_create (dst))
433 return GNUNET_SYSERR;
435 GNUNET_DISK_directory_scan (src, ©_dir_scanner, (char *) dst))
436 return GNUNET_SYSERR;
442 * Function called with each file/folder inside source sensor directory.
444 * @param cls closure (unused)
445 * @param filename complete filename (absolute path)
446 * @return #GNUNET_OK to continue to iterate.
449 sensor_dir_scanner (void *cls, const char *filename)
451 const char *file_basename;
453 struct GNUNET_CONFIGURATION_Handle *sensor_cfg;
456 file_basename = GNUNET_STRINGS_get_short_name (filename);
457 GNUNET_asprintf (&dst_path, "%s%s%s", sensor_dst_dir, DIR_SEPARATOR_STR,
459 if (GNUNET_YES == GNUNET_DISK_directory_test (filename, GNUNET_NO))
461 GNUNET_assert (GNUNET_OK == copy_dir (filename, dst_path));
465 sensor_name = GNUNET_strdup (file_basename);
466 GNUNET_array_append (sensor_names, sensor_names_size, sensor_name);
467 sensor_cfg = GNUNET_CONFIGURATION_create ();
468 GNUNET_assert (GNUNET_OK ==
469 GNUNET_CONFIGURATION_parse (sensor_cfg, filename));
470 GNUNET_CONFIGURATION_set_value_string (sensor_cfg, file_basename,
472 GNUNET_i2s_full (&all_peers_info[0].
474 if (sensors_interval > 0)
476 GNUNET_CONFIGURATION_set_value_number (sensor_cfg, file_basename,
478 (unsigned long long int)
481 GNUNET_CONFIGURATION_write (sensor_cfg, dst_path);
482 GNUNET_CONFIGURATION_destroy (sensor_cfg);
484 GNUNET_free (dst_path);
490 * Load sensor definitions and rewrite them to tmp location.
491 * Add collection point peer id and change running interval if needed.
496 GNUNET_assert (GNUNET_YES ==
497 GNUNET_DISK_directory_test (sensor_src_dir, GNUNET_YES));
498 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_create (sensor_dst_dir));
499 GNUNET_DISK_directory_scan (sensor_src_dir, &sensor_dir_scanner, NULL);
504 * Callback to be called when dashboard service is started
506 * @param cls the callback closure from functions generating an operation
507 * @param op the operation that has been finished
508 * @param emsg error message in case the operation has failed; will be NULL if
509 * operation has executed successfully.
512 dashboard_started (void *cls, struct GNUNET_TESTBED_Operation *op,
517 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg);
520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dashboard service started.\n");
521 GNUNET_TESTBED_operation_done (op);
522 dashboard_service_started = GNUNET_YES;
527 * Function called by PEERSTORE for each matching record.
530 * @param record peerstore record information
531 * @param emsg error message, or NULL if no errors
532 * @return #GNUNET_YES to continue iterating, #GNUNET_NO to stop
535 peerstore_watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record,
538 struct PeerInfo *peer = cls;
539 struct GNUNET_SENSOR_DashboardAnomalyEntry *anomaly;
543 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg);
546 GNUNET_assert (record->value_size ==
547 sizeof (struct GNUNET_SENSOR_DashboardAnomalyEntry));
548 anomaly = record->value;
550 GNUNET_CRYPTO_cmp_peer_identity (&peer->peer_id,
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
553 "Anomaly report:{'peerid': '%s'," "'peer': %d," "'sensor': '%s',"
554 "'anomalous': %d," "'neighbors': %f}\n",
555 GNUNET_i2s (&peer->peer_id), peer->index, record->key,
556 anomaly->anomalous, anomaly->anomalous_neighbors);
562 * Callback to be called when peerstore service connect operation is completed
564 * @param cls the callback closure from functions generating an operation
565 * @param op the operation that has been finished
566 * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
567 * @param emsg error message in case the operation has failed; will be NULL if
568 * operation has executed successfully.
571 peerstore_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
572 void *ca_result, const char *emsg)
576 struct PeerInfo *peer;
580 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg);
583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peerstore service.\n");
584 /* Watch for anomaly reports from other peers */
585 for (i = 0; i < num_peers; i++)
587 peer = &all_peers_info[i];
588 for (j = 0; j < sensor_names_size; j++)
590 GNUNET_PEERSTORE_watch (peerstore, "sensordashboard-anomalies",
591 &peer->peer_id, sensor_names[j],
592 &peerstore_watch_cb, peer);
599 * Adapter function called to establish a connection to peerstore service.
602 * @param cfg configuration of the peer to connect to; will be available until
603 * GNUNET_TESTBED_operation_done() is called on the operation returned
604 * from GNUNET_TESTBED_service_connect()
605 * @return service handle to return in 'op_result', NULL on error
608 peerstore_connect_adapter (void *cls,
609 const struct GNUNET_CONFIGURATION_Handle *cfg)
611 peerstore = GNUNET_PEERSTORE_connect (cfg);
612 GNUNET_assert (NULL != peerstore);
618 * Adapter function called to destroy a connection to peerstore service.
621 * @param op_result service handle returned from the connect adapter
624 peerstore_disconnect_adapter (void *cls, void *op_result)
626 GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO);
633 * Prompt the user to disconnect two peers
636 prompt_peer_disconnection ()
642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
643 "Disconnect peers (e.g. '0,2') or empty line to execute:\n");
644 if (NULL == fgets (line, sizeof (line), stdin) || 1 == strlen (line))
646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing.\n");
649 if (2 != sscanf (line, "%d,%d", &p1, &p2) || p1 >= num_peers ||
650 p2 >= num_peers || p1 < 0 || p2 < 0 || p1 == p2)
652 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Invalid input.\n");
653 prompt_peer_disconnection ();
656 disconnect_peers (&all_peers_info[p1], &all_peers_info[p2]);
657 prompt_peer_disconnection ();
662 * This function is called after the estimated training period is over.
665 simulate_anomalies (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
667 delayed_task = GNUNET_SCHEDULER_NO_TASK;
668 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
669 "Training period over, simulating anomalies now.\n");
670 prompt_peer_disconnection ();
675 * This function is called after a delay which ensures that all peers are
676 * properly initialized
679 peers_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
681 unsigned long long int training_points;
682 struct GNUNET_TIME_Relative training_period;
684 delayed_task = GNUNET_SCHEDULER_NO_TASK;
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers are ready.\n");
686 GNUNET_assert (GNUNET_OK ==
687 GNUNET_CONFIGURATION_get_value_number (cfg,
688 "sensor-model-gaussian",
692 GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_multiply
693 (GNUNET_TIME_UNIT_SECONDS,
695 0) ? 60 : sensors_interval),
697 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
698 "Sleeping for a training period of %s.\n",
699 GNUNET_STRINGS_relative_time_to_string (training_period,
702 GNUNET_SCHEDULER_add_delayed (training_period, &simulate_anomalies, NULL);
707 * Callback to be called when sensor service is started
709 * @param cls the callback closure from functions generating an operation
710 * @param op the operation that has been finished
711 * @param emsg error message in case the operation has failed; will be NULL if
712 * operation has executed successfully.
715 sensor_service_started (void *cls, struct GNUNET_TESTBED_Operation *op,
718 struct PeerInfo *peer = cls;
722 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg);
725 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sensor service started on peer `%s'.\n",
726 GNUNET_i2s (&peer->peer_id));
727 GNUNET_TESTBED_operation_done (op);
728 sensor_services_started++;
729 if (sensor_services_started == num_peers)
732 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
733 (PEER_STARTUP_TIME, num_peers),
740 * Callback to be called when the requested peer information is available
742 * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
743 * @param op the operation this callback corresponds to
744 * @param pinfo the result; will be NULL if the operation has failed
745 * @param emsg error message if the operation has failed; will be NULL if the
746 * operation is successfull
749 peer_info_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
750 const struct GNUNET_TESTBED_PeerInformation *pinfo,
753 struct GNUNET_TESTBED_Peer *testbed_peer = cb_cls;
754 struct PeerInfo *peer = &all_peers_info[peers_known];
758 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg);
761 peer->testbed_peer = testbed_peer;
762 GNUNET_CRYPTO_get_peer_identity (pinfo->result.cfg, &peer->peer_id);
763 peer->index = peers_known;
765 if (1 == peers_known) /* First peer is collection point */
767 /* Rewrite sensors */
769 /* Start dashboard */
770 GNUNET_TESTBED_peer_manage_service (NULL, testbed_peer, "sensordashboard",
771 &dashboard_started, NULL, 1);
773 /* Start sensor service on every peer */
774 GNUNET_TESTBED_peer_manage_service (NULL, testbed_peer, "sensor",
775 &sensor_service_started, peer, 1);
776 if (num_peers == peers_known) /* Last peer */
778 /* Connect to peerstore on first peer (collection point) */
780 GNUNET_TESTBED_service_connect (NULL, all_peers_info[0].testbed_peer,
781 "peerstore", &peerstore_connect_cb,
782 NULL, &peerstore_connect_adapter,
783 &peerstore_disconnect_adapter, NULL);
785 GNUNET_TESTBED_operation_done (op);
790 * Signature of a main function for a testcase.
793 * @param h the run handle
794 * @param num number of peers in 'peers'
795 * @param peers handle to peers run in the testbed. NULL upon timeout (see
796 * GNUNET_TESTBED_test_run()).
797 * @param links_succeeded the number of overlay link connection attempts that
799 * @param links_failed the number of overlay link connection attempts that
801 * @see GNUNET_TESTBED_test_run()
804 test_master (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num,
805 struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded,
806 unsigned int links_failed)
810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
811 "%d peers started. %d links succeeded. %d links failed.\n",
812 num_peers, links_succeeded, links_failed);
813 GNUNET_assert (num == num_peers);
814 GNUNET_assert (0 == links_failed);
815 /* Collect peer information */
816 all_peers_info = GNUNET_new_array (num_peers, struct PeerInfo);
818 for (i = 0; i < num_peers; i++)
820 GNUNET_TESTBED_peer_get_information (peers[i],
821 GNUNET_TESTBED_PIT_CONFIGURATION,
822 &peer_info_cb, peers[i]);
828 * Verify that the user passed correct CL args
830 * @return #GNUNET_OK if arguments are valid, #GNUNET_SYSERR otherwise
837 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
839 ("Invalid or missing number of peers. Set at least 2 peers.\n"));
840 return GNUNET_SYSERR;
842 if (NULL == topology_file ||
843 GNUNET_YES != GNUNET_DISK_file_test (topology_file))
845 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
846 _("Missing or invalid topology file.\n"));
847 return GNUNET_SYSERR;
854 * Actual main function.
857 * @param args remaining args, unused
858 * @param cfgfile name of the configuration
859 * @param cfg configuration handle
862 run (void *cls, char *const *args, const char *cf,
863 const struct GNUNET_CONFIGURATION_Handle *c)
865 if (GNUNET_OK != verify_args ())
867 do_shutdown (NULL, NULL);
870 cfg = GNUNET_CONFIGURATION_create ();
871 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, cfg_filename));
872 GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle *)
874 "OVERLAY_TOPOLOGY_FILE",
877 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown,
879 GNUNET_TESTBED_run (NULL, cfg, num_peers, 0, NULL, NULL, &test_master, NULL);
886 * @return 0 on success
889 main (int argc, char *const *argv)
891 static struct GNUNET_GETOPT_CommandLineOption options[] = {
892 {'p', "peers", "COUNT", gettext_noop ("Number of peers to run"), GNUNET_YES,
893 &GNUNET_GETOPT_set_uint, &num_peers},
894 {'t', "topology-file", "FILEPATH", gettext_noop ("Path to topology file"),
895 GNUNET_YES, &GNUNET_GETOPT_set_filename, &topology_file},
896 {'i', "sensors-interval", "INTERVAL",
897 gettext_noop ("Change the interval or running sensors to given value"),
898 GNUNET_YES, &GNUNET_GETOPT_set_uint, &sensors_interval},
899 GNUNET_GETOPT_OPTION_END
903 GNUNET_PROGRAM_run (argc, argv, "gnunet-sensor-profiler",
904 gettext_noop ("Profiler for sensor service"),
905 options, &run, NULL)) ? 0 : 1;
908 /* end of gnunet-sensor-profiler.c */