2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file cadet/test_cadet.c
23 * @brief Test for the cadet service: retransmission of traffic.
27 #include "cadet_test_lib.h"
28 #include "gnunet_cadet_service.h"
29 #include "gnunet_statistics_service.h"
34 * How namy messages to send
36 #define TOTAL_PACKETS 100
39 * How long until we give up on connecting the peers?
41 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
44 * Time to wait for stuff that should be rather fast
46 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
49 * DIFFERENT TESTS TO RUN
60 * Which test are we running?
65 * String with test name
70 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
72 static int test_backwards = GNUNET_NO;
75 * How many events have happened
80 * Number of events expected to conclude the test successfully.
85 * Size of each test packet
87 size_t size_payload = sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t);
90 * Operation to get peer ids.
92 struct GNUNET_TESTBED_Operation *t_op[2];
97 struct GNUNET_PeerIdentity *p_id[2];
105 * Is the setup initialized?
107 static int initialized;
110 * Number of payload packes sent.
112 static int data_sent;
115 * Number of payload packets received.
117 static int data_received;
120 * Number of payload packed acknowledgements sent.
125 * Number of payload packed explicitly (app level) acknowledged.
127 static int ack_received;
130 * Total number of peers asked to run.
132 static unsigned long long peers_requested;
135 * Number of currently running peers (should be same as @c peers_requested).
137 static unsigned long long peers_running;
140 * Test context (to shut down).
142 struct GNUNET_CADET_TEST_Context *test_ctx;
145 * Task called to disconnect peers.
147 static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
150 * Task To perform tests
152 static GNUNET_SCHEDULER_TaskIdentifier test_task;
155 * Task called to shutdown test.
157 static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
160 * Cadet handle for the root peer
162 static struct GNUNET_CADET_Handle *h1;
165 * Cadet handle for the first leaf peer
167 static struct GNUNET_CADET_Handle *h2;
170 * Channel handle for the root peer
172 static struct GNUNET_CADET_Channel *ch;
175 * Channel handle for the dest peer
177 static struct GNUNET_CADET_Channel *incoming_ch;
180 * Time we started the data transmission (after channel has been established
183 static struct GNUNET_TIME_Absolute start_time;
188 static struct GNUNET_TESTBED_Peer **testbed_peers;
191 * Statistics operation handle.
193 static struct GNUNET_TESTBED_Operation *stats_op;
198 static unsigned int ka_sent;
201 * Keepalives received.
203 static unsigned int ka_received;
207 * Get the client number considered as the "target" or "receiver", depending on
208 * the test type and size.
210 * @return Peer # of the target client, either 0 (for backward tests) or
211 * the last peer in the line (for other tests).
214 get_expected_target ()
216 if (SPEED == test && GNUNET_YES == test_backwards)
219 return peers_requested - 1;
223 * Show the results of the test (banwidth acheived) and log them to GAUGER
228 static struct GNUNET_TIME_Absolute end_time;
229 static struct GNUNET_TIME_Relative total_time;
231 end_time = GNUNET_TIME_absolute_get();
232 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
233 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
234 FPRINTF (stderr, "Test time %s\n",
235 GNUNET_STRINGS_relative_time_to_string (total_time,
237 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
238 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
239 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
240 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
241 GAUGER ("CADET", test_name,
242 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
248 * Shut down peergroup, clean up.
250 * @param cls Closure (unused).
251 * @param tc Task Context.
254 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
257 shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
262 * Disconnect from cadet services af all peers, call shutdown.
264 * @param cls Closure (unused).
265 * @param tc Task Context.
268 disconnect_cadet_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
270 long line = (long) cls;
273 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
275 "disconnecting cadet peers due to SHUTDOWN! called from %ld\n",
278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
279 "disconnecting cadet service of peers, called from line %ld\n",
281 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
282 for (i = 0; i < 2; i++)
284 GNUNET_TESTBED_operation_done (t_op[i]);
288 GNUNET_CADET_channel_destroy (ch);
291 if (NULL != incoming_ch)
293 GNUNET_CADET_channel_destroy (incoming_ch);
296 GNUNET_CADET_TEST_cleanup (test_ctx);
297 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
299 GNUNET_SCHEDULER_cancel (shutdown_handle);
301 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
306 * Abort test: schedule disconnect and shutdown immediately
308 * @param line Line in the code the abort is requested from (__LINE__).
311 abort_test (long line)
313 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
315 GNUNET_SCHEDULER_cancel (disconnect_task);
316 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
322 * Transmit ready callback.
324 * @param cls Closure (message type).
325 * @param size Size of the tranmist buffer.
326 * @param buf Pointer to the beginning of the buffer.
328 * @return Number of bytes written to buf.
331 tmt_rdy (void *cls, size_t size, void *buf);
335 * Task to schedule a new data transmission.
337 * @param cls Closure (peer #).
338 * @param tc Task Context.
341 data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
343 struct GNUNET_CADET_TransmitHandle *th;
344 struct GNUNET_CADET_Channel *channel;
347 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
350 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
351 if (GNUNET_YES == test_backwards)
353 channel = incoming_ch;
354 src = peers_requested - 1;
361 th = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
362 GNUNET_TIME_UNIT_FOREVER_REL,
363 size_payload + data_sent,
364 &tmt_rdy, (void *) src);
367 unsigned long i = (unsigned long) cls;
369 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Retransmission\n");
372 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n");
373 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
374 &data_task, (void *) 1L);
379 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "in %u ms\n", i);
380 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
381 GNUNET_TIME_UNIT_MILLISECONDS,
383 &data_task, (void *) i);
390 * Transmit ready callback
392 * @param cls Closure (peer # which is sending the data).
393 * @param size Size of the buffer we have.
394 * @param buf Buffer to copy data to.
397 tmt_rdy (void *cls, size_t size, void *buf)
399 struct GNUNET_MessageHeader *msg = buf;
402 long id = (long) cls;
403 unsigned int counter;
405 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy on %ld, filling buffer\n", id);
406 counter = get_expected_target () == id ? ack_sent : data_sent;
407 msg_size = size_payload + counter;
408 if (size < msg_size || NULL == buf)
410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
411 "size %u, buf %p, data_sent %u, ack_received %u\n",
412 size, buf, data_sent, ack_received);
413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
414 GNUNET_break (ok >= ok_goal - 2);
418 msg->size = htons (size);
419 msg->type = htons (1);
420 data = (uint32_t *) &msg[1];
421 *data = htonl (counter);
422 if (GNUNET_NO == initialized)
424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n");
425 if (SPEED_ACK == test)
428 else if (SPEED == test || SPEED_ACK == test)
430 if (get_expected_target() == id)
435 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " Sent message %d size %u\n",
437 if (data_sent < TOTAL_PACKETS && SPEED == test)
439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n",
441 GNUNET_SCHEDULER_add_now (&data_task, NULL);
450 * Function is called whenever a message is received.
452 * @param cls closure (set from GNUNET_CADET_connect)
453 * @param channel connection to the other end
454 * @param channel_ctx place to store local state associated with the channel
455 * @param message the actual message
456 * @return GNUNET_OK to keep the connection open,
457 * GNUNET_SYSERR to close it (signal serious error)
460 data_callback (void *cls, struct GNUNET_CADET_Channel *channel,
462 const struct GNUNET_MessageHeader *message)
464 long client = (long) cls;
465 long expected_target_client;
468 unsigned int counter;
471 counter = get_expected_target () == client ? data_received : ack_received;
473 GNUNET_CADET_receive_done (channel);
477 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
479 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " reschedule timeout\n");
480 GNUNET_SCHEDULER_cancel (disconnect_task);
481 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
482 &disconnect_cadet_peers,
490 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
494 GNUNET_assert (client == peers_requested - 1);
495 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client %li got a message.\n",
499 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %li not valid.\n", client);
502 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
503 data = (uint32_t *) &message[1];
504 payload = ntohl (*data);
505 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload: %u, data_received: %u\n",
507 GNUNET_break (payload == counter);
508 expected_target_client = get_expected_target ();
510 if (GNUNET_NO == initialized)
512 initialized = GNUNET_YES;
513 start_time = GNUNET_TIME_absolute_get ();
516 GNUNET_assert (peers_requested - 1 == client);
517 GNUNET_SCHEDULER_add_now (&data_task, NULL);
523 if (client == expected_target_client) /* Normally 4 */
526 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
527 if (SPEED != test || (ok_goal - 2) == ok)
530 GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
531 GNUNET_TIME_UNIT_FOREVER_REL,
532 size_payload + ack_sent, &tmt_rdy,
538 if (data_received < TOTAL_PACKETS)
542 else /* Normally 0 */
544 if (SPEED_ACK == test || SPEED == test)
547 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
548 GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
549 GNUNET_TIME_UNIT_FOREVER_REL,
550 size_payload + data_sent, &tmt_rdy,
552 if (ack_received < TOTAL_PACKETS && SPEED != test)
554 if (ok == 2 && SPEED == test)
558 if (test == P2P_SIGNAL)
560 GNUNET_CADET_channel_destroy (incoming_ch);
565 GNUNET_CADET_channel_destroy (ch);
570 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
572 GNUNET_SCHEDULER_cancel (disconnect_task);
573 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
574 &disconnect_cadet_peers,
583 * Stats callback. Finish the stats testbed operation and when all stats have
584 * been iterated, shutdown the test.
587 * @param op the operation that has been finished
588 * @param emsg error message in case the operation has failed; will be NULL if
589 * operation has executed successfully.
592 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
594 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stats_cont for peer %u\n", cls);
595 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n",
596 ka_sent, ka_received);
597 if (ka_sent < 2 || ka_sent > ka_received + 1)
599 GNUNET_TESTBED_operation_done (stats_op);
601 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
602 GNUNET_SCHEDULER_cancel (disconnect_task);
603 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
610 * Process statistic values.
613 * @param peer the peer the statistic belong to
614 * @param subsystem name of subsystem that created the statistic
615 * @param name the name of the datum
616 * @param value the current value
617 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
618 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
621 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
622 const char *subsystem, const char *name,
623 uint64_t value, int is_persistent)
625 static const char *s_sent = "# keepalives sent";
626 static const char *s_recv = "# keepalives received";
629 i = GNUNET_TESTBED_get_index (peer);
630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u - %s [%s]: %llu\n",
631 i, subsystem, name, value);
632 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
635 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
643 * Task check that keepalives were sent and received.
645 * @param cls Closure (NULL).
646 * @param tc Task Context.
649 check_keepalives (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
651 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
654 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
655 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "check keepalives\n");
656 GNUNET_CADET_channel_destroy (ch);
657 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
659 stats_iterator, stats_cont, NULL);
664 * Handlers, for diverse services
666 static struct GNUNET_CADET_MessageHandler handlers[] = {
667 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
673 * Method called whenever another peer has added us to a channel
674 * the other peer initiated.
676 * @param cls Closure.
677 * @param channel New handle to the channel.
678 * @param initiator Peer that started the channel.
679 * @param port Port this channel is connected to.
680 * @param options channel option flags
681 * @return Initial channel context for the channel
682 * (can be NULL -- that's not an error).
685 incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel,
686 const struct GNUNET_PeerIdentity *initiator,
687 uint32_t port, enum GNUNET_CADET_ChannelOption options)
689 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
690 "Incoming channel from %s to peer %d\n",
691 GNUNET_i2s (initiator), (long) cls);
693 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
694 if ((long) cls == peers_requested - 1)
695 incoming_ch = channel;
698 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
699 "Incoming channel for unknown client %lu\n", (long) cls);
702 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
704 GNUNET_SCHEDULER_cancel (disconnect_task);
705 if (KEEPALIVE == test)
707 struct GNUNET_TIME_Relative delay;
708 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS , 5);
710 GNUNET_SCHEDULER_add_delayed (delay, &check_keepalives, NULL);
713 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
714 &disconnect_cadet_peers,
722 * Function called whenever an inbound channel is destroyed. Should clean up
723 * any associated state.
725 * @param cls closure (set from GNUNET_CADET_connect)
726 * @param channel connection to the other end (henceforth invalid)
727 * @param channel_ctx place where local state associated
728 * with the channel is stored
731 channel_cleaner (void *cls, const struct GNUNET_CADET_Channel *channel,
736 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
737 "Incoming channel disconnected at peer %ld\n", i);
738 if (peers_running - 1 == i)
741 GNUNET_break (channel == incoming_ch);
746 if (P2P_SIGNAL == test)
750 GNUNET_break (channel == ch);
754 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
755 "Unknown peer! %d\n", i);
756 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
758 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
760 GNUNET_SCHEDULER_cancel (disconnect_task);
761 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
770 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
772 * Testcase continues when the root receives confirmation of connected peers,
773 * on callback funtion ch.
775 * @param cls Closure (unsued).
776 * @param tc Task Context.
779 do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
781 enum GNUNET_CADET_ChannelOption flags;
783 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test_task\n");
788 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
790 GNUNET_SCHEDULER_cancel (disconnect_task);
793 flags = GNUNET_CADET_OPTION_DEFAULT;
794 if (SPEED_REL == test)
797 flags |= GNUNET_CADET_OPTION_RELIABLE;
799 ch = GNUNET_CADET_channel_create (h1, NULL, p_id[1], 1, flags);
801 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
802 &disconnect_cadet_peers,
804 if (KEEPALIVE == test)
805 return; /* Don't send any data. */
807 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n");
812 GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO,
813 GNUNET_TIME_UNIT_FOREVER_REL,
814 size_payload, &tmt_rdy, (void *) 0L);
818 * Callback to be called when the requested peer information is available
820 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
821 * @param op the operation this callback corresponds to
822 * @param pinfo the result; will be NULL if the operation has failed
823 * @param emsg error message if the operation has failed;
824 * NULL if the operation is successfull
828 struct GNUNET_TESTBED_Operation *op,
829 const struct GNUNET_TESTBED_PeerInformation *pinfo,
834 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "id callback for %ld\n", i);
836 if (NULL == pinfo || NULL != emsg)
838 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
839 abort_test (__LINE__);
842 p_id[i] = pinfo->result.id;
843 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
848 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
853 * test main: start test when all peers are connected
855 * @param cls Closure.
856 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
857 * @param num_peers Number of peers that are running.
858 * @param peers Array of peers.
859 * @param cadetes Handle to each of the CADETs of the peers.
863 struct GNUNET_CADET_TEST_Context *ctx,
864 unsigned int num_peers,
865 struct GNUNET_TESTBED_Peer **peers,
866 struct GNUNET_CADET_Handle **cadets)
868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
871 peers_running = num_peers;
872 GNUNET_assert (peers_running == peers_requested);
873 testbed_peers = peers;
875 h2 = cadets[num_peers - 1];
876 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
877 &disconnect_cadet_peers,
879 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
880 &shutdown_task, NULL);
881 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
882 GNUNET_TESTBED_PIT_IDENTITY,
883 &pi_cb, (void *) 0L);
884 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
885 GNUNET_TESTBED_PIT_IDENTITY,
886 &pi_cb, (void *) 1L);
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
895 main (int argc, char *argv[])
897 initialized = GNUNET_NO;
898 static uint32_t ports[2];
899 const char *config_file;
901 GNUNET_log_setup ("test", "DEBUG", NULL);
902 config_file = "test_cadet.conf";
904 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
906 /* Find out requested size */
907 if (strstr (argv[0], "_2_") != NULL)
909 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
912 else if (strstr (argv[0], "_5_") != NULL)
914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
919 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
923 /* Find out requested test */
924 if (strstr (argv[0], "_forward") != NULL)
926 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
928 test_name = "unicast";
931 else if (strstr (argv[0], "_signal") != NULL)
933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
935 test_name = "signal";
938 else if (strstr (argv[0], "_speed_ack") != NULL)
940 /* Test is supposed to generate the following callbacks:
941 * 1 incoming channel (@dest)
942 * TOTAL_PACKETS received data packet (@dest)
943 * TOTAL_PACKETS received data packet (@orig)
944 * 1 received channel destroy (@dest)
946 ok_goal = TOTAL_PACKETS * 2 + 2;
947 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
949 test_name = "speed ack";
951 else if (strstr (argv[0], "_speed") != NULL)
953 /* Test is supposed to generate the following callbacks:
954 * 1 incoming channel (@dest)
955 * 1 initial packet (@dest)
956 * TOTAL_PACKETS received data packet (@dest)
957 * 1 received data packet (@orig)
958 * 1 received channel destroy (@dest)
960 ok_goal = TOTAL_PACKETS + 4;
961 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
962 if (strstr (argv[0], "_reliable") != NULL)
965 test_name = "speed reliable";
966 config_file = "test_cadet_drop.conf";
974 else if (strstr (argv[0], "_keepalive") != NULL)
977 /* Test is supposed to generate the following callbacks:
978 * 1 incoming channel (@dest)
980 * 1 received channel destroy (@dest)
986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
991 if (strstr (argv[0], "backwards") != NULL)
993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
994 test_backwards = GNUNET_YES;
995 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1001 GNUNET_CADET_TEST_run ("test_cadet_small",
1005 NULL, /* tmain cls */
1013 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1014 "FAILED! (%d/%d)\n", ok, ok_goal);
1017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1021 /* end of test_cadet.c */