2 This file is part of GNUnet.
3 Copyright (C) 2011 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 * @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 many messages to send
36 #define TOTAL_PACKETS 500 /* Cannot exceed 64k! */
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, 20)
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];
102 struct GNUNET_HashCode port;
110 * Is the setup initialized?
112 static int initialized;
115 * Number of payload packes sent.
117 static int data_sent;
120 * Number of payload packets received.
122 static int data_received;
125 * Number of payload packed acknowledgements sent.
130 * Number of payload packed explicitly (app level) acknowledged.
132 static int ack_received;
135 * Total number of peers asked to run.
137 static unsigned long long peers_requested;
140 * Number of currently running peers (should be same as @c peers_requested).
142 static unsigned long long peers_running;
145 * Test context (to shut down).
147 struct GNUNET_CADET_TEST_Context *test_ctx;
150 * Task called to disconnect peers.
152 static struct GNUNET_SCHEDULER_Task *disconnect_task;
155 * Task To perform tests
157 static struct GNUNET_SCHEDULER_Task *test_task;
160 * Task runnining #data_task().
162 static struct GNUNET_SCHEDULER_Task *data_job;
165 * Cadet handle for the root peer
167 static struct GNUNET_CADET_Handle *h1;
170 * Cadet handle for the first leaf peer
172 static struct GNUNET_CADET_Handle *h2;
175 * Channel handle for the root peer
177 static struct GNUNET_CADET_Channel *ch;
180 * Channel handle for the dest peer
182 static struct GNUNET_CADET_Channel *incoming_ch;
185 * Transmit handle for root data calls
187 static struct GNUNET_CADET_TransmitHandle *th;
190 * Transmit handle for root data calls
192 static struct GNUNET_CADET_TransmitHandle *incoming_th;
196 * Time we started the data transmission (after channel has been established
199 static struct GNUNET_TIME_Absolute start_time;
204 static struct GNUNET_TESTBED_Peer **testbed_peers;
207 * Statistics operation handle.
209 static struct GNUNET_TESTBED_Operation *stats_op;
214 static unsigned int ka_sent;
217 * Keepalives received.
219 static unsigned int ka_received;
223 * Get the client number considered as the "target" or "receiver", depending on
224 * the test type and size.
226 * @return Peer # of the target client, either 0 (for backward tests) or
227 * the last peer in the line (for other tests).
230 get_expected_target ()
232 if (SPEED == test && GNUNET_YES == test_backwards)
235 return peers_requested - 1;
240 * Show the results of the test (banwidth acheived) and log them to GAUGER
245 static struct GNUNET_TIME_Absolute end_time;
246 static struct GNUNET_TIME_Relative total_time;
248 end_time = GNUNET_TIME_absolute_get();
249 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
250 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
251 FPRINTF (stderr, "Test time %s\n",
252 GNUNET_STRINGS_relative_time_to_string (total_time,
254 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
255 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
256 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
257 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
258 GAUGER ("CADET", test_name,
259 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
265 * Disconnect from cadet services af all peers, call shutdown.
267 * @param cls Closure (line number from which termination was requested).
268 * @param tc Task Context.
271 disconnect_cadet_peers (void *cls)
273 long line = (long) cls;
276 disconnect_task = NULL;
277 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
278 "disconnecting cadet service of peers, called from line %ld\n",
280 for (i = 0; i < 2; i++)
282 GNUNET_TESTBED_operation_done (t_op[i]);
288 GNUNET_CADET_notify_transmit_ready_cancel (th);
291 GNUNET_CADET_channel_destroy (ch);
294 if (NULL != incoming_ch)
296 if (NULL != incoming_th)
298 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
301 GNUNET_CADET_channel_destroy (incoming_ch);
304 GNUNET_CADET_TEST_cleanup (test_ctx);
305 GNUNET_SCHEDULER_shutdown ();
310 * Shut down peergroup, clean up.
312 * @param cls Closure (unused).
313 * @param tc Task Context.
316 shutdown_task (void *cls)
318 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
319 if (NULL != data_job)
321 GNUNET_SCHEDULER_cancel (data_job);
324 if (NULL != test_task)
326 GNUNET_SCHEDULER_cancel (test_task);
329 if (NULL != disconnect_task)
331 GNUNET_SCHEDULER_cancel (disconnect_task);
332 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
339 * Stats callback. Finish the stats testbed operation and when all stats have
340 * been iterated, shutdown the test.
342 * @param cls Closure (line number from which termination was requested).
343 * @param op the operation that has been finished
344 * @param emsg error message in case the operation has failed; will be NULL if
345 * operation has executed successfully.
348 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
350 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n",
351 ka_sent, ka_received);
352 if (KEEPALIVE == test && (ka_sent < 2 || ka_sent > ka_received + 1))
354 GNUNET_TESTBED_operation_done (stats_op);
356 if (NULL != disconnect_task)
357 GNUNET_SCHEDULER_cancel (disconnect_task);
358 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
364 * Process statistic values.
366 * @param cls closure (line number, unused)
367 * @param peer the peer the statistic belong to
368 * @param subsystem name of subsystem that created the statistic
369 * @param name the name of the datum
370 * @param value the current value
371 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
372 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
375 stats_iterator (void *cls,
376 const struct GNUNET_TESTBED_Peer *peer,
377 const char *subsystem,
382 static const char *s_sent = "# keepalives sent";
383 static const char *s_recv = "# keepalives received";
386 i = GNUNET_TESTBED_get_index (peer);
387 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
388 "STATS PEER %u - %s [%s]: %llu\n",
392 (unsigned long long) value);
393 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
396 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
404 * Task to gather all statistics.
406 * @param cls Closure (NULL).
409 gather_stats_and_exit (void *cls)
413 disconnect_task = NULL;
414 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
415 "gathering statistics from line %d\n",
421 GNUNET_CADET_notify_transmit_ready_cancel (th);
424 GNUNET_CADET_channel_destroy (ch);
427 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
429 stats_iterator, stats_cont, cls);
435 * Abort test: schedule disconnect and shutdown immediately
437 * @param line Line in the code the abort is requested from (__LINE__).
440 abort_test (long line)
442 if (disconnect_task != NULL)
444 GNUNET_SCHEDULER_cancel (disconnect_task);
445 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting test from %ld\n", line);
446 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
452 * Transmit ready callback.
454 * @param cls Closure (message type).
455 * @param size Size of the tranmist buffer.
456 * @param buf Pointer to the beginning of the buffer.
458 * @return Number of bytes written to buf.
461 tmt_rdy (void *cls, size_t size, void *buf);
465 * Task to request a new data transmission.
467 * @param cls Closure (peer #).
470 data_task (void *cls)
472 struct GNUNET_CADET_Channel *channel;
473 static struct GNUNET_CADET_TransmitHandle **pth;
477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
478 if (GNUNET_YES == test_backwards)
480 channel = incoming_ch;
482 src = peers_requested - 1;
491 GNUNET_assert (NULL != channel);
492 GNUNET_assert (NULL == *pth);
494 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
495 GNUNET_TIME_UNIT_FOREVER_REL,
496 size_payload + data_sent,
497 &tmt_rdy, (void *) src);
500 unsigned long i = (unsigned long) cls;
502 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Retransmission\n");
505 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n");
506 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
507 &data_task, (void *) 1L);
512 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
514 (unsigned long long) i);
515 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
517 &data_task, (void *) i);
524 * Transmit ready callback
526 * @param cls Closure (peer # which is sending the data).
527 * @param size Size of the buffer we have.
528 * @param buf Buffer to copy data to.
531 tmt_rdy (void *cls, size_t size, void *buf)
533 struct GNUNET_MessageHeader *msg = buf;
536 long id = (long) cls;
537 unsigned int counter;
539 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
540 "tmt_rdy on %ld, filling buffer\n",
544 else if ((peers_requested - 1) == id)
548 counter = get_expected_target () == id ? ack_sent : data_sent;
549 msg_size = size_payload + counter;
550 GNUNET_assert (msg_size > sizeof (struct GNUNET_MessageHeader));
551 if ( (size < msg_size) ||
554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
555 "size %u, buf %p, data_sent %u, ack_received %u\n",
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
561 GNUNET_break (ok >= ok_goal - 2);
565 msg->size = htons (msg_size);
566 msg->type = htons (GNUNET_MESSAGE_TYPE_DUMMY);
567 data = (uint32_t *) &msg[1];
568 *data = htonl (counter);
569 if (GNUNET_NO == initialized)
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "sending initializer\n");
573 msg_size = size_payload + 1000;
574 msg->size = htons (msg_size);
575 if (SPEED_ACK == test)
578 else if ( (SPEED == test) ||
579 (SPEED_ACK == test) )
581 if (get_expected_target() == id)
586 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
587 " Sent message %u size %u\n",
589 (unsigned int) msg_size);
590 if ( (data_sent < TOTAL_PACKETS) &&
593 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
594 " Scheduling message %d\n",
596 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
605 * Function is called whenever a message is received.
607 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
608 * @param channel connection to the other end
609 * @param channel_ctx place to store local state associated with the channel
610 * @param message the actual message
611 * @return #GNUNET_OK to keep the connection open,
612 * #GNUNET_SYSERR to close it (signal serious error)
615 data_callback (void *cls,
616 struct GNUNET_CADET_Channel *channel,
618 const struct GNUNET_MessageHeader *message)
620 struct GNUNET_CADET_TransmitHandle **pth;
621 long client = (long) cls;
622 long expected_target_client;
625 unsigned int counter;
628 counter = get_expected_target () == client ? data_received : ack_received;
630 GNUNET_CADET_receive_done (channel);
634 if (NULL != disconnect_task)
636 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
637 " reschedule timeout\n");
638 GNUNET_SCHEDULER_cancel (disconnect_task);
639 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
640 &gather_stats_and_exit,
648 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
649 GNUNET_assert (channel == ch);
654 GNUNET_assert (client == peers_requested - 1);
655 GNUNET_assert (channel == incoming_ch);
657 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client %ld got a message.\n",
661 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %ld not valid.\n", client);
664 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
665 data = (uint32_t *) &message[1];
666 payload = ntohl (*data);
667 if (payload == counter)
669 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
673 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " payload %u, expected: %u\n",
676 expected_target_client = get_expected_target ();
678 if (GNUNET_NO == initialized)
680 initialized = GNUNET_YES;
681 start_time = GNUNET_TIME_absolute_get ();
684 GNUNET_assert (peers_requested - 1 == client);
685 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
691 if (client == expected_target_client) /* Normally 4 */
694 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
695 if (SPEED != test || (ok_goal - 2) == ok)
698 GNUNET_assert (NULL == *pth);
699 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
700 GNUNET_TIME_UNIT_FOREVER_REL,
701 size_payload + ack_sent,
702 &tmt_rdy, (void *) client);
707 if (data_received < TOTAL_PACKETS)
711 else /* Normally 0 */
713 if (SPEED_ACK == test || SPEED == test)
716 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
718 GNUNET_assert (NULL == *pth);
719 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
720 GNUNET_TIME_UNIT_FOREVER_REL,
721 size_payload + data_sent,
722 &tmt_rdy, (void *) client);
723 if (ack_received < TOTAL_PACKETS && SPEED != test)
725 if (ok == 2 && SPEED == test)
729 if (test == P2P_SIGNAL)
731 if (NULL != incoming_th)
733 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
736 GNUNET_CADET_channel_destroy (incoming_ch);
743 GNUNET_CADET_notify_transmit_ready_cancel (th);
746 GNUNET_CADET_channel_destroy (ch);
756 * Data handlers for every message type of CADET's payload.
757 * {callback_function, message_type, size_expected}
759 static struct GNUNET_CADET_MessageHandler handlers[] = {
761 GNUNET_MESSAGE_TYPE_DUMMY,
762 sizeof (struct GNUNET_MessageHeader)},
768 * Method called whenever another peer has added us to a channel
769 * the other peer initiated.
771 * @param cls Closure.
772 * @param channel New handle to the channel.
773 * @param initiator Peer that started the channel.
774 * @param port Port this channel is connected to.
775 * @param options channel option flags
776 * @return Initial channel context for the channel
777 * (can be NULL -- that's not an error).
780 incoming_channel (void *cls,
781 struct GNUNET_CADET_Channel *channel,
782 const struct GNUNET_PeerIdentity *initiator,
783 const struct GNUNET_HashCode *port,
784 enum GNUNET_CADET_ChannelOption options)
786 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
787 "Incoming channel from %s to peer %d:%s\n",
788 GNUNET_i2s (initiator),
789 (int) (long) cls, GNUNET_h2s (port));
791 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
792 if ((long) cls == peers_requested - 1)
794 if (NULL != incoming_ch)
796 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
797 "Duplicate incoming channel for client %lu\n",
801 incoming_ch = channel;
805 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
806 "Incoming channel for unknown client %lu\n", (long) cls);
809 if (NULL != disconnect_task)
811 GNUNET_SCHEDULER_cancel (disconnect_task);
812 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
813 &gather_stats_and_exit,
822 * Function called whenever an inbound channel is destroyed. Should clean up
823 * any associated state.
825 * @param cls closure (set from GNUNET_CADET_connect, peer number)
826 * @param channel connection to the other end (henceforth invalid)
827 * @param channel_ctx place where local state associated
828 * with the channel is stored
831 channel_cleaner (void *cls,
832 const struct GNUNET_CADET_Channel *channel,
837 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
838 "Incoming channel disconnected at peer %ld\n",
840 if (peers_running - 1 == i)
843 GNUNET_break (channel == incoming_ch);
848 if (P2P_SIGNAL == test)
852 GNUNET_break (channel == ch);
856 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
857 "Unknown peer! %d\n",
859 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
861 if (NULL != disconnect_task)
863 GNUNET_SCHEDULER_cancel (disconnect_task);
864 disconnect_task = GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
871 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
873 * Testcase continues when the root receives confirmation of connected peers,
874 * on callback function ch.
876 * @param cls Closure (unused).
881 enum GNUNET_CADET_ChannelOption flags;
884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
886 if (NULL != disconnect_task)
888 GNUNET_SCHEDULER_cancel (disconnect_task);
889 disconnect_task = NULL;
892 flags = GNUNET_CADET_OPTION_DEFAULT;
893 if (SPEED_REL == test)
896 flags |= GNUNET_CADET_OPTION_RELIABLE;
899 ch = GNUNET_CADET_channel_create (h1,
906 = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
907 &gather_stats_and_exit,
909 if (KEEPALIVE == test)
910 return; /* Don't send any data. */
912 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
913 "Sending data initializer...\n");
918 th = GNUNET_CADET_notify_transmit_ready (ch,
920 GNUNET_TIME_UNIT_FOREVER_REL,
922 &tmt_rdy, (void *) 0L);
927 * Callback to be called when the requested peer information is available
929 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
930 * @param op the operation this callback corresponds to
931 * @param pinfo the result; will be NULL if the operation has failed
932 * @param emsg error message if the operation has failed;
933 * NULL if the operation is successfull
937 struct GNUNET_TESTBED_Operation *op,
938 const struct GNUNET_TESTBED_PeerInformation *pinfo,
943 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
944 "id callback for %ld\n", i);
946 if ( (NULL == pinfo) ||
949 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
950 "pi_cb: %s\n", emsg);
951 abort_test (__LINE__);
954 p_id[i] = pinfo->result.id;
955 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
956 " id: %s\n", GNUNET_i2s (p_id[i]));
960 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
961 "Got all IDs, starting test\n");
962 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
969 * test main: start test when all peers are connected
971 * @param cls Closure.
972 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
973 * @param num_peers Number of peers that are running.
974 * @param peers Array of peers.
975 * @param cadetes Handle to each of the CADETs of the peers.
979 struct GNUNET_CADET_TEST_Context *ctx,
980 unsigned int num_peers,
981 struct GNUNET_TESTBED_Peer **peers,
982 struct GNUNET_CADET_Handle **cadets)
984 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
987 peers_running = num_peers;
988 GNUNET_assert (peers_running == peers_requested);
989 testbed_peers = peers;
991 h2 = cadets[num_peers - 1];
992 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
993 &disconnect_cadet_peers,
995 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
996 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
997 GNUNET_TESTBED_PIT_IDENTITY,
998 &pi_cb, (void *) 0L);
999 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
1000 GNUNET_TESTBED_PIT_IDENTITY,
1001 &pi_cb, (void *) 1L);
1002 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
1010 main (int argc, char *argv[])
1012 initialized = GNUNET_NO;
1013 static const struct GNUNET_HashCode *ports[2];
1014 const char *config_file;
1015 char port_id[] = "test port";
1016 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
1018 GNUNET_log_setup ("test", "DEBUG", NULL);
1019 config_file = "test_cadet.conf";
1021 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
1023 /* Find out requested size */
1024 if (strstr (argv[0], "_2_") != NULL)
1026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
1027 peers_requested = 2;
1029 else if (strstr (argv[0], "_5_") != NULL)
1031 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1032 peers_requested = 5;
1036 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1037 peers_requested = 2;
1040 /* Find out requested test */
1041 if (strstr (argv[0], "_forward") != NULL)
1043 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1045 test_name = "unicast";
1048 else if (strstr (argv[0], "_signal") != NULL)
1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1052 test_name = "signal";
1055 else if (strstr (argv[0], "_speed_ack") != NULL)
1057 /* Test is supposed to generate the following callbacks:
1058 * 1 incoming channel (@dest)
1059 * TOTAL_PACKETS received data packet (@dest)
1060 * TOTAL_PACKETS received data packet (@orig)
1061 * 1 received channel destroy (@dest)
1063 ok_goal = TOTAL_PACKETS * 2 + 2;
1064 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1066 test_name = "speed ack";
1068 else if (strstr (argv[0], "_speed") != NULL)
1070 /* Test is supposed to generate the following callbacks:
1071 * 1 incoming channel (@dest)
1072 * 1 initial packet (@dest)
1073 * TOTAL_PACKETS received data packet (@dest)
1074 * 1 received data packet (@orig)
1075 * 1 received channel destroy (@dest)
1077 ok_goal = TOTAL_PACKETS + 4;
1078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1079 if (strstr (argv[0], "_reliable") != NULL)
1082 test_name = "speed reliable";
1083 config_file = "test_cadet_drop.conf";
1088 test_name = "speed";
1091 else if (strstr (argv[0], "_keepalive") != NULL)
1094 /* Test is supposed to generate the following callbacks:
1095 * 1 incoming channel (@dest)
1097 * 1 received channel destroy (@dest)
1103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1108 if (strstr (argv[0], "backwards") != NULL)
1110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1111 test_backwards = GNUNET_YES;
1112 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1118 GNUNET_CADET_TEST_run ("test_cadet_small",
1122 NULL, /* tmain cls */
1130 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1131 "FAILED! (%d/%d)\n", ok, ok_goal);
1134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1138 /* end of test_cadet.c */