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)
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)
281 long line = (long) cls;
283 const struct GNUNET_SCHEDULER_TaskContext *tc;
285 tc = GNUNET_SCHEDULER_get_task_context ();
286 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
288 "disconnecting cadet peers due to SHUTDOWN! called from %ld\n",
291 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
292 "disconnecting cadet service of peers, called from line %ld\n",
294 disconnect_task = NULL;
295 for (i = 0; i < 2; i++)
297 GNUNET_TESTBED_operation_done (t_op[i]);
303 GNUNET_CADET_notify_transmit_ready_cancel (th);
306 GNUNET_CADET_channel_destroy (ch);
309 if (NULL != incoming_ch)
311 if (NULL != incoming_th)
313 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
316 GNUNET_CADET_channel_destroy (incoming_ch);
319 GNUNET_CADET_TEST_cleanup (test_ctx);
320 if (NULL != shutdown_handle)
322 GNUNET_SCHEDULER_cancel (shutdown_handle);
324 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
330 * Stats callback. Finish the stats testbed operation and when all stats have
331 * been iterated, shutdown the test.
333 * @param cls Closure (line number from which termination was requested).
334 * @param op the operation that has been finished
335 * @param emsg error message in case the operation has failed; will be NULL if
336 * operation has executed successfully.
339 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
341 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n",
342 ka_sent, ka_received);
343 if (KEEPALIVE == test && (ka_sent < 2 || ka_sent > ka_received + 1))
345 GNUNET_TESTBED_operation_done (stats_op);
347 if (NULL != disconnect_task)
348 GNUNET_SCHEDULER_cancel (disconnect_task);
349 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, cls);
355 * Process statistic values.
357 * @param cls closure (line number, unused)
358 * @param peer the peer the statistic belong to
359 * @param subsystem name of subsystem that created the statistic
360 * @param name the name of the datum
361 * @param value the current value
362 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
363 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
366 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
367 const char *subsystem, const char *name,
368 uint64_t value, int is_persistent)
370 static const char *s_sent = "# keepalives sent";
371 static const char *s_recv = "# keepalives received";
374 i = GNUNET_TESTBED_get_index (peer);
375 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n",
376 i, subsystem, name, value);
377 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
380 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
388 * Task to gather all statistics.
390 * @param cls Closure (NULL).
393 gather_stats_and_exit (void *cls)
396 const struct GNUNET_SCHEDULER_TaskContext *tc;
398 disconnect_task = NULL;
399 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "gathering statistics from line %d\n", l);
400 tc = GNUNET_SCHEDULER_get_task_context ();
401 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
403 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
413 GNUNET_CADET_notify_transmit_ready_cancel (th);
416 GNUNET_CADET_channel_destroy (ch);
419 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
421 stats_iterator, stats_cont, cls);
427 * Abort test: schedule disconnect and shutdown immediately
429 * @param line Line in the code the abort is requested from (__LINE__).
432 abort_test (long line)
434 if (disconnect_task != NULL)
436 GNUNET_SCHEDULER_cancel (disconnect_task);
437 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting test from %ld\n", line);
438 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
444 * Transmit ready callback.
446 * @param cls Closure (message type).
447 * @param size Size of the tranmist buffer.
448 * @param buf Pointer to the beginning of the buffer.
450 * @return Number of bytes written to buf.
453 tmt_rdy (void *cls, size_t size, void *buf);
457 * Task to request a new data transmission.
459 * @param cls Closure (peer #).
462 data_task (void *cls)
464 struct GNUNET_CADET_Channel *channel;
465 static struct GNUNET_CADET_TransmitHandle **pth;
466 const struct GNUNET_SCHEDULER_TaskContext *tc;
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
470 tc = GNUNET_SCHEDULER_get_task_context ();
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).
844 enum GNUNET_CADET_ChannelOption flags;
845 const struct GNUNET_SCHEDULER_TaskContext *tc;
847 tc = GNUNET_SCHEDULER_get_task_context ();
848 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
851 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "do_test\n");
853 if (NULL != disconnect_task)
855 GNUNET_SCHEDULER_cancel (disconnect_task);
858 flags = GNUNET_CADET_OPTION_DEFAULT;
859 if (SPEED_REL == test)
862 flags |= GNUNET_CADET_OPTION_RELIABLE;
864 ch = GNUNET_CADET_channel_create (h1, NULL, p_id[1], 1, flags);
866 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
867 &gather_stats_and_exit,
869 if (KEEPALIVE == test)
870 return; /* Don't send any data. */
872 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n");
877 th = GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO,
878 GNUNET_TIME_UNIT_FOREVER_REL,
880 &tmt_rdy, (void *) 0L);
884 * Callback to be called when the requested peer information is available
886 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
887 * @param op the operation this callback corresponds to
888 * @param pinfo the result; will be NULL if the operation has failed
889 * @param emsg error message if the operation has failed;
890 * NULL if the operation is successfull
894 struct GNUNET_TESTBED_Operation *op,
895 const struct GNUNET_TESTBED_PeerInformation *pinfo,
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "id callback for %ld\n", i);
902 if (NULL == pinfo || NULL != emsg)
904 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
905 abort_test (__LINE__);
908 p_id[i] = pinfo->result.id;
909 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
913 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
914 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
919 * test main: start test when all peers are connected
921 * @param cls Closure.
922 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
923 * @param num_peers Number of peers that are running.
924 * @param peers Array of peers.
925 * @param cadetes Handle to each of the CADETs of the peers.
929 struct GNUNET_CADET_TEST_Context *ctx,
930 unsigned int num_peers,
931 struct GNUNET_TESTBED_Peer **peers,
932 struct GNUNET_CADET_Handle **cadets)
934 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
937 peers_running = num_peers;
938 GNUNET_assert (peers_running == peers_requested);
939 testbed_peers = peers;
941 h2 = cadets[num_peers - 1];
942 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
943 &disconnect_cadet_peers,
945 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
946 &shutdown_task, NULL);
947 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
948 GNUNET_TESTBED_PIT_IDENTITY,
949 &pi_cb, (void *) 0L);
950 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
951 GNUNET_TESTBED_PIT_IDENTITY,
952 &pi_cb, (void *) 1L);
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
961 main (int argc, char *argv[])
963 initialized = GNUNET_NO;
964 static uint32_t ports[2];
965 const char *config_file;
967 GNUNET_log_setup ("test", "DEBUG", NULL);
968 config_file = "test_cadet.conf";
970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
972 /* Find out requested size */
973 if (strstr (argv[0], "_2_") != NULL)
975 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
978 else if (strstr (argv[0], "_5_") != NULL)
980 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
985 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
989 /* Find out requested test */
990 if (strstr (argv[0], "_forward") != NULL)
992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
994 test_name = "unicast";
997 else if (strstr (argv[0], "_signal") != NULL)
999 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1001 test_name = "signal";
1004 else if (strstr (argv[0], "_speed_ack") != NULL)
1006 /* Test is supposed to generate the following callbacks:
1007 * 1 incoming channel (@dest)
1008 * TOTAL_PACKETS received data packet (@dest)
1009 * TOTAL_PACKETS received data packet (@orig)
1010 * 1 received channel destroy (@dest)
1012 ok_goal = TOTAL_PACKETS * 2 + 2;
1013 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1015 test_name = "speed ack";
1017 else if (strstr (argv[0], "_speed") != NULL)
1019 /* Test is supposed to generate the following callbacks:
1020 * 1 incoming channel (@dest)
1021 * 1 initial packet (@dest)
1022 * TOTAL_PACKETS received data packet (@dest)
1023 * 1 received data packet (@orig)
1024 * 1 received channel destroy (@dest)
1026 ok_goal = TOTAL_PACKETS + 4;
1027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1028 if (strstr (argv[0], "_reliable") != NULL)
1031 test_name = "speed reliable";
1032 config_file = "test_cadet_drop.conf";
1037 test_name = "speed";
1040 else if (strstr (argv[0], "_keepalive") != NULL)
1043 /* Test is supposed to generate the following callbacks:
1044 * 1 incoming channel (@dest)
1046 * 1 received channel destroy (@dest)
1052 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1057 if (strstr (argv[0], "backwards") != NULL)
1059 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1060 test_backwards = GNUNET_YES;
1061 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1067 GNUNET_CADET_TEST_run ("test_cadet_small",
1071 NULL, /* tmain cls */
1079 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1080 "FAILED! (%d/%d)\n", ok, ok_goal);
1083 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1087 /* end of test_cadet.c */