GNUnet 0.22.2
transport_api_cmd_send_simple_performance.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
#include "transport-testing2.h"
#include "transport-testing-cmds.h"
Include dependency graph for transport_api_cmd_send_simple_performance.c:

Go to the source code of this file.

Data Structures

struct  SendSimplePerfState
 Struct to hold information for callbacks. More...
 
struct  MQWrapper
 

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...
 

Functions

static void send_simple_cleanup (void *cls)
 The cleanup function of this cmd frees resources the cmd allocated. More...
 
static void send_simple_single (void *cls)
 
static int send_simple_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static void send_simple_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 The run method of this cmd will send a simple message to the connected peers. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple_performance (const char *label, const char *start_peer_label, const char *create_label, uint32_t num, int size, int max_send, struct GNUNET_TESTING_NetjailTopology *topology)
 

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log (kind, __VA_ARGS__)

Generic logging shortcut.

Definition at line 36 of file transport_api_cmd_send_simple_performance.c.

Function Documentation

◆ send_simple_cleanup()

static void send_simple_cleanup ( void *  cls)
static

The cleanup function of this cmd frees resources the cmd allocated.

Definition at line 100 of file transport_api_cmd_send_simple_performance.c.

101{
102 struct SendSimpleState *sss = cls;
103
104 GNUNET_free (sss);
105}
#define GNUNET_free(ptr)
Wrapper around free.
Struct to hold information for callbacks.

References GNUNET_free.

Referenced by GNUNET_TRANSPORT_cmd_send_simple_performance().

Here is the caller graph for this function:

◆ send_simple_single()

static void send_simple_single ( void *  cls)
static

Definition at line 109 of file transport_api_cmd_send_simple_performance.c.

110{
111 struct MQWrapper *mq_wrapper = cls;
112 struct GNUNET_MQ_Envelope *env;
114 struct GNUNET_TIME_Absolute now;
115
117 mq_wrapper->num_send++;
119 "Sending simple test message with size %u number %u with mq %p max %u\n",
120 mq_wrapper->sss->size,
121 mq_wrapper->num_send,
122 mq_wrapper->mq,
123 mq_wrapper->sss->max_send);
124
125 env = GNUNET_MQ_msg_extra (test,
126 mq_wrapper->sss->size - sizeof(*test),
128 test->num = htonl (mq_wrapper->num_send);
130 memset (&test[1],
131 '1',
132 mq_wrapper->sss->size - sizeof(*test));
133 GNUNET_MQ_send (mq_wrapper->mq,
134 env);
135 if (mq_wrapper->sss->max_send > mq_wrapper->num_send)
137 else
138 GNUNET_TESTING_async_finish (&mq_wrapper->sss->ac);
139}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:61
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.
Definition: scheduler.c:1304
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
Time for absolute times used by GNUnet, in microseconds.
uint32_t num
Monotonically increasing counter throughout the test.
struct GNUNET_TIME_AbsoluteNBO time_send
Time this message was send via transport api.
struct GNUNET_MQ_Handle * mq
Message queue for a peer.
uint32_t num_send
Number of messages already send.
struct SendSimplePerfState * sss
State of the command.
unsigned int size
Size of the message in bytes.
unsigned int max_send
Maximum number of messages per peer.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
#define GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE
Message type used by #().
static void send_simple_single(void *cls)
#define LOG(kind,...)
Generic logging shortcut.

