GNUnet  0.10.x
Data Structures | Macros | Enumerations | Functions | Variables
gnunet_dht_profiler.c File Reference

Profiler for GNUnet DHT. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "gnunet_dht_service.h"
#include "gnunet_constants.h"
Include dependency graph for gnunet_dht_profiler.c:

Go to the source code of this file.

Data Structures

struct  Context
 Context to hold data of peer. More...
 
struct  ActiveContext
 Context for a peer which actively does DHT PUT/GET. More...
 

Macros

#define MESSAGE(...)   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__)
 
#define DEBUG(...)   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 

Enumerations

enum  { MODE_PUT = 0, MODE_GET = 1 }
 Should we do a PUT (mode = 0) or GET (mode = 1);. More...
 

Functions

static void start_profiling (void)
 Connect to DHT services of active peers. More...
 
static void do_shutdown (void *cls)
 Shutdown task. More...
 
static void bandwidth_stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 Stats callback. More...
 
static int bandwidth_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 summarize ()
 
static void cancel_get (void *cls)
 Task to cancel DHT GET. More...
 
static void get_iter (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data)
 Iterator called on each result obtained for a DHT operation that expects a reply. More...
 
static void delayed_get (void *cls)
 Task to do DHT GETs. More...
 
static void delayed_put (void *cls)
 Task to do DHT PUTs. More...
 
static void put_cont (void *cls)
 Conclude individual PUT operation, schedule the next one. More...
 
