GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-transport-profiler.c File Reference

Tool to help benchmark the transport subsystem. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_ats_service.h"
#include "gnunet_transport_service.h"
Include dependency graph for gnunet-transport-profiler.c:

Go to the source code of this file.

Data Structures

struct  Iteration
 

Macros

#define CONNECT_TIMEOUT   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
 Timeout for a connections. More...
 
#define DEFAULT_MESSAGE_SIZE   1024
 Benchmarking block size in bye. More...
 
#define DEFAULT_MESSAGE_COUNT   1024
 Benchmarking message count. More...
 
#define DEFAULT_ITERATION_COUNT   1
 Benchmarking iteration count. More...
 

Functions

static void shutdown_task (void *cls)
 Task run in monitor mode when the user presses CTRL-C to abort. More...
 
static void iteration_done ()
 
static void send_msg (void *cls)
 Function called to notify a client about the socket begin ready to queue more data. More...
 
static void iteration_start ()
 
static void * notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *m)
 Function called to notify transport users that another peer connected to us. More...
 
static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
 Function called to notify transport users that another peer disconnected from us. More...
 
static int check_dummy (void *cls, const struct GNUNET_MessageHeader *message)
 Function called by the transport for each received message. More...
 
static void handle_dummy (void *cls, const struct GNUNET_MessageHeader *message)
 Function called by the transport for each received message. More...
 
static int blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 

Variables

static int benchmark_send
 Option -s. More...
 
static int benchmark_receive
 Option -b. More...
 
static unsigned int benchmark_count
 Option -n. More...
 
static unsigned int benchmark_iterations
 Option -i. More...
 
static unsigned int benchmark_size
 Option -m. More...
 
static unsigned int benchmark_running
 Benchmark running. More...
 
static char * cpid
 Which peer should we connect to? More...
 
static struct GNUNET_TRANSPORT_CoreHandlehandle
 Handle to transport service. More...
 
static struct GNUNET_ATS_ConnectivityHandleats
 Handle to ATS service. More...
 
static struct GNUNET_CONFIGURATION_Handlecfg
 Configuration handle. More...
 
static struct GNUNET_ATS_ConnectivitySuggestHandleats_sh
 Try_connect handle. More...
 
static struct Iterationihead
 
static struct Iterationitail
 
static int ret
 Global return value (0 success). More...
 
static struct GNUNET_MQ_Handlemq
 Handle for transmissions. More...
 
static struct GNUNET_TRANSPORT_Blacklistbl_handle
 
static struct GNUNET_PeerIdentity pid
 Identity of the peer we transmit to / connect to. More...
 
static unsigned int verbosity
 Selected level of verbosity. More...
 

Detailed Description

Tool to help benchmark the transport subsystem.

Author
Christian Grothoff
Nathan Evans

This utility can be used to benchmark a transport mechanism for GNUnet.

Definition in file gnunet-transport-profiler.c.

Macro Definition Documentation

◆ CONNECT_TIMEOUT

#define CONNECT_TIMEOUT   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)

Timeout for a connections.

Definition at line 55 of file gnunet-transport-profiler.c.

◆ DEFAULT_MESSAGE_SIZE

#define DEFAULT_MESSAGE_SIZE   1024

Benchmarking block size in bye.

Definition at line 61 of file gnunet-transport-profiler.c.

Referenced by main().

◆ DEFAULT_MESSAGE_COUNT

#define DEFAULT_MESSAGE_COUNT   1024

Benchmarking message count.

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

Referenced by main().

◆ DEFAULT_ITERATION_COUNT

#define DEFAULT_ITERATION_COUNT   1

Benchmarking iteration count.

Definition at line 71 of file gnunet-transport-profiler.c.

Referenced by main().

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run in monitor mode when the user presses CTRL-C to abort.

Stops monitoring activity.

Parameters
clsNULL

Definition at line 163 of file gnunet-transport-profiler.c.

