GNUnet  0.11.x
Functions | Variables
gnunet-fs-profiler.c File Reference

tool to benchmark/profile file-sharing More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
Include dependency graph for gnunet-fs-profiler.c:

Go to the source code of this file.

Functions

static void shutdown_task (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 Function called after we've collected the statistics. More...
 
static int process_stats (void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Callback function to process statistic values from all peers. More...
 
static void terminate_task (void *cls)
 Task run on shutdown to terminate. More...
 
static void timeout_task (void *cls)
 Task run on timeout to terminate. More...
 
static void test_master (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 *cfg)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 Program to run a file-sharing testbed. More...
 

Variables

static int ret
 Final status code. More...
 
static char * host_filename
 Data file with the hosts for the testbed. More...
 
static unsigned int num_peers
 Number of peers to run in the experiment. More...
 
static struct GNUNET_TIME_Relative timeout
 After how long do we abort the test? More...
 
static struct GNUNET_SCHEDULER_Taskterminate_taskid
 Handle to the task run during termination. More...
 

Detailed Description

tool to benchmark/profile file-sharing

Author
Christian Grothoff

Definition in file gnunet-fs-profiler.c.

Function Documentation

◆ shutdown_task()

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

Function called after we've collected the statistics.

Parameters
clsNULL
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 65 of file gnunet-fs-profiler.c.

References GNUNET_SCHEDULER_shutdown().

Referenced by terminate_task().

68 {
69  if (NULL != emsg)
70  fprintf (stderr,
71  "Error collecting statistics: %s\n",
72  emsg);
74 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_stats()

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

Callback function to process statistic values from all peers.

Prints them out.

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 90 of file gnunet-fs-profiler.c.

References GNUNET_OK.

Referenced by terminate_task().

96 {
97  fprintf (stdout,
98  "%p-%s: %s = %llu\n",
99  peer,
100  subsystem,
101  name,
102  (unsigned long long) value);
103  return GNUNET_OK;
104 }
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
const char * name
Here is the caller graph for this function:

◆ terminate_task()

static void terminate_task ( void *  cls)
static

Task run on shutdown to terminate.

Triggers printing out all statistics.

Parameters
clsNULL

Definition at line 114 of file gnunet-fs-profiler.c.

References GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_get_statistics(), process_stats(), and shutdown_task().

Referenced by test_master().

115 {
116  if (NULL != terminate_taskid)
117  {
119  terminate_taskid = NULL;
120  }
122  NULL, NULL,
123  &process_stats,
124  &shutdown_task,
125  NULL);
126 }
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 int process_stats(void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values from all peers.
static void shutdown_task(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Function called after we've collected the statistics.
static struct GNUNET_SCHEDULER_Task * terminate_taskid
Handle to the task run during termination.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_task()

static void timeout_task ( void *  cls)
static

Task run on timeout to terminate.

Triggers printing out all statistics.

Parameters
clsNULL

Definition at line 136 of file gnunet-fs-profiler.c.

References GNUNET_SCHEDULER_shutdown().

Referenced by test_master().

137 {
138  terminate_taskid = NULL;
140 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static struct GNUNET_SCHEDULER_Task * terminate_taskid
Handle to the task run during termination.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_master()

static void test_master ( void *  cls,
struct GNUNET_TESTBED_RunHandle h,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  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 connection attempts that failed

Definition at line 156 of file gnunet-fs-profiler.c.

References GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TIME_Relative::rel_value_us, terminate_task(), timeout, and timeout_task().

Referenced by run().

162 {
163  // const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
164  // FIXME: enable clients to signal 'completion' before timeout;
165  // in that case, run the 'terminate_task' "immediately"
166 
167  if (0 != timeout.rel_value_us)
169  &timeout_task,
170  NULL);
172  NULL);
173 }
uint64_t rel_value_us
The actual value.
static void terminate_task(void *cls)
Task run on shutdown to terminate.
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:1300
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:1253
static void timeout_task(void *cls)
Task run on timeout to terminate.
static struct GNUNET_SCHEDULER_Task * terminate_taskid
Handle to the task run during termination.
static struct GNUNET_TIME_Relative timeout
After how long do we abort the test?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

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!)
cfgconfiguration

Definition at line 185 of file gnunet-fs-profiler.c.

References GNUNET_TESTBED_run(), host_filename, num_peers, and test_master().

Referenced by main().

187 {
189  cfg,
190  num_peers,
191  0, NULL, NULL,
192  &test_master, (void *) cfg);
193 }
static unsigned int num_peers
Number of peers to run in the experiment.
static void test_master(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.
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.
static char * host_filename
Data file with the hosts for the testbed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

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

Program to run a file-sharing testbed.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 204 of file gnunet-fs-profiler.c.

References gettext_noop, GNUNET_free, 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(), host_filename, num_peers, ret, run(), and timeout.

205 {
208  "num-peers",
209  "COUNT",
210  gettext_noop (
211  "run the experiment with COUNT peers"),
212  &num_peers),
213 
215  "hosts",
216  "HOSTFILE",
217  gettext_noop (
218  "specifies name of a file with the HOSTS the testbed should use"),
219  &host_filename),
220 
222  "timeout",
223  "DELAY",
224  gettext_noop (
225  "automatically terminate experiment after DELAY"),
226  &timeout),
227 
229  };
230 
231  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
232  return 2;
233 
234  ret = (GNUNET_OK ==
235  GNUNET_PROGRAM_run (argc, argv, "gnunet-fs-profiler",
236  gettext_noop (
237  "run a testbed to measure file-sharing performance"),
238  options, &run,
239  NULL)) ? ret : 1;
240  GNUNET_free ((void*) argv);
241  return ret;
242 }
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)...
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1438
static int ret
Final status code.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static unsigned int num_peers
Number of peers to run in the experiment.
Definition of a command line option.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
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 char * host_filename
Data file with the hosts for the testbed.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
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.
static struct GNUNET_TIME_Relative timeout
After how long do we abort the test?
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Final status code.

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

Referenced by main().

◆ host_filename

char* host_filename
static

Data file with the hosts for the testbed.

Definition at line 38 of file gnunet-fs-profiler.c.

Referenced by main(), and run().

◆ num_peers

unsigned int num_peers
static

Number of peers to run in the experiment.

Definition at line 43 of file gnunet-fs-profiler.c.

Referenced by main(), and run().

◆ timeout

struct GNUNET_TIME_Relative timeout
static

After how long do we abort the test?

Definition at line 48 of file gnunet-fs-profiler.c.

Referenced by main(), and test_master().

◆ terminate_taskid

struct GNUNET_SCHEDULER_Task* terminate_taskid
static

Handle to the task run during termination.

Definition at line 53 of file gnunet-fs-profiler.c.