GNUnet  0.11.x
Functions | Variables
gnunet-consensus-profiler.c File Reference

profiling tool for gnunet-consensus More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_time_lib.h"
#include "gnunet_consensus_service.h"
#include "gnunet_testbed_service.h"
Include dependency graph for gnunet-consensus-profiler.c:

Go to the source code of this file.

Functions

static void controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Signature of the event handler function called by the respective event controller. More...
 
static void statistics_done_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 
static int statistics_cb (void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Callback function to process statistic values from all peers. More...
 
static void destroy (void *cls)
 
static void conclude_cb (void *cls)
 Called when a conclusion was successful. More...
 
static void generate_indices (int *indices)
 
static void do_consensus ()
 
static void connect_complete (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 Callback to be called when a service connect operation is completed. More...
 
static void new_element_cb (void *cls, const struct GNUNET_SET_Element *element)
 
static void * connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Adapter function called to establish a connection to a service. More...
 
static void disconnect_adapter (void *cls, void *op_result)
 Adapter function called to destroy a connection to a service. More...
 
static void peer_info_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
 Callback to be called when the requested peer information is available. More...
 
static void test_master (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **started_peers, unsigned int links_succeeded, unsigned int links_failed)
 Signature of a main function for a testcase. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
int main (int argc, char **argv)
 

Variables

static unsigned int num_peers = 2
 
static unsigned int replication = 1
 
static unsigned int num_values = 5
 
static struct GNUNET_TIME_Relative conclude_timeout
 
static struct GNUNET_TIME_Relative consensus_delay
 
static struct GNUNET_CONSENSUS_Handle ** consensus_handles
 
static struct GNUNET_TESTBED_Operation ** testbed_operations
 
static unsigned int num_connected_handles
 
static struct GNUNET_TESTBED_Peer ** peers
 
static struct GNUNET_PeerIdentitypeer_ids
 
static unsigned int num_retrieved_peer_ids
 
static struct GNUNET_HashCode session_id
 
static unsigned int peers_done = 0
 
static int dist_static
 
static unsigned * results_for_peer
 
static char * statistics_filename
 The profiler will write statistics for all peers to the file with this name. More...
 
static FILE * statistics_file
 The profiler will write statistics for all peers to this file. More...
 
static int verbose
 
static struct GNUNET_TIME_Absolute start
 Start time for all consensuses. More...
 
static struct GNUNET_TIME_Absolute deadline
 Deadline for all consensuses. More...
 

Detailed Description

profiling tool for gnunet-consensus

Author
Florian Dold

Definition in file gnunet-consensus-profiler.c.

Function Documentation

◆ controller_cb()

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

Signature of the event handler function called by the respective event controller.

Parameters
clsclosure
eventinformation about the event

Definition at line 95 of file gnunet-consensus-profiler.c.

References GNUNET_assert.

Referenced by run().

97 {
98  GNUNET_assert (0);
99 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Here is the caller graph for this function:

◆ statistics_done_cb()

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

Definition at line 103 of file gnunet-consensus-profiler.c.

References GNUNET_assert, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_operation_done(), and statistics_file.

Referenced by destroy().

108 {
109  GNUNET_assert (NULL == emsg);
111  if (NULL != statistics_file)
112  fclose (statistics_file);
113  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "got statistics, shutting down\n");
115 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
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:2044
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ statistics_cb()

static int statistics_cb ( void *  cls,
const struct GNUNET_TESTBED_Peer peer,
const char *  subsystem,
const char *  name,
uint64_t  value,
int  is_persistent 
)
static

Callback function to process statistic values from all peers.

Parameters
clsclosure
peerthe peer the statistic belong to
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 130 of file gnunet-consensus-profiler.c.

References GNUNET_OK, GNUNET_TESTBED_get_index(), and statistics_file.

Referenced by destroy().

136 {
137  if (NULL != statistics_file)
138  {
139  fprintf (statistics_file, "P%u\t%s\t%s\t%lu\n", GNUNET_TESTBED_get_index (
140  peer), subsystem, name, (unsigned long) value);
141  }
142  return GNUNET_OK;
143 }
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
const char * name
uint32_t GNUNET_TESTBED_get_index(const struct GNUNET_TESTBED_Peer *peer)
Return the index of the peer inside of the total peer array, aka.
Definition: testbed_api.c:2321
Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy()

static void destroy ( void *  cls)
static

Definition at line 147 of file gnunet-consensus-profiler.c.

References GNUNET_CONSENSUS_destroy(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_TESTBED_get_statistics(), GNUNET_TESTBED_operation_done(), num_peers, num_values, peers_done, results_for_peer, statistics_cb(), statistics_done_cb(), statistics_file, and statistics_filename.

Referenced by conclude_cb(), GNUNET_MQ_queue_for_callbacks(), and GNUNET_SERVER_set_callbacks().

148 {
149  struct GNUNET_CONSENSUS_Handle *consensus = cls;
150 
152  "destroying consensus\n");
153  GNUNET_CONSENSUS_destroy (consensus);
154  peers_done++;
155  if (peers_done == num_peers)
156  {
157  unsigned int i;
158  for (i = 0; i < num_peers; i++)
160  for (i = 0; i < num_peers; i++)
161  printf ("P%u got %u of %u elements\n",
162  i,
163  results_for_peer[i],
164  num_values);
165  if (NULL != statistics_filename)
166  statistics_file = fopen (statistics_filename, "w");
167  GNUNET_TESTBED_get_statistics (num_peers, peers, NULL, NULL,
170  NULL);
171  }
172 }
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_get_statistics(unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, const char *subsystem, const char *name, GNUNET_TESTBED_StatisticsIterator proc, GNUNET_TESTBED_OperationCompletionCallback cont, void *cls)
Convenience method that iterates over all (running) peers and retrieves all statistics from each peer...
void GNUNET_CONSENSUS_destroy(struct GNUNET_CONSENSUS_Handle *consensus)
Destroy a consensus handle (free all state associated with it, no longer call any of the callbacks)...
static int statistics_cb(void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values from all peers.
static unsigned * results_for_peer
static unsigned int num_values
static void statistics_done_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
static char * statistics_filename
The profiler will write statistics for all peers to the file with this name.
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
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:2044
static struct GNUNET_TESTBED_Operation ** testbed_operations
static struct GNUNET_TESTBED_Peer ** peers
static unsigned int num_peers
static unsigned int peers_done
#define GNUNET_log(kind,...)
Handle for the service.
Definition: consensus_api.c:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ conclude_cb()

static void conclude_cb ( void *  cls)
static

Called when a conclusion was successful.

Parameters
clsclosure, the consensus handle
Returns
GNUNET_YES if more consensus groups should be offered, GNUNET_NO if not

Definition at line 183 of file gnunet-consensus-profiler.c.

References destroy(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, and GNUNET_SCHEDULER_add_now().

Referenced by do_consensus().

184 {
185  struct GNUNET_CONSENSUS_Handle **chp = cls;
186 
188  "consensus %d done\n",
189  (int) (chp - consensus_handles));
191 }
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:1280
#define GNUNET_log(kind,...)
Handle for the service.
Definition: consensus_api.c:40
static struct GNUNET_CONSENSUS_Handle ** consensus_handles
static void destroy(void *cls)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_indices()

static void generate_indices ( int *  indices)
static

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

References GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_NO, GNUNET_YES, num_peers, and replication.

Referenced by do_consensus().

196 {
197  int j;
198 
199  j = 0;
200  while (j < replication)
201  {
202  int n;
203  int k;
204  int repeat;
206  repeat = GNUNET_NO;
207  for (k = 0; k < j; k++)
208  if (indices[k] == n)
209  {
210  repeat = GNUNET_YES;
211  break;
212  }
213  if (GNUNET_NO == repeat)
214  indices[j++] = n;
215  }
216 }
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
static unsigned int replication
#define GNUNET_NO
Definition: gnunet_common.h:78
static unsigned int num_peers
#define GNUNET_YES
Definition: gnunet_common.h:77
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_consensus()

static void do_consensus ( )
static

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

References conclude_cb(), GNUNET_SET_Element::data, dist_static, generate_indices(), GNUNET_CONSENSUS_conclude(), GNUNET_CONSENSUS_insert(), GNUNET_CRYPTO_hash_create_random(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ERROR_TYPE_INFO, GNUNET_log, num_peers, num_values, replication, and GNUNET_SET_Element::size.

Referenced by connect_complete().

221 {
222  int unique_indices[replication];
223  unsigned int i;
224  unsigned int j;
225  struct GNUNET_HashCode val;
226  struct GNUNET_SET_Element element;
227 
228  if (dist_static)
229  {
230  for (i = 0; i < num_values; i++)
231  {
233 
234  element.data = &val;
235  element.size = sizeof(val);
236  for (j = 0; j < replication; j++)
237  {
239  &element,
240  NULL, NULL);
241  }
242  }
243  }
244  else
245  {
246  for (i = 0; i < num_values; i++)
247  {
248  generate_indices (unique_indices);
250 
251  element.data = &val;
252  element.size = sizeof(val);
253  for (j = 0; j < replication; j++)
254  {
255  int cid;
256 
257  cid = unique_indices[j];
259  &element,
260  NULL, NULL);
261  }
262  }
263  }
264 
266  "all elements inserted, calling conclude\n");
267 
268  for (i = 0; i < num_peers; i++)
271 }
Element stored in a set.
static unsigned int replication
void GNUNET_CONSENSUS_insert(struct GNUNET_CONSENSUS_Handle *consensus, const struct GNUNET_SET_Element *element, GNUNET_CONSENSUS_InsertDoneCallback idc, void *idc_cls)
Insert an element in the set being reconsiled.
static unsigned int num_values
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
Definition: crypto_hash.c:144
static void conclude_cb(void *cls)
Called when a conclusion was successful.
static void generate_indices(int *indices)
A 512-bit hashcode.
static int dist_static
static unsigned int num_peers
#define GNUNET_log(kind,...)
void GNUNET_CONSENSUS_conclude(struct GNUNET_CONSENSUS_Handle *consensus, GNUNET_CONSENSUS_ConcludeCallback conclude, void *conclude_cls)
We are done with inserting new elements into the consensus; try to conclude the consensus within a gi...
static struct GNUNET_CONSENSUS_Handle ** consensus_handles
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_complete()

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

Callback to be called when a service connect operation is completed.

Parameters
clsthe callback closure from functions generating an operation
opthe operation that has been finished
ca_resultthe service handle returned from GNUNET_TESTBED_ConnectAdapter()
emsgerror message in case the operation has failed; will be NULL if operation has executed successfully.

Definition at line 284 of file gnunet-consensus-profiler.c.

References do_consensus(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, num_connected_handles, and num_peers.

Referenced by peer_info_cb().

288 {
289  if (NULL != emsg)
290  {
292  "testbed connect emsg: %s\n",
293  emsg);
294  GNUNET_assert (0);
295  }
296 
298 
300  "connect complete\n");
301 
303  {
304  do_consensus ();
305  }
306 }
static void do_consensus()
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static unsigned int num_connected_handles
static unsigned int num_peers
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_element_cb()

static void new_element_cb ( void *  cls,
const struct GNUNET_SET_Element element 
)
static

Definition at line 310 of file gnunet-consensus-profiler.c.

References consensus_handles, GNUNET_SET_Element::data, GNUNET_assert, GNUNET_h2s(), GNUNET_YES, results_for_peer, GNUNET_SET_Element::size, and verbose.

Referenced by connect_adapter().

312 {
313  struct GNUNET_CONSENSUS_Handle **chp = cls;
314  int idx = chp - consensus_handles;
315 
316  GNUNET_assert (NULL != cls);
317 
318  results_for_peer[idx]++;
319 
320  GNUNET_assert (sizeof(struct GNUNET_HashCode) == element->size);
321 
322  if (GNUNET_YES == verbose)
323  {
324  printf ("P%d received %s\n",
325  idx,
326  GNUNET_h2s ((struct GNUNET_HashCode *) element->data));
327  }
328 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static unsigned * results_for_peer
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
const void * data
Actual data of the element.
static int verbose
A 512-bit hashcode.
uint16_t size
Number of bytes in the buffer pointed to by data.
Handle for the service.
Definition: consensus_api.c:40
static struct GNUNET_CONSENSUS_Handle ** consensus_handles
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_adapter()

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

Adapter function called to establish a connection to a 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 342 of file gnunet-consensus-profiler.c.

References deadline, GNUNET_CONSENSUS_create(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, new_element_cb(), num_peers, session_id, and start.

Referenced by peer_info_cb().

344 {
345  struct GNUNET_CONSENSUS_Handle **chp = cls;
346  struct GNUNET_CONSENSUS_Handle *consensus;
347 
348  chp = (struct GNUNET_CONSENSUS_Handle **) cls;
349 
351  "connect adapter, %d peers\n",
352  num_peers);
353  consensus = GNUNET_CONSENSUS_create (cfg,
355  &session_id,
356  start,
357  deadline,
358  &new_element_cb, chp);
359  *chp = (struct GNUNET_CONSENSUS_Handle *) consensus;
360  return consensus;
361 }
static struct GNUNET_HashCode session_id
static struct GNUNET_TIME_Absolute start
Start time for all consensuses.
static struct GNUNET_PeerIdentity * peer_ids
static unsigned int num_peers
#define GNUNET_log(kind,...)
Handle for the service.
Definition: consensus_api.c:40
static struct GNUNET_TIME_Absolute deadline
Deadline for all consensuses.
struct GNUNET_CONSENSUS_Handle * GNUNET_CONSENSUS_create(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, const struct GNUNET_PeerIdentity *peers, const struct GNUNET_HashCode *session_id, struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute deadline, GNUNET_CONSENSUS_ElementCallback new_element_cb, void *new_element_cls)
Create a consensus session.
static void new_element_cb(void *cls, const struct GNUNET_SET_Element *element)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect_adapter()

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

Adapter function called to destroy a connection to a service.

Parameters
clsclosure
op_resultservice handle returned from the connect adapter

Definition at line 372 of file gnunet-consensus-profiler.c.

References GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

Referenced by peer_info_cb().

373 {
374  /* FIXME: what to do here? */
376  "disconnect adapter called\n");
377 }
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ peer_info_cb()

static void peer_info_cb ( void *  cb_cls,
struct GNUNET_TESTBED_Operation op,
const struct GNUNET_TESTBED_PeerInformation pinfo,
const char *  emsg 
)
static

Callback to be called when the requested peer information is available.

Parameters
cb_clsthe closure from GNUNET_TETSBED_peer_get_information()
opthe operation this callback corresponds to
pinfothe result; will be NULL if the operation has failed
emsgerror message if the operation has failed; will be NULL if the operation is successfull

Definition at line 390 of file gnunet-consensus-profiler.c.

References connect_adapter(), connect_complete(), disconnect_adapter(), GNUNET_assert, GNUNET_TESTBED_operation_done(), GNUNET_TESTBED_PIT_IDENTITY, GNUNET_TESTBED_service_connect(), GNUNET_TESTBED_PeerInformation::id, num_peers, num_retrieved_peer_ids, p, GNUNET_TESTBED_PeerInformation::pit, and GNUNET_TESTBED_PeerInformation::result.

Referenced by test_master().

394 {
395  struct GNUNET_PeerIdentity *p;
396  int i;
397 
398  GNUNET_assert (NULL == emsg);
399 
400  p = (struct GNUNET_PeerIdentity *) cb_cls;
401 
402  if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY)
403  {
404  *p = *pinfo->result.id;
407  for (i = 0; i < num_peers; i++)
408  testbed_operations[i] =
409  GNUNET_TESTBED_service_connect (NULL, peers[i], "consensus",
410  connect_complete, NULL,
412  &consensus_handles[i]);
413  }
414  else
415  {
416  GNUNET_assert (0);
417  }
418 
420 }
enum GNUNET_TESTBED_PeerInformationType pit
Peer information type; captures which of the types in the &#39;op_result&#39; is actually in use...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PeerIdentity * id
The identity of the peer.
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.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
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:2044
static struct GNUNET_TESTBED_Operation ** testbed_operations
static struct GNUNET_TESTBED_Peer ** peers
static unsigned int num_peers
static void disconnect_adapter(void *cls, void *op_result)
Adapter function called to destroy a connection to a service.
The identity of the host (wraps the signing key of the peer).
What is the identity of the peer? Returns a &#39;const struct GNUNET_PeerIdentity *&#39;. ...
static unsigned int num_retrieved_peer_ids
static void * connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Adapter function called to establish a connection to a service.
static struct GNUNET_CONSENSUS_Handle ** consensus_handles
union GNUNET_TESTBED_PeerInformation::@61 result
The result of the get information operation; Choose according to the pit.
static void connect_complete(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Callback to be called when a service connect operation is completed.
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 **  started_peers,
unsigned int  links_succeeded,
unsigned int  links_failed 
)
static

