2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file mesh/test_mesh_small.c
23 * @brief Test for the mesh service: retransmission of traffic.
27 #include "gnunet_testing_lib.h"
28 #include "gnunet_mesh_service.h"
32 #define VERBOSE GNUNET_YES
33 #define REMOVE_DIR GNUNET_YES
37 struct MeshPeer *prev;
39 struct MeshPeer *next;
41 struct GNUNET_TESTING_Daemon *daemon;
43 struct GNUNET_MESH_Handle *mesh_handle;
48 * How long until we give up on connecting the peers?
50 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500)
53 * Time to wait for stuff that should be rather fast
55 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
58 * DIFFERENT TESTS TO RUN
67 * Which test are we running?
72 * How many events have happened
76 static int peers_in_tunnel;
78 static int peers_responded;
82 static int data_received;
92 * Total number of peers in the test.
94 static unsigned long long num_peers;
97 * Global configuration file
99 static struct GNUNET_CONFIGURATION_Handle *testing_cfg;
102 * Total number of currently running peers.
104 static unsigned long long peers_running;
107 * Total number of connections in the whole network.
109 static unsigned int total_connections;
112 * The currently running peer group.
114 static struct GNUNET_TESTING_PeerGroup *pg;
117 * File to report results to.
119 static struct GNUNET_DISK_FileHandle *output_file;
122 * File to log connection info, statistics to.
124 static struct GNUNET_DISK_FileHandle *data_file;
127 * How many data points to capture before triggering next round?
129 static struct GNUNET_TIME_Relative wait_time;
132 * Task called to disconnect peers.
134 static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
137 * Task To perform tests
139 static GNUNET_SCHEDULER_TaskIdentifier test_task;
142 * Task called to shutdown test.
144 static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
146 static char *topology_file;
148 static struct GNUNET_TESTING_Daemon *d1;
150 static GNUNET_PEER_Id pid1;
152 static struct GNUNET_TESTING_Daemon *d2;
154 static struct GNUNET_TESTING_Daemon *d3;
156 static struct GNUNET_MESH_Handle *h1;
158 static struct GNUNET_MESH_Handle *h2;
160 static struct GNUNET_MESH_Handle *h3;
162 static struct GNUNET_MESH_Tunnel *t;
164 static struct GNUNET_MESH_Tunnel *incoming_t;
166 static struct GNUNET_MESH_Tunnel *incoming_t2;
168 static struct GNUNET_TIME_Absolute start_time;
170 static struct GNUNET_TIME_Absolute end_time;
172 static struct GNUNET_TIME_Relative total_time;
176 * Check whether peers successfully shut down.
179 shutdown_callback (void *cls, const char *emsg)
184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
185 "Shutdown of peers failed!\n");
192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
193 "All peers successfully shut down!\n");
196 GNUNET_CONFIGURATION_destroy (testing_cfg);
201 * Shut down peergroup, clean up.
204 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
211 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
213 GNUNET_SCHEDULER_cancel (disconnect_task);
214 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
219 GNUNET_MESH_disconnect (h1);
224 GNUNET_MESH_disconnect (h2);
227 if (test == MULTICAST && NULL != h3)
229 GNUNET_MESH_disconnect (h3);
233 if (data_file != NULL)
234 GNUNET_DISK_file_close (data_file);
235 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
240 * Disconnect from mesh services af all peers, call shutdown.
243 disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
246 "disconnecting mesh service of peers\n");
247 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
250 GNUNET_MESH_tunnel_destroy(t);
253 if (NULL != incoming_t)
255 GNUNET_MESH_tunnel_destroy(incoming_t);
258 if (NULL != incoming_t2)
260 GNUNET_MESH_tunnel_destroy(incoming_t2);
263 GNUNET_MESH_disconnect (h1);
264 GNUNET_MESH_disconnect (h2);
266 if (test == MULTICAST)
268 GNUNET_MESH_disconnect (h3);
271 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
273 GNUNET_SCHEDULER_cancel (shutdown_handle);
274 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
279 tmt_rdy (void *cls, size_t size, void *buf);
282 data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
284 struct GNUNET_MESH_TransmitHandle *th;
285 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
287 th = GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO, 0,
288 GNUNET_TIME_UNIT_FOREVER_REL, &d2->id,
289 sizeof (struct GNUNET_MessageHeader),
290 &tmt_rdy, (void *) 1L);
293 unsigned long i = (unsigned long) cls;
295 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retransmission\n");
298 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " in 1 ms\n");
299 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
300 &data_task, (void *)1UL);
305 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "in %u ms\n", i);
306 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
307 GNUNET_TIME_UNIT_MILLISECONDS,
309 &data_task, (void *)i);
315 * Transmit ready callback
317 * @param cls Closure.
318 * @param size Size of the buffer we have.
319 * @param buf Buffer to copy data to.
322 tmt_rdy (void *cls, size_t size, void *buf)
324 struct GNUNET_MessageHeader *msg = buf;
326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
327 " tmt_rdy called\n");
328 if (size < sizeof (struct GNUNET_MessageHeader) || NULL == buf)
330 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
331 msg->type = htons ((long) cls);
335 if (data_sent < 1000)
337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
338 " Scheduling %d packet\n", data_sent);
339 GNUNET_SCHEDULER_add_now(&data_task, NULL);
342 return sizeof (struct GNUNET_MessageHeader);
347 * Function is called whenever a message is received.
349 * @param cls closure (set from GNUNET_MESH_connect)
350 * @param tunnel connection to the other end
351 * @param tunnel_ctx place to store local state associated with the tunnel
352 * @param sender who sent the message
353 * @param message the actual message
354 * @param atsi performance data for the connection
355 * @return GNUNET_OK to keep the connection open,
356 * GNUNET_SYSERR to close it (signal serious error)
359 data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
360 const struct GNUNET_PeerIdentity *sender,
361 const struct GNUNET_MessageHeader *message,
362 const struct GNUNET_ATS_Information *atsi)
364 long client = (long) cls;
369 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Origin client got a response!\n");
371 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
374 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
376 GNUNET_SCHEDULER_cancel (disconnect_task);
378 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers,
381 if (test == MULTICAST && peers_responded < 2)
383 if (test == SPEED_ACK || test == SPEED)
385 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
386 " received ack %u\n", data_ack);
387 GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, 0,
388 GNUNET_TIME_UNIT_FOREVER_REL, sender,
389 sizeof (struct GNUNET_MessageHeader),
390 &tmt_rdy, (void *) 1L);
391 if (data_ack < 1000 && test != SPEED)
393 end_time = GNUNET_TIME_absolute_get();
394 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
395 FPRINTF (stderr, "\nTest time %llu ms\n",
396 (unsigned long long) total_time.rel_value);
397 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
398 4 * 1000.0 / total_time.rel_value); // 4bytes * ms
399 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
400 1000.0 * 1000.0 / total_time.rel_value); // 1000 packets * ms
401 GAUGER ("MESH", "Tunnel 5 peers", 1000.0 * 1000.0 / total_time.rel_value,
404 GNUNET_assert (tunnel == t);
405 GNUNET_MESH_tunnel_destroy (t);
410 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
411 "Destination client %u got a message.\n",
414 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
415 if (SPEED != test || 1002 == ok)
417 GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, 0,
418 GNUNET_TIME_UNIT_FOREVER_REL, sender,
419 sizeof (struct GNUNET_MessageHeader),
420 &tmt_rdy, (void *) 1L);
425 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
426 " received data %u\n", data_received);
427 if (data_received < 1000)
430 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
432 GNUNET_SCHEDULER_cancel (disconnect_task);
434 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers,
446 * Handlers, for diverse services
448 static struct GNUNET_MESH_MessageHandler handlers[] = {
449 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
455 * Method called whenever another peer has added us to a tunnel
456 * the other peer initiated.
459 * @param tunnel new handle to the tunnel
460 * @param initiator peer that started the tunnel
461 * @param atsi performance information for the tunnel
462 * @return initial tunnel context for the tunnel
463 * (can be NULL -- that's not an error)
466 incoming_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
467 const struct GNUNET_PeerIdentity *initiator,
468 const struct GNUNET_ATS_Information *atsi)
470 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
471 "Incoming tunnel from %s to peer %d\n",
472 GNUNET_i2s (initiator), (long) cls);
474 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
475 if ((long) cls == 2L)
477 else if ((long) cls == 3L)
478 incoming_t2 = tunnel;
481 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
482 "Incoming tunnel for unknown client %lu\n", (long) cls);
484 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
486 GNUNET_SCHEDULER_cancel (disconnect_task);
488 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers, NULL);
494 * Function called whenever an inbound tunnel is destroyed. Should clean up
495 * any associated state.
497 * @param cls closure (set from GNUNET_MESH_connect)
498 * @param tunnel connection to the other end (henceforth invalid)
499 * @param tunnel_ctx place where local state associated
500 * with the tunnel is stored
503 tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
508 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
509 "Incoming tunnel disconnected at peer %d\n",
522 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
523 "Unknown peer! %d\n", i);
524 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
526 if (peers_in_tunnel > 0)
529 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
531 GNUNET_SCHEDULER_cancel (disconnect_task);
532 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers, NULL);
540 * Method called whenever a tunnel falls apart.
543 * @param peer peer identity the tunnel stopped working with
546 dh (void *cls, const struct GNUNET_PeerIdentity *peer)
548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
549 "peer %s disconnected\n",
556 * Method called whenever a peer connects to a tunnel.
559 * @param peer peer identity the tunnel was created to, NULL on timeout
560 * @param atsi performance data for the connection
563 ch (void *cls, const struct GNUNET_PeerIdentity *peer,
564 const struct GNUNET_ATS_Information *atsi)
566 struct GNUNET_PeerIdentity *dest;
568 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
569 "peer %s connected\n", GNUNET_i2s (peer));
571 if (0 == memcmp (&d2->id, peer, sizeof (d2->id)) && (long) cls == 1L)
575 if (test == MULTICAST && 0 == memcmp (&d3->id, peer, sizeof (d3->id)) &&
580 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
590 if (peers_in_tunnel < 2)
597 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
599 GNUNET_SCHEDULER_cancel (disconnect_task);
601 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers, NULL);
602 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
603 "Sending data...\n");
608 start_time = GNUNET_TIME_absolute_get();
609 GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO, 0,
610 GNUNET_TIME_UNIT_FOREVER_REL, dest,
611 sizeof (struct GNUNET_MessageHeader),
612 &tmt_rdy, (void *) 1L);
616 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
617 "Disconnect already run?\n");
618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
626 do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
628 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test_task\n");
629 if (test == MULTICAST)
631 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
633 GNUNET_MESH_peer_request_connect_add (t, &d3->id);
635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "add peer 2\n");
636 GNUNET_MESH_peer_request_connect_add (t, &d2->id);
637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
638 "schedule timeout in 90s\n");
639 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
641 GNUNET_SCHEDULER_cancel (disconnect_task);
643 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers, NULL);
649 * connect_mesh_service: connect to the mesh service of one of the peers
653 connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
655 GNUNET_MESH_ApplicationType app;
657 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
658 "connect_mesh_service\n");
660 d2 = GNUNET_TESTING_daemon_get (pg, 4);
661 if (test == MULTICAST)
663 d3 = GNUNET_TESTING_daemon_get (pg, 3);
665 app = (GNUNET_MESH_ApplicationType) 0;
668 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
669 "connecting to mesh service of peer %s\n",
670 GNUNET_i2s (&d1->id));
671 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
672 "connecting to mesh service of peer %s\n",
673 GNUNET_i2s (&d2->id));
674 if (test == MULTICAST)
676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
677 "connecting to mesh service of peer %s\n",
678 GNUNET_i2s (&d3->id));
681 h1 = GNUNET_MESH_connect (d1->cfg, 5, (void *) 1L, NULL, &tunnel_cleaner,
683 h2 = GNUNET_MESH_connect (d2->cfg, 5, (void *) 2L, &incoming_tunnel,
684 &tunnel_cleaner, handlers, &app);
685 if (test == MULTICAST)
687 h3 = GNUNET_MESH_connect (d3->cfg, 5, (void *) 3L, &incoming_tunnel,
688 &tunnel_cleaner, handlers, &app);
690 t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L);
693 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
694 (GNUNET_TIME_UNIT_SECONDS, 1), &do_test,
701 * peergroup_ready: start test when all peers are connected
703 * @param emsg error message
706 peergroup_ready (void *cls, const char *emsg)
714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
715 "Peergroup callback called with error, aborting test!\n");
716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
717 "Error from testing: `%s'\n", emsg);
719 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
724 "************************************************************\n");
725 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
726 "Peer Group started successfully!\n");
727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
728 "Have %u connections\n",
732 if (data_file != NULL)
735 buf_len = GNUNET_asprintf (&buf, "CONNECTIONS_0: %u\n", total_connections);
737 GNUNET_DISK_file_write (data_file, buf, buf_len);
740 peers_running = GNUNET_TESTING_daemons_running (pg);
741 for (i = 0; i < num_peers; i++)
743 GNUNET_PEER_Id peer_id;
745 d1 = GNUNET_TESTING_daemon_get (pg, i);
746 peer_id = GNUNET_PEER_intern (&d1->id);
747 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u: %s\n",
748 peer_id, GNUNET_i2s (&d1->id));
750 d1 = GNUNET_TESTING_daemon_get (pg, 0);
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
752 "Peer looking: %s\n",
753 GNUNET_i2s (&d1->id));
754 pid1 = GNUNET_PEER_intern (&d1->id);
756 GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL);
758 GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL);
764 * Function that will be called whenever two daemons are connected by
765 * the testing library.
768 * @param first peer id for first daemon
769 * @param second peer id for the second daemon
770 * @param distance distance between the connected peers
771 * @param first_cfg config for the first daemon
772 * @param second_cfg config for the second daemon
773 * @param first_daemon handle for the first daemon
774 * @param second_daemon handle for the second daemon
775 * @param emsg error message (NULL on success)
778 connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
779 const struct GNUNET_PeerIdentity *second, uint32_t distance,
780 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
781 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
782 struct GNUNET_TESTING_Daemon *first_daemon,
783 struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg)
791 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
792 "Problem with new connection (%s)\n",
794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " (%s)\n", GNUNET_i2s (first));
795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " (%s)\n", GNUNET_i2s (second));
802 * run: load configuration options and schedule test to run (start peergroup)
805 * @param cfgfile configuration file name (can be NULL)
806 * @param cfg configuration handle
809 run (void *cls, char *const *args, const char *cfgfile,
810 const struct GNUNET_CONFIGURATION_Handle *cfg)
813 struct GNUNET_TESTING_Host *hosts;
817 testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
819 GNUNET_log_setup ("test_mesh_small",
828 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
829 "Starting daemons.\n");
830 GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing_old",
831 "use_progressbars", "YES");
835 GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing_old",
836 "num_peers", &num_peers))
838 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
839 "Option TESTING:NUM_PEERS is required!\n");
844 GNUNET_CONFIGURATION_get_value_time (testing_cfg, "test_mesh_small",
845 "WAIT_TIME", &wait_time))
847 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
848 "Option test_mesh_small:wait_time is required!\n");
853 GNUNET_CONFIGURATION_get_value_string (testing_cfg, "testing_old",
854 "topology_output_file",
857 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
858 "Option test_mesh_small:topology_output_file is required!\n");
863 GNUNET_CONFIGURATION_get_value_string (testing_cfg, "test_mesh_small",
868 GNUNET_DISK_file_open (data_filename,
869 GNUNET_DISK_OPEN_READWRITE |
870 GNUNET_DISK_OPEN_CREATE,
871 GNUNET_DISK_PERM_USER_READ |
872 GNUNET_DISK_PERM_USER_WRITE);
873 if (data_file == NULL)
875 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
877 GNUNET_free (data_filename);
882 GNUNET_CONFIGURATION_get_value_string (cfg, "test_mesh_small",
883 "output_file", &temp_str))
886 GNUNET_DISK_file_open (temp_str,
887 GNUNET_DISK_OPEN_READWRITE |
888 GNUNET_DISK_OPEN_CREATE,
889 GNUNET_DISK_PERM_USER_READ |
890 GNUNET_DISK_PERM_USER_WRITE);
891 if (output_file == NULL)
892 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
895 GNUNET_free_non_null (temp_str);
897 hosts = GNUNET_TESTING_hosts_load (testing_cfg);
899 pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT,
900 &connect_cb, &peergroup_ready, NULL,
902 GNUNET_assert (pg != NULL);
904 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
905 &shutdown_task, NULL);
911 * test_mesh_small command line options
913 static struct GNUNET_GETOPT_CommandLineOption options[] = {
914 {'V', "verbose", NULL,
915 gettext_noop ("be verbose (print progress information)"),
916 0, &GNUNET_GETOPT_set_one, &verbose},
917 GNUNET_GETOPT_OPTION_END
925 main (int argc, char *argv[])
930 "test_mesh_small.conf",
937 int argc2 = (sizeof (argv2) / sizeof (char *)) - 1;
939 /* Each peer is supposed to generate the following callbacks:
940 * 1 incoming tunnel (@dest)
941 * 1 connected peer (@orig)
942 * 1 received data packet (@dest)
943 * 1 received data packet (@orig)
944 * 1 received tunnel destroy (@dest)
945 * _________________________________
946 * 5 x ok expected per peer
950 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
951 if (strstr (argv[0], "test_mesh_small_unicast") != NULL)
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNICAST\n");
957 else if (strstr (argv[0], "test_mesh_small_multicast") != NULL)
959 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MULTICAST\n");
963 else if (strstr (argv[0], "test_mesh_small_speed_ack") != NULL)
965 /* Each peer is supposed to generate the following callbacks:
966 * 1 incoming tunnel (@dest)
967 * 1 connected peer (@orig)
968 * 1000 received data packet (@dest)
969 * 1000 received data packet (@orig)
970 * 1 received tunnel destroy (@dest)
971 * _________________________________
972 * 5 x ok expected per peer
974 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
977 argv2 [3] = NULL; // remove -L DEBUG
982 else if (strstr (argv[0], "test_mesh_small_speed") != NULL)
984 /* Each peer is supposed to generate the following callbacks:
985 * 1 incoming tunnel (@dest)
986 * 1 connected peer (@orig)
987 * 1000 received data packet (@dest)
988 * 1received data packet (@orig)
989 * 1 received tunnel destroy (@dest)
990 * _________________________________
992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1003 GNUNET_PROGRAM_run (argc2, argv2,
1005 gettext_noop ("Test mesh in a small network."), options,
1008 GNUNET_DISK_directory_remove ("/tmp/test_mesh_small");
1012 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1013 "FAILED! (%d/%d)\n", ok, ok_goal);
1016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1020 /* end of test_mesh_small.c */