References _, benchmark_count, benchmark_receive, benchmark_send, benchmark_size, Iteration::dur, duration, GNUNET_ATS_connectivity_done(), GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TRANSPORT_blacklist_cancel(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_YES, ihead, iteration_done(), Iteration::next, Iteration::rate, GNUNET_TIME_Relative::rel_value_us, start_time, traffic_received, and verbosity.

Referenced by run().

164 {
165  struct Iteration *icur;
166  struct Iteration *inext;
167 
168  unsigned int iterations;
169 
170  unsigned long long avg_duration;
171  float avg_rate;
172  float stddev_rate;
173  float stddev_duration;
174 
175  if (NULL != ats_sh)
176  {
178  ats_sh = NULL;
179  }
180  if (NULL != bl_handle)
181  {
183  bl_handle = NULL;
184  }
185  if (NULL != ats)
186  {
188  ats = NULL;
189  }
190  if (NULL != handle)
191  {
193  handle = NULL;
194  }
195 
196  if (verbosity > 0)
197  fprintf(stdout, "\n");
198 
199  /* Output format:
200  * All time values in ms
201  * Rate in KB/s
202  * #messages;#messagesize;#avg_dur;#avg_rate;#duration_i0;#duration_i0;... */
203 
204  if (benchmark_send)
205  {
206  /* First iteration to calculcate avg and stddev */
207  iterations = 0;
208  avg_duration = 0;
209  avg_rate = 0.0;
210 
211  inext = ihead;
212  while (NULL != (icur = inext))
213  {
214  inext = icur->next;
215  icur->rate = ((benchmark_count * benchmark_size) / 1024) /
216  ((float)icur->dur.rel_value_us / (1000 * 1000));
217  if (verbosity > 0)
218  fprintf(stdout,
219  _("%llu B in %llu ms == %.2f KB/s!\n"),
220  ((long long unsigned int)benchmark_count * benchmark_size),
221  ((long long unsigned int)icur->dur.rel_value_us / 1000),
222  (float)icur->rate);
223 
224  avg_duration += icur->dur.rel_value_us / (1000);
225  avg_rate += icur->rate;
226  iterations++;
227  }
228  if (0 == iterations)
229  iterations = 1; /* avoid division by zero */
230  /* Calculate average rate */
231  avg_rate /= iterations;
232  /* Calculate average duration */
233  avg_duration /= iterations;
234 
235  stddev_rate = 0;
236  stddev_duration = 0;
237  inext = ihead;
238  while (NULL != (icur = inext))
239  {
240  inext = icur->next;
241  stddev_rate += ((icur->rate - avg_rate) * (icur->rate - avg_rate));
242  stddev_duration += (((icur->dur.rel_value_us / 1000) - avg_duration) *
243  ((icur->dur.rel_value_us / 1000) - avg_duration));
244  }
245  /* Calculate standard deviation rate */
246  stddev_rate = stddev_rate / iterations;
247  stddev_rate = sqrtf(stddev_rate);
248 
249  /* Calculate standard deviation duration */
250  stddev_duration = stddev_duration / iterations;
251  stddev_duration = sqrtf(stddev_duration);
252 
253  /* Output */
254  fprintf(stdout,
255  "%u;%u;%llu;%llu;%.2f;%.2f",
257  benchmark_size,
258  avg_duration,
259  (unsigned long long)stddev_duration,
260  avg_rate,
261  stddev_rate);
262 
263  inext = ihead;
264  while (NULL != (icur = inext))
265  {
266  inext = icur->next;
268 
269  fprintf(stdout,
270  ";%llu;%.2f",
271  (long long unsigned int)(icur->dur.rel_value_us / 1000),
272  icur->rate);
273 
274  GNUNET_free(icur);
275  }
276  }
277 #if 0
278  if (benchmark_receive)
279  {
281  fprintf(stdout,
282  "Received %llu bytes/s (%llu bytes in %s)\n",
283  1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
286  }
287 #endif
288  fprintf(stdout, "\n");
289 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint64_t rel_value_us
The actual value.
static unsigned int verbosity
Selected level of verbosity.
static unsigned int benchmark_size
Option -m.
struct Iteration * next
static struct GNUNET_ATS_ConnectivityHandle * ats
Handle to ATS service.
static struct Iteration * itail
static struct Iteration * ihead
static struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Try_connect handle.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
void GNUNET_TRANSPORT_blacklist_cancel(struct GNUNET_TRANSPORT_Blacklist *br)
Abort the blacklist.
static struct GNUNET_TRANSPORT_CoreHandle * handle
Handle to transport service.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static unsigned int benchmark_count
Option -n.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
static struct GNUNET_TIME_Absolute start_time
Start time of the current round; used to determine how long one iteration takes (which influences how...
static unsigned long long traffic_received
Number of bytes of traffic we received so far.
static struct GNUNET_TRANSPORT_Blacklist * bl_handle
static int benchmark_send
Option -s.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
static struct GNUNET_TIME_Relative duration
How long do we run the test?
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_TIME_Relative dur
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
#define GNUNET_free(ptr)
Wrapper around free.
static int benchmark_receive
Option -b.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iteration_done()

static void iteration_done ( )
static

Definition at line 355 of file gnunet-transport-profiler.c.

References benchmark_iterations, benchmark_running, Iteration::dur, GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_absolute_get_duration(), iteration_start(), and Iteration::start.

Referenced by send_msg(), and shutdown_task().

356 {
357  static int it_count = 0;
358 
359  it_count++;
361  if (it_count == benchmark_iterations)
362  {
365  return;
366  }
367  iteration_start();
368 }
static struct Iteration * itail
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
static unsigned int benchmark_iterations
Option -i.
struct GNUNET_TIME_Absolute start
static void iteration_start()
static unsigned int benchmark_running
Benchmark running.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
struct GNUNET_TIME_Relative dur
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_msg()

static void send_msg ( void *  cls)
static

Function called to notify a client about the socket begin ready to queue more data.

buf will be NULL and size zero if the socket was closed for writing in the meantime.

Parameters
clsclosure
sizenumber of bytes available in buf
bufwhere the callee should write the message
Returns
number of bytes written to buf

Definition at line 308 of file gnunet-transport-profiler.c.

References benchmark_count, benchmark_size, env, GNUNET_MESSAGE_TYPE_DUMMY, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), iteration_done(), m, Iteration::msgs_sent, and verbosity.

Referenced by iteration_start(), and reconnect().

309 {
310  struct GNUNET_MQ_Envelope *env;
311  struct GNUNET_MessageHeader *m;
312 
313  if (NULL == mq)
314  return;
316  memset(&m[1], 52, benchmark_size - sizeof(struct GNUNET_MessageHeader));
317 
319  {
320  GNUNET_MQ_notify_sent(env, &send_msg, NULL);
321  }
322  else
323  {
324  iteration_done();
325  }
326  GNUNET_MQ_send(mq, env);
327  if ((verbosity > 0) && (0 == itail->msgs_sent % 10))
328  fprintf(stdout, ".");
329 }
static unsigned int verbosity
Selected level of verbosity.
static struct GNUNET_MQ_Handle * mq
Handle for transmissions.
static unsigned int benchmark_size
Option -m.
static struct Iteration * itail
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
static unsigned int benchmark_count
Option -n.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:772
unsigned int msgs_sent
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void send_msg(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
static void iteration_done()
Header for all communications.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iteration_start()

static void iteration_start ( )
static

Definition at line 333 of file gnunet-transport-profiler.c.

References benchmark_count, benchmark_running, benchmark_send, benchmark_size, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, GNUNET_TIME_absolute_get(), GNUNET_YES, ret, send_msg(), Iteration::start, and verbosity.

Referenced by client_connect_cb(), iteration_done(), notify_connect(), and run().

334 {
335  struct Iteration *icur;
336 
337  ret = 0;
338  if (!benchmark_send)
339  return;
341  icur = GNUNET_new(struct Iteration);
344  if (verbosity > 0)
345  fprintf(
346  stdout,
347  "\nStarting benchmark, starting to send %u messages in %u byte blocks\n",
350  send_msg(NULL);
351 }
static unsigned int verbosity
Selected level of verbosity.
static unsigned int benchmark_size
Option -m.
static struct Iteration * itail
static struct Iteration * ihead
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static unsigned int benchmark_count
Option -n.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TIME_Absolute start
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
static void send_msg(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
static int benchmark_send
Option -s.
static unsigned int benchmark_running
Benchmark running.
static int ret
Global return value (0 success).
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_connect()

static void* notify_connect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle m 
)
static

Function called to notify transport users that another peer connected to us.

Parameters
clsclosure
peerthe peer that connected
mmessage queue for transmissions
Returns
NULL

Definition at line 381 of file gnunet-transport-profiler.c.

References GNUNET_i2s(), iteration_start(), m, pid, and verbosity.

Referenced by run().

384 {
385  if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
386  {
387  fprintf(stdout, "Connected to different peer `%s'\n", GNUNET_i2s(&pid));
388  return NULL;
389  }
390 
391  if (verbosity > 0)
392  fprintf(stdout, "Successfully connected to `%s'\n", GNUNET_i2s(&pid));
393  mq = m;
394  iteration_start();
395  return NULL;
396 }
static unsigned int verbosity
Selected level of verbosity.
static struct GNUNET_MQ_Handle * mq
Handle for transmissions.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
static void iteration_start()
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_disconnect()

static void notify_disconnect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  internal_cls 
)
static

Function called to notify transport users that another peer disconnected from us.

Parameters
clsclosure
peerthe peer that disconnected
internal_clsNULL

Definition at line 408 of file gnunet-transport-profiler.c.

References benchmark_running, GNUNET_i2s(), GNUNET_YES, and pid.

Referenced by run().

411 {
412  if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
413  return;
414  mq = NULL;
416  {
417  fprintf(stdout,
418  "Disconnected from peer `%s' while benchmarking\n",
419  GNUNET_i2s(&pid));
420  return;
421  }
422 }
static struct GNUNET_MQ_Handle * mq
Handle for transmissions.
static unsigned int benchmark_running
Benchmark running.
The identity of the host (wraps the signing key of the peer).
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_dummy()

static int check_dummy ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Function called by the transport for each received message.

Parameters
clsclosure
messagethe message
Returns
GNUNET_OK

Definition at line 433 of file gnunet-transport-profiler.c.

References GNUNET_OK.

434 {
435  return GNUNET_OK; /* all messages are fine */
436 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ handle_dummy()

static void handle_dummy ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Function called by the transport for each received message.

Parameters
clsclosure
messagethe message

Definition at line 446 of file gnunet-transport-profiler.c.

References benchmark_receive, GNUNET_MessageHeader::size, and verbosity.

447 {
448  if (!benchmark_receive)
449  return;
450  if (verbosity > 0)
451  fprintf(stdout,
452  "Received %u bytes\n",
453  (unsigned int)ntohs(message->size));
454 }
static unsigned int verbosity
Selected level of verbosity.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static int benchmark_receive
Option -b.

◆ blacklist_cb()

static int blacklist_cb ( void *  cls,
const struct GNUNET_PeerIdentity peer 
)
static

Definition at line 458 of file gnunet-transport-profiler.c.

References GNUNET_i2s(), GNUNET_OK, GNUNET_SYSERR, pid, and verbosity.

Referenced by run().

459 {
460  if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
461  {
462  if (verbosity > 0)
463  fprintf(stdout, "Denying connection to `%s'\n", GNUNET_i2s(peer));
464  return GNUNET_SYSERR;
465  }
466  return GNUNET_OK;
467 }
static unsigned int verbosity
Selected level of verbosity.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 mycfg 
)
static

Main function that will be run by the scheduler.

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

Definition at line 479 of file gnunet-transport-profiler.c.

References benchmark_count, benchmark_receive, benchmark_send, benchmark_size, blacklist_cb(), cpid, dummy, GNUNET_ATS_connectivity_done(), GNUNET_ATS_connectivity_init(), GNUNET_ATS_connectivity_suggest(), GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_i2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_MESSAGE_TYPE_DUMMY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_TRANSPORT_blacklist(), GNUNET_TRANSPORT_core_connect(), notify_connect(), notify_disconnect(), pid, GNUNET_PeerIdentity::public_key, ret, shutdown_task(), and verbosity.

Referenced by main().

483 {
487  struct GNUNET_MessageHeader,
488  NULL),
490 
491  cfg = (struct GNUNET_CONFIGURATION_Handle *)mycfg;
492 
493  ret = 1;
495  {
496  fprintf(stderr, "Message size too big!\n");
497  return;
498  }
499 
500  if (NULL == cpid)
501  {
502  fprintf(stderr, "No peer identity given\n");
503  return;
504  }
506  strlen(cpid),
507  &pid.public_key))
508  {
509  fprintf(stderr, "Failed to parse peer identity `%s'\n", cpid);
510  return;
511  }
512  if (1 == benchmark_send)
513  {
514  if (verbosity > 0)
515  fprintf(stderr,
516  "Trying to send %u messages with size %u to peer `%s'\n",
519  GNUNET_i2s(&pid));
520  }
521  else if (1 == benchmark_receive)
522  {
523  fprintf(stderr,
524  "Trying to receive messages from peer `%s'\n",
525  GNUNET_i2s(&pid));
526  }
527  else
528  {
529  fprintf(stderr, "No operation given\n");
530  return;
531  }
532 
534  if (NULL == ats)
535  {
536  fprintf(stderr, "Failed to connect to ATS service\n");
537  ret = 1;
538  return;
539  }
540 
542  NULL,
543  handlers,
544  NULL,
547  NULL);
548  if (NULL == handle)
549  {
550  fprintf(stderr, "Failed to connect to transport service\n");
552  ats = NULL;
553  ret = 1;
554  return;
555  }
556 
560 }
static char * cpid
Which peer should we connect to?
static unsigned int verbosity
Selected level of verbosity.
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:1284
static unsigned int benchmark_size
Option -m.
static struct GNUNET_ATS_ConnectivityHandle * ats
Handle to ATS service.
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
static struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Try_connect handle.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
static struct GNUNET_TRANSPORT_CoreHandle * handle
Handle to transport service.
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *m)
Function called to notify transport users that another peer connected to us.
static unsigned int benchmark_count
Option -n.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_TRANSPORT_Blacklist * GNUNET_TRANSPORT_blacklist(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls)
Install a blacklist callback.
Message handler for a specific message type.
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
static struct GNUNET_TRANSPORT_Blacklist * bl_handle
static int benchmark_send
Option -s.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
int GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:501
static int ret
Global return value (0 success).
configuration data
Definition: configuration.c:83
Header for all communications.
static int blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Function called to notify transport users that another peer disconnected from us. ...
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void shutdown_task(void *cls)
Task run in monitor mode when the user presses CTRL-C to abort.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
static int benchmark_receive
Option -b.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

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

