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.
22 * @file src/transport/gnunet-transport.c
23 * @brief Tool to help configure, measure and control the transport subsystem.
24 * @author Christian Grothoff
25 * @author Nathan Evans
27 * This utility can be used to test if a transport mechanism for
28 * GNUnet is properly configured.
32 #include "gnunet_util_lib.h"
33 #include "gnunet_resolver_service.h"
34 #include "gnunet_protocols.h"
35 #include "gnunet_transport_service.h"
36 #include "gnunet_nat_lib.h"
39 * How long do we wait for the NAT test to report success?
40 * Should match NAT_SERVER_TIMEOUT in 'nat_test.c'.
42 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
43 #define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
44 #define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
47 * Benchmarking block size in KB
53 * Which peer should we connect to?
58 * Handle to transport service.
60 static struct GNUNET_TRANSPORT_Handle *handle;
63 * Configuration handle
65 static struct GNUNET_CONFIGURATION_Handle *cfg;
70 struct GNUNET_TRANSPORT_TryConnectHandle * tc_handle;
75 static int benchmark_send;
80 static int benchmark_receive;
85 static int benchmark_receive;
90 static int iterate_connections;
95 static int test_configuration;
100 static int monitor_connects;
105 static int monitor_connections;
110 static int try_connect;
118 * Global return value (0 success).
123 * Current number of connections in monitor mode
125 static int monitor_connect_counter;
128 * Number of bytes of traffic we received so far.
130 static unsigned long long traffic_received;
133 * Number of bytes of traffic we sent so far.
135 static unsigned long long traffic_sent;
138 * Starting time of transmitting/receiving data.
140 static struct GNUNET_TIME_Absolute start_time;
143 * Handle for current transmission request.
145 static struct GNUNET_TRANSPORT_TransmitHandle *th;
150 struct GNUNET_TRANSPORT_PeerIterateContext *pic;
153 * Identity of the peer we transmit to / connect to.
154 * (equivalent to 'cpid' string).
156 static struct GNUNET_PeerIdentity pid;
159 * Task scheduled for cleanup / termination of the process.
161 static GNUNET_SCHEDULER_TaskIdentifier end;
164 * Task for operation timeout
166 static GNUNET_SCHEDULER_TaskIdentifier op_timeout;
169 static struct GNUNET_CONTAINER_MultiHashMap *peers;
172 * Selected level of verbosity.
174 static int verbosity;
177 * Resolver process handle.
179 struct GNUNET_OS_Process *resolver;
182 * Number of tasks running that still need the resolver.
184 static unsigned int resolver_users;
187 * Number of address resolutions pending
189 static unsigned int address_resolutions;
192 * Address resolutions pending in progress
194 static unsigned int address_resolution_in_progress;
197 * Context for a plugin test.
203 * Handle to the active NAT test.
205 struct GNUNET_NAT_Test *tst;
208 * Task identifier for the timeout.
210 GNUNET_SCHEDULER_TaskIdentifier tsk;
213 * Name of plugin under test.
221 * Task run in monitor mode when the user presses CTRL-C to abort.
222 * Stops monitoring activity.
224 * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *'
225 * @param tc scheduler context
228 shutdown_task (void *cls,
229 const struct GNUNET_SCHEDULER_TaskContext *tc)
231 struct GNUNET_TIME_Relative duration;
232 end = GNUNET_SCHEDULER_NO_TASK;
233 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
235 GNUNET_SCHEDULER_cancel (op_timeout);
236 op_timeout = GNUNET_SCHEDULER_NO_TASK;
238 if (NULL != tc_handle)
240 GNUNET_TRANSPORT_try_connect_cancel (tc_handle);
245 GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);
250 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th);
255 GNUNET_TRANSPORT_disconnect(handle);
260 GNUNET_CONTAINER_multihashmap_destroy (peers);
265 duration = GNUNET_TIME_absolute_get_duration (start_time);
266 FPRINTF (stdout, _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
267 1000 * traffic_sent / (1 + duration.rel_value), traffic_sent,
268 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
270 if (benchmark_receive)
272 duration = GNUNET_TIME_absolute_get_duration (start_time);
273 FPRINTF (stdout, _("Received %llu bytes/s (%llu bytes in %s)\n"),
274 1000 * traffic_received / (1 + duration.rel_value),
276 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
280 struct ResolutionContext *rc_head;
281 struct ResolutionContext *rc_tail;
283 struct ResolutionContext
285 struct ResolutionContext *next;
286 struct ResolutionContext *prev;
287 struct GNUNET_HELLO_Address *addrcp;
288 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
294 operation_timeout (void *cls,
295 const struct GNUNET_SCHEDULER_TaskContext *tc)
297 struct ResolutionContext *cur;
298 struct ResolutionContext *next;
299 op_timeout = GNUNET_SCHEDULER_NO_TASK;
300 if ((try_connect) || (benchmark_send) ||
303 FPRINTF (stdout, _("Failed to connect to `%s'\n"), GNUNET_h2s_full (&pid.hashPubKey));
304 if (GNUNET_SCHEDULER_NO_TASK != end)
305 GNUNET_SCHEDULER_cancel (end);
306 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
310 if (iterate_connections)
313 while (NULL != (cur = next))
316 FPRINTF (stdout, _("Failed to resolve address for peer `%s'\n"),
317 GNUNET_i2s (&cur->addrcp->peer));
319 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, cur);
320 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
321 GNUNET_free (cur->addrcp);
325 FPRINTF (stdout, "%s", _("Failed to list connections, timeout occured\n"));
326 if (GNUNET_SCHEDULER_NO_TASK != end)
327 GNUNET_SCHEDULER_cancel (end);
328 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
338 * Display the result of the test.
340 * @param tc test context
341 * @param result GNUNET_YES on success
344 display_test_result (struct TestContext *tc, int result)
346 if (GNUNET_YES != result)
348 FPRINTF (stderr, "Configuration for plugin `%s' did not work!\n", tc->name);
352 FPRINTF (stderr, "Configuration for plugin `%s' is working!\n", tc->name);
354 if (GNUNET_SCHEDULER_NO_TASK != tc->tsk)
356 GNUNET_SCHEDULER_cancel (tc->tsk);
357 tc->tsk = GNUNET_SCHEDULER_NO_TASK;
361 GNUNET_NAT_test_stop (tc->tst);
366 if ((0 == resolver_users) && (NULL != resolver))
368 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
369 GNUNET_OS_process_destroy (resolver);
376 * Function called by NAT on success.
377 * Clean up and update GUI (with success).
379 * @param cls test context
380 * @param success currently always GNUNET_OK
383 result_callback (void *cls, int success)
385 struct TestContext *tc = cls;
387 display_test_result (tc, success);
392 * Function called if NAT failed to confirm success.
393 * Clean up and update GUI (with failure).
395 * @param cls test context
396 * @param tc scheduler callback
399 fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
401 struct TestContext *tstc = cls;
403 tstc->tsk = GNUNET_SCHEDULER_NO_TASK;
404 display_test_result (tstc, GNUNET_NO);
409 * Test our plugin's configuration (NAT traversal, etc.).
411 * @param cfg configuration to test
414 do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
418 unsigned long long bnd_port;
419 unsigned long long adv_port;
420 struct TestContext *tc;
423 GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
429 ("No transport plugins configured, peer will never communicate\n"));
433 for (tok = strtok (plugins, " "); tok != NULL; tok = strtok (NULL, " "))
435 char section[12 + strlen (tok)];
437 GNUNET_snprintf (section, sizeof (section), "transport-%s", tok);
439 GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT", &bnd_port))
442 _("No port configured for plugin `%s', cannot test it\n"), tok);
446 GNUNET_CONFIGURATION_get_value_number (cfg, section, "ADVERTISED_PORT",
449 if (NULL == resolver)
451 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-resolver",
452 "gnunet-service-resolver", NULL);
454 GNUNET_RESOLVER_connect (cfg);
455 tc = GNUNET_malloc (sizeof (struct TestContext));
456 tc->name = GNUNET_strdup (tok);
458 GNUNET_NAT_test_start (cfg,
461 "udp")) ? GNUNET_NO : GNUNET_YES,
462 (uint16_t) bnd_port, (uint16_t) adv_port,
463 &result_callback, tc);
466 display_test_result (tc, GNUNET_SYSERR);
469 tc->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, tc);
471 GNUNET_free (plugins);
475 * Function called to notify a client about the socket
476 * begin ready to queue more data. "buf" will be
477 * NULL and "size" zero if the socket was closed for
478 * writing in the meantime.
481 * @param size number of bytes available in buf
482 * @param buf where the callee should write the message
483 * @return number of bytes written to buf
486 transmit_data (void *cls, size_t size, void *buf)
488 struct GNUNET_MessageHeader *m = buf;
490 if ((NULL == buf) && (0 == size))
496 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
497 GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
498 m->size = ntohs (size);
499 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
500 memset (&m[1], 52, size - sizeof (struct GNUNET_MessageHeader));
501 traffic_sent += size;
502 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, BLOCKSIZE * 1024, 0,
503 GNUNET_TIME_UNIT_FOREVER_REL,
504 &transmit_data, NULL);
506 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
513 * Function called to notify transport users that another
514 * peer connected to us.
517 * @param peer the peer that connected
518 * @param ats performance data
519 * @param ats_count number of entries in ats (excluding 0-termination)
522 notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
523 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
525 if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
530 /* all done, terminate instantly */
531 FPRINTF (stdout, _("Successfully connected to `%s'\n"), GNUNET_h2s_full (&peer->hashPubKey));
534 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
536 GNUNET_SCHEDULER_cancel (op_timeout);
537 op_timeout = GNUNET_SCHEDULER_NO_TASK;
540 if (GNUNET_SCHEDULER_NO_TASK != end)
541 GNUNET_SCHEDULER_cancel (end);
542 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
547 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
549 GNUNET_SCHEDULER_cancel (op_timeout);
550 op_timeout = GNUNET_SCHEDULER_NO_TASK;
553 FPRINTF (stdout, _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
554 GNUNET_i2s (&pid), BLOCKSIZE);
555 start_time = GNUNET_TIME_absolute_get ();
557 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer,
559 GNUNET_TIME_UNIT_FOREVER_REL,
560 &transmit_data, NULL);
569 * Function called to notify transport users that another
570 * peer disconnected from us.
573 * @param peer the peer that disconnected
576 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
578 if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
583 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
588 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"), GNUNET_i2s (&pid));
589 if (GNUNET_SCHEDULER_NO_TASK != end)
590 GNUNET_SCHEDULER_cancel (end);
596 * Function called to notify transport users that another
597 * peer connected to us.
600 * @param peer the peer that connected
601 * @param ats performance data
602 * @param ats_count number of entries in ats (excluding 0-termination)
605 monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
606 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
608 monitor_connect_counter ++;
609 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
610 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
612 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
616 monitor_connect_counter);
621 * Function called to notify transport users that another
622 * peer disconnected from us.
625 * @param peer the peer that disconnected
628 monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
630 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
631 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
633 GNUNET_assert (monitor_connect_counter > 0);
634 monitor_connect_counter --;
636 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
638 _("Disconnected from"),
640 monitor_connect_counter);
646 * Function called by the transport for each received message.
649 * @param peer (claimed) identity of the other peer
650 * @param message the message
653 notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
654 const struct GNUNET_MessageHeader *message)
656 if (benchmark_receive)
658 if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type))
661 FPRINTF (stdout, _("Received %u bytes from %s\n"),
662 (unsigned int) ntohs (message->size), GNUNET_i2s (peer));
664 if (traffic_received == 0)
665 start_time = GNUNET_TIME_absolute_get ();
666 traffic_received += ntohs (message->size);
672 static void resolve_address (const struct GNUNET_HELLO_Address *address,
677 process_string (void *cls, const char *address)
679 struct ResolutionContext *rc = cls;
680 struct GNUNET_HELLO_Address *addrcp = rc->addrcp;
684 FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name, address);
685 rc->printed = GNUNET_YES;
690 GNUNET_assert (address_resolutions > 0);
691 address_resolutions --;
692 if (GNUNET_NO == rc->printed)
694 if (numeric == GNUNET_NO)
696 resolve_address (rc->addrcp, GNUNET_YES ); /* Failed to resolve address, try numeric lookup */
699 FPRINTF (stdout, _("Peer `%s': %s <unable to resolve address>\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name);
701 GNUNET_free (rc->addrcp);
702 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc);
704 if ((0 == address_resolutions) && (iterate_connections))
706 if (GNUNET_SCHEDULER_NO_TASK != end)
708 GNUNET_SCHEDULER_cancel (end);
709 end = GNUNET_SCHEDULER_NO_TASK;
711 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
713 GNUNET_SCHEDULER_cancel (op_timeout);
714 op_timeout = GNUNET_SCHEDULER_NO_TASK;
717 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
722 static void resolve_address (const struct GNUNET_HELLO_Address *address,
725 struct ResolutionContext *rc;
727 rc = GNUNET_malloc(sizeof (struct ResolutionContext));
728 GNUNET_assert (NULL != rc);
729 GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc);
730 address_resolutions ++;
732 rc->addrcp = GNUNET_HELLO_address_copy(address);
733 rc->printed = GNUNET_NO;
734 /* Resolve address to string */
735 rc->asc = GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
736 RESOLUTION_TIMEOUT, &process_string,
741 * Function to call with a binary address
744 * @param peer identity of the peer
745 * @param address binary address (NULL on disconnect)
748 process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
749 const struct GNUNET_HELLO_Address *address)
754 address_resolution_in_progress = GNUNET_NO;
756 if (GNUNET_SCHEDULER_NO_TASK != end)
757 GNUNET_SCHEDULER_cancel (end);
758 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
763 FPRINTF (stdout, _("Peer `%s' disconnected\n"), GNUNET_i2s (peer));
767 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
768 GNUNET_SCHEDULER_cancel (op_timeout);
769 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
770 &operation_timeout, NULL);
772 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received address for peer `%s': %s\n",
773 GNUNET_i2s (peer), address->transport_name);
774 resolve_address (address, numeric);
777 void try_connect_cb (void *cls,
780 static int retries = 0;
781 if (GNUNET_OK == result)
788 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL);
791 FPRINTF (stderr, "%s", _("Failed to send connect request to transport service\n"));
792 if (GNUNET_SCHEDULER_NO_TASK != end)
793 GNUNET_SCHEDULER_cancel (end);
795 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
802 testservice_task (void *cls,
803 const struct GNUNET_SCHEDULER_TaskContext *tc)
808 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
810 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
814 if ((NULL != cpid) && (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey)))
816 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
820 counter = benchmark_send + benchmark_receive + iterate_connections +
821 monitor_connections + monitor_connects + try_connect;
825 FPRINTF (stderr, _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s\n"),
826 "connect", "benchmark send", "benchmark receive", "information", "monitor", "events");
831 FPRINTF (stderr, _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s\n"),
832 "connect", "benchmark send", "benchmark receive", "information", "monitor", "events");
836 if (try_connect) /* -C: Connect to peer */
840 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
845 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
851 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
855 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL);
856 if (NULL == tc_handle)
858 FPRINTF (stderr, "%s", _("Failed to send request to transport service\n"));
862 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
863 &operation_timeout, NULL);
866 else if (benchmark_send) /* -s: Benchmark sending */
870 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
875 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
881 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
885 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL);
886 if (NULL == tc_handle)
888 FPRINTF (stderr, "%s", _("Failed to send request to transport service\n"));
892 start_time = GNUNET_TIME_absolute_get ();
893 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
894 &operation_timeout, NULL);
896 else if (benchmark_receive) /* -b: Benchmark receiving */
899 GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
903 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
908 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n"));
909 start_time = GNUNET_TIME_absolute_get ();
912 else if (iterate_connections) /* -i: List all active addresses once */
914 peers = GNUNET_CONTAINER_multihashmap_create (20, GNUNET_NO);
915 address_resolution_in_progress = GNUNET_YES;
916 pic = GNUNET_TRANSPORT_peer_get_active_addresses (cfg,
917 (NULL == cpid) ? NULL : &pid,
920 &process_address, (void *) cfg);
921 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
922 &operation_timeout, NULL);
924 else if (monitor_connections) /* -m: List all active addresses continously */
926 peers = GNUNET_CONTAINER_multihashmap_create (20, GNUNET_NO);
927 address_resolution_in_progress = GNUNET_YES;
928 pic = GNUNET_TRANSPORT_peer_get_active_addresses (cfg,
929 (NULL == cpid) ? NULL : &pid,
932 &process_address, (void *) cfg);
934 else if (monitor_connects) /* -e : Monitor (dis)connect events continously */
936 monitor_connect_counter = 0;
937 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL,
938 &monitor_notify_connect,
939 &monitor_notify_disconnect);
942 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
954 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
962 * Main function that will be run by the scheduler.
965 * @param args remaining command-line arguments
966 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
967 * @param mycfg configuration
970 run (void *cls, char *const *args, const char *cfgfile,
971 const struct GNUNET_CONFIGURATION_Handle *mycfg)
973 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
974 if (test_configuration)
976 do_test_configuration (cfg);
980 GNUNET_CLIENT_service_test ("transport", cfg,
981 GNUNET_TIME_UNIT_SECONDS,
988 main (int argc, char *const *argv)
991 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
992 {'b', "benchmark", NULL,
993 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
994 0, &GNUNET_GETOPT_set_one, &benchmark_receive},
995 {'C', "connect", NULL,
996 gettext_noop ("connect to a peer"),
997 0, &GNUNET_GETOPT_set_one, &try_connect},
998 {'i', "information", NULL,
999 gettext_noop ("provide information about all current connections (once)"),
1000 0, &GNUNET_GETOPT_set_one, &iterate_connections},
1001 {'m', "monitor", NULL,
1002 gettext_noop ("provide information about all current connections (continuously)"),
1003 0, &GNUNET_GETOPT_set_one, &monitor_connections},
1004 {'e', "events", NULL,
1005 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
1006 0, &GNUNET_GETOPT_set_one, &monitor_connects},
1007 {'n', "numeric", NULL,
1008 gettext_noop ("do not resolve hostnames"),
1009 0, &GNUNET_GETOPT_set_one, &numeric},
1010 {'p', "peer", "PEER",
1011 gettext_noop ("peer identity"),
1012 1, &GNUNET_GETOPT_set_string, &cpid},
1015 ("send data for benchmarking to the other peer (until CTRL-C)"),
1016 0, &GNUNET_GETOPT_set_one, &benchmark_send},
1018 gettext_noop ("test transport configuration (involves external server)"),
1019 0, &GNUNET_GETOPT_set_one, &test_configuration},
1020 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
1021 GNUNET_GETOPT_OPTION_END
1024 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1027 res = GNUNET_PROGRAM_run (argc, argv, "gnunet-transport",
1029 ("Direct access to transport service."), options,
1031 GNUNET_free ((void *) argv);
1032 if (GNUNET_OK == res)
1038 /* end of gnunet-transport.c */