2 This file is part of GNUnet.
3 Copyright (C) 2011, 2017 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file cadet/test_cadet.c
23 * @author Christian Grothoff
24 * @brief Test for the cadet service using mq API.
28 #include "cadet_test_lib.h"
29 #include "gnunet_cadet_service.h"
30 #include "gnunet_statistics_service.h"
35 * Ugly workaround to unify data handlers on incoming and outgoing channels.
37 struct CadetTestChannelWrapper
42 struct GNUNET_CADET_Channel *ch;
46 * How many messages to send by default.
48 #define TOTAL_PACKETS 500 /* Cannot exceed 64k! */
51 * How long until we give up on connecting the peers?
53 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
56 * Time to wait by default for stuff that should be rather fast.
58 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
61 * DIFFERENT TESTS TO RUN
72 * Which test are we running?
77 * String with test name
79 static char *test_name;
82 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
84 static int test_backwards = GNUNET_NO;
87 * How many packets to send.
89 static unsigned int total_packets;
92 * Time to wait for fast operations.
94 static struct GNUNET_TIME_Relative short_time;
97 * How many events have happened
102 * Number of events expected to conclude the test successfully.
107 * Size of each test packet's payload
109 static size_t size_payload = sizeof (uint32_t);
112 * Operation to get peer ids.
114 static struct GNUNET_TESTBED_Operation *t_op[2];
119 static struct GNUNET_PeerIdentity *p_id[2];
124 static struct GNUNET_HashCode port;
129 static unsigned int p_ids;
132 * Is the setup initialized?
134 static int initialized;
137 * Number of payload packes sent.
139 static int data_sent;
142 * Number of payload packets received.
144 static int data_received;
147 * Number of payload packed acknowledgements sent.
152 * Number of payload packed explicitly (app level) acknowledged.
154 static int ack_received;
157 * Total number of peers asked to run.
159 static unsigned long long peers_requested;
162 * Number of currently running peers (should be same as @c peers_requested).
164 static unsigned long long peers_running;
167 * Test context (to shut down).
169 struct GNUNET_CADET_TEST_Context *test_ctx;
172 * Task called to disconnect peers.
174 static struct GNUNET_SCHEDULER_Task *disconnect_task;
177 * Task To perform tests
179 static struct GNUNET_SCHEDULER_Task *test_task;
182 * Task runnining #send_next_msg().
184 static struct GNUNET_SCHEDULER_Task *send_next_msg_task;
187 * Cadet handle for the root peer
189 static struct GNUNET_CADET_Handle *h1;
192 * Cadet handle for the first leaf peer
194 static struct GNUNET_CADET_Handle *h2;
197 * Channel handle for the root peer
199 static struct GNUNET_CADET_Channel *outgoing_ch;
202 * Channel handle for the dest peer
204 static struct GNUNET_CADET_Channel *incoming_ch;
207 * Time we started the data transmission (after channel has been established
210 static struct GNUNET_TIME_Absolute start_time;
215 static struct GNUNET_TESTBED_Peer **testbed_peers;
218 * Statistics operation handle.
220 static struct GNUNET_TESTBED_Operation *stats_op;
225 static unsigned int ka_sent;
228 * Keepalives received.
230 static unsigned int ka_received;
233 * How many messages were dropped by CADET because of full buffers?
235 static unsigned int msg_dropped;
238 /******************************************************************************/
241 /******************************************************************************/
245 * Get the channel considered as the "target" or "receiver", depending on
246 * the test type and size.
248 * @return Channel handle of the target client, either 0 (for backward tests)
249 * or the last peer in the line (for other tests).
251 static struct GNUNET_CADET_Channel *
252 get_target_channel ()
254 if (SPEED == test && GNUNET_YES == test_backwards)
262 * Show the results of the test (banwidth acheived) and log them to GAUGER
267 static struct GNUNET_TIME_Absolute end_time;
268 static struct GNUNET_TIME_Relative total_time;
270 end_time = GNUNET_TIME_absolute_get ();
271 total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time);
272 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
273 FPRINTF (stderr, "Test time %s\n",
274 GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES));
275 FPRINTF (stderr, "Test bandwidth: %f kb/s\n", 4 * total_packets * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
276 FPRINTF (stderr, "Test throughput: %f packets/s\n\n", total_packets * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
277 GAUGER ("CADET", test_name,
278 total_packets * 1000.0 / (total_time.rel_value_us / 1000),
284 * Disconnect from cadet services af all peers, call shutdown.
286 * @param cls Closure (line number from which termination was requested).
287 * @param tc Task Context.
290 disconnect_cadet_peers (void *cls)
292 long line = (long) cls;
295 disconnect_task = NULL;
296 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
297 "disconnecting cadet service of peers, called from line %ld\n",
299 for (i = 0; i < 2; i++)
301 GNUNET_TESTBED_operation_done (t_op[i]);
303 if (NULL != outgoing_ch)
305 GNUNET_CADET_channel_destroy (outgoing_ch);
308 if (NULL != incoming_ch)
310 GNUNET_CADET_channel_destroy (incoming_ch);
313 GNUNET_CADET_TEST_cleanup (test_ctx);
314 GNUNET_SCHEDULER_shutdown ();
319 * Shut down peergroup, clean up.
321 * @param cls Closure (unused).
322 * @param tc Task Context.
325 shutdown_task (void *cls)
327 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
328 if (NULL != send_next_msg_task)
330 GNUNET_SCHEDULER_cancel (send_next_msg_task);
331 send_next_msg_task = NULL;
333 if (NULL != test_task)
335 GNUNET_SCHEDULER_cancel (test_task);
338 if (NULL != disconnect_task)
340 GNUNET_SCHEDULER_cancel (disconnect_task);
342 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, (void *) __LINE__);
348 * Stats callback. Finish the stats testbed operation and when all stats have
349 * been iterated, shutdown the test.
351 * @param cls Closure (line number from which termination was requested).
352 * @param op the operation that has been finished
353 * @param emsg error message in case the operation has failed; will be NULL if
354 * operation has executed successfully.
357 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
359 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n",
360 ka_sent, ka_received);
361 if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1)))
366 GNUNET_TESTBED_operation_done (stats_op);
368 if (NULL != disconnect_task)
369 GNUNET_SCHEDULER_cancel (disconnect_task);
370 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, cls);
375 * Process statistic values.
377 * @param cls closure (line number, unused)
378 * @param peer the peer the statistic belong to
379 * @param subsystem name of subsystem that created the statistic
380 * @param name the name of the datum
381 * @param value the current value
382 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
383 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
386 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
387 const char *subsystem, const char *name, uint64_t value,
390 static const char *s_sent = "# keepalives sent";
391 static const char *s_recv = "# keepalives received";
392 static const char *rdrops = "# messages dropped due to full buffer";
393 static const char *cdrops = "# messages dropped due to slow client";
396 i = GNUNET_TESTBED_get_index (peer);
397 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n", i,
398 subsystem, name, (unsigned long long) value);
399 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
401 if (0 == strncmp (s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
403 if (0 == strncmp (rdrops, name, strlen (rdrops)))
404 msg_dropped += value;
405 if (0 == strncmp (cdrops, name, strlen (cdrops)))
406 msg_dropped += value;
413 * Task to gather all statistics.
415 * @param cls Closure (line from which the task was scheduled).
418 gather_stats_and_exit (void *cls)
422 disconnect_task = NULL;
423 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
424 "gathering statistics from line %ld\n",
426 if (NULL != outgoing_ch)
428 GNUNET_CADET_channel_destroy (outgoing_ch);
431 stats_op = GNUNET_TESTBED_get_statistics (peers_running,
443 * Abort test: schedule disconnect and shutdown immediately
445 * @param line Line in the code the abort is requested from (__LINE__).
448 abort_test (long line)
450 if (NULL != disconnect_task)
452 GNUNET_SCHEDULER_cancel (disconnect_task);
453 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting test from %ld\n", line);
455 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, (void *) line);
461 * Send a message on the channel with the appropriate size and payload.
463 * Update the appropriate *_sent counter.
465 * @param channel Channel to send the message on.
468 send_test_message (struct GNUNET_CADET_Channel *channel)
470 struct GNUNET_MQ_Envelope *env;
471 struct GNUNET_MessageHeader *msg;
476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
477 "Sending test message on channel %p\n",
480 if (GNUNET_NO == initialized)
482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending INITIALIZER\n");
485 if (SPEED_ACK == test) // FIXME unify SPEED_ACK with an initializer
488 else if (SPEED == test || SPEED_ACK == test)
490 if (get_target_channel() == channel)
495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
496 "Sending ACK %u [%d bytes]\n",
504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
505 "Sending DATA %u [%d bytes]\n",
509 else if (FORWARD == test)
513 else if (P2P_SIGNAL == test)
521 env = GNUNET_MQ_msg_extra (msg, size, GNUNET_MESSAGE_TYPE_DUMMY);
523 data = (uint32_t *) &msg[1];
524 *data = htonl (payload);
525 GNUNET_MQ_send (GNUNET_CADET_get_mq (channel), env);
529 * Task to request a new data transmission in a SPEED test, without waiting
530 * for previous messages to be sent/arrrive.
532 * @param cls Closure (unused).
535 send_next_msg (void *cls)
537 struct GNUNET_CADET_Channel *channel;
539 send_next_msg_task = NULL;
540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending next message: %d\n", data_sent);
542 channel = GNUNET_YES == test_backwards ? incoming_ch : outgoing_ch;
543 GNUNET_assert (NULL != channel);
544 GNUNET_assert (SPEED == test);
545 send_test_message (channel);
546 if (data_sent < total_packets)
548 /* SPEED test: Send all messages as soon as possible */
549 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
550 "Scheduling message %d\n",
553 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS,
561 * Every few messages cancel the timeout task and re-schedule it again, to
562 * avoid timing out when traffic keeps coming.
564 * @param line Code line number to log if a timeout occurs.
567 reschedule_timeout_task (long line)
571 if (NULL != disconnect_task)
573 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
574 " reschedule timeout every 10 messages\n");
575 GNUNET_SCHEDULER_cancel (disconnect_task);
576 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
577 &gather_stats_and_exit,
585 * Check if payload is sane (size contains payload).
587 * @param cls should match #ch
588 * @param message The actual message.
589 * @return #GNUNET_OK to keep the channel open,
590 * #GNUNET_SYSERR to close it (signal serious error).
593 check_data (void *cls, const struct GNUNET_MessageHeader *message)
595 if (sizeof (struct GNUNET_MessageHeader) >= ntohs (message->size))
596 return GNUNET_SYSERR;
597 return GNUNET_OK; /* all is well-formed */
602 * Function is called whenever a message is received.
604 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
605 * @param message the actual message
608 handle_data (void *cls, const struct GNUNET_MessageHeader *message)
610 struct CadetTestChannelWrapper *ch = cls;
611 struct GNUNET_CADET_Channel *channel = ch->ch;
617 GNUNET_CADET_receive_done (channel);
618 counter = get_target_channel () == channel ? &data_received : &ack_received;
620 reschedule_timeout_task ((long) __LINE__);
622 if (channel == outgoing_ch)
624 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message.\n");
626 else if (channel == incoming_ch)
628 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client got a message.\n");
632 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unknown channel %p.\n", channel);
636 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
637 data = (uint32_t *) &message[1];
638 payload = ntohl (*data);
639 if (payload == *counter)
641 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
645 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
646 " payload %u, expected: %u\n",
650 if (GNUNET_NO == initialized)
652 initialized = GNUNET_YES;
653 start_time = GNUNET_TIME_absolute_get ();
656 GNUNET_assert (incoming_ch == channel);
657 send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg, NULL);
663 if (get_target_channel () == channel) /* Got "data" */
665 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
666 if (SPEED != test || (ok_goal - 2) == ok)
669 send_test_message (channel);
674 if (data_received < total_packets)
680 if (SPEED_ACK == test || SPEED == test)
682 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
684 send_test_message (channel);
685 if (ack_received < total_packets && SPEED != test)
687 if (ok == 2 && SPEED == test)
691 if (test == P2P_SIGNAL)
693 GNUNET_CADET_channel_destroy (incoming_ch);
698 GNUNET_CADET_channel_destroy (outgoing_ch);
706 * Method called whenever a peer connects to a port in MQ-based CADET.
708 * @param cls Closure from #GNUNET_CADET_open_port (peer # as long).
709 * @param channel New handle to the channel.
710 * @param source Peer that started this channel.
711 * @return Closure for the incoming @a channel. It's given to:
712 * - The #GNUNET_CADET_DisconnectEventHandler (given to
713 * #GNUNET_CADET_open_port) when the channel dies.
714 * - Each the #GNUNET_MQ_MessageCallback handlers for each message
715 * received on the @a channel.
718 connect_handler (void *cls, struct GNUNET_CADET_Channel *channel,
719 const struct GNUNET_PeerIdentity *source)
721 struct CadetTestChannelWrapper *ch;
722 long peer = (long) cls;
724 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
725 "Incoming channel from %s to %ld: %p\n",
726 GNUNET_i2s (source), peer, channel);
728 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
729 if (peer == peers_requested - 1)
731 if (NULL != incoming_ch)
733 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
734 "Duplicate incoming channel for client %lu\n", (long) cls);
737 incoming_ch = channel;
741 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
742 "Incoming channel for unexpected peer #%lu\n", (long) cls);
745 if (NULL != disconnect_task)
747 GNUNET_SCHEDULER_cancel (disconnect_task);
748 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
749 &gather_stats_and_exit,
753 /* TODO: cannot return channel as-is, in order to unify the data handlers */
754 ch = GNUNET_new (struct CadetTestChannelWrapper);
762 * Function called whenever an MQ-channel is destroyed, even if the destruction
763 * was requested by #GNUNET_CADET_channel_destroy.
764 * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
766 * It should clean up any associated state, including cancelling any pending
767 * transmission on this channel.
769 * @param cls Channel closure (channel wrapper).
770 * @param channel Connection to the other end (henceforth invalid).
773 disconnect_handler (void *cls, const struct GNUNET_CADET_Channel *channel)
775 struct CadetTestChannelWrapper *ch_w = cls;
777 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Channel disconnected\n");
778 GNUNET_assert (ch_w->ch == channel);
779 if (channel == incoming_ch)
784 else if (outgoing_ch == channel
787 if (P2P_SIGNAL == test)
794 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unknown channel! %p\n", channel);
795 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
797 if (NULL != disconnect_task)
799 GNUNET_SCHEDULER_cancel (disconnect_task);
801 GNUNET_SCHEDULER_add_now (&gather_stats_and_exit, (void *) __LINE__);
807 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
809 * Testcase continues when the root receives confirmation of connected peers,
810 * on callback function ch.
812 * @param cls Closure (unused).
815 start_test (void *cls)
817 struct GNUNET_MQ_MessageHandler handlers[] = {
818 GNUNET_MQ_hd_var_size (data,
819 GNUNET_MESSAGE_TYPE_DUMMY,
820 struct GNUNET_MessageHeader,
822 GNUNET_MQ_handler_end ()
824 struct CadetTestChannelWrapper *ch;
825 enum GNUNET_CADET_ChannelOption flags;
828 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
829 if (NULL != disconnect_task)
831 GNUNET_SCHEDULER_cancel (disconnect_task);
832 disconnect_task = NULL;
835 flags = GNUNET_CADET_OPTION_DEFAULT;
836 if (SPEED_REL == test)
839 flags |= GNUNET_CADET_OPTION_RELIABLE;
842 ch = GNUNET_new (struct CadetTestChannelWrapper);
843 outgoing_ch = GNUNET_CADET_channel_create (h1,
852 ch->ch = outgoing_ch;
854 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
855 &gather_stats_and_exit,
857 if (KEEPALIVE == test)
858 return; /* Don't send any data. */
865 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
866 "Sending data initializer on channel %p...\n",
868 send_test_message (outgoing_ch);
873 * Callback to be called when the requested peer information is available
875 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
876 * @param op the operation this callback corresponds to
877 * @param pinfo the result; will be NULL if the operation has failed
878 * @param emsg error message if the operation has failed;
879 * NULL if the operation is successfull
882 pi_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
883 const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ID callback for %ld\n", i);
889 if ((NULL == pinfo) || (NULL != emsg))
891 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
892 abort_test (__LINE__);
895 p_id[i] = pinfo->result.id;
896 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
901 test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
906 * test main: start test when all peers are connected
908 * @param cls Closure.
909 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
910 * @param num_peers Number of peers that are running.
911 * @param peers Array of peers.
912 * @param cadets Handle to each of the CADETs of the peers.
916 struct GNUNET_CADET_TEST_Context *ctx,
917 unsigned int num_peers,
918 struct GNUNET_TESTBED_Peer **peers,
919 struct GNUNET_CADET_Handle **cadets)
921 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
924 peers_running = num_peers;
925 GNUNET_assert (peers_running == peers_requested);
926 testbed_peers = peers;
928 h2 = cadets[num_peers - 1];
929 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
930 &disconnect_cadet_peers,
932 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
933 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
934 GNUNET_TESTBED_PIT_IDENTITY,
937 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
938 GNUNET_TESTBED_PIT_IDENTITY,
941 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
949 main (int argc, char *argv[])
951 static const struct GNUNET_HashCode *ports[2];
952 struct GNUNET_MQ_MessageHandler handlers[] = {
953 GNUNET_MQ_hd_var_size (data,
954 GNUNET_MESSAGE_TYPE_DUMMY,
955 struct GNUNET_MessageHeader,
957 GNUNET_MQ_handler_end ()
959 const char *config_file;
960 char port_id[] = "test port";
961 struct GNUNET_GETOPT_CommandLineOption options[] = {
962 GNUNET_GETOPT_option_relative_time ('t',
965 gettext_noop ("set short timeout"),
968 GNUNET_GETOPT_option_uint ('m',
971 gettext_noop ("set number of messages to send"),
974 GNUNET_GETOPT_OPTION_END
978 initialized = GNUNET_NO;
979 GNUNET_log_setup ("test", "DEBUG", NULL);
981 total_packets = TOTAL_PACKETS;
982 short_time = SHORT_TIME;
983 if (-1 == GNUNET_GETOPT_run (argv[0], options, argc, argv))
985 FPRINTF (stderr, "test failed: problem with CLI parameters\n");
989 config_file = "test_cadet.conf";
990 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
992 /* Find out requested size */
993 if (strstr (argv[0], "_2_") != NULL)
995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
998 else if (strstr (argv[0], "_5_") != NULL)
1000 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1001 peers_requested = 5;
1005 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1006 peers_requested = 2;
1009 /* Find out requested test */
1010 if (strstr (argv[0], "_forward") != NULL)
1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1014 test_name = "unicast";
1017 else if (strstr (argv[0], "_signal") != NULL)
1019 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1021 test_name = "signal";
1024 else if (strstr (argv[0], "_speed_ack") != NULL)
1026 /* Test is supposed to generate the following callbacks:
1027 * 1 incoming channel (@dest)
1028 * total_packets received data packet (@dest)
1029 * total_packets received data packet (@orig)
1030 * 1 received channel destroy (@dest)
1032 ok_goal = total_packets * 2 + 2;
1033 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1035 test_name = "speed ack";
1037 else if (strstr (argv[0], "_speed") != NULL)
1039 /* Test is supposed to generate the following callbacks:
1040 * 1 incoming channel (@dest)
1041 * 1 initial packet (@dest)
1042 * total_packets received data packet (@dest)
1043 * 1 received data packet (@orig)
1044 * 1 received channel destroy (@dest)
1046 ok_goal = total_packets + 4;
1047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1048 if (strstr (argv[0], "_reliable") != NULL)
1051 test_name = "speed reliable";
1052 config_file = "test_cadet_drop.conf";
1057 test_name = "speed";
1060 else if (strstr (argv[0], "_keepalive") != NULL)
1063 /* Test is supposed to generate the following callbacks:
1064 * 1 incoming channel (@dest)
1066 * 1 received channel destroy (@dest)
1072 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1077 if (strstr (argv[0], "backwards") != NULL)
1079 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1080 test_backwards = GNUNET_YES;
1081 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1087 GNUNET_CADET_TEST_ruN ("test_cadet_small",
1091 NULL, /* tmain cls */
1094 &disconnect_handler,
1097 if (NULL != strstr (argv[0], "_reliable"))
1098 msg_dropped = 0; /* dropped should be retransmitted */
1100 if (ok_goal > ok - msg_dropped)
1102 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FAILED! (%d/%d)\n", ok, ok_goal);
1105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1109 /* end of test_cadet.c */