GNUnet  0.19.4
gnunet-cadet-profiler.c File Reference

Profiler for cadet experiments. More...

#include "platform.h"
#include <stdio.h>
#include "cadet_test_lib.h"
#include "gnunet_cadet_service.h"
#include "gnunet_statistics_service.h"
Include dependency graph for gnunet-cadet-profiler.c:

Go to the source code of this file.

Data Structures

struct  CadetPingMessage
 Message type for pings. More...
 
struct  CadetPeer
 Peer description. More...
 

Macros

#define PING   1
 
#define PONG   2
 
#define PING_PERIOD   500
 Paximum ping period in milliseconds. More...
 
#define TIMEOUT   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
 How long until we give up on connecting the peers? More...
 
#define SHORT_TIME   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
 Time to wait for stuff that should be rather fast. More...
 
#define number_rounds   sizeof(rounds) / sizeof(rounds[0])
 Total number of rounds. More...
 

Functions

static void start_test (void *cls)
 START THE TEST ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES. More...
 
static struct GNUNET_TIME_Relative delay_ms_rnd (unsigned int max)
 Calculate a random delay. More...
 
static unsigned int get_index (struct CadetPeer *peer)
 Get the index of a peer in the peers array. More...
 
static void show_end_data (void)
 Show the results of the test (banwidth achieved) and log them to GAUGER. More...
 
static void disconnect_cadet_peers (void *cls)
 Disconnect from cadet services af all peers, call shutdown. More...
 
static void shutdown_task (void *cls)
 Shut down peergroup, clean up. More...
 
static void abort_test (long line)
 Finish test normally: schedule disconnect and shutdown. More...
 
static void stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 Stats callback. More...
 
static int stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Process statistic values. More...
 
static void collect_stats (void *cls)
 Task check that keepalives were sent and received. More...
 
static void finish_profiler (void *cls)
 Finish profiler normally. More...
 
static void adjust_running_peers (unsigned int target)
 Set the total number of running peers. More...
 
static void next_rnd (void *cls)
 Move to next round. More...
 
static size_t tmt_rdy_ping (void *cls, size_t size, void *buf)
 Transmit ping callback. More...
 
static size_t tmt_rdy_pong (void *cls, size_t size, void *buf)
 Transmit pong callback. More...
 
static void ping (void *cls)
 Send a ping to destination. More...
 
static void pong (struct GNUNET_CADET_Channel *channel, const struct CadetPingMessage *ping)
 Reply with a pong to origin. More...
 
int ping_handler (void *cls, struct GNUNET_CADET_Channel *channel, void **channel_ctx, const struct GNUNET_MessageHeader *message)
 Function is called whenever a PING message is received. More...
 
int pong_handler (void *cls, struct GNUNET_CADET_Channel *channel, void **channel_ctx, const struct GNUNET_MessageHeader *message)
 Function is called whenever a PONG message is received. More...
 
static void * incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator, const struct GNUNET_HashCode *port, enum GNUNET_CADET_ChannelOption options)
 Method called whenever another peer has added us to a channel the other peer initiated. More...
 
static void channel_cleaner (void *cls, const struct GNUNET_CADET_Channel *channel, void *channel_ctx)
 Function called whenever an inbound channel is destroyed. More...
 
static struct CadetPeerselect_random_peer (struct CadetPeer *peer)
 Select a random peer that has no incoming channel. More...
 
static void warmup (void)
 Do warmup: create some channels to spread information about the topology. More...
 
static void peer_id_cb (void *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 tmain (void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **testbed_peers, struct GNUNET_CADET_Handle **cadetes)
 test main: start test when all peers are connected More...
 
int main (int argc, char *argv[])
 Main: start profiler. More...
 

Variables

static float rounds [] = { 0.8, 0.6, 0.8, 0.5, 0.3, 0.8, 0.0 }
 Ratio of peers active. More...
 
static struct GNUNET_TIME_Relative round_time
 Duration of each round. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapids
 GNUNET_PeerIdentity -> CadetPeer. More...
 
static struct GNUNET_TESTBED_Peer ** testbed_handles
 Testbed peer handles. More...
 
static struct GNUNET_TESTBED_Operationstats_op
 Testbed Operation (to get stats). More...
 
static struct CadetPeerpeers
 Operation to get peer ids. More...
 
static unsigned int p_ids
 Peer ids counter. More...
 
static unsigned long long peers_total
 Total number of peers. More...
 
static unsigned long long peers_running
 Number of currently running peers. More...
 
static unsigned long long peers_pinging
 Number of peers doing pings. More...
 
static struct GNUNET_CADET_TEST_Contexttest_ctx
 Test context (to shut down). More...
 
static struct GNUNET_SCHEDULER_Taskdisconnect_task
 Task called to disconnect peers, before shutdown. More...
 
static struct GNUNET_SCHEDULER_Tasktest_task
 Task to perform tests. More...
 
static unsigned int current_round
 Round number. More...
 
static int do_warmup
 Do preconnect? (Each peer creates a tunnel to one other peer). More...
 
static unsigned int peers_warmup
 Warmup progress. More...
 
static int test_finished
 Flag to notify callbacks not to generate any new traffic anymore. More...
 
static struct GNUNET_SCHEDULER_Taskround_task
 Task running each round of the benchmark. More...
 
static struct GNUNET_CADET_MessageHandler handlers []
 Handlers, for diverse services. More...
 

Detailed Description

Profiler for cadet experiments.

Definition in file gnunet-cadet-profiler.c.

Macro Definition Documentation

◆ PING

#define PING   1

Definition at line 32 of file gnunet-cadet-profiler.c.

◆ PONG

#define PONG   2

Definition at line 33 of file gnunet-cadet-profiler.c.

◆ PING_PERIOD

#define PING_PERIOD   500

Paximum ping period in milliseconds.

Real period = rand (0, PING_PERIOD)

Definition at line 39 of file gnunet-cadet-profiler.c.

◆ TIMEOUT

How long until we give up on connecting the peers?

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

◆ SHORT_TIME

Time to wait for stuff that should be rather fast.

Definition at line 49 of file gnunet-cadet-profiler.c.

◆ number_rounds

#define number_rounds   sizeof(rounds) / sizeof(rounds[0])

Total number of rounds.

Definition at line 54 of file gnunet-cadet-profiler.c.

Function Documentation

◆ start_test()

static void start_test ( void *  cls)
static

START THE TEST ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.

Testcase continues when the root receives confirmation of connected peers, on callback function ch.

Parameters
clsClosure (unused).

Definition at line 917 of file gnunet-cadet-profiler.c.

918 {
919  unsigned long i;
920 
921  test_task = NULL;
922  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n");
923 
924 
925  for (i = 0; i < peers_pinging; i++)
926  {
927  peers[i].dest = select_random_peer (&peers[i]);
929  &peers[i].dest->id,
930  GC_u2h (1));
931  if (NULL == peers[i].ch)
932  {
933  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Channel %lu failed\n", i);
935  return;
936  }
938  "%lu => %u %p\n",
939  i,
940  get_index (peers[i].dest),
941  peers[i].ch);
943  &ping, &peers[i]);
944  }
946  if (NULL != disconnect_task)
951  + 1),
953  (void *) __LINE__);
955  &next_rnd,
956  NULL);
957 }
void GNUNET_CADET_TEST_cleanup(struct GNUNET_CADET_TEST_Context *ctx)
Clean up the testbed.
#define number_rounds
Total number of rounds.
static struct GNUNET_TIME_Relative delay_ms_rnd(unsigned int max)
Calculate a random delay.
static unsigned long long peers_total
Total number of peers.
static unsigned int get_index(struct CadetPeer *peer)
Get the index of a peer in the peers array.
static struct GNUNET_TIME_Relative round_time
Duration of each round.
static void disconnect_cadet_peers(void *cls)
Disconnect from cadet services af all peers, call shutdown.
static void next_rnd(void *cls)
Move to next round.
static struct CadetPeer * select_random_peer(struct CadetPeer *peer)
Select a random peer that has no incoming channel.
static struct GNUNET_SCHEDULER_Task * round_task
Task running each round of the benchmark.
static struct CadetPeer * peers
Operation to get peer ids.
static unsigned long long peers_pinging
Number of peers doing pings.
static struct GNUNET_CADET_TEST_Context * test_ctx
Test context (to shut down).
static struct GNUNET_SCHEDULER_Task * disconnect_task
Task called to disconnect peers, before shutdown.
static void ping(void *cls)
Send a ping to destination.
static struct GNUNET_SCHEDULER_Task * test_task
Task to perform tests.
static unsigned long long peers_running
Number of currently running peers.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
Definition: cadet_api.c:1015
const struct GNUNET_HashCode * GC_u2h(uint32_t port)
Transitional function to convert an unsigned int port to a hash value.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_INFO
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1272
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:484
struct GNUNET_SCHEDULER_Task * ping_task
Task to do the next ping.
struct GNUNET_CADET_Channel * ch
Channel handle for the root peer.
struct CadetPeer * dest
Destinaton to ping.

References cadet, CadetPeer::ch, ch, delay_ms_rnd(), warningfilter::dest, CadetPeer::dest, disconnect_cadet_peers(), disconnect_task, GC_u2h(), get_index(), GNUNET_CADET_channel_create(), GNUNET_CADET_TEST_cleanup(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_multiply(), next_rnd(), number_rounds, peers, peers_pinging, peers_running, peers_total, ping(), CadetPeer::ping_task, round_task, round_time, select_random_peer(), test_ctx, and test_task.

Referenced by incoming_channel(), and peer_id_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delay_ms_rnd()

static struct GNUNET_TIME_Relative delay_ms_rnd ( unsigned int  max)
static

Calculate a random delay.

Parameters
maxExclusive maximum, in ms.
Returns
A time between 0 a max-1 ms.

Definition at line 258 of file gnunet-cadet-profiler.c.

270 {
271  unsigned int rnd;
272 
275 }
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
#define max(x, y)

Referenced by start_test(), and tmt_rdy_ping().

Here is the caller graph for this function:

◆ get_index()

static unsigned int get_index ( struct CadetPeer peer)
static

Get the index of a peer in the peers array.

Parameters
peerPeer whose index to get.
Returns
Index of peer in peers.

Definition at line 286 of file gnunet-cadet-profiler.c.

287 {
288  return peer - peers;
289 }
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References peer, and peers.

Referenced by incoming_channel(), ping(), start_test(), and warmup().

Here is the caller graph for this function:

◆ show_end_data()

static void show_end_data ( void  )
static

Show the results of the test (banwidth achieved) and log them to GAUGER.

Definition at line 296 of file gnunet-cadet-profiler.c.

297 {
298  struct CadetPeer *peer;
299  unsigned int i;
300  unsigned int j;
301 
302  for (i = 0; i < number_rounds; i++)
303  {
304  for (j = 0; j < peers_pinging; j++)
305  {
306  peer = &peers[j];
307  fprintf (stdout,
308  "ROUND %3u PEER %3u: %10.2f / %10.2f, PINGS: %3u, PONGS: %3u\n",
309  i, j, peer->mean[i], sqrt (peer->var[i] / (peer->pongs[i] - 1)),
310  peer->pings[i], peer->pongs[i]);
311  }
312  }
313 }
Peer description.

References number_rounds, peer, peers, and peers_pinging.

Referenced by finish_profiler().

Here is the caller graph for this function:

◆ disconnect_cadet_peers()

static void disconnect_cadet_peers ( void *  cls)
static

Disconnect from cadet services af all peers, call shutdown.

Parameters
clsClosure (unused).

Definition at line 322 of file gnunet-cadet-profiler.c.

323 {
324  long line = (long) cls;
325  unsigned int i;
326 
328  "disconnecting cadet service, called from line %ld\n",
329  line);
330  disconnect_task = NULL;
331  for (i = 0; i < peers_total; i++)
332  {
333  if (NULL != peers[i].op)
335 
336  if (peers[i].up != GNUNET_YES)
337  continue;
338 
339  if (NULL != peers[i].ch)
340  {
342  "%u: channel %p\n", i, peers[i].ch);
344  }
345  if (NULL != peers[i].warmup_ch)
346  {
348  "%u: warmup channel %p\n",
349  i, peers[i].warmup_ch);
350  GNUNET_CADET_channel_destroy (peers[i].warmup_ch);
351  }
352  if (NULL != peers[i].incoming_ch)
353  {
355  "%u: incoming channel %p\n",
356  i, peers[i].incoming_ch);
357  GNUNET_CADET_channel_destroy (peers[i].incoming_ch);
358  }
359  }
362 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static char * line
Desired phone line (string to be converted to a hash).
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:830
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
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:2021

