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 * @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
67 static char *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 static size_t size_payload = sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t);
90 * Operation to get peer ids.
92 static struct GNUNET_TESTBED_Operation *t_op[2];
97 static struct GNUNET_PeerIdentity *p_id[2];
102 static struct GNUNET_HashCode port;
107 static unsigned int p_ids;
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;
222 * How many messages were dropped by CADET because of full buffers?
224 static unsigned int msg_dropped;
228 * Get the client number considered as the "target" or "receiver", depending on
229 * the test type and size.
231 * @return Peer # of the target client, either 0 (for backward tests) or
232 * the last peer in the line (for other tests).
235 get_expected_target ()
237 if (SPEED == test && GNUNET_YES == test_backwards)
240 return peers_requested - 1;
245 * Show the results of the test (banwidth acheived) and log them to GAUGER
250 static struct GNUNET_TIME_Absolute end_time;
251 static struct GNUNET_TIME_Relative total_time;
253 end_time = GNUNET_TIME_absolute_get();
254 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
255 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
256 FPRINTF (stderr, "Test time %s\n",
257 GNUNET_STRINGS_relative_time_to_string (total_time,
259 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
260 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
261 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
262 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
263 GAUGER ("CADET", test_name,
264 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
270 * Disconnect from cadet services af all peers, call shutdown.
272 * @param cls Closure (line number from which termination was requested).
273 * @param tc Task Context.
276 disconnect_cadet_peers (void *cls)
278 long line = (long) cls;
281 disconnect_task = NULL;
282 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
283 "disconnecting cadet service of peers, called from line %ld\n",
285 for (i = 0; i < 2; i++)
287 GNUNET_TESTBED_operation_done (t_op[i]);
293 GNUNET_CADET_notify_transmit_ready_cancel (th);
296 GNUNET_CADET_channel_destroy (ch);
299 if (NULL != incoming_ch)
301 if (NULL != incoming_th)
303 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
306 GNUNET_CADET_channel_destroy (incoming_ch);
309 GNUNET_CADET_TEST_cleanup (test_ctx);
310 GNUNET_SCHEDULER_shutdown ();
315 * Shut down peergroup, clean up.
317 * @param cls Closure (unused).
318 * @param tc Task Context.
321 shutdown_task (void *cls)
323 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
324 if (NULL != data_job)
326 GNUNET_SCHEDULER_cancel (data_job);
329 if (NULL != test_task)
331 GNUNET_SCHEDULER_cancel (test_task);
334 if (NULL != disconnect_task)
336 GNUNET_SCHEDULER_cancel (disconnect_task);
337 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
344 * Stats callback. Finish the stats testbed operation and when all stats have
345 * been iterated, shutdown the test.
347 * @param cls Closure (line number from which termination was requested).
348 * @param op the operation that has been finished
349 * @param emsg error message in case the operation has failed; will be NULL if
350 * operation has executed successfully.
353 stats_cont (void *cls,
354 struct GNUNET_TESTBED_Operation *op,
357 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
358 " KA sent: %u, KA received: %u\n",
361 if ( (KEEPALIVE == test) &&
363 (ka_sent > ka_received + 1)) )
368 GNUNET_TESTBED_operation_done (stats_op);
370 if (NULL != disconnect_task)
371 GNUNET_SCHEDULER_cancel (disconnect_task);
372 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
378 * Process statistic values.
380 * @param cls closure (line number, unused)
381 * @param peer the peer the statistic belong to
382 * @param subsystem name of subsystem that created the statistic
383 * @param name the name of the datum
384 * @param value the current value
385 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
386 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
389 stats_iterator (void *cls,
390 const struct GNUNET_TESTBED_Peer *peer,
391 const char *subsystem,
396 static const char *s_sent = "# keepalives sent";
397 static const char *s_recv = "# keepalives received";
398 static const char *drops = "# messages dropped due to full buffer";
401 i = GNUNET_TESTBED_get_index (peer);
402 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
403 "STATS PEER %u - %s [%s]: %llu\n",
407 (unsigned long long) value);
408 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
410 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
412 if (0 == strncmp(drops, name, strlen (drops)))
413 msg_dropped += value;
420 * Task to gather all statistics.
422 * @param cls Closure (NULL).
425 gather_stats_and_exit (void *cls)
429 disconnect_task = NULL;
430 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
431 "gathering statistics from line %d\n",
437 GNUNET_CADET_notify_transmit_ready_cancel (th);
440 GNUNET_CADET_channel_destroy (ch);
443 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
445 &stats_iterator, stats_cont, cls);
451 * Abort test: schedule disconnect and shutdown immediately
453 * @param line Line in the code the abort is requested from (__LINE__).
456 abort_test (long line)
458 if (NULL != disconnect_task)
460 GNUNET_SCHEDULER_cancel (disconnect_task);
461 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
462 "Aborting test from %ld\n", line);
463 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
469 * Transmit ready callback.
471 * @param cls Closure (message type).
472 * @param size Size of the tranmist buffer.
473 * @param buf Pointer to the beginning of the buffer.
475 * @return Number of bytes written to buf.
478 tmt_rdy (void *cls, size_t size, void *buf);
482 * Task to request a new data transmission.
484 * @param cls Closure (peer #).
487 data_task (void *cls)
489 struct GNUNET_CADET_Channel *channel;
490 static struct GNUNET_CADET_TransmitHandle **pth;
494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
495 if (GNUNET_YES == test_backwards)
497 channel = incoming_ch;
499 src = peers_requested - 1;
508 GNUNET_assert (NULL != channel);
509 GNUNET_assert (NULL == *pth);
511 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
512 GNUNET_TIME_UNIT_FOREVER_REL,
513 size_payload + data_sent,
514 &tmt_rdy, (void *) src);
517 unsigned long i = (unsigned long) cls;
519 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Retransmission\n");
522 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n");
523 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
524 &data_task, (void *) 1L);
529 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
531 (unsigned long long) i);
532 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
534 &data_task, (void *) i);
541 * Transmit ready callback
543 * @param cls Closure (peer # which is sending the data).
544 * @param size Size of the buffer we have.
545 * @param buf Buffer to copy data to.
548 tmt_rdy (void *cls, size_t size, void *buf)
550 struct GNUNET_MessageHeader *msg = buf;
553 long id = (long) cls;
554 unsigned int counter;
556 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
557 "tmt_rdy on %ld, filling buffer\n",
561 else if ((peers_requested - 1) == id)
565 counter = get_expected_target () == id ? ack_sent : data_sent;
566 msg_size = size_payload + counter;
567 GNUNET_assert (msg_size > sizeof (struct GNUNET_MessageHeader));
568 if ( (size < msg_size) ||
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "size %u, buf %p, data_sent %u, ack_received %u\n",
577 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
578 GNUNET_break (ok >= ok_goal - 2);
582 msg->size = htons (msg_size);
583 msg->type = htons (GNUNET_MESSAGE_TYPE_DUMMY);
584 data = (uint32_t *) &msg[1];
585 *data = htonl (counter);
586 if (GNUNET_NO == initialized)
588 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
589 "sending initializer\n");
590 msg_size = size_payload + 1000;
591 msg->size = htons (msg_size);
592 if (SPEED_ACK == test)
595 else if ( (SPEED == test) ||
596 (SPEED_ACK == test) )
598 if (get_expected_target() == id)
603 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
604 " Sent message %u size %u\n",
606 (unsigned int) msg_size);
607 if ( (data_sent < TOTAL_PACKETS) &&
610 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
611 " Scheduling message %d\n",
613 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
622 * Function is called whenever a message is received.
624 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
625 * @param channel connection to the other end
626 * @param channel_ctx place to store local state associated with the channel
627 * @param message the actual message
628 * @return #GNUNET_OK to keep the connection open,
629 * #GNUNET_SYSERR to close it (signal serious error)
632 data_callback (void *cls,
633 struct GNUNET_CADET_Channel *channel,
635 const struct GNUNET_MessageHeader *message)
637 struct GNUNET_CADET_TransmitHandle **pth;
638 long client = (long) cls;
639 long expected_target_client;
642 unsigned int counter;
645 counter = get_expected_target () == client ? data_received : ack_received;
647 GNUNET_CADET_receive_done (channel);
651 if (NULL != disconnect_task)
653 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
654 " reschedule timeout\n");
655 GNUNET_SCHEDULER_cancel (disconnect_task);
656 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
657 &gather_stats_and_exit,
665 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
666 GNUNET_assert (channel == ch);
671 GNUNET_assert (client == peers_requested - 1);
672 GNUNET_assert (channel == incoming_ch);
674 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client %ld got a message.\n",
678 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %ld not valid.\n", client);
681 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
682 data = (uint32_t *) &message[1];
683 payload = ntohl (*data);
684 if (payload == counter)
686 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
690 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " payload %u, expected: %u\n",
693 expected_target_client = get_expected_target ();
695 if (GNUNET_NO == initialized)
697 initialized = GNUNET_YES;
698 start_time = GNUNET_TIME_absolute_get ();
701 GNUNET_assert (peers_requested - 1 == client);
702 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
708 if (client == expected_target_client) /* Normally 4 */
711 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
712 if (SPEED != test || (ok_goal - 2) == ok)
715 GNUNET_assert (NULL == *pth);
716 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
717 GNUNET_TIME_UNIT_FOREVER_REL,
718 size_payload + ack_sent,
719 &tmt_rdy, (void *) client);
724 if (data_received < TOTAL_PACKETS)
728 else /* Normally 0 */
730 if (SPEED_ACK == test || SPEED == test)
733 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
735 GNUNET_assert (NULL == *pth);
736 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
737 GNUNET_TIME_UNIT_FOREVER_REL,
738 size_payload + data_sent,
739 &tmt_rdy, (void *) client);
740 if (ack_received < TOTAL_PACKETS && SPEED != test)
742 if (ok == 2 && SPEED == test)
746 if (test == P2P_SIGNAL)
748 if (NULL != incoming_th)
750 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
753 GNUNET_CADET_channel_destroy (incoming_ch);
760 GNUNET_CADET_notify_transmit_ready_cancel (th);
763 GNUNET_CADET_channel_destroy (ch);
773 * Data handlers for every message type of CADET's payload.
774 * {callback_function, message_type, size_expected}
776 static struct GNUNET_CADET_MessageHandler handlers[] = {
778 GNUNET_MESSAGE_TYPE_DUMMY,
779 sizeof (struct GNUNET_MessageHeader)},
785 * Method called whenever another peer has added us to a channel
786 * the other peer initiated.
788 * @param cls Closure.
789 * @param channel New handle to the channel.
790 * @param initiator Peer that started the channel.
791 * @param port Port this channel is connected to.
792 * @param options channel option flags
793 * @return Initial channel context for the channel
794 * (can be NULL -- that's not an error).
797 incoming_channel (void *cls,
798 struct GNUNET_CADET_Channel *channel,
799 const struct GNUNET_PeerIdentity *initiator,
800 const struct GNUNET_HashCode *port,
801 enum GNUNET_CADET_ChannelOption options)
803 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
804 "Incoming channel from %s to peer %d:%s\n",
805 GNUNET_i2s (initiator),
806 (int) (long) cls, GNUNET_h2s (port));
808 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
809 if ((long) cls == peers_requested - 1)
811 if (NULL != incoming_ch)
813 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
814 "Duplicate incoming channel for client %lu\n",
818 incoming_ch = channel;
822 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
823 "Incoming channel for unexpected peer #%lu\n",
827 if (NULL != disconnect_task)
829 GNUNET_SCHEDULER_cancel (disconnect_task);
830 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
831 &gather_stats_and_exit,
840 * Function called whenever an inbound channel is destroyed. Should clean up
841 * any associated state.
843 * @param cls closure (set from GNUNET_CADET_connect, peer number)
844 * @param channel connection to the other end (henceforth invalid)
845 * @param channel_ctx place where local state associated
846 * with the channel is stored
849 channel_cleaner (void *cls,
850 const struct GNUNET_CADET_Channel *channel,
855 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
856 "Incoming channel disconnected at peer %ld\n",
858 if (peers_running - 1 == i)
861 GNUNET_break (channel == incoming_ch);
866 if (P2P_SIGNAL == test)
870 GNUNET_break (channel == ch);
874 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
875 "Unknown peer! %d\n",
877 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
879 if (NULL != disconnect_task)
881 GNUNET_SCHEDULER_cancel (disconnect_task);
882 disconnect_task = GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
889 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
891 * Testcase continues when the root receives confirmation of connected peers,
892 * on callback function ch.
894 * @param cls Closure (unused).
899 enum GNUNET_CADET_ChannelOption flags;
902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
904 if (NULL != disconnect_task)
906 GNUNET_SCHEDULER_cancel (disconnect_task);
907 disconnect_task = NULL;
910 flags = GNUNET_CADET_OPTION_DEFAULT;
911 if (SPEED_REL == test)
914 flags |= GNUNET_CADET_OPTION_RELIABLE;
917 ch = GNUNET_CADET_channel_create (h1,
924 = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
925 &gather_stats_and_exit,
927 if (KEEPALIVE == test)
928 return; /* Don't send any data. */
930 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
931 "Sending data initializer...\n");
936 th = GNUNET_CADET_notify_transmit_ready (ch,
938 GNUNET_TIME_UNIT_FOREVER_REL,
940 &tmt_rdy, (void *) 0L);
945 * Callback to be called when the requested peer information is available
947 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
948 * @param op the operation this callback corresponds to
949 * @param pinfo the result; will be NULL if the operation has failed
950 * @param emsg error message if the operation has failed;
951 * NULL if the operation is successfull
955 struct GNUNET_TESTBED_Operation *op,
956 const struct GNUNET_TESTBED_PeerInformation *pinfo,
961 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
962 "id callback for %ld\n", i);
964 if ( (NULL == pinfo) ||
967 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
968 "pi_cb: %s\n", emsg);
969 abort_test (__LINE__);
972 p_id[i] = pinfo->result.id;
973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
974 " id: %s\n", GNUNET_i2s (p_id[i]));
978 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
979 "Got all IDs, starting test\n");
980 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
987 * test main: start test when all peers are connected
989 * @param cls Closure.
990 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
991 * @param num_peers Number of peers that are running.
992 * @param peers Array of peers.
993 * @param cadetes Handle to each of the CADETs of the peers.
997 struct GNUNET_CADET_TEST_Context *ctx,
998 unsigned int num_peers,
999 struct GNUNET_TESTBED_Peer **peers,
1000 struct GNUNET_CADET_Handle **cadets)
1002 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
1005 peers_running = num_peers;
1006 GNUNET_assert (peers_running == peers_requested);
1007 testbed_peers = peers;
1009 h2 = cadets[num_peers - 1];
1010 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
1011 &disconnect_cadet_peers,
1013 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
1014 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
1015 GNUNET_TESTBED_PIT_IDENTITY,
1016 &pi_cb, (void *) 0L);
1017 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
1018 GNUNET_TESTBED_PIT_IDENTITY,
1019 &pi_cb, (void *) 1L);
1020 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
1028 main (int argc, char *argv[])
1030 initialized = GNUNET_NO;
1031 static const struct GNUNET_HashCode *ports[2];
1032 const char *config_file;
1033 char port_id[] = "test port";
1034 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
1036 GNUNET_log_setup ("test", "DEBUG", NULL);
1037 config_file = "test_cadet.conf";
1039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
1041 /* Find out requested size */
1042 if (strstr (argv[0], "_2_") != NULL)
1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
1045 peers_requested = 2;
1047 else if (strstr (argv[0], "_5_") != NULL)
1049 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1050 peers_requested = 5;
1054 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1055 peers_requested = 2;
1058 /* Find out requested test */
1059 if (strstr (argv[0], "_forward") != NULL)
1061 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1063 test_name = "unicast";
1066 else if (strstr (argv[0], "_signal") != NULL)
1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1070 test_name = "signal";
1073 else if (strstr (argv[0], "_speed_ack") != NULL)
1075 /* Test is supposed to generate the following callbacks:
1076 * 1 incoming channel (@dest)
1077 * TOTAL_PACKETS received data packet (@dest)
1078 * TOTAL_PACKETS received data packet (@orig)
1079 * 1 received channel destroy (@dest)
1081 ok_goal = TOTAL_PACKETS * 2 + 2;
1082 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1084 test_name = "speed ack";
1086 else if (strstr (argv[0], "_speed") != NULL)
1088 /* Test is supposed to generate the following callbacks:
1089 * 1 incoming channel (@dest)
1090 * 1 initial packet (@dest)
1091 * TOTAL_PACKETS received data packet (@dest)
1092 * 1 received data packet (@orig)
1093 * 1 received channel destroy (@dest)
1095 ok_goal = TOTAL_PACKETS + 4;
1096 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1097 if (strstr (argv[0], "_reliable") != NULL)
1100 test_name = "speed reliable";
1101 config_file = "test_cadet_drop.conf";
1106 test_name = "speed";
1109 else if (strstr (argv[0], "_keepalive") != NULL)
1112 /* Test is supposed to generate the following callbacks:
1113 * 1 incoming channel (@dest)
1115 * 1 received channel destroy (@dest)
1121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1126 if (strstr (argv[0], "backwards") != NULL)
1128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1129 test_backwards = GNUNET_YES;
1130 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1136 GNUNET_CADET_TEST_run ("test_cadet_small",
1140 NULL, /* tmain cls */
1145 if (NULL != strstr (argv[0], "_reliable"))
1146 msg_dropped = 0; /* dropped should be retransmitted */
1148 if (ok_goal > ok - msg_dropped)
1150 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1151 "FAILED! (%d/%d)\n", ok, ok_goal);
1154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1158 /* end of test_cadet.c */