GNUnet  0.10.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:517
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:2037
#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(peer), subsystem, name, (unsigned long)value);
140  }
141  return GNUNET_OK;
142 }
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:2314
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 146 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().

147 {
148  struct GNUNET_CONSENSUS_Handle *consensus = cls;
149 
151  "destroying consensus\n");
152  GNUNET_CONSENSUS_destroy(consensus);
153  peers_done++;
154  if (peers_done == num_peers)
155  {
156  unsigned int i;
157  for (i = 0; i < num_peers; i++)
159  for (i = 0; i < num_peers; i++)
160  printf("P%u got %u of %u elements\n",
161  i,
162  results_for_peer[i],
163  num_values);
164  if (NULL != statistics_filename)
165  statistics_file = fopen(statistics_filename, "w");
166  GNUNET_TESTBED_get_statistics(num_peers, peers, NULL, NULL,
169  NULL);
170  }
171 }
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:2037
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 182 of file gnunet-consensus-profiler.c.

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

Referenced by do_consensus().

183 {
184  struct GNUNET_CONSENSUS_Handle **chp = cls;
185 
187  "consensus %d done\n",
188  (int)(chp - consensus_handles));
190 }
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:1264
#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 194 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().

195 {
196  int j;
197 
198  j = 0;
199  while (j < replication)
200  {
201  int n;
202  int k;
203  int repeat;
205  repeat = GNUNET_NO;
206  for (k = 0; k < j; k++)
207  if (indices[k] == n)
208  {
209  repeat = GNUNET_YES;
210  break;
211  }
212  if (GNUNET_NO == repeat)
213  indices[j++] = n;
214  }
215 }
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 219 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().

220 {
221  int unique_indices[replication];
222  unsigned int i;
223  unsigned int j;
224  struct GNUNET_HashCode val;
225  struct GNUNET_SET_Element element;
226 
227  if (dist_static)
228  {
229  for (i = 0; i < num_values; i++)
230  {
232 
233  element.data = &val;
234  element.size = sizeof(val);
235  for (j = 0; j < replication; j++)
236  {
238  &element,
239  NULL, NULL);
240  }
241  }
242  }
243  else
244  {
245  for (i = 0; i < num_values; i++)
246  {
247  generate_indices(unique_indices);
249 
250  element.data = &val;
251  element.size = sizeof(val);
252  for (j = 0; j < replication; j++)
253  {
254  int cid;
255 
256  cid = unique_indices[j];
258  &element,
259  NULL, NULL);
260  }
261  }
262  }
263 
265  "all elements inserted, calling conclude\n");
266 
267  for (i = 0; i < num_peers; i++)
270 }
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:138
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 283 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().

287 {
288  if (NULL != emsg)
289  {
291  "testbed connect emsg: %s\n",
292  emsg);
293  GNUNET_assert(0);
294  }
295 
297 
299  "connect complete\n");
300 
302  {
303  do_consensus();
304  }
305 }
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 309 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().

311 {
312  struct GNUNET_CONSENSUS_Handle **chp = cls;
313  int idx = chp - consensus_handles;
314 
315  GNUNET_assert(NULL != cls);
316 
317  results_for_peer[idx]++;
318 
319  GNUNET_assert(sizeof(struct GNUNET_HashCode) == element->size);
320 
321  if (GNUNET_YES == verbose)
322  {
323  printf("P%d received %s\n",
324  idx,
325  GNUNET_h2s((struct GNUNET_HashCode *)element->data));
326  }
327 }
#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 341 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().

343 {
344  struct GNUNET_CONSENSUS_Handle **chp = cls;
345  struct GNUNET_CONSENSUS_Handle *consensus;
346 
347  chp = (struct GNUNET_CONSENSUS_Handle **)cls;
348 
350  "connect adapter, %d peers\n",
351  num_peers);
352  consensus = GNUNET_CONSENSUS_create(cfg,
354  &session_id,
355  start,
356  deadline,
357  &new_element_cb, chp);
358  *chp = (struct GNUNET_CONSENSUS_Handle *)consensus;
359  return consensus;
360 }
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 371 of file gnunet-consensus-profiler.c.

