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 200 /* 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];
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 struct GNUNET_SCHEDULER_Task * disconnect_task;
150 * Task To perform tests
152 static struct GNUNET_SCHEDULER_Task * test_task;
155 * Task called to shutdown test.
157 static struct GNUNET_SCHEDULER_Task * 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 * Transmit handle for root data calls
182 static struct GNUNET_CADET_TransmitHandle *th;
185 * Transmit handle for root data calls
187 static struct GNUNET_CADET_TransmitHandle *incoming_th;
191 * Time we started the data transmission (after channel has been established
194 static struct GNUNET_TIME_Absolute start_time;
199 static struct GNUNET_TESTBED_Peer **testbed_peers;
202 * Statistics operation handle.
204 static struct GNUNET_TESTBED_Operation *stats_op;
209 static unsigned int ka_sent;
212 * Keepalives received.
214 static unsigned int ka_received;
218 * Get the client number considered as the "target" or "receiver", depending on
219 * the test type and size.
221 * @return Peer # of the target client, either 0 (for backward tests) or
222 * the last peer in the line (for other tests).
225 get_expected_target ()
227 if (SPEED == test && GNUNET_YES == test_backwards)
230 return peers_requested - 1;
234 * Show the results of the test (banwidth acheived) and log them to GAUGER
239 static struct GNUNET_TIME_Absolute end_time;
240 static struct GNUNET_TIME_Relative total_time;
242 end_time = GNUNET_TIME_absolute_get();
243 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
244 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
245 FPRINTF (stderr, "Test time %s\n",
246 GNUNET_STRINGS_relative_time_to_string (total_time,
248 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
249 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
250 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
251 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
252 GAUGER ("CADET", test_name,
253 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
259 * Shut down peergroup, clean up.
261 * @param cls Closure (unused).
262 * @param tc Task Context.
265 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
268 shutdown_handle = NULL;
273 * Disconnect from cadet services af all peers, call shutdown.
275 * @param cls Closure (line number from which termination was requested).
276 * @param tc Task Context.
279 disconnect_cadet_peers (void *cls,
280 const struct GNUNET_SCHEDULER_TaskContext *tc)
282 long line = (long) cls;
285 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
287 "disconnecting cadet peers due to SHUTDOWN! called from %ld\n",
290 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
291 "disconnecting cadet service of peers, called from line %ld\n",
293 disconnect_task = NULL;
294 for (i = 0; i < 2; i++)
296 GNUNET_TESTBED_operation_done (t_op[i]);
302 GNUNET_CADET_notify_transmit_ready_cancel (th);
305 GNUNET_CADET_channel_destroy (ch);
308 if (NULL != incoming_ch)
310 if (NULL != incoming_th)
312 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
315 GNUNET_CADET_channel_destroy (incoming_ch);
318 GNUNET_CADET_TEST_cleanup (test_ctx);
319 if (NULL != shutdown_handle)
321 GNUNET_SCHEDULER_cancel (shutdown_handle);
323 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
329 * Stats callback. Finish the stats testbed operation and when all stats have
330 * been iterated, shutdown the test.
332 * @param cls Closure (line number from which termination was requested).
333 * @param op the operation that has been finished
334 * @param emsg error message in case the operation has failed; will be NULL if
335 * operation has executed successfully.
338 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
340 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n",
341 ka_sent, ka_received);
342 if (KEEPALIVE == test && (ka_sent < 2 || ka_sent > ka_received + 1))
344 GNUNET_TESTBED_operation_done (stats_op);
346 if (NULL != disconnect_task)
347 GNUNET_SCHEDULER_cancel (disconnect_task);
348 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, cls);
354 * Process statistic values.
356 * @param cls closure (line number, unused)
357 * @param peer the peer the statistic belong to
358 * @param subsystem name of subsystem that created the statistic
359 * @param name the name of the datum
360 * @param value the current value
361 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
362 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
365 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
366 const char *subsystem, const char *name,
367 uint64_t value, int is_persistent)
369 static const char *s_sent = "# keepalives sent";
370 static const char *s_recv = "# keepalives received";
373 i = GNUNET_TESTBED_get_index (peer);
374 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n",
375 i, subsystem, name, value);
376 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
379 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
387 * Task to gather all statistics.
389 * @param cls Closure (NULL).
390 * @param tc Task Context.
393 gather_stats_and_exit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
395 disconnect_task = NULL;
398 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "gathering statistics from line %d\n", l);
400 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
402 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
412 GNUNET_CADET_notify_transmit_ready_cancel (th);
415 GNUNET_CADET_channel_destroy (ch);
418 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
420 stats_iterator, stats_cont, cls);
426 * Abort test: schedule disconnect and shutdown immediately
428 * @param line Line in the code the abort is requested from (__LINE__).
431 abort_test (long line)
433 if (disconnect_task != NULL)
435 GNUNET_SCHEDULER_cancel (disconnect_task);
436 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting test from %ld\n", line);
437 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
443 * Transmit ready callback.
445 * @param cls Closure (message type).
446 * @param size Size of the tranmist buffer.
447 * @param buf Pointer to the beginning of the buffer.
449 * @return Number of bytes written to buf.
452 tmt_rdy (void *cls, size_t size, void *buf);
456 * Task to request a new data transmission.
458 * @param cls Closure (peer #).
459 * @param tc Task Context.
462 data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
464 struct GNUNET_CADET_Channel *channel;
465 static struct GNUNET_CADET_TransmitHandle **pth;
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
471 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
474 if (GNUNET_YES == test_backwards)
476 channel = incoming_ch;
478 src = peers_requested - 1;
487 GNUNET_assert (NULL != channel);
488 GNUNET_assert (NULL == *pth);
490 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
491 GNUNET_TIME_UNIT_FOREVER_REL,
492 size_payload + data_sent,
493 &tmt_rdy, (void *) src);
496 unsigned long i = (unsigned long) cls;
498 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Retransmission\n");
501 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n");
502 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
503 &data_task, (void *) 1L);
508 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "in %u ms\n", i);
509 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
510 GNUNET_TIME_UNIT_MILLISECONDS,
512 &data_task, (void *) i);
519 * Transmit ready callback
521 * @param cls Closure (peer # which is sending the data).
522 * @param size Size of the buffer we have.
523 * @param buf Buffer to copy data to.
526 tmt_rdy (void *cls, size_t size, void *buf)
528 struct GNUNET_MessageHeader *msg = buf;
531 long id = (long) cls;
532 unsigned int counter;
534 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy on %ld, filling buffer\n", id);
537 else if ((peers_requested - 1) == id)
541 counter = get_expected_target () == id ? ack_sent : data_sent;
542 msg_size = size_payload + counter;
543 if (size < msg_size || NULL == buf)
545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
546 "size %u, buf %p, data_sent %u, ack_received %u\n",
547 size, buf, data_sent, ack_received);
548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
549 GNUNET_break (ok >= ok_goal - 2);
553 msg->size = htons (msg_size);
554 msg->type = htons (1);
555 data = (uint32_t *) &msg[1];
556 *data = htonl (counter);
557 if (GNUNET_NO == initialized)
559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n");
560 msg_size = size_payload + 1000;
561 if (SPEED_ACK == test)
564 else if (SPEED == test || SPEED_ACK == test)
566 if (get_expected_target() == id)
571 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " Sent message %d size %u\n",
573 if (data_sent < TOTAL_PACKETS && SPEED == test)
575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n",
577 GNUNET_SCHEDULER_add_now (&data_task, NULL);
586 * Function is called whenever a message is received.
588 * @param cls closure (set from GNUNET_CADET_connect, peer number)
589 * @param channel connection to the other end
590 * @param channel_ctx place to store local state associated with the channel
591 * @param message the actual message
592 * @return GNUNET_OK to keep the connection open,
593 * GNUNET_SYSERR to close it (signal serious error)
596 data_callback (void *cls, struct GNUNET_CADET_Channel *channel,
598 const struct GNUNET_MessageHeader *message)
600 struct GNUNET_CADET_TransmitHandle **pth;
601 long client = (long) cls;
602 long expected_target_client;
605 unsigned int counter;
608 counter = get_expected_target () == client ? data_received : ack_received;
610 GNUNET_CADET_receive_done (channel);
614 if (NULL != disconnect_task)
616 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " reschedule timeout\n");
617 GNUNET_SCHEDULER_cancel (disconnect_task);
618 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
619 &gather_stats_and_exit,
627 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
628 GNUNET_assert (channel == ch);
633 GNUNET_assert (client == peers_requested - 1);
634 GNUNET_assert (channel == incoming_ch);
636 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client %ld got a message.\n",
640 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %ld not valid.\n", client);
643 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
644 data = (uint32_t *) &message[1];
645 payload = ntohl (*data);
646 if (payload == counter)
648 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
652 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " payload %u, expected: %u\n",
655 expected_target_client = get_expected_target ();
657 if (GNUNET_NO == initialized)
659 initialized = GNUNET_YES;
660 start_time = GNUNET_TIME_absolute_get ();
663 GNUNET_assert (peers_requested - 1 == client);
664 GNUNET_SCHEDULER_add_now (&data_task, NULL);
670 if (client == expected_target_client) /* Normally 4 */
673 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
674 if (SPEED != test || (ok_goal - 2) == ok)
677 GNUNET_assert (NULL == *pth);
678 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
679 GNUNET_TIME_UNIT_FOREVER_REL,
680 size_payload + ack_sent,
681 &tmt_rdy, (void *) client);
686 if (data_received < TOTAL_PACKETS)
690 else /* Normally 0 */
692 if (SPEED_ACK == test || SPEED == test)
695 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
697 GNUNET_assert (NULL == *pth);
698 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
699 GNUNET_TIME_UNIT_FOREVER_REL,
700 size_payload + data_sent,
701 &tmt_rdy, (void *) client);
702 if (ack_received < TOTAL_PACKETS && SPEED != test)
704 if (ok == 2 && SPEED == test)
708 if (test == P2P_SIGNAL)
710 if (NULL != incoming_th)
712 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
715 GNUNET_CADET_channel_destroy (incoming_ch);
722 GNUNET_CADET_notify_transmit_ready_cancel (th);
725 GNUNET_CADET_channel_destroy (ch);
735 * Data handlers for every message type of CADET's payload.
736 * {callback_function, message_type, size_expected}
738 static struct GNUNET_CADET_MessageHandler handlers[] = {
739 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
745 * Method called whenever another peer has added us to a channel
746 * the other peer initiated.
748 * @param cls Closure.
749 * @param channel New handle to the channel.
750 * @param initiator Peer that started the channel.
751 * @param port Port this channel is connected to.
752 * @param options channel option flags
753 * @return Initial channel context for the channel
754 * (can be NULL -- that's not an error).
757 incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel,
758 const struct GNUNET_PeerIdentity *initiator,
759 uint32_t port, enum GNUNET_CADET_ChannelOption options)
761 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
762 "Incoming channel from %s to peer %d\n",
763 GNUNET_i2s (initiator), (long) cls);
765 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
766 if ((long) cls == peers_requested - 1)
767 incoming_ch = channel;
770 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
771 "Incoming channel for unknown client %lu\n", (long) cls);
774 if (NULL != disconnect_task)
776 GNUNET_SCHEDULER_cancel (disconnect_task);
777 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
778 &gather_stats_and_exit,
786 * Function called whenever an inbound channel is destroyed. Should clean up
787 * any associated state.
789 * @param cls closure (set from GNUNET_CADET_connect, peer number)
790 * @param channel connection to the other end (henceforth invalid)
791 * @param channel_ctx place where local state associated
792 * with the channel is stored
795 channel_cleaner (void *cls, const struct GNUNET_CADET_Channel *channel,
800 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
801 "Incoming channel disconnected at peer %ld\n", i);
802 if (peers_running - 1 == i)
805 GNUNET_break (channel == incoming_ch);
810 if (P2P_SIGNAL == test)
814 GNUNET_break (channel == ch);
818 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
819 "Unknown peer! %d\n", i);
820 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
822 if (NULL != disconnect_task)
824 GNUNET_SCHEDULER_cancel (disconnect_task);
825 disconnect_task = GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
834 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
836 * Testcase continues when the root receives confirmation of connected peers,
837 * on callback function ch.
839 * @param cls Closure (unused).
840 * @param tc Task Context.
843 do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
845 enum GNUNET_CADET_ChannelOption flags;
847 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
850 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "do_test\n");
852 if (NULL != disconnect_task)
854 GNUNET_SCHEDULER_cancel (disconnect_task);
857 flags = GNUNET_CADET_OPTION_DEFAULT;
858 if (SPEED_REL == test)
861 flags |= GNUNET_CADET_OPTION_RELIABLE;
863 ch = GNUNET_CADET_channel_create (h1, NULL, p_id[1], 1, flags);
865 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
866 &gather_stats_and_exit,
868 if (KEEPALIVE == test)
869 return; /* Don't send any data. */
871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n");
876 th = GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO,
877 GNUNET_TIME_UNIT_FOREVER_REL,
879 &tmt_rdy, (void *) 0L);
883 * Callback to be called when the requested peer information is available
885 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
886 * @param op the operation this callback corresponds to
887 * @param pinfo the result; will be NULL if the operation has failed
888 * @param emsg error message if the operation has failed;
889 * NULL if the operation is successfull
893 struct GNUNET_TESTBED_Operation *op,
894 const struct GNUNET_TESTBED_PeerInformation *pinfo,
899 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "id callback for %ld\n", i);
901 if (NULL == pinfo || NULL != emsg)
903 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
904 abort_test (__LINE__);
907 p_id[i] = pinfo->result.id;
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
912 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
913 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
918 * test main: start test when all peers are connected
920 * @param cls Closure.
921 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
922 * @param num_peers Number of peers that are running.
923 * @param peers Array of peers.
924 * @param cadetes Handle to each of the CADETs of the peers.
928 struct GNUNET_CADET_TEST_Context *ctx,
929 unsigned int num_peers,
930 struct GNUNET_TESTBED_Peer **peers,
931 struct GNUNET_CADET_Handle **cadets)
933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
936 peers_running = num_peers;
937 GNUNET_assert (peers_running == peers_requested);
938 testbed_peers = peers;
940 h2 = cadets[num_peers - 1];
941 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
942 &disconnect_cadet_peers,
944 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
945 &shutdown_task, NULL);
946 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
947 GNUNET_TESTBED_PIT_IDENTITY,
948 &pi_cb, (void *) 0L);
949 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
950 GNUNET_TESTBED_PIT_IDENTITY,
951 &pi_cb, (void *) 1L);
952 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
960 main (int argc, char *argv[])
962 initialized = GNUNET_NO;
963 static uint32_t ports[2];
964 const char *config_file;
966 GNUNET_log_setup ("test", "DEBUG", NULL);
967 config_file = "test_cadet.conf";
969 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
971 /* Find out requested size */
972 if (strstr (argv[0], "_2_") != NULL)
974 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
977 else if (strstr (argv[0], "_5_") != NULL)
979 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
984 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
988 /* Find out requested test */
989 if (strstr (argv[0], "_forward") != NULL)
991 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
993 test_name = "unicast";
996 else if (strstr (argv[0], "_signal") != NULL)
998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1000 test_name = "signal";
1003 else if (strstr (argv[0], "_speed_ack") != NULL)
1005 /* Test is supposed to generate the following callbacks:
1006 * 1 incoming channel (@dest)
1007 * TOTAL_PACKETS received data packet (@dest)
1008 * TOTAL_PACKETS received data packet (@orig)
1009 * 1 received channel destroy (@dest)
1011 ok_goal = TOTAL_PACKETS * 2 + 2;
1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1014 test_name = "speed ack";
1016 else if (strstr (argv[0], "_speed") != NULL)
1018 /* Test is supposed to generate the following callbacks:
1019 * 1 incoming channel (@dest)
1020 * 1 initial packet (@dest)
1021 * TOTAL_PACKETS received data packet (@dest)
1022 * 1 received data packet (@orig)
1023 * 1 received channel destroy (@dest)
1025 ok_goal = TOTAL_PACKETS + 4;
1026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1027 if (strstr (argv[0], "_reliable") != NULL)
1030 test_name = "speed reliable";
1031 config_file = "test_cadet_drop.conf";
1036 test_name = "speed";
1039 else if (strstr (argv[0], "_keepalive") != NULL)
1042 /* Test is supposed to generate the following callbacks:
1043 * 1 incoming channel (@dest)
1045 * 1 received channel destroy (@dest)
1051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1056 if (strstr (argv[0], "backwards") != NULL)
1058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1059 test_backwards = GNUNET_YES;
1060 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1066 GNUNET_CADET_TEST_run ("test_cadet_small",
1070 NULL, /* tmain cls */
1078 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1079 "FAILED! (%d/%d)\n", ok, ok_goal);
1082 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1086 /* end of test_cadet.c */