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"
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 *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *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_Handle * | cfg |
Configuration. More... | |
static char * | hosts_file |
Name of the file with the hosts to run the test over. More... | |
static struct Context * | a_ctx |
An array of contexts. More... | |
static struct ActiveContext * | a_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_Operation * | bandwidth_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... | |
Profiler for GNUnet DHT.
Definition in file gnunet_dht_profiler.c.
#define MESSAGE | ( | ... | ) | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__) |
Definition at line 34 of file gnunet_dht_profiler.c.
#define DEBUG | ( | ... | ) | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
Definition at line 37 of file gnunet_dht_profiler.c.
anonymous enum |
Should we do a PUT (mode = 0) or GET (mode = 1);.
Enumerator | |
---|---|
MODE_PUT | |
MODE_GET |
Definition at line 263 of file gnunet_dht_profiler.c.
|
static |
Connect to DHT services of active peers.
Definition at line 784 of file gnunet_dht_profiler.c.
References a_ac, ctx, ActiveContext::ctx, DEBUG, dht_connect(), dht_connected(), dht_disconnect(), GNUNET_assert, GNUNET_break, GNUNET_YES, in_shutdown, and n_active.
Referenced by dht_disconnect(), and service_started().
|
static |
Shutdown task.
Cleanup all resources and operations.
cls | NULL |
Definition at line 290 of file gnunet_dht_profiler.c.
References a_ac, a_ctx, Context::ac, bandwidth_stats_op, ActiveContext::delay_task, ActiveContext::dht_get, ActiveContext::dht_put, GNUNET_DHT_get_stop(), GNUNET_DHT_put_cancel(), GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_YES, ActiveContext::hash, in_shutdown, num_peers, and op.
Referenced by run().
|
static |
Stats callback.
Finish the stats testbed operation and when all stats have been iterated, shutdown the test.
cls | closure |
op | the operation that has been finished |
emsg | error message in case the operation has failed; will be NULL if operation has executed successfully. |
Definition at line 340 of file gnunet_dht_profiler.c.
References GNUNET_SCHEDULER_shutdown(), incoming_bandwidth, MESSAGE, and outgoing_bandwidth.
Referenced by summarize().
|
static |
Process statistic values.
cls | closure |
peer | the peer the statistic belong to |
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 367 of file gnunet_dht_profiler.c.
References GNUNET_OK, incoming_bandwidth, name, outgoing_bandwidth, and value.
Referenced by summarize().
|
static |
Definition at line 386 of file gnunet_dht_profiler.c.
References average_get_path_length, average_put_path_length, bandwidth_stats_cont(), bandwidth_stats_iterator(), bandwidth_stats_op, MESSAGE, n_active, n_gets, n_gets_fail, n_gets_ok, n_puts, n_puts_ok, and testbed_handles.
Referenced by cancel_get(), and get_iter().
|
static |
Task to cancel DHT GET.
cls | NULL |
Definition at line 425 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(), n_active, n_gets_fail, n_gets_ok, summarize(), total_get_path_length, and total_put_path_length.
Referenced by delayed_get().
|
static |
Iterator called on each result obtained for a DHT operation that expects a reply.
cls | closure |
exp | when will this value expire |
key | key of the result |
trunc_peer | peer the path was truncated at, or NULL |
get_path | peers on reply path (or NULL if not recorded) [0] = datastore's first neighbor, [length - 1] = local peer |
get_path_length | number of entries in get_path |
put_path | peers on the PUT path (or NULL if not recorded) [0] = origin, [length - 1] = datastore |
put_path_length | number of entries in put_path |
type | type of the result |
size | number of bytes in data |
data | pointer to the result data |
Definition at line 470 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(), n_active, n_gets, n_gets_fail, n_gets_ok, ActiveContext::nrefs, summarize(), total_get_path_length, and total_put_path_length.
Referenced by delayed_get().
|
static |
Task to do DHT GETs.
cls | the active context |
Definition at line 522 of file gnunet_dht_profiler.c.
References a_ac, cancel_get(), DEBUG, ActiveContext::delay_task, 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().
|
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.
cls | the active context |
Definition at line 599 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_TIME_UNIT_FOREVER_ABS, ActiveContext::hash, n_puts, op, put_cont(), ActiveContext::put_count, and replication.
Referenced by dht_connected(), and put_cont().
|
static |
Conclude individual PUT operation, schedule the next one.
cls | the active context |
Definition at line 580 of file gnunet_dht_profiler.c.
References ActiveContext::delay_task, delayed_put(), ActiveContext::dht_put, GNUNET_SCHEDULER_add_now(), and n_puts_ok.
Referenced by delayed_put().
|
static |
Connection to DHT has been established.
Call the delay task.
cls | the active context |
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 658 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(), ActiveContext::hash, mode, MODE_GET, MODE_PUT, num_puts_per_peer, op, ActiveContext::put_count, and GNUNET_TIME_Relative::rel_value_us.
Referenced by start_profiling().
|
static |
Connect to DHT service and return the DHT client handler.
cls | the active 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 731 of file gnunet_dht_profiler.c.
References cfg, GNUNET_DHT_connect(), and n_dht.
Referenced by start_profiling().
|
static |
Adapter function called to destroy a connection to a service.
cls | the active context |
op_result | service handle returned from the connect adapter |
Definition at line 748 of file gnunet_dht_profiler.c.
References 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().
|
static |
Callback called when DHT service on the peer is started.
cls | the context |
op | the operation that has been finished |
emsg | error message in case the operation has failed; will be NULL if operation has executed successfully. |
Definition at line 815 of file gnunet_dht_profiler.c.
References ctx, DEBUG, GNUNET_assert, num_peers, peers_started, and start_profiling().
Referenced by test_run().
|
static |
Signature of a main function for a testcase.
cls | closure |
h | the run handle |
num_peers | number of peers in 'peers' |
peers | handle to peers run in the testbed |
links_succeeded | the number of overlay link connection attempts that succeeded |
links_failed | the number of overlay link |
Definition at line 846 of file gnunet_dht_profiler.c.
References a_ac, a_ctx, Context::ac, ActiveContext::ctx, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_free, GNUNET_new_array, GNUNET_SCHEDULER_shutdown(), MESSAGE, n_active, num_peers, Context::op, Context::peer, peers, put_probability, service_started(), and testbed_handles.
Referenced by run().
|
static |
Main function that will be run by the scheduler.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
config | configuration |
Definition at line 915 of file gnunet_dht_profiler.c.
References _, cfg, config, do_shutdown(), event_mask, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_shutdown(), hosts_file, num_peers, and test_run().
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
Main function.
Definition at line 950 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_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, hosts_file, num_peers, num_puts_per_peer, options, put_probability, replication, run(), and timeout.
|
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().
|
static |
Configuration.
Definition at line 48 of file gnunet_dht_profiler.c.
Referenced by dht_connect(), and run().
|
static |
Name of the file with the hosts to run the test over.
Definition at line 53 of file gnunet_dht_profiler.c.
|
static |
An array of contexts.
The size of this array should be equal to num_peers
Definition at line 138 of file gnunet_dht_profiler.c.
Referenced by do_shutdown(), and test_run().
|
static |
Array of active peers.
Definition at line 143 of file gnunet_dht_profiler.c.
Referenced by delayed_get(), do_shutdown(), start_profiling(), and test_run().
|
static |
The delay between rounds for collecting statistics.
Definition at line 148 of file gnunet_dht_profiler.c.
Referenced by main().
|
static |
The delay to start puts.
Definition at line 153 of file gnunet_dht_profiler.c.
Referenced by dht_connected(), and main().
|
static |
The delay to start puts.
Definition at line 158 of file gnunet_dht_profiler.c.
Referenced by dht_connected(), and main().
|
static |
The timeout for GET and PUT.
Definition at line 163 of file gnunet_dht_profiler.c.
Referenced by delayed_get(), and main().
|
static |
Number of peers.
Definition at line 168 of file gnunet_dht_profiler.c.
Referenced by check_client_keygen(), check_client_seed(), check_n_peers_ready(), check_stream_input(), check_view_update(), clients_notify_stream_peer(), clients_notify_view_update(), collect_peers_cb(), collect_peers_info_cb(), do_connect(), do_shutdown(), extend_path(), GNUNET_CONSENSUS_create(), GNUNET_SECRETSHARING_create_session(), GNUNET_TRANSPORT_TESTING_connect_check(), GNUNET_TRANSPORT_TESTING_main_(), handle_client_seed(), handle_stream_input(), hist_update(), keygen_reveal_get_enc_preshare(), keygen_reveal_get_exp_preshare(), main(), peers_ready_cb(), restore_valid_peers(), rfn_commit(), rfn_contest(), rfn_vote(), RPS_sampler_get_n_rand_peers(), RPS_sampler_update_with_nw_size(), run(), send_stream_peers(), service_started(), stream_input_handle(), task_start_eval_echo(), task_start_grade(), and test_run().
|
static |
Number of active peers.
Definition at line 173 of file gnunet_dht_profiler.c.
Referenced by cancel_get(), delayed_get(), dht_disconnect(), get_iter(), start_profiling(), summarize(), and test_run().
|
static |
Number of DHT service connections we currently have.
Definition at line 178 of file gnunet_dht_profiler.c.
Referenced by dht_connect(), and dht_disconnect().
|
static |
Number of DHT PUTs made.
Definition at line 183 of file gnunet_dht_profiler.c.
Referenced by delayed_put(), and summarize().
|
static |
Number of DHT PUTs to be made per peer.
Definition at line 188 of file gnunet_dht_profiler.c.
Referenced by delayed_get(), dht_connected(), dht_disconnect(), and main().
|
static |
Number of DHT PUTs succeeded.
Definition at line 193 of file gnunet_dht_profiler.c.
Referenced by dht_disconnect(), put_cont(), and summarize().
|
static |
Number of DHT GETs made.
Definition at line 198 of file gnunet_dht_profiler.c.
Referenced by delayed_get(), get_iter(), and summarize().
|
static |
Number of DHT GETs succeeded.
Definition at line 203 of file gnunet_dht_profiler.c.
Referenced by cancel_get(), dht_disconnect(), get_iter(), and summarize().
|
static |
Number of DHT GETs succeeded.
Definition at line 208 of file gnunet_dht_profiler.c.
Referenced by cancel_get(), dht_disconnect(), get_iter(), and summarize().
|
static |
Replication degree.
Definition at line 213 of file gnunet_dht_profiler.c.
Referenced by delayed_put(), and main().
|
static |
Testbed Operation (to get stats).
Definition at line 218 of file gnunet_dht_profiler.c.
Referenced by do_shutdown(), and summarize().
|
static |
Testbed peer handles.
Definition at line 223 of file gnunet_dht_profiler.c.
Referenced by summarize(), and test_run().
|
static |
Total number of messages sent by peer.
Definition at line 228 of file gnunet_dht_profiler.c.
Referenced by bandwidth_stats_cont(), and bandwidth_stats_iterator().
|
static |
Total number of messages received by peer.
Definition at line 233 of file gnunet_dht_profiler.c.
Referenced by bandwidth_stats_cont(), and bandwidth_stats_iterator().
|
static |
Average number of hops taken to do put.
Definition at line 238 of file gnunet_dht_profiler.c.
Referenced by cancel_get(), get_iter(), and summarize().
|
static |
Average number of hops taken to do get.
Definition at line 243 of file gnunet_dht_profiler.c.
Referenced by cancel_get(), get_iter(), and summarize().
|
static |
Total put path length across all peers.
Definition at line 248 of file gnunet_dht_profiler.c.
Referenced by cancel_get(), and get_iter().
|
static |
Total get path length across all peers.
Definition at line 253 of file gnunet_dht_profiler.c.
Referenced by cancel_get(), and get_iter().
|
static |
Counter to keep track of peers added to peer_context lists.
Definition at line 258 of file gnunet_dht_profiler.c.
Referenced by service_started().
enum { ... } mode |
Should we do a PUT (mode = 0) or GET (mode = 1);.
Referenced by dht_connected(), dht_disconnect(), GNUNET_CRYPTO_hash_create_random(), GNUNET_CRYPTO_hpke_receiver_setup2(), GNUNET_CRYPTO_hpke_sender_setup2(), GNUNET_CRYPTO_random_block(), GNUNET_CRYPTO_random_permute(), GNUNET_CRYPTO_random_timeflake(), GNUNET_CRYPTO_random_u32(), GNUNET_CRYPTO_random_u64(), GNUNET_DISK_file_open(), GNUNET_DISK_fix_permissions(), GNUNET_DISK_fn_write(), key_schedule(), pack_message(), pack_srv_room_message(), translate_unix_perms(), and verify_psk_inputs().
|
static |
Are we shutting down.
Definition at line 274 of file gnunet_dht_profiler.c.
Referenced by dht_disconnect(), do_shutdown(), and start_profiling().