static void dht_connected (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 Connection to DHT has been established. More...
 
static void * dht_connect (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to DHT service and return the DHT client handler. More...
 
static void dht_disconnect (void *cls, void *op_result)
 Adapter function called to destroy a connection to a service. More...
 
static void service_started (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 Callback called when DHT service on the peer is started. More...
 
static void test_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
 Signature of a main function for a testcase. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 Main function. More...
 

Variables

static unsigned int put_probability = 100
 Number of peers which should perform a PUT out of 100 peers. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Configuration. More...
 
static char * hosts_file
 Name of the file with the hosts to run the test over. More...
 
static struct Contexta_ctx
 An array of contexts. More...
 
static struct ActiveContexta_ac
 Array of active peers. More...
 
static struct GNUNET_TIME_Relative delay_stats
 The delay between rounds for collecting statistics. More...
 
static struct GNUNET_TIME_Relative delay_put
 The delay to start puts. More...
 
static struct GNUNET_TIME_Relative delay_get
 The delay to start puts. More...
 
static struct GNUNET_TIME_Relative timeout
 The timeout for GET and PUT. More...
 
static unsigned int num_peers
 Number of peers. More...
 
static unsigned int n_active
 Number of active peers. More...
 
static unsigned int n_dht
 Number of DHT service connections we currently have. More...
 
static unsigned long long n_puts
 Number of DHT PUTs made. More...
 
static unsigned int num_puts_per_peer = 1
 Number of DHT PUTs to be made per peer. More...
 
static unsigned long long n_puts_ok
 Number of DHT PUTs succeeded. More...
 
static unsigned int n_gets
 Number of DHT GETs made. More...
 
static unsigned int n_gets_ok
 Number of DHT GETs succeeded. More...
 
static unsigned int n_gets_fail
 Number of DHT GETs succeeded. More...
 
static unsigned int replication
 Replication degree. More...
 
static struct GNUNET_TESTBED_Operationbandwidth_stats_op
 Testbed Operation (to get stats). More...
 
static struct GNUNET_TESTBED_Peer ** testbed_handles
 Testbed peer handles. More...
 
static uint64_t outgoing_bandwidth
 Total number of messages sent by peer. More...
 
static uint64_t incoming_bandwidth
 Total number of messages received by peer. More...
 
static double average_put_path_length
 Average number of hops taken to do put. More...
 
static double average_get_path_length
 Average number of hops taken to do get. More...
 
static unsigned int total_put_path_length
 Total put path length across all peers. More...
 
static unsigned int total_get_path_length
 Total get path length across all peers. More...
 
static int peers_started = 0
 Counter to keep track of peers added to peer_context lists. More...
 
static enum { ... }  mode
 Should we do a PUT (mode = 0) or GET (mode = 1);. More...
 
static int in_shutdown = 0
 Are we shutting down. More...
 

Detailed Description

Profiler for GNUnet DHT.

Author
Sree Harsha Totakura sreeh.nosp@m.arsh.nosp@m.a@tot.nosp@m.akur.nosp@m.a.in

Definition in file gnunet_dht_profiler.c.

Macro Definition Documentation

◆ MESSAGE

#define MESSAGE (   ...)    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__)

Definition at line 34 of file gnunet_dht_profiler.c.

Referenced by bandwidth_stats_cont(), summarize(), and test_run().

◆ DEBUG

#define DEBUG (   ...)    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Should we do a PUT (mode = 0) or GET (mode = 1);.

Enumerator
MODE_PUT 
MODE_GET 

Definition at line 264 of file gnunet_dht_profiler.c.

265 {
266  MODE_PUT = 0,
267 
268  MODE_GET = 1
269 } mode;
static enum @11 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.

Function Documentation

◆ start_profiling()

static void start_profiling ( void  )
static

Connect to DHT services of active peers.

Definition at line 775 of file gnunet_dht_profiler.c.

References Context::ac, ctx, ActiveContext::ctx, DEBUG, dht_connect(), dht_connected(), dht_disconnect(), GNUNET_assert, GNUNET_break, GNUNET_TESTBED_service_connect(), GNUNET_YES, in_shutdown, n_active, Context::op, and Context::peer.

Referenced by dht_disconnect(), and service_started().

776 {
777  struct Context *ctx;
778 
779  DEBUG ("GNUNET_TESTBED_service_connect\n");
781  for (unsigned int i = 0; i < n_active; i++)
782  {
783  struct ActiveContext *ac = &a_ac[i];
784  GNUNET_assert (NULL != (ctx = ac->ctx));
785  GNUNET_assert (NULL == ctx->op);
787  ctx->peer,
788  "dht",
789  &dht_connected, ac,
790  &dht_connect,
792  ac);
793  }
794 }
Context to hold data of peer.
static void dht_disconnect(void *cls, void *op_result)
Adapter function called to destroy a connection to a service.
static void * dht_connect(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to DHT service and return the DHT client handler.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a peer which actively does DHT PUT/GET.
#define DEBUG(...)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
static unsigned int n_active
Number of active peers.
static void dht_connected(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Connection to DHT has been established.
struct GNUNET_TESTBED_Peer * peer
The testbed peer this context belongs to.
struct Context * ctx
The linked peer context.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static int in_shutdown
Are we shutting down.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
static struct ActiveContext * a_ac
Array of active peers.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Shutdown task.

Cleanup all resources and operations.

Parameters
clsNULL

Definition at line 291 of file gnunet_dht_profiler.c.

References Context::ac, ActiveContext::delay_task, ActiveContext::dht_get, ActiveContext::dht_put, GNUNET_DHT_get_stop(), GNUNET_DHT_put_cancel(), GNUNET_free, GNUNET_free_non_null, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_operation_done(), GNUNET_YES, ActiveContext::hash, in_shutdown, num_peers, and Context::op.

Referenced by run().

292 {
293  struct ActiveContext *ac;
294 
296  if (NULL != a_ctx)
297  {
298  for (unsigned int cnt=0; cnt < num_peers; cnt++)
299  {
300  /* Cleanup active context if this peer is an active peer */
301  ac = a_ctx[cnt].ac;
302  if (NULL != ac)
303  {
304  if (NULL != ac->delay_task)
306  if (NULL != ac->hash)
307  free (ac->hash);
308  if (NULL != ac->dht_put)
310  if (NULL != ac->dht_get)
312  }
313  /* Cleanup testbed operation handle at the last as this operation may
314  contain service connection to DHT */
315  if (NULL != a_ctx[cnt].op)
317  }
318  GNUNET_free (a_ctx);
319  a_ctx = NULL;
320  }
321  //FIXME: Should we collect stats only for put/get not for other messages.
322  if (NULL != bandwidth_stats_op)
323  {
325  bandwidth_stats_op = NULL;
326  }
328 }
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:1040
static unsigned int num_peers
Number of peers.
struct GNUNET_HashCode * hash
The hashes of the values stored via this activity context.
Context for a peer which actively does DHT PUT/GET.
static struct Context * a_ctx
An array of contexts.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
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:2046
struct ActiveContext * ac
Active context; NULL if this peer is not an active peer.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1160
static struct GNUNET_TESTBED_Operation * bandwidth_stats_op
Testbed Operation (to get stats).
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static int in_shutdown
Are we shutting down.
struct GNUNET_DHT_GetHandle * dht_get
The get handle.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_SCHEDULER_Task * delay_task
Delay task.
struct GNUNET_DHT_PutHandle * dht_put
The put handle.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
static struct ActiveContext * a_ac
Array of active peers.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bandwidth_stats_cont()

static void bandwidth_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 341 of file gnunet_dht_profiler.c.

References GNUNET_SCHEDULER_shutdown(), incoming_bandwidth, MESSAGE, and outgoing_bandwidth.

Referenced by summarize().

344 {
345  MESSAGE ("# Outgoing (core) bandwidth: %llu bytes\n",
346  (unsigned long long) outgoing_bandwidth);
347  MESSAGE ("# Incoming (core) bandwidth: %llu bytes\n",
348  (unsigned long long) incoming_bandwidth);
349  fprintf (stderr,
350  "Benchmark done. Collect data via gnunet-statistics, then press ENTER to exit.\n");
351  (void) getchar ();
353 }
static uint64_t incoming_bandwidth
Total number of messages received by peer.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static uint64_t outgoing_bandwidth
Total number of messages sent by peer.
#define MESSAGE(...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bandwidth_stats_iterator()

static int bandwidth_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 368 of file gnunet_dht_profiler.c.

References GNUNET_OK, incoming_bandwidth, outgoing_bandwidth, and value.

Referenced by summarize().

374 {
375  static const char *s_sent = "# bytes encrypted";
376  static const char *s_recv = "# bytes decrypted";
377 
378  if (0 == strncmp (s_sent, name, strlen (s_sent)))
380  else if (0 == strncmp(s_recv, name, strlen (s_recv)))
382  return GNUNET_OK;
383 }
static uint64_t incoming_bandwidth
Total number of messages received by peer.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static char * value
Value of the record to add/remove.
static uint64_t outgoing_bandwidth
Total number of messages sent by peer.
const char * name
Here is the caller graph for this function:

◆ summarize()

static void summarize ( )
static

Definition at line 387 of file gnunet_dht_profiler.c.

References average_get_path_length, average_put_path_length, bandwidth_stats_cont(), bandwidth_stats_iterator(), GNUNET_TESTBED_get_statistics(), MESSAGE, n_active, n_gets, n_gets_fail, n_gets_ok, n_puts, and n_puts_ok.

Referenced by cancel_get(), and get_iter().

388 {
389  MESSAGE ("# PUTS started: %llu\n",
390  n_puts);
391  MESSAGE ("# PUTS succeeded: %llu\n",
392  n_puts_ok);
393  MESSAGE ("# GETS made: %u\n",
394  n_gets);
395  MESSAGE ("# GETS succeeded: %u\n",
396  n_gets_ok);
397  MESSAGE ("# GETS failed: %u\n",
398  n_gets_fail);
399  MESSAGE ("# average_put_path_length: %f\n",
401  MESSAGE ("# average_get_path_length: %f\n",
403 
404  if (NULL == testbed_handles)
405  {
406  MESSAGE ("No peers found\n");
407  return;
408  }
409  /* Collect Stats*/
412  "core",
413  NULL,
416  NULL);
417 }
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...
static unsigned int n_gets_ok
Number of DHT GETs succeeded.
static void bandwidth_stats_cont(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Stats callback.
static int bandwidth_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 unsigned int n_active
Number of active peers.
static double average_put_path_length
Average number of hops taken to do put.
static unsigned int n_gets
Number of DHT GETs made.
static struct GNUNET_TESTBED_Operation * bandwidth_stats_op
Testbed Operation (to get stats).
static unsigned long long n_puts
Number of DHT PUTs made.
static struct GNUNET_TESTBED_Peer ** testbed_handles
Testbed peer handles.
#define MESSAGE(...)
static unsigned long long n_puts_ok
Number of DHT PUTs succeeded.
static double average_get_path_length
Average number of hops taken to do get.
static unsigned int n_gets_fail
Number of DHT GETs succeeded.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cancel_get()

static void cancel_get ( void *  cls)
static

Task to cancel DHT GET.

Parameters
clsNULL

Definition at line 426 of file gnunet_dht_profiler.c.

References Context::ac, average_get_path_length, average_put_path_length, ctx, ActiveContext::ctx, ActiveContext::delay_task, ActiveContext::dht_get, GNUNET_assert, GNUNET_DHT_get_stop(), GNUNET_TESTBED_operation_done(), n_active, n_gets_fail, n_gets_ok, Context::op, summarize(), total_get_path_length, and total_put_path_length.

Referenced by delayed_get().

427 {
428  struct ActiveContext *ac = cls;
429  struct Context *ctx = ac->ctx;
430 
431  ac->delay_task = NULL;
432  GNUNET_assert (NULL != ac->dht_get);
434  ac->dht_get = NULL;
435  n_gets_fail++;
436  GNUNET_assert (NULL != ctx->op);
438  ctx->op = NULL;
439 
440  /* If profiling is complete, summarize */
441  if (n_active == n_gets_fail + n_gets_ok)
442  {
445  summarize ();
446  }
447 }
Context to hold data of peer.
static unsigned int n_gets_ok
Number of DHT GETs succeeded.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a peer which actively does DHT PUT/GET.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static unsigned int total_put_path_length
Total put path length across all peers.
static unsigned int n_active
Number of active peers.
static void summarize()
static double average_put_path_length
Average number of hops taken to do put.
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:2046
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1160
struct Context * ctx
The linked peer context.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
struct GNUNET_DHT_GetHandle * dht_get
The get handle.
static double average_get_path_length
Average number of hops taken to do get.
struct GNUNET_SCHEDULER_Task * delay_task
Delay task.
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
static unsigned int n_gets_fail
Number of DHT GETs succeeded.
static unsigned int total_get_path_length
Total get path length across all peers.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_iter()

static void get_iter ( void *  cls,
struct GNUNET_TIME_Absolute  exp,
const struct GNUNET_HashCode key,
const struct GNUNET_PeerIdentity get_path,
unsigned int  get_path_length,
const struct GNUNET_PeerIdentity put_path,
unsigned int  put_path_length,
enum GNUNET_BLOCK_Type  type,
size_t  size,
const void *  data 
)
static

Iterator called on each result obtained for a DHT operation that expects a reply.

Parameters
clsclosure
expwhen will this value expire
keykey of the result
get_pathpeers on reply path (or NULL if not recorded) [0] = datastore's first neighbor, [length - 1] = local peer
get_path_lengthnumber of entries in get_path
put_pathpeers on the PUT path (or NULL if not recorded) [0] = origin, [length - 1] = datastore
put_path_lengthnumber of entries in put_path
typetype of the result
sizenumber of bytes in data
datapointer to the result data

Definition at line 468 of file gnunet_dht_profiler.c.

References Context::ac, average_get_path_length, average_put_path_length, ctx, ActiveContext::ctx, DEBUG, ActiveContext::delay_task, ActiveContext::dht_get, ActiveContext::get_ac, GNUNET_assert, GNUNET_DHT_get_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_operation_done(), n_active, n_gets, n_gets_fail, n_gets_ok, ActiveContext::nrefs, Context::op, summarize(), total_get_path_length, and total_put_path_length.

Referenced by delayed_get().

477 {
478  struct ActiveContext *ac = cls;
479  struct ActiveContext *get_ac = ac->get_ac;
480  struct Context *ctx = ac->ctx;
481 
482  /* we found the data we are looking for */
483  DEBUG ("We found a GET request; %u remaining\n",
484  n_gets - (n_gets_fail + n_gets_ok)); //FIXME: It always prints 1.
485  n_gets_ok++;
486  get_ac->nrefs--;
488  ac->dht_get = NULL;
489  if (ac->delay_task != NULL)
491  ac->delay_task = NULL;
492  GNUNET_assert (NULL != ctx->op);
494  ctx->op = NULL;
495 
496  total_put_path_length = total_put_path_length + (double)put_path_length;
497  total_get_path_length = total_get_path_length + (double)get_path_length;
498  DEBUG ("total_put_path_length = %u,put_path \n",
500  /* Summarize if profiling is complete */
501  if (n_active == n_gets_fail + n_gets_ok)
502  {
504  average_get_path_length = (double)total_get_path_length/(double )n_gets_ok;
505  summarize ();
506  }
507 }
Context to hold data of peer.
static unsigned int n_gets_ok
Number of DHT GETs succeeded.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a peer which actively does DHT PUT/GET.
#define DEBUG(...)
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static unsigned int total_put_path_length
Total put path length across all peers.
static unsigned int n_active
Number of active peers.
static void summarize()
static double average_put_path_length
Average number of hops taken to do put.
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:2046
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1160
struct Context * ctx
The linked peer context.
static unsigned int n_gets
Number of DHT GETs made.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
uint16_t nrefs
The number of peers currently doing GET on our data.
struct ActiveContext * get_ac
The active context used for our DHT GET.
struct GNUNET_DHT_GetHandle * dht_get
The get handle.
static double average_get_path_length
Average number of hops taken to do get.
struct GNUNET_SCHEDULER_Task * delay_task
Delay task.
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
static unsigned int n_gets_fail
Number of DHT GETs succeeded.
static unsigned int total_get_path_length
Total get path length across all peers.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delayed_get()

static void delayed_get ( void *  cls)
static

Task to do DHT GETs.

Parameters
clsthe active context

Definition at line 516 of file gnunet_dht_profiler.c.

References Context::ac, cancel_get(), DEBUG, ActiveContext::delay_task, delayed_put(), ActiveContext::dht, ActiveContext::dht_get, ActiveContext::get_ac, get_iter(), GNUNET_BLOCK_TYPE_TEST, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_DHT_get_start(), GNUNET_DHT_RO_NONE, GNUNET_h2s(), GNUNET_SCHEDULER_add_delayed(), ActiveContext::hash, n_active, n_gets, ActiveContext::nrefs, num_puts_per_peer, and timeout.

Referenced by dht_connected().

517 {
518  struct ActiveContext *ac = cls;
519  struct ActiveContext *get_ac;
520  unsigned int r;
521 
522  ac->delay_task = NULL;
523  get_ac = NULL;
524  while (1)
525  {
527  n_active);
528  get_ac = &a_ac[r];
529  if (NULL != get_ac->hash)
530  break;
531  }
532  get_ac->nrefs++;
533  ac->get_ac = get_ac;
536  DEBUG ("GET_REQUEST_START key %s \n",
537  GNUNET_h2s(&get_ac->hash[r]));
538  ac->dht_get = GNUNET_DHT_get_start (ac->dht,
540  &get_ac->hash[r],
541  1, /* replication level */
543  NULL,
544  0, /* extended query and size */
545  &get_iter,
546  ac); /* GET iterator and closure */
547  n_gets++;
548 
549  /* schedule the timeout task for GET */
551  &cancel_get,
552  ac);
553 }
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_HashCode * hash
The hashes of the values stored via this activity context.
Context for a peer which actively does DHT PUT/GET.
static unsigned int num_puts_per_peer
Number of DHT PUTs to be made per peer.
static void get_iter(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data)
Iterator called on each result obtained for a DHT operation that expects a reply. ...
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define DEBUG(...)
struct GNUNET_DHT_Handle * dht
Handler to the DHT service.
static unsigned int n_active
Number of active peers.
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:1246
static unsigned int n_gets
Number of DHT GETs made.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static struct GNUNET_TIME_Relative timeout
The timeout for GET and PUT.
Block for testing.
uint16_t nrefs
The number of peers currently doing GET on our data.
struct GNUNET_DHT_GetHandle * GNUNET_DHT_get_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls)
Perform an asynchronous GET operation on the DHT identified.
Definition: dht_api.c:1072
struct ActiveContext * get_ac
The active context used for our DHT GET.
struct GNUNET_DHT_GetHandle * dht_get
The get handle.
static void cancel_get(void *cls)
Task to cancel DHT GET.
struct GNUNET_SCHEDULER_Task * delay_task
Delay task.
static struct ActiveContext * a_ac
Array of active peers.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delayed_put()

static void delayed_put ( void *  cls)
static

Task to do DHT PUTs.

If the "put_count" hits zero, we stop the TESTBED operation (connection to DHT) so that others PUTs have a chance.

Parameters
clsthe active context

Definition at line 593 of file gnunet_dht_profiler.c.

References Context::ac, ctx, ActiveContext::ctx, DEBUG, ActiveContext::delay_task, ActiveContext::dht, ActiveContext::dht_put, GNUNET_assert, GNUNET_BLOCK_TYPE_TEST, GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_block(), GNUNET_CRYPTO_random_u32(), GNUNET_DHT_put(), GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_h2s(), GNUNET_TESTBED_operation_done(), GNUNET_TIME_UNIT_FOREVER_ABS, ActiveContext::hash, n_puts, Context::op, put_cont(), ActiveContext::put_count, and replication.

Referenced by delayed_get(), dht_connected(), and put_cont().

594 {
595  struct ActiveContext *ac = cls;
596  char block[65536];
597  size_t block_size;
598 
599  ac->delay_task = NULL;
600  if (0 == ac->put_count)
601  {
602  struct Context *ctx = ac->ctx;
604 
605  GNUNET_assert (NULL != ctx);
606  op = ctx->op;
607  ctx->op = NULL;
609  return;
610  }
611 
612 
613  /* Generate and DHT PUT some random data */
614  block_size = 16; /* minimum */
615  /* make random payload, reserve 512 - 16 bytes for DHT headers */
619  block,
620  block_size);
621  ac->put_count--;
622  GNUNET_CRYPTO_hash (block,
623  block_size,
624  &ac->hash[ac->put_count]);
625  DEBUG ("PUT_REQUEST_START key %s\n",
626  GNUNET_h2s (&ac->hash[ac->put_count]));
627  ac->dht_put = GNUNET_DHT_put (ac->dht,
628  &ac->hash[ac->put_count],
629  replication,
632  block_size,
633  block,
634  GNUNET_TIME_UNIT_FOREVER_ABS, /* expiration time */
635  &put_cont,
636  ac); /* continuation and its closure */
637  n_puts++;
638 }
Context to hold data of peer.
We should keep track of the route that the message took in the P2P network.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_HashCode * hash
The hashes of the values stored via this activity context.
unsigned int put_count
How many puts should we still issue?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a peer which actively does DHT PUT/GET.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define DEBUG(...)
static void put_cont(void *cls)
Conclude individual PUT operation, schedule the next one.
#define GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE
What is the maximum size for encrypted messages? Note that this number imposes a clear limit on the m...
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Opaque handle to an abstract operation to be executed by the testing framework.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
struct GNUNET_DHT_Handle * dht
Handler to the DHT service.
static unsigned int replication
Replication degree.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
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:2046
struct Context * ctx
The linked peer context.
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
Definition: dht_api.c:971
static unsigned long long n_puts
Number of DHT PUTs made.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
Block for testing.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
struct GNUNET_SCHEDULER_Task * delay_task
Delay task.
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
struct GNUNET_DHT_PutHandle * dht_put
The put handle.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ put_cont()

static void put_cont ( void *  cls)
static

Conclude individual PUT operation, schedule the next one.

Parameters
clsthe active context

Definition at line 574 of file gnunet_dht_profiler.c.

References Context::ac, ActiveContext::delay_task, delayed_put(), ActiveContext::dht_put, GNUNET_SCHEDULER_add_now(), and n_puts_ok.

Referenced by delayed_put().

575 {
576  struct ActiveContext *ac = cls;
577 
578  ac->dht_put = NULL;
579  n_puts_ok++;
581  ac);
582 }
static void delayed_put(void *cls)
Task to do DHT PUTs.
Context for a peer which actively does DHT PUT/GET.
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:1273
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static unsigned long long n_puts_ok
Number of DHT PUTs succeeded.
struct GNUNET_SCHEDULER_Task * delay_task
Delay task.
struct GNUNET_DHT_PutHandle * dht_put
The put handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_connected()

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

Connection to DHT has been established.

Call the delay task.

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

Definition at line 651 of file gnunet_dht_profiler.c.

References Context::ac, ctx, ActiveContext::ctx, delay_get, delay_put, ActiveContext::delay_task, delayed_get(), delayed_put(), ActiveContext::dht, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_strerror, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_operation_done(), ActiveContext::hash, mode, MODE_GET, MODE_PUT, num_puts_per_peer, Context::op, ActiveContext::put_count, and GNUNET_TIME_Relative::rel_value_us.

Referenced by start_profiling().

655 {
656  struct ActiveContext *ac = cls;
657  struct Context *ctx = ac->ctx;
658 
659  GNUNET_assert (NULL != ctx); //FIXME: Fails
660  GNUNET_assert (NULL != ctx->op);
661  GNUNET_assert (ctx->op == op);
662  ac->dht = (struct GNUNET_DHT_Handle *) ca_result;
663  if (NULL != emsg)
664  {
666  "Connection to DHT service failed: %s\n",
667  emsg);
668  GNUNET_TESTBED_operation_done (ctx->op); /* Calls dht_disconnect() */
669  ctx->op = NULL;
670  return;
671  }
672  switch (mode)
673  {
674  case MODE_PUT:
675  {
676  struct GNUNET_TIME_Relative peer_delay_put;
677 
678  peer_delay_put.rel_value_us =
682  ac->hash = calloc (ac->put_count,
683  sizeof (struct GNUNET_HashCode));
684  if (NULL == ac->hash)
685  {
687  "calloc");
689  return;
690  }
691  ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_put,
692  &delayed_put,
693  ac);
694  break;
695  }
696  case MODE_GET:
697  {
698  struct GNUNET_TIME_Relative peer_delay_get;
699 
700  peer_delay_get.rel_value_us =
704  ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_get,
705  &delayed_get,
706  ac);
707  break;
708  }
709  }
710 }
Context to hold data of peer.
static void delayed_put(void *cls)
Task to do DHT PUTs.
uint64_t rel_value_us
The actual value.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
struct GNUNET_HashCode * hash
The hashes of the values stored via this activity context.
unsigned int put_count
How many puts should we still issue?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a peer which actively does DHT PUT/GET.
static unsigned int num_puts_per_peer
Number of DHT PUTs to be made per peer.
static void delayed_get(void *cls)
Task to do DHT GETs.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Connection to the DHT service.
Definition: dht_api.c:205
struct GNUNET_DHT_Handle * dht
Handler to the DHT service.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
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:1246
static struct GNUNET_TIME_Relative delay_get
The delay to start puts.
static struct GNUNET_TIME_Relative delay_put
The delay to start puts.
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:2046
A 512-bit hashcode.
struct Context * ctx
The linked peer context.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
#define GNUNET_log(kind,...)
struct GNUNET_SCHEDULER_Task * delay_task
Delay task.
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
static enum @11 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_connect()

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