References ch, disconnect_task, GNUNET_CADET_channel_destroy(), GNUNET_CADET_TEST_cleanup(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_operation_done(), GNUNET_YES, CadetPeer::incoming_ch, line, op, peers, peers_total, test_ctx, CadetPeer::up, and CadetPeer::warmup_ch.

Referenced by abort_test(), shutdown_task(), start_test(), stats_cont(), and tmain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Shut down peergroup, clean up.

Parameters
clsClosure (unused).

Definition at line 371 of file gnunet-cadet-profiler.c.

372 {
374  "Ending test.\n");
375  if (NULL != disconnect_task)
376  {
379  (void *) __LINE__);
380  }
381  if (NULL != round_task)
382  {
384  round_task = NULL;
385  }
386  if (NULL != test_task)
387  {
389  test_task = NULL;
390  }
391 }
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:1299

References disconnect_cadet_peers(), disconnect_task, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), round_task, and test_task.

Referenced by tmain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ abort_test()

static void abort_test ( long  line)
static

Finish test normally: schedule disconnect and shutdown.

Parameters
lineLine in the code the abort is requested from (LINE).

Definition at line 400 of file gnunet-cadet-profiler.c.

401 {
402  if (disconnect_task != NULL)
403  {
406  (void *) line);
407  }
408 }

References disconnect_cadet_peers(), disconnect_task, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), and line.

Referenced by peer_id_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stats_cont()

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

Stats callback.

Finish the stats testbed operation and when all stats have been iterated, shutdown the test.

Parameters
clsclosure
opthe operation that has been finished
emsgerror message in case the operation has failed; will be NULL if operation has executed successfully.

Definition at line 421 of file gnunet-cadet-profiler.c.

422 {
423  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "... collecting statistics done.\n");
425 
426  if (NULL != disconnect_task)
429  (void *) __LINE__);
430 }
static struct GNUNET_TESTBED_Operation * stats_op
Testbed Operation (to get stats).

References disconnect_cadet_peers(), disconnect_task, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_operation_done(), and stats_op.

Referenced by collect_stats().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stats_iterator()

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

Process statistic values.

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 445 of file gnunet-cadet-profiler.c.

451 {
452  uint32_t i;
453 
456  " STATS %u - %s [%s]: %llu\n",
457  i, subsystem, name,
458  (unsigned long long) value);
459 
460  return GNUNET_OK;
461 }
static char * value
Value of the record to add/remove.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
@ GNUNET_OK
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:2291
const char * name

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_TESTBED_get_index(), name, peer, subsystem, and value.

Referenced by collect_stats().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_stats()

static void collect_stats ( void *  cls)
static

Task check that keepalives were sent and received.

Parameters
clsClosure (NULL).

Definition at line 470 of file gnunet-cadet-profiler.c.

471 {
473  "Start collecting statistics...\n");
476  NULL, NULL,
478  &stats_cont, NULL);
479 }
static struct GNUNET_TESTBED_Peer ** testbed_handles
Testbed peer handles.
static int stats_iterator(void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Process statistic values.
static void stats_cont(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Stats callback.
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...

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_TESTBED_get_statistics(), peers_total, stats_cont(), stats_iterator(), stats_op, and testbed_handles.

Referenced by finish_profiler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finish_profiler()

static void finish_profiler ( void *  cls)
static

Finish profiler normally.

Signal finish and start collecting stats.

Parameters
clsClosure (unused).

Definition at line 488 of file gnunet-cadet-profiler.c.

489 {
491  show_end_data ();
493 }
static void show_end_data(void)
Show the results of the test (banwidth achieved) and log them to GAUGER.
static void collect_stats(void *cls)
Task check that keepalives were sent and received.
static int test_finished
Flag to notify callbacks not to generate any new traffic anymore.

References collect_stats(), GNUNET_SCHEDULER_add_now(), GNUNET_YES, show_end_data(), and test_finished.

Referenced by next_rnd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjust_running_peers()

static void adjust_running_peers ( unsigned int  target)
static

Set the total number of running peers.

Parameters
targetDesired number of running peers.

Definition at line 502 of file gnunet-cadet-profiler.c.

503 {
505  unsigned int delta;
506  unsigned int run;
507  unsigned int i;
508  unsigned int r;
509 
510  GNUNET_assert (target <= peers_total);
511 
512  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "adjust peers to %u\n", target);
513  if (target > peers_running)
514  {
515  delta = target - peers_running;
516  run = GNUNET_YES;
517  }
518  else
519  {
520  delta = peers_running - target;
521  run = GNUNET_NO;
522  }
523 
524  for (i = 0; i < delta; i++)
525  {
526  do
527  {
530  r += peers_pinging;
531  }
532  while (peers[r].up == run || NULL != peers[r].incoming);
533  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n",
534  run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id));
535 
536  if (NULL != peers[r].ping_task)
537  {
538  GNUNET_SCHEDULER_cancel (peers[r].ping_task);
539  peers[r].ping_task = NULL;
540  }
541  if (NULL != peers[r].ping_ntr)
542  {
543  GNUNET_CADET_notify_transmit_ready_cancel (peers[r].ping_ntr);
544  peers[r].ping_ntr = NULL;
545  }
546  peers[r].up = run;
547 
548  if (NULL != peers[r].ch)
550  peers[r].ch = NULL;
551  if (NULL != peers[r].dest)
552  {
553  if (NULL != peers[r].dest->incoming_ch)
554  GNUNET_CADET_channel_destroy (peers[r].dest->incoming_ch);
555  peers[r].dest->incoming_ch = NULL;
556  }
557 
559  "cadet", NULL, NULL, run);
560  GNUNET_break (NULL != op);
561  peers_running += run ? 1 : -1;
563  }
564 }
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
Definition: gnunet-abd.c:757
@ GNUNET_NO
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_manage_service(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, unsigned int start)
Start or stop given service at a peer.
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36
int up
Is peer up?
struct GNUNET_CADET_TransmitHandle * ping_ntr
NTR operation for the next ping.
struct GNUNET_CADET_Channel * incoming_ch
Channel handle for the dest peer.
Opaque handle to an abstract operation to be executed by the testing framework.

References CadetPeer::ch, ch, delta, warningfilter::dest, CadetPeer::dest, GNUNET_assert, GNUNET_break, GNUNET_CADET_channel_destroy(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_peer_manage_service(), GNUNET_YES, CadetPeer::incoming_ch, op, peers, peers_pinging, peers_running, peers_total, CadetPeer::ping_ntr, CadetPeer::ping_task, run(), testbed_handles, and CadetPeer::up.

Referenced by next_rnd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_rnd()

static void next_rnd ( void *  cls)
static

Move to next round.

Parameters
clsClosure (round #).

Definition at line 573 of file gnunet-cadet-profiler.c.

574 {
576  "ROUND %u\n",
577  current_round);
578  if (0.0 == rounds[current_round])
579  {
580  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Finishing\n");
582  return;
583  }
585  current_round++;
586 
588  &next_rnd,
589  NULL);
590 }
static unsigned int current_round
Round number.
static float rounds[]
Ratio of peers active.
static void finish_profiler(void *cls)
Finish profiler normally.
static void adjust_running_peers(unsigned int target)
Set the total number of running peers.

References adjust_running_peers(), current_round, finish_profiler(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), peers_total, round_task, round_time, and rounds.

Referenced by start_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmt_rdy_ping()

static size_t tmt_rdy_ping ( void *  cls,
size_t  size,
void *  buf 
)
static

Transmit ping callback.

Parameters
clsClosure (peer for PING, NULL for PONG).
sizeSize of the transmit buffer.
bufPointer to the beginning of the buffer.
Returns
Number of bytes written to buf.
Parameters
clsClosure (peer).
sizeSize of the buffer we have.
bufBuffer to copy data to.

Definition at line 686 of file gnunet-cadet-profiler.c.

687 {
688  struct CadetPeer *peer = cls;
689  struct CadetPingMessage *msg = buf;
690 
691  peer->ping_ntr = NULL;
693  "tmt_rdy called, filling buffer\n");
694  if ((size < sizeof(struct CadetPingMessage)) || (NULL == buf))
695  {
698  "size %u, buf %p, data_sent %u, data_received %u\n",
699  (unsigned int) size,
700  buf,
701  peer->data_sent,
702  peer->data_received);
703 
704  return 0;
705  }
707  "Sending: msg %d\n",
708  peer->data_sent);
709  msg->header.size = htons (size);
710  msg->header.type = htons (PING);
711  msg->counter = htonl (peer->data_sent++);
712  msg->round_number = htonl (current_round);
714  peer->pings[current_round]++;
716  &ping, peer);
717 
718  return sizeof(struct CadetPingMessage);
719 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define PING
#define PING_PERIOD
Paximum ping period in milliseconds.
static char buf[2048]
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
static unsigned int size
Size of the "table".
Definition: peer.c:68
Message type for pings.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References buf, current_round, delay_ms_rnd(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_YES, msg, peer, PING, ping(), PING_PERIOD, GNUNET_MessageHeader::size, size, test_finished, and GNUNET_MessageHeader::type.

Referenced by ping().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmt_rdy_pong()

static size_t tmt_rdy_pong ( void *  cls,
size_t  size,
void *  buf 
)
static

Transmit pong callback.

Parameters
clsClosure (copy of PING message, to be freed).
sizeSize of the buffer we have.
bufBuffer to copy data to.

Definition at line 614 of file gnunet-cadet-profiler.c.

615 {
616  struct CadetPingMessage *ping = cls;
617  struct CadetPingMessage *pong;
618 
619  if ((0 == size) || (NULL == buf))
620  {
621  GNUNET_free (ping);
622  return 0;
623  }
624  pong = (struct CadetPingMessage *) buf;
625  GNUNET_memcpy (pong, ping, sizeof(*ping));
626  pong->header.type = htons (PONG);
627 
628  GNUNET_free (ping);
629  return sizeof(*ping);
630 }
#define PONG
static void pong(struct GNUNET_CADET_Channel *channel, const struct CadetPingMessage *ping)
Reply with a pong to origin.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_free(ptr)
Wrapper around free.

References buf, GNUNET_free, GNUNET_memcpy, ping(), PONG, pong(), and size.

Referenced by pong().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ping()

static void ping ( void *  cls)
static

Send a ping to destination.

Parameters
clsClosure (peer).

Definition at line 639 of file gnunet-cadet-profiler.c.

640 {
641  struct CadetPeer *peer = cls;
642 
643  peer->ping_task = NULL;
644  if (GNUNET_YES == test_finished)
645  return;
647  "%u -> %u (%u)\n",
648  get_index (peer),
649  get_index (peer->dest),
650  peer->data_sent);
651  peer->ping_ntr = GNUNET_CADET_notify_transmit_ready (peer->ch, GNUNET_NO,
653  sizeof(struct
655  &tmt_rdy_ping, peer);
656 }
static size_t tmt_rdy_ping(void *cls, size_t size, void *buf)
Transmit ping callback.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".

References get_index(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, peer, test_finished, and tmt_rdy_ping().

Referenced by GSC_KX_init(), GST_validation_handle_ping(), pong(), start_test(), tmt_rdy_ping(), tmt_rdy_pong(), and transmit_ping_if_allowed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pong()

static void pong ( struct GNUNET_CADET_Channel channel,
const struct CadetPingMessage ping 
)
static

Reply with a pong to origin.

Definition at line 664 of file gnunet-cadet-profiler.c.

666 {
667  struct CadetPingMessage *copy;
668 
669  copy = GNUNET_new (struct CadetPingMessage);
670  *copy = *ping;
671  GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
673  sizeof(struct CadetPingMessage),
674  &tmt_rdy_pong, copy);
675 }
static size_t tmt_rdy_pong(void *cls, size_t size, void *buf)
Transmit pong callback.
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References GNUNET_new, GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_REL, ping(), and tmt_rdy_pong().

Referenced by GSC_KX_init(), GST_validation_handle_ping(), GST_validation_handle_pong(), multicast_pong(), ping_handler(), and tmt_rdy_pong().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ping_handler()

int ping_handler ( void *  cls,
struct GNUNET_CADET_Channel channel,
void **  channel_ctx,
const struct GNUNET_MessageHeader message 
)

Function is called whenever a PING message is received.

Parameters
clsclosure (peer #, set from GNUNET_CADET_connect)
channelconnection to the other end
channel_ctxplace to store local state associated with the channel
messagethe actual message
Returns
GNUNET_OK to keep the connection open, GNUNET_SYSERR to close it (signal serious error)

Definition at line 733 of file gnunet-cadet-profiler.c.

736 {
737  long n = (long) cls;
738 
740  "%u got PING\n",
741  (unsigned int) n);
742  GNUNET_CADET_receive_done (channel);
743  if (GNUNET_NO == test_finished)
744  pong (channel, (struct CadetPingMessage *) message);
745 
746  return GNUNET_OK;
747 }
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
Definition: cadet_api.c:872

References GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_OK, pong(), and test_finished.

Here is the call graph for this function:

◆ pong_handler()

int pong_handler ( void *  cls,
struct GNUNET_CADET_Channel channel,
void **  channel_ctx,
const struct GNUNET_MessageHeader message 
)

Function is called whenever a PONG message is received.

Parameters
clsclosure (peer #, set from GNUNET_CADET_connect)
channelconnection to the other end
channel_ctxplace to store local state associated with the channel
messagethe actual message
Returns
GNUNET_OK to keep the connection open, GNUNET_SYSERR to close it (signal serious error)

Definition at line 761 of file gnunet-cadet-profiler.c.

764 {
765  long n = (long) cls;
766  struct CadetPeer *peer;
767  struct CadetPingMessage *msg;
768  struct GNUNET_TIME_Absolute send_time;
769  struct GNUNET_TIME_Relative latency;
770  unsigned int r /* Ping round */;
771  float delta;
772 
773  GNUNET_CADET_receive_done (channel);
774  peer = &peers[n];
775 
776  msg = (struct CadetPingMessage *) message;
777 
778  send_time = GNUNET_TIME_absolute_ntoh (msg->timestamp);
779  latency = GNUNET_TIME_absolute_get_duration (send_time);
780  r = ntohl (msg->round_number);
781  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <- %u (%u) latency: %s\n",
782  get_index (peer),
783  get_index (peer->dest),
784  (uint32_t) ntohl (msg->counter),
786 
787  /* Online variance calculation */
788  peer->pongs[r]++;
789  delta = latency.rel_value_us - peer->mean[r];
790  peer->mean[r] = peer->mean[r] + delta / peer->pongs[r];
791  peer->var[r] += delta * (latency.rel_value_us - peer->mean[r]);
792 
793  return GNUNET_OK;
794 }
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
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
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
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.

◆ incoming_channel()

static void* incoming_channel ( void *  cls,
struct GNUNET_CADET_Channel channel,
const struct GNUNET_PeerIdentity initiator,
const struct GNUNET_HashCode port,
enum GNUNET_CADET_ChannelOption  options 
)
static

Method called whenever another peer has added us to a channel the other peer initiated.

Parameters
clsClosure.
channelNew handle to the channel.
initiatorPeer that started the channel.
portPort this channel is connected to.
optionschannel option flags
Returns
Initial channel context for the channel (can be NULL – that's not an error).

Definition at line 820 of file gnunet-cadet-profiler.c.

824 {
825  long n = (long) cls;
826  struct CadetPeer *peer;
827 
829  GNUNET_assert (NULL != peer);
830  if (NULL == peers[n].incoming)
831  {
833  "WARMUP %3u: %u <= %u\n",
834  peers_warmup,
835  (unsigned int) n,
836  get_index (peer));
837  peers_warmup++;
839  return NULL;
840  if (NULL != test_task)
841  {
844  &start_test, NULL);
845  }
846  return NULL;
847  }
849  GNUNET_assert (peer->dest == &peers[n]);
851  "%u <= %u %p\n",
852  (unsigned int) n,
853  get_index (peer),
854  channel);
855  peers[n].incoming_ch = channel;
856 
857  return NULL;
858 }
static struct GNUNET_CONTAINER_MultiPeerMap * ids
GNUNET_PeerIdentity -> CadetPeer.
static void start_test(void *cls)
START THE TEST ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
static unsigned int peers_warmup
Warmup progress.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct CadetPeer * incoming
Incoming channel for pings.

References get_index(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_get(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_UNIT_SECONDS, ids, CadetPeer::incoming, CadetPeer::incoming_ch, peer, peers, peers_total, peers_warmup, start_test(), and test_task.

Here is the call graph for this function:

◆ channel_cleaner()

static void channel_cleaner ( void *  cls,
const struct GNUNET_CADET_Channel channel,
void *  channel_ctx 
)
static

Function called whenever an inbound channel is destroyed.

Should clean up any associated state.

Parameters
clsclosure (set from GNUNET_CADET_connect)
channelconnection to the other end (henceforth invalid)
channel_ctxplace where local state associated with the channel is stored

Definition at line 871 of file gnunet-cadet-profiler.c.

874 {
875  long n = (long) cls;
876  struct CadetPeer *peer = &peers[n];
877 
879  "Channel %p disconnected at peer %ld\n", channel, n);
880  if (peer->ch == channel)
881  peer->ch = NULL;
882 }

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, peer, and peers.

◆ select_random_peer()

static struct CadetPeer* select_random_peer ( struct CadetPeer peer)
static

Select a random peer that has no incoming channel.

Parameters
peerID of the peer connecting. NULL if irrelevant (warmup).
Returns
Random peer not yet connected to.

Definition at line 893 of file gnunet-cadet-profiler.c.

894 {
895  unsigned int r;
896 
897  do
898  {
900  }
901  while (NULL != peers[r].incoming);
902  peers[r].incoming = peer;
903 
904  return &peers[r];
905 }

References GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), CadetPeer::incoming, peer, peers, and peers_total.

Referenced by start_test(), and warmup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ warmup()

static void warmup ( void  )
static

Do warmup: create some channels to spread information about the topology.

Definition at line 964 of file gnunet-cadet-profiler.c.

965 {
966  struct CadetPeer *peer;
967  unsigned int i;
968 
969  for (i = 0; i < peers_total; i++)
970  {
971  peer = select_random_peer (NULL);
972  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "WARMUP %u => %u\n",
973  i, get_index (peer));
974  peers[i].warmup_ch =
976  GC_u2h (1));
977  if (NULL == peers[i].warmup_ch)
978  {
979  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Warmup %u failed\n", i);
981  return;
982  }
983  }
984 }
struct GNUNET_CADET_Channel * warmup_ch
Channel handle for a warmup channel.

References cadet, GC_u2h(), get_index(), GNUNET_CADET_channel_create(), GNUNET_CADET_TEST_cleanup(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, peer, peers, peers_total, select_random_peer(), test_ctx, and CadetPeer::warmup_ch.

Referenced by peer_id_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_id_cb()

static void peer_id_cb ( void *  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
clsthe closure from GNUNET_TESTBED_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; NULL if the operation is successful

Definition at line 997 of file gnunet-cadet-profiler.c.

1001 {
1002  long n = (long) cls;
1003 
1004  if ((NULL == pinfo) || (NULL != emsg))
1005  {
1006  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
1007  abort_test (__LINE__);
1008  return;
1009  }
1010  peers[n].id = *(pinfo->result.id);
1012  "%ld id: %s\n",
1013  n,
1014  GNUNET_i2s (&peers[n].id));
1018 
1020  peers[n].op = NULL;
1021 
1022  p_ids++;
1023  if (p_ids < peers_total)
1024  return;
1025  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got all IDs, starting profiler\n");
1026  if (do_warmup)
1027  {
1028  struct GNUNET_TIME_Relative delay;
1029 
1030  warmup ();
1032  100 * peers_total);
1034  return; /* start_test from incoming_channel */
1035  }
1036  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting in a second...\n");
1038  &start_test, NULL);
1039 }
static int do_warmup
Do preconnect? (Each peer creates a tunnel to one other peer).
static void abort_test(long line)
Finish test normally: schedule disconnect and shutdown.
static unsigned int p_ids
Peer ids counter.
static void warmup(void)
Do warmup: create some channels to spread information about the topology.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
struct GNUNET_PeerIdentity id
Peer ID.
struct GNUNET_TESTBED_Operation * op
Testbed Operation (to get peer id, etc).
union GNUNET_TESTBED_PeerInformation::@49 result
The result of the get information operation; Choose according to the pit.
struct GNUNET_PeerIdentity * id
The identity of the peer.

References abort_test(), delay, do_warmup, GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_TESTBED_operation_done(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_TIME_UNIT_SECONDS, CadetPeer::id, GNUNET_TESTBED_PeerInformation::id, ids, op, CadetPeer::op, p_ids, peers, peers_total, GNUNET_TESTBED_PeerInformation::result, start_test(), test_task, and warmup().

Referenced by tmain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmain()

static void tmain ( void *  cls,
struct GNUNET_CADET_TEST_Context ctx,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  testbed_peers,
struct GNUNET_CADET_Handle **  cadetes 
)
static

test main: start test when all peers are connected

Parameters
clsClosure.
ctxArgument to give to GNUNET_CADET_TEST_cleanup on test end.
num_peersNumber of peers that are running.
testbed_peersArray of peers.
cadetesHandle to each of the CADETs of the peers.

Definition at line 1052 of file gnunet-cadet-profiler.c.

1057 {
1058  unsigned long i;
1059 
1061  "test main\n");
1062  test_ctx = ctx;
1068  (void *) __LINE__);
1070  for (i = 0; i < peers_total; i++)
1071  {
1073  "requesting id %ld\n",
1074  i);
1075  peers[i].up = GNUNET_YES;
1076  peers[i].cadet = cadetes[i];
1077  peers[i].op =
1080  &peer_id_cb, (void *) i);
1081  }
1082  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "requested peer ids\n");
1083  /* Continues from pi_cb -> do_test */
1084 }
static void shutdown_task(void *cls)
Shut down peergroup, clean up.
static void peer_id_cb(void *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.
#define SHORT_TIME
Time to wait for stuff that should be rather fast.
static unsigned int num_peers
static struct GNUNET_TESTBED_Peer ** testbed_peers
Handles to all of the running peers.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
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_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.
@ GNUNET_TESTBED_PIT_IDENTITY
What is the identity of the peer? Returns a 'const struct GNUNET_PeerIdentity *'.
struct GNUNET_CADET_Handle * cadet
Cadet handle for the root peer.

References CadetPeer::cadet, ctx, disconnect_cadet_peers(), disconnect_task, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_PIT_IDENTITY, GNUNET_YES, num_peers, CadetPeer::op, peer_id_cb(), peers, peers_running, peers_total, SHORT_TIME, shutdown_task(), test_ctx, testbed_handles, testbed_peers, and CadetPeer::up.

Referenced by GNUNET_CADET_TEST_ruN(), and GNUNET_DHT_TEST_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main: start profiler.

Definition at line 1091 of file gnunet-cadet-profiler.c.

1092 {
1093  static const struct GNUNET_HashCode *ports[2];
1094  const char *config_file;
1095 
1096  config_file = ".profiler.conf";
1097 
1098  if (4 > argc)
1099  {
1100  fprintf (stderr,
1101  "usage: %s ROUND_TIME PEERS PINGS [DO_WARMUP]\n",
1102  argv[0]);
1103  fprintf (stderr,
1104  "example: %s 30s 16 1 Y\n",
1105  argv[0]);
1106  return 1;
1107  }
1108 
1109  if (GNUNET_OK !=
1111  &round_time))
1112  {
1113  fprintf (stderr,
1114  "%s is not a valid time\n",
1115  argv[1]);
1116  return 1;
1117  }
1118 
1119  peers_total = atoll (argv[2]);
1120  if (2 > peers_total)
1121  {
1122  fprintf (stderr,
1123  "%s peers is not valid (> 2)\n",
1124  argv[1]);
1125  return 1;
1126  }
1128  struct CadetPeer);
1129  peers_pinging = atoll (argv[3]);
1130 
1131  if (peers_total < 2 * peers_pinging)
1132  {
1134  "not enough peers, total should be > 2 * peers_pinging\n");
1135  return 1;
1136  }
1137 
1138  do_warmup = (5 > argc || argv[4][0] != 'N');
1139 
1141  GNUNET_YES);
1142  GNUNET_assert (NULL != ids);
1143  p_ids = 0;
1145  ports[0] = GC_u2h (1);
1146  ports[1] = 0;
1147  GNUNET_CADET_TEST_run ("cadet-profiler", config_file, peers_total,
1148  &tmain, NULL, /* tmain cls */
1150  handlers, ports);
1151  GNUNET_free (peers);
1152 
1153  return 0;
1154 }
static char * config_file
Set to the name of the config file used.
Definition: gnunet-arm.c:84
static void * incoming_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator, const struct GNUNET_HashCode *port, enum GNUNET_CADET_ChannelOption options)
Method called whenever another peer has added us to a channel the other peer initiated.
static void tmain(void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **testbed_peers, struct GNUNET_CADET_Handle **cadetes)
test main: start test when all peers are connected
static void channel_cleaner(void *cls, const struct GNUNET_CADET_Channel *channel, void *channel_ctx)
Function called whenever an inbound channel is destroyed.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:260
long long atoll(const char *nptr)
A 512-bit hashcode.

Variable Documentation

◆ rounds

float rounds[] = { 0.8, 0.6, 0.8, 0.5, 0.3, 0.8, 0.0 }
static

Ratio of peers active.

First round always is 1.0.

Definition at line 59 of file gnunet-cadet-profiler.c.

Referenced by next_rnd().

◆ round_time

struct GNUNET_TIME_Relative round_time
static

Duration of each round.

Definition at line 59 of file gnunet-cadet-profiler.c.

Referenced by next_rnd(), and start_test().

◆ ids

◆ testbed_handles

struct GNUNET_TESTBED_Peer** testbed_handles
static

Testbed peer handles.

Definition at line 176 of file gnunet-cadet-profiler.c.

Referenced by adjust_running_peers(), collect_stats(), and tmain().

◆ stats_op

struct GNUNET_TESTBED_Operation* stats_op
static

Testbed Operation (to get stats).

Definition at line 181 of file gnunet-cadet-profiler.c.

Referenced by collect_stats(), and stats_cont().

◆ peers

◆ p_ids

unsigned int p_ids
static

Peer ids counter.

Definition at line 191 of file gnunet-cadet-profiler.c.

Referenced by peer_id_cb().

◆ peers_total

unsigned long long peers_total
static

◆ peers_running

unsigned long long peers_running
static

Number of currently running peers.

Definition at line 201 of file gnunet-cadet-profiler.c.

Referenced by adjust_running_peers(), start_test(), and tmain().

◆ peers_pinging

unsigned long long peers_pinging
static

Number of peers doing pings.

Definition at line 206 of file gnunet-cadet-profiler.c.

Referenced by adjust_running_peers(), show_end_data(), and start_test().

◆ test_ctx

struct GNUNET_CADET_TEST_Context* test_ctx
static

Test context (to shut down).

Definition at line 211 of file gnunet-cadet-profiler.c.

Referenced by disconnect_cadet_peers(), start_test(), tmain(), and warmup().

◆ disconnect_task

struct GNUNET_SCHEDULER_Task* disconnect_task
static

Task called to disconnect peers, before shutdown.

Definition at line 216 of file gnunet-cadet-profiler.c.

Referenced by abort_test(), disconnect_cadet_peers(), shutdown_task(), start_test(), stats_cont(), and tmain().

◆ test_task

struct GNUNET_SCHEDULER_Task* test_task
static

Task to perform tests.

Definition at line 221 of file gnunet-cadet-profiler.c.

Referenced by incoming_channel(), peer_id_cb(), shutdown_task(), and start_test().

◆ current_round

unsigned int current_round
static

Round number.

Definition at line 226 of file gnunet-cadet-profiler.c.

Referenced by next_rnd(), and tmt_rdy_ping().

◆ do_warmup

int do_warmup
static

Do preconnect? (Each peer creates a tunnel to one other peer).

Definition at line 231 of file gnunet-cadet-profiler.c.

Referenced by peer_id_cb().

◆ peers_warmup

unsigned int peers_warmup
static

Warmup progress.

Definition at line 236 of file gnunet-cadet-profiler.c.

Referenced by incoming_channel().

◆ test_finished

int test_finished ( void  )
static

Flag to notify callbacks not to generate any new traffic anymore.

Definition at line 241 of file gnunet-cadet-profiler.c.

Referenced by finish_profiler(), ping(), ping_handler(), and tmt_rdy_ping().

◆ round_task

struct GNUNET_SCHEDULER_Task* round_task
static

Task running each round of the benchmark.

Definition at line 246 of file gnunet-cadet-profiler.c.

Referenced by next_rnd(), shutdown_task(), and start_test().

◆ handlers

struct GNUNET_CADET_MessageHandler handlers[]
static
Initial value:
= {
{ &ping_handler, 1 , sizeof(struct CadetPingMessage) },
{ &pong_handler, 2 , sizeof(struct CadetPingMessage) },
{ NULL, 0, 0 }
}
int pong_handler(void *cls, struct GNUNET_CADET_Channel *channel, void **channel_ctx, const struct GNUNET_MessageHeader *message)
Function is called whenever a PONG message is received.
int ping_handler(void *cls, struct GNUNET_CADET_Channel *channel, void **channel_ctx, const struct GNUNET_MessageHeader *message)
Function is called whenever a PING message is received.

Handlers, for diverse services.

Definition at line 761 of file gnunet-cadet-profiler.c.

Referenced by advertise_dns_exit(), connect_check_run(), connect_task(), connect_tunnel(), create_loc_uri(), demultiplex_with_cmc(), do_connect(), do_peer_connect(), do_plugin_connect(), do_reconnect(), GCO_init(), GCT_create_tunnel(), get_cadet(), GNUNET_CADET_channel_create(), GNUNET_CADET_open_port(), GNUNET_CADET_TEST_ruN(), GNUNET_CLIENT_connect(), GNUNET_CONVERSATION_call_start(), GNUNET_CORE_connect(), GNUNET_FS_get_indexed_files(), GNUNET_IDENTITY_ego_lookup(), GNUNET_IDENTITY_ego_lookup_by_suffix(), GNUNET_MQ_copy_handlers(), GNUNET_MQ_copy_handlers2(), GNUNET_MQ_count_handlers(), GNUNET_MQ_queue_for_callbacks(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_REST_handle_request(), GNUNET_REVOCATION_query(), GNUNET_REVOCATION_revoke(), GNUNET_SCALARPRODUCT_accept_computation(), GNUNET_SCALARPRODUCT_start_computation(), GNUNET_SERVER_add_handlers(), GNUNET_SERVICE_run_(), GNUNET_SERVICE_start(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_controller_connect(), GNUNET_TRANSPORT_address_to_string(), GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_TESTING_start_peer(), GSC_KX_init(), GSF_cadet_start_server(), hash_for_index_cb(), libgnunet_plugin_dhtu_gnunet_init(), main(), open_srv_room(), reconnect(), reconnect_arm(), reconnect_arm_monitor(), reconnect_phone(), reconnect_task(), reset_cadet(), run(), search_reconnect(), store_service(), try_connect(), try_reconnect(), and unindex_finish().