GNUnet  0.19.4
gnunet-transport-profiler.c File Reference

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

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 56 of file gnunet-transport-profiler.c.

◆ DEFAULT_MESSAGE_SIZE

#define DEFAULT_MESSAGE_SIZE   1024

Benchmarking block size in bye.

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

◆ DEFAULT_MESSAGE_COUNT

#define DEFAULT_MESSAGE_COUNT   1024

Benchmarking message count.

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

◆ DEFAULT_ITERATION_COUNT

#define DEFAULT_ITERATION_COUNT   1

Benchmarking iteration count.

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

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 164 of file gnunet-transport-profiler.c.

165 {
166  struct Iteration *icur;
167  struct Iteration *inext;
168 
169  unsigned int iterations;
170 
171  unsigned long long avg_duration;
172  float avg_rate;
173  float stddev_rate;
174  float stddev_duration;
175 
176  if (NULL != ats_sh)
177  {
179  ats_sh = NULL;
180  }
181  if (NULL != bl_handle)
182  {
184  bl_handle = NULL;
185  }
186  if (NULL != ats)
187  {
189  ats = NULL;
190  }
191  if (NULL != handle)
192  {
194  handle = NULL;
195  }
196 
197  if (verbosity > 0)
198  fprintf (stdout, "\n");
199 
200  /* Output format:
201  * All time values in ms
202  * Rate in KB/s
203  * #messages;#messagesize;#avg_dur;#avg_rate;#duration_i0;#duration_i0;... */
204 
205  if (benchmark_send)
206  {
207  /* First iteration to calculate avg and stddev */
208  iterations = 0;
209  avg_duration = 0;
210  avg_rate = 0.0;
211 
212  inext = ihead;
213  while (NULL != (icur = inext))
214  {
215  inext = icur->next;
216  icur->rate = ((benchmark_count * benchmark_size) / 1024)
217  / ((float) icur->dur.rel_value_us / (1000 * 1000));
218  if (verbosity > 0)
219  fprintf (stdout,
220  _ ("%llu B in %llu ms == %.2f KB/s!\n"),
221  ((long long unsigned int) benchmark_count * benchmark_size),
222  ((long long unsigned int) icur->dur.rel_value_us / 1000),
223  (float) icur->rate);
224 
225  avg_duration += icur->dur.rel_value_us / (1000);
226  avg_rate += icur->rate;
227  iterations++;
228  }
229  if (0 == iterations)
230  iterations = 1; /* avoid division by zero */
231  /* Calculate average rate */
232  avg_rate /= iterations;
233  /* Calculate average duration */
234  avg_duration /= iterations;
235 
236  stddev_rate = 0;
237  stddev_duration = 0;
238  inext = ihead;
239  while (NULL != (icur = inext))
240  {
241  inext = icur->next;
242  stddev_rate += ((icur->rate - avg_rate) * (icur->rate - avg_rate));
243  stddev_duration += (((icur->dur.rel_value_us / 1000) - avg_duration)
244  * ((icur->dur.rel_value_us / 1000) - avg_duration));
245  }
246  /* Calculate standard deviation rate */
247  stddev_rate = stddev_rate / iterations;
248  stddev_rate = sqrtf (stddev_rate);
249 
250  /* Calculate standard deviation duration */
251  stddev_duration = stddev_duration / iterations;
252  stddev_duration = sqrtf (stddev_duration);
253 
254  /* Output */
255  fprintf (stdout,
256  "%u;%u;%llu;%llu;%.2f;%.2f",
259  avg_duration,
260  (unsigned long long) stddev_duration,
261  avg_rate,
262  stddev_rate);
263 
264  inext = ihead;
265  while (NULL != (icur = inext))
266  {
267  inext = icur->next;
269 
270  fprintf (stdout,
271  ";%llu;%.2f",
272  (long long unsigned int) (icur->dur.rel_value_us / 1000),
273  icur->rate);
274 
275  GNUNET_free (icur);
276  }
277  }
278 #if 0
279  if (benchmark_receive)
280  {
282  fprintf (stdout,
283  "Received %llu bytes/s (%llu bytes in %s)\n",
284  1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
287  }
288 #endif
289  fprintf (stdout, "\n");
290 }
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 struct GNUNET_TIME_Relative duration
How long do we run the test?
static int benchmark_send
Option -s.
static unsigned int benchmark_size
Option -m.
static struct Iteration * ihead
static struct GNUNET_ATS_ConnectivityHandle * ats
Handle to ATS service.
static unsigned int verbosity
Selected level of verbosity.
static struct Iteration * itail
static struct GNUNET_TRANSPORT_CoreHandle * handle
Handle to transport service.
static struct GNUNET_TRANSPORT_Blacklist * bl_handle
static unsigned int benchmark_count
Option -n.
static int benchmark_receive
Option -b.
static struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Try_connect handle.
static unsigned long long traffic_received
Number of bytes of traffic we received so far.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_YES
#define GNUNET_free(ptr)
Wrapper around free.
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:436
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:569
void GNUNET_TRANSPORT_blacklist_cancel(struct GNUNET_TRANSPORT_Blacklist *br)
Abort the blacklist.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
uint64_t rel_value_us
The actual value.
struct GNUNET_TIME_Relative dur
struct Iteration * next

References _, ats, ats_sh, benchmark_count, benchmark_receive, benchmark_send, benchmark_size, bl_handle, 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, handle, ihead, itail, Iteration::next, Iteration::rate, GNUNET_TIME_Relative::rel_value_us, start_time, traffic_received, and verbosity.

Referenced by run().

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 356 of file gnunet-transport-profiler.c.

357 {
358  static int it_count = 0;
359 
360  it_count++;
362  if (it_count == benchmark_iterations)
363  {
366  return;
367  }
368  iteration_start ();
369 }
static void iteration_start()
static unsigned int benchmark_iterations
Option -i.
static unsigned int benchmark_running
Benchmark running.
@ GNUNET_NO
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
struct GNUNET_TIME_Absolute start

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

Referenced by send_msg().

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 309 of file gnunet-transport-profiler.c.

310 {
311  struct GNUNET_MQ_Envelope *env;
312  struct GNUNET_MessageHeader *m;
313 
314  if (NULL == mq)
315  return;
317  memset (&m[1], 52, benchmark_size - sizeof(struct GNUNET_MessageHeader));
318 
320  {
322  }
323  else
324  {
325  iteration_done ();
326  }
327  GNUNET_MQ_send (mq, env);
328  if ((verbosity > 0) && (0 == itail->msgs_sent % 10))
329  fprintf (stdout, ".");
330 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static void iteration_done()
static struct GNUNET_MQ_Handle * mq
Handle for transmissions.
static void send_msg(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
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:304
#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:62
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:638
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
Header for all communications.
unsigned int msgs_sent

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

Referenced by iteration_start(), and reconnect().

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 334 of file gnunet-transport-profiler.c.

335 {
336  struct Iteration *icur;
337 
338  ret = 0;
339  if (! benchmark_send)
340  return;
342  icur = GNUNET_new (struct Iteration);
344  icur->start = GNUNET_TIME_absolute_get ();
345  if (verbosity > 0)
346  fprintf (
347  stdout,
348  "\nStarting benchmark, starting to send %u messages in %u byte blocks\n",
351  send_msg (NULL);
352 }
static int ret
Global return value (0 success).
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111

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

Referenced by iteration_done(), and notify_connect().

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 382 of file gnunet-transport-profiler.c.

385 {
386  if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
387  {
388  fprintf (stdout, "Connected to different peer `%s'\n", GNUNET_i2s (&pid));
389  return NULL;
390  }
391 
392  if (verbosity > 0)
393  fprintf (stdout, "Successfully connected to `%s'\n", GNUNET_i2s (&pid));
394  mq = m;
395  iteration_start ();
396  return NULL;
397 }
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).
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

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

Referenced by run().

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 409 of file gnunet-transport-profiler.c.

412 {
413  if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
414  return;
415  mq = NULL;
417  {
418  fprintf (stdout,
419  "Disconnected from peer `%s' while benchmarking\n",
420  GNUNET_i2s (&pid));
421  return;
422  }
423 }

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

Referenced by run().

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 434 of file gnunet-transport-profiler.c.

435 {
436  return GNUNET_OK; /* all messages are fine */
437 }
@ GNUNET_OK

References GNUNET_OK.

◆ 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 447 of file gnunet-transport-profiler.c.

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

References benchmark_receive, GNUNET_MessageHeader::size, and verbosity.

◆ blacklist_cb()

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

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

460 {
461  if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
462  {
463  if (verbosity > 0)
464  fprintf (stdout, "Denying connection to `%s'\n", GNUNET_i2s (peer));
465  return GNUNET_SYSERR;
466  }
467  return GNUNET_OK;
468 }
@ GNUNET_SYSERR

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

Referenced by run().

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 480 of file gnunet-transport-profiler.c.

484 {
488  struct GNUNET_MessageHeader,
489  NULL),
491 
492  cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
493 
494  ret = 1;
496  {
497  fprintf (stderr, "Message size too big!\n");
498  return;
499  }
500 
501  if (NULL == cpid)
502  {
503  fprintf (stderr, "No peer identity given\n");
504  return;
505  }
507  strlen (cpid),
508  &pid.public_key))
509  {
510  fprintf (stderr, "Failed to parse peer identity `%s'\n", cpid);
511  return;
512  }
513  if (1 == benchmark_send)
514  {
515  if (verbosity > 0)
516  fprintf (stderr,
517  "Trying to send %u messages with size %u to peer `%s'\n",
520  GNUNET_i2s (&pid));
521  }
522  else if (1 == benchmark_receive)
523  {
524  fprintf (stderr,
525  "Trying to receive messages from peer `%s'\n",
526  GNUNET_i2s (&pid));
527  }
528  else
529  {
530  fprintf (stderr, "No operation given\n");
531  return;
532  }
533 
535  if (NULL == ats)
536  {
537  fprintf (stderr, "Failed to connect to ATS service\n");
538  ret = 1;
539  return;
540  }
541 
543  NULL,
544  handlers,
545  NULL,
548  NULL);
549  if (NULL == handle)
550  {
551  fprintf (stderr, "Failed to connect to transport service\n");
553  ats = NULL;
554  ret = 1;
555  return;
556  }
557 
561 }
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
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 int blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
static void shutdown_task(void *cls)
Task run in monitor mode when the user presses CTRL-C to abort.
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
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.
static char * cpid
Which peer should we connect to?
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
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.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
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.
enum GNUNET_GenericReturnValue 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:357
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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,...
Definition: scheduler.c:1334
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.
struct GNUNET_CRYPTO_EddsaPublicKey public_key