Signature of a main function for a testcase.

Parameters
clsclosure
hthe run handle
num_peersnumber of peers in 'peers'
started_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 437 of file gnunet-consensus-profiler.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_log_setup(), GNUNET_malloc, GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_PIT_IDENTITY, num_peers, peer_info_cb(), and results_for_peer.

Referenced by GNUNET_TESTBED_run(), and run().

443 {
444  int i;
445 
446  GNUNET_log_setup ("gnunet-consensus", "INFO", NULL);
447 
448  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n");
449 
450  peers = started_peers;
451 
453 
454  results_for_peer = GNUNET_malloc (num_peers * sizeof(unsigned int));
455  consensus_handles = GNUNET_malloc (num_peers * sizeof(struct
456  ConsensusHandle *));
457  testbed_operations = GNUNET_malloc (num_peers * sizeof(struct
458  ConsensusHandle *));
459 
460  for (i = 0; i < num_peers; i++)
463  peer_info_cb,
464  &peer_ids[i]);
465 }
static unsigned * results_for_peer
static struct GNUNET_PeerIdentity * peer_ids
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
Request information about a peer.
static struct GNUNET_TESTBED_Operation ** testbed_operations
static struct GNUNET_TESTBED_Peer ** peers
static unsigned int num_peers
The identity of the host (wraps the signing key of the peer).
What is the identity of the peer? Returns a &#39;const struct GNUNET_PeerIdentity *&#39;. ...
#define GNUNET_log(kind,...)
static void peer_info_cb(void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
Callback to be called when the requested peer information is available.
static struct GNUNET_CONSENSUS_Handle ** consensus_handles
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_malloc(size)
Wrapper around malloc.
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 cfg 
)
static

