34 #define MESSAGE(...) \ 35 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__) 38 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 297 for (
unsigned int cnt = 0; cnt <
num_peers; cnt++)
305 if (NULL != ac->
hash)
314 if (NULL != a_ctx[cnt].
op)
321 if (NULL != bandwidth_stats_op)
324 bandwidth_stats_op = NULL;
344 MESSAGE (
"# Outgoing (core) bandwidth: %llu bytes\n",
346 MESSAGE (
"# Incoming (core) bandwidth: %llu bytes\n",
349 "Benchmark done. Collect data via gnunet-statistics, then press ENTER to exit.\n");
374 static const char *s_sent =
"# bytes encrypted";
375 static const char *s_recv =
"# bytes decrypted";
377 if (0 == strncmp (s_sent, name, strlen (s_sent)))
379 else if (0 == strncmp (s_recv, name, strlen (s_recv)))
388 MESSAGE (
"# PUTS started: %llu\n",
390 MESSAGE (
"# PUTS succeeded: %llu\n",
394 MESSAGE (
"# GETS succeeded: %u\n",
396 MESSAGE (
"# GETS failed: %u\n",
398 MESSAGE (
"# average_put_path_length: %f\n",
400 MESSAGE (
"# average_get_path_length: %f\n",
403 if (NULL == testbed_handles)
473 unsigned int get_path_length,
475 unsigned int put_path_length,
484 DEBUG (
"We found a GET request; %u remaining\n",
499 DEBUG (
"total_put_path_length = %u,put_path \n",
532 if (NULL != get_ac->
hash)
539 DEBUG (
"GET_REQUEST_START key %s \n",
629 DEBUG (
"PUT_REQUEST_START key %s\n",
670 "Connection to DHT service failed: %s\n",
688 if (NULL == ac->
hash)
785 DEBUG (
"GNUNET_TESTBED_service_connect\n");
787 for (
unsigned int i = 0; i <
n_active; i++)
823 DEBUG (
"Peers Started = %d; num_peers = %d \n",
847 unsigned int links_succeeded,
848 unsigned int links_failed)
852 testbed_handles =
peers;
858 MESSAGE (
"%u peers started, %u/%u links up\n",
861 links_succeeded + links_failed);
877 for (
unsigned int cnt = 0; cnt < num_peers && ac_cnt <
n_active; cnt++)
883 a_ctx[cnt].
ac = &a_ac[ac_cnt];
884 a_ac[ac_cnt].
ctx = &a_ctx[cnt];
890 for (
unsigned int cnt = 0; cnt <
num_peers; cnt++)
892 a_ctx[cnt].
peer = peers[cnt];
922 _ (
"Exiting as the number of peers is %u\n"),
961 "number of PUTs to perform per peer"),
967 "name of the file with the login information for the testbed"),
973 "delay between rounds for collecting statistics (default: 30 sec)"),
979 "delay to start doing PUTs (default: 1 sec)"),
985 "delay to start doing GETs (default: 5 min)"),
996 "chance that a peer is selected at random for PUTs"),
1002 "timeout for DHT PUT and GET requests (default: 1 min)"),
1021 "gnunet-dht-profiler",
1023 "Measure quality and performance of the DHT service."),
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)...
Context to hold data of peer.
static void delayed_put(void *cls)
Task to do DHT PUTs.
static void dht_disconnect(void *cls, void *op_result)
Adapter function called to destroy a connection to a service.
We should keep track of the route that the message took in the P2P network.
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 char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
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, parse options).
static unsigned int put_probability
Number of peers which should perform a PUT out of 100 peers.
uint64_t rel_value_us
The actual value.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
static uint64_t incoming_bandwidth
Total number of messages received by peer.
static unsigned int n_gets_ok
Number of DHT GETs succeeded.
static unsigned int num_peers
Number of peers.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
static void bandwidth_stats_cont(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Stats callback.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
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.
static void * dht_connect(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to DHT service and return the DHT client handler.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
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.
static unsigned int n_dht
Number of DHT service connections we currently have.
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 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).
#define GNUNET_TIME_UNIT_SECONDS
One second.
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. ...
static struct Context * a_ctx
An array of contexts.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
Definition of a command line option.
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 void delayed_get(void *cls)
Task to do DHT GETs.
static enum @8 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
static void put_cont(void *cls)
Conclude individual PUT operation, schedule the next one.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
#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...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void service_started(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback called when DHT service on the peer is started.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Connection to the DHT service.
Opaque handle to an abstract operation to be executed by the testing framework.
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_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
struct GNUNET_DHT_Handle * dht
Handler to the DHT service.
static unsigned int total_put_path_length
Total put path length across all peers.
static unsigned int replication
Replication degree.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
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.
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.
static char * value
Value of the record to add/remove.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
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.
static struct GNUNET_TIME_Relative delay_get
The delay to start puts.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static struct GNUNET_TIME_Relative delay_put
The delay to start puts.
static const struct GNUNET_CONFIGURATION_Handle * config
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
static double average_put_path_length
Average number of hops taken to do put.
static void dht_connected(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Connection to DHT has been established.
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...
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 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.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
static uint64_t outgoing_bandwidth
Total number of messages sent by peer.
struct Context * ctx
The linked peer context.
static unsigned int n_gets
Number of DHT GETs made.
uint64_t event_mask
Global event mask for all testbed events.
static struct GNUNET_TESTBED_Operation * bandwidth_stats_op
Testbed Operation (to get stats).
struct GNUNET_HashCode key
The key used in the DHT.
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.
static unsigned int size
Size of the "table".
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
static unsigned long long n_puts
Number of DHT PUTs made.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
static struct GNUNET_TESTBED_Peer ** testbed_handles
Testbed peer handles.
static struct GNUNET_TIME_Relative timeout
The timeout for GET and PUT.
static int in_shutdown
Are we shutting down.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration.
static void start_profiling(void)
Connect to DHT services of active peers.
The identity of the host (wraps the signing key of the peer).
static char * hosts_file
Name of the file with the hosts to run the test over.
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.
struct ActiveContext * get_ac
The active context used for our DHT GET.
static struct CadetPeer * peers
Operation to get peer ids.
struct GNUNET_DHT_GetHandle * dht_get
The get handle.
#define GNUNET_log(kind,...)
static void do_shutdown(void *cls)
Shutdown task.
Entry in list of pending tasks.
static int peers_started
Counter to keep track of peers added to peer_context lists.
static void cancel_get(void *cls)
Task to cancel DHT GET.
static unsigned long long n_puts_ok
Number of DHT PUTs succeeded.
int main(int argc, char *const *argv)
Main function.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
static struct GNUNET_TIME_Relative delay_stats
The delay between rounds for collecting statistics.
static double average_get_path_length
Average number of hops taken to do get.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
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_SCHEDULER_Task * delay_task
Delay task.
struct GNUNET_TESTBED_Operation * op
Testbed operation acting on this peer.
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_DHT_PutHandle * dht_put
The put handle.
A peer controlled by the testing framework.
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 unsigned int n_gets_fail
Number of DHT GETs succeeded.
uint32_t data
The data value.
static struct ActiveContext * a_ac
Array of active peers.
static unsigned int total_get_path_length
Total get path length across all peers.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
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.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.