56 #define CONNECT_TIMEOUT \
57 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
62 #define DEFAULT_MESSAGE_SIZE 1024
67 #define DEFAULT_MESSAGE_COUNT 1024
72 #define DEFAULT_ITERATION_COUNT 1
169 unsigned int iterations;
171 unsigned long long avg_duration;
174 float stddev_duration;
198 fprintf (stdout,
"\n");
213 while (NULL != (icur = inext))
220 _ (
"%llu B in %llu ms == %.2f KB/s!\n"),
226 avg_rate += icur->
rate;
232 avg_rate /= iterations;
234 avg_duration /= iterations;
239 while (NULL != (icur = inext))
242 stddev_rate += ((icur->
rate - avg_rate) * (icur->
rate - avg_rate));
247 stddev_rate = stddev_rate / iterations;
248 stddev_rate = sqrtf (stddev_rate);
251 stddev_duration = stddev_duration / iterations;
252 stddev_duration = sqrtf (stddev_duration);
256 "%u;%u;%llu;%llu;%.2f;%.2f",
260 (
unsigned long long) stddev_duration,
265 while (NULL != (icur = inext))
283 "Received %llu bytes/s (%llu bytes in %s)\n",
289 fprintf (stdout,
"\n");
329 fprintf (stdout,
".");
348 "\nStarting benchmark, starting to send %u messages in %u byte blocks\n",
358 static int it_count = 0;
388 fprintf (stdout,
"Connected to different peer `%s'\n",
GNUNET_i2s (&
pid));
393 fprintf (stdout,
"Successfully connected to `%s'\n",
GNUNET_i2s (&
pid));
419 "Disconnected from peer `%s' while benchmarking\n",
453 "Received %u bytes\n",
454 (
unsigned int) ntohs (message->
size));
464 fprintf (stdout,
"Denying connection to `%s'\n",
GNUNET_i2s (
peer));
497 fprintf (stderr,
"Message size too big!\n");
503 fprintf (stderr,
"No peer identity given\n");
510 fprintf (stderr,
"Failed to parse peer identity `%s'\n",
cpid);
517 "Trying to send %u messages with size %u to peer `%s'\n",
525 "Trying to receive messages from peer `%s'\n",
530 fprintf (stderr,
"No operation given\n");
537 fprintf (stderr,
"Failed to connect to ATS service\n");
551 fprintf (stderr,
"Failed to connect to transport service\n");
565 main (
int argc,
char *
const *argv)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_Envelope * env
#define gettext_noop(String)
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct GNUNET_TIME_Absolute start_time
Start time of the current round; used to determine how long one iteration takes (which influences how...
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static struct GNUNET_TIME_Relative duration
How long do we run the test?
static int benchmark_send
Option -s.
static void iteration_start()
static unsigned int benchmark_size
Option -m.
static struct Iteration * ihead
static struct GNUNET_ATS_ConnectivityHandle * ats
Handle to ATS service.
static unsigned int verbosity
Selected level of verbosity.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *m)
Function called to notify transport users that another peer connected to us.
static struct Iteration * itail
static void iteration_done()
#define DEFAULT_ITERATION_COUNT
Benchmarking iteration count.
static struct GNUNET_MQ_Handle * mq
Handle for transmissions.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg)
Main function that will be run by the scheduler.
static int blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
static struct GNUNET_TRANSPORT_CoreHandle * handle
Handle to transport service.
static void shutdown_task(void *cls)
Task run in monitor mode when the user presses CTRL-C to abort.
static int ret
Global return value (0 success).
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
static struct GNUNET_TRANSPORT_Blacklist * bl_handle
#define DEFAULT_MESSAGE_SIZE
Benchmarking block size in bye.
static unsigned int benchmark_iterations
Option -i.
static unsigned int benchmark_count
Option -n.
static void handle_dummy(void *cls, const struct GNUNET_MessageHeader *message)
Function called by the transport for each received message.
#define DEFAULT_MESSAGE_COUNT
Benchmarking message count.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Function called to notify transport users that another peer disconnected from us.
static int check_dummy(void *cls, const struct GNUNET_MessageHeader *message)
Function called by the transport for each received message.
int main(int argc, char *const *argv)
static char * cpid
Which peer should we connect to?
static unsigned int benchmark_running
Benchmark running.
static int benchmark_receive
Option -b.
static struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Try_connect handle.
static void send_msg(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
static unsigned long long traffic_received
Number of bytes of traffic we received so far.
Automatic transport selection and outbound bandwidth determination.
Constants for network protocols.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
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.
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
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,...
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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,...
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
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_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
struct GNUNET_TRANSPORT_Blacklist * GNUNET_TRANSPORT_blacklist(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls)
Install a blacklist callback.
void GNUNET_TRANSPORT_blacklist_cancel(struct GNUNET_TRANSPORT_Blacklist *br)
Abort the blacklist.
Handle to the ATS subsystem for connectivity management.
Handle for ATS address suggestion requests.
Definition of a command line option.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Handle for blacklisting requests.
Handle for the transport service (includes all of the state for the transport service).
struct GNUNET_TIME_Absolute end
struct GNUNET_TIME_Absolute start
struct GNUNET_TIME_Relative dur
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.