Connect to DHT service and return the DHT client handler.

Parameters
clsthe active context
cfgconfiguration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect()
Returns
service handle to return in 'op_result', NULL on error

Definition at line 723 of file gnunet_dht_profiler.c.

References GNUNET_DHT_connect(), and n_dht.

Referenced by start_profiling().

725 {
726  n_dht++;
727  return GNUNET_DHT_connect (cfg,
728  10);
729 }
static unsigned int n_dht
Number of DHT service connections we currently have.
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:895
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_disconnect()

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

Adapter function called to destroy a connection to a service.

Parameters
clsthe active context
op_resultservice handle returned from the connect adapter

Definition at line 740 of file gnunet_dht_profiler.c.

References Context::ac, ActiveContext::dht, GNUNET_assert, GNUNET_DHT_disconnect(), GNUNET_YES, in_shutdown, mode, MODE_GET, MODE_PUT, n_active, n_dht, n_gets_fail, n_gets_ok, n_puts_ok, num_puts_per_peer, and start_profiling().

Referenced by start_profiling().

742 {
743  struct ActiveContext *ac = cls;
744 
745  GNUNET_assert (NULL != ac->dht);
746  GNUNET_assert (ac->dht == op_result);
748  ac->dht = NULL;
749  n_dht--;
750  if (0 != n_dht)
751  return;
752  if (GNUNET_YES == in_shutdown)
753  return;
754  switch (mode)
755  {
756  case MODE_PUT:
757  if (n_puts_ok != ((unsigned long long) n_active) * num_puts_per_peer)
758  return;
759  /* Start GETs if all PUTs have been made */
760  mode = MODE_GET;
761  start_profiling ();
762  return;
763  case MODE_GET:
764  if ((n_gets_ok + n_gets_fail) != n_active)
765  return;
766  break;
767  }
768 }
static unsigned int n_gets_ok
Number of DHT GETs succeeded.
static unsigned int n_dht
Number of DHT service connections we currently have.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a peer which actively does DHT PUT/GET.
static int op_result(struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx, uint8_t cancel)
Remove an operation, and call its result callback (unless it was cancelled).
Definition: op.c:244
static unsigned int num_puts_per_peer
Number of DHT PUTs to be made per peer.
struct GNUNET_DHT_Handle * dht
Handler to the DHT service.
static unsigned int n_active
Number of active peers.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:923
static int in_shutdown
Are we shutting down.
static void start_profiling(void)
Connect to DHT services of active peers.
static unsigned long long n_puts_ok
Number of DHT PUTs succeeded.
#define GNUNET_YES
Definition: gnunet_common.h:80
static unsigned int n_gets_fail
Number of DHT GETs succeeded.
static enum @11 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ service_started()

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

