diff options
Diffstat (limited to 'src/transport/test_communicator_basic.c')
-rw-r--r-- | src/transport/test_communicator_basic.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index f43cdaaf3..14d1a4792 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -104,13 +104,13 @@ static unsigned int iterations_left[NUM_PEERS]; | |||
104 | #define TIMEOUT_MULTIPLIER 1 | 104 | #define TIMEOUT_MULTIPLIER 1 |
105 | 105 | ||
106 | #define DELAY \ | 106 | #define DELAY \ |
107 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,200) | 107 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,200) |
108 | 108 | ||
109 | #define SHORT_BURST_WINDOW \ | 109 | #define SHORT_BURST_WINDOW \ |
110 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) | 110 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) |
111 | 111 | ||
112 | #define LONG_BURST_WINDOW \ | 112 | #define LONG_BURST_WINDOW \ |
113 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) | 113 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) |
114 | 114 | ||
115 | enum TestPhase | 115 | enum TestPhase |
116 | { | 116 | { |
@@ -283,6 +283,7 @@ make_payload (size_t payload_size) | |||
283 | return payload; | 283 | return payload; |
284 | } | 284 | } |
285 | 285 | ||
286 | |||
286 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 287 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * |
287 | get_tc_h (unsigned int peer_nr) | 288 | get_tc_h (unsigned int peer_nr) |
288 | { | 289 | { |
@@ -316,6 +317,7 @@ get_peer_nr_from_tc (struct | |||
316 | return PEER_B; | 317 | return PEER_B; |
317 | } | 318 | } |
318 | 319 | ||
320 | |||
319 | static unsigned int | 321 | static unsigned int |
320 | get_peer_nr (void *cls, unsigned int get_the_other_one) | 322 | get_peer_nr (void *cls, unsigned int get_the_other_one) |
321 | { | 323 | { |
@@ -325,6 +327,7 @@ get_peer_nr (void *cls, unsigned int get_the_other_one) | |||
325 | return get_the_other_one ? PEER_A : PEER_B; | 327 | return get_the_other_one ? PEER_A : PEER_B; |
326 | } | 328 | } |
327 | 329 | ||
330 | |||
328 | static void | 331 | static void |
329 | process_statistics_box_done (void *cls, int success) | 332 | process_statistics_box_done (void *cls, int success) |
330 | { | 333 | { |
@@ -362,6 +365,7 @@ process_statistics_rekey_done (void *cls, int success) | |||
362 | } | 365 | } |
363 | } | 366 | } |
364 | 367 | ||
368 | |||
365 | static int | 369 | static int |
366 | process_statistics (void *cls, | 370 | process_statistics (void *cls, |
367 | const char *subsystem, | 371 | const char *subsystem, |
@@ -407,6 +411,7 @@ process_statistics (void *cls, | |||
407 | return GNUNET_OK; | 411 | return GNUNET_OK; |
408 | } | 412 | } |
409 | 413 | ||
414 | |||
410 | static void | 415 | static void |
411 | short_test (void *cls); | 416 | short_test (void *cls); |
412 | 417 | ||
@@ -442,6 +447,7 @@ short_test_cb (void *cls) | |||
442 | TIMEOUT_MULTIPLIER)); | 447 | TIMEOUT_MULTIPLIER)); |
443 | } | 448 | } |
444 | 449 | ||
450 | |||
445 | static void | 451 | static void |
446 | short_test (void *cls) | 452 | short_test (void *cls) |
447 | { | 453 | { |
@@ -450,6 +456,7 @@ short_test (void *cls) | |||
450 | cls); | 456 | cls); |
451 | } | 457 | } |
452 | 458 | ||
459 | |||
453 | static void | 460 | static void |
454 | size_test (void *cls) | 461 | size_test (void *cls) |
455 | { | 462 | { |
@@ -485,6 +492,7 @@ size_test (void *cls) | |||
485 | TIMEOUT_MULTIPLIER)); | 492 | TIMEOUT_MULTIPLIER)); |
486 | } | 493 | } |
487 | 494 | ||
495 | |||
488 | static void | 496 | static void |
489 | long_test (void *cls); | 497 | long_test (void *cls); |
490 | 498 | ||
@@ -527,6 +535,7 @@ long_test (void *cls) | |||
527 | cls); | 535 | cls); |
528 | } | 536 | } |
529 | 537 | ||
538 | |||
530 | static void | 539 | static void |
531 | choose_phase (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | 540 | choose_phase (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) |
532 | { | 541 | { |
@@ -564,9 +573,9 @@ choose_phase (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | |||
564 | { | 573 | { |
565 | if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey", | 574 | if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey", |
566 | test_name)) | 575 | test_name)) |
567 | ||(0 == strcmp ( | 576 | || (0 == strcmp ( |
568 | "backchannel", | 577 | "backchannel", |
569 | test_name))) ) | 578 | test_name))) ) |
570 | { | 579 | { |
571 | if (NULL != box_stats[peer_nr]) | 580 | if (NULL != box_stats[peer_nr]) |
572 | GNUNET_STATISTICS_get_cancel (box_stats[peer_nr]); | 581 | GNUNET_STATISTICS_get_cancel (box_stats[peer_nr]); |
@@ -587,11 +596,11 @@ choose_phase (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | |||
587 | } | 596 | } |
588 | else | 597 | else |
589 | { | 598 | { |
590 | if ((GNUNET_NO == bidirect)|| (((PEER_A == peer_nr) && | 599 | if ((GNUNET_NO == bidirect) || (((PEER_A == peer_nr) && |
591 | finished[PEER_B]) || ((PEER_B == | 600 | finished[PEER_B]) || ((PEER_B == |
592 | peer_nr) && | 601 | peer_nr) && |
593 | finished | 602 | finished |
594 | [PEER_A]))) | 603 | [PEER_A]))) |
595 | { | 604 | { |
596 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 605 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
597 | "Finished\n"); | 606 | "Finished\n"); |
@@ -602,7 +611,9 @@ choose_phase (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | |||
602 | } | 611 | } |
603 | } | 612 | } |
604 | 613 | ||
605 | static void finish_phase_long (unsigned int peer_nr) | 614 | |
615 | static void | ||
616 | finish_phase_long (unsigned int peer_nr) | ||
606 | { | 617 | { |
607 | static struct GNUNET_TIME_Relative duration; | 618 | static struct GNUNET_TIME_Relative duration; |
608 | 619 | ||
@@ -633,6 +644,7 @@ static void finish_phase_long (unsigned int peer_nr) | |||
633 | choose_phase (get_tc_h (peer_nr)); | 644 | choose_phase (get_tc_h (peer_nr)); |
634 | } | 645 | } |
635 | 646 | ||
647 | |||
636 | static void | 648 | static void |
637 | finish_phase_short (unsigned int peer_nr) | 649 | finish_phase_short (unsigned int peer_nr) |
638 | { | 650 | { |
@@ -663,6 +675,7 @@ finish_phase_short (unsigned int peer_nr) | |||
663 | // long_test (NULL); | 675 | // long_test (NULL); |
664 | } | 676 | } |
665 | 677 | ||
678 | |||
666 | static void | 679 | static void |
667 | latency_timeout (void *cls) | 680 | latency_timeout (void *cls) |
668 | { | 681 | { |
@@ -733,6 +746,7 @@ latency_timeout (void *cls) | |||
733 | GNUNET_SCHEDULER_shutdown (); | 746 | GNUNET_SCHEDULER_shutdown (); |
734 | } | 747 | } |
735 | 748 | ||
749 | |||
736 | /** | 750 | /** |
737 | * @brief Handle opening of queue | 751 | * @brief Handle opening of queue |
738 | * | 752 | * |
@@ -760,7 +774,7 @@ add_queue_cb (void *cls, | |||
760 | tc_h, | 774 | tc_h, |
761 | peer_nr, | 775 | peer_nr, |
762 | get_peer_nr_from_tc (tc_h)); | 776 | get_peer_nr_from_tc (tc_h)); |
763 | if ((GNUNET_NO == bidirect)&&(0 != strcmp ((char*) cls, cfg_peers_name[0]))) | 777 | if ((GNUNET_NO == bidirect) && (0 != strcmp ((char*) cls, cfg_peers_name[0]))) |
764 | { | 778 | { |
765 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 779 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
766 | "Queue available at receiving peer\n"); | 780 | "Queue available at receiving peer\n"); |
@@ -832,8 +846,6 @@ update_avg_latency (const char *payload, unsigned int peer_nr) | |||
832 | } | 846 | } |
833 | 847 | ||
834 | 848 | ||
835 | |||
836 | |||
837 | static void | 849 | static void |
838 | load_phase_config () | 850 | load_phase_config () |
839 | { | 851 | { |
@@ -866,7 +878,6 @@ load_phase_config () | |||
866 | } | 878 | } |
867 | 879 | ||
868 | 880 | ||
869 | |||
870 | /** | 881 | /** |
871 | * @brief Handle an incoming message | 882 | * @brief Handle an incoming message |
872 | * | 883 | * |
@@ -888,8 +899,8 @@ incoming_message_cb ( | |||
888 | 899 | ||
889 | peer_nr = get_peer_nr (cls, GNUNET_YES); | 900 | peer_nr = get_peer_nr (cls, GNUNET_YES); |
890 | 901 | ||
891 | if ((GNUNET_NO == bidirect)&&(0 != strcmp ((char*) cls, | 902 | if ((GNUNET_NO == bidirect) && (0 != strcmp ((char*) cls, |
892 | cfg_peers_name[NUM_PEERS - 1]))) | 903 | cfg_peers_name[NUM_PEERS - 1]))) |
893 | { | 904 | { |
894 | LOG (GNUNET_ERROR_TYPE_WARNING, | 905 | LOG (GNUNET_ERROR_TYPE_WARNING, |
895 | "unexpected receiver...\n"); | 906 | "unexpected receiver...\n"); |
@@ -1016,7 +1027,6 @@ do_shutdown (void *cls) | |||
1016 | } | 1027 | } |
1017 | 1028 | ||
1018 | 1029 | ||
1019 | |||
1020 | /** | 1030 | /** |
1021 | * @brief Main function called by the scheduler | 1031 | * @brief Main function called by the scheduler |
1022 | * | 1032 | * |
@@ -1044,7 +1054,8 @@ run (void *cls) | |||
1044 | cfg_peers_name[i]); /* cls */ | 1054 | cfg_peers_name[i]); /* cls */ |
1045 | 1055 | ||
1046 | if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey", | 1056 | if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey", |
1047 | test_name))|| | 1057 | test_name)) |
1058 | || | ||
1048 | (0 == strcmp ( | 1059 | (0 == strcmp ( |
1049 | "backchannel", | 1060 | "backchannel", |
1050 | test_name))) ) | 1061 | test_name))) ) |
@@ -1061,6 +1072,7 @@ run (void *cls) | |||
1061 | NULL); | 1072 | NULL); |
1062 | } | 1073 | } |
1063 | 1074 | ||
1075 | |||
1064 | int | 1076 | int |
1065 | main (int argc, | 1077 | main (int argc, |
1066 | char *const *argv) | 1078 | char *const *argv) |
@@ -1162,7 +1174,7 @@ main (int argc, | |||
1162 | if (GNUNET_OK != | 1174 | if (GNUNET_OK != |
1163 | GNUNET_CONFIGURATION_get_value_number (cfg_peers[0], | 1175 | GNUNET_CONFIGURATION_get_value_number (cfg_peers[0], |
1164 | TEST_SECTION, | 1176 | TEST_SECTION, |
1165 | "BURST_ÜACKETS_LONG", | 1177 | "BURST_PACKETS_LONG", |
1166 | &burst_packets_long)) | 1178 | &burst_packets_long)) |
1167 | burst_packets_long = BURST_PACKETS; | 1179 | burst_packets_long = BURST_PACKETS; |
1168 | if (GNUNET_OK != | 1180 | if (GNUNET_OK != |