References ats, ats_sh, benchmark_count, benchmark_receive, benchmark_send, benchmark_size, bl_handle, blacklist_cb(), cfg, 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(), handle, handlers, notify_connect(), notify_disconnect(), pid, GNUNET_PeerIdentity::public_key, ret, shutdown_task(), and verbosity.

Referenced by main().

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 565 of file gnunet-transport-profiler.c.

566 {
567  int res;
568 
573 
576  "send",
577  gettext_noop ("send data to peer"),
578  &benchmark_send),
580  "receive",
581  gettext_noop ("receive data from peer"),
584  "iterations",
585  NULL,
586  gettext_noop ("iterations"),
589  "number",
590  NULL,
591  gettext_noop ("number of messages to send"),
592  &benchmark_count),
594  "messagesize",
595  NULL,
596  gettext_noop ("message size to use"),
597  &benchmark_size),
599  "peer",
600  "PEER",
601  gettext_noop ("peer identity"),
602  &cpid),
605  };
606 
607  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
608  return 2;
609 
610  res =
611  GNUNET_PROGRAM_run (argc,
612  argv,
613  "gnunet-transport",
614  gettext_noop ("Direct access to transport service."),
615  options,
616  &run,
617  NULL);
618  GNUNET_free_nz ((void *) argv);
619  if (GNUNET_OK == res)
620  return ret;
621  return 1;
622 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:70
static int res
#define DEFAULT_ITERATION_COUNT
Benchmarking iteration count.
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.
#define DEFAULT_MESSAGE_SIZE
Benchmarking block size in bye.
#define DEFAULT_MESSAGE_COUNT
Benchmarking message 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.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
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.
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.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:400
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1222
Definition of a command line option.

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_nz, 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(), options, res, ret, run(), and verbosity.