Definition at line 469 of file gnunet-consensus-profiler.c.

References conclude_timeout, consensus_delay, controller_cb(), deadline, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_TESTBED_test_run(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), num_peers, replication, session_id, start, test_master(), and topology.

Referenced by main().

471 {
472  static char *session_str = "gnunet-consensus/test";
473  char *topology;
474  int topology_cmp_result;
475 
476  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
477  "OVERLAY_TOPOLOGY",
478  &topology))
479  {
480  fprintf (stderr,
481  "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, "
482  "seems like you passed the wrong configuration file\n");
483  return;
484  }
485 
486  topology_cmp_result = strcasecmp (topology, "NONE");
487  GNUNET_free (topology);
488 
489  if (0 == topology_cmp_result)
490  {
491  fprintf (stderr,
492  "'OVERLAY_TOPOLOGY' set to 'NONE', "
493  "seems like you passed the wrong configuration file\n");
494  return;
495  }
496 
497  if (num_peers < replication)
498  {
499  fprintf (stderr, "k must be <=n\n");
500  return;
501  }
502 
506 
508  "running gnunet-consensus\n");
509 
510  GNUNET_CRYPTO_hash (session_str, strlen (session_str), &session_id);
511 
512  (void) GNUNET_TESTBED_test_run ("gnunet-consensus",
513  cfgfile,
514  num_peers,
515  0,
517  NULL,
518  test_master,
519  NULL);
520 }
static struct GNUNET_TIME_Relative conclude_timeout
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **started_peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
int GNUNET_TESTBED_test_run(const char *testname, const char *cfg_filename, 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 "simple" test on the local system with a single call from &#39;main&#39;...
static unsigned int replication
static struct GNUNET_HashCode session_id
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:395
static struct GNUNET_TIME_Absolute start
Start time for all consensuses.
static void controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Signature of the event handler function called by the respective event controller.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
int 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.
static struct GNUNET_TIME_Relative consensus_delay
static unsigned int num_peers
#define GNUNET_log(kind,...)
static struct GNUNET_TIME_Absolute deadline
Deadline for all consensuses.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 524 of file gnunet-consensus-profiler.c.

References conclude_timeout, consensus_delay, dist_static, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_filename(), GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_uint(), GNUNET_PROGRAM_run2(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, num_peers, num_values, replication, run(), statistics_filename, and verbose.

525 {
528  "num-peers",
529  NULL,
530  gettext_noop ("number of peers in consensus"),
531  &num_peers),
532 
534  "value-replication",
535  NULL,
536  gettext_noop (
537  "how many peers (random selection without replacement) receive one value?"),
538  &replication),
539 
541  "num-values",
542  NULL,
543  gettext_noop ("number of values"),
544  &num_values),
545 
547  "timeout",
548  NULL,
549  gettext_noop ("consensus timeout"),
551 
552 
554  "delay",
555  NULL,
556  gettext_noop (
557  "delay until consensus starts"),
558  &consensus_delay),
559 
561  "statistics",
562  "FILENAME",
563  gettext_noop ("write statistics to file"),
565 
567  "dist-static",
568  gettext_noop (
569  "distribute elements to a static subset of good peers"),
570  &dist_static),
571 
573  "verbose",
574  gettext_noop (
575  "be more verbose (print received values)"),
576  &verbose),
577 
579  };
580 
582  GNUNET_PROGRAM_run2 (argc, argv, "gnunet-consensus-profiler",
583  "help",
584  options, &run, NULL, GNUNET_YES);
585  return 0;
586 }
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)...
static struct GNUNET_TIME_Relative conclude_timeout
int GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:141
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_TIME_UNIT_SECONDS
One second.
static unsigned int replication
Definition of a command line option.
static unsigned int num_values
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static char * statistics_filename
The profiler will write statistics for all peers to the file with this name.
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).
static int verbose
static int dist_static
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
static struct GNUNET_TIME_Relative consensus_delay
static unsigned int num_peers
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_YES
Definition: gnunet_common.h:77
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.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ num_peers

