diff options
Diffstat (limited to 'src/dht/gnunet_dht_profiler.c')
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 776 |
1 files changed, 396 insertions, 380 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index 179f84a11..5a73880be 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -32,10 +32,10 @@ | |||
32 | 32 | ||
33 | 33 | ||
34 | #define MESSAGE(...) \ | 34 | #define MESSAGE(...) \ |
35 | GNUNET_log(GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__) | 35 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__) |
36 | 36 | ||
37 | #define DEBUG(...) \ | 37 | #define DEBUG(...) \ |
38 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 38 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Number of peers which should perform a PUT out of 100 peers | 41 | * Number of peers which should perform a PUT out of 100 peers |
@@ -60,7 +60,8 @@ struct ActiveContext; | |||
60 | /** | 60 | /** |
61 | * Context to hold data of peer | 61 | * Context to hold data of peer |
62 | */ | 62 | */ |
63 | struct Context { | 63 | struct Context |
64 | { | ||
64 | /** | 65 | /** |
65 | * The testbed peer this context belongs to | 66 | * The testbed peer this context belongs to |
66 | */ | 67 | */ |
@@ -81,7 +82,8 @@ struct Context { | |||
81 | /** | 82 | /** |
82 | * Context for a peer which actively does DHT PUT/GET | 83 | * Context for a peer which actively does DHT PUT/GET |
83 | */ | 84 | */ |
84 | struct ActiveContext { | 85 | struct ActiveContext |
86 | { | ||
85 | /** | 87 | /** |
86 | * The linked peer context | 88 | * The linked peer context |
87 | */ | 89 | */ |
@@ -258,7 +260,8 @@ static int peers_started = 0; | |||
258 | /** | 260 | /** |
259 | * Should we do a PUT (mode = 0) or GET (mode = 1); | 261 | * Should we do a PUT (mode = 0) or GET (mode = 1); |
260 | */ | 262 | */ |
261 | static enum { | 263 | static enum |
264 | { | ||
262 | MODE_PUT = 0, | 265 | MODE_PUT = 0, |
263 | 266 | ||
264 | MODE_GET = 1 | 267 | MODE_GET = 1 |
@@ -275,7 +278,7 @@ static int in_shutdown = 0; | |||
275 | * Connect to DHT services of active peers | 278 | * Connect to DHT services of active peers |
276 | */ | 279 | */ |
277 | static void | 280 | static void |
278 | start_profiling(void); | 281 | start_profiling (void); |
279 | 282 | ||
280 | 283 | ||
281 | /** | 284 | /** |
@@ -284,43 +287,43 @@ start_profiling(void); | |||
284 | * @param cls NULL | 287 | * @param cls NULL |
285 | */ | 288 | */ |
286 | static void | 289 | static void |
287 | do_shutdown(void *cls) | 290 | do_shutdown (void *cls) |
288 | { | 291 | { |
289 | struct ActiveContext *ac; | 292 | struct ActiveContext *ac; |
290 | 293 | ||
291 | in_shutdown = GNUNET_YES; | 294 | in_shutdown = GNUNET_YES; |
292 | if (NULL != a_ctx) | 295 | if (NULL != a_ctx) |
296 | { | ||
297 | for (unsigned int cnt = 0; cnt < num_peers; cnt++) | ||
293 | { | 298 | { |
294 | for (unsigned int cnt = 0; cnt < num_peers; cnt++) | 299 | /* Cleanup active context if this peer is an active peer */ |
295 | { | 300 | ac = a_ctx[cnt].ac; |
296 | /* Cleanup active context if this peer is an active peer */ | 301 | if (NULL != ac) |
297 | ac = a_ctx[cnt].ac; | 302 | { |
298 | if (NULL != ac) | 303 | if (NULL != ac->delay_task) |
299 | { | 304 | GNUNET_SCHEDULER_cancel (ac->delay_task); |
300 | if (NULL != ac->delay_task) | 305 | if (NULL != ac->hash) |
301 | GNUNET_SCHEDULER_cancel(ac->delay_task); | 306 | free (ac->hash); |
302 | if (NULL != ac->hash) | 307 | if (NULL != ac->dht_put) |
303 | free(ac->hash); | 308 | GNUNET_DHT_put_cancel (ac->dht_put); |
304 | if (NULL != ac->dht_put) | 309 | if (NULL != ac->dht_get) |
305 | GNUNET_DHT_put_cancel(ac->dht_put); | 310 | GNUNET_DHT_get_stop (ac->dht_get); |
306 | if (NULL != ac->dht_get) | 311 | } |
307 | GNUNET_DHT_get_stop(ac->dht_get); | 312 | /* Cleanup testbed operation handle at the last as this operation may |
308 | } | 313 | contain service connection to DHT */ |
309 | /* Cleanup testbed operation handle at the last as this operation may | 314 | if (NULL != a_ctx[cnt].op) |
310 | contain service connection to DHT */ | 315 | GNUNET_TESTBED_operation_done (a_ctx[cnt].op); |
311 | if (NULL != a_ctx[cnt].op) | ||
312 | GNUNET_TESTBED_operation_done(a_ctx[cnt].op); | ||
313 | } | ||
314 | GNUNET_free(a_ctx); | ||
315 | a_ctx = NULL; | ||
316 | } | 316 | } |
317 | //FIXME: Should we collect stats only for put/get not for other messages. | 317 | GNUNET_free (a_ctx); |
318 | a_ctx = NULL; | ||
319 | } | ||
320 | // FIXME: Should we collect stats only for put/get not for other messages. | ||
318 | if (NULL != bandwidth_stats_op) | 321 | if (NULL != bandwidth_stats_op) |
319 | { | 322 | { |
320 | GNUNET_TESTBED_operation_done(bandwidth_stats_op); | 323 | GNUNET_TESTBED_operation_done (bandwidth_stats_op); |
321 | bandwidth_stats_op = NULL; | 324 | bandwidth_stats_op = NULL; |
322 | } | 325 | } |
323 | GNUNET_free_non_null(a_ac); | 326 | GNUNET_free_non_null (a_ac); |
324 | } | 327 | } |
325 | 328 | ||
326 | 329 | ||
@@ -334,18 +337,18 @@ do_shutdown(void *cls) | |||
334 | * operation has executed successfully. | 337 | * operation has executed successfully. |
335 | */ | 338 | */ |
336 | static void | 339 | static void |
337 | bandwidth_stats_cont(void *cls, | 340 | bandwidth_stats_cont (void *cls, |
338 | struct GNUNET_TESTBED_Operation *op, | 341 | struct GNUNET_TESTBED_Operation *op, |
339 | const char *emsg) | 342 | const char *emsg) |
340 | { | 343 | { |
341 | MESSAGE("# Outgoing (core) bandwidth: %llu bytes\n", | 344 | MESSAGE ("# Outgoing (core) bandwidth: %llu bytes\n", |
342 | (unsigned long long)outgoing_bandwidth); | 345 | (unsigned long long) outgoing_bandwidth); |
343 | MESSAGE("# Incoming (core) bandwidth: %llu bytes\n", | 346 | MESSAGE ("# Incoming (core) bandwidth: %llu bytes\n", |
344 | (unsigned long long)incoming_bandwidth); | 347 | (unsigned long long) incoming_bandwidth); |
345 | fprintf(stderr, | 348 | fprintf (stderr, |
346 | "Benchmark done. Collect data via gnunet-statistics, then press ENTER to exit.\n"); | 349 | "Benchmark done. Collect data via gnunet-statistics, then press ENTER to exit.\n"); |
347 | (void)getchar(); | 350 | (void) getchar (); |
348 | GNUNET_SCHEDULER_shutdown(); | 351 | GNUNET_SCHEDULER_shutdown (); |
349 | } | 352 | } |
350 | 353 | ||
351 | 354 | ||
@@ -361,55 +364,55 @@ bandwidth_stats_cont(void *cls, | |||
361 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | 364 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
362 | */ | 365 | */ |
363 | static int | 366 | static int |
364 | bandwidth_stats_iterator(void *cls, | 367 | bandwidth_stats_iterator (void *cls, |
365 | const struct GNUNET_TESTBED_Peer *peer, | 368 | const struct GNUNET_TESTBED_Peer *peer, |
366 | const char *subsystem, | 369 | const char *subsystem, |
367 | const char *name, | 370 | const char *name, |
368 | uint64_t value, | 371 | uint64_t value, |
369 | int is_persistent) | 372 | int is_persistent) |
370 | { | 373 | { |
371 | static const char *s_sent = "# bytes encrypted"; | 374 | static const char *s_sent = "# bytes encrypted"; |
372 | static const char *s_recv = "# bytes decrypted"; | 375 | static const char *s_recv = "# bytes decrypted"; |
373 | 376 | ||
374 | if (0 == strncmp(s_sent, name, strlen(s_sent))) | 377 | if (0 == strncmp (s_sent, name, strlen (s_sent))) |
375 | outgoing_bandwidth = outgoing_bandwidth + value; | 378 | outgoing_bandwidth = outgoing_bandwidth + value; |
376 | else if (0 == strncmp(s_recv, name, strlen(s_recv))) | 379 | else if (0 == strncmp (s_recv, name, strlen (s_recv))) |
377 | incoming_bandwidth = incoming_bandwidth + value; | 380 | incoming_bandwidth = incoming_bandwidth + value; |
378 | return GNUNET_OK; | 381 | return GNUNET_OK; |
379 | } | 382 | } |
380 | 383 | ||
381 | 384 | ||
382 | static void | 385 | static void |
383 | summarize() | 386 | summarize () |
384 | { | 387 | { |
385 | MESSAGE("# PUTS started: %llu\n", | 388 | MESSAGE ("# PUTS started: %llu\n", |
386 | n_puts); | 389 | n_puts); |
387 | MESSAGE("# PUTS succeeded: %llu\n", | 390 | MESSAGE ("# PUTS succeeded: %llu\n", |
388 | n_puts_ok); | 391 | n_puts_ok); |
389 | MESSAGE("# GETS made: %u\n", | 392 | MESSAGE ("# GETS made: %u\n", |
390 | n_gets); | 393 | n_gets); |
391 | MESSAGE("# GETS succeeded: %u\n", | 394 | MESSAGE ("# GETS succeeded: %u\n", |
392 | n_gets_ok); | 395 | n_gets_ok); |
393 | MESSAGE("# GETS failed: %u\n", | 396 | MESSAGE ("# GETS failed: %u\n", |
394 | n_gets_fail); | 397 | n_gets_fail); |
395 | MESSAGE("# average_put_path_length: %f\n", | 398 | MESSAGE ("# average_put_path_length: %f\n", |
396 | average_put_path_length); | 399 | average_put_path_length); |
397 | MESSAGE("# average_get_path_length: %f\n", | 400 | MESSAGE ("# average_get_path_length: %f\n", |
398 | average_get_path_length); | 401 | average_get_path_length); |
399 | 402 | ||
400 | if (NULL == testbed_handles) | 403 | if (NULL == testbed_handles) |
401 | { | 404 | { |
402 | MESSAGE("No peers found\n"); | 405 | MESSAGE ("No peers found\n"); |
403 | return; | 406 | return; |
404 | } | 407 | } |
405 | /* Collect Stats*/ | 408 | /* Collect Stats*/ |
406 | bandwidth_stats_op = GNUNET_TESTBED_get_statistics(n_active, | 409 | bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, |
407 | testbed_handles, | 410 | testbed_handles, |
408 | "core", | 411 | "core", |
409 | NULL, | 412 | NULL, |
410 | &bandwidth_stats_iterator, | 413 | &bandwidth_stats_iterator, |
411 | &bandwidth_stats_cont, | 414 | &bandwidth_stats_cont, |
412 | NULL); | 415 | NULL); |
413 | } | 416 | } |
414 | 417 | ||
415 | 418 | ||
@@ -419,27 +422,29 @@ summarize() | |||
419 | * @param cls NULL | 422 | * @param cls NULL |
420 | */ | 423 | */ |
421 | static void | 424 | static void |
422 | cancel_get(void *cls) | 425 | cancel_get (void *cls) |
423 | { | 426 | { |
424 | struct ActiveContext *ac = cls; | 427 | struct ActiveContext *ac = cls; |
425 | struct Context *ctx = ac->ctx; | 428 | struct Context *ctx = ac->ctx; |
426 | 429 | ||
427 | ac->delay_task = NULL; | 430 | ac->delay_task = NULL; |
428 | GNUNET_assert(NULL != ac->dht_get); | 431 | GNUNET_assert (NULL != ac->dht_get); |
429 | GNUNET_DHT_get_stop(ac->dht_get); | 432 | GNUNET_DHT_get_stop (ac->dht_get); |
430 | ac->dht_get = NULL; | 433 | ac->dht_get = NULL; |
431 | n_gets_fail++; | 434 | n_gets_fail++; |
432 | GNUNET_assert(NULL != ctx->op); | 435 | GNUNET_assert (NULL != ctx->op); |
433 | GNUNET_TESTBED_operation_done(ctx->op); | 436 | GNUNET_TESTBED_operation_done (ctx->op); |
434 | ctx->op = NULL; | 437 | ctx->op = NULL; |
435 | 438 | ||
436 | /* If profiling is complete, summarize */ | 439 | /* If profiling is complete, summarize */ |
437 | if (n_active == n_gets_fail + n_gets_ok) | 440 | if (n_active == n_gets_fail + n_gets_ok) |
438 | { | 441 | { |
439 | average_put_path_length = (double)total_put_path_length / (double)n_active; | 442 | average_put_path_length = (double) total_put_path_length |
440 | average_get_path_length = (double)total_get_path_length / (double )n_gets_ok; | 443 | / (double) n_active; |
441 | summarize(); | 444 | average_get_path_length = (double) total_get_path_length |
442 | } | 445 | / (double ) n_gets_ok; |
446 | summarize (); | ||
447 | } | ||
443 | } | 448 | } |
444 | 449 | ||
445 | 450 | ||
@@ -461,45 +466,47 @@ cancel_get(void *cls) | |||
461 | * @param data pointer to the result data | 466 | * @param data pointer to the result data |
462 | */ | 467 | */ |
463 | static void | 468 | static void |
464 | get_iter(void *cls, | 469 | get_iter (void *cls, |
465 | struct GNUNET_TIME_Absolute exp, | 470 | struct GNUNET_TIME_Absolute exp, |
466 | const struct GNUNET_HashCode *key, | 471 | const struct GNUNET_HashCode *key, |
467 | const struct GNUNET_PeerIdentity *get_path, | 472 | const struct GNUNET_PeerIdentity *get_path, |
468 | unsigned int get_path_length, | 473 | unsigned int get_path_length, |
469 | const struct GNUNET_PeerIdentity *put_path, | 474 | const struct GNUNET_PeerIdentity *put_path, |
470 | unsigned int put_path_length, | 475 | unsigned int put_path_length, |
471 | enum GNUNET_BLOCK_Type type, | 476 | enum GNUNET_BLOCK_Type type, |
472 | size_t size, const void *data) | 477 | size_t size, const void *data) |
473 | { | 478 | { |
474 | struct ActiveContext *ac = cls; | 479 | struct ActiveContext *ac = cls; |
475 | struct ActiveContext *get_ac = ac->get_ac; | 480 | struct ActiveContext *get_ac = ac->get_ac; |
476 | struct Context *ctx = ac->ctx; | 481 | struct Context *ctx = ac->ctx; |
477 | 482 | ||
478 | /* we found the data we are looking for */ | 483 | /* we found the data we are looking for */ |
479 | DEBUG("We found a GET request; %u remaining\n", | 484 | DEBUG ("We found a GET request; %u remaining\n", |
480 | n_gets - (n_gets_fail + n_gets_ok)); //FIXME: It always prints 1. | 485 | n_gets - (n_gets_fail + n_gets_ok)); // FIXME: It always prints 1. |
481 | n_gets_ok++; | 486 | n_gets_ok++; |
482 | get_ac->nrefs--; | 487 | get_ac->nrefs--; |
483 | GNUNET_DHT_get_stop(ac->dht_get); | 488 | GNUNET_DHT_get_stop (ac->dht_get); |
484 | ac->dht_get = NULL; | 489 | ac->dht_get = NULL; |
485 | if (ac->delay_task != NULL) | 490 | if (ac->delay_task != NULL) |
486 | GNUNET_SCHEDULER_cancel(ac->delay_task); | 491 | GNUNET_SCHEDULER_cancel (ac->delay_task); |
487 | ac->delay_task = NULL; | 492 | ac->delay_task = NULL; |
488 | GNUNET_assert(NULL != ctx->op); | 493 | GNUNET_assert (NULL != ctx->op); |
489 | GNUNET_TESTBED_operation_done(ctx->op); | 494 | GNUNET_TESTBED_operation_done (ctx->op); |
490 | ctx->op = NULL; | 495 | ctx->op = NULL; |
491 | 496 | ||
492 | total_put_path_length = total_put_path_length + (double)put_path_length; | 497 | total_put_path_length = total_put_path_length + (double) put_path_length; |
493 | total_get_path_length = total_get_path_length + (double)get_path_length; | 498 | total_get_path_length = total_get_path_length + (double) get_path_length; |
494 | DEBUG("total_put_path_length = %u,put_path \n", | 499 | DEBUG ("total_put_path_length = %u,put_path \n", |
495 | total_put_path_length); | 500 | total_put_path_length); |
496 | /* Summarize if profiling is complete */ | 501 | /* Summarize if profiling is complete */ |
497 | if (n_active == n_gets_fail + n_gets_ok) | 502 | if (n_active == n_gets_fail + n_gets_ok) |
498 | { | 503 | { |
499 | average_put_path_length = (double)total_put_path_length / (double)n_active; | 504 | average_put_path_length = (double) total_put_path_length |
500 | average_get_path_length = (double)total_get_path_length / (double )n_gets_ok; | 505 | / (double) n_active; |
501 | summarize(); | 506 | average_get_path_length = (double) total_get_path_length |
502 | } | 507 | / (double ) n_gets_ok; |
508 | summarize (); | ||
509 | } | ||
503 | } | 510 | } |
504 | 511 | ||
505 | 512 | ||
@@ -509,7 +516,7 @@ get_iter(void *cls, | |||
509 | * @param cls the active context | 516 | * @param cls the active context |
510 | */ | 517 | */ |
511 | static void | 518 | static void |
512 | delayed_get(void *cls) | 519 | delayed_get (void *cls) |
513 | { | 520 | { |
514 | struct ActiveContext *ac = cls; | 521 | struct ActiveContext *ac = cls; |
515 | struct ActiveContext *get_ac; | 522 | struct ActiveContext *get_ac; |
@@ -518,34 +525,34 @@ delayed_get(void *cls) | |||
518 | ac->delay_task = NULL; | 525 | ac->delay_task = NULL; |
519 | get_ac = NULL; | 526 | get_ac = NULL; |
520 | while (1) | 527 | while (1) |
521 | { | 528 | { |
522 | r = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, | 529 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
523 | n_active); | 530 | n_active); |
524 | get_ac = &a_ac[r]; | 531 | get_ac = &a_ac[r]; |
525 | if (NULL != get_ac->hash) | 532 | if (NULL != get_ac->hash) |
526 | break; | 533 | break; |
527 | } | 534 | } |
528 | get_ac->nrefs++; | 535 | get_ac->nrefs++; |
529 | ac->get_ac = get_ac; | 536 | ac->get_ac = get_ac; |
530 | r = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, | 537 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
531 | num_puts_per_peer); | 538 | num_puts_per_peer); |
532 | DEBUG("GET_REQUEST_START key %s \n", | 539 | DEBUG ("GET_REQUEST_START key %s \n", |
533 | GNUNET_h2s(&get_ac->hash[r])); | 540 | GNUNET_h2s (&get_ac->hash[r])); |
534 | ac->dht_get = GNUNET_DHT_get_start(ac->dht, | 541 | ac->dht_get = GNUNET_DHT_get_start (ac->dht, |
535 | GNUNET_BLOCK_TYPE_TEST, | 542 | GNUNET_BLOCK_TYPE_TEST, |
536 | &get_ac->hash[r], | 543 | &get_ac->hash[r], |
537 | 1, /* replication level */ | 544 | 1, /* replication level */ |
538 | GNUNET_DHT_RO_NONE, | 545 | GNUNET_DHT_RO_NONE, |
539 | NULL, | 546 | NULL, |
540 | 0, /* extended query and size */ | 547 | 0, /* extended query and size */ |
541 | &get_iter, | 548 | &get_iter, |
542 | ac); /* GET iterator and closure */ | 549 | ac); /* GET iterator and closure */ |
543 | n_gets++; | 550 | n_gets++; |
544 | 551 | ||
545 | /* schedule the timeout task for GET */ | 552 | /* schedule the timeout task for GET */ |
546 | ac->delay_task = GNUNET_SCHEDULER_add_delayed(timeout, | 553 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (timeout, |
547 | &cancel_get, | 554 | &cancel_get, |
548 | ac); | 555 | ac); |
549 | } | 556 | } |
550 | 557 | ||
551 | 558 | ||
@@ -557,7 +564,7 @@ delayed_get(void *cls) | |||
557 | * @param cls the active context | 564 | * @param cls the active context |
558 | */ | 565 | */ |
559 | static void | 566 | static void |
560 | delayed_put(void *cls); | 567 | delayed_put (void *cls); |
561 | 568 | ||
562 | 569 | ||
563 | /** | 570 | /** |
@@ -567,14 +574,14 @@ delayed_put(void *cls); | |||
567 | * @param cls the active context | 574 | * @param cls the active context |
568 | */ | 575 | */ |
569 | static void | 576 | static void |
570 | put_cont(void *cls) | 577 | put_cont (void *cls) |
571 | { | 578 | { |
572 | struct ActiveContext *ac = cls; | 579 | struct ActiveContext *ac = cls; |
573 | 580 | ||
574 | ac->dht_put = NULL; | 581 | ac->dht_put = NULL; |
575 | n_puts_ok++; | 582 | n_puts_ok++; |
576 | ac->delay_task = GNUNET_SCHEDULER_add_now(&delayed_put, | 583 | ac->delay_task = GNUNET_SCHEDULER_add_now (&delayed_put, |
577 | ac); | 584 | ac); |
578 | } | 585 | } |
579 | 586 | ||
580 | 587 | ||
@@ -586,7 +593,7 @@ put_cont(void *cls) | |||
586 | * @param cls the active context | 593 | * @param cls the active context |
587 | */ | 594 | */ |
588 | static void | 595 | static void |
589 | delayed_put(void *cls) | 596 | delayed_put (void *cls) |
590 | { | 597 | { |
591 | struct ActiveContext *ac = cls; | 598 | struct ActiveContext *ac = cls; |
592 | char block[65536]; | 599 | char block[65536]; |
@@ -594,42 +601,43 @@ delayed_put(void *cls) | |||
594 | 601 | ||
595 | ac->delay_task = NULL; | 602 | ac->delay_task = NULL; |
596 | if (0 == ac->put_count) | 603 | if (0 == ac->put_count) |
597 | { | 604 | { |
598 | struct Context *ctx = ac->ctx; | 605 | struct Context *ctx = ac->ctx; |
599 | struct GNUNET_TESTBED_Operation *op; | 606 | struct GNUNET_TESTBED_Operation *op; |
600 | 607 | ||
601 | GNUNET_assert(NULL != ctx); | 608 | GNUNET_assert (NULL != ctx); |
602 | op = ctx->op; | 609 | op = ctx->op; |
603 | ctx->op = NULL; | 610 | ctx->op = NULL; |
604 | GNUNET_TESTBED_operation_done(op); | 611 | GNUNET_TESTBED_operation_done (op); |
605 | return; | 612 | return; |
606 | } | 613 | } |
607 | 614 | ||
608 | 615 | ||
609 | /* Generate and DHT PUT some random data */ | 616 | /* Generate and DHT PUT some random data */ |
610 | block_size = 16; /* minimum */ | 617 | block_size = 16; /* minimum */ |
611 | /* make random payload, reserve 512 - 16 bytes for DHT headers */ | 618 | /* make random payload, reserve 512 - 16 bytes for DHT headers */ |
612 | block_size += GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, | 619 | block_size += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
613 | GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE - 512); | 620 | GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE |
614 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, | 621 | - 512); |
615 | block, | 622 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, |
616 | block_size); | 623 | block, |
624 | block_size); | ||
617 | ac->put_count--; | 625 | ac->put_count--; |
618 | GNUNET_CRYPTO_hash(block, | 626 | GNUNET_CRYPTO_hash (block, |
619 | block_size, | 627 | block_size, |
620 | &ac->hash[ac->put_count]); | 628 | &ac->hash[ac->put_count]); |
621 | DEBUG("PUT_REQUEST_START key %s\n", | 629 | DEBUG ("PUT_REQUEST_START key %s\n", |
622 | GNUNET_h2s(&ac->hash[ac->put_count])); | 630 | GNUNET_h2s (&ac->hash[ac->put_count])); |
623 | ac->dht_put = GNUNET_DHT_put(ac->dht, | 631 | ac->dht_put = GNUNET_DHT_put (ac->dht, |
624 | &ac->hash[ac->put_count], | 632 | &ac->hash[ac->put_count], |
625 | replication, | 633 | replication, |
626 | GNUNET_DHT_RO_RECORD_ROUTE, | 634 | GNUNET_DHT_RO_RECORD_ROUTE, |
627 | GNUNET_BLOCK_TYPE_TEST, | 635 | GNUNET_BLOCK_TYPE_TEST, |
628 | block_size, | 636 | block_size, |
629 | block, | 637 | block, |
630 | GNUNET_TIME_UNIT_FOREVER_ABS, /* expiration time */ | 638 | GNUNET_TIME_UNIT_FOREVER_ABS, /* expiration time */ |
631 | &put_cont, | 639 | &put_cont, |
632 | ac); /* continuation and its closure */ | 640 | ac); /* continuation and its closure */ |
633 | n_puts++; | 641 | n_puts++; |
634 | } | 642 | } |
635 | 643 | ||
@@ -644,66 +652,66 @@ delayed_put(void *cls) | |||
644 | * operation has executed successfully. | 652 | * operation has executed successfully. |
645 | */ | 653 | */ |
646 | static void | 654 | static void |
647 | dht_connected(void *cls, | 655 | dht_connected (void *cls, |
648 | struct GNUNET_TESTBED_Operation *op, | 656 | struct GNUNET_TESTBED_Operation *op, |
649 | void *ca_result, | 657 | void *ca_result, |
650 | const char *emsg) | 658 | const char *emsg) |
651 | { | 659 | { |
652 | struct ActiveContext *ac = cls; | 660 | struct ActiveContext *ac = cls; |
653 | struct Context *ctx = ac->ctx; | 661 | struct Context *ctx = ac->ctx; |
654 | 662 | ||
655 | GNUNET_assert(NULL != ctx); //FIXME: Fails | 663 | GNUNET_assert (NULL != ctx); // FIXME: Fails |
656 | GNUNET_assert(NULL != ctx->op); | 664 | GNUNET_assert (NULL != ctx->op); |
657 | GNUNET_assert(ctx->op == op); | 665 | GNUNET_assert (ctx->op == op); |
658 | ac->dht = (struct GNUNET_DHT_Handle *)ca_result; | 666 | ac->dht = (struct GNUNET_DHT_Handle *) ca_result; |
659 | if (NULL != emsg) | 667 | if (NULL != emsg) |
660 | { | 668 | { |
661 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 669 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
662 | "Connection to DHT service failed: %s\n", | 670 | "Connection to DHT service failed: %s\n", |
663 | emsg); | 671 | emsg); |
664 | GNUNET_TESTBED_operation_done(ctx->op); /* Calls dht_disconnect() */ | 672 | GNUNET_TESTBED_operation_done (ctx->op); /* Calls dht_disconnect() */ |
665 | ctx->op = NULL; | 673 | ctx->op = NULL; |
666 | return; | 674 | return; |
667 | } | 675 | } |
668 | switch (mode) | 676 | switch (mode) |
669 | { | 677 | { |
670 | case MODE_PUT: | 678 | case MODE_PUT: |
671 | { | 679 | { |
672 | struct GNUNET_TIME_Relative peer_delay_put; | 680 | struct GNUNET_TIME_Relative peer_delay_put; |
673 | 681 | ||
674 | peer_delay_put.rel_value_us = | 682 | peer_delay_put.rel_value_us = |
675 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, | 683 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
676 | delay_put.rel_value_us); | 684 | delay_put.rel_value_us); |
677 | ac->put_count = num_puts_per_peer; | 685 | ac->put_count = num_puts_per_peer; |
678 | ac->hash = calloc(ac->put_count, | 686 | ac->hash = calloc (ac->put_count, |
679 | sizeof(struct GNUNET_HashCode)); | 687 | sizeof(struct GNUNET_HashCode)); |
680 | if (NULL == ac->hash) | 688 | if (NULL == ac->hash) |
681 | { | 689 | { |
682 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, | 690 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
683 | "calloc"); | 691 | "calloc"); |
684 | GNUNET_SCHEDULER_shutdown(); | 692 | GNUNET_SCHEDULER_shutdown (); |
685 | return; | 693 | return; |
686 | } | 694 | } |
687 | ac->delay_task = GNUNET_SCHEDULER_add_delayed(peer_delay_put, | 695 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_put, |
688 | &delayed_put, | 696 | &delayed_put, |
689 | ac); | 697 | ac); |
690 | break; | 698 | break; |
691 | } | 699 | } |
692 | 700 | ||
693 | case MODE_GET: | 701 | case MODE_GET: |
694 | { | 702 | { |
695 | struct GNUNET_TIME_Relative peer_delay_get; | 703 | struct GNUNET_TIME_Relative peer_delay_get; |
696 | 704 | ||
697 | peer_delay_get.rel_value_us = | 705 | peer_delay_get.rel_value_us = |
698 | delay_get.rel_value_us + | 706 | delay_get.rel_value_us |
699 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, | 707 | + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
700 | delay_get.rel_value_us); | 708 | delay_get.rel_value_us); |
701 | ac->delay_task = GNUNET_SCHEDULER_add_delayed(peer_delay_get, | 709 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_get, |
702 | &delayed_get, | 710 | &delayed_get, |
703 | ac); | 711 | ac); |
704 | break; | 712 | break; |
705 | } | 713 | } |
706 | } | 714 | } |
707 | } | 715 | } |
708 | 716 | ||
709 | 717 | ||
@@ -717,12 +725,12 @@ dht_connected(void *cls, | |||
717 | * @return service handle to return in 'op_result', NULL on error | 725 | * @return service handle to return in 'op_result', NULL on error |
718 | */ | 726 | */ |
719 | static void * | 727 | static void * |
720 | dht_connect(void *cls, | 728 | dht_connect (void *cls, |
721 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 729 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
722 | { | 730 | { |
723 | n_dht++; | 731 | n_dht++; |
724 | return GNUNET_DHT_connect(cfg, | 732 | return GNUNET_DHT_connect (cfg, |
725 | 10); | 733 | 10); |
726 | } | 734 | } |
727 | 735 | ||
728 | 736 | ||
@@ -734,14 +742,14 @@ dht_connect(void *cls, | |||
734 | * @param op_result service handle returned from the connect adapter | 742 | * @param op_result service handle returned from the connect adapter |
735 | */ | 743 | */ |
736 | static void | 744 | static void |
737 | dht_disconnect(void *cls, | 745 | dht_disconnect (void *cls, |
738 | void *op_result) | 746 | void *op_result) |
739 | { | 747 | { |
740 | struct ActiveContext *ac = cls; | 748 | struct ActiveContext *ac = cls; |
741 | 749 | ||
742 | GNUNET_assert(NULL != ac->dht); | 750 | GNUNET_assert (NULL != ac->dht); |
743 | GNUNET_assert(ac->dht == op_result); | 751 | GNUNET_assert (ac->dht == op_result); |
744 | GNUNET_DHT_disconnect(ac->dht); | 752 | GNUNET_DHT_disconnect (ac->dht); |
745 | ac->dht = NULL; | 753 | ac->dht = NULL; |
746 | n_dht--; | 754 | n_dht--; |
747 | if (0 != n_dht) | 755 | if (0 != n_dht) |
@@ -749,20 +757,20 @@ dht_disconnect(void *cls, | |||
749 | if (GNUNET_YES == in_shutdown) | 757 | if (GNUNET_YES == in_shutdown) |
750 | return; | 758 | return; |
751 | switch (mode) | 759 | switch (mode) |
752 | { | 760 | { |
753 | case MODE_PUT: | 761 | case MODE_PUT: |
754 | if (n_puts_ok != ((unsigned long long)n_active) * num_puts_per_peer) | 762 | if (n_puts_ok != ((unsigned long long) n_active) * num_puts_per_peer) |
755 | return; | ||
756 | /* Start GETs if all PUTs have been made */ | ||
757 | mode = MODE_GET; | ||
758 | start_profiling(); | ||
759 | return; | 763 | return; |
764 | /* Start GETs if all PUTs have been made */ | ||
765 | mode = MODE_GET; | ||
766 | start_profiling (); | ||
767 | return; | ||
760 | 768 | ||
761 | case MODE_GET: | 769 | case MODE_GET: |
762 | if ((n_gets_ok + n_gets_fail) != n_active) | 770 | if ((n_gets_ok + n_gets_fail) != n_active) |
763 | return; | 771 | return; |
764 | break; | 772 | break; |
765 | } | 773 | } |
766 | } | 774 | } |
767 | 775 | ||
768 | 776 | ||
@@ -770,25 +778,25 @@ dht_disconnect(void *cls, | |||
770 | * Connect to DHT services of active peers | 778 | * Connect to DHT services of active peers |
771 | */ | 779 | */ |
772 | static void | 780 | static void |
773 | start_profiling() | 781 | start_profiling () |
774 | { | 782 | { |
775 | struct Context *ctx; | 783 | struct Context *ctx; |
776 | 784 | ||
777 | DEBUG("GNUNET_TESTBED_service_connect\n"); | 785 | DEBUG ("GNUNET_TESTBED_service_connect\n"); |
778 | GNUNET_break(GNUNET_YES != in_shutdown); | 786 | GNUNET_break (GNUNET_YES != in_shutdown); |
779 | for (unsigned int i = 0; i < n_active; i++) | 787 | for (unsigned int i = 0; i < n_active; i++) |
780 | { | 788 | { |
781 | struct ActiveContext *ac = &a_ac[i]; | 789 | struct ActiveContext *ac = &a_ac[i]; |
782 | GNUNET_assert(NULL != (ctx = ac->ctx)); | 790 | GNUNET_assert (NULL != (ctx = ac->ctx)); |
783 | GNUNET_assert(NULL == ctx->op); | 791 | GNUNET_assert (NULL == ctx->op); |
784 | ctx->op = GNUNET_TESTBED_service_connect(ctx, | 792 | ctx->op = GNUNET_TESTBED_service_connect (ctx, |
785 | ctx->peer, | 793 | ctx->peer, |
786 | "dht", | 794 | "dht", |
787 | &dht_connected, ac, | 795 | &dht_connected, ac, |
788 | &dht_connect, | 796 | &dht_connect, |
789 | &dht_disconnect, | 797 | &dht_disconnect, |
790 | ac); | 798 | ac); |
791 | } | 799 | } |
792 | } | 800 | } |
793 | 801 | ||
794 | 802 | ||
@@ -801,22 +809,22 @@ start_profiling() | |||
801 | * operation has executed successfully. | 809 | * operation has executed successfully. |
802 | */ | 810 | */ |
803 | static void | 811 | static void |
804 | service_started(void *cls, | 812 | service_started (void *cls, |
805 | struct GNUNET_TESTBED_Operation *op, | 813 | struct GNUNET_TESTBED_Operation *op, |
806 | const char *emsg) | 814 | const char *emsg) |
807 | { | 815 | { |
808 | struct Context *ctx = cls; | 816 | struct Context *ctx = cls; |
809 | 817 | ||
810 | GNUNET_assert(NULL != ctx); | 818 | GNUNET_assert (NULL != ctx); |
811 | GNUNET_assert(NULL != ctx->op); | 819 | GNUNET_assert (NULL != ctx->op); |
812 | GNUNET_TESTBED_operation_done(ctx->op); | 820 | GNUNET_TESTBED_operation_done (ctx->op); |
813 | ctx->op = NULL; | 821 | ctx->op = NULL; |
814 | peers_started++; | 822 | peers_started++; |
815 | DEBUG("Peers Started = %d; num_peers = %d \n", | 823 | DEBUG ("Peers Started = %d; num_peers = %d \n", |
816 | peers_started, | 824 | peers_started, |
817 | num_peers); | 825 | num_peers); |
818 | if (peers_started == num_peers) | 826 | if (peers_started == num_peers) |
819 | start_profiling(); | 827 | start_profiling (); |
820 | } | 828 | } |
821 | 829 | ||
822 | 830 | ||
@@ -832,63 +840,63 @@ service_started(void *cls, | |||
832 | * @param links_failed the number of overlay link | 840 | * @param links_failed the number of overlay link |
833 | */ | 841 | */ |
834 | static void | 842 | static void |
835 | test_run(void *cls, | 843 | test_run (void *cls, |
836 | struct GNUNET_TESTBED_RunHandle *h, | 844 | struct GNUNET_TESTBED_RunHandle *h, |
837 | unsigned int num_peers, | 845 | unsigned int num_peers, |
838 | struct GNUNET_TESTBED_Peer **peers, | 846 | struct GNUNET_TESTBED_Peer **peers, |
839 | unsigned int links_succeeded, | 847 | unsigned int links_succeeded, |
840 | unsigned int links_failed) | 848 | unsigned int links_failed) |
841 | { | 849 | { |
842 | unsigned int ac_cnt; | 850 | unsigned int ac_cnt; |
843 | 851 | ||
844 | testbed_handles = peers; | 852 | testbed_handles = peers; |
845 | if (NULL == peers) | 853 | if (NULL == peers) |
846 | { | 854 | { |
847 | /* exit */ | 855 | /* exit */ |
848 | GNUNET_assert(0); | 856 | GNUNET_assert (0); |
849 | } | 857 | } |
850 | MESSAGE("%u peers started, %u/%u links up\n", | 858 | MESSAGE ("%u peers started, %u/%u links up\n", |
851 | num_peers, | 859 | num_peers, |
852 | links_succeeded, | 860 | links_succeeded, |
853 | links_succeeded + links_failed); | 861 | links_succeeded + links_failed); |
854 | a_ctx = GNUNET_new_array(num_peers, | 862 | a_ctx = GNUNET_new_array (num_peers, |
855 | struct Context); | 863 | struct Context); |
856 | /* select the peers which actively participate in profiling */ | 864 | /* select the peers which actively participate in profiling */ |
857 | n_active = num_peers * put_probability / 100; | 865 | n_active = num_peers * put_probability / 100; |
858 | if (0 == n_active) | 866 | if (0 == n_active) |
859 | { | 867 | { |
860 | GNUNET_SCHEDULER_shutdown(); | 868 | GNUNET_SCHEDULER_shutdown (); |
861 | GNUNET_free(a_ctx); | 869 | GNUNET_free (a_ctx); |
862 | a_ctx = NULL; | 870 | a_ctx = NULL; |
863 | return; | 871 | return; |
864 | } | 872 | } |
865 | 873 | ||
866 | a_ac = GNUNET_new_array(n_active, | 874 | a_ac = GNUNET_new_array (n_active, |
867 | struct ActiveContext); | 875 | struct ActiveContext); |
868 | ac_cnt = 0; | 876 | ac_cnt = 0; |
869 | for (unsigned int cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) | 877 | for (unsigned int cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) |
870 | { | 878 | { |
871 | if (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, | 879 | if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
872 | 100) >= put_probability) | 880 | 100) >= put_probability) |
873 | continue; | 881 | continue; |
874 | 882 | ||
875 | a_ctx[cnt].ac = &a_ac[ac_cnt]; | 883 | a_ctx[cnt].ac = &a_ac[ac_cnt]; |
876 | a_ac[ac_cnt].ctx = &a_ctx[cnt]; | 884 | a_ac[ac_cnt].ctx = &a_ctx[cnt]; |
877 | ac_cnt++; | 885 | ac_cnt++; |
878 | } | 886 | } |
879 | n_active = ac_cnt; | 887 | n_active = ac_cnt; |
880 | 888 | ||
881 | /* start DHT service on all peers */ | 889 | /* start DHT service on all peers */ |
882 | for (unsigned int cnt = 0; cnt < num_peers; cnt++) | 890 | for (unsigned int cnt = 0; cnt < num_peers; cnt++) |
883 | { | 891 | { |
884 | a_ctx[cnt].peer = peers[cnt]; | 892 | a_ctx[cnt].peer = peers[cnt]; |
885 | a_ctx[cnt].op = GNUNET_TESTBED_peer_manage_service(&a_ctx[cnt], | 893 | a_ctx[cnt].op = GNUNET_TESTBED_peer_manage_service (&a_ctx[cnt], |
886 | peers[cnt], | 894 | peers[cnt], |
887 | "dht", | 895 | "dht", |
888 | &service_started, | 896 | &service_started, |
889 | &a_ctx[cnt], | 897 | &a_ctx[cnt], |
890 | 1); | 898 | 1); |
891 | } | 899 | } |
892 | } | 900 | } |
893 | 901 | ||
894 | 902 | ||
@@ -901,32 +909,32 @@ test_run(void *cls, | |||
901 | * @param config configuration | 909 | * @param config configuration |
902 | */ | 910 | */ |
903 | static void | 911 | static void |
904 | run(void *cls, | 912 | run (void *cls, |
905 | char *const *args, | 913 | char *const *args, |
906 | const char *cfgfile, | 914 | const char *cfgfile, |
907 | const struct GNUNET_CONFIGURATION_Handle *config) | 915 | const struct GNUNET_CONFIGURATION_Handle *config) |
908 | { | 916 | { |
909 | uint64_t event_mask; | 917 | uint64_t event_mask; |
910 | 918 | ||
911 | if (0 == num_peers) | 919 | if (0 == num_peers) |
912 | { | 920 | { |
913 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 921 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
914 | _("Exiting as the number of peers is %u\n"), | 922 | _ ("Exiting as the number of peers is %u\n"), |
915 | num_peers); | 923 | num_peers); |
916 | return; | 924 | return; |
917 | } | 925 | } |
918 | cfg = config; | 926 | cfg = config; |
919 | event_mask = 0; | 927 | event_mask = 0; |
920 | GNUNET_TESTBED_run(hosts_file, | 928 | GNUNET_TESTBED_run (hosts_file, |
921 | cfg, | 929 | cfg, |
922 | num_peers, | 930 | num_peers, |
923 | event_mask, | 931 | event_mask, |
924 | NULL, | 932 | NULL, |
925 | NULL, | 933 | NULL, |
926 | &test_run, | 934 | &test_run, |
927 | NULL); | 935 | NULL); |
928 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, | 936 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
929 | NULL); | 937 | NULL); |
930 | } | 938 | } |
931 | 939 | ||
932 | 940 | ||
@@ -936,78 +944,86 @@ run(void *cls, | |||
936 | * @return 0 on success | 944 | * @return 0 on success |
937 | */ | 945 | */ |
938 | int | 946 | int |
939 | main(int argc, | 947 | main (int argc, |
940 | char *const *argv) | 948 | char *const *argv) |
941 | { | 949 | { |
942 | int rc; | 950 | int rc; |
943 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 951 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
944 | GNUNET_GETOPT_option_uint('n', | 952 | GNUNET_GETOPT_option_uint ('n', |
945 | "peers", | 953 | "peers", |
946 | "COUNT", | 954 | "COUNT", |
947 | gettext_noop("number of peers to start"), | 955 | gettext_noop ("number of peers to start"), |
948 | &num_peers), | 956 | &num_peers), |
949 | GNUNET_GETOPT_option_uint('p', | 957 | GNUNET_GETOPT_option_uint ('p', |
950 | "peer-put-count", | 958 | "peer-put-count", |
951 | "COUNT", | 959 | "COUNT", |
952 | gettext_noop("number of PUTs to perform per peer"), | 960 | gettext_noop ( |
953 | &num_puts_per_peer), | 961 | "number of PUTs to perform per peer"), |
954 | GNUNET_GETOPT_option_string('H', | 962 | &num_puts_per_peer), |
955 | "hosts", | 963 | GNUNET_GETOPT_option_string ('H', |
956 | "FILENAME", | 964 | "hosts", |
957 | gettext_noop("name of the file with the login information for the testbed"), | 965 | "FILENAME", |
958 | &hosts_file), | 966 | gettext_noop ( |
959 | GNUNET_GETOPT_option_relative_time('D', | 967 | "name of the file with the login information for the testbed"), |
960 | "delay", | 968 | &hosts_file), |
961 | "DELAY", | 969 | GNUNET_GETOPT_option_relative_time ('D', |
962 | gettext_noop("delay between rounds for collecting statistics (default: 30 sec)"), | 970 | "delay", |
963 | &delay_stats), | 971 | "DELAY", |
964 | GNUNET_GETOPT_option_relative_time('P', | 972 | gettext_noop ( |
965 | "PUT-delay", | 973 | "delay between rounds for collecting statistics (default: 30 sec)"), |
966 | "DELAY", | 974 | &delay_stats), |
967 | gettext_noop("delay to start doing PUTs (default: 1 sec)"), | 975 | GNUNET_GETOPT_option_relative_time ('P', |
968 | &delay_put), | 976 | "PUT-delay", |
969 | GNUNET_GETOPT_option_relative_time('G', | 977 | "DELAY", |
970 | "GET-delay", | 978 | gettext_noop ( |
971 | "DELAY", | 979 | "delay to start doing PUTs (default: 1 sec)"), |
972 | gettext_noop("delay to start doing GETs (default: 5 min)"), | 980 | &delay_put), |
973 | &delay_get), | 981 | GNUNET_GETOPT_option_relative_time ('G', |
974 | GNUNET_GETOPT_option_uint('r', | 982 | "GET-delay", |
975 | "replication", | 983 | "DELAY", |
976 | "DEGREE", | 984 | gettext_noop ( |
977 | gettext_noop("replication degree for DHT PUTs"), | 985 | "delay to start doing GETs (default: 5 min)"), |
978 | &replication), | 986 | &delay_get), |
979 | GNUNET_GETOPT_option_uint('R', | 987 | GNUNET_GETOPT_option_uint ('r', |
980 | "random-chance", | 988 | "replication", |
981 | "PROBABILITY", | 989 | "DEGREE", |
982 | gettext_noop("chance that a peer is selected at random for PUTs"), | 990 | gettext_noop ("replication degree for DHT PUTs"), |
983 | &put_probability), | 991 | &replication), |
984 | GNUNET_GETOPT_option_relative_time('t', | 992 | GNUNET_GETOPT_option_uint ('R', |
985 | "timeout", | 993 | "random-chance", |
986 | "TIMEOUT", | 994 | "PROBABILITY", |
987 | gettext_noop("timeout for DHT PUT and GET requests (default: 1 min)"), | 995 | gettext_noop ( |
988 | &timeout), | 996 | "chance that a peer is selected at random for PUTs"), |
997 | &put_probability), | ||
998 | GNUNET_GETOPT_option_relative_time ('t', | ||
999 | "timeout", | ||
1000 | "TIMEOUT", | ||
1001 | gettext_noop ( | ||
1002 | "timeout for DHT PUT and GET requests (default: 1 min)"), | ||
1003 | &timeout), | ||
989 | GNUNET_GETOPT_OPTION_END | 1004 | GNUNET_GETOPT_OPTION_END |
990 | }; | 1005 | }; |
991 | 1006 | ||
992 | if (GNUNET_OK != | 1007 | if (GNUNET_OK != |
993 | GNUNET_STRINGS_get_utf8_args(argc, argv, | 1008 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
994 | &argc, &argv)) | 1009 | &argc, &argv)) |
995 | return 2; | 1010 | return 2; |
996 | /* set default delays */ | 1011 | /* set default delays */ |
997 | delay_stats = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10); | 1012 | delay_stats = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
998 | delay_put = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10); | 1013 | delay_put = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
999 | delay_get = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10); | 1014 | delay_get = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
1000 | timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10); | 1015 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
1001 | replication = 1; /* default replication */ | 1016 | replication = 1; /* default replication */ |
1002 | rc = 0; | 1017 | rc = 0; |
1003 | if (GNUNET_OK != | 1018 | if (GNUNET_OK != |
1004 | GNUNET_PROGRAM_run(argc, | 1019 | GNUNET_PROGRAM_run (argc, |
1005 | argv, | 1020 | argv, |
1006 | "gnunet-dht-profiler", | 1021 | "gnunet-dht-profiler", |
1007 | gettext_noop("Measure quality and performance of the DHT service."), | 1022 | gettext_noop ( |
1008 | options, | 1023 | "Measure quality and performance of the DHT service."), |
1009 | &run, | 1024 | options, |
1010 | NULL)) | 1025 | &run, |
1026 | NULL)) | ||
1011 | rc = 1; | 1027 | rc = 1; |
1012 | return rc; | 1028 | return rc; |
1013 | } | 1029 | } |