Definition at line 564 of file gnunet-transport-profiler.c.

References benchmark_count, benchmark_iterations, benchmark_receive, benchmark_running, benchmark_send, benchmark_size, cpid, DEFAULT_ITERATION_COUNT, DEFAULT_MESSAGE_COUNT, DEFAULT_MESSAGE_SIZE, gettext_noop, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_GETOPT_option_verbose(), GNUNET_NO, GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), res, ret, run(), and verbosity.

565 {
566  int res;
567 
572 
575  "send",
576  gettext_noop("send data to peer"),
577  &benchmark_send),
579  "receive",
580  gettext_noop("receive data from peer"),
583  "iterations",
584  NULL,
585  gettext_noop("iterations"),
588  "number",
589  NULL,
590  gettext_noop("number of messages to send"),
591  &benchmark_count),
593  "messagesize",
594  NULL,
595  gettext_noop("message size to use"),
596  &benchmark_size),
598  "peer",
599  "PEER",
600  gettext_noop("peer identity"),
601  &cpid),
604  };
605 
606  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
607  return 2;
608 
609  res =
610  GNUNET_PROGRAM_run(argc,
611  argv,
612  "gnunet-transport",
613  gettext_noop("Direct access to transport service."),
614  options,
615  &run,
616  NULL);
617  GNUNET_free((void *)argv);
618  if (GNUNET_OK == res)
619  return ret;
620  return 1;
621 }
static char * cpid
Which peer should we connect to?
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static unsigned int verbosity
Selected level of verbosity.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
static unsigned int benchmark_size
Option -m.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1439
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Definition of a command line option.
#define DEFAULT_MESSAGE_COUNT
Benchmarking message count.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
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 unsigned int benchmark_count
Option -n.
#define DEFAULT_MESSAGE_SIZE
Benchmarking block size in bye.
static unsigned int benchmark_iterations
Option -i.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg)
Main function that will be run by the scheduler.
static int res
static int benchmark_send
Option -s.
static unsigned int benchmark_running
Benchmark running.
static int ret
Global return value (0 success).
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.
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:367
#define DEFAULT_ITERATION_COUNT
Benchmarking iteration count.
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 GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
static int benchmark_receive
Option -b.
Here is the call graph for this function:

Variable Documentation

◆ benchmark_send

int benchmark_send
static

Option -s.

Definition at line 76 of file gnunet-transport-profiler.c.

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

◆ benchmark_receive

int benchmark_receive
static

Option -b.

Definition at line 81 of file gnunet-transport-profiler.c.

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

◆ benchmark_count

unsigned int benchmark_count
static

Option -n.

Definition at line 86 of file gnunet-transport-profiler.c.

Referenced by iteration_start(), main(), run(), send_msg(), and shutdown_task().

◆ benchmark_iterations

unsigned int benchmark_iterations
static

Option -i.

Definition at line 91 of file gnunet-transport-profiler.c.

Referenced by iteration_done(), and main().

◆ benchmark_size

unsigned int benchmark_size
static

Option -m.

Definition at line 96 of file gnunet-transport-profiler.c.

Referenced by iteration_start(), main(), run(), send_msg(), and shutdown_task().

◆ benchmark_running

unsigned int benchmark_running
static

Benchmark running.

Definition at line 101 of file gnunet-transport-profiler.c.

Referenced by iteration_done(), iteration_start(), main(), and notify_disconnect().

◆ cpid

char* cpid
static

Which peer should we connect to?

Definition at line 106 of file gnunet-transport-profiler.c.

Referenced by main(), and run().