Here is the call graph for this function:

Variable Documentation

◆ benchmark_send

int benchmark_send
static

Option -s.

Definition at line 77 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 82 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 87 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 92 of file gnunet-transport-profiler.c.

Referenced by iteration_done(), and main().

◆ benchmark_size

unsigned int benchmark_size
static

Option -m.

Definition at line 97 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 102 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 107 of file gnunet-transport-profiler.c.

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

◆ handle

struct GNUNET_TRANSPORT_CoreHandle* handle
static

Handle to transport service.

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

Referenced by run(), and shutdown_task().

◆ ats

struct GNUNET_ATS_ConnectivityHandle* ats
static

Handle to ATS service.

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

Referenced by run(), and shutdown_task().

◆ cfg

struct GNUNET_CONFIGURATION_Handle* cfg
static

Configuration handle.

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

Referenced by run().

◆ ats_sh

struct GNUNET_ATS_ConnectivitySuggestHandle* ats_sh
static

Try_connect handle.

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

Referenced by run(), and shutdown_task().

◆ ihead

struct Iteration* ihead
static

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

Referenced by iteration_start(), and shutdown_task().

◆ itail

struct Iteration* itail
static

◆ ret

int ret
static

Global return value (0 success).

Definition at line 136 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 141 of file gnunet-transport-profiler.c.

Referenced by notify_connect(), notify_disconnect(), and send_msg().

◆ bl_handle

struct GNUNET_TRANSPORT_Blacklist* bl_handle
static

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

Referenced by run(), and shutdown_task().

◆ pid

struct GNUNET_PeerIdentity pid
static

Identity of the peer we transmit to / connect to.

(equivalent to 'cpid' string).

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

Referenced by add_valid_address(), blacklist_cb(), blacklist_check(), check_access(), check_connection_quality(), check_hello(), check_known_address(), check_known_challenge(), check_validation_request_pending(), consider_for_advertising(), consider_peer_for_forwarding(), core_send_connect_info(), cores_send_connect_info(), cores_send_disconnect_info(), create_target(), cummulative_ack(), db_read_whitelist(), detach_terminal(), do_transmit(), dv_neighbour_selection(), dv_neighbour_transmission(), find_list_tunnels(), find_peer_by_pid(), find_queue(), find_target(), flush_respect(), fork_and_exec(), free_ack_cummulator_cb(), free_backtalker_cb(), free_dv_routes_cb(), free_matching_requests(), free_neighbour_cb(), free_peer(), free_request(), free_validation_state_cb(), GAS_plugin_request_connect_start(), GAS_plugin_request_connect_stop(), GCPP_try_path_from_dht(), GDS_NEIGHBOURS_handle_get(), GDS_try_connect(), GDS_u_connect(), GDS_u_try_connect(), get_idx_of_pid(), gns_resolve_name(), GNUNET_CORE_get_mq(), GNUNET_FRIENDS_parse(), GNUNET_HELLO_builder_from_url(), GNUNET_HELLO_builder_new(), GNUNET_HELLO_extract_address(), GNUNET_i2s(), GNUNET_i2s2(), GNUNET_i2s_full(), GNUNET_PEER_intern(), GNUNET_PEER_resolve(), GNUNET_PEER_search(), GNUNET_TRANSPORT_communicator_notify(), gnunet_try_connect(), GSC_SESSIONS_end(), GSC_SESSIONS_solicit(), GST_validation_handle_hello(), handle_ack(), handle_dht_local_hello_offer(), handle_friend(), handle_hello(), handle_p2p_put(), handle_remote_overlay_connect(), handle_search_response(), handle_transport_notify_connect(), handle_transport_notify_excess_bw(), handshake_ack_monotime_cb(), handshake_monotime_cb(), ip_try_connect(), logger_run(), lookup_neighbour(), lookup_virtual_link(), main(), maint_child_death(), netjail_stop_run(), notify_client_connect_info(), notify_client_queues(), notify_connect(), notify_disconnect(), read_cb(), rekey_monotime_cb(), run(), save_list_tunnels(), setup_cipher(), show_peer(), start_address_validation(), start_helper(), stop_peer_request(), suggest_to_connect(), transmit_ping_if_allowed(), update_ax_by_kx(), update_friend_hello(), write_benchmark_data(), and write_pid_file().

◆ verbosity

unsigned int verbosity
static

Selected level of verbosity.

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

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