References GNUNET_ERROR_TYPE_INFO, and GNUNET_log.

Referenced by peer_info_cb().

372 {
373  /* FIXME: what to do here? */
375  "disconnect adapter called\n");
376 }
#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 389 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().

393 {
394  struct GNUNET_PeerIdentity *p;
395  int i;
396 
397  GNUNET_assert(NULL == emsg);
398 
399  p = (struct GNUNET_PeerIdentity *)cb_cls;
400 
401  if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY)
402  {
403  *p = *pinfo->result.id;
406  for (i = 0; i < num_peers; i++)
407  testbed_operations[i] =
408  GNUNET_TESTBED_service_connect(NULL, peers[i], "consensus", connect_complete, NULL,
410  }
411  else
412  {
413  GNUNET_assert(0);
414  }
415 
417 }
union GNUNET_TESTBED_PeerInformation::@64 result
The result of the get information operation; Choose according to the pit.
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:2037
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
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 434 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().

440 {
441  int i;
442 
443  GNUNET_log_setup("gnunet-consensus", "INFO", NULL);
444 
445  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "test master\n");
446 
447  peers = started_peers;
448 
450 
451  results_for_peer = GNUNET_malloc(num_peers * sizeof(unsigned int));
452  consensus_handles = GNUNET_malloc(num_peers * sizeof(struct ConsensusHandle *));
453  testbed_operations = GNUNET_malloc(num_peers * sizeof(struct ConsensusHandle *));
454 
455  for (i = 0; i < num_peers; i++)
458  peer_info_cb,
459  &peer_ids[i]);
460 }
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 464 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().

466 {
467  static char *session_str = "gnunet-consensus/test";
468  char *topology;
469  int topology_cmp_result;
470 
471  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "testbed", "OVERLAY_TOPOLOGY", &topology))
472  {
473  fprintf(stderr,
474  "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, "
475  "seems like you passed the wrong configuration file\n");
476  return;
477  }
478 
479  topology_cmp_result = strcasecmp(topology, "NONE");
480  GNUNET_free(topology);
481 
482  if (0 == topology_cmp_result)
483  {
484  fprintf(stderr,
485  "'OVERLAY_TOPOLOGY' set to 'NONE', "
486  "seems like you passed the wrong configuration file\n");
487  return;
488  }
489 
490  if (num_peers < replication)
491  {
492  fprintf(stderr, "k must be <=n\n");
493  return;
494  }
495 
498 
500  "running gnunet-consensus\n");
501 
502  GNUNET_CRYPTO_hash(session_str, strlen(session_str), &session_id);
503 
504  (void)GNUNET_TESTBED_test_run("gnunet-consensus",
505  cfgfile,
506  num_peers,
507  0,
509  NULL,
510  test_master,
511  NULL);
512 }
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:393
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:44
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 516 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.

517 {
520  "num-peers",
521  NULL,
522  gettext_noop("number of peers in consensus"),
523  &num_peers),
524 
526  "value-replication",
527  NULL,
528  gettext_noop("how many peers (random selection without replacement) receive one value?"),
529  &replication),
530 
532  "num-values",
533  NULL,
534  gettext_noop("number of values"),
535  &num_values),
536 
538  "timeout",
539  NULL,
540  gettext_noop("consensus timeout"),
542 
543 
545  "delay",
546  NULL,
547  gettext_noop("delay until consensus starts"),
548  &consensus_delay),
549 
551  "statistics",
552  "FILENAME",
553  gettext_noop("write statistics to file"),
555 
557  "dist-static",
558  gettext_noop("distribute elements to a static subset of good peers"),
559  &dist_static),
560 
562  "verbose",
563  gettext_noop("be more verbose (print received values)"),
564  &verbose),
565 
567  };
568 
570  GNUNET_PROGRAM_run2(argc, argv, "gnunet-consensus-profiler",
571  "help",
572  options, &run, NULL, GNUNET_YES);
573  return 0;
574 }
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:140
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().