Profiling driver for the network size estimation service. More...
Go to the source code of this file.
Data Structures | |
struct | NSEPeer |
Information we track for a peer in the testbed. More... | |
struct | OpListEntry |
Operation map entry. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
Generic loggins shorthand. More... | |
#define | LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
Debug logging shorthand. More... | |
Functions | |
static void | close_monitor_connections () |
Clean up all of the monitoring connections to NSE and STATISTICS that we keep to selected peers. More... | |
static void | shutdown_task (void *cls) |
Task run on shutdown; cleans up everything. More... | |
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. More... | |
static void * | nse_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Adapter function called to establish a connection to NSE service. More... | |
static void | nse_disconnect_adapter (void *cls, void *op_result) |
Adapter function called to destroy a connection to NSE service. More... | |
static int | stat_iterator (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) |
Callback function to process statistic values. More... | |
static void * | stat_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Called to open a connection to the peer's statistics. More... | |
static void | stat_disconnect_adapter (void *cls, void *op_result) |
Called to disconnect from peer's statistics service. More... | |
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 monitoring for CORE and NSE here. More... | |
static void | connect_nse_service () |
Task run to connect to the NSE and statistics services to a subset of all of the running peers. More... | |
static void | next_round (void *cls) |
Task that starts/stops peers to move to the next round. More... | |
static void | finish_round (void *cls) |
We're at the end of a round. More... | |
static void | run_round () |
We have reached the desired number of peers for the current round. More... | |
static struct OpListEntry * | make_oplist_entry () |
Creates an oplist entry and adds it to the oplist DLL. More... | |
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. More... | |
static void | adjust_running_peers () |
Adjust the number of running peers to match the required number of running peers for the round. More... | |
static void | master_controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
Function that will be called whenever something in the testbed changes. 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) |
Actual main function that runs the emulation. More... | |
int | main (int argc, char *const *argv) |
Main function. More... | |
Variables | |
static struct NSEPeer * | peer_head |
Head of DLL of peers we monitor closely. More... | |
static struct NSEPeer * | peer_tail |
Tail of DLL of peers we monitor closely. More... | |
static int | ok |
Return value from 'main' (0 == success) More... | |
static unsigned int | verbose |
Be verbose (configuration option) More... | |
static char * | hosts_file |
Name of the file with the hosts to run the test over (configuration option) More... | |
static unsigned int | num_peers |
Maximum number of peers in the test. More... | |
static unsigned int | num_rounds |
Total number of rounds to execute. More... | |
static unsigned int | current_round |
Current round we are in. More... | |
static unsigned int * | num_peers_in_round |
Array of size 'num_rounds' with the requested number of peers in the given round. More... | |
static unsigned int | peers_running |
How many peers are running right now? More... | |
static char * | num_peer_spec |
Specification for the numbers of peers to have in each round. More... | |
static struct GNUNET_TESTBED_Peer ** | daemons |
Handles to all of the running peers. More... | |
static struct GNUNET_CONFIGURATION_Handle * | testing_cfg |
Global configuration file. More... | |
static unsigned int | connection_limit |
Maximum number of connections to NSE services. More... | |
static unsigned int | total_connections |
Total number of connections in the whole network. More... | |
static struct GNUNET_DISK_FileHandle * | output_file |
File to report results to. More... | |
static char * | output_filename |
Filename to log results to. More... | |
static struct GNUNET_DISK_FileHandle * | data_file |
File to log connection info, statistics to. More... | |
static char * | data_filename |
Filename to log connection info, statistics to. More... | |
static struct GNUNET_TIME_Relative | wait_time = { 60 * 1000 } |
How long to wait before triggering next round? Default: 60 s. More... | |
static struct OpListEntry * | oplist_head |
DLL head for operation list. More... | |
static struct OpListEntry * | oplist_tail |
DLL tail for operation list. More... | |
static struct GNUNET_SCHEDULER_Task * | round_task |
Task running each round of the experiment. More... | |
Profiling driver for the network size estimation service.
Generally, the profiler starts a given number of peers, then churns some off, waits a certain amount of time, then churns again, and repeats.
Definition in file gnunet-nse-profiler.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log (kind, __VA_ARGS__) |
Generic loggins shorthand.
Definition at line 39 of file gnunet-nse-profiler.c.
#define LOG_DEBUG | ( | ... | ) | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
Debug logging shorthand.
Definition at line 44 of file gnunet-nse-profiler.c.
|
static |
Clean up all of the monitoring connections to NSE and STATISTICS that we keep to selected peers.
Definition at line 234 of file gnunet-nse-profiler.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_TESTBED_operation_done(), NSEPeer::nse_op, OpListEntry::op, oplist_head, oplist_tail, peer_head, peer_tail, and NSEPeer::stat_op.
Referenced by finish_round(), and shutdown_task().
|
static |
Task run on shutdown; cleans up everything.
cls | unused |
Definition at line 263 of file gnunet-nse-profiler.c.
References close_monitor_connections(), data_file, GNUNET_CONFIGURATION_destroy(), GNUNET_DISK_file_close(), GNUNET_SCHEDULER_cancel(), LOG_DEBUG, output_file, round_task, and testing_cfg.
Referenced by run().
|
static |
Callback to call when network size estimate is updated.
cls | closure with the 'struct NSEPeer' providing the update |
timestamp | server timestamp |
estimate | the value of the current network size estimate |
std_dev | standard deviation (rounded down to nearest integer) of the size estimation values seen |
Definition at line 300 of file gnunet-nse-profiler.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NSE_log_estimate_to_n, GNUNET_snprintf(), output_file, peer, peers_running, and size.
Referenced by nse_connect_adapter().
|
static |
Adapter function called to establish a connection to NSE service.
cls | closure (the 'struct NSEPeer') |
cfg | configuration 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() |
Definition at line 343 of file gnunet-nse-profiler.c.
References cfg, GNUNET_NSE_connect(), and handle_estimate().
Referenced by connect_nse_service().
|
static |
Adapter function called to destroy a connection to NSE service.
cls | closure |
op_result | service handle returned from the connect adapter |
Definition at line 359 of file gnunet-nse-profiler.c.
References GNUNET_NSE_disconnect(), and op_result().
Referenced by connect_nse_service().
|
static |
Callback function to process statistic values.
cls | struct NSEPeer |
subsystem | name of subsystem that created the statistic |
name | the name of the datum |
value | the current value |
is_persistent | GNUNET_YES if the value is persistent, GNUNET_NO if not |
Definition at line 376 of file gnunet-nse-profiler.c.
References GNUNET_TIME_Absolute::abs_value_us, data_file, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_get(), size, subsystem, and value.
Referenced by stat_comp_cb(), and stat_disconnect_adapter().
|
static |
Called to open a connection to the peer's statistics.
cls | peer context |
cfg | configuration 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() |
Definition at line 424 of file gnunet-nse-profiler.c.
References cfg, GNUNET_STATISTICS_create(), and peer.
Referenced by connect_nse_service().
|
static |
Called to disconnect from peer's statistics service.
cls | peer context |
op_result | service handle returned from the connect adapter |
Definition at line 440 of file gnunet-nse-profiler.c.
References GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_destroy(), GNUNET_STATISTICS_watch_cancel(), op_result(), peer, and stat_iterator().
Referenced by connect_nse_service().
|
static |
Called after successfully opening a connection to a peer's statistics service; we register statistics monitoring for CORE and NSE here.
cls | the callback closure from functions generating an operation |
op | the operation that has been finished |
ca_result | the service handle returned from GNUNET_TESTBED_ConnectAdapter() |
emsg | error message in case the operation has failed; will be NULL if operation has executed successfully. |
Definition at line 472 of file gnunet-nse-profiler.c.
References GNUNET_break, GNUNET_OK, GNUNET_STATISTICS_watch(), peer, sh, and stat_iterator().
Referenced by connect_nse_service().
|
static |
Task run to connect to the NSE and statistics services to a subset of all of the running peers.
Definition at line 503 of file gnunet-nse-profiler.c.
References connection_limit, connections, current_round, NSEPeer::daemon, daemons, data_file, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_TESTBED_service_connect(), LOG_DEBUG, nse_connect_adapter(), nse_disconnect_adapter(), NSEPeer::nse_op, num_peers_in_round, peer_head, peer_tail, stat_comp_cb(), stat_connect_adapter(), stat_disconnect_adapter(), and NSEPeer::stat_op.
Referenced by run_round().
|
static |
Task that starts/stops peers to move to the next round.
Task run at the end of a round.
cls | NULL, unused |
Disconnect from all monitored peers; then get statistics from all peers.
cls | NULL, unused |
Definition at line 674 of file gnunet-nse-profiler.c.
References adjust_running_peers(), current_round, GNUNET_SCHEDULER_shutdown(), LOG_DEBUG, num_peers_in_round, num_rounds, ok, peers_running, round_task, and run_round().
Referenced by finish_round().
|
static |
We're at the end of a round.
Stop monitoring, write total number of connections to log and get full stats. Then trigger the next round.
cls | unused, NULL |
Definition at line 564 of file gnunet-nse-profiler.c.
References close_monitor_connections(), GNUNET_ERROR_TYPE_INFO, GNUNET_SCHEDULER_add_now(), LOG, next_round(), round_task, and total_connections.
Referenced by run_round().
|
static |
We have reached the desired number of peers for the current round.
Run it (by connecting and monitoring a few peers and waiting the specified delay before finishing the round).
Definition at line 578 of file gnunet-nse-profiler.c.
References connect_nse_service(), current_round, finish_round(), GNUNET_SCHEDULER_add_delayed(), LOG_DEBUG, and wait_time.
Referenced by manage_service_cb(), next_round(), and test_master().
|
static |
Creates an oplist entry and adds it to the oplist DLL.
Definition at line 590 of file gnunet-nse-profiler.c.
References GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, oplist_head, and oplist_tail.
Referenced by adjust_running_peers().
|
static |
Callback to be called when NSE service is started or stopped at peers.
cls | NULL |
op | the operation handle |
emsg | NULL on success; otherwise an error description |
Definition at line 608 of file gnunet-nse-profiler.c.
References current_round, OpListEntry::delta, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_operation_done(), LOG, num_peers_in_round, OpListEntry::op, oplist_head, oplist_tail, peers_running, and run_round().
Referenced by adjust_running_peers().
|
static |
Adjust the number of running peers to match the required number of running peers for the round.
Definition at line 635 of file gnunet-nse-profiler.c.
References current_round, daemons, OpListEntry::delta, GNUNET_TESTBED_peer_manage_service(), make_oplist_entry(), manage_service_cb(), num_peers_in_round, OpListEntry::op, and peers_running.
Referenced by next_round(), and test_master().
|
static |
Function that will be called whenever something in the testbed changes.
cls | closure, NULL |
event | information on what is happening |
Definition at line 704 of file gnunet-nse-profiler.c.
References GNUNET_TESTBED_ET_CONNECT, GNUNET_TESTBED_ET_DISCONNECT, total_connections, and GNUNET_TESTBED_EventInformation::type.
Referenced by run().
|
static |
Signature of a main function for a testcase.
cls | NULL |
h | the run handle |
num_peers_ | number of peers in 'peers' |
peers | handle to peers run in the testbed. NULL upon timeout (see GNUNET_TESTBED_test_run()). |
links_succeeded | the number of overlay link connection attempts that succeeded |
links_failed | the number of overlay link connection attempts that failed |
Definition at line 737 of file gnunet-nse-profiler.c.
References adjust_running_peers(), current_round, daemons, GNUNET_break, GNUNET_SCHEDULER_shutdown(), num_peers, num_peers_in_round, peers, peers_running, and run_round().
Referenced by run().
|
static |
Actual main function that runs the emulation.
cls | unused |
args | remaining args, unused |
cfgfile | name of the configuration |
cfg | configuration handle |
Definition at line 771 of file gnunet-nse-profiler.c.
References cfg, data_file, data_filename, event_mask, GNUNET_array_append, GNUNET_CONFIGURATION_dup(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_strerror_file, GNUNET_MAX, GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_ET_CONNECT, GNUNET_TESTBED_ET_DISCONNECT, GNUNET_TESTBED_ET_PEER_START, GNUNET_TESTBED_ET_PEER_STOP, GNUNET_TESTBED_run(), hosts_file, LOG_DEBUG, master_controller_cb(), num_peer_spec, num_peers, num_peers_in_round, num_rounds, ok, output_file, output_filename, shutdown_task(), test_master(), and testing_cfg.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
Main function.
Definition at line 849 of file gnunet-nse-profiler.c.
References connection_limit, data_filename, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_increment_uint(), GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), hosts_file, num_peer_spec, ok, options, output_filename, run(), verbose, and wait_time.
|
static |
Head of DLL of peers we monitor closely.
Definition at line 115 of file gnunet-nse-profiler.c.
Referenced by close_monitor_connections(), and connect_nse_service().
|
static |
Tail of DLL of peers we monitor closely.
Definition at line 120 of file gnunet-nse-profiler.c.
Referenced by close_monitor_connections(), and connect_nse_service().
|
static |
Return value from 'main' (0 == success)
Definition at line 125 of file gnunet-nse-profiler.c.
Referenced by accept_client(), check_unique(), connect_check_run(), GNUNET_CRYPTO_rsa_blind(), GNUNET_log_skip(), main(), next_round(), pick_random_dv_hops(), run(), and save_hostlist_file().
|
static |
Be verbose (configuration option)
Definition at line 130 of file gnunet-nse-profiler.c.
Referenced by main().
|
static |
Name of the file with the hosts to run the test over (configuration option)
Definition at line 135 of file gnunet-nse-profiler.c.
|
static |
Maximum number of peers in the test.
Definition at line 140 of file gnunet-nse-profiler.c.
Referenced by run(), and test_master().
|
static |
Total number of rounds to execute.
Definition at line 145 of file gnunet-nse-profiler.c.
Referenced by next_round(), and run().
|
static |
Current round we are in.
Definition at line 150 of file gnunet-nse-profiler.c.
Referenced by adjust_running_peers(), connect_nse_service(), manage_service_cb(), next_round(), run_round(), and test_master().
|
static |
Array of size 'num_rounds' with the requested number of peers in the given round.
Definition at line 155 of file gnunet-nse-profiler.c.
Referenced by adjust_running_peers(), connect_nse_service(), manage_service_cb(), next_round(), run(), and test_master().
|
static |
How many peers are running right now?
Definition at line 160 of file gnunet-nse-profiler.c.
Referenced by adjust_running_peers(), handle_estimate(), manage_service_cb(), next_round(), and test_master().
|
static |
Specification for the numbers of peers to have in each round.
Definition at line 165 of file gnunet-nse-profiler.c.
|
static |
Handles to all of the running peers.
Definition at line 170 of file gnunet-nse-profiler.c.
Referenced by adjust_running_peers(), connect_nse_service(), and test_master().
|
static |
Global configuration file.
Definition at line 175 of file gnunet-nse-profiler.c.
Referenced by run(), and shutdown_task().
|
static |
Maximum number of connections to NSE services.
Definition at line 180 of file gnunet-nse-profiler.c.
Referenced by connect_nse_service(), and main().
|
static |
Total number of connections in the whole network.
Definition at line 185 of file gnunet-nse-profiler.c.
Referenced by finish_round(), and master_controller_cb().
|
static |
File to report results to.
Definition at line 190 of file gnunet-nse-profiler.c.
Referenced by handle_estimate(), run(), and shutdown_task().
|
static |
Filename to log results to.
Definition at line 195 of file gnunet-nse-profiler.c.
|
static |
File to log connection info, statistics to.
Definition at line 200 of file gnunet-nse-profiler.c.
Referenced by connect_nse_service(), run(), shutdown_task(), and stat_iterator().
|
static |
Filename to log connection info, statistics to.
Definition at line 205 of file gnunet-nse-profiler.c.
|
static |
How long to wait before triggering next round? Default: 60 s.
Definition at line 205 of file gnunet-nse-profiler.c.
Referenced by main(), and run_round().
|
static |
DLL head for operation list.
Definition at line 216 of file gnunet-nse-profiler.c.
Referenced by close_monitor_connections(), make_oplist_entry(), and manage_service_cb().
|
static |
DLL tail for operation list.
Definition at line 221 of file gnunet-nse-profiler.c.
Referenced by close_monitor_connections(), make_oplist_entry(), and manage_service_cb().
|
static |
Task running each round of the experiment.
Definition at line 226 of file gnunet-nse-profiler.c.
Referenced by finish_round(), next_round(), and shutdown_task().