unsigned int num_peers = 2
static

◆ replication

unsigned int replication = 1
static

◆ num_values

unsigned int num_values = 5
static

Definition at line 36 of file gnunet-consensus-profiler.c.

Referenced by destroy(), do_consensus(), and main().

◆ conclude_timeout

struct GNUNET_TIME_Relative conclude_timeout
static

Definition at line 38 of file gnunet-consensus-profiler.c.

Referenced by main(), and run().

◆ consensus_delay

struct GNUNET_TIME_Relative consensus_delay
static

Definition at line 40 of file gnunet-consensus-profiler.c.

Referenced by main(), and run().

◆ consensus_handles

struct GNUNET_CONSENSUS_Handle** consensus_handles
static

Definition at line 42 of file gnunet-consensus-profiler.c.

Referenced by new_element_cb().

◆ testbed_operations

struct GNUNET_TESTBED_Operation** testbed_operations
static

Definition at line 44 of file gnunet-consensus-profiler.c.

◆ num_connected_handles

unsigned int num_connected_handles
static

Definition at line 46 of file gnunet-consensus-profiler.c.

Referenced by connect_complete().

◆ peers

struct GNUNET_TESTBED_Peer** peers
static

Definition at line 48 of file gnunet-consensus-profiler.c.

◆ peer_ids

