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 * How fast do we send messages?
63 #define SEND_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 10)
66 * DIFFERENT TESTS TO RUN
77 * Which test are we running?
82 * String with test name
84 static char *test_name;
87 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
89 static int test_backwards = GNUNET_NO;
92 * How many packets to send.
94 static unsigned int total_packets;
97 * Time to wait for fast operations.
99 static struct GNUNET_TIME_Relative short_time;
102 * How many events have happened
107 * Number of events expected to conclude the test successfully.
112 * Size of each test packet's payload
114 static size_t size_payload = sizeof (uint32_t);
117 * Operation to get peer ids.
119 static struct GNUNET_TESTBED_Operation *t_op[2];
124 static struct GNUNET_PeerIdentity *p_id[2];
129 static struct GNUNET_HashCode port;
134 static unsigned int p_ids;
137 * Is the setup initialized?
139 static int initialized;
142 * Number of payload packes sent.
144 static int data_sent;
147 * Number of payload packets received.
149 static int data_received;
152 * Number of payload packed acknowledgements sent.
157 * Number of payload packed explicitly (app level) acknowledged.
159 static int ack_received;
162 * Total number of peers asked to run.
164 static unsigned long long peers_requested;
167 * Number of currently running peers (should be same as @c peers_requested).
169 static unsigned long long peers_running;
172 * Test context (to shut down).
174 struct GNUNET_CADET_TEST_Context *test_ctx;
177 * Task called to disconnect peers.
179 static struct GNUNET_SCHEDULER_Task *disconnect_task;
182 * Task To perform tests
184 static struct GNUNET_SCHEDULER_Task *test_task;
187 * Task runnining #send_next_msg().
189 static struct GNUNET_SCHEDULER_Task *send_next_msg_task;
192 * Cadet handle for the root peer
194 static struct GNUNET_CADET_Handle *h1;
197 * Cadet handle for the first leaf peer
199 static struct GNUNET_CADET_Handle *h2;
202 * Channel handle for the root peer
204 static struct GNUNET_CADET_Channel *outgoing_ch;
207 * Channel handle for the dest peer
209 static struct GNUNET_CADET_Channel *incoming_ch;
212 * Time we started the data transmission (after channel has been established
215 static struct GNUNET_TIME_Absolute start_time;
220 static struct GNUNET_TESTBED_Peer **testbed_peers;
223 * Statistics operation handle.
225 static struct GNUNET_TESTBED_Operation *stats_op;
230 static unsigned int ka_sent;
233 * Keepalives received.
235 static unsigned int ka_received;
238 * How many messages were dropped by CADET because of full buffers?
240 static unsigned int msg_dropped;
243 /******************************************************************************/
246 /******************************************************************************/
250 * Get the channel considered as the "target" or "receiver", depending on
251 * the test type and size.
253 * @return Channel handle of the target client, either 0 (for backward tests)
254 * or the last peer in the line (for other tests).
256 static struct GNUNET_CADET_Channel *
257 get_target_channel ()
259 if (SPEED == test && GNUNET_YES == test_backwards)
267 * Show the results of the test (banwidth acheived) and log them to GAUGER
272 static struct GNUNET_TIME_Absolute end_time;
273 static struct GNUNET_TIME_Relative total_time;
275 end_time = GNUNET_TIME_absolute_get ();
276 total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time);
278 "\nResults of test \"%s\"\n",
282 GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES));
284 "Test bandwidth: %f kb/s\n",
285 4 * total_packets * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
287 "Test throughput: %f packets/s\n\n",
288 total_packets * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
291 total_packets * 1000.0 / (total_time.rel_value_us / 1000),
297 * Disconnect from cadet services af all peers, call shutdown.
299 * @param cls Closure (line number from which termination was requested).
300 * @param tc Task Context.
303 disconnect_cadet_peers (void *cls)
305 long line = (long) cls;
307 disconnect_task = NULL;
308 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
309 "disconnecting cadet service of peers, called from line %ld\n",
311 for (unsigned int i = 0; i < 2; i++)
313 GNUNET_TESTBED_operation_done (t_op[i]);
315 if (NULL != outgoing_ch)
317 GNUNET_CADET_channel_destroy (outgoing_ch);
320 if (NULL != incoming_ch)
322 GNUNET_CADET_channel_destroy (incoming_ch);
325 GNUNET_CADET_TEST_cleanup (test_ctx);
326 GNUNET_SCHEDULER_shutdown ();
331 * Shut down peergroup, clean up.
333 * @param cls Closure (unused).
334 * @param tc Task Context.
337 shutdown_task (void *cls)
339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
341 if (NULL != send_next_msg_task)
343 GNUNET_SCHEDULER_cancel (send_next_msg_task);
344 send_next_msg_task = NULL;
346 if (NULL != test_task)
348 GNUNET_SCHEDULER_cancel (test_task);
351 if (NULL != disconnect_task)
353 GNUNET_SCHEDULER_cancel (disconnect_task);
355 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
362 * Stats callback. Finish the stats testbed operation and when all stats have
363 * been iterated, shutdown the test.
365 * @param cls Closure (line number from which termination was requested).
366 * @param op the operation that has been finished
367 * @param emsg error message in case the operation has failed; will be NULL if
368 * operation has executed successfully.
371 stats_cont (void *cls,
372 struct GNUNET_TESTBED_Operation *op,
375 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
376 "KA sent: %u, KA received: %u\n",
379 if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1)))
384 GNUNET_TESTBED_operation_done (stats_op);
386 if (NULL != disconnect_task)
387 GNUNET_SCHEDULER_cancel (disconnect_task);
388 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
394 * Process statistic values.
396 * @param cls closure (line number, unused)
397 * @param peer the peer the statistic belong to
398 * @param subsystem name of subsystem that created the statistic
399 * @param name the name of the datum
400 * @param value the current value
401 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
402 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
405 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
406 const char *subsystem, const char *name, uint64_t value,
409 static const char *s_sent = "# keepalives sent";
410 static const char *s_recv = "# keepalives received";
411 static const char *rdrops = "# messages dropped due to full buffer";
412 static const char *cdrops = "# messages dropped due to slow client";
415 i = GNUNET_TESTBED_get_index (peer);
416 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n", i,
417 subsystem, name, (unsigned long long) value);
418 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
420 if (0 == strncmp (s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
422 if (0 == strncmp (rdrops, name, strlen (rdrops)))
423 msg_dropped += value;
424 if (0 == strncmp (cdrops, name, strlen (cdrops)))
425 msg_dropped += value;
432 * Task to gather all statistics.
434 * @param cls Closure (line from which the task was scheduled).
437 gather_stats_and_exit (void *cls)
441 disconnect_task = NULL;
442 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
443 "gathering statistics from line %ld\n",
445 if (NULL != outgoing_ch)
447 GNUNET_CADET_channel_destroy (outgoing_ch);
450 stats_op = GNUNET_TESTBED_get_statistics (peers_running,
461 * Abort test: schedule disconnect and shutdown immediately
463 * @param line Line in the code the abort is requested from (__LINE__).
466 abort_test (long line)
468 if (NULL != disconnect_task)
470 GNUNET_SCHEDULER_cancel (disconnect_task);
471 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
472 "Aborting test from %ld\n",
475 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
482 * Send a message on the channel with the appropriate size and payload.
484 * Update the appropriate *_sent counter.
486 * @param channel Channel to send the message on.
489 send_test_message (struct GNUNET_CADET_Channel *channel)
491 struct GNUNET_MQ_Envelope *env;
492 struct GNUNET_MessageHeader *msg;
497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
498 "Sending test message on channel %p\n",
501 if (GNUNET_NO == initialized)
503 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending INITIALIZER\n");
506 if (SPEED_ACK == test) // FIXME unify SPEED_ACK with an initializer
509 else if (SPEED == test || SPEED_ACK == test)
511 if (get_target_channel() == channel)
516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
517 "Sending ACK %u [%d bytes]\n",
525 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
526 "Sending DATA %u [%d bytes]\n",
530 else if (FORWARD == test)
534 else if (P2P_SIGNAL == test)
542 env = GNUNET_MQ_msg_extra (msg, size, GNUNET_MESSAGE_TYPE_DUMMY);
544 data = (uint32_t *) &msg[1];
545 *data = htonl (payload);
546 GNUNET_MQ_send (GNUNET_CADET_get_mq (channel), env);
551 * Task to request a new data transmission in a SPEED test, without waiting
552 * for previous messages to be sent/arrrive.
554 * @param cls Closure (unused).
557 send_next_msg (void *cls)
559 struct GNUNET_CADET_Channel *channel;
561 send_next_msg_task = NULL;
562 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
563 "Sending next message: %d\n",
566 channel = GNUNET_YES == test_backwards ? incoming_ch : outgoing_ch;
567 GNUNET_assert (NULL != channel);
568 GNUNET_assert (SPEED == test);
569 send_test_message (channel);
570 if (data_sent < total_packets)
572 /* SPEED test: Send all messages as soon as possible */
573 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
574 "Scheduling message %d\n",
577 GNUNET_SCHEDULER_add_delayed (SEND_INTERVAL,
585 * Every few messages cancel the timeout task and re-schedule it again, to
586 * avoid timing out when traffic keeps coming.
588 * @param line Code line number to log if a timeout occurs.
591 reschedule_timeout_task (long line)
595 if (NULL != disconnect_task)
597 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
598 "reschedule timeout every 10 messages\n");
599 GNUNET_SCHEDULER_cancel (disconnect_task);
600 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
601 &gather_stats_and_exit,
609 * Check if payload is sane (size contains payload).
611 * @param cls should match #ch
612 * @param message The actual message.
613 * @return #GNUNET_OK to keep the channel open,
614 * #GNUNET_SYSERR to close it (signal serious error).
617 check_data (void *cls, const struct GNUNET_MessageHeader *message)
619 if (sizeof (struct GNUNET_MessageHeader) >= ntohs (message->size))
620 return GNUNET_SYSERR;
621 return GNUNET_OK; /* all is well-formed */
626 * Function is called whenever a message is received.
628 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
629 * @param message the actual message
632 handle_data (void *cls,
633 const struct GNUNET_MessageHeader *message)
635 struct CadetTestChannelWrapper *ch = cls;
636 struct GNUNET_CADET_Channel *channel = ch->ch;
642 GNUNET_CADET_receive_done (channel);
643 counter = get_target_channel () == channel ? &data_received : &ack_received;
645 reschedule_timeout_task ((long) __LINE__);
647 if (channel == outgoing_ch)
649 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message.\n");
651 else if (channel == incoming_ch)
653 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client got a message.\n");
657 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unknown channel %p.\n", channel);
661 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
662 data = (uint32_t *) &message[1];
663 payload = ntohl (*data);
664 if (payload == *counter)
666 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
670 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
671 " payload %u, expected: %u\n",
675 if (GNUNET_NO == initialized)
677 initialized = GNUNET_YES;
678 start_time = GNUNET_TIME_absolute_get ();
681 GNUNET_assert (incoming_ch == channel);
682 send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg, NULL);
688 if (get_target_channel () == channel) /* Got "data" */
690 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
691 if (SPEED != test || (ok_goal - 2) == ok)
694 send_test_message (channel);
699 if (data_received < total_packets)
705 if (SPEED_ACK == test || SPEED == test)
707 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
709 send_test_message (channel);
710 if (ack_received < total_packets && SPEED != test)
712 if (ok == 2 && SPEED == test)
716 if (test == P2P_SIGNAL)
718 GNUNET_CADET_channel_destroy (incoming_ch);
723 GNUNET_CADET_channel_destroy (outgoing_ch);
731 * Method called whenever a peer connects to a port in MQ-based CADET.
733 * @param cls Closure from #GNUNET_CADET_open_port (peer # as long).
734 * @param channel New handle to the channel.
735 * @param source Peer that started this channel.
736 * @return Closure for the incoming @a channel. It's given to:
737 * - The #GNUNET_CADET_DisconnectEventHandler (given to
738 * #GNUNET_CADET_open_port) when the channel dies.
739 * - Each the #GNUNET_MQ_MessageCallback handlers for each message
740 * received on the @a channel.
743 connect_handler (void *cls, struct GNUNET_CADET_Channel *channel,
744 const struct GNUNET_PeerIdentity *source)
746 struct CadetTestChannelWrapper *ch;
747 long peer = (long) cls;
749 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
750 "Incoming channel from %s to %ld: %p\n",
751 GNUNET_i2s (source), peer, channel);
753 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
754 if (peer == peers_requested - 1)
756 if (NULL != incoming_ch)
758 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
759 "Duplicate incoming channel for client %lu\n", (long) cls);
762 incoming_ch = channel;
766 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
767 "Incoming channel for unexpected peer #%lu\n", (long) cls);
770 if (NULL != disconnect_task)
772 GNUNET_SCHEDULER_cancel (disconnect_task);
773 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
774 &gather_stats_and_exit,
778 /* TODO: cannot return channel as-is, in order to unify the data handlers */
779 ch = GNUNET_new (struct CadetTestChannelWrapper);
787 * Function called whenever an MQ-channel is destroyed, even if the destruction
788 * was requested by #GNUNET_CADET_channel_destroy.
789 * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
791 * It should clean up any associated state, including cancelling any pending
792 * transmission on this channel.
794 * @param cls Channel closure (channel wrapper).
795 * @param channel Connection to the other end (henceforth invalid).
798 disconnect_handler (void *cls,
799 const struct GNUNET_CADET_Channel *channel)
801 struct CadetTestChannelWrapper *ch_w = cls;
803 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
804 "Channel disconnected at %d\n",
806 GNUNET_assert (ch_w->ch == channel);
807 if (channel == incoming_ch)
812 else if (outgoing_ch == channel)
814 if (P2P_SIGNAL == test)
821 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
822 "Unknown channel! %p\n",
824 if (NULL != disconnect_task)
826 GNUNET_SCHEDULER_cancel (disconnect_task);
828 GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
836 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
838 * Testcase continues when the root receives confirmation of connected peers,
839 * on callback function ch.
841 * @param cls Closure (unused).
844 start_test (void *cls)
846 struct GNUNET_MQ_MessageHandler handlers[] = {
847 GNUNET_MQ_hd_var_size (data,
848 GNUNET_MESSAGE_TYPE_DUMMY,
849 struct GNUNET_MessageHeader,
851 GNUNET_MQ_handler_end ()
853 struct CadetTestChannelWrapper *ch;
854 enum GNUNET_CADET_ChannelOption flags;
857 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
858 if (NULL != disconnect_task)
860 GNUNET_SCHEDULER_cancel (disconnect_task);
861 disconnect_task = NULL;
864 flags = GNUNET_CADET_OPTION_DEFAULT;
865 if (SPEED_REL == test)
868 flags |= GNUNET_CADET_OPTION_RELIABLE;
871 ch = GNUNET_new (struct CadetTestChannelWrapper);
872 outgoing_ch = GNUNET_CADET_channel_create (h1,
881 ch->ch = outgoing_ch;
883 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
884 &gather_stats_and_exit,
886 if (KEEPALIVE == test)
887 return; /* Don't send any data. */
894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
895 "Sending data initializer on channel %p...\n",
897 send_test_message (outgoing_ch);
902 * Callback to be called when the requested peer information is available
904 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
905 * @param op the operation this callback corresponds to
906 * @param pinfo the result; will be NULL if the operation has failed
907 * @param emsg error message if the operation has failed;
908 * NULL if the operation is successfull
912 struct GNUNET_TESTBED_Operation *op,
913 const struct GNUNET_TESTBED_PeerInformation *pinfo,
918 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
919 "ID callback for %ld\n",
921 if ( (NULL == pinfo) ||
924 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
927 abort_test (__LINE__);
930 p_id[i] = pinfo->result.id;
931 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
933 GNUNET_i2s (p_id[i]));
937 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
938 "Got all IDs, starting test\n");
939 test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
944 * test main: start test when all peers are connected
946 * @param cls Closure.
947 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
948 * @param num_peers Number of peers that are running.
949 * @param peers Array of peers.
950 * @param cadets Handle to each of the CADETs of the peers.
954 struct GNUNET_CADET_TEST_Context *ctx,
955 unsigned int num_peers,
956 struct GNUNET_TESTBED_Peer **peers,
957 struct GNUNET_CADET_Handle **cadets)
959 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
962 peers_running = num_peers;
963 GNUNET_assert (peers_running == peers_requested);
964 testbed_peers = peers;
966 h2 = cadets[num_peers - 1];
967 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
968 &disconnect_cadet_peers,
970 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
972 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
973 GNUNET_TESTBED_PIT_IDENTITY,
976 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
977 GNUNET_TESTBED_PIT_IDENTITY,
980 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
988 main (int argc, char *argv[])
990 static const struct GNUNET_HashCode *ports[2];
991 struct GNUNET_MQ_MessageHandler handlers[] = {
992 GNUNET_MQ_hd_var_size (data,
993 GNUNET_MESSAGE_TYPE_DUMMY,
994 struct GNUNET_MessageHeader,
996 GNUNET_MQ_handler_end ()
998 const char *config_file;
999 char port_id[] = "test port";
1000 struct GNUNET_GETOPT_CommandLineOption options[] = {
1001 GNUNET_GETOPT_option_relative_time ('t',
1004 gettext_noop ("set short timeout"),
1007 GNUNET_GETOPT_option_uint ('m',
1010 gettext_noop ("set number of messages to send"),
1013 GNUNET_GETOPT_OPTION_END
1017 initialized = GNUNET_NO;
1018 GNUNET_log_setup ("test", "DEBUG", NULL);
1020 total_packets = TOTAL_PACKETS;
1021 short_time = SHORT_TIME;
1022 if (-1 == GNUNET_GETOPT_run (argv[0], options, argc, argv))
1024 FPRINTF (stderr, "test failed: problem with CLI parameters\n");
1028 config_file = "test_cadet.conf";
1029 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
1031 /* Find out requested size */
1032 if (strstr (argv[0], "_2_") != NULL)
1034 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
1035 peers_requested = 2;
1037 else if (strstr (argv[0], "_5_") != NULL)
1039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1040 peers_requested = 5;
1044 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1045 peers_requested = 2;
1048 /* Find out requested test */
1049 if (strstr (argv[0], "_forward") != NULL)
1051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1053 test_name = "unicast";
1056 else if (strstr (argv[0], "_signal") != NULL)
1058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1060 test_name = "signal";
1063 else if (strstr (argv[0], "_speed_ack") != NULL)
1065 /* Test is supposed to generate the following callbacks:
1066 * 1 incoming channel (@dest)
1067 * total_packets received data packet (@dest)
1068 * total_packets received data packet (@orig)
1069 * 1 received channel destroy (@dest)
1071 ok_goal = total_packets * 2 + 2;
1072 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1074 test_name = "speed ack";
1076 else if (strstr (argv[0], "_speed") != NULL)
1078 /* Test is supposed to generate the following callbacks:
1079 * 1 incoming channel (@dest)
1080 * 1 initial packet (@dest)
1081 * total_packets received data packet (@dest)
1082 * 1 received data packet (@orig)
1083 * 1 received channel destroy (@dest)
1085 ok_goal = total_packets + 4;
1086 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1087 if (strstr (argv[0], "_reliable") != NULL)
1090 test_name = "speed reliable";
1091 config_file = "test_cadet_drop.conf";
1096 test_name = "speed";
1099 else if (strstr (argv[0], "_keepalive") != NULL)
1102 /* Test is supposed to generate the following callbacks:
1103 * 1 incoming channel (@dest)
1105 * 1 received channel destroy (@dest)
1111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1116 if (strstr (argv[0], "backwards") != NULL)
1118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1119 test_backwards = GNUNET_YES;
1120 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1126 GNUNET_CADET_TEST_ruN ("test_cadet_small",
1130 NULL, /* tmain cls */
1133 &disconnect_handler,
1136 if (NULL != strstr (argv[0], "_reliable"))
1137 msg_dropped = 0; /* dropped should be retransmitted */
1139 if (ok_goal > ok - msg_dropped)
1141 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FAILED! (%d/%d)\n", ok, ok_goal);
1144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1148 /* end of test_cadet.c */