39 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
44 #define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
306 char output_buffer[512];
312 "Received network size estimate from peer %p. Size: %f std.dev. %f\n",
319 sizeof(output_buffer),
320 "%p %u %llu %f %f %f\n",
345 struct NSEPeer *current_peer = cls;
394 (
unsigned long long) now.
abs_value_us / 1000LL / 1000LL,
395 (
unsigned long long)
value,
511 LOG_DEBUG (
"Connecting to nse service of peers\n");
518 LOG_DEBUG (
"Connecting to nse service of peer %d\n", i);
677 LOG_DEBUG (
"Disconnecting nse service of peers\n");
739 unsigned int num_peers_,
741 unsigned int links_succeeded,
742 unsigned int links_failed)
785 fprintf (stderr,
"You need to specify the number of peers to run\n");
788 for (tok = strtok (
num_peer_spec,
","); NULL != tok; tok = strtok (NULL,
","))
790 if (1 != sscanf (tok,
"%u", &num))
792 fprintf (stderr,
"You need to specify numbers, not `%s'\n", tok);
797 fprintf (stderr,
"Refusing to run a round with 0 peers\n");
805 fprintf (stderr,
"Refusing to run a testbed with no rounds\n");
849 main (
int argc,
char *
const *argv)
857 "limit to the number of connections to NSE services, 0 for none"),
864 "name of the file for writing connection information and statistics"),
872 "name of the file with the login information for the testbed"),
879 gettext_noop (
"name of the file for writing the main results"),
888 "Number of peers to run in each round, separated by commas"),
894 gettext_noop (
"be verbose (print progress information)"),
912 "Measure quality and performance of the NSE service."),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static struct GNUNET_ARM_Operation * op
Current operation.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct SolverHandle * sh
static struct CadetPeer * peers
Operation to get peer ids.
static char * value
Value of the record to add/remove.
static int ok
Return value from 'main' (0 == success)
static char * output_filename
Filename to log results to.
static unsigned int verbose
Be verbose (configuration option)
static unsigned int peers_running
How many peers are running right now?
static void stat_comp_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Called after successfully opening a connection to a peer's statistics service; we register statistics...
static struct OpListEntry * oplist_head
DLL head for operation list.
static char * data_filename
Filename to log connection info, statistics to.
static unsigned int connection_limit
Maximum number of connections to NSE services.
static unsigned int total_connections
Total number of connections in the whole network.
static unsigned int current_round
Current round we are in.
static void stat_disconnect_adapter(void *cls, void *op_result)
Called to disconnect from peer's statistics service.
static int stat_iterator(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values.
static struct OpListEntry * oplist_tail
DLL tail for operation list.
static void close_monitor_connections()
Clean up all of the monitoring connections to NSE and STATISTICS that we keep to selected peers.
static void shutdown_task(void *cls)
Task run on shutdown; cleans up everything.
#define LOG_DEBUG(...)
Debug logging shorthand.
static char * hosts_file
Name of the file with the hosts to run the test over (configuration option)
static struct GNUNET_TIME_Relative wait_time
How long to wait before triggering next round? Default: 60 s.
static struct GNUNET_SCHEDULER_Task * round_task
Task running each round of the experiment.
static void connect_nse_service()
Task run to connect to the NSE and statistics services to a subset of all of the running peers.
static void run_round()
We have reached the desired number of peers for the current round.
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.
static struct GNUNET_CONFIGURATION_Handle * testing_cfg
Global configuration file.
static void manage_service_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback to be called when NSE service is started or stopped at peers.
static void adjust_running_peers()
Adjust the number of running peers to match the required number of running peers for the round.
static void handle_estimate(void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev)
Callback to call when network size estimate is updated.
static void next_round(void *cls)
Task that starts/stops peers to move to the next round.
static struct GNUNET_TESTBED_Peer ** daemons
Handles to all of the running peers.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Actual main function that runs the emulation.
static void master_controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Function that will be called whenever something in the testbed changes.
static struct OpListEntry * make_oplist_entry()
Creates an oplist entry and adds it to the oplist DLL.
static char * num_peer_spec
Specification for the numbers of peers to have in each round.
static struct GNUNET_DISK_FileHandle * output_file
File to report results to.
#define LOG(kind,...)
Generic loggins shorthand.
int main(int argc, char *const *argv)
Main function.
static unsigned int * num_peers_in_round
Array of size 'num_rounds' with the requested number of peers in the given round.
static void * stat_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Called to open a connection to the peer's statistics.
static unsigned int num_rounds
Total number of rounds to execute.
static struct NSEPeer * peer_head
Head of DLL of peers we monitor closely.
static unsigned int num_peers
Maximum number of peers in the test.
static void * nse_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Adapter function called to establish a connection to NSE service.
static struct GNUNET_DISK_FileHandle * data_file
File to log connection info, statistics to.
static struct NSEPeer * peer_tail
Tail of DLL of peers we monitor closely.
static void nse_disconnect_adapter(void *cls, void *op_result)
Adapter function called to destroy a connection to NSE service.
static void finish_round(void *cls)
We're at the end of a round.
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
uint64_t event_mask
Global event mask for all testbed events.
API to retrieve the current network size estimate.
API for writing tests and creating large-scale emulation testbeds for GNUnet.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_increment_uint(char shortName, const char *name, const char *description, unsigned int *val)
Increment val each time the option flag is given by one.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_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 GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define GNUNET_log(kind,...)
#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.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
#define GNUNET_NSE_log_estimate_to_n(loge)
Convert the logarithmic estimated returned to the 'GNUNET_NSE_Callback' into an absolute estimate in ...
struct GNUNET_NSE_Handle * GNUNET_NSE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_Callback func, void *func_cls)
Connect to the network size estimation service.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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.
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,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
int GNUNET_STATISTICS_watch_cancel(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Iterator proc, void *proc_cls)
Stop watching statistics from the peer.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
int GNUNET_STATISTICS_watch(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Iterator proc, void *proc_cls)
Watch statistics from the peer (be notified whenever they change).
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
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...
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.
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.
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.
@ GNUNET_TESTBED_ET_CONNECT
A connection between two peers was established.
@ GNUNET_TESTBED_ET_PEER_START
A peer has been started.
@ GNUNET_TESTBED_ET_DISCONNECT
A connection between two peers was torn down.
@ GNUNET_TESTBED_ET_PEER_STOP
A peer has been stopped.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
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).
static unsigned int size
Size of the "table".
Handle used to access files (and pipes).
Definition of a command line option.
Entry in list of pending tasks.
Opaque handle to an abstract operation to be executed by the testing framework.
A peer controlled by the testing framework.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
Information we track for a peer in the testbed.
struct GNUNET_STATISTICS_Handle * sh
Handle to the statistics service.
struct GNUNET_TESTBED_Peer * daemon
Handle with testbed.
struct NSEPeer * next
Next reference in DLL.
struct GNUNET_TESTBED_Operation * stat_op
Testbed operation to connect to statistics service.
struct NSEPeer * prev
Prev reference in DLL.
struct GNUNET_TESTBED_Operation * nse_op
Testbed operation to connect to NSE service.
struct OpListEntry * prev
DLL prev ptr.
struct GNUNET_TESTBED_Operation * op
The testbed operation.
int delta
Depending on whether we start or stop NSE service at the peer set this to 1 or -1.
struct OpListEntry * next
DLL next ptr.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.