diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-06-01 16:39:35 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-06-01 16:39:35 +0200 |
commit | 198c09654354d09a9b33f27cf095e0295f70826c (patch) | |
tree | 07aa088c8e9664dc76915cc6b664654da59359f4 /src/transport/test_communicator_basic.c | |
parent | a325c3eaa8450d325fe57959eac29da5496cfd6d (diff) | |
download | gnunet-198c09654354d09a9b33f27cf095e0295f70826c.tar.gz gnunet-198c09654354d09a9b33f27cf095e0295f70826c.zip |
tng: more UDP communicator backchannels
Added a new message for queue updates to indicate queue length.
Queues now may also have a priority parameter.
Diffstat (limited to 'src/transport/test_communicator_basic.c')
-rw-r--r-- | src/transport/test_communicator_basic.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 1dfcf2371..1ea79fa19 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -58,19 +58,21 @@ static char *cfg_peers_name[NUM_PEERS]; | |||
58 | 58 | ||
59 | static int ret; | 59 | static int ret; |
60 | 60 | ||
61 | static size_t long_message_size; | ||
62 | |||
61 | static struct GNUNET_TIME_Absolute start_short; | 63 | static struct GNUNET_TIME_Absolute start_short; |
62 | 64 | ||
63 | static struct GNUNET_TIME_Absolute start_long; | 65 | static struct GNUNET_TIME_Absolute start_long; |
64 | 66 | ||
65 | static struct GNUNET_TIME_Absolute timeout; | 67 | static struct GNUNET_TIME_Absolute timeout; |
66 | 68 | ||
67 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *my_tc; | 69 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc; |
68 | 70 | ||
69 | #define SHORT_MESSAGE_SIZE 128 | 71 | #define SHORT_MESSAGE_SIZE 128 |
70 | 72 | ||
71 | #define LONG_MESSAGE_SIZE 32000 | 73 | #define LONG_MESSAGE_SIZE 32000 /* FIXME */ |
72 | 74 | ||
73 | #define BURST_PACKETS 50 | 75 | #define BURST_PACKETS 500 |
74 | 76 | ||
75 | #define TOTAL_ITERATIONS 1 | 77 | #define TOTAL_ITERATIONS 1 |
76 | 78 | ||
@@ -88,6 +90,7 @@ static unsigned int iterations_left = TOTAL_ITERATIONS; | |||
88 | 90 | ||
89 | enum TestPhase | 91 | enum TestPhase |
90 | { | 92 | { |
93 | TP_INIT, | ||
91 | TP_BURST_SHORT, | 94 | TP_BURST_SHORT, |
92 | TP_BURST_LONG, | 95 | TP_BURST_LONG, |
93 | TP_SIZE_CHECK | 96 | TP_SIZE_CHECK |
@@ -230,15 +233,18 @@ static void | |||
230 | size_test (void *cls) | 233 | size_test (void *cls) |
231 | { | 234 | { |
232 | char *payload; | 235 | char *payload; |
236 | size_t max_size = 64000; | ||
233 | 237 | ||
234 | GNUNET_assert (TP_SIZE_CHECK == phase); | 238 | GNUNET_assert (TP_SIZE_CHECK == phase); |
235 | if (ack >= 64000) | 239 | if (LONG_MESSAGE_SIZE != long_message_size) |
240 | max_size = long_message_size; | ||
241 | if (ack >= max_size) | ||
236 | return; /* Leave some room for our protocol, so not 2^16 exactly */ | 242 | return; /* Leave some room for our protocol, so not 2^16 exactly */ |
237 | payload = make_payload (ack); | 243 | payload = make_payload (ack); |
238 | ack += 5; | 244 | ack += 5; |
239 | num_sent++; | 245 | num_sent++; |
240 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 246 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
241 | (ack < 64000) | 247 | (ack < max_size) |
242 | ? &size_test | 248 | ? &size_test |
243 | : NULL, | 249 | : NULL, |
244 | NULL, | 250 | NULL, |
@@ -254,7 +260,7 @@ long_test (void *cls) | |||
254 | { | 260 | { |
255 | char *payload; | 261 | char *payload; |
256 | 262 | ||
257 | payload = make_payload (LONG_MESSAGE_SIZE); | 263 | payload = make_payload (long_message_size); |
258 | num_sent++; | 264 | num_sent++; |
259 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 265 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
260 | (BURST_PACKETS == | 266 | (BURST_PACKETS == |
@@ -263,7 +269,7 @@ long_test (void *cls) | |||
263 | : &long_test, | 269 | : &long_test, |
264 | NULL, | 270 | NULL, |
265 | payload, | 271 | payload, |
266 | LONG_MESSAGE_SIZE); | 272 | long_message_size); |
267 | GNUNET_free (payload); | 273 | GNUNET_free (payload); |
268 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); | 274 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); |
269 | } | 275 | } |
@@ -288,6 +294,7 @@ short_test (void *cls) | |||
288 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); | 294 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); |
289 | } | 295 | } |
290 | 296 | ||
297 | |||
291 | static int test_prepared = GNUNET_NO; | 298 | static int test_prepared = GNUNET_NO; |
292 | 299 | ||
293 | /** | 300 | /** |
@@ -316,7 +323,6 @@ prepare_test (void *cls) | |||
316 | } | 323 | } |
317 | 324 | ||
318 | 325 | ||
319 | |||
320 | /** | 326 | /** |
321 | * @brief Handle opening of queue | 327 | * @brief Handle opening of queue |
322 | * | 328 | * |
@@ -332,18 +338,25 @@ static void | |||
332 | add_queue_cb (void *cls, | 338 | add_queue_cb (void *cls, |
333 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, | 339 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
334 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * | 340 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue * |
335 | tc_queue) | 341 | tc_queue, |
342 | size_t mtu) | ||
336 | { | 343 | { |
344 | if (TP_INIT != phase) | ||
345 | return; | ||
337 | if (0 != strcmp ((char*) cls, cfg_peers_name[0])) | 346 | if (0 != strcmp ((char*) cls, cfg_peers_name[0])) |
338 | return; // TODO? | 347 | return; // TODO? |
339 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 348 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
340 | "Queue established, starting test...\n"); | 349 | "Queue established, starting test...\n"); |
341 | start_short = GNUNET_TIME_absolute_get (); | 350 | start_short = GNUNET_TIME_absolute_get (); |
342 | my_tc = tc_queue; | 351 | my_tc = tc_h; |
352 | if (0 != mtu) | ||
353 | long_message_size = mtu; | ||
354 | else | ||
355 | long_message_size = LONG_MESSAGE_SIZE; | ||
343 | phase = TP_BURST_SHORT; | 356 | phase = TP_BURST_SHORT; |
344 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); | 357 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); |
345 | GNUNET_assert (NULL == to_task); | 358 | GNUNET_assert (NULL == to_task); |
346 | to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 359 | to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
347 | &latency_timeout, | 360 | &latency_timeout, |
348 | NULL); | 361 | NULL); |
349 | prepare_test (NULL); | 362 | prepare_test (NULL); |
@@ -395,6 +408,9 @@ incoming_message_cb (void *cls, | |||
395 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); | 408 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); |
396 | switch (phase) | 409 | switch (phase) |
397 | { | 410 | { |
411 | case TP_INIT: | ||
412 | GNUNET_break (0); | ||
413 | break; | ||
398 | case TP_BURST_SHORT: | 414 | case TP_BURST_SHORT: |
399 | { | 415 | { |
400 | GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); | 416 | GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); |
@@ -428,7 +444,7 @@ incoming_message_cb (void *cls, | |||
428 | } | 444 | } |
429 | case TP_BURST_LONG: | 445 | case TP_BURST_LONG: |
430 | { | 446 | { |
431 | if (LONG_MESSAGE_SIZE != payload_len) | 447 | if (long_message_size != payload_len) |
432 | { | 448 | { |
433 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 449 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
434 | "Ignoring packet with wrong length\n"); | 450 | "Ignoring packet with wrong length\n"); |
@@ -441,7 +457,7 @@ incoming_message_cb (void *cls, | |||
441 | { | 457 | { |
442 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 458 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
443 | "Long size packet test done.\n"); | 459 | "Long size packet test done.\n"); |
444 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((LONG_MESSAGE_SIZE | 460 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size |
445 | * num_received * 1000 | 461 | * num_received * 1000 |
446 | * 1000) | 462 | * 1000) |
447 | / duration.rel_value_us); | 463 | / duration.rel_value_us); |
@@ -553,6 +569,7 @@ main (int argc, | |||
553 | char *test_name; | 569 | char *test_name; |
554 | char *cfg_peer; | 570 | char *cfg_peer; |
555 | 571 | ||
572 | phase = TP_INIT; | ||
556 | ret = 1; | 573 | ret = 1; |
557 | test_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 574 | test_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); |
558 | communicator_name = strchr (test_name, '-'); | 575 | communicator_name = strchr (test_name, '-'); |