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;
66 struct GNUNET_TRANSPORT_TryConnectHandle * tc_handle;
71 static int benchmark_send;
76 static int benchmark_receive;
81 static int benchmark_receive;
86 static int iterate_connections;
91 static int test_configuration;
96 static int monitor_connects;
101 static int monitor_connections;
106 static int try_connect;
114 * Global return value (0 success).
119 * Current number of connections in monitor mode
121 static int monitor_connect_counter;
124 * Number of bytes of traffic we received so far.
126 static unsigned long long traffic_received;
129 * Number of bytes of traffic we sent so far.
131 static unsigned long long traffic_sent;
134 * Starting time of transmitting/receiving data.
136 static struct GNUNET_TIME_Absolute start_time;
139 * Handle for current transmission request.
141 static struct GNUNET_TRANSPORT_TransmitHandle *th;
146 struct GNUNET_TRANSPORT_PeerIterateContext *pic;
149 * Identity of the peer we transmit to / connect to.
150 * (equivalent to 'cpid' string).
152 static struct GNUNET_PeerIdentity pid;
155 * Task scheduled for cleanup / termination of the process.
157 static GNUNET_SCHEDULER_TaskIdentifier end;
160 * Task for operation timeout
162 static GNUNET_SCHEDULER_TaskIdentifier op_timeout;
165 static struct GNUNET_CONTAINER_MultiHashMap *peers;
168 * Selected level of verbosity.
170 static int verbosity;
173 * Resolver process handle.
175 struct GNUNET_OS_Process *resolver;
178 * Number of tasks running that still need the resolver.
180 static unsigned int resolver_users;
183 * Number of address resolutions pending
185 static unsigned int address_resolutions;
188 * Address resolutions pending in progress
190 static unsigned int address_resolution_in_progress;
193 * Context for a plugin test.
199 * Handle to the active NAT test.
201 struct GNUNET_NAT_Test *tst;
204 * Task identifier for the timeout.
206 GNUNET_SCHEDULER_TaskIdentifier tsk;
209 * Name of plugin under test.
217 * Task run in monitor mode when the user presses CTRL-C to abort.
218 * Stops monitoring activity.
220 * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *'
221 * @param tc scheduler context
224 shutdown_task (void *cls,
225 const struct GNUNET_SCHEDULER_TaskContext *tc)
227 struct GNUNET_TIME_Relative duration;
228 end = GNUNET_SCHEDULER_NO_TASK;
229 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
231 GNUNET_SCHEDULER_cancel (op_timeout);
232 op_timeout = GNUNET_SCHEDULER_NO_TASK;
234 if (NULL != tc_handle)
236 GNUNET_TRANSPORT_try_connect_cancel (tc_handle);
241 GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);
246 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th);
251 GNUNET_TRANSPORT_disconnect(handle);
256 GNUNET_CONTAINER_multihashmap_destroy (peers);
261 duration = GNUNET_TIME_absolute_get_duration (start_time);
262 FPRINTF (stdout, _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
263 1000 * traffic_sent / (1 + duration.rel_value), traffic_sent,
264 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
266 if (benchmark_receive)
268 duration = GNUNET_TIME_absolute_get_duration (start_time);
269 FPRINTF (stdout, _("Received %llu bytes/s (%llu bytes in %s)\n"),
270 1000 * traffic_received / (1 + duration.rel_value),
272 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
276 struct ResolutionContext *rc_head;
277 struct ResolutionContext *rc_tail;
279 struct ResolutionContext
281 struct ResolutionContext *next;
282 struct ResolutionContext *prev;
283 struct GNUNET_HELLO_Address *addrcp;
284 struct GNUNET_TRANSPORT_AddressToStringContext *asc;
290 operation_timeout (void *cls,
291 const struct GNUNET_SCHEDULER_TaskContext *tc)
293 struct ResolutionContext *cur;
294 struct ResolutionContext *next;
295 op_timeout = GNUNET_SCHEDULER_NO_TASK;
296 if ((try_connect) || (benchmark_send) ||
299 FPRINTF (stdout, _("Failed to connect to `%s'\n"), GNUNET_h2s_full (&pid.hashPubKey));
300 if (GNUNET_SCHEDULER_NO_TASK != end)
301 GNUNET_SCHEDULER_cancel (end);
302 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
306 if (iterate_connections)
309 while (NULL != (cur = next))
312 FPRINTF (stdout, _("Failed to resolve address for peer `%s'\n"),
313 GNUNET_i2s (&cur->addrcp->peer));
315 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, cur);
316 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
317 GNUNET_free (cur->addrcp);
321 FPRINTF (stdout, _("Failed to list connections, timeout occured\n"));
322 if (GNUNET_SCHEDULER_NO_TASK != end)
323 GNUNET_SCHEDULER_cancel (end);
324 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
334 * Display the result of the test.
336 * @param tc test context
337 * @param result GNUNET_YES on success
340 display_test_result (struct TestContext *tc, int result)
342 if (GNUNET_YES != result)
344 FPRINTF (stderr, "Configuration for plugin `%s' did not work!\n", tc->name);
348 FPRINTF (stderr, "Configuration for plugin `%s' is working!\n", tc->name);
350 if (GNUNET_SCHEDULER_NO_TASK != tc->tsk)
352 GNUNET_SCHEDULER_cancel (tc->tsk);
353 tc->tsk = GNUNET_SCHEDULER_NO_TASK;
357 GNUNET_NAT_test_stop (tc->tst);
362 if ((0 == resolver_users) && (NULL != resolver))
364 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
365 GNUNET_OS_process_destroy (resolver);
372 * Function called by NAT on success.
373 * Clean up and update GUI (with success).
375 * @param cls test context
376 * @param success currently always GNUNET_OK
379 result_callback (void *cls, int success)
381 struct TestContext *tc = cls;
383 display_test_result (tc, success);
388 * Function called if NAT failed to confirm success.
389 * Clean up and update GUI (with failure).
391 * @param cls test context
392 * @param tc scheduler callback
395 fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
397 struct TestContext *tstc = cls;
399 tstc->tsk = GNUNET_SCHEDULER_NO_TASK;
400 display_test_result (tstc, GNUNET_NO);
405 * Test our plugin's configuration (NAT traversal, etc.).
407 * @param cfg configuration to test
410 do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
414 unsigned long long bnd_port;
415 unsigned long long adv_port;
416 struct TestContext *tc;
419 GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins",
425 ("No transport plugins configured, peer will never communicate\n"));
429 for (tok = strtok (plugins, " "); tok != NULL; tok = strtok (NULL, " "))
431 char section[12 + strlen (tok)];
433 GNUNET_snprintf (section, sizeof (section), "transport-%s", tok);
435 GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT", &bnd_port))
438 _("No port configured for plugin `%s', cannot test it\n"), tok);
442 GNUNET_CONFIGURATION_get_value_number (cfg, section, "ADVERTISED_PORT",
445 if (NULL == resolver)
447 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-resolver",
448 "gnunet-service-resolver", NULL);
450 GNUNET_RESOLVER_connect (cfg);
451 tc = GNUNET_malloc (sizeof (struct TestContext));
452 tc->name = GNUNET_strdup (tok);
454 GNUNET_NAT_test_start (cfg,
457 "udp")) ? GNUNET_NO : GNUNET_YES,
458 (uint16_t) bnd_port, (uint16_t) adv_port,
459 &result_callback, tc);
462 display_test_result (tc, GNUNET_SYSERR);
465 tc->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, tc);
467 GNUNET_free (plugins);
471 * Function called to notify a client about the socket
472 * begin ready to queue more data. "buf" will be
473 * NULL and "size" zero if the socket was closed for
474 * writing in the meantime.
477 * @param size number of bytes available in buf
478 * @param buf where the callee should write the message
479 * @return number of bytes written to buf
482 transmit_data (void *cls, size_t size, void *buf)
484 struct GNUNET_MessageHeader *m = buf;
486 if ((NULL == buf) && (0 == size))
492 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
493 GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
494 m->size = ntohs (size);
495 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
496 memset (&m[1], 52, size - sizeof (struct GNUNET_MessageHeader));
497 traffic_sent += size;
498 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, BLOCKSIZE * 1024, 0,
499 GNUNET_TIME_UNIT_FOREVER_REL,
500 &transmit_data, NULL);
502 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size,
509 * Function called to notify transport users that another
510 * peer connected to us.
513 * @param peer the peer that connected
514 * @param ats performance data
515 * @param ats_count number of entries in ats (excluding 0-termination)
518 notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
519 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
521 if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
526 /* all done, terminate instantly */
527 FPRINTF (stdout, _("Successfully connected to `%s'\n"), GNUNET_h2s_full (&peer->hashPubKey));
530 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
532 GNUNET_SCHEDULER_cancel (op_timeout);
533 op_timeout = GNUNET_SCHEDULER_NO_TASK;
536 if (GNUNET_SCHEDULER_NO_TASK != end)
537 GNUNET_SCHEDULER_cancel (end);
538 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
543 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
545 GNUNET_SCHEDULER_cancel (op_timeout);
546 op_timeout = GNUNET_SCHEDULER_NO_TASK;
549 FPRINTF (stdout, _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
550 GNUNET_i2s (&pid), BLOCKSIZE);
551 start_time = GNUNET_TIME_absolute_get ();
553 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer,
555 GNUNET_TIME_UNIT_FOREVER_REL,
556 &transmit_data, NULL);
565 * Function called to notify transport users that another
566 * peer disconnected from us.
569 * @param peer the peer that disconnected
572 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
574 if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
579 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
584 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"), GNUNET_i2s (&pid));
585 if (GNUNET_SCHEDULER_NO_TASK != end)
586 GNUNET_SCHEDULER_cancel (end);
592 * Function called to notify transport users that another
593 * peer connected to us.
596 * @param peer the peer that connected
597 * @param ats performance data
598 * @param ats_count number of entries in ats (excluding 0-termination)
601 monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
602 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
604 monitor_connect_counter ++;
605 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
606 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
608 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
612 monitor_connect_counter);
617 * Function called to notify transport users that another
618 * peer disconnected from us.
621 * @param peer the peer that disconnected
624 monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
626 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
627 const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
629 GNUNET_assert (monitor_connect_counter > 0);
630 monitor_connect_counter --;
632 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
634 _("Disconnected from"),
636 monitor_connect_counter);
642 * Function called by the transport for each received message.
645 * @param peer (claimed) identity of the other peer
646 * @param message the message
647 * @param ats performance data
648 * @param ats_count number of entries in ats
651 notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
652 const struct GNUNET_MessageHeader *message,
653 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
655 if (benchmark_receive)
657 if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type))
660 FPRINTF (stdout, _("Received %u bytes from %s\n"),
661 (unsigned int) ntohs (message->size), GNUNET_i2s (peer));
663 if (traffic_received == 0)
664 start_time = GNUNET_TIME_absolute_get ();
665 traffic_received += ntohs (message->size);
672 process_string (void *cls, const char *address)
674 struct ResolutionContext *rc = cls;
675 struct GNUNET_HELLO_Address *addrcp = rc->addrcp;
679 FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name, address);
680 rc->printed = GNUNET_YES;
685 GNUNET_assert (address_resolutions > 0);
686 address_resolutions --;
687 if (GNUNET_NO == rc->printed)
688 FPRINTF (stdout, _("Peer `%s': %s <unable to resolve address>\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name);
689 GNUNET_free (rc->addrcp);
690 GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc);
692 if ((0 == address_resolutions) && (iterate_connections))
694 if (GNUNET_SCHEDULER_NO_TASK != end)
696 GNUNET_SCHEDULER_cancel (end);
697 end = GNUNET_SCHEDULER_NO_TASK;
699 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
701 GNUNET_SCHEDULER_cancel (op_timeout);
702 op_timeout = GNUNET_SCHEDULER_NO_TASK;
705 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
712 * Function to call with a binary address
715 * @param peer identity of the peer
716 * @param address binary address (NULL on disconnect)
719 process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
720 const struct GNUNET_HELLO_Address *address)
722 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
723 struct ResolutionContext *rc;
728 address_resolution_in_progress = GNUNET_NO;
730 if (GNUNET_SCHEDULER_NO_TASK != end)
731 GNUNET_SCHEDULER_cancel (end);
732 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
737 FPRINTF (stdout, _("Peer `%s' disconnected\n"), GNUNET_i2s (peer));
741 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
742 GNUNET_SCHEDULER_cancel (op_timeout);
743 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
744 &operation_timeout, NULL);
746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received address for peer `%s': %s\n",
747 GNUNET_i2s (peer), address->transport_name);
749 rc = GNUNET_malloc(sizeof (struct ResolutionContext));
750 GNUNET_assert (NULL != rc);
751 GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc);
752 address_resolutions ++;
754 rc->addrcp = GNUNET_HELLO_address_copy(address);
755 rc->printed = GNUNET_NO;
756 /* Resolve address to string */
757 rc->asc = GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
758 RESOLUTION_TIMEOUT, &process_string,
763 void try_connect_cb (void *cls,
766 static int retries = 0;
767 if (GNUNET_OK == result)
774 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL);
777 FPRINTF (stderr, "%s", _("Failed to send connect request to transport service\n"));
778 if (GNUNET_SCHEDULER_NO_TASK != end)
779 GNUNET_SCHEDULER_cancel (end);
781 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
788 testservice_task (void *cls,
789 const struct GNUNET_SCHEDULER_TaskContext *tc)
791 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
795 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
797 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
801 if ((NULL != cpid) && (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey)))
803 FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
807 counter = benchmark_send + benchmark_receive + iterate_connections +
808 monitor_connections + monitor_connects + try_connect;
812 FPRINTF (stderr, _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s\n"),
813 "connect", "benchmark send", "benchmark receive", "information", "monitor", "events");
818 FPRINTF (stderr, _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s\n"),
819 "connect", "benchmark send", "benchmark receive", "information", "monitor", "events");
823 if (try_connect) /* -C: Connect to peer */
827 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
832 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
838 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
842 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL);
843 if (NULL == tc_handle)
845 FPRINTF (stderr, "%s", _("Failed to send request to transport service\n"));
849 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
850 &operation_timeout, NULL);
853 else if (benchmark_send) /* -s: Benchmark sending */
857 FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
862 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
868 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
872 tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL);
873 if (NULL == tc_handle)
875 FPRINTF (stderr, "%s", _("Failed to send request to transport service\n"));
879 start_time = GNUNET_TIME_absolute_get ();
880 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
881 &operation_timeout, NULL);
883 else if (benchmark_receive) /* -b: Benchmark receiving */
886 GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive,
890 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
895 FPRINTF (stdout, "%s", _("Starting to receive benchmark data\n"));
896 start_time = GNUNET_TIME_absolute_get ();
899 else if (iterate_connections) /* -i: List all active addresses once */
901 peers = GNUNET_CONTAINER_multihashmap_create (20, GNUNET_NO);
902 address_resolution_in_progress = GNUNET_YES;
903 pic = GNUNET_TRANSPORT_peer_get_active_addresses (cfg,
904 (NULL == cpid) ? NULL : &pid,
907 &process_address, (void *) cfg);
908 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
909 &operation_timeout, NULL);
911 else if (monitor_connections) /* -m: List all active addresses continously */
913 peers = GNUNET_CONTAINER_multihashmap_create (20, GNUNET_NO);
914 address_resolution_in_progress = GNUNET_YES;
915 pic = GNUNET_TRANSPORT_peer_get_active_addresses (cfg,
916 (NULL == cpid) ? NULL : &pid,
919 &process_address, (void *) cfg);
921 else if (monitor_connects) /* -e : Monitor (dis)connect events continously */
923 monitor_connect_counter = 0;
924 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL,
925 &monitor_notify_connect,
926 &monitor_notify_disconnect);
929 FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
941 end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
949 * Main function that will be run by the scheduler.
952 * @param args remaining command-line arguments
953 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
954 * @param cfg configuration
957 run (void *cls, char *const *args, const char *cfgfile,
958 const struct GNUNET_CONFIGURATION_Handle *cfg)
960 if (test_configuration)
962 do_test_configuration (cfg);
966 GNUNET_CLIENT_service_test ("transport", cfg,
967 GNUNET_TIME_UNIT_SECONDS,
974 main (int argc, char *const *argv)
977 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
978 {'b', "benchmark", NULL,
979 gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"),
980 0, &GNUNET_GETOPT_set_one, &benchmark_receive},
981 {'C', "connect", NULL,
982 gettext_noop ("connect to a peer"),
983 0, &GNUNET_GETOPT_set_one, &try_connect},
984 {'i', "information", NULL,
985 gettext_noop ("provide information about all current connections (once)"),
986 0, &GNUNET_GETOPT_set_one, &iterate_connections},
987 {'m', "monitor", NULL,
988 gettext_noop ("provide information about all current connections (continuously)"),
989 0, &GNUNET_GETOPT_set_one, &monitor_connections},
990 {'e', "events", NULL,
991 gettext_noop ("provide information about all connects and disconnect events (continuously)"),
992 0, &GNUNET_GETOPT_set_one, &monitor_connects},
993 {'n', "numeric", NULL,
994 gettext_noop ("do not resolve hostnames"),
995 0, &GNUNET_GETOPT_set_one, &numeric},
996 {'p', "peer", "PEER",
997 gettext_noop ("peer identity"),
998 1, &GNUNET_GETOPT_set_string, &cpid},
1001 ("send data for benchmarking to the other peer (until CTRL-C)"),
1002 0, &GNUNET_GETOPT_set_one, &benchmark_send},
1004 gettext_noop ("test transport configuration (involves external server)"),
1005 0, &GNUNET_GETOPT_set_one, &test_configuration},
1006 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
1007 GNUNET_GETOPT_OPTION_END
1010 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1013 res = GNUNET_PROGRAM_run (argc, argv, "gnunet-transport",
1015 ("Direct access to transport service."), options,
1017 GNUNET_free ((void *) argv);
1018 if (GNUNET_OK == res)
1024 /* end of gnunet-transport.c */