GNUnet  0.10.x
gnunet-nse-profiler.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2011, 2012 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19 */
32 #include "platform.h"
33 #include "gnunet_testbed_service.h"
34 #include "gnunet_nse_service.h"
35 
39 #define LOG(kind,...) \
40  GNUNET_log (kind, __VA_ARGS__)
41 
45 #define LOG_DEBUG(...) \
46  LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
47 
48 
52 struct NSEPeer
53 {
57  struct NSEPeer *prev;
58 
62  struct NSEPeer *next;
63 
68 
73 
78 
83 };
84 
85 
90 {
94  struct OpListEntry *next;
95 
99  struct OpListEntry *prev;
100 
105 
110  int delta;
111 };
112 
113 
117 static struct NSEPeer *peer_head;
118 
122 static struct NSEPeer *peer_tail;
123 
127 static int ok;
128 
132 static unsigned int verbose;
133 
137 static char *hosts_file;
138 
142 static unsigned int num_peers;
143 
147 static unsigned int num_rounds;
148 
152 static unsigned int current_round;
153 
157 static unsigned int *num_peers_in_round;
158 
162 static unsigned int peers_running;
163 
167 static char *num_peer_spec;
168 
172 static struct GNUNET_TESTBED_Peer **daemons;
173 
178 
182 static unsigned int connection_limit;
183 
187 static unsigned int total_connections;
188 
193 
197 static char *output_filename;
198 
203 
207 static char *data_filename;
208 
213 static struct GNUNET_TIME_Relative wait_time = { 60 * 1000 };
214 
218 static struct OpListEntry *oplist_head;
219 
223 static struct OpListEntry *oplist_tail;
224 
229 
230 
235 static void
237 {
238  struct NSEPeer *pos;
239  struct OpListEntry *oplist_entry;
240 
241  while (NULL != (pos = peer_head))
242  {
243  if (NULL != pos->nse_op)
245  if (NULL != pos->stat_op)
247  GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos);
248  GNUNET_free (pos);
249  }
250  while (NULL != (oplist_entry = oplist_head))
251  {
252  GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, oplist_entry);
253  GNUNET_TESTBED_operation_done (oplist_entry->op);
254  GNUNET_free (oplist_entry);
255  }
256 }
257 
258 
264 static void
265 shutdown_task (void *cls)
266 {
267  LOG_DEBUG ("Ending test.\n");
269  if (NULL != round_task)
270  {
271  GNUNET_SCHEDULER_cancel (round_task);
272  round_task = NULL;
273  }
274  if (NULL != data_file)
275  {
276  GNUNET_DISK_file_close (data_file);
277  data_file = NULL;
278  }
279  if (NULL != output_file)
280  {
281  GNUNET_DISK_file_close (output_file);
282  output_file = NULL;
283  }
284  if (NULL != testing_cfg)
285  {
286  GNUNET_CONFIGURATION_destroy (testing_cfg);
287  testing_cfg = NULL;
288  }
289 }
290 
291 
301 static void
302 handle_estimate (void *cls,
303  struct GNUNET_TIME_Absolute timestamp,
304  double estimate, double std_dev)
305 {
306  struct NSEPeer *peer = cls;
307  char output_buffer[512];
308  size_t size;
309 
310  if (NULL == output_file)
311  {
312  FPRINTF (stderr,
313  "Received network size estimate from peer %p. Size: %f std.dev. %f\n",
314  peer, estimate, std_dev);
315  return;
316  }
317  size = GNUNET_snprintf (output_buffer,
318  sizeof (output_buffer),
319  "%p %llu %llu %f %f %f\n",
320  peer, peers_running,
321  (unsigned long long) timestamp.abs_value_us,
322  GNUNET_NSE_log_estimate_to_n (estimate), estimate,
323  std_dev);
324  if (size != GNUNET_DISK_file_write (output_file, output_buffer, size))
326  "Unable to write to file!\n");
327 }
328 
329 
340 static void *
342  const struct GNUNET_CONFIGURATION_Handle *cfg)
343 {
344  struct NSEPeer *current_peer = cls;
345 
346  return GNUNET_NSE_connect (cfg, &handle_estimate, current_peer);
347 }
348 
349 
357 static void
359  void *op_result)
360 {
361  GNUNET_NSE_disconnect (op_result);
362 }
363 
364 
375 static int
376 stat_iterator (void *cls,
377  const char *subsystem,
378  const char *name,
379  uint64_t value,
380  int is_persistent)
381 {
382  char *output_buffer;
383  struct GNUNET_TIME_Absolute now;
384  int size;
385  unsigned int flag;
386 
387  GNUNET_assert (NULL != data_file);
388  now = GNUNET_TIME_absolute_get ();
389  flag = strcasecmp (subsystem, "core");
390  if (0 != flag)
391  flag = 1;
392  size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n",
393  now.abs_value_us / 1000LL / 1000LL,
394  value, flag);
395  if (0 > size)
396  {
397  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Error formatting output buffer.\n");
398  GNUNET_free (output_buffer);
399  return GNUNET_SYSERR;
400  }
401  if (size != GNUNET_DISK_file_write (data_file, output_buffer, (size_t) size))
402  {
403  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
404  GNUNET_free (output_buffer);
405  return GNUNET_SYSERR;
406  }
407  GNUNET_free (output_buffer);
408  return GNUNET_OK;
409 }
410 
411 
421 static void *
423  const struct GNUNET_CONFIGURATION_Handle *cfg)
424 {
425  struct NSEPeer *peer = cls;
426 
427  peer->sh = GNUNET_STATISTICS_create ("nse-profiler", cfg);
428  return peer->sh;
429 }
430 
431 
438 static void
440 {
441  struct NSEPeer *peer = cls;
442 
444  (peer->sh, "core", "# peers connected",
445  stat_iterator, peer));
447  (peer->sh, "nse", "# peers connected",
448  stat_iterator, peer));
450  peer->sh = NULL;
451 }
452 
453 
464 static void
466  void *ca_result, const char *emsg )
467 {
468  struct GNUNET_STATISTICS_Handle *sh = ca_result;
469  struct NSEPeer *peer = cls;
470 
471  if (NULL != emsg)
472  {
473  GNUNET_break (0);
474  return;
475  }
477  (sh, "core", "# peers connected",
478  stat_iterator, peer));
480  (sh, "nse", "# peers connected",
481  stat_iterator, peer));
482 }
483 
484 
489 static void
491 {
492  struct NSEPeer *current_peer;
493  unsigned int i;
494  unsigned int connections;
495 
496  if (0 == connection_limit)
497  return;
498  LOG_DEBUG ("Connecting to nse service of peers\n");
499  connections = 0;
500  for (i = 0; i < num_peers_in_round[current_round]; i++)
501  {
502  if ((num_peers_in_round[current_round] > connection_limit) &&
503  (0 != (i % (num_peers_in_round[current_round] / connection_limit))))
504  continue;
505  LOG_DEBUG ("Connecting to nse service of peer %d\n", i);
506  current_peer = GNUNET_new (struct NSEPeer);
507  current_peer->daemon = daemons[i];
508  current_peer->nse_op
510  current_peer->daemon,
511  "nse",
512  NULL, NULL,
515  current_peer);
516  if (NULL != data_file)
517  current_peer->stat_op
519  current_peer->daemon,
520  "statistics",
521  stat_comp_cb,
522  current_peer,
525  current_peer);
526  GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer);
527  if (++connections == connection_limit)
528  break;
529  }
530 }
531 
532 
538 static void
539 next_round (void *cls);
540 
541 
549 static void
550 finish_round (void *cls)
551 {
553  "Have %u connections\n",
556  round_task = GNUNET_SCHEDULER_add_now (&next_round, NULL);
557 }
558 
559 
565 static void
567 {
568  LOG_DEBUG ("Running round %u\n",
569  current_round);
571  GNUNET_SCHEDULER_add_delayed (wait_time,
572  &finish_round,
573  NULL);
574 }
575 
576 
580 static struct OpListEntry *
582 {
583  struct OpListEntry *entry;
584 
585  entry = GNUNET_new (struct OpListEntry);
587  oplist_tail,
588  entry);
589  return entry;
590 }
591 
592 
600 static void
601 manage_service_cb (void *cls,
603  const char *emsg)
604 {
605  struct OpListEntry *entry = cls;
606 
608  if (NULL != emsg)
609  {
610  LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop NSE at a peer\n");
612  return;
613  }
614  GNUNET_assert (0 != entry->delta);
615  peers_running += entry->delta;
616  GNUNET_CONTAINER_DLL_remove (oplist_head,
617  oplist_tail,
618  entry);
619  GNUNET_free (entry);
621  run_round ();
622 }
623 
624 
629 static void
631 {
632  struct OpListEntry *entry;
633  unsigned int i;
634 
635  /* start peers if we have too few */
637  {
638  entry = make_oplist_entry ();
639  entry->delta = 1;
640  entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
641  daemons[i],
642  "nse",
644  entry,
645  1);
646  }
647  /* stop peers if we have too many */
648  for (i=num_peers_in_round[current_round];i<peers_running;i++)
649  {
650  entry = make_oplist_entry ();
651  entry->delta = -1;
652  entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
653  daemons[i],
654  "nse",
656  entry,
657  0);
658  }
659 }
660 
661 
668 static void
669 next_round (void *cls)
670 {
671  round_task = NULL;
672  LOG_DEBUG ("Disconnecting nse service of peers\n");
673  current_round++;
674  if (current_round == num_rounds)
675  {
676  /* this was the last round, terminate */
677  ok = 0;
679  return;
680  }
682  {
683  /* no need to churn, just run next round */
684  run_round ();
685  return;
686  }
688 }
689 
690 
698 static void
700  const struct GNUNET_TESTBED_EventInformation *event)
701 {
702  switch (event->type)
703  {
706  break;
709  break;
710  default:
711  break;
712  }
713 }
714 
715 
729 static void
730 test_master (void *cls,
731  struct GNUNET_TESTBED_RunHandle *h,
732  unsigned int num_peers_,
733  struct GNUNET_TESTBED_Peer **peers,
734  unsigned int links_succeeded,
735  unsigned int links_failed)
736 {
737  if (NULL == peers)
738  {
740  return;
741  }
742  daemons = peers;
743  GNUNET_break (num_peers_ == num_peers);
746  {
747  /* no need to churn, just run the starting round */
748  run_round ();
749  return;
750  }
752 }
753 
754 
763 static void
764 run (void *cls, char *const *args, const char *cfgfile,
765  const struct GNUNET_CONFIGURATION_Handle *cfg)
766 {
767  char *tok;
768  uint64_t event_mask;
769  unsigned int num;
770 
771  ok = 1;
772  testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
773  LOG_DEBUG ("Starting daemons.\n");
774  if (NULL == num_peer_spec)
775  {
776  fprintf (stderr, "You need to specify the number of peers to run\n");
777  return;
778  }
779  for (tok = strtok (num_peer_spec, ","); NULL != tok; tok = strtok (NULL, ","))
780  {
781  if (1 != sscanf (tok, "%u", &num))
782  {
783  fprintf (stderr, "You need to specify numbers, not `%s'\n", tok);
784  return;
785  }
786  if (0 == num)
787  {
788  fprintf (stderr, "Refusing to run a round with 0 peers\n");
789  return;
790  }
792  num_peers = GNUNET_MAX (num_peers, num);
793  }
794  if (0 == num_peers)
795  {
796  fprintf (stderr, "Refusing to run a testbed with no rounds\n");
797  return;
798  }
799  if ( (NULL != data_filename) &&
800  (NULL == (data_file =
808  "open",
809  data_filename);
810 
811  if ( (NULL != output_filename) &&
812  (NULL == (output_file =
820  event_mask = 0LL;
821  event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
822  event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
823  event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
824  event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
826  cfg,
827  num_peers,
828  event_mask,
830  NULL, /* master_controller_cb cls */
831  &test_master,
832  NULL); /* test_master cls */
834 }
835 
836 
842 int
843 main (int argc, char *const *argv)
844 {
845  struct GNUNET_GETOPT_CommandLineOption options[] = {
847  "connections",
848  "COUNT",
849  gettext_noop ("limit to the number of connections to NSE services, 0 for none"),
852  "details",
853  "FILENAME",
854  gettext_noop ("name of the file for writing connection information and statistics"),
855  &data_filename),
856 
858  "hosts",
859  "FILENAME",
860  gettext_noop ("name of the file with the login information for the testbed"),
861  &hosts_file),
862 
864  "output",
865  "FILENAME",
866  gettext_noop ("name of the file for writing the main results"),
867  &output_filename),
868 
869 
871  "peers",
872  "NETWORKSIZESPEC",
873  gettext_noop ("Number of peers to run in each round, separated by commas"),
874  &num_peer_spec),
875 
877  "verbose",
878  gettext_noop ("be verbose (print progress information)"),
879  &verbose),
880 
882  "wait",
883  "DELAY",
884  gettext_noop ("delay between rounds"),
885  &wait_time),
887  };
888  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
889  return 2;
890  if (GNUNET_OK !=
891  GNUNET_PROGRAM_run (argc, argv, "nse-profiler",
893  ("Measure quality and performance of the NSE service."),
894  options, &run, NULL))
895  ok = 1;
896  return ok;
897 }
898 
899 /* end of nse-profiler.c */
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_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void close_monitor_connections()
Clean up all of the monitoring connections to NSE and STATISTICS that we keep to selected peers...
static void next_round(void *cls)
Task that starts/stops peers to move to the next round.
struct OpListEntry * prev
DLL prev ptr.
Create file if it doesn&#39;t exist.
struct NSEPeer * next
Next reference in DLL.
static char * subsystem
Set to subsystem that we&#39;re going to get stats for (or NULL for all).
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1817
static struct GNUNET_TESTBED_Peer ** daemons
Handles to all of the running peers.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
#define FPRINTF
Definition: plibc.h:683
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1521
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_increment_uint(char shortName, const char *name, const char *description, unsigned int *val)
Increment val each time the option flag is given by one.
static unsigned int current_round
Current round we are in.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int op_result(struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx, uint8_t cancel)
Remove an operation, and call its result callback (unless it was cancelled).
Definition: op.c:244
struct GNUNET_NSE_Handle * GNUNET_NSE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_Callback func, void *func_cls)
Connect to the network size estimation service.
Definition: nse_api.c:165
static struct NSEPeer * peer_head
Head of DLL of peers we monitor closely.
static void * stat_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Called to open a connection to the peer&#39;s statistics.
static int ok
Return value from &#39;main&#39; (0 == success)
Argument to GNUNET_TESTBED_ControllerCallback with details about the event.
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers_, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_DISK_FileHandle * data_file
File to log connection info, statistics to.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
enum GNUNET_TESTBED_EventType type
Type of the event.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
static char * hosts_file
Name of the file with the hosts to run the test over (configuration option)
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
Handle for the service.
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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 OpListEntry * make_oplist_entry()
Creates an oplist entry and adds it to the oplist DLL.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
Opaque handle to an abstract operation to be executed by the testing framework.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
static struct OpListEntry * oplist_head
DLL head for operation list.
struct GNUNET_TESTBED_Operation * nse_op
Testbed operation to connect to NSE service.
static void shutdown_task(void *cls)
Task run on shutdown; cleans up everything.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
struct NSEPeer * prev
Prev reference in DLL.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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:1246
Information we track for a peer in the testbed.
static struct OpListEntry * oplist_tail
DLL tail for operation list.
static void handle_estimate(void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev)
Callback to call when network size estimate is updated.
struct GNUNET_TESTBED_Peer * daemon
Handle with testbed.
static char * value
Value of the record to add/remove.
static struct GNUNET_SCHEDULER_Task * round_task
Task running each round of the experiment.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static unsigned int num_peers
Maximum number of peers in the test.
Truncate file if it exists.
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:1049
#define GNUNET_MAX(a, b)
Definition: gnunet_common.h:85
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:1273
static char * data_filename
Filename to log connection info, statistics to.
Operation map entry.
static struct NSEPeer * peer_tail
Tail of DLL of peers we monitor closely.
static unsigned int verbose
Be verbose (configuration option)
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static unsigned int total_connections
Total number of connections in the whole network.
static struct GNUNET_TIME_Relative wait_time
How long to wait before triggering next round? Default: 60 s.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2046
static struct GNUNET_CONFIGURATION_Handle * testing_cfg
Global configuration file.
void GNUNET_TESTBED_run(const char *host_filename, const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a testbed with a single call.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
A connection between two peers was torn down.
static unsigned int connection_limit
Maximum number of connections to NSE services.
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
Definition: nse_api.c:193
static void finish_round(void *cls)
We&#39;re at the end of a round.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint64_t event_mask
Global event mask for all testbed events.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
const char * name
static void adjust_running_peers()
Adjust the number of running peers to match the required number of running peers for the round...
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static void stat_comp_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Called after successfully opening a connection to a peer&#39;s statistics service; we register statistics...
A connection between two peers was established.
int delta
Depending on whether we start or stop NSE service at the peer set this to 1 or -1.
static unsigned int num_rounds
Total number of rounds to execute.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
struct GNUNET_STATISTICS_Handle * sh
Handle to the statistics service.
static unsigned int * num_peers_in_round
Array of size &#39;num_rounds&#39; with the requested number of peers in the given round. ...
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
int GNUNET_STATISTICS_watch_cancel(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Iterator proc, void *proc_cls)
Stop watching statistics from the peer.
int main(int argc, char *const *argv)
Main function.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Actual main function that runs the emulation.
#define LOG(kind,...)
Generic loggins shorthand.
configuration data
Definition: configuration.c:85
static void nse_disconnect_adapter(void *cls, void *op_result)
Adapter function called to destroy a connection to NSE service.
static struct CadetPeer * peers
Operation to get peer ids.
static char * num_peer_spec
Specification for the numbers of peers to have in each round.
int GNUNET_STATISTICS_watch(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Iterator proc, void *proc_cls)
Watch statistics from the peer (be notified whenever they change).
static void connect_nse_service()
Task run to connect to the NSE and statistics services to a subset of all of the running peers...
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
static int stat_iterator(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values.
Open the file for both reading and writing.
static void run_round()
We have reached the desired number of peers for the current round.
int GNUNET_PROGRAM_run(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, parse options).
Definition: program.c:361
static void manage_service_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback to be called when NSE service is started or stopped at peers.
Time for absolute times used by GNUnet, in microseconds.
static void * nse_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Adapter function called to establish a connection to NSE service.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
A peer controlled by the testing framework.
A peer has been stopped.
static unsigned int peers_running
How many peers are running right now?
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_manage_service(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, unsigned int start)
Start or stop given service at a peer.
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:1673
#define GNUNET_NSE_log_estimate_to_n(loge)
Convert the logarithmic estimated returned to the &#39;GNUNET_NSE_Callback&#39; into an absolute estimate in ...
struct GNUNET_TESTBED_Operation * stat_op
Testbed operation to connect to statistics service.
Handle used to access files (and pipes).
struct OpListEntry * next
DLL next ptr.
struct GNUNET_TESTBED_Operation * op
The testbed operation.
#define LOG_DEBUG(...)
Debug logging shorthand.
static struct GNUNET_DISK_FileHandle * output_file
File to report results to.
static void stat_disconnect_adapter(void *cls, void *op_result)
Called to disconnect from peer&#39;s statistics service.
static char * output_filename
Filename to log results to.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965