GNUnet  0.20.0
transport_api_cmd_send_simple_performance.c File Reference
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.

◆ 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 
116  now = GNUNET_TIME_absolute_get ();
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);
129  test->time_send = GNUNET_TIME_absolute_hton (now);
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:304
#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:63
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:1299
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:638
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 allready 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, SendSimplePerfState::size, MQWrapper::sss, and GNUNET_TRANSPORT_TESTING_PerformanceTestMessage::time_send.

Referenced by send_simple_cb().

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.

Here is the call 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_TESTING_System *tl_system;
172 
173 
175  sss->start_peer_label);
177  &connected_peers_map);
178 
180  sss->create_label);
182  &tl_system);
183 
186  connected_peers_map, send_simple_cb,
187  sss);
188 }
struct GNUNET_TESTING_Interpreter * is
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_test_system(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_System **ret)
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
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.
A command to be run by the interpreter.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:122
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.
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_connected_peers_map(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_CONTAINER_MultiShortmap **ret)
static int send_simple_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

◆ 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 164 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;
211 
212  cmd = GNUNET_TESTING_command_new (sss,
213  label,
216  NULL,
217  &sss->ac);
218  cmd.asynchronous_finish = GNUNET_YES;
219  return cmd;
220 }
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new(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.
@ GNUNET_YES
static unsigned int size
Size of the "table".
Definition: peer.c:68
char label[127+1]
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.