summaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport-profiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-transport-profiler.c')
-rw-r--r--src/transport/gnunet-transport-profiler.c560
1 files changed, 280 insertions, 280 deletions
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c
index d4f8589d1..9451f95da 100644
--- a/src/transport/gnunet-transport-profiler.c
+++ b/src/transport/gnunet-transport-profiler.c
@@ -1,19 +1,19 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2011-2016 GNUnet e.V. 3 Copyright (C) 2011-2016 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License, 7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
@@ -34,8 +34,7 @@
34#include "gnunet_transport_service.h" 34#include "gnunet_transport_service.h"
35 35
36 36
37struct Iteration 37struct Iteration {
38{
39 struct Iteration *next; 38 struct Iteration *next;
40 struct Iteration *prev; 39 struct Iteration *prev;
41 struct GNUNET_TIME_Absolute start; 40 struct GNUNET_TIME_Absolute start;
@@ -54,7 +53,7 @@ struct Iteration
54 * Timeout for a connections 53 * Timeout for a connections
55 */ 54 */
56#define CONNECT_TIMEOUT \ 55#define CONNECT_TIMEOUT \
57 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 56 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
58 57
59/** 58/**
60 * Benchmarking block size in bye 59 * Benchmarking block size in bye
@@ -161,7 +160,7 @@ static unsigned int verbosity;
161 * @param cls NULL 160 * @param cls NULL
162 */ 161 */
163static void 162static void
164shutdown_task (void *cls) 163shutdown_task(void *cls)
165{ 164{
166 struct Iteration *icur; 165 struct Iteration *icur;
167 struct Iteration *inext; 166 struct Iteration *inext;
@@ -174,28 +173,28 @@ shutdown_task (void *cls)
174 float stddev_duration; 173 float stddev_duration;
175 174
176 if (NULL != ats_sh) 175 if (NULL != ats_sh)
177 { 176 {
178 GNUNET_ATS_connectivity_suggest_cancel (ats_sh); 177 GNUNET_ATS_connectivity_suggest_cancel(ats_sh);
179 ats_sh = NULL; 178 ats_sh = NULL;
180 } 179 }
181 if (NULL != bl_handle) 180 if (NULL != bl_handle)
182 { 181 {
183 GNUNET_TRANSPORT_blacklist_cancel (bl_handle); 182 GNUNET_TRANSPORT_blacklist_cancel(bl_handle);
184 bl_handle = NULL; 183 bl_handle = NULL;
185 } 184 }
186 if (NULL != ats) 185 if (NULL != ats)
187 { 186 {
188 GNUNET_ATS_connectivity_done (ats); 187 GNUNET_ATS_connectivity_done(ats);
189 ats = NULL; 188 ats = NULL;
190 } 189 }
191 if (NULL != handle) 190 if (NULL != handle)
192 { 191 {
193 GNUNET_TRANSPORT_core_disconnect (handle); 192 GNUNET_TRANSPORT_core_disconnect(handle);
194 handle = NULL; 193 handle = NULL;
195 } 194 }
196 195
197 if (verbosity > 0) 196 if (verbosity > 0)
198 fprintf (stdout, "\n"); 197 fprintf(stdout, "\n");
199 198
200 /* Output format: 199 /* Output format:
201 * All time values in ms 200 * All time values in ms
@@ -203,95 +202,95 @@ shutdown_task (void *cls)
203 * #messages;#messagesize;#avg_dur;#avg_rate;#duration_i0;#duration_i0;... */ 202 * #messages;#messagesize;#avg_dur;#avg_rate;#duration_i0;#duration_i0;... */
204 203
205 if (benchmark_send) 204 if (benchmark_send)
206 {
207 /* First iteration to calculcate avg and stddev */
208 iterations = 0;
209 avg_duration = 0;
210 avg_rate = 0.0;
211
212 inext = ihead;
213 while (NULL != (icur = inext))
214 {
215 inext = icur->next;
216 icur->rate = ((benchmark_count * benchmark_size) / 1024) /
217 ((float) icur->dur.rel_value_us / (1000 * 1000));
218 if (verbosity > 0)
219 fprintf (stdout,
220 _ ("%llu B in %llu ms == %.2f KB/s!\n"),
221 ((long long unsigned int) benchmark_count * benchmark_size),
222 ((long long unsigned int) icur->dur.rel_value_us / 1000),
223 (float) icur->rate);
224
225 avg_duration += icur->dur.rel_value_us / (1000);
226 avg_rate += icur->rate;
227 iterations++;
228 }
229 if (0 == iterations)
230 iterations = 1; /* avoid division by zero */
231 /* Calculate average rate */
232 avg_rate /= iterations;
233 /* Calculate average duration */
234 avg_duration /= iterations;
235
236 stddev_rate = 0;
237 stddev_duration = 0;
238 inext = ihead;
239 while (NULL != (icur = inext))
240 { 205 {
241 inext = icur->next; 206 /* First iteration to calculcate avg and stddev */
242 stddev_rate += ((icur->rate - avg_rate) * (icur->rate - avg_rate)); 207 iterations = 0;
243 stddev_duration += (((icur->dur.rel_value_us / 1000) - avg_duration) * 208 avg_duration = 0;
244 ((icur->dur.rel_value_us / 1000) - avg_duration)); 209 avg_rate = 0.0;
245 } 210
246 /* Calculate standard deviation rate */ 211 inext = ihead;
247 stddev_rate = stddev_rate / iterations; 212 while (NULL != (icur = inext))
248 stddev_rate = sqrtf (stddev_rate); 213 {
249 214 inext = icur->next;
250 /* Calculate standard deviation duration */ 215 icur->rate = ((benchmark_count * benchmark_size) / 1024) /
251 stddev_duration = stddev_duration / iterations; 216 ((float)icur->dur.rel_value_us / (1000 * 1000));
252 stddev_duration = sqrtf (stddev_duration); 217 if (verbosity > 0)
253 218 fprintf(stdout,
254 /* Output */ 219 _("%llu B in %llu ms == %.2f KB/s!\n"),
255 fprintf (stdout, 220 ((long long unsigned int)benchmark_count * benchmark_size),
256 "%u;%u;%llu;%llu;%.2f;%.2f", 221 ((long long unsigned int)icur->dur.rel_value_us / 1000),
257 benchmark_count, 222 (float)icur->rate);
258 benchmark_size, 223
259 avg_duration, 224 avg_duration += icur->dur.rel_value_us / (1000);
260 (unsigned long long) stddev_duration, 225 avg_rate += icur->rate;
261 avg_rate, 226 iterations++;
262 stddev_rate); 227 }
263 228 if (0 == iterations)
264 inext = ihead; 229 iterations = 1; /* avoid division by zero */
265 while (NULL != (icur = inext)) 230 /* Calculate average rate */
266 { 231 avg_rate /= iterations;
267 inext = icur->next; 232 /* Calculate average duration */
268 GNUNET_CONTAINER_DLL_remove (ihead, itail, icur); 233 avg_duration /= iterations;
269 234
270 fprintf (stdout, 235 stddev_rate = 0;
271 ";%llu;%.2f", 236 stddev_duration = 0;
272 (long long unsigned int) (icur->dur.rel_value_us / 1000), 237 inext = ihead;
273 icur->rate); 238 while (NULL != (icur = inext))
274 239 {
275 GNUNET_free (icur); 240 inext = icur->next;
241 stddev_rate += ((icur->rate - avg_rate) * (icur->rate - avg_rate));
242 stddev_duration += (((icur->dur.rel_value_us / 1000) - avg_duration) *
243 ((icur->dur.rel_value_us / 1000) - avg_duration));
244 }
245 /* Calculate standard deviation rate */
246 stddev_rate = stddev_rate / iterations;
247 stddev_rate = sqrtf(stddev_rate);
248
249 /* Calculate standard deviation duration */
250 stddev_duration = stddev_duration / iterations;
251 stddev_duration = sqrtf(stddev_duration);
252
253 /* Output */
254 fprintf(stdout,
255 "%u;%u;%llu;%llu;%.2f;%.2f",
256 benchmark_count,
257 benchmark_size,
258 avg_duration,
259 (unsigned long long)stddev_duration,
260 avg_rate,
261 stddev_rate);
262
263 inext = ihead;
264 while (NULL != (icur = inext))
265 {
266 inext = icur->next;
267 GNUNET_CONTAINER_DLL_remove(ihead, itail, icur);
268
269 fprintf(stdout,
270 ";%llu;%.2f",
271 (long long unsigned int)(icur->dur.rel_value_us / 1000),
272 icur->rate);
273
274 GNUNET_free(icur);
275 }
276 } 276 }
277 }
278#if 0 277#if 0
279 if (benchmark_receive) 278 if (benchmark_receive)
280 { 279 {
281 duration = GNUNET_TIME_absolute_get_duration (start_time); 280 duration = GNUNET_TIME_absolute_get_duration(start_time);
282 fprintf (stdout, 281 fprintf(stdout,
283 "Received %llu bytes/s (%llu bytes in %s)\n", 282 "Received %llu bytes/s (%llu bytes in %s)\n",
284 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us), 283 1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
285 traffic_received, 284 traffic_received,
286 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); 285 GNUNET_STRINGS_relative_time_to_string(duration, GNUNET_YES));
287 } 286 }
288#endif 287#endif
289 fprintf (stdout, "\n"); 288 fprintf(stdout, "\n");
290} 289}
291 290
292 291
293static void 292static void
294iteration_done (); 293iteration_done();
295 294
296 295
297/** 296/**
@@ -306,66 +305,66 @@ iteration_done ();
306 * @return number of bytes written to @a buf 305 * @return number of bytes written to @a buf
307 */ 306 */
308static void 307static void
309send_msg (void *cls) 308send_msg(void *cls)
310{ 309{
311 struct GNUNET_MQ_Envelope *env; 310 struct GNUNET_MQ_Envelope *env;
312 struct GNUNET_MessageHeader *m; 311 struct GNUNET_MessageHeader *m;
313 312
314 if (NULL == mq) 313 if (NULL == mq)
315 return; 314 return;
316 env = GNUNET_MQ_msg_extra (m, benchmark_size, GNUNET_MESSAGE_TYPE_DUMMY); 315 env = GNUNET_MQ_msg_extra(m, benchmark_size, GNUNET_MESSAGE_TYPE_DUMMY);
317 memset (&m[1], 52, benchmark_size - sizeof (struct GNUNET_MessageHeader)); 316 memset(&m[1], 52, benchmark_size - sizeof(struct GNUNET_MessageHeader));
318 317
319 if (itail->msgs_sent < benchmark_count) 318 if (itail->msgs_sent < benchmark_count)
320 { 319 {
321 GNUNET_MQ_notify_sent (env, &send_msg, NULL); 320 GNUNET_MQ_notify_sent(env, &send_msg, NULL);
322 } 321 }
323 else 322 else
324 { 323 {
325 iteration_done (); 324 iteration_done();
326 } 325 }
327 GNUNET_MQ_send (mq, env); 326 GNUNET_MQ_send(mq, env);
328 if ((verbosity > 0) && (0 == itail->msgs_sent % 10)) 327 if ((verbosity > 0) && (0 == itail->msgs_sent % 10))
329 fprintf (stdout, "."); 328 fprintf(stdout, ".");
330} 329}
331 330
332 331
333static void 332static void
334iteration_start () 333iteration_start()
335{ 334{
336 struct Iteration *icur; 335 struct Iteration *icur;
337 336
338 ret = 0; 337 ret = 0;
339 if (! benchmark_send) 338 if (!benchmark_send)
340 return; 339 return;
341 benchmark_running = GNUNET_YES; 340 benchmark_running = GNUNET_YES;
342 icur = GNUNET_new (struct Iteration); 341 icur = GNUNET_new(struct Iteration);
343 GNUNET_CONTAINER_DLL_insert_tail (ihead, itail, icur); 342 GNUNET_CONTAINER_DLL_insert_tail(ihead, itail, icur);
344 icur->start = GNUNET_TIME_absolute_get (); 343 icur->start = GNUNET_TIME_absolute_get();
345 if (verbosity > 0) 344 if (verbosity > 0)
346 fprintf ( 345 fprintf(
347 stdout, 346 stdout,
348 "\nStarting benchmark, starting to send %u messages in %u byte blocks\n", 347 "\nStarting benchmark, starting to send %u messages in %u byte blocks\n",
349 benchmark_count, 348 benchmark_count,
350 benchmark_size); 349 benchmark_size);
351 send_msg (NULL); 350 send_msg(NULL);
352} 351}
353 352
354 353
355static void 354static void
356iteration_done () 355iteration_done()
357{ 356{
358 static int it_count = 0; 357 static int it_count = 0;
359 358
360 it_count++; 359 it_count++;
361 itail->dur = GNUNET_TIME_absolute_get_duration (itail->start); 360 itail->dur = GNUNET_TIME_absolute_get_duration(itail->start);
362 if (it_count == benchmark_iterations) 361 if (it_count == benchmark_iterations)
363 { 362 {
364 benchmark_running = GNUNET_NO; 363 benchmark_running = GNUNET_NO;
365 GNUNET_SCHEDULER_shutdown (); 364 GNUNET_SCHEDULER_shutdown();
366 return; 365 return;
367 } 366 }
368 iteration_start (); 367 iteration_start();
369} 368}
370 369
371 370
@@ -379,20 +378,20 @@ iteration_done ()
379 * @return NULL 378 * @return NULL
380 */ 379 */
381static void * 380static void *
382notify_connect (void *cls, 381notify_connect(void *cls,
383 const struct GNUNET_PeerIdentity *peer, 382 const struct GNUNET_PeerIdentity *peer,
384 struct GNUNET_MQ_Handle *m) 383 struct GNUNET_MQ_Handle *m)
385{ 384{
386 if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) 385 if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
387 { 386 {
388 fprintf (stdout, "Connected to different peer `%s'\n", GNUNET_i2s (&pid)); 387 fprintf(stdout, "Connected to different peer `%s'\n", GNUNET_i2s(&pid));
389 return NULL; 388 return NULL;
390 } 389 }
391 390
392 if (verbosity > 0) 391 if (verbosity > 0)
393 fprintf (stdout, "Successfully connected to `%s'\n", GNUNET_i2s (&pid)); 392 fprintf(stdout, "Successfully connected to `%s'\n", GNUNET_i2s(&pid));
394 mq = m; 393 mq = m;
395 iteration_start (); 394 iteration_start();
396 return NULL; 395 return NULL;
397} 396}
398 397
@@ -406,20 +405,20 @@ notify_connect (void *cls,
406 * @param internal_cls NULL 405 * @param internal_cls NULL
407 */ 406 */
408static void 407static void
409notify_disconnect (void *cls, 408notify_disconnect(void *cls,
410 const struct GNUNET_PeerIdentity *peer, 409 const struct GNUNET_PeerIdentity *peer,
411 void *internal_cls) 410 void *internal_cls)
412{ 411{
413 if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) 412 if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
414 return; 413 return;
415 mq = NULL; 414 mq = NULL;
416 if (GNUNET_YES == benchmark_running) 415 if (GNUNET_YES == benchmark_running)
417 { 416 {
418 fprintf (stdout, 417 fprintf(stdout,
419 "Disconnected from peer `%s' while benchmarking\n", 418 "Disconnected from peer `%s' while benchmarking\n",
420 GNUNET_i2s (&pid)); 419 GNUNET_i2s(&pid));
421 return; 420 return;
422 } 421 }
423} 422}
424 423
425 424
@@ -431,7 +430,7 @@ notify_disconnect (void *cls,
431 * @return #GNUNET_OK 430 * @return #GNUNET_OK
432 */ 431 */
433static int 432static int
434check_dummy (void *cls, const struct GNUNET_MessageHeader *message) 433check_dummy(void *cls, const struct GNUNET_MessageHeader *message)
435{ 434{
436 return GNUNET_OK; /* all messages are fine */ 435 return GNUNET_OK; /* all messages are fine */
437} 436}
@@ -444,26 +443,26 @@ check_dummy (void *cls, const struct GNUNET_MessageHeader *message)
444 * @param message the message 443 * @param message the message
445 */ 444 */
446static void 445static void
447handle_dummy (void *cls, const struct GNUNET_MessageHeader *message) 446handle_dummy(void *cls, const struct GNUNET_MessageHeader *message)
448{ 447{
449 if (! benchmark_receive) 448 if (!benchmark_receive)
450 return; 449 return;
451 if (verbosity > 0) 450 if (verbosity > 0)
452 fprintf (stdout, 451 fprintf(stdout,
453 "Received %u bytes\n", 452 "Received %u bytes\n",
454 (unsigned int) ntohs (message->size)); 453 (unsigned int)ntohs(message->size));
455} 454}
456 455
457 456
458static int 457static int
459blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer) 458blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
460{ 459{
461 if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) 460 if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
462 { 461 {
463 if (verbosity > 0) 462 if (verbosity > 0)
464 fprintf (stdout, "Denying connection to `%s'\n", GNUNET_i2s (peer)); 463 fprintf(stdout, "Denying connection to `%s'\n", GNUNET_i2s(peer));
465 return GNUNET_SYSERR; 464 return GNUNET_SYSERR;
466 } 465 }
467 return GNUNET_OK; 466 return GNUNET_OK;
468} 467}
469 468
@@ -477,144 +476,145 @@ blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
477 * @param mycfg configuration 476 * @param mycfg configuration
478 */ 477 */
479static void 478static void
480run (void *cls, 479run(void *cls,
481 char *const *args, 480 char *const *args,
482 const char *cfgfile, 481 const char *cfgfile,
483 const struct GNUNET_CONFIGURATION_Handle *mycfg) 482 const struct GNUNET_CONFIGURATION_Handle *mycfg)
484{ 483{
485 struct GNUNET_MQ_MessageHandler handlers[] = 484 struct GNUNET_MQ_MessageHandler handlers[] =
486 {GNUNET_MQ_hd_var_size (dummy, 485 { GNUNET_MQ_hd_var_size(dummy,
487 GNUNET_MESSAGE_TYPE_DUMMY, 486 GNUNET_MESSAGE_TYPE_DUMMY,
488 struct GNUNET_MessageHeader, 487 struct GNUNET_MessageHeader,
489 NULL), 488 NULL),
490 GNUNET_MQ_handler_end ()}; 489 GNUNET_MQ_handler_end() };
491 490
492 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; 491 cfg = (struct GNUNET_CONFIGURATION_Handle *)mycfg;
493 492
494 ret = 1; 493 ret = 1;
495 if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size) 494 if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size)
496 { 495 {
497 fprintf (stderr, "Message size too big!\n"); 496 fprintf(stderr, "Message size too big!\n");
498 return; 497 return;
499 } 498 }
500 499
501 if (NULL == cpid) 500 if (NULL == cpid)
502 { 501 {
503 fprintf (stderr, "No peer identity given\n"); 502 fprintf(stderr, "No peer identity given\n");
504 return; 503 return;
505 } 504 }
506 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, 505 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string(cpid,
507 strlen (cpid), 506 strlen(cpid),
508 &pid.public_key)) 507 &pid.public_key))
509 { 508 {
510 fprintf (stderr, "Failed to parse peer identity `%s'\n", cpid); 509 fprintf(stderr, "Failed to parse peer identity `%s'\n", cpid);
511 return; 510 return;
512 } 511 }
513 if (1 == benchmark_send) 512 if (1 == benchmark_send)
514 { 513 {
515 if (verbosity > 0) 514 if (verbosity > 0)
516 fprintf (stderr, 515 fprintf(stderr,
517 "Trying to send %u messages with size %u to peer `%s'\n", 516 "Trying to send %u messages with size %u to peer `%s'\n",
518 benchmark_count, 517 benchmark_count,
519 benchmark_size, 518 benchmark_size,
520 GNUNET_i2s (&pid)); 519 GNUNET_i2s(&pid));
521 } 520 }
522 else if (1 == benchmark_receive) 521 else if (1 == benchmark_receive)
523 { 522 {
524 fprintf (stderr, 523 fprintf(stderr,
525 "Trying to receive messages from peer `%s'\n", 524 "Trying to receive messages from peer `%s'\n",
526 GNUNET_i2s (&pid)); 525 GNUNET_i2s(&pid));
527 } 526 }
528 else 527 else
529 { 528 {
530 fprintf (stderr, "No operation given\n"); 529 fprintf(stderr, "No operation given\n");
531 return; 530 return;
532 } 531 }
533 532
534 ats = GNUNET_ATS_connectivity_init (cfg); 533 ats = GNUNET_ATS_connectivity_init(cfg);
535 if (NULL == ats) 534 if (NULL == ats)
536 { 535 {
537 fprintf (stderr, "Failed to connect to ATS service\n"); 536 fprintf(stderr, "Failed to connect to ATS service\n");
538 ret = 1; 537 ret = 1;
539 return; 538 return;
540 } 539 }
541 540
542 handle = GNUNET_TRANSPORT_core_connect (cfg, 541 handle = GNUNET_TRANSPORT_core_connect(cfg,
543 NULL, 542 NULL,
544 handlers, 543 handlers,
545 NULL, 544 NULL,
546 &notify_connect, 545 &notify_connect,
547 &notify_disconnect, 546 &notify_disconnect,
548 NULL); 547 NULL);
549 if (NULL == handle) 548 if (NULL == handle)
550 { 549 {
551 fprintf (stderr, "Failed to connect to transport service\n"); 550 fprintf(stderr, "Failed to connect to transport service\n");
552 GNUNET_ATS_connectivity_done (ats); 551 GNUNET_ATS_connectivity_done(ats);
553 ats = NULL; 552 ats = NULL;
554 ret = 1; 553 ret = 1;
555 return; 554 return;
556 } 555 }
557 556
558 bl_handle = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_cb, NULL); 557 bl_handle = GNUNET_TRANSPORT_blacklist(cfg, &blacklist_cb, NULL);
559 ats_sh = GNUNET_ATS_connectivity_suggest (ats, &pid, 1); 558 ats_sh = GNUNET_ATS_connectivity_suggest(ats, &pid, 1);
560 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); 559 GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL);
561} 560}
562 561
563 562
564int 563int
565main (int argc, char *const *argv) 564main(int argc, char *const *argv)
566{ 565{
567 int res; 566 int res;
567
568 benchmark_count = DEFAULT_MESSAGE_COUNT; 568 benchmark_count = DEFAULT_MESSAGE_COUNT;
569 benchmark_size = DEFAULT_MESSAGE_SIZE; 569 benchmark_size = DEFAULT_MESSAGE_SIZE;
570 benchmark_iterations = DEFAULT_ITERATION_COUNT; 570 benchmark_iterations = DEFAULT_ITERATION_COUNT;
571 benchmark_running = GNUNET_NO; 571 benchmark_running = GNUNET_NO;
572 572
573 struct GNUNET_GETOPT_CommandLineOption options[] = { 573 struct GNUNET_GETOPT_CommandLineOption options[] = {
574 574 GNUNET_GETOPT_option_flag('s',
575 GNUNET_GETOPT_option_flag ('s', 575 "send",
576 "send", 576 gettext_noop("send data to peer"),
577 gettext_noop ("send data to peer"), 577 &benchmark_send),
578 &benchmark_send), 578 GNUNET_GETOPT_option_flag('r',
579 GNUNET_GETOPT_option_flag ('r', 579 "receive",
580 "receive", 580 gettext_noop("receive data from peer"),
581 gettext_noop ("receive data from peer"), 581 &benchmark_receive),
582 &benchmark_receive), 582 GNUNET_GETOPT_option_uint('i',
583 GNUNET_GETOPT_option_uint ('i', 583 "iterations",
584 "iterations", 584 NULL,
585 NULL, 585 gettext_noop("iterations"),
586 gettext_noop ("iterations"), 586 &benchmark_iterations),
587 &benchmark_iterations), 587 GNUNET_GETOPT_option_uint('n',
588 GNUNET_GETOPT_option_uint ('n', 588 "number",
589 "number", 589 NULL,
590 NULL, 590 gettext_noop("number of messages to send"),
591 gettext_noop ("number of messages to send"), 591 &benchmark_count),
592 &benchmark_count), 592 GNUNET_GETOPT_option_uint('m',
593 GNUNET_GETOPT_option_uint ('m', 593 "messagesize",
594 "messagesize", 594 NULL,
595 NULL, 595 gettext_noop("message size to use"),
596 gettext_noop ("message size to use"), 596 &benchmark_size),
597 &benchmark_size), 597 GNUNET_GETOPT_option_string('p',
598 GNUNET_GETOPT_option_string ('p', 598 "peer",
599 "peer", 599 "PEER",
600 "PEER", 600 gettext_noop("peer identity"),
601 gettext_noop ("peer identity"), 601 &cpid),
602 &cpid), 602 GNUNET_GETOPT_option_verbose(&verbosity),
603 GNUNET_GETOPT_option_verbose (&verbosity), 603 GNUNET_GETOPT_OPTION_END
604 GNUNET_GETOPT_OPTION_END}; 604 };
605 605
606 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 606 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
607 return 2; 607 return 2;
608 608
609 res = 609 res =
610 GNUNET_PROGRAM_run (argc, 610 GNUNET_PROGRAM_run(argc,
611 argv, 611 argv,
612 "gnunet-transport", 612 "gnunet-transport",
613 gettext_noop ("Direct access to transport service."), 613 gettext_noop("Direct access to transport service."),
614 options, 614 options,
615 &run, 615 &run,
616 NULL); 616 NULL);
617 GNUNET_free ((void *) argv); 617 GNUNET_free((void *)argv);
618 if (GNUNET_OK == res) 618 if (GNUNET_OK == res)
619 return ret; 619 return ret;
620 return 1; 620 return 1;