◆ handle

struct GNUNET_TRANSPORT_CoreHandle* handle
static

Handle to transport service.

Definition at line 111 of file gnunet-transport-profiler.c.

◆ ats

struct GNUNET_ATS_ConnectivityHandle* ats
static

Handle to ATS service.

Definition at line 116 of file gnunet-transport-profiler.c.

◆ cfg

struct GNUNET_CONFIGURATION_Handle* cfg
static

Configuration handle.

Definition at line 121 of file gnunet-transport-profiler.c.

◆ ats_sh

struct GNUNET_ATS_ConnectivitySuggestHandle* ats_sh
static

Try_connect handle.

Definition at line 126 of file gnunet-transport-profiler.c.

◆ ihead

struct Iteration* ihead
static

Definition at line 128 of file gnunet-transport-profiler.c.

Referenced by shutdown_task().

◆ itail

struct Iteration* itail
static

Definition at line 130 of file gnunet-transport-profiler.c.

◆ ret

int ret
static

Global return value (0 success).

Definition at line 135 of file gnunet-transport-profiler.c.

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

◆ mq

struct GNUNET_MQ_Handle* mq
static

Handle for transmissions.

Definition at line 140 of file gnunet-transport-profiler.c.

◆ bl_handle

struct GNUNET_TRANSPORT_Blacklist* bl_handle
static

Definition at line 142 of file gnunet-transport-profiler.c.

◆ pid

struct GNUNET_PeerIdentity pid
static

◆ verbosity

unsigned int verbosity
static

Selected level of verbosity.

Definition at line 153 of file gnunet-transport-profiler.c.

Referenced by blacklist_cb(), handle_dummy(), iteration_start(), main(), notify_connect(), run(), send_msg(), and shutdown_task().