aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-01-05 17:39:22 +0100
committert3sserakt <t3ss@posteo.de>2021-01-05 17:39:22 +0100
commit8b8b1d58d73f70560e5f677c4e11d6d495f2d96d (patch)
tree5d7d5e0d4e4267fecbb13fd12559359bfc10dc17
parentfac97cea47df432d6418e0399e799e47057e89d7 (diff)
downloadgnunet-8b8b1d58d73f70560e5f677c4e11d6d495f2d96d.tar.gz
gnunet-8b8b1d58d73f70560e5f677c4e11d6d495f2d96d.zip
- added configuration to the tng communicator test code
-rw-r--r--src/transport/test_communicator_basic.c216
1 files changed, 168 insertions, 48 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 1f85a9895..55df9a022 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -73,6 +73,9 @@ static struct GNUNET_TIME_Absolute timeout;
73 73
74static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc; 74static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
75 75
76static struct
77GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tcs[NUM_PEERS];
78
76static char *communicator_name; 79static char *communicator_name;
77 80
78static char *test_name; 81static char *test_name;
@@ -81,10 +84,14 @@ static struct GNUNET_STATISTICS_GetHandle *box_stats;
81 84
82static struct GNUNET_STATISTICS_GetHandle *rekey_stats; 85static struct GNUNET_STATISTICS_GetHandle *rekey_stats;
83 86
87#define TEST_SECTION "test-setup"
88
84#define SHORT_MESSAGE_SIZE 128 89#define SHORT_MESSAGE_SIZE 128
85 90
86#define LONG_MESSAGE_SIZE 32000 /* FIXME */ 91#define LONG_MESSAGE_SIZE 32000 /* FIXME */
87 92
93#define ALLOWED_PACKET_LOSS 91
94
88#define BURST_PACKETS 5000 95#define BURST_PACKETS 5000
89 96
90#define TOTAL_ITERATIONS 1 97#define TOTAL_ITERATIONS 1
@@ -114,6 +121,27 @@ enum TestPhase
114 TP_SIZE_CHECK 121 TP_SIZE_CHECK
115}; 122};
116 123
124static unsigned int phase_short;
125
126static unsigned int phase_long;
127
128static unsigned int phase_size;
129
130static long long unsigned int allowed_packet_loss_short;
131
132static long long unsigned int allowed_packet_loss_long;
133
134static long long unsigned int burst_packets_short;
135
136static long long unsigned int burst_packets_long;
137
138static long long unsigned int delay_long_value;
139
140static long long unsigned int delay_short_value;
141
142static struct GNUNET_TIME_Relative delay_short;
143
144static struct GNUNET_TIME_Relative delay_long;
117 145
118static size_t num_sent_short = 0; 146static size_t num_sent_short = 0;
119 147
@@ -300,10 +328,6 @@ latency_timeout (void *cls)
300 GNUNET_SCHEDULER_shutdown (); 328 GNUNET_SCHEDULER_shutdown ();
301} 329}
302 330
303
304/*static void
305 size_test (void *cls);*/
306
307static void 331static void
308size_test (void *cls) 332size_test (void *cls)
309{ 333{
@@ -350,7 +374,7 @@ long_test_cb (void *cls)
350 payload = make_payload (long_message_size); 374 payload = make_payload (long_message_size);
351 num_sent_long++; 375 num_sent_long++;
352 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 376 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
353 (BURST_PACKETS == 377 (burst_packets_long ==
354 num_sent_long) 378 num_sent_long)
355 ? NULL 379 ? NULL
356 : &long_test, 380 : &long_test,
@@ -368,10 +392,7 @@ long_test_cb (void *cls)
368static void 392static void
369long_test (void *cls) 393long_test (void *cls)
370{ 394{
371 /*LOG (GNUNET_ERROR_TYPE_DEBUG, 395 GNUNET_SCHEDULER_add_delayed (delay_long,
372 "long_test %u\n",
373 num_sent_long);*/
374 GNUNET_SCHEDULER_add_delayed (DELAY,
375 &long_test_cb, 396 &long_test_cb,
376 NULL); 397 NULL);
377} 398}
@@ -393,7 +414,7 @@ short_test_cb (void *cls)
393 payload = make_payload (SHORT_MESSAGE_SIZE); 414 payload = make_payload (SHORT_MESSAGE_SIZE);
394 num_sent_short++; 415 num_sent_short++;
395 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 416 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
396 (BURST_PACKETS == 417 (burst_packets_short ==
397 num_sent_short) 418 num_sent_short)
398 ? NULL 419 ? NULL
399 : &short_test, 420 : &short_test,
@@ -410,40 +431,61 @@ short_test_cb (void *cls)
410static void 431static void
411short_test (void *cls) 432short_test (void *cls)
412{ 433{
413 GNUNET_SCHEDULER_add_delayed (DELAY, 434 GNUNET_SCHEDULER_add_delayed (delay_short,
414 &short_test_cb, 435 &short_test_cb,
415 NULL); 436 NULL);
416} 437}
417 438
418 439
419static int test_prepared = GNUNET_NO; 440/* static int test_prepared = GNUNET_NO; */
441
442/* This helps establishing the backchannel */
443/* static void */
444/* prepare_test (void *cls) */
445/* { */
446/* char *payload; */
447
448/* if (GNUNET_YES == test_prepared) */
449/* { */
450/* GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, */
451/* &short_test, */
452/* NULL); */
453/* return; */
454/* } */
455/* test_prepared = GNUNET_YES; */
456/* payload = make_payload (SHORT_MESSAGE_SIZE); */
457/* GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, */
458/* &prepare_test, */
459/* NULL, */
460/* payload, */
461/* SHORT_MESSAGE_SIZE); */
462/* GNUNET_free (payload); */
463/* } */
420 464
421/**
422 * This helps establishing the backchannel
423 */
424static void 465static void
425prepare_test (void *cls) 466choose_phase ()
426{ 467{
427 char *payload; 468 if (phase_short)
428
429 if (GNUNET_YES == test_prepared)
430 { 469 {
431 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 470 phase = TP_BURST_SHORT;
432 &short_test, 471 start_short = GNUNET_TIME_absolute_get ();
433 NULL); 472 short_test (NULL);
434 return;
435 } 473 }
436 test_prepared = GNUNET_YES; 474 else if (phase_long)
437 payload = make_payload (SHORT_MESSAGE_SIZE); 475 {
438 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 476 phase = TP_BURST_LONG;
439 &prepare_test, 477 start_long = GNUNET_TIME_absolute_get ();
440 NULL, 478 long_test (NULL);
441 payload, 479 }
442 SHORT_MESSAGE_SIZE); 480 else if (phase_size)
443 GNUNET_free (payload); 481 {
482 phase = TP_SIZE_CHECK;
483 size_test (NULL);
484 }
485 else
486 GNUNET_assert (0);
444} 487}
445 488
446
447/** 489/**
448 * @brief Handle opening of queue 490 * @brief Handle opening of queue
449 * 491 *
@@ -468,14 +510,14 @@ add_queue_cb (void *cls,
468 return; // TODO? 510 return; // TODO?
469 LOG (GNUNET_ERROR_TYPE_DEBUG, 511 LOG (GNUNET_ERROR_TYPE_DEBUG,
470 "Queue established, starting test...\n"); 512 "Queue established, starting test...\n");
471 start_short = GNUNET_TIME_absolute_get (); 513 // start_short = GNUNET_TIME_absolute_get ();
472 my_tc = tc_h; 514 my_tc = tc_h;
473 if (0 != mtu) /* Message header overhead */ 515 if (0 != mtu) /* Message header overhead */
474 long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) 516 long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo)
475 - sizeof(struct GNUNET_MessageHeader); 517 - sizeof(struct GNUNET_MessageHeader);
476 else 518 else
477 long_message_size = LONG_MESSAGE_SIZE; 519 long_message_size = LONG_MESSAGE_SIZE;
478 phase = TP_BURST_SHORT; 520 // phase = TP_BURST_SHORT;
479 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( 521 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
480 GNUNET_TIME_UNIT_SECONDS, 522 GNUNET_TIME_UNIT_SECONDS,
481 TIMEOUT_MULTIPLIER)); 523 TIMEOUT_MULTIPLIER));
@@ -486,7 +528,8 @@ add_queue_cb (void *cls,
486 &latency_timeout, 528 &latency_timeout,
487 NULL); 529 NULL);
488 // prepare_test (NULL); 530 // prepare_test (NULL);
489 short_test (NULL); 531 // short_test (NULL);
532 choose_phase ();
490} 533}
491 534
492 535
@@ -602,6 +645,30 @@ process_statistics (void *cls,
602 return GNUNET_OK; 645 return GNUNET_OK;
603} 646}
604 647
648static void
649load_phase_config ()
650{
651
652 phase_short = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
653 TEST_SECTION,
654 "PHASE_SHORT");
655 if (GNUNET_SYSERR == phase_short)
656 phase_short = GNUNET_YES;
657
658 phase_long = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
659 TEST_SECTION,
660 "PHASE_LONG");
661
662 if (GNUNET_SYSERR == phase_long)
663 phase_long = GNUNET_YES;
664
665 phase_size = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
666 TEST_SECTION,
667 "PHASE_SIZE");
668
669 if (GNUNET_SYSERR == phase_size)
670 phase_size = GNUNET_YES;
671}
605 672
606/** 673/**
607 * @brief Handle an incoming message 674 * @brief Handle an incoming message
@@ -641,8 +708,10 @@ incoming_message_cb (
641 num_received_short++; 708 num_received_short++;
642 duration = GNUNET_TIME_absolute_get_duration (start_short); 709 duration = GNUNET_TIME_absolute_get_duration (start_short);
643 update_avg_latency (payload); 710 update_avg_latency (payload);
644 if ((num_sent_short == BURST_PACKETS) && (num_received_short > 711 if ((num_sent_short == burst_packets_short) && (num_received_short >
645 BURST_PACKETS * 0.91) ) 712 burst_packets_short / 100
713 *
714 allowed_packet_loss_short) )
646 { 715 {
647 LOG (GNUNET_ERROR_TYPE_MESSAGE, 716 LOG (GNUNET_ERROR_TYPE_MESSAGE,
648 "Short size packet test done.\n"); 717 "Short size packet test done.\n");
@@ -657,12 +726,14 @@ incoming_message_cb (
657 goodput, 726 goodput,
658 (unsigned long long) avg_latency); 727 (unsigned long long) avg_latency);
659 GNUNET_free (goodput); 728 GNUNET_free (goodput);
660 start_long = GNUNET_TIME_absolute_get (); 729 // start_long = GNUNET_TIME_absolute_get ();
661 phase = TP_BURST_LONG; 730 // phase = TP_BURST_LONG;
662 // num_sent_short = 0; 731 // num_sent_short = 0;
663 avg_latency = 0; 732 avg_latency = 0;
664 // num_received = 0; 733 // num_received = 0;
665 long_test (NULL); 734 phase_short = GNUNET_NO;
735 choose_phase ();
736 // long_test (NULL);
666 } 737 }
667 break; 738 break;
668 } 739 }
@@ -677,8 +748,10 @@ incoming_message_cb (
677 num_received_long++; 748 num_received_long++;
678 duration = GNUNET_TIME_absolute_get_duration (start_long); 749 duration = GNUNET_TIME_absolute_get_duration (start_long);
679 update_avg_latency (payload); 750 update_avg_latency (payload);
680 if ((num_sent_long == BURST_PACKETS) && (num_received_long > BURST_PACKETS 751 if ((num_sent_long == burst_packets_long) && (num_received_long >
681 * 0.91) ) 752 burst_packets_long
753 / 100
754 * allowed_packet_loss_short) )
682 { 755 {
683 LOG (GNUNET_ERROR_TYPE_MESSAGE, 756 LOG (GNUNET_ERROR_TYPE_MESSAGE,
684 "Long size packet test done.\n"); 757 "Long size packet test done.\n");
@@ -696,11 +769,13 @@ incoming_message_cb (
696 (unsigned long long) avg_latency); 769 (unsigned long long) avg_latency);
697 GNUNET_free (goodput); 770 GNUNET_free (goodput);
698 ack = 0; 771 ack = 0;
699 phase = TP_SIZE_CHECK; 772 // phase = TP_SIZE_CHECK;
700 // num_received = 0; 773 // num_received = 0;
701 // num_sent_long = 0; 774 // num_sent_long = 0;
702 avg_latency = 0; 775 avg_latency = 0;
703 size_test (NULL); 776 // size_test (NULL);
777 phase_long = GNUNET_NO;
778 choose_phase ();
704 } 779 }
705 break; 780 break;
706 } 781 }
@@ -728,13 +803,15 @@ incoming_message_cb (
728 iterations_left--; 803 iterations_left--;
729 if (0 != iterations_left) 804 if (0 != iterations_left)
730 { 805 {
731 start_short = GNUNET_TIME_absolute_get (); 806 // start_short = GNUNET_TIME_absolute_get ();
732 phase = TP_BURST_SHORT; 807 // phase = TP_BURST_SHORT;
733 num_sent_short = 0; 808 num_sent_short = 0;
734 num_sent_long = 0; 809 num_sent_long = 0;
735 num_received_short = 0; 810 num_received_short = 0;
736 num_received_long = 0; 811 num_received_long = 0;
737 short_test (NULL); 812 // short_test (NULL);
813 load_phase_config ();
814 choose_phase ();
738 break; 815 break;
739 } 816 }
740 if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey", 817 if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
@@ -802,6 +879,7 @@ do_shutdown (void *cls)
802} 879}
803 880
804 881
882
805/** 883/**
806 * @brief Main function called by the scheduler 884 * @brief Main function called by the scheduler
807 * 885 *
@@ -846,7 +924,6 @@ run (void *cls)
846 NULL); 924 NULL);
847} 925}
848 926
849
850int 927int
851main (int argc, 928main (int argc,
852 char *const *argv) 929 char *const *argv)
@@ -924,6 +1001,49 @@ main (int argc,
924 i, 1001 i,
925 GNUNET_i2s_full (&peer_id[i])); 1002 GNUNET_i2s_full (&peer_id[i]));
926 } 1003 }
1004 if (GNUNET_OK !=
1005 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1006 TEST_SECTION,
1007 "ALLOWED_PACKET_LOSS_SHORT",
1008 &allowed_packet_loss_short))
1009 allowed_packet_loss_short = ALLOWED_PACKET_LOSS;
1010 if (GNUNET_OK !=
1011 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1012 TEST_SECTION,
1013 "ALLOWED_PACKET_LOSS_LONG",
1014 &allowed_packet_loss_long))
1015 allowed_packet_loss_long = ALLOWED_PACKET_LOSS;
1016 if (GNUNET_OK !=
1017 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1018 TEST_SECTION,
1019 "BURST_PACKETS_SHORT",
1020 &burst_packets_short))
1021 burst_packets_short = BURST_PACKETS;
1022 if (GNUNET_OK !=
1023 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1024 TEST_SECTION,
1025 "BURST_ÜACKETS_LONG",
1026 &burst_packets_long))
1027 burst_packets_long = BURST_PACKETS;
1028 if (GNUNET_OK !=
1029 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1030 TEST_SECTION,
1031 "DELAY_SHORT",
1032 &delay_short_value))
1033 delay_short = DELAY;
1034 else
1035 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,
1036 delay_short_value);
1037 if (GNUNET_OK !=
1038 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1039 TEST_SECTION,
1040 "DELAY_SHORT",
1041 &delay_long_value))
1042 delay_long = DELAY;
1043 else
1044 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,
1045 delay_long_value);
1046 load_phase_config ();
927 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n"); 1047 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n");
928 LOG (GNUNET_ERROR_TYPE_DEBUG, 1048 LOG (GNUNET_ERROR_TYPE_DEBUG,
929 "argv[0]: %s\n", 1049 "argv[0]: %s\n",