References SendSimplePerfState::ac, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SCHEDULER_add_now(), GNUNET_TESTING_async_finish(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE, LOG, SendSimplePerfState::max_send, MQWrapper::mq, GNUNET_TRANSPORT_TESTING_PerformanceTestMessage::num, MQWrapper::num_send, send_simple_single(), SendSimplePerfState::size, MQWrapper::sss, and GNUNET_TRANSPORT_TESTING_PerformanceTestMessage::time_send.

Referenced by send_simple_cb(), and send_simple_single().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_simple_cb()

static int send_simple_cb ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 143 of file transport_api_cmd_send_simple_performance.c.

146{
147 struct SendSimplePerfState *sss = cls;
148 struct GNUNET_MQ_Handle *mq = value;
149 struct MQWrapper *mq_wrapper = GNUNET_new (struct MQWrapper);
150
151 mq_wrapper->sss = sss;
152 mq_wrapper->mq = mq;
153 send_simple_single (mq_wrapper);
154
155 return GNUNET_OK;
156}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static char * value
Value of the record to add/remove.
@ GNUNET_OK
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Handle to a message queue.
Definition: mq.c:87
Struct to hold information for callbacks.

References GNUNET_new, GNUNET_OK, mq, MQWrapper::mq, send_simple_single(), MQWrapper::sss, and value.

Referenced by send_simple_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_simple_run()

static void send_simple_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

The run method of this cmd will send a simple message to the connected peers.

Definition at line 164 of file transport_api_cmd_send_simple_performance.c.

166{
167 struct SendSimplePerfState *sss = cls;
168 const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
169 const struct GNUNET_TESTING_Command *peer1_cmd;
170 const struct GNUNET_TESTING_Command *system_cmd;
171 const struct GNUNET_TESTBED_System *tl_system;
172
173
175 sss->start_peer_label);
177 &connected_peers_map);
178
180 sss->create_label);
181 GNUNET_TESTING_get_trait_test_system (system_cmd,
182 &tl_system);
183
186 connected_peers_map, send_simple_cb,
187 sss);
188}
static struct GNUNET_TESTING_Interpreter * is
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_TESTING_get_trait_connected_peers_map(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_CONTAINER_MultiShortmap **ret)
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
Internal representation of the hash map.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testbed.c:54
A command to be run by the interpreter.
const char * create_label
Label of the cmd which started the test system.
const char * start_peer_label
Label of the cmd to start a peer.
static int send_simple_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References SendSimplePerfState::create_label, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TRANSPORT_TESTING_get_trait_connected_peers_map(), is, send_simple_cb(), and SendSimplePerfState::start_peer_label.

Referenced by GNUNET_TRANSPORT_cmd_send_simple_performance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_cmd_send_simple_performance()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple_performance ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num,
int  size,
int  max_send,
struct GNUNET_TESTING_NetjailTopology topology 
)
Parameters
labelname for command.
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
sizeThe size of the test message to send.
max_sendThe number of messages to send.
topologyThe topology for the test setup.
Returns
command.

Definition at line 192 of file transport_api_cmd_send_simple_performance.c.

201{
202 struct SendSimplePerfState *sss;
203 struct GNUNET_TESTING_Command cmd;
204
205 sss = GNUNET_new (struct SendSimplePerfState);
206 sss->start_peer_label = start_peer_label;
207 sss->create_label = create_label;
208 sss->topology = topology;
209 sss->size = size;
210 sss->max_send = max_send;
212 label,
215 NULL,
216 &sss->ac);
217 cmd.asynchronous_finish = GNUNET_YES;
218 return cmd;
219}
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command that may be asynchronous.
@ GNUNET_YES
static unsigned int size
Size of the "table".
Definition: peer.c:68
struct GNUNET_TESTING_CommandLabel label
Label for the command.
struct GNUNET_TESTING_NetjailTopology * topology
The topology we get the connected nodes from.
static void send_simple_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will send a simple message to the connected peers.
static void send_simple_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.

References SendSimplePerfState::ac, GNUNET_TESTING_Command::asynchronous_finish, SendSimplePerfState::create_label, GNUNET_new, GNUNET_TESTING_command_new_ac(), GNUNET_YES, GNUNET_TESTING_Command::label, SendSimplePerfState::max_send, send_simple_cleanup(), send_simple_run(), size, SendSimplePerfState::size, SendSimplePerfState::start_peer_label, and SendSimplePerfState::topology.

Here is the call graph for this function: