diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 1 | ||||
-rw-r--r-- | src/transport/gnunet-transport-profiler.c | 69 |
2 files changed, 50 insertions, 20 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 001681181..7cd4596df 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -228,6 +228,7 @@ gnunet_transport_profiler_LDADD = \ | |||
228 | libgnunettransport.la \ | 228 | libgnunettransport.la \ |
229 | $(top_builddir)/src/nat/libgnunetnat.la \ | 229 | $(top_builddir)/src/nat/libgnunetnat.la \ |
230 | $(top_builddir)/src/hello/libgnunethello.la \ | 230 | $(top_builddir)/src/hello/libgnunethello.la \ |
231 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
231 | $(top_builddir)/src/util/libgnunetutil.la \ | 232 | $(top_builddir)/src/util/libgnunetutil.la \ |
232 | $(GN_LIBINTL) | 233 | $(GN_LIBINTL) |
233 | 234 | ||
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c index af52a7377..e33a71d17 100644 --- a/src/transport/gnunet-transport-profiler.c +++ b/src/transport/gnunet-transport-profiler.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011-2014 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2011-2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -19,17 +19,18 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/transport/gnunet-transport.c | 22 | * @file src/transport/gnunet-transport-profiler.c |
23 | * @brief Tool to help configure, measure and control the transport subsystem. | 23 | * @brief Tool to help benchmark the transport subsystem. |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * @author Nathan Evans | 25 | * @author Nathan Evans |
26 | * | 26 | * |
27 | * This utility can be used to test if a transport mechanism for | 27 | * This utility can be used to benchmark a transport mechanism for |
28 | * GNUnet is properly configured. | 28 | * GNUnet. |
29 | */ | 29 | */ |
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_protocols.h" | 32 | #include "gnunet_protocols.h" |
33 | #include "gnunet_ats_service.h" | ||
33 | #include "gnunet_transport_service.h" | 34 | #include "gnunet_transport_service.h" |
34 | 35 | ||
35 | struct Iteration | 36 | struct Iteration |
@@ -109,6 +110,11 @@ static char *cpid; | |||
109 | static struct GNUNET_TRANSPORT_Handle *handle; | 110 | static struct GNUNET_TRANSPORT_Handle *handle; |
110 | 111 | ||
111 | /** | 112 | /** |
113 | * Handle to ATS service. | ||
114 | */ | ||
115 | static struct GNUNET_ATS_ConnectivityHandle *ats; | ||
116 | |||
117 | /** | ||
112 | * Configuration handle | 118 | * Configuration handle |
113 | */ | 119 | */ |
114 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 120 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
@@ -116,11 +122,11 @@ static struct GNUNET_CONFIGURATION_Handle *cfg; | |||
116 | /** | 122 | /** |
117 | * Try_connect handle | 123 | * Try_connect handle |
118 | */ | 124 | */ |
119 | struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle; | 125 | static struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle; |
120 | 126 | ||
127 | static struct Iteration *ihead; | ||
121 | 128 | ||
122 | struct Iteration *ihead; | 129 | static struct Iteration *itail; |
123 | struct Iteration *itail; | ||
124 | 130 | ||
125 | /** | 131 | /** |
126 | * Global return value (0 success). | 132 | * Global return value (0 success). |
@@ -131,7 +137,7 @@ static int ret; | |||
131 | */ | 137 | */ |
132 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 138 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
133 | 139 | ||
134 | struct GNUNET_TRANSPORT_Blacklist *bl_handle; | 140 | static struct GNUNET_TRANSPORT_Blacklist *bl_handle; |
135 | 141 | ||
136 | /** | 142 | /** |
137 | * Identity of the peer we transmit to / connect to. | 143 | * Identity of the peer we transmit to / connect to. |
@@ -149,6 +155,7 @@ static struct GNUNET_SCHEDULER_Task * end; | |||
149 | */ | 155 | */ |
150 | static int verbosity; | 156 | static int verbosity; |
151 | 157 | ||
158 | |||
152 | /** | 159 | /** |
153 | * Task run in monitor mode when the user presses CTRL-C to abort. | 160 | * Task run in monitor mode when the user presses CTRL-C to abort. |
154 | * Stops monitoring activity. | 161 | * Stops monitoring activity. |
@@ -186,7 +193,11 @@ shutdown_task (void *cls, | |||
186 | GNUNET_TRANSPORT_blacklist_cancel (bl_handle); | 193 | GNUNET_TRANSPORT_blacklist_cancel (bl_handle); |
187 | bl_handle = NULL; | 194 | bl_handle = NULL; |
188 | } | 195 | } |
189 | 196 | if (NULL != ats) | |
197 | { | ||
198 | GNUNET_ATS_connectivity_done (ats); | ||
199 | ats = NULL; | ||
200 | } | ||
190 | if (NULL != handle) | 201 | if (NULL != handle) |
191 | { | 202 | { |
192 | GNUNET_TRANSPORT_disconnect (handle); | 203 | GNUNET_TRANSPORT_disconnect (handle); |
@@ -283,6 +294,7 @@ shutdown_task (void *cls, | |||
283 | static void | 294 | static void |
284 | iteration_done (); | 295 | iteration_done (); |
285 | 296 | ||
297 | |||
286 | /** | 298 | /** |
287 | * Function called to notify a client about the socket | 299 | * Function called to notify a client about the socket |
288 | * begin ready to queue more data. @a buf will be | 300 | * begin ready to queue more data. @a buf will be |
@@ -360,6 +372,7 @@ iteration_start () | |||
360 | } | 372 | } |
361 | } | 373 | } |
362 | 374 | ||
375 | |||
363 | static void | 376 | static void |
364 | iteration_done () | 377 | iteration_done () |
365 | { | 378 | { |
@@ -382,7 +395,6 @@ iteration_done () | |||
382 | } | 395 | } |
383 | 396 | ||
384 | 397 | ||
385 | |||
386 | /** | 398 | /** |
387 | * Function called to notify transport users that another | 399 | * Function called to notify transport users that another |
388 | * peer connected to us. | 400 | * peer connected to us. |
@@ -437,6 +449,7 @@ notify_disconnect (void *cls, | |||
437 | } | 449 | } |
438 | } | 450 | } |
439 | 451 | ||
452 | |||
440 | /** | 453 | /** |
441 | * Function called by the transport for each received message. | 454 | * Function called by the transport for each received message. |
442 | * | 455 | * |
@@ -463,7 +476,6 @@ notify_receive (void *cls, | |||
463 | } | 476 | } |
464 | 477 | ||
465 | 478 | ||
466 | |||
467 | static void | 479 | static void |
468 | try_connect_cb (void *cls, | 480 | try_connect_cb (void *cls, |
469 | const int result) | 481 | const int result) |
@@ -498,6 +510,7 @@ try_connect_cb (void *cls, | |||
498 | } | 510 | } |
499 | } | 511 | } |
500 | 512 | ||
513 | |||
501 | static int | 514 | static int |
502 | blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer) | 515 | blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer) |
503 | { | 516 | { |
@@ -543,14 +556,14 @@ testservice_task (void *cls, int result) | |||
543 | FPRINTF (stderr, _("No peer identity given\n")); | 556 | FPRINTF (stderr, _("No peer identity given\n")); |
544 | return; | 557 | return; |
545 | } | 558 | } |
546 | if ((GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid), | 559 | if ((GNUNET_OK != |
547 | &pid.public_key))) | 560 | GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid), |
561 | &pid.public_key))) | ||
548 | { | 562 | { |
549 | FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid); | 563 | FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid); |
550 | return; | 564 | return; |
551 | } | 565 | } |
552 | 566 | ||
553 | |||
554 | if (1 == benchmark_send) | 567 | if (1 == benchmark_send) |
555 | { | 568 | { |
556 | if (verbosity > 0) | 569 | if (verbosity > 0) |
@@ -570,18 +583,33 @@ testservice_task (void *cls, int result) | |||
570 | return; | 583 | return; |
571 | } | 584 | } |
572 | 585 | ||
573 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, | 586 | ats = GNUNET_ATS_connectivity_init (cfg); |
574 | ¬ify_connect, ¬ify_disconnect); | 587 | if (NULL == ats) |
588 | { | ||
589 | FPRINTF (stderr, "%s", _("Failed to connect to ATS service\n")); | ||
590 | ret = 1; | ||
591 | return; | ||
592 | } | ||
575 | 593 | ||
594 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, | ||
595 | ¬ify_receive, | ||
596 | ¬ify_connect, | ||
597 | ¬ify_disconnect); | ||
576 | if (NULL == handle) | 598 | if (NULL == handle) |
577 | { | 599 | { |
578 | FPRINTF (stderr, "%s", _("Failed to connect to transport service\n")); | 600 | FPRINTF (stderr, "%s", _("Failed to connect to transport service\n")); |
601 | GNUNET_ATS_connectivity_done (ats); | ||
602 | ats = NULL; | ||
579 | ret = 1; | 603 | ret = 1; |
580 | return; | 604 | return; |
581 | } | 605 | } |
582 | 606 | ||
583 | bl_handle = GNUNET_TRANSPORT_blacklist (cfg, blacklist_cb, NULL); | 607 | bl_handle = GNUNET_TRANSPORT_blacklist (cfg, |
584 | tc_handle = GNUNET_TRANSPORT_try_connect(handle, &pid, try_connect_cb, NULL); | 608 | &blacklist_cb, |
609 | NULL); | ||
610 | tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, | ||
611 | &try_connect_cb, | ||
612 | NULL); | ||
585 | 613 | ||
586 | end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 614 | end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
587 | &shutdown_task, | 615 | &shutdown_task, |
@@ -608,6 +636,7 @@ run (void *cls, | |||
608 | &testservice_task, (void *) cfg); | 636 | &testservice_task, (void *) cfg); |
609 | } | 637 | } |
610 | 638 | ||
639 | |||
611 | int | 640 | int |
612 | main (int argc, char * const *argv) | 641 | main (int argc, char * const *argv) |
613 | { | 642 | { |
@@ -655,4 +684,4 @@ main (int argc, char * const *argv) | |||
655 | return 1; | 684 | return 1; |
656 | } | 685 | } |
657 | 686 | ||
658 | /* end of gnunet-transport.c */ | 687 | /* end of gnunet-transport-profiler.c */ |