aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/test_communicator_basic.c207
-rw-r--r--src/transport/transport-testing2.c1
2 files changed, 159 insertions, 49 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 43c98a401..d599d06c6 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -68,8 +68,6 @@ static struct GNUNET_TIME_Absolute timeout;
68 68
69static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc; 69static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
70 70
71#define DROP_RATIO 0.91
72
73#define SHORT_MESSAGE_SIZE 128 71#define SHORT_MESSAGE_SIZE 128
74 72
75#define LONG_MESSAGE_SIZE 32000 /* FIXME */ 73#define LONG_MESSAGE_SIZE 32000 /* FIXME */
@@ -84,6 +82,11 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
84 82
85static unsigned int iterations_left = TOTAL_ITERATIONS; 83static unsigned int iterations_left = TOTAL_ITERATIONS;
86 84
85#define TIMEOUT_MULTIPLIER 1
86
87#define DELAY \
88 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,30)
89
87#define SHORT_BURST_WINDOW \ 90#define SHORT_BURST_WINDOW \
88 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) 91 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
89 92
@@ -99,13 +102,21 @@ enum TestPhase
99}; 102};
100 103
101 104
102static size_t num_sent = 0; 105static size_t num_sent_short = 0;
106
107static size_t num_sent_long = 0;
108
109static size_t num_sent_size = 0;
103 110
104static uint32_t ack = 0; 111static uint32_t ack = 0;
105 112
106static enum TestPhase phase; 113static enum TestPhase phase;
107 114
108static size_t num_received = 0; 115static size_t num_received_short = 0;
116
117static size_t num_received_long = 0;
118
119static size_t num_received_size = 0;
109 120
110static uint64_t avg_latency = 0; 121static uint64_t avg_latency = 0;
111 122
@@ -232,17 +243,34 @@ make_payload (size_t payload_size)
232static void 243static void
233latency_timeout (void *cls) 244latency_timeout (void *cls)
234{ 245{
246
247 size_t num_sent = 0;
248 size_t num_received = 0;
249
235 to_task = NULL; 250 to_task = NULL;
236 if (GNUNET_TIME_absolute_get_remaining (timeout).rel_value_us > 0) 251 if (GNUNET_TIME_absolute_get_remaining (timeout).rel_value_us > 0)
237 { 252 {
238 LOG (GNUNET_ERROR_TYPE_ERROR,
239 "Reschedule latency task\n");
240 to_task = GNUNET_SCHEDULER_add_at (timeout, 253 to_task = GNUNET_SCHEDULER_add_at (timeout,
241 &latency_timeout, 254 &latency_timeout,
242 NULL); 255 NULL);
243 return; 256 return;
244 } 257 }
245 258
259 switch (phase)
260 {
261 case TP_BURST_SHORT:
262 num_sent = num_sent_short;
263 num_received = num_received_short;
264 break;
265 case TP_BURST_LONG:
266 num_sent = num_sent_long;
267 num_received = num_received_long;
268 break;
269 case TP_SIZE_CHECK:
270 num_sent = num_sent_size;
271 num_received = num_received_size;
272 break;
273 }
246 LOG (GNUNET_ERROR_TYPE_ERROR, 274 LOG (GNUNET_ERROR_TYPE_ERROR,
247 "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n", 275 "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n",
248 phase, num_sent, num_received); 276 phase, num_sent, num_received);
@@ -250,6 +278,8 @@ latency_timeout (void *cls)
250 GNUNET_SCHEDULER_shutdown (); 278 GNUNET_SCHEDULER_shutdown ();
251} 279}
252 280
281/*static void
282 size_test (void *cls);*/
253 283
254static void 284static void
255size_test (void *cls) 285size_test (void *cls)
@@ -257,6 +287,9 @@ size_test (void *cls)
257 char *payload; 287 char *payload;
258 size_t max_size = 64000; 288 size_t max_size = 64000;
259 289
290 LOG (GNUNET_ERROR_TYPE_DEBUG,
291 "size_test_cb %u\n",
292 num_sent_size);
260 GNUNET_assert (TP_SIZE_CHECK == phase); 293 GNUNET_assert (TP_SIZE_CHECK == phase);
261 if (LONG_MESSAGE_SIZE != long_message_size) 294 if (LONG_MESSAGE_SIZE != long_message_size)
262 max_size = long_message_size; 295 max_size = long_message_size;
@@ -264,7 +297,7 @@ size_test (void *cls)
264 return; /* Leave some room for our protocol, so not 2^16 exactly */ 297 return; /* Leave some room for our protocol, so not 2^16 exactly */
265 ack += 10; 298 ack += 10;
266 payload = make_payload (ack); 299 payload = make_payload (ack);
267 num_sent++; 300 num_sent_size++;
268 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 301 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
269 (ack < max_size) 302 (ack < max_size)
270 ? &size_test 303 ? &size_test
@@ -273,47 +306,98 @@ size_test (void *cls)
273 payload, 306 payload,
274 ack); 307 ack);
275 GNUNET_free (payload); 308 GNUNET_free (payload);
276 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 309 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
310 GNUNET_TIME_UNIT_SECONDS,
311 TIMEOUT_MULTIPLIER));
277} 312}
278 313
314/*static void
315size_test (void *cls)
316{
317 GNUNET_SCHEDULER_add_delayed (DELAY,
318 &size_test_cb,
319 NULL);
320 }*/
321
322static void
323long_test (void *cls);
279 324
280static void 325static void
281long_test (void *cls) 326long_test_cb (void *cls)
282{ 327{
283 char *payload; 328 char *payload;
284 329
330 LOG (GNUNET_ERROR_TYPE_DEBUG,
331 "long_test_cb %u/%u\n",
332 num_sent_long,
333 num_received_long);
285 payload = make_payload (long_message_size); 334 payload = make_payload (long_message_size);
286 num_sent++; 335 num_sent_long++;
287 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 336 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
288 (BURST_PACKETS == 337 ((BURST_PACKETS
289 num_sent) 338 * 0.91 ==
339 num_received_long) ||
340 (BURST_PACKETS ==
341 num_sent_long))
290 ? NULL 342 ? NULL
291 : &long_test, 343 : &long_test,
292 NULL, 344 NULL,
293 payload, 345 payload,
294 long_message_size); 346 long_message_size);
295 GNUNET_free (payload); 347 GNUNET_free (payload);
296 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 348 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
349 GNUNET_TIME_UNIT_SECONDS,
350 TIMEOUT_MULTIPLIER));
297} 351}
298 352
353static void
354long_test (void *cls)
355{
356 /*LOG (GNUNET_ERROR_TYPE_DEBUG,
357 "long_test %u\n",
358 num_sent_long);*/
359 GNUNET_SCHEDULER_add_delayed (DELAY,
360 &long_test_cb,
361 NULL);
362}
299 363
300static void 364static void
301short_test (void *cls) 365short_test (void *cls);
366
367static void
368short_test_cb (void *cls)
302{ 369{
303 char *payload; 370 char *payload;
304 371
372 LOG (GNUNET_ERROR_TYPE_DEBUG,
373 "short_test_cb %u/%u\n",
374 num_sent_short,
375 num_received_short);
305 payload = make_payload (SHORT_MESSAGE_SIZE); 376 payload = make_payload (SHORT_MESSAGE_SIZE);
306 num_sent++; 377 num_sent_short++;
307 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 378 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
308 (BURST_PACKETS == 379 ((BURST_PACKETS
309 num_sent) 380 * 0.91 ==
381 num_received_short) ||
382 (BURST_PACKETS ==
383 num_sent_short))
310 ? NULL 384 ? NULL
311 : &short_test, 385 : &short_test,
312 NULL, 386 NULL,
313 payload, 387 payload,
314 SHORT_MESSAGE_SIZE); 388 SHORT_MESSAGE_SIZE);
315 GNUNET_free (payload); 389 GNUNET_free (payload);
316 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 390 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
391 GNUNET_TIME_UNIT_SECONDS,
392 TIMEOUT_MULTIPLIER));
393}
394
395static void
396short_test (void *cls)
397{
398 GNUNET_SCHEDULER_add_delayed (DELAY,
399 &short_test_cb,
400 NULL);
317} 401}
318 402
319 403
@@ -378,10 +462,12 @@ add_queue_cb (void *cls,
378 long_message_size = LONG_MESSAGE_SIZE; 462 long_message_size = LONG_MESSAGE_SIZE;
379 phase = TP_BURST_SHORT; 463 phase = TP_BURST_SHORT;
380 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( 464 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
381 GNUNET_TIME_UNIT_SECONDS, 2)); 465 GNUNET_TIME_UNIT_SECONDS,
466 TIMEOUT_MULTIPLIER));
382 GNUNET_assert (NULL == to_task); 467 GNUNET_assert (NULL == to_task);
383 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( 468 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
384 GNUNET_TIME_UNIT_SECONDS, 2), 469 GNUNET_TIME_UNIT_SECONDS,
470 TIMEOUT_MULTIPLIER),
385 &latency_timeout, 471 &latency_timeout,
386 NULL); 472 NULL);
387 // prepare_test (NULL); 473 // prepare_test (NULL);
@@ -395,10 +481,26 @@ update_avg_latency (const char*payload)
395 struct GNUNET_TIME_AbsoluteNBO *ts_n; 481 struct GNUNET_TIME_AbsoluteNBO *ts_n;
396 struct GNUNET_TIME_Absolute ts; 482 struct GNUNET_TIME_Absolute ts;
397 struct GNUNET_TIME_Relative latency; 483 struct GNUNET_TIME_Relative latency;
484 size_t num_received = 0;
398 485
399 ts_n = (struct GNUNET_TIME_AbsoluteNBO *) payload; 486 ts_n = (struct GNUNET_TIME_AbsoluteNBO *) payload;
400 ts = GNUNET_TIME_absolute_ntoh (*ts_n); 487 ts = GNUNET_TIME_absolute_ntoh (*ts_n);
401 latency = GNUNET_TIME_absolute_get_duration (ts); 488 latency = GNUNET_TIME_absolute_get_duration (ts);
489 LOG (GNUNET_ERROR_TYPE_DEBUG,
490 "Latency of received packet: %u\n",
491 latency);
492 switch (phase)
493 {
494 case TP_BURST_SHORT:
495 num_received = num_received_short;
496 break;
497 case TP_BURST_LONG:
498 num_received = num_received_long;
499 break;
500 case TP_SIZE_CHECK:
501 num_received = num_received_size;
502 break;
503 }
402 if (1 >= num_received) 504 if (1 >= num_received)
403 avg_latency = latency.rel_value_us; 505 avg_latency = latency.rel_value_us;
404 else 506 else
@@ -407,7 +509,6 @@ update_avg_latency (const char*payload)
407 509
408} 510}
409 511
410
411/** 512/**
412 * @brief Handle an incoming message 513 * @brief Handle an incoming message
413 * 514 *
@@ -419,7 +520,8 @@ update_avg_latency (const char*payload)
419 */ 520 */
420static void 521static void
421incoming_message_cb (void *cls, 522incoming_message_cb (void *cls,
422 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle 523 struct
524 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
423 *tc_h, 525 *tc_h,
424 const char*payload, 526 const char*payload,
425 size_t payload_len) 527 size_t payload_len)
@@ -430,10 +532,10 @@ incoming_message_cb (void *cls,
430 "unexpected receiver...\n"); 532 "unexpected receiver...\n");
431 return; 533 return;
432 } 534 }
433 LOG (GNUNET_ERROR_TYPE_DEBUG,
434 "Incomming message\n");
435 /* Reset timeout */ 535 /* Reset timeout */
436 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 536 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
537 GNUNET_TIME_UNIT_SECONDS,
538 TIMEOUT_MULTIPLIER));
437 switch (phase) 539 switch (phase)
438 { 540 {
439 case TP_INIT: 541 case TP_INIT:
@@ -442,30 +544,31 @@ incoming_message_cb (void *cls,
442 case TP_BURST_SHORT: 544 case TP_BURST_SHORT:
443 { 545 {
444 GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); 546 GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len);
445 num_received++; 547 num_received_short++;
446 duration = GNUNET_TIME_absolute_get_duration (start_short); 548 duration = GNUNET_TIME_absolute_get_duration (start_short);
447 update_avg_latency (payload); 549 update_avg_latency (payload);
448 if (num_received == BURST_PACKETS * DROP_RATIO) 550 if (num_received_short == BURST_PACKETS * 0.91)
449 { 551 {
450 LOG (GNUNET_ERROR_TYPE_MESSAGE, 552 LOG (GNUNET_ERROR_TYPE_MESSAGE,
451 "Short size packet test done.\n"); 553 "Short size packet test done.\n");
452 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE 554 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
453 * num_received * 1000 555 * num_received_short
556 * 1000
454 * 1000) 557 * 1000)
455 / duration.rel_value_us); 558 / duration.rel_value_us);
456 LOG (GNUNET_ERROR_TYPE_MESSAGE, 559 LOG (GNUNET_ERROR_TYPE_MESSAGE,
457 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 560 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
458 (unsigned long) num_received, 561 (unsigned long) num_received_short,
459 (unsigned long) num_sent, 562 (unsigned long) num_sent_short,
460 (unsigned long long) duration.rel_value_us, 563 (unsigned long long) duration.rel_value_us,
461 goodput, 564 goodput,
462 (unsigned long long) avg_latency); 565 (unsigned long long) avg_latency);
463 GNUNET_free (goodput); 566 GNUNET_free (goodput);
464 start_long = GNUNET_TIME_absolute_get (); 567 start_long = GNUNET_TIME_absolute_get ();
465 phase = TP_BURST_LONG; 568 phase = TP_BURST_LONG;
466 num_sent = 0; 569 // num_sent_short = 0;
467 avg_latency = 0; 570 avg_latency = 0;
468 num_received = 0; 571 // num_received = 0;
469 long_test (NULL); 572 long_test (NULL);
470 } 573 }
471 break; 574 break;
@@ -476,32 +579,34 @@ incoming_message_cb (void *cls,
476 { 579 {
477 LOG (GNUNET_ERROR_TYPE_WARNING, 580 LOG (GNUNET_ERROR_TYPE_WARNING,
478 "Ignoring packet with wrong length\n"); 581 "Ignoring packet with wrong length\n");
479 return; // Ignore 582 return; // Ignore
480 } 583 }
481 num_received++; 584 num_received_long++;
482 duration = GNUNET_TIME_absolute_get_duration (start_long); 585 duration = GNUNET_TIME_absolute_get_duration (start_long);
483 update_avg_latency (payload); 586 update_avg_latency (payload);
484 if (num_received == BURST_PACKETS * DROP_RATIO) 587 if (num_received_long == BURST_PACKETS * 0.91)
485 { 588 {
486 LOG (GNUNET_ERROR_TYPE_MESSAGE, 589 LOG (GNUNET_ERROR_TYPE_MESSAGE,
487 "Long size packet test done.\n"); 590 "Long size packet test done.\n");
488 char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size 591 char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size
489 * num_received * 1000 592 * num_received_long
593 * 1000
490 * 1000) 594 * 1000)
491 / duration.rel_value_us); 595 / duration.
596 rel_value_us);
492 597
493 LOG (GNUNET_ERROR_TYPE_MESSAGE, 598 LOG (GNUNET_ERROR_TYPE_MESSAGE,
494 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 599 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
495 (unsigned long) num_received, 600 (unsigned long) num_received_long,
496 (unsigned long) num_sent, 601 (unsigned long) num_sent_long,
497 (unsigned long long) duration.rel_value_us, 602 (unsigned long long) duration.rel_value_us,
498 goodput, 603 goodput,
499 (unsigned long long) avg_latency); 604 (unsigned long long) avg_latency);
500 GNUNET_free (goodput); 605 GNUNET_free (goodput);
501 ack = 0; 606 ack = 0;
502 phase = TP_SIZE_CHECK; 607 phase = TP_SIZE_CHECK;
503 num_received = 0; 608 // num_received = 0;
504 num_sent = 0; 609 // num_sent_long = 0;
505 avg_latency = 0; 610 avg_latency = 0;
506 size_test (NULL); 611 size_test (NULL);
507 } 612 }
@@ -514,25 +619,29 @@ incoming_message_cb (void *cls,
514 GNUNET_assert (TP_SIZE_CHECK == phase); 619 GNUNET_assert (TP_SIZE_CHECK == phase);
515 if (LONG_MESSAGE_SIZE != long_message_size) 620 if (LONG_MESSAGE_SIZE != long_message_size)
516 max_size = long_message_size; 621 max_size = long_message_size;
517 num_received++; 622 num_received_size++;
518 update_avg_latency (payload); 623 update_avg_latency (payload);
519 if (num_received >= (max_size) / 10) 624 if (num_received_size >= (max_size) / 10)
520 { 625 {
521 LOG (GNUNET_ERROR_TYPE_MESSAGE, 626 LOG (GNUNET_ERROR_TYPE_MESSAGE,
522 "Size packet test done.\n"); 627 "Size packet test done.\n");
523 LOG (GNUNET_ERROR_TYPE_MESSAGE, 628 LOG (GNUNET_ERROR_TYPE_MESSAGE,
524 "%lu/%lu packets -- avg latency: %llu us\n", 629 "%lu/%lu packets -- avg latency: %llu us\n",
525 (unsigned long) num_received, 630 (unsigned long) num_received_size,
526 (unsigned long) num_sent, 631 (unsigned long) num_sent_size,
527 (unsigned long long) avg_latency); 632 (unsigned long long) avg_latency);
528 num_received = 0; 633 num_received_size = 0;
529 num_sent = 0; 634 num_sent_size = 0;
530 avg_latency = 0; 635 avg_latency = 0;
531 iterations_left--; 636 iterations_left--;
532 if (0 != iterations_left) 637 if (0 != iterations_left)
533 { 638 {
534 start_short = GNUNET_TIME_absolute_get (); 639 start_short = GNUNET_TIME_absolute_get ();
535 phase = TP_BURST_SHORT; 640 phase = TP_BURST_SHORT;
641 num_sent_short = 0;
642 num_sent_long = 0;
643 num_received_short = 0;
644 num_received_long = 0;
536 short_test (NULL); 645 short_test (NULL);
537 break; 646 break;
538 } 647 }
@@ -570,8 +679,8 @@ static void
570run (void *cls) 679run (void *cls)
571{ 680{
572 ret = 0; 681 ret = 0;
573 num_received = 0; 682 // num_received = 0;
574 num_sent = 0; 683 // num_sent = 0;
575 for (unsigned int i = 0; i < NUM_PEERS; i++) 684 for (unsigned int i = 0; i < NUM_PEERS; i++)
576 { 685 {
577 tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( 686 tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index baafff249..1e2579048 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -557,6 +557,7 @@ handle_update_queue_message (void *cls,
557 // tc_queue->q_len += GNUNET_ntohll (msg->q_len); 557 // tc_queue->q_len += GNUNET_ntohll (msg->q_len);
558 // Uncomment this for alternativ 2 of backchannel functionality 558 // Uncomment this for alternativ 2 of backchannel functionality
559 tc_queue->q_len = GNUNET_ntohll (msg->q_len); 559 tc_queue->q_len = GNUNET_ntohll (msg->q_len);
560 // Until here for alternativ 2
560 GNUNET_SERVICE_client_continue (client->client); 561 GNUNET_SERVICE_client_continue (client->client);
561} 562}
562 563