struct GNUNET_PeerIdentity* peer_ids
static

Definition at line 50 of file gnunet-consensus-profiler.c.

Referenced by GNUNET_RPS_seed_ids().

◆ num_retrieved_peer_ids

unsigned int num_retrieved_peer_ids
static

Definition at line 52 of file gnunet-consensus-profiler.c.

Referenced by peer_info_cb().

◆ session_id

struct GNUNET_HashCode session_id
static

◆ peers_done

unsigned int peers_done = 0
static

Definition at line 56 of file gnunet-consensus-profiler.c.

Referenced by destroy().

◆ dist_static

int dist_static
static

Definition at line 58 of file gnunet-consensus-profiler.c.

Referenced by do_consensus(), and main().

◆ results_for_peer

unsigned* results_for_peer
static

Definition at line 60 of file gnunet-consensus-profiler.c.

Referenced by destroy(), new_element_cb(), and test_master().

◆ statistics_filename

char* statistics_filename
static

The profiler will write statistics for all peers to the file with this name.

Definition at line 66 of file gnunet-consensus-profiler.c.

Referenced by destroy(), and main().

◆ statistics_file

FILE* statistics_file
static

The profiler will write statistics for all peers to this file.

Definition at line 72 of file gnunet-consensus-profiler.c.

Referenced by destroy(), statistics_cb(), and statistics_done_cb().

◆ verbose

int verbose
static

Definition at line 74 of file gnunet-consensus-profiler.c.

Referenced by GNUNET_ATS_TEST_logging_start(), main(), and new_element_cb().

◆ start

struct GNUNET_TIME_Absolute start
static

Start time for all consensuses.

Definition at line 79 of file gnunet-consensus-profiler.c.

Referenced by connect_adapter(), and run().

◆ deadline

struct GNUNET_TIME_Absolute deadline
static

Deadline for all consensuses.

Definition at line 84 of file gnunet-consensus-profiler.c.

Referenced by connect_adapter(), and run().