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: retransmission of traffic.
28 #include "cadet_test_lib.h"
29 #include "gnunet_cadet_service.h"
30 #include "gnunet_statistics_service.h"
35 * How many messages to send
37 #define TOTAL_PACKETS 500 /* Cannot exceed 64k! */
40 * How long until we give up on connecting the peers?
42 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
45 * Time to wait for stuff that should be rather fast
47 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
50 * DIFFERENT TESTS TO RUN
61 * Which test are we running?
66 * String with test name
68 static char *test_name;
71 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
73 static int test_backwards = GNUNET_NO;
76 * How many events have happened
81 * Number of events expected to conclude the test successfully.
86 * Size of each test packet
88 static size_t size_payload = sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t);
91 * Operation to get peer ids.
93 static struct GNUNET_TESTBED_Operation *t_op[2];
98 static struct GNUNET_PeerIdentity *p_id[2];
103 static struct GNUNET_HashCode port;
108 static unsigned int p_ids;
111 * Is the setup initialized?
113 static int initialized;
116 * Number of payload packes sent.
118 static int data_sent;
121 * Number of payload packets received.
123 static int data_received;
126 * Number of payload packed acknowledgements sent.
131 * Number of payload packed explicitly (app level) acknowledged.
133 static int ack_received;
136 * Total number of peers asked to run.
138 static unsigned long long peers_requested;
141 * Number of currently running peers (should be same as @c peers_requested).
143 static unsigned long long peers_running;
146 * Test context (to shut down).
148 struct GNUNET_CADET_TEST_Context *test_ctx;
151 * Task called to disconnect peers.
153 static struct GNUNET_SCHEDULER_Task *disconnect_task;
156 * Task To perform tests
158 static struct GNUNET_SCHEDULER_Task *test_task;
161 * Task runnining #data_task().
163 static struct GNUNET_SCHEDULER_Task *data_job;
166 * Cadet handle for the root peer
168 static struct GNUNET_CADET_Handle *h1;
171 * Cadet handle for the first leaf peer
173 static struct GNUNET_CADET_Handle *h2;
176 * Channel handle for the root peer
178 static struct GNUNET_CADET_Channel *ch;
181 * Channel handle for the dest peer
183 static struct GNUNET_CADET_Channel *incoming_ch;
186 * Transmit handle for root data calls
188 static struct GNUNET_CADET_TransmitHandle *th;
191 * Transmit handle for root data calls
193 static struct GNUNET_CADET_TransmitHandle *incoming_th;
197 * Time we started the data transmission (after channel has been established
200 static struct GNUNET_TIME_Absolute start_time;
205 static struct GNUNET_TESTBED_Peer **testbed_peers;
208 * Statistics operation handle.
210 static struct GNUNET_TESTBED_Operation *stats_op;
215 static unsigned int ka_sent;
218 * Keepalives received.
220 static unsigned int ka_received;
223 * How many messages were dropped by CADET because of full buffers?
225 static unsigned int msg_dropped;
229 * Get the client number considered as the "target" or "receiver", depending on
230 * the test type and size.
232 * @return Peer # of the target client, either 0 (for backward tests) or
233 * the last peer in the line (for other tests).
236 get_expected_target ()
238 if (SPEED == test && GNUNET_YES == test_backwards)
241 return peers_requested - 1;
246 * Show the results of the test (banwidth acheived) and log them to GAUGER
251 static struct GNUNET_TIME_Absolute end_time;
252 static struct GNUNET_TIME_Relative total_time;
254 end_time = GNUNET_TIME_absolute_get();
255 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
256 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
257 FPRINTF (stderr, "Test time %s\n",
258 GNUNET_STRINGS_relative_time_to_string (total_time,
260 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
261 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
262 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
263 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
264 GAUGER ("CADET", test_name,
265 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
271 * Disconnect from cadet services af all peers, call shutdown.
273 * @param cls Closure (line number from which termination was requested).
274 * @param tc Task Context.
277 disconnect_cadet_peers (void *cls)
279 long line = (long) cls;
282 disconnect_task = NULL;
283 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
284 "disconnecting cadet service of peers, called from line %ld\n",
286 for (i = 0; i < 2; i++)
288 GNUNET_TESTBED_operation_done (t_op[i]);
294 GNUNET_CADET_notify_transmit_ready_cancel (th);
297 GNUNET_CADET_channel_destroy (ch);
300 if (NULL != incoming_ch)
302 if (NULL != incoming_th)
304 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
307 GNUNET_CADET_channel_destroy (incoming_ch);
310 GNUNET_CADET_TEST_cleanup (test_ctx);
311 GNUNET_SCHEDULER_shutdown ();
316 * Shut down peergroup, clean up.
318 * @param cls Closure (unused).
319 * @param tc Task Context.
322 shutdown_task (void *cls)
324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
325 if (NULL != data_job)
327 GNUNET_SCHEDULER_cancel (data_job);
330 if (NULL != test_task)
332 GNUNET_SCHEDULER_cancel (test_task);
335 if (NULL != disconnect_task)
337 GNUNET_SCHEDULER_cancel (disconnect_task);
338 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
345 * Stats callback. Finish the stats testbed operation and when all stats have
346 * been iterated, shutdown the test.
348 * @param cls Closure (line number from which termination was requested).
349 * @param op the operation that has been finished
350 * @param emsg error message in case the operation has failed; will be NULL if
351 * operation has executed successfully.
354 stats_cont (void *cls,
355 struct GNUNET_TESTBED_Operation *op,
358 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
359 " KA sent: %u, KA received: %u\n",
362 if ( (KEEPALIVE == test) &&
364 (ka_sent > ka_received + 1)) )
369 GNUNET_TESTBED_operation_done (stats_op);
371 if (NULL != disconnect_task)
372 GNUNET_SCHEDULER_cancel (disconnect_task);
373 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
379 * Process statistic values.
381 * @param cls closure (line number, unused)
382 * @param peer the peer the statistic belong to
383 * @param subsystem name of subsystem that created the statistic
384 * @param name the name of the datum
385 * @param value the current value
386 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
387 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
390 stats_iterator (void *cls,
391 const struct GNUNET_TESTBED_Peer *peer,
392 const char *subsystem,
397 static const char *s_sent = "# keepalives sent";
398 static const char *s_recv = "# keepalives received";
399 static const char *rdrops = "# messages dropped due to full buffer";
400 static const char *cdrops = "# messages dropped due to slow client";
403 i = GNUNET_TESTBED_get_index (peer);
404 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
405 "STATS PEER %u - %s [%s]: %llu\n",
409 (unsigned long long) value);
410 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
412 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
414 if (0 == strncmp(rdrops, name, strlen (rdrops)))
415 msg_dropped += value;
416 if (0 == strncmp(cdrops, name, strlen (cdrops)))
417 msg_dropped += value;
424 * Task to gather all statistics.
426 * @param cls Closure (NULL).
429 gather_stats_and_exit (void *cls)
433 disconnect_task = NULL;
434 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
435 "gathering statistics from line %d\n",
441 GNUNET_CADET_notify_transmit_ready_cancel (th);
444 GNUNET_CADET_channel_destroy (ch);
447 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
449 &stats_iterator, stats_cont, cls);
455 * Abort test: schedule disconnect and shutdown immediately
457 * @param line Line in the code the abort is requested from (__LINE__).
460 abort_test (long line)
462 if (NULL != disconnect_task)
464 GNUNET_SCHEDULER_cancel (disconnect_task);
465 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
466 "Aborting test from %ld\n", line);
467 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
473 * Transmit ready callback.
475 * @param cls Closure (message type).
476 * @param size Size of the tranmist buffer.
477 * @param buf Pointer to the beginning of the buffer.
479 * @return Number of bytes written to buf.
482 tmt_rdy (void *cls, size_t size, void *buf);
486 * Task to request a new data transmission.
488 * @param cls Closure (peer #).
491 data_task (void *cls)
493 struct GNUNET_CADET_Channel *channel;
494 static struct GNUNET_CADET_TransmitHandle **pth;
498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
499 if (GNUNET_YES == test_backwards)
501 channel = incoming_ch;
503 src = peers_requested - 1;
512 GNUNET_assert (NULL != channel);
513 GNUNET_assert (NULL == *pth);
515 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
516 GNUNET_TIME_UNIT_FOREVER_REL,
517 size_payload + data_sent,
518 &tmt_rdy, (void *) src);
521 unsigned long i = (unsigned long) cls;
523 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Retransmission\n");
526 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n");
527 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
528 &data_task, (void *) 1L);
533 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
535 (unsigned long long) i);
536 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
538 &data_task, (void *) i);
545 * Transmit ready callback
547 * @param cls Closure (peer # which is sending the data).
548 * @param size Size of the buffer we have.
549 * @param buf Buffer to copy data to.
552 tmt_rdy (void *cls, size_t size, void *buf)
554 struct GNUNET_MessageHeader *msg = buf;
557 long id = (long) cls;
558 unsigned int counter;
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 "tmt_rdy on %ld, filling buffer\n",
565 else if ((peers_requested - 1) == id)
569 counter = get_expected_target () == id ? ack_sent : data_sent;
570 msg_size = size_payload + counter;
571 GNUNET_assert (msg_size > sizeof (struct GNUNET_MessageHeader));
572 if ( (size < msg_size) ||
575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
576 "size %u, buf %p, data_sent %u, ack_received %u\n",
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
582 GNUNET_break (ok >= ok_goal - 2);
586 msg->size = htons (msg_size);
587 msg->type = htons (GNUNET_MESSAGE_TYPE_DUMMY);
588 data = (uint32_t *) &msg[1];
589 *data = htonl (counter);
590 if (GNUNET_NO == initialized)
592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
593 "sending initializer\n");
594 msg_size = size_payload + 1000;
595 msg->size = htons (msg_size);
596 if (SPEED_ACK == test)
599 else if ( (SPEED == test) ||
600 (SPEED_ACK == test) )
602 if (get_expected_target() == id)
607 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
608 " Sent message %u size %u\n",
610 (unsigned int) msg_size);
611 if ( (data_sent < TOTAL_PACKETS) &&
614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
615 " Scheduling message %d\n",
617 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
626 * Function is called whenever a message is received.
628 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
629 * @param channel connection to the other end
630 * @param channel_ctx place to store local state associated with the channel
631 * @param message the actual message
632 * @return #GNUNET_OK to keep the connection open,
633 * #GNUNET_SYSERR to close it (signal serious error)
636 data_callback (void *cls,
637 struct GNUNET_CADET_Channel *channel,
639 const struct GNUNET_MessageHeader *message)
641 struct GNUNET_CADET_TransmitHandle **pth;
642 long client = (long) cls;
643 long expected_target_client;
646 unsigned int counter;
649 counter = get_expected_target () == client ? data_received : ack_received;
651 GNUNET_CADET_receive_done (channel);
655 if (NULL != disconnect_task)
657 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
658 " reschedule timeout\n");
659 GNUNET_SCHEDULER_cancel (disconnect_task);
660 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
661 &gather_stats_and_exit,
669 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
670 GNUNET_assert (channel == ch);
675 GNUNET_assert (client == peers_requested - 1);
676 GNUNET_assert (channel == incoming_ch);
678 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client %ld got a message.\n",
682 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %ld not valid.\n", client);
685 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
686 data = (uint32_t *) &message[1];
687 payload = ntohl (*data);
688 if (payload == counter)
690 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
694 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " payload %u, expected: %u\n",
697 expected_target_client = get_expected_target ();
699 if (GNUNET_NO == initialized)
701 initialized = GNUNET_YES;
702 start_time = GNUNET_TIME_absolute_get ();
705 GNUNET_assert (peers_requested - 1 == client);
706 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
712 if (client == expected_target_client) /* Normally 4 */
715 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
716 if (SPEED != test || (ok_goal - 2) == ok)
719 GNUNET_assert (NULL == *pth);
720 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
721 GNUNET_TIME_UNIT_FOREVER_REL,
722 size_payload + ack_sent,
723 &tmt_rdy, (void *) client);
728 if (data_received < TOTAL_PACKETS)
732 else /* Normally 0 */
734 if (SPEED_ACK == test || SPEED == test)
737 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
739 GNUNET_assert (NULL == *pth);
740 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
741 GNUNET_TIME_UNIT_FOREVER_REL,
742 size_payload + data_sent,
743 &tmt_rdy, (void *) client);
744 if (ack_received < TOTAL_PACKETS && SPEED != test)
746 if (ok == 2 && SPEED == test)
750 if (test == P2P_SIGNAL)
752 if (NULL != incoming_th)
754 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
757 GNUNET_CADET_channel_destroy (incoming_ch);
764 GNUNET_CADET_notify_transmit_ready_cancel (th);
767 GNUNET_CADET_channel_destroy (ch);
777 * Data handlers for every message type of CADET's payload.
778 * {callback_function, message_type, size_expected}
780 static struct GNUNET_CADET_MessageHandler handlers[] = {
782 GNUNET_MESSAGE_TYPE_DUMMY,
783 sizeof (struct GNUNET_MessageHeader)},
789 * Method called whenever another peer has added us to a channel
790 * the other peer initiated.
792 * @param cls Closure.
793 * @param channel New handle to the channel.
794 * @param initiator Peer that started the channel.
795 * @param port Port this channel is connected to.
796 * @param options channel option flags
797 * @return Initial channel context for the channel
798 * (can be NULL -- that's not an error).
801 incoming_channel (void *cls,
802 struct GNUNET_CADET_Channel *channel,
803 const struct GNUNET_PeerIdentity *initiator,
804 const struct GNUNET_HashCode *port,
805 enum GNUNET_CADET_ChannelOption options)
807 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
808 "Incoming channel from %s to peer %d:%s\n",
809 GNUNET_i2s (initiator),
810 (int) (long) cls, GNUNET_h2s (port));
812 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
813 if ((long) cls == peers_requested - 1)
815 if (NULL != incoming_ch)
817 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
818 "Duplicate incoming channel for client %lu\n",
822 incoming_ch = channel;
826 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
827 "Incoming channel for unexpected peer #%lu\n",
831 if (NULL != disconnect_task)
833 GNUNET_SCHEDULER_cancel (disconnect_task);
834 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
835 &gather_stats_and_exit,
844 * Function called whenever an inbound channel is destroyed. Should clean up
845 * any associated state.
847 * @param cls closure (set from GNUNET_CADET_connect, peer number)
848 * @param channel connection to the other end (henceforth invalid)
849 * @param channel_ctx place where local state associated
850 * with the channel is stored
853 channel_cleaner (void *cls,
854 const struct GNUNET_CADET_Channel *channel,
859 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
860 "Incoming channel disconnected at peer %ld\n",
862 if (peers_running - 1 == i)
865 GNUNET_break (channel == incoming_ch);
870 if (P2P_SIGNAL == test)
874 GNUNET_break (channel == ch);
878 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
879 "Unknown peer! %d\n",
881 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
883 if (NULL != disconnect_task)
885 GNUNET_SCHEDULER_cancel (disconnect_task);
886 disconnect_task = GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
893 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
895 * Testcase continues when the root receives confirmation of connected peers,
896 * on callback function ch.
898 * @param cls Closure (unused).
903 enum GNUNET_CADET_ChannelOption flags;
906 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
908 if (NULL != disconnect_task)
910 GNUNET_SCHEDULER_cancel (disconnect_task);
911 disconnect_task = NULL;
914 flags = GNUNET_CADET_OPTION_DEFAULT;
915 if (SPEED_REL == test)
918 flags |= GNUNET_CADET_OPTION_RELIABLE;
921 ch = GNUNET_CADET_channel_create (h1,
928 = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
929 &gather_stats_and_exit,
931 if (KEEPALIVE == test)
932 return; /* Don't send any data. */
934 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
935 "Sending data initializer...\n");
940 th = GNUNET_CADET_notify_transmit_ready (ch,
942 GNUNET_TIME_UNIT_FOREVER_REL,
944 &tmt_rdy, (void *) 0L);
949 * Callback to be called when the requested peer information is available
951 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
952 * @param op the operation this callback corresponds to
953 * @param pinfo the result; will be NULL if the operation has failed
954 * @param emsg error message if the operation has failed;
955 * NULL if the operation is successfull
959 struct GNUNET_TESTBED_Operation *op,
960 const struct GNUNET_TESTBED_PeerInformation *pinfo,
965 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
966 "id callback for %ld\n", i);
968 if ( (NULL == pinfo) ||
971 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
972 "pi_cb: %s\n", emsg);
973 abort_test (__LINE__);
976 p_id[i] = pinfo->result.id;
977 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
978 " id: %s\n", GNUNET_i2s (p_id[i]));
982 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
983 "Got all IDs, starting test\n");
984 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
991 * test main: start test when all peers are connected
993 * @param cls Closure.
994 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
995 * @param num_peers Number of peers that are running.
996 * @param peers Array of peers.
997 * @param cadetes Handle to each of the CADETs of the peers.
1001 struct GNUNET_CADET_TEST_Context *ctx,
1002 unsigned int num_peers,
1003 struct GNUNET_TESTBED_Peer **peers,
1004 struct GNUNET_CADET_Handle **cadets)
1006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
1009 peers_running = num_peers;
1010 GNUNET_assert (peers_running == peers_requested);
1011 testbed_peers = peers;
1013 h2 = cadets[num_peers - 1];
1014 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
1015 &disconnect_cadet_peers,
1017 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
1018 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
1019 GNUNET_TESTBED_PIT_IDENTITY,
1020 &pi_cb, (void *) 0L);
1021 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
1022 GNUNET_TESTBED_PIT_IDENTITY,
1023 &pi_cb, (void *) 1L);
1024 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
1032 main (int argc, char *argv[])
1034 initialized = GNUNET_NO;
1035 static const struct GNUNET_HashCode *ports[2];
1036 const char *config_file;
1037 char port_id[] = "test port";
1038 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
1040 GNUNET_log_setup ("test", "DEBUG", NULL);
1041 config_file = "test_cadet.conf";
1043 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
1045 /* Find out requested size */
1046 if (strstr (argv[0], "_2_") != NULL)
1048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
1049 peers_requested = 2;
1051 else if (strstr (argv[0], "_5_") != NULL)
1053 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1054 peers_requested = 5;
1058 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1059 peers_requested = 2;
1062 /* Find out requested test */
1063 if (strstr (argv[0], "_forward") != NULL)
1065 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1067 test_name = "unicast";
1070 else if (strstr (argv[0], "_signal") != NULL)
1072 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1074 test_name = "signal";
1077 else if (strstr (argv[0], "_speed_ack") != NULL)
1079 /* Test is supposed to generate the following callbacks:
1080 * 1 incoming channel (@dest)
1081 * TOTAL_PACKETS received data packet (@dest)
1082 * TOTAL_PACKETS received data packet (@orig)
1083 * 1 received channel destroy (@dest)
1085 ok_goal = TOTAL_PACKETS * 2 + 2;
1086 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1088 test_name = "speed ack";
1090 else if (strstr (argv[0], "_speed") != NULL)
1092 /* Test is supposed to generate the following callbacks:
1093 * 1 incoming channel (@dest)
1094 * 1 initial packet (@dest)
1095 * TOTAL_PACKETS received data packet (@dest)
1096 * 1 received data packet (@orig)
1097 * 1 received channel destroy (@dest)
1099 ok_goal = TOTAL_PACKETS + 4;
1100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1101 if (strstr (argv[0], "_reliable") != NULL)
1104 test_name = "speed reliable";
1105 config_file = "test_cadet_drop.conf";
1110 test_name = "speed";
1113 else if (strstr (argv[0], "_keepalive") != NULL)
1116 /* Test is supposed to generate the following callbacks:
1117 * 1 incoming channel (@dest)
1119 * 1 received channel destroy (@dest)
1125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1130 if (strstr (argv[0], "backwards") != NULL)
1132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1133 test_backwards = GNUNET_YES;
1134 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1140 GNUNET_CADET_TEST_run ("test_cadet_small",
1144 NULL, /* tmain cls */
1149 if (NULL != strstr (argv[0], "_reliable"))
1150 msg_dropped = 0; /* dropped should be retransmitted */
1152 if (ok_goal > ok - msg_dropped)
1154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1155 "FAILED! (%d/%d)\n", ok, ok_goal);
1158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1162 /* end of test_cadet.c */