34 #define DEF_REQUEST_DELAY GNUNET_TIME_relative_multiply ( \ 35 GNUNET_TIME_UNIT_MILLISECONDS, 1) 40 #define DEF_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) 223 "Got response for request `%s'\n",
254 while (NULL != (req = act_head))
263 "Failing request `%s' due to timeout\n",
269 if (NULL == (req = todo_head))
273 if (NULL == (req = act_head))
295 "Starting request `%s' (%u in parallel)\n",
323 const struct Request *r1 = *(
void **) c1;
324 const struct Request *r2 = *(
void **) c2;
353 for (req = succ_head; NULL != req; req = req->
next)
356 ra[req->
cat][rp[req->
cat]++] = req;
366 "\tlookups: %u replies: %u failures: %u\n",
382 off = rp[rc] * 50 / 100;
384 "\tmedian(50): %s\n",
387 off = rp[rc] * 75 / 100;
389 "\tquantile(75): %s\n",
392 off = rp[rc] * 90 / 100;
394 "\tquantile(90): %s\n",
397 off = rp[rc] * 99 / 100;
399 "\tquantile(99): %s\n",
409 while (NULL != (req = act_head))
416 while (NULL != (req = succ_head))
423 while (NULL != (req = todo_head))
452 dot = strchr (hostname,
453 (
unsigned char)
'.');
457 "Refusing invalid hostname `%s' (lacks '.')\n",
461 hlen = strlen (hostname) + 1;
483 static uint64_t idot;
496 hn[strlen (in) - 1] =
'\0';
497 if ((2 != sscanf (in,
504 "Malformed input line `%s', skipping\n",
511 if (0 == idot % 100000)
518 "Read 100000 domain names in %s\n",
526 "Done reading %llu domain names\n",
527 (
unsigned long long) idot);
582 "how long to wait between queries"),
588 "how long to wait for an answer"),
593 "look for GNS2DNS records instead of ANY"),
607 "gnunet-gns-benchmark",
608 "resolve GNS names and measure performance",
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)...
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Connection to the GNS service.
static void free_request(struct Request *req)
Free req and data structures reachable from it.
static struct Request * todo_head
Yet to be started requests are kept in a DLL.
static int compare_req(const void *c1, const void *c2)
Compare two requests by latency for qsort().
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.
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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
char * hostname
Hostname we are resolving.
const char * hostname
Hostname we are resolving, allocated at the end of this struct (optimizing memory consumption by redu...
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 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.
void * GNUNET_GNS_lookup_with_tld_cancel(struct GNUNET_GNS_LookupWithTldRequest *ltr)
Cancel pending lookup request.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/'*'.
static struct GNUNET_TIME_Relative request_delay
Delay between requests.
static struct Request * todo_tail
Yet to be started requests are kept in a DLL.
struct GNUNET_GNS_LookupWithTldRequest * GNUNET_GNS_lookup_with_tld(struct GNUNET_GNS_Handle *handle, const char *name, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor2 proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS, determining the zone using the TLD of the given ...
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
static unsigned int failures[RC_MAX]
Number of replies we got per category.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition of a command line option.
enum RequestCategory cat
Category of the request.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
static struct GNUNET_GNS_Handle * gns
GNS handle.
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 unsigned int replies[RC_MAX]
Number of replies we got per category.
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.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
static void process_stdin(void *cls)
Begin processing hostnames from stdin.
struct GNUNET_CONTAINER_HeapNode * hn
Requests are kept in a heap while waiting to be resolved.
#define GNUNET_GNSRECORD_TYPE_GNS2DNS
Record type for delegation to DNS.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define DEF_REQUEST_DELAY
How long do we wait at least between requests by default?
static void do_shutdown(void *cls)
Output statistics, then clean up and terminate the process.
int main(int argc, char *const *argv)
Call with list of names with numeric category to query.
static struct Request * succ_head
Completed successful requests are kept in a DLL.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
static void queue(const char *hostname, enum RequestCategory cat)
Add hostname to the list of requests to be made.
static struct GNUNET_TIME_Relative latency_sum[RC_MAX]
Sum of the observed latencies of successful queries, per category.
static void process_queue(void *cls)
Process request from the queue.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
static unsigned int lookups[RC_MAX]
Number of lookups we performed overall per category.
#define GNUNET_free_nz(ptr)
Wrapper around free.
static struct GNUNET_SCHEDULER_Task * t
Main task.
struct Request * prev
Requests are kept in a DLL.
static struct GNUNET_TIME_Relative timeout
Timeout for requests.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
struct GNUNET_GNS_LookupWithTldRequest * lr
Socket used to make the request, NULL if not active.
struct GNUNET_TIME_Absolute op_start_time
While we are fetching the record, the value is set to the starting time of the GNS operation...
RequestCategory
We distinguish between different categories of requests, for which we track statistics separately...
static struct Request * act_tail
Active requests are kept in a DLL.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
struct GNUNET_TIME_Relative latency
Observed latency, set once we got a reply.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
struct Request * next
Requests are kept in a DLL.
Must be last and match number of categories.
static char * rp
Relying party.
#define DEF_TIMEOUT
How long do we wait until we consider a request failed by default?
static int g2d
Look for GNS2DNS records specifically?
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Time for absolute times used by GNUnet, in microseconds.
static unsigned int active_cnt
Number of requests we have concurrently active.
Defaults, look in cache, then in DHT.
static struct Request * act_head
Active requests are kept in a DLL.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
static struct Request * succ_tail
Completed successful requests are kept in a DLL.
Handle to a lookup request.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.