#include "platform.h"
#include <gnunet_util_lib.h>
#include <gnunet_gnsrecord_lib.h>
#include <gnunet_gns_service.h>
Go to the source code of this file.
Data Structures | |
struct | Request |
Request we should make. More... | |
Macros | |
#define | DEF_REQUEST_DELAY |
How long do we wait at least between requests by default? More... | |
#define | DEF_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) |
How long do we wait until we consider a request failed by default? More... | |
Enumerations | |
enum | RequestCategory { RC_SHARED = 0 , RC_PRIVATE = 1 , RC_MAX = 2 } |
We distinguish between different categories of requests, for which we track statistics separately. More... | |
Functions | |
static void | free_request (struct Request *req) |
Free req and data structures reachable from it. More... | |
static void | process_result (void *cls, int gns_tld, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Function called with the result of a GNS resolution. More... | |
static void | process_queue (void *cls) |
Process request from the queue. More... | |
static int | compare_req (const void *c1, const void *c2) |
Compare two requests by latency for qsort(). More... | |
static void | do_shutdown (void *cls) |
Output statistics, then clean up and terminate the process. More... | |
static void | queue (const char *hostname, enum RequestCategory cat) |
Add hostname to the list of requests to be made. More... | |
static void | process_stdin (void *cls) |
Begin processing hostnames from stdin. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Process requests from the queue, then if the queue is not empty, try again. More... | |
int | main (int argc, char *const *argv) |
Call with list of names with numeric category to query. More... | |
Variables | |
static struct GNUNET_GNS_Handle * | gns |
GNS handle. More... | |
static unsigned int | lookups [RC_MAX] |
Number of lookups we performed overall per category. More... | |
static unsigned int | replies [RC_MAX] |
Number of replies we got per category. More... | |
static unsigned int | failures [RC_MAX] |
Number of replies we got per category. More... | |
static struct GNUNET_TIME_Relative | latency_sum [RC_MAX] |
Sum of the observed latencies of successful queries, per category. More... | |
static struct Request * | act_head |
Active requests are kept in a DLL. More... | |
static struct Request * | act_tail |
Active requests are kept in a DLL. More... | |
static struct Request * | succ_head |
Completed successful requests are kept in a DLL. More... | |
static struct Request * | succ_tail |
Completed successful requests are kept in a DLL. More... | |
static struct Request * | todo_head |
Yet to be started requests are kept in a DLL. More... | |
static struct Request * | todo_tail |
Yet to be started requests are kept in a DLL. More... | |
static struct GNUNET_SCHEDULER_Task * | t |
Main task. More... | |
static struct GNUNET_TIME_Relative | request_delay |
Delay between requests. More... | |
static struct GNUNET_TIME_Relative | timeout |
Timeout for requests. More... | |
static unsigned int | active_cnt |
Number of requests we have concurrently active. More... | |
static int | g2d |
Look for GNS2DNS records specifically? More... | |
#define DEF_REQUEST_DELAY |
How long do we wait at least between requests by default?
Definition at line 34 of file gnunet-gns-benchmark.c.
#define DEF_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) |
How long do we wait until we consider a request failed by default?
Definition at line 40 of file gnunet-gns-benchmark.c.
enum RequestCategory |
We distinguish between different categories of requests, for which we track statistics separately.
However, this process does not change how it acts based on the category.
Enumerator | |
---|---|
RC_SHARED | |
RC_PRIVATE | |
RC_MAX | Must be last and match number of categories. |
Definition at line 49 of file gnunet-gns-benchmark.c.
|
static |
Free req and data structures reachable from it.
req | request to free |
Definition at line 194 of file gnunet-gns-benchmark.c.
References GNUNET_free, GNUNET_GNS_lookup_with_tld_cancel(), and Request::lr.
Referenced by do_shutdown(), and process_queue().
|
static |
Function called with the result of a GNS resolution.
cls | closure with the struct Request |
gns_tld | GNUNET_YES if GNS lookup was attempted |
rd_count | number of records in rd |
rd | the records in reply |
Definition at line 211 of file gnunet-gns-benchmark.c.
References act_head, act_tail, active_cnt, Request::cat, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_add(), Request::hostname, Request::latency, latency_sum, Request::lr, Request::op_start_time, rd, rd_count, replies, succ_head, and succ_tail.
Referenced by process_queue().
|
static |
Process request from the queue.
cls | NULL |
Definition at line 246 of file gnunet-gns-benchmark.c.
References act_head, act_tail, active_cnt, Request::cat, duration, failures, free_request(), g2d, gns, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup_with_tld(), GNUNET_GNSRECORD_TYPE_ANY, GNUNET_GNSRECORD_TYPE_GNS2DNS, GNUNET_log, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), Request::hostname, lookups, Request::lr, Request::op_start_time, process_queue(), process_result(), GNUNET_TIME_Relative::rel_value_us, request_delay, t, timeout, todo_head, and todo_tail.
Referenced by process_queue(), and process_stdin().
|
static |
Compare two requests by latency for qsort().
Definition at line 320 of file gnunet-gns-benchmark.c.
References Request::latency, and GNUNET_TIME_Relative::rel_value_us.
Referenced by do_shutdown().
|
static |
Output statistics, then clean up and terminate the process.
cls | NULL |
Definition at line 340 of file gnunet-gns-benchmark.c.
References act_head, act_tail, Request::cat, compare_req(), failures, free_request(), gns, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_GNS_disconnect(), GNUNET_new_array, GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_divide(), GNUNET_YES, Request::latency, latency_sum, lookups, Request::next, RC_MAX, replies, rp, succ_head, succ_tail, t, todo_head, and todo_tail.
Referenced by run().
|
static |
Add hostname to the list of requests to be made.
hostname | name to resolve |
cat | category of the hostname |
Definition at line 445 of file gnunet-gns-benchmark.c.
References Request::cat, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, Request::hostname, todo_head, and todo_tail.
Referenced by process_stdin().
|
static |
Begin processing hostnames from stdin.
cls | NULL |
Definition at line 480 of file gnunet-gns-benchmark.c.
References delta, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, process_queue(), queue(), RC_MAX, and t.
Referenced by run().
|
static |
Process requests from the queue, then if the queue is not empty, try again.
cls | NULL |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
cfg | configuration |
Definition at line 543 of file gnunet-gns-benchmark.c.
References consensus-simulation::args, cfg, do_shutdown(), gns, GNUNET_break, GNUNET_GNS_connect(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), process_stdin(), and t.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
Call with list of names with numeric category to query.
argc | unused |
argv | unused |
Definition at line 573 of file gnunet-gns-benchmark.c.
References DEF_REQUEST_DELAY, DEF_TIMEOUT, g2d, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_relative_time(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), options, request_delay, ret, run(), and timeout.
|
static |
GNS handle.
Definition at line 110 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), process_queue(), and run().
|
static |
Number of lookups we performed overall per category.
Definition at line 115 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), and process_queue().
|
static |
Number of replies we got per category.
Definition at line 120 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), and process_result().
|
static |
Number of replies we got per category.
Definition at line 125 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), and process_queue().
|
static |
Sum of the observed latencies of successful queries, per category.
Definition at line 131 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), and process_result().
|
static |
Active requests are kept in a DLL.
Definition at line 136 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), process_queue(), and process_result().
|
static |
Active requests are kept in a DLL.
Definition at line 141 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), process_queue(), and process_result().
|
static |
Completed successful requests are kept in a DLL.
Definition at line 146 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), and process_result().
|
static |
Completed successful requests are kept in a DLL.
Definition at line 151 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), and process_result().
|
static |
Yet to be started requests are kept in a DLL.
Definition at line 156 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), process_queue(), and queue().
|
static |
Yet to be started requests are kept in a DLL.
Definition at line 161 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), process_queue(), and queue().
|
static |
Main task.
Definition at line 166 of file gnunet-gns-benchmark.c.
Referenced by do_shutdown(), process_queue(), process_stdin(), and run().
|
static |
Delay between requests.
Definition at line 171 of file gnunet-gns-benchmark.c.
Referenced by main(), and process_queue().
|
static |
Timeout for requests.
Definition at line 176 of file gnunet-gns-benchmark.c.
Referenced by main(), and process_queue().
|
static |
Number of requests we have concurrently active.
Definition at line 181 of file gnunet-gns-benchmark.c.
Referenced by process_queue(), and process_result().
|
static |
Look for GNS2DNS records specifically?
Definition at line 186 of file gnunet-gns-benchmark.c.
Referenced by main(), and process_queue().