Callback called when DHT service on the peer is started.

Parameters
clsthe context
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 806 of file gnunet_dht_profiler.c.

References ctx, DEBUG, GNUNET_assert, GNUNET_TESTBED_operation_done(), num_peers, Context::op, peers_started, and start_profiling().

Referenced by test_run().

809 {
810  struct Context *ctx = cls;
811 
812  GNUNET_assert (NULL != ctx);
813  GNUNET_assert (NULL != ctx->op);
815  ctx->op = NULL;
816  peers_started++;
817  DEBUG ("Peers Started = %d; num_peers = %d \n",
819  num_peers);
820  if (peers_started == num_peers)
821  start_profiling ();
822 }
Context to hold data of peer.
static unsigned int num_peers
Number of peers.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define DEBUG(...)
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
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:2046
static void start_profiling(void)
Connect to DHT services of active peers.
static int peers_started
Counter to keep track of peers added to peer_context lists.
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_run()

static void test_run ( void *  cls,
struct GNUNET_TESTBED_RunHandle h,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  peers,
unsigned int  links_succeeded,
unsigned int  links_failed 
)
static

Signature of a main function for a testcase.

Parameters
clsclosure
hthe run handle
num_peersnumber of peers in 'peers'
peershandle to peers run in the testbed
links_succeededthe number of overlay link connection attempts that succeeded
links_failedthe number of overlay link

Definition at line 837 of file gnunet_dht_profiler.c.

References Context::ac, ActiveContext::ctx, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_free, GNUNET_new_array, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_peer_manage_service(), MESSAGE, n_active, num_peers, Context::op, Context::peer, peers, put_probability, and service_started().

Referenced by run().

843 {
844  unsigned int ac_cnt;
845 
847  if (NULL == peers)
848  {
849  /* exit */
850  GNUNET_assert (0);
851  }
852  MESSAGE ("%u peers started, %u/%u links up\n",
853  num_peers,
854  links_succeeded,
855  links_succeeded + links_failed);
857  struct Context);
858  /* select the peers which actively participate in profiling */
860  if (0 == n_active)
861  {
863  GNUNET_free (a_ctx);
864  a_ctx = NULL;
865  return;
866  }
867 
869  struct ActiveContext);
870  ac_cnt = 0;
871  for (unsigned int cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++)
872  {
874  100) >= put_probability)
875  continue;
876 
877  a_ctx[cnt].ac = &a_ac[ac_cnt];
878  a_ac[ac_cnt].ctx = &a_ctx[cnt];
879  ac_cnt++;
880  }
881  n_active = ac_cnt;
882 
883  /* start DHT service on all peers */
884  for (unsigned int cnt = 0; cnt < num_peers; cnt++)
885  {
886  a_ctx[cnt].peer = peers[cnt];
888  peers[cnt],
889  "dht",
891  &a_ctx[cnt],
892  1);
893  }
894 }
Context to hold data of peer.
static unsigned int put_probability
Number of peers which should perform a PUT out of 100 peers.
static unsigned int num_peers
Number of peers.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a peer which actively does DHT PUT/GET.
static struct Context * a_ctx
An array of contexts.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static void service_started(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback called when DHT service on the peer is started.
static unsigned int n_active
Number of active peers.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct ActiveContext * ac
Active context; NULL if this peer is not an active peer.
struct GNUNET_TESTBED_Peer * peer
The testbed peer this context belongs to.
struct Context * ctx
The linked peer context.
static struct GNUNET_TESTBED_Peer ** testbed_handles
Testbed peer handles.
#define MESSAGE(...)
static struct CadetPeer * peers
Operation to get peer ids.
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
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 ActiveContext * a_ac
Array of active peers.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_free(ptr)
Wrapper around free.
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 config 
)
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!)
configconfiguration

Definition at line 906 of file gnunet_dht_profiler.c.

References _, config, do_shutdown(), event_mask, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_run(), hosts_file, num_peers, and test_run().

Referenced by main().

910 {
911  uint64_t event_mask;
912 
913  if (0 == num_peers)
914  {
916  _("Exiting as the number of peers is %u\n"),
917  num_peers);
918  return;
919  }
920  cfg = config;
921  event_mask = 0;
923  cfg,
924  num_peers,
925  event_mask,
926  NULL,
927  NULL,
928  &test_run,
929  NULL);
931  NULL);
932 }
static unsigned int num_peers
Number of peers.
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:1293
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static const struct GNUNET_CONFIGURATION_Handle * config
void GNUNET_TESTBED_run(const char *host_filename, const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a testbed with a single call.
uint64_t event_mask
Global event mask for all testbed events.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration.
static char * hosts_file
Name of the file with the hosts to run the test over.
#define GNUNET_log(kind,...)
static void do_shutdown(void *cls)
Shutdown task.
static void test_run(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

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

Main function.

Returns
0 on success

Definition at line 941 of file gnunet_dht_profiler.c.

References delay_get, delay_put, delay_stats, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, hosts_file, num_peers, num_puts_per_peer, put_probability, replication, run(), and timeout.

943 {
944  int rc;
947  "peers",
948  "COUNT",
949  gettext_noop ("number of peers to start"),
950  &num_peers),
952  "peer-put-count",
953  "COUNT",
954  gettext_noop ("number of PUTs to perform per peer"),
957  "hosts",
958  "FILENAME",
959  gettext_noop ("name of the file with the login information for the testbed"),
960  &hosts_file),
962  "delay",
963  "DELAY",
964  gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"),
965  &delay_stats),
967  "PUT-delay",
968  "DELAY",
969  gettext_noop ("delay to start doing PUTs (default: 1 sec)"),
970  &delay_put),
972  "GET-delay",
973  "DELAY",
974  gettext_noop ("delay to start doing GETs (default: 5 min)"),
975  &delay_get),
977  "replication",
978  "DEGREE",
979  gettext_noop ("replication degree for DHT PUTs"),
980  &replication),
982  "random-chance",
983  "PROBABILITY",
984  gettext_noop ("chance that a peer is selected at random for PUTs"),
985  &put_probability),
987  "timeout",
988  "TIMEOUT",
989  gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"),
990  &timeout),
992  };
993 
994  if (GNUNET_OK !=
995  GNUNET_STRINGS_get_utf8_args (argc, argv,
996  &argc, &argv))
997  return 2;
998  /* set default delays */
1003  replication = 1; /* default replication */
1004  rc = 0;
1005  if (GNUNET_OK !=
1006  GNUNET_PROGRAM_run (argc,
1007  argv,
1008  "gnunet-dht-profiler",
1009  gettext_noop ("Measure quality and performance of the DHT service."),
1010  options,
1011  &run,
1012  NULL))
1013  rc = 1;
1014  return rc;
1015 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
static unsigned int put_probability
Number of peers which should perform a PUT out of 100 peers.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static unsigned int num_peers
Number of peers.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1521
#define GNUNET_TIME_UNIT_SECONDS
One second.
static unsigned int num_puts_per_peer
Number of DHT PUTs to be made per peer.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
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 replication
Replication degree.
static struct GNUNET_TIME_Relative delay_get
The delay to start puts.
static struct GNUNET_TIME_Relative delay_put
The delay to start puts.
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:439
static struct GNUNET_TIME_Relative timeout
The timeout for GET and PUT.
static char * hosts_file
Name of the file with the hosts to run the test over.
static struct GNUNET_TIME_Relative delay_stats
The delay between rounds for collecting statistics.
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:361
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
Main function that will be run by the scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ put_probability

unsigned int put_probability = 100
static

Number of peers which should perform a PUT out of 100 peers.

Definition at line 43 of file gnunet_dht_profiler.c.

Referenced by main(), and test_run().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Configuration.

Definition at line 48 of file gnunet_dht_profiler.c.

◆ hosts_file

char* hosts_file
static

Name of the file with the hosts to run the test over.

Definition at line 53 of file gnunet_dht_profiler.c.

Referenced by main(), and run().

◆ a_ctx

struct Context* a_ctx
static

An array of contexts.

The size of this array should be equal to num_peers

Definition at line 139 of file gnunet_dht_profiler.c.

◆ a_ac

struct ActiveContext* a_ac
static

Array of active peers.

Definition at line 144 of file gnunet_dht_profiler.c.

◆ delay_stats

struct GNUNET_TIME_Relative delay_stats
static

The delay between rounds for collecting statistics.

Definition at line 149 of file gnunet_dht_profiler.c.

Referenced by main().

◆ delay_put

struct GNUNET_TIME_Relative delay_put
static

The delay to start puts.

Definition at line 154 of file gnunet_dht_profiler.c.

Referenced by dht_connected(), and main().

◆ delay_get

struct GNUNET_TIME_Relative delay_get
static

The delay to start puts.

Definition at line 159 of file gnunet_dht_profiler.c.

Referenced by dht_connected(), and main().

◆ timeout

struct GNUNET_TIME_Relative timeout
static

The timeout for GET and PUT.

Definition at line 164 of file gnunet_dht_profiler.c.

Referenced by delayed_get(), and main().

◆ num_peers

unsigned int num_peers
static

Number of peers.

Definition at line 169 of file gnunet_dht_profiler.c.

Referenced by do_shutdown(), main(), run(), service_started(), and test_run().

◆ n_active

unsigned int n_active
static

Number of active peers.

Definition at line 174 of file gnunet_dht_profiler.c.

Referenced by cancel_get(), delayed_get(), dht_disconnect(), get_iter(), start_profiling(), summarize(), and test_run().

◆ n_dht

unsigned int n_dht
static

Number of DHT service connections we currently have.

Definition at line 179 of file gnunet_dht_profiler.c.

Referenced by dht_connect(), and dht_disconnect().

◆ n_puts

unsigned long long n_puts
static

Number of DHT PUTs made.

Definition at line 184 of file gnunet_dht_profiler.c.

Referenced by delayed_put(), and summarize().

◆ num_puts_per_peer

unsigned int num_puts_per_peer = 1
static

Number of DHT PUTs to be made per peer.

Definition at line 189 of file gnunet_dht_profiler.c.

Referenced by delayed_get(), dht_connected(), dht_disconnect(), and main().

◆ n_puts_ok

unsigned long long n_puts_ok
static

Number of DHT PUTs succeeded.

Definition at line 194 of file gnunet_dht_profiler.c.

Referenced by dht_disconnect(), put_cont(), and summarize().

◆ n_gets

unsigned int n_gets
static

Number of DHT GETs made.

Definition at line 199 of file gnunet_dht_profiler.c.

Referenced by delayed_get(), get_iter(), and summarize().

◆ n_gets_ok

unsigned int n_gets_ok
static

Number of DHT GETs succeeded.

Definition at line 204 of file gnunet_dht_profiler.c.

Referenced by cancel_get(), dht_disconnect(), get_iter(), and summarize().

◆ n_gets_fail

unsigned int n_gets_fail
static

Number of DHT GETs succeeded.

Definition at line 209 of file gnunet_dht_profiler.c.

Referenced by cancel_get(), dht_disconnect(), get_iter(), and summarize().

◆ replication

unsigned int replication
static

Replication degree.

Definition at line 214 of file gnunet_dht_profiler.c.

Referenced by delayed_put(), and main().

◆ bandwidth_stats_op

struct GNUNET_TESTBED_Operation* bandwidth_stats_op
static

Testbed Operation (to get stats).

Definition at line 219 of file gnunet_dht_profiler.c.

◆ testbed_handles

struct GNUNET_TESTBED_Peer** testbed_handles
static

Testbed peer handles.

Definition at line 224 of file gnunet_dht_profiler.c.

◆ outgoing_bandwidth

uint64_t outgoing_bandwidth
static

Total number of messages sent by peer.

Definition at line 229 of file gnunet_dht_profiler.c.

Referenced by bandwidth_stats_cont(), and bandwidth_stats_iterator().

◆ incoming_bandwidth

uint64_t incoming_bandwidth
static

Total number of messages received by peer.

Definition at line 234 of file gnunet_dht_profiler.c.

Referenced by bandwidth_stats_cont(), and bandwidth_stats_iterator().

◆ average_put_path_length

double average_put_path_length
static

Average number of hops taken to do put.

Definition at line 239 of file gnunet_dht_profiler.c.

Referenced by cancel_get(), get_iter(), and summarize().

◆ average_get_path_length

double average_get_path_length
static

Average number of hops taken to do get.

Definition at line 244 of file gnunet_dht_profiler.c.

Referenced by cancel_get(), get_iter(), and summarize().

◆ total_put_path_length

unsigned int total_put_path_length
static

Total put path length across all peers.

Definition at line 249 of file gnunet_dht_profiler.c.

Referenced by cancel_get(), and get_iter().

◆ total_get_path_length

unsigned int total_get_path_length
static

Total get path length across all peers.

Definition at line 254 of file gnunet_dht_profiler.c.

Referenced by cancel_get(), and get_iter().

◆ peers_started

int peers_started = 0
static

Counter to keep track of peers added to peer_context lists.

Definition at line 259 of file gnunet_dht_profiler.c.

Referenced by service_started().

◆ mode

enum { ... } mode

◆ in_shutdown

int in_shutdown = 0
static

Are we shutting down.

Definition at line 275 of file gnunet_dht_profiler.c.

Referenced by dht_disconnect(), do_shutdown(), and start_profiling().