aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-transport-profiler.c223
-rw-r--r--src/transport/perf_tcp_peer1.conf21
-rw-r--r--src/transport/perf_tcp_peer2.conf22
3 files changed, 166 insertions, 100 deletions
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c
index f37d2f8a4..8c41ea2b5 100644
--- a/src/transport/gnunet-transport-profiler.c
+++ b/src/transport/gnunet-transport-profiler.c
@@ -29,10 +29,20 @@
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_resolver_service.h"
33#include "gnunet_protocols.h" 32#include "gnunet_protocols.h"
34#include "gnunet_transport_service.h" 33#include "gnunet_transport_service.h"
35#include "gnunet_nat_lib.h" 34
35struct Iteration
36{
37 struct Iteration *next;
38 struct Iteration *prev;
39 struct GNUNET_TIME_Absolute start;
40 struct GNUNET_TIME_Absolute end;
41
42 struct GNUNET_TIME_Relative dur;
43
44 unsigned int msgs_sent;
45};
36 46
37 47
38/** 48/**
@@ -51,6 +61,11 @@
51#define DEFAULT_MESSAGE_COUNT 1024 61#define DEFAULT_MESSAGE_COUNT 1024
52 62
53/** 63/**
64 * Benchmarking iteration count
65 */
66#define DEFAULT_ITERATION_COUNT 1
67
68/**
54 * Option -s. 69 * Option -s.
55 */ 70 */
56static int benchmark_send; 71static int benchmark_send;
@@ -66,11 +81,21 @@ static int benchmark_receive;
66static unsigned int benchmark_count; 81static unsigned int benchmark_count;
67 82
68/** 83/**
84 * Option -i.
85 */
86static unsigned int benchmark_iterations;
87
88/**
69 * Option -m. 89 * Option -m.
70 */ 90 */
71static unsigned int benchmark_size; 91static unsigned int benchmark_size;
72 92
73/** 93/**
94 * Benchmark running
95 */
96static unsigned int benchmark_running;
97
98/**
74 * Which peer should we connect to? 99 * Which peer should we connect to?
75 */ 100 */
76static char *cpid; 101static char *cpid;
@@ -91,27 +116,14 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
91struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle; 116struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle;
92 117
93 118
119struct Iteration *ihead;
120struct Iteration *itail;
94 121
95/** 122/**
96 * Global return value (0 success). 123 * Global return value (0 success).
97 */ 124 */
98static int ret; 125static int ret;
99/** 126/**
100 * Number of bytes of traffic we received so far.
101 */
102static unsigned long long traffic_received;
103
104/**
105 * Number of bytes of traffic we sent so far.
106 */
107static unsigned long long traffic_sent;
108
109/**
110 * Starting time of transmitting/receiving data.
111 */
112static struct GNUNET_TIME_Absolute start_time;
113
114/**
115 * Handle for current transmission request. 127 * Handle for current transmission request.
116 */ 128 */
117static struct GNUNET_TRANSPORT_TransmitHandle *th; 129static struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -130,11 +142,6 @@ static struct GNUNET_PeerIdentity pid;
130static GNUNET_SCHEDULER_TaskIdentifier end; 142static GNUNET_SCHEDULER_TaskIdentifier end;
131 143
132/** 144/**
133 * Task for operation timeout
134 */
135static GNUNET_SCHEDULER_TaskIdentifier op_timeout;
136
137/**
138 * Selected level of verbosity. 145 * Selected level of verbosity.
139 */ 146 */
140static int verbosity; 147static int verbosity;
@@ -150,14 +157,8 @@ static void
150shutdown_task (void *cls, 157shutdown_task (void *cls,
151 const struct GNUNET_SCHEDULER_TaskContext *tc) 158 const struct GNUNET_SCHEDULER_TaskContext *tc)
152{ 159{
153 struct GNUNET_TIME_Relative duration; 160 struct Iteration *icur;
154 161 struct Iteration *inext;
155 end = GNUNET_SCHEDULER_NO_TASK;
156 if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
157 {
158 GNUNET_SCHEDULER_cancel (op_timeout);
159 op_timeout = GNUNET_SCHEDULER_NO_TASK;
160 }
161 162
162 if (NULL != tc_handle) 163 if (NULL != tc_handle)
163 { 164 {
@@ -169,26 +170,45 @@ shutdown_task (void *cls,
169 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 170 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
170 th = NULL; 171 th = NULL;
171 } 172 }
172 if (NULL != handle) 173
173 {
174 GNUNET_TRANSPORT_disconnect (handle);
175 handle = NULL;
176 }
177 if (NULL != bl_handle ) 174 if (NULL != bl_handle )
178 { 175 {
179 GNUNET_TRANSPORT_blacklist_cancel (bl_handle); 176 GNUNET_TRANSPORT_blacklist_cancel (bl_handle);
180 bl_handle = NULL; 177 bl_handle = NULL;
181 } 178 }
182#if 0 179
180 if (NULL != handle)
181 {
182 GNUNET_TRANSPORT_disconnect (handle);
183 handle = NULL;
184 }
185
183 if (benchmark_send) 186 if (benchmark_send)
184 { 187 {
185 duration = GNUNET_TIME_absolute_get_duration (start_time); 188 inext = ihead;
186 FPRINTF (stdout, 189 while (NULL != (icur = inext))
187 _("Transmitted %llu bytes/s (%llu bytes in %s)\n"), 190 {
188 1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us), 191 inext = icur->next;
189 traffic_sent, 192 if (verbosity > 0)
190 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); 193 FPRINTF (stdout, _("%llu B in %llu ms == %.2f KB/s!\n"),
194 ((long long unsigned int) benchmark_count * benchmark_size),
195 ((long long unsigned int) itail->dur.rel_value_us / 1000),
196 (float) ((benchmark_count * benchmark_size) / 1024)/ ((float) itail->dur.rel_value_us / (1000 * 1000)));
197 }
198 FPRINTF (stdout, _("%u;%u"),benchmark_count, benchmark_size);
199 inext = ihead;
200 while (NULL != (icur = inext))
201 {
202 inext = icur->next;
203 GNUNET_CONTAINER_DLL_remove (ihead, itail, icur);
204
205 FPRINTF (stdout, _(";%llu"),
206 (long long unsigned int) icur->dur.rel_value_us);
207
208 GNUNET_free (icur);
209 }
191 } 210 }
211#if 0
192 if (benchmark_receive) 212 if (benchmark_receive)
193 { 213 {
194 duration = GNUNET_TIME_absolute_get_duration (start_time); 214 duration = GNUNET_TIME_absolute_get_duration (start_time);
@@ -199,28 +219,11 @@ shutdown_task (void *cls,
199 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); 219 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
200 } 220 }
201#endif 221#endif
222 FPRINTF (stdout, _("\n"));
202} 223}
203 224
204
205static void 225static void
206operation_timeout (void *cls, 226iteration_done ();
207 const struct GNUNET_SCHEDULER_TaskContext *tc)
208{
209
210 op_timeout = GNUNET_SCHEDULER_NO_TASK;
211 if ((benchmark_send) || (benchmark_receive))
212 {
213 FPRINTF (stdout,
214 _("Failed to connect to `%s'\n"),
215 GNUNET_i2s_full (&pid));
216 if (GNUNET_SCHEDULER_NO_TASK != end)
217 GNUNET_SCHEDULER_cancel (end);
218 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
219 ret = 1;
220 return;
221 }
222}
223
224 227
225/** 228/**
226 * Function called to notify a client about the socket 229 * Function called to notify a client about the socket
@@ -238,60 +241,58 @@ transmit_data (void *cls,
238 size_t size, 241 size_t size,
239 void *buf) 242 void *buf)
240{ 243{
241 static msgs_sent = 0;
242 struct GNUNET_MessageHeader *m = buf; 244 struct GNUNET_MessageHeader *m = buf;
243 245
244 246 th = NULL;
245 if ((NULL == buf) || (0 == size)) 247 if ((NULL == buf) || (0 == size))
246 { 248 {
247 th = NULL; 249 th = NULL;
248 return 0; 250 return 0;
249 } 251 }
250 252
251 msgs_sent ++; 253 itail->msgs_sent ++;
252 254
253 GNUNET_assert(size >= sizeof(struct GNUNET_MessageHeader)); 255 GNUNET_assert(size >= sizeof(struct GNUNET_MessageHeader));
254 GNUNET_assert(size < GNUNET_SERVER_MAX_MESSAGE_SIZE); 256 GNUNET_assert(size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
255 m->size = ntohs (size); 257 m->size = ntohs (size);
256 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY); 258 m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY);
257 memset (&m[1], 52, size - sizeof(struct GNUNET_MessageHeader)); 259 memset (&m[1], 52, size - sizeof(struct GNUNET_MessageHeader));
258 traffic_sent += size;
259 260
260 if (msgs_sent <benchmark_count) 261 if (itail->msgs_sent < benchmark_count)
261 { 262 {
262 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, 263 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, benchmark_size,
263 benchmark_size, 264 GNUNET_TIME_UNIT_FOREVER_REL, &transmit_data, NULL );
264 GNUNET_TIME_UNIT_FOREVER_REL,
265 &transmit_data, NULL);
266 } 265 }
267 else 266 else
268 { 267 {
269 if (verbosity > 0) 268
270 FPRINTF (stdout, _("DONE!\n")); 269 iteration_done();
271 return size; 270 return size;
272 } 271 }
273 if (verbosity > 0) 272 if (verbosity > 0)
274 FPRINTF (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size, 273 if (itail->msgs_sent % 10 == 0 )
275 GNUNET_i2s (&pid)); 274 FPRINTF (stdout, _("."));
276 return size; 275 return size;
277} 276}
278 277
278
279static void 279static void
280start_benchmark () 280iteration_start ()
281{ 281{
282 struct Iteration *icur;
282 ret = 0; 283 ret = 0;
284
283 if (benchmark_send) 285 if (benchmark_send)
284 { 286 {
285 if (GNUNET_SCHEDULER_NO_TASK != op_timeout) 287 benchmark_running = GNUNET_YES;
286 { 288 icur = GNUNET_new (struct Iteration);
287 GNUNET_SCHEDULER_cancel (op_timeout); 289 GNUNET_CONTAINER_DLL_insert_tail (ihead, itail, icur);
288 op_timeout = GNUNET_SCHEDULER_NO_TASK; 290 icur->start = GNUNET_TIME_absolute_get();
289 } 291
290 if (verbosity > 0) 292 if (verbosity > 0)
291 FPRINTF (stdout, 293 FPRINTF (stdout,
292 _("Successfully connected to `%s', starting to send %u messages in %u byte blocks\n"), 294 _("\nStarting benchmark to `%s', starting to send %u messages in %u byte blocks\n"),
293 GNUNET_i2s (&pid), benchmark_count, benchmark_size); 295 GNUNET_i2s (&pid), benchmark_count, benchmark_size);
294 start_time = GNUNET_TIME_absolute_get ();
295 if (NULL == th) 296 if (NULL == th)
296 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, benchmark_size, 297 th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, benchmark_size,
297 GNUNET_TIME_UNIT_FOREVER_REL, &transmit_data, NULL ); 298 GNUNET_TIME_UNIT_FOREVER_REL, &transmit_data, NULL );
@@ -301,6 +302,28 @@ start_benchmark ()
301 } 302 }
302} 303}
303 304
305static void
306iteration_done ()
307{
308 static int it_count = 0;
309 it_count ++;
310
311 itail->dur = GNUNET_TIME_absolute_get_duration (itail->start);
312 if (it_count == benchmark_iterations)
313 {
314 benchmark_running = GNUNET_NO;
315 if (GNUNET_SCHEDULER_NO_TASK != end)
316 GNUNET_SCHEDULER_cancel (end);
317 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
318 return;
319 }
320 else
321 {
322 iteration_start ();
323 }
324}
325
326
304 327
305/** 328/**
306 * Function called to notify transport users that another 329 * Function called to notify transport users that another
@@ -331,7 +354,7 @@ notify_connect (void *cls,
331 tc_handle = NULL; 354 tc_handle = NULL;
332 } 355 }
333 356
334 start_benchmark (); 357 iteration_start ();
335} 358}
336 359
337 360
@@ -348,12 +371,10 @@ notify_disconnect (void *cls,
348{ 371{
349 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) 372 if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
350 return; 373 return;
351 if (benchmark_send) 374 if (GNUNET_YES == benchmark_running)
352 { 375 {
353 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"), 376 FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"),
354 GNUNET_i2s (&pid)); 377 GNUNET_i2s (&pid));
355 if (GNUNET_SCHEDULER_NO_TASK != end)
356 GNUNET_SCHEDULER_cancel (end);
357 return; 378 return;
358 } 379 }
359} 380}
@@ -379,10 +400,6 @@ notify_receive (void *cls,
379 _("Received %u bytes from %s\n"), 400 _("Received %u bytes from %s\n"),
380 (unsigned int) ntohs (message->size), 401 (unsigned int) ntohs (message->size),
381 GNUNET_i2s (peer)); 402 GNUNET_i2s (peer));
382
383 if (traffic_received == 0)
384 start_time = GNUNET_TIME_absolute_get ();
385 traffic_received += ntohs (message->size);
386 return; 403 return;
387 } 404 }
388} 405}
@@ -417,8 +434,8 @@ try_connect_cb (void *cls,
417 _("Failed to send connect request to transport service\n")); 434 _("Failed to send connect request to transport service\n"));
418 if (GNUNET_SCHEDULER_NO_TASK != end) 435 if (GNUNET_SCHEDULER_NO_TASK != end)
419 GNUNET_SCHEDULER_cancel (end); 436 GNUNET_SCHEDULER_cancel (end);
420 ret = 1;
421 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 437 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
438 ret = 1;
422 return; 439 return;
423 } 440 }
424} 441}
@@ -430,15 +447,10 @@ blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
430 { 447 {
431 if (verbosity > 0) 448 if (verbosity > 0)
432 FPRINTF (stdout, 449 FPRINTF (stdout,
433 _("Denying connection to `%s'\n"), 450 _("Denying connection to `%s'\n"), GNUNET_i2s (peer));
434 GNUNET_i2s (&peer));
435 return GNUNET_SYSERR; 451 return GNUNET_SYSERR;
436 } 452 }
437 453
438 if (verbosity > 0)
439 FPRINTF (stdout,
440 _("Permitting connection to `%s'\n"),
441 GNUNET_i2s (&pid));
442 return GNUNET_OK; 454 return GNUNET_OK;
443} 455}
444 456
@@ -455,13 +467,18 @@ static void
455testservice_task (void *cls, int result) 467testservice_task (void *cls, int result)
456{ 468{
457 ret = 1; 469 ret = 1;
458#if 0 470
459 if (GNUNET_YES != result) 471 if (GNUNET_YES != result)
460 { 472 {
461 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport"); 473 FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
462 return; 474 return;
463 } 475 }
464#endif 476
477 if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= benchmark_size)
478 {
479 FPRINTF (stderr, _("Message size too big!\n"));
480 return;
481 }
465 482
466 if (NULL == cpid) 483 if (NULL == cpid)
467 { 484 {
@@ -478,7 +495,8 @@ testservice_task (void *cls, int result)
478 495
479 if (1 == benchmark_send) 496 if (1 == benchmark_send)
480 { 497 {
481 FPRINTF (stderr, 498 if (verbosity > 0)
499 FPRINTF (stderr,
482 _("Trying to send %u messages with size %u to peer `%s'\n"), 500 _("Trying to send %u messages with size %u to peer `%s'\n"),
483 benchmark_count, benchmark_size, GNUNET_i2s (&pid)); 501 benchmark_count, benchmark_size, GNUNET_i2s (&pid));
484 } 502 }
@@ -538,6 +556,8 @@ main (int argc, char * const *argv)
538 int res; 556 int res;
539 benchmark_count = DEFAULT_MESSAGE_COUNT; 557 benchmark_count = DEFAULT_MESSAGE_COUNT;
540 benchmark_size = DEFAULT_MESSAGE_SIZE; 558 benchmark_size = DEFAULT_MESSAGE_SIZE;
559 benchmark_iterations = DEFAULT_ITERATION_COUNT;
560 benchmark_running = GNUNET_NO;
541 561
542 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 562 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
543 563
@@ -547,6 +567,9 @@ main (int argc, char * const *argv)
547 { 'r', "receive", NULL, gettext_noop 567 { 'r', "receive", NULL, gettext_noop
548 ("receive data from peer"), 0, 568 ("receive data from peer"), 0,
549 &GNUNET_GETOPT_set_one, &benchmark_receive}, 569 &GNUNET_GETOPT_set_one, &benchmark_receive},
570 { 'i', "iterations", NULL, gettext_noop
571 ("iterations"), 1,
572 &GNUNET_GETOPT_set_uint, &benchmark_iterations},
550 { 'n', "number", NULL, gettext_noop 573 { 'n', "number", NULL, gettext_noop
551 ("number of messages to send"), 1, 574 ("number of messages to send"), 1,
552 &GNUNET_GETOPT_set_uint, &benchmark_count}, 575 &GNUNET_GETOPT_set_uint, &benchmark_count},
diff --git a/src/transport/perf_tcp_peer1.conf b/src/transport/perf_tcp_peer1.conf
index 26ac32e55..9cca25b3c 100644
--- a/src/transport/perf_tcp_peer1.conf
+++ b/src/transport/perf_tcp_peer1.conf
@@ -31,3 +31,24 @@ PLUGINS = tcp
31[hostlist] 31[hostlist]
32OPTIONS = -b 32OPTIONS = -b
33SERVERS = http://localhost:9080/ 33SERVERS = http://localhost:9080/
34
35[ats]
36# Network specific inbound/outbound quotas
37UNSPECIFIED_QUOTA_IN = unlimited
38UNSPECIFIED_QUOTA_OUT = unlimited
39# LOOPBACK
40LOOPBACK_QUOTA_IN = unlimited
41LOOPBACK_QUOTA_OUT = unlimited
42# LAN
43LAN_QUOTA_IN = unlimited
44LAN_QUOTA_OUT = unlimited
45# WAN
46WAN_QUOTA_IN = unlimited
47WAN_QUOTA_OUT = unlimited
48# WLAN
49WLAN_QUOTA_IN = unlimited
50WLAN_QUOTA_OUT = unlimited
51# BLUETOOTH
52BLUETOOTH_QUOTA_IN = unlimited
53BLUETOOTH_QUOTA_OUT = unlimited
54# ATS options
diff --git a/src/transport/perf_tcp_peer2.conf b/src/transport/perf_tcp_peer2.conf
index dacfe9cc9..8f6b551e9 100644
--- a/src/transport/perf_tcp_peer2.conf
+++ b/src/transport/perf_tcp_peer2.conf
@@ -33,3 +33,25 @@ HTTPPORT = 9080
33OPTIONS = -p 33OPTIONS = -p
34BINDTOIPV4 = YES 34BINDTOIPV4 = YES
35BINDTOIP = 127.0.0.1 35BINDTOIP = 127.0.0.1
36
37[ats]
38# Network specific inbound/outbound quotas
39UNSPECIFIED_QUOTA_IN = unlimited
40UNSPECIFIED_QUOTA_OUT = unlimited
41# LOOPBACK
42LOOPBACK_QUOTA_IN = unlimited
43LOOPBACK_QUOTA_OUT = unlimited
44# LAN
45LAN_QUOTA_IN = unlimited
46LAN_QUOTA_OUT = unlimited
47# WAN
48WAN_QUOTA_IN = unlimited
49WAN_QUOTA_OUT = unlimited
50# WLAN
51WLAN_QUOTA_IN = unlimited
52WLAN_QUOTA_OUT = unlimited
53# BLUETOOTH
54BLUETOOTH_QUOTA_IN = unlimited
55BLUETOOTH_QUOTA_OUT = unlimited
56# ATS options
57