diff options
Diffstat (limited to 'src/dht/gnunet_dht_profiler.c')
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 665 |
1 files changed, 227 insertions, 438 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index 4a703399e..12e99f65d 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_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) 2014 GNUnet e.V. | 3 | Copyright (C) 2014, 2018 GNUnet e.V. |
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 |
@@ -29,8 +29,8 @@ | |||
29 | #include "gnunet_testbed_service.h" | 29 | #include "gnunet_testbed_service.h" |
30 | #include "gnunet_dht_service.h" | 30 | #include "gnunet_dht_service.h" |
31 | 31 | ||
32 | #define INFO(...) \ | 32 | #define MESSAGE(...) \ |
33 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, __VA_ARGS__) | 33 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, __VA_ARGS__) |
34 | 34 | ||
35 | #define DEBUG(...) \ | 35 | #define DEBUG(...) \ |
36 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 36 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
@@ -38,7 +38,7 @@ | |||
38 | /** | 38 | /** |
39 | * Number of peers which should perform a PUT out of 100 peers | 39 | * Number of peers which should perform a PUT out of 100 peers |
40 | */ | 40 | */ |
41 | #define PUT_PROBABILITY 50 | 41 | static unsigned int put_probability = 100; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Configuration | 44 | * Configuration |
@@ -121,7 +121,12 @@ struct ActiveContext | |||
121 | /** | 121 | /** |
122 | * Delay task | 122 | * Delay task |
123 | */ | 123 | */ |
124 | struct GNUNET_SCHEDULER_Task * delay_task; | 124 | struct GNUNET_SCHEDULER_Task *delay_task; |
125 | |||
126 | /** | ||
127 | * How many puts should we still issue? | ||
128 | */ | ||
129 | unsigned int put_count; | ||
125 | 130 | ||
126 | /** | 131 | /** |
127 | * The size of the @e put_data | 132 | * The size of the @e put_data |
@@ -183,12 +188,17 @@ static unsigned int n_dht; | |||
183 | /** | 188 | /** |
184 | * Number of DHT PUTs made | 189 | * Number of DHT PUTs made |
185 | */ | 190 | */ |
186 | static unsigned int n_puts; | 191 | static unsigned long long n_puts; |
192 | |||
193 | /** | ||
194 | * Number of DHT PUTs to be made per peer. | ||
195 | */ | ||
196 | static unsigned int num_puts_per_peer = 1; | ||
187 | 197 | ||
188 | /** | 198 | /** |
189 | * Number of DHT PUTs succeeded | 199 | * Number of DHT PUTs succeeded |
190 | */ | 200 | */ |
191 | static unsigned int n_puts_ok; | 201 | static unsigned long long n_puts_ok; |
192 | 202 | ||
193 | /** | 203 | /** |
194 | * Number of DHT GETs made | 204 | * Number of DHT GETs made |
@@ -221,11 +231,6 @@ static unsigned int max_searches; | |||
221 | static struct GNUNET_TESTBED_Operation *bandwidth_stats_op; | 231 | static struct GNUNET_TESTBED_Operation *bandwidth_stats_op; |
222 | 232 | ||
223 | /** | 233 | /** |
224 | * To get successor stats. | ||
225 | */ | ||
226 | static struct GNUNET_TESTBED_Operation *successor_stats_op; | ||
227 | |||
228 | /** | ||
229 | * Testbed peer handles. | 234 | * Testbed peer handles. |
230 | */ | 235 | */ |
231 | static struct GNUNET_TESTBED_Peer **testbed_handles; | 236 | static struct GNUNET_TESTBED_Peer **testbed_handles; |
@@ -261,42 +266,6 @@ static unsigned int total_put_path_length; | |||
261 | static unsigned int total_get_path_length; | 266 | static unsigned int total_get_path_length; |
262 | 267 | ||
263 | /** | 268 | /** |
264 | * Hashmap to store pair of peer and its corresponding successor. | ||
265 | */ | ||
266 | static struct GNUNET_CONTAINER_MultiHashMap *successor_peer_hashmap; | ||
267 | |||
268 | /** | ||
269 | * Key to start the lookup on successor_peer_hashmap. | ||
270 | */ | ||
271 | static struct GNUNET_HashCode *start_key; | ||
272 | |||
273 | /** | ||
274 | * Flag used to get the start_key. | ||
275 | */ | ||
276 | static int flag = 0; | ||
277 | |||
278 | /** | ||
279 | * Task to collect peer and its current successor statistics. | ||
280 | */ | ||
281 | static struct GNUNET_SCHEDULER_Task * successor_stats_task; | ||
282 | |||
283 | /** | ||
284 | * Closure for successor_stats_task. | ||
285 | */ | ||
286 | struct Collect_Stat_Context | ||
287 | { | ||
288 | /** | ||
289 | * Current Peer Context. | ||
290 | */ | ||
291 | struct Context *service_connect_ctx; | ||
292 | |||
293 | /** | ||
294 | * Testbed operation acting on this peer | ||
295 | */ | ||
296 | struct GNUNET_TESTBED_Operation *op; | ||
297 | }; | ||
298 | |||
299 | /** | ||
300 | * List of all the peers contexts. | 269 | * List of all the peers contexts. |
301 | */ | 270 | */ |
302 | struct Context **peer_contexts = NULL; | 271 | struct Context **peer_contexts = NULL; |
@@ -322,20 +291,6 @@ static enum | |||
322 | */ | 291 | */ |
323 | static int in_shutdown = 0; | 292 | static int in_shutdown = 0; |
324 | 293 | ||
325 | /** | ||
326 | * Total number of times to check if circle is formed or not. | ||
327 | */ | ||
328 | static unsigned int tries; | ||
329 | |||
330 | |||
331 | /** | ||
332 | * Task that collects successor statistics from all the peers. | ||
333 | * | ||
334 | * @param cls | ||
335 | */ | ||
336 | static void | ||
337 | collect_stats (void *cls); | ||
338 | |||
339 | 294 | ||
340 | /** | 295 | /** |
341 | * Connect to DHT services of active peers | 296 | * Connect to DHT services of active peers |
@@ -353,12 +308,11 @@ static void | |||
353 | do_shutdown (void *cls) | 308 | do_shutdown (void *cls) |
354 | { | 309 | { |
355 | struct ActiveContext *ac; | 310 | struct ActiveContext *ac; |
356 | unsigned int cnt; | ||
357 | 311 | ||
358 | in_shutdown = GNUNET_YES; | 312 | in_shutdown = GNUNET_YES; |
359 | if (NULL != a_ctx) | 313 | if (NULL != a_ctx) |
360 | { | 314 | { |
361 | for (cnt=0; cnt < num_peers; cnt++) | 315 | for (unsigned int cnt=0; cnt < num_peers; cnt++) |
362 | { | 316 | { |
363 | /* Cleanup active context if this peer is an active peer */ | 317 | /* Cleanup active context if this peer is an active peer */ |
364 | ac = a_ctx[cnt].ac; | 318 | ac = a_ctx[cnt].ac; |
@@ -387,16 +341,6 @@ do_shutdown (void *cls) | |||
387 | GNUNET_TESTBED_operation_done (bandwidth_stats_op); | 341 | GNUNET_TESTBED_operation_done (bandwidth_stats_op); |
388 | bandwidth_stats_op = NULL; | 342 | bandwidth_stats_op = NULL; |
389 | } | 343 | } |
390 | if (NULL != successor_stats_op) | ||
391 | { | ||
392 | GNUNET_TESTBED_operation_done (successor_stats_op); | ||
393 | successor_stats_op = NULL; | ||
394 | } | ||
395 | if (NULL != successor_stats_task) | ||
396 | { | ||
397 | GNUNET_SCHEDULER_cancel (successor_stats_task); | ||
398 | successor_stats_task = NULL; | ||
399 | } | ||
400 | GNUNET_free_non_null (a_ac); | 344 | GNUNET_free_non_null (a_ac); |
401 | } | 345 | } |
402 | 346 | ||
@@ -415,10 +359,13 @@ bandwidth_stats_cont (void *cls, | |||
415 | struct GNUNET_TESTBED_Operation *op, | 359 | struct GNUNET_TESTBED_Operation *op, |
416 | const char *emsg) | 360 | const char *emsg) |
417 | { | 361 | { |
418 | INFO ("# Outgoing bandwidth: %llu\n", | 362 | MESSAGE ("# Outgoing bandwidth: %llu\n", |
419 | (unsigned long long) outgoing_bandwidth); | 363 | (unsigned long long) outgoing_bandwidth); |
420 | INFO ("# Incoming bandwidth: %llu\n", | 364 | MESSAGE ("# Incoming bandwidth: %llu\n", |
421 | (unsigned long long) incoming_bandwidth); | 365 | (unsigned long long) incoming_bandwidth); |
366 | fprintf (stderr, | ||
367 | "Benchmark done. Collect data via gnunet-statisics, then press ENTER to exit.\n"); | ||
368 | getchar (); | ||
422 | GNUNET_SCHEDULER_shutdown (); | 369 | GNUNET_SCHEDULER_shutdown (); |
423 | } | 370 | } |
424 | 371 | ||
@@ -442,39 +389,48 @@ bandwidth_stats_iterator (void *cls, | |||
442 | uint64_t value, | 389 | uint64_t value, |
443 | int is_persistent) | 390 | int is_persistent) |
444 | { | 391 | { |
445 | static const char *s_sent = "# Bytes transmitted to other peers"; | 392 | static const char *s_sent = "# Bytes transmitted to other peers"; |
446 | static const char *s_recv = "# Bytes received from other peers"; | 393 | static const char *s_recv = "# Bytes received from other peers"; |
447 | |||
448 | if (0 == strncmp (s_sent, name, strlen (s_sent))) | ||
449 | outgoing_bandwidth = outgoing_bandwidth + value; | ||
450 | else if (0 == strncmp(s_recv, name, strlen (s_recv))) | ||
451 | incoming_bandwidth = incoming_bandwidth + value; | ||
452 | 394 | ||
453 | return GNUNET_OK; | 395 | if (0 == strncmp (s_sent, name, strlen (s_sent))) |
396 | outgoing_bandwidth = outgoing_bandwidth + value; | ||
397 | else if (0 == strncmp(s_recv, name, strlen (s_recv))) | ||
398 | incoming_bandwidth = incoming_bandwidth + value; | ||
399 | return GNUNET_OK; | ||
454 | } | 400 | } |
455 | 401 | ||
456 | 402 | ||
457 | static void | 403 | static void |
458 | summarize () | 404 | summarize () |
459 | { | 405 | { |
460 | INFO ("# PUTS made: %u\n", n_puts); | 406 | MESSAGE ("# PUTS started: %llu\n", |
461 | INFO ("# PUTS succeeded: %u\n", n_puts_ok); | 407 | n_puts); |
462 | INFO ("# GETS made: %u\n", n_gets); | 408 | MESSAGE ("# PUTS succeeded: %llu\n", |
463 | INFO ("# GETS succeeded: %u\n", n_gets_ok); | 409 | n_puts_ok); |
464 | INFO ("# GETS failed: %u\n", n_gets_fail); | 410 | MESSAGE ("# GETS made: %u\n", |
465 | INFO ("# average_put_path_length: %f\n", average_put_path_length); | 411 | n_gets); |
466 | INFO ("# average_get_path_length: %f\n", average_get_path_length); | 412 | MESSAGE ("# GETS succeeded: %u\n", |
413 | n_gets_ok); | ||
414 | MESSAGE ("# GETS failed: %u\n", | ||
415 | n_gets_fail); | ||
416 | MESSAGE ("# average_put_path_length: %f\n", | ||
417 | average_put_path_length); | ||
418 | MESSAGE ("# average_get_path_length: %f\n", | ||
419 | average_get_path_length); | ||
467 | 420 | ||
468 | if (NULL == testbed_handles) | 421 | if (NULL == testbed_handles) |
469 | { | 422 | { |
470 | INFO ("No peers found\n"); | 423 | MESSAGE ("No peers found\n"); |
471 | return; | 424 | return; |
472 | } | 425 | } |
473 | /* Collect Stats*/ | 426 | /* Collect Stats*/ |
474 | bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles, | 427 | bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, |
475 | "dht", NULL, | 428 | testbed_handles, |
476 | bandwidth_stats_iterator, | 429 | "dht", |
477 | bandwidth_stats_cont, NULL); | 430 | NULL, |
431 | bandwidth_stats_iterator, | ||
432 | bandwidth_stats_cont, | ||
433 | NULL); | ||
478 | } | 434 | } |
479 | 435 | ||
480 | 436 | ||
@@ -541,9 +497,12 @@ get_iter (void *cls, | |||
541 | struct Context *ctx = ac->ctx; | 497 | struct Context *ctx = ac->ctx; |
542 | 498 | ||
543 | /* Check the keys of put and get match or not. */ | 499 | /* Check the keys of put and get match or not. */ |
544 | GNUNET_assert (0 == memcmp (key, &get_ac->hash, sizeof (struct GNUNET_HashCode))); | 500 | GNUNET_assert (0 == memcmp (key, |
501 | &get_ac->hash, | ||
502 | sizeof (struct GNUNET_HashCode))); | ||
545 | /* we found the data we are looking for */ | 503 | /* we found the data we are looking for */ |
546 | DEBUG ("We found a GET request; %u remaining\n", n_gets - (n_gets_fail + n_gets_ok)); //FIXME: It always prints 1. | 504 | DEBUG ("We found a GET request; %u remaining\n", |
505 | n_gets - (n_gets_fail + n_gets_ok)); //FIXME: It always prints 1. | ||
547 | n_gets_ok++; | 506 | n_gets_ok++; |
548 | get_ac->nrefs--; | 507 | get_ac->nrefs--; |
549 | GNUNET_DHT_get_stop (ac->dht_get); | 508 | GNUNET_DHT_get_stop (ac->dht_get); |
@@ -585,53 +544,48 @@ delayed_get (void *cls) | |||
585 | get_ac = NULL; | 544 | get_ac = NULL; |
586 | while (1) | 545 | while (1) |
587 | { | 546 | { |
588 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, n_active); | 547 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
548 | n_active); | ||
589 | get_ac = &a_ac[r]; | 549 | get_ac = &a_ac[r]; |
590 | if (NULL != get_ac->put_data) | 550 | if (NULL != get_ac->put_data) |
591 | break; | 551 | break; |
592 | } | 552 | } |
593 | get_ac->nrefs++; | 553 | get_ac->nrefs++; |
594 | ac->get_ac = get_ac; | 554 | ac->get_ac = get_ac; |
595 | DEBUG ("GET_REQUEST_START key %s \n", GNUNET_h2s((struct GNUNET_HashCode *)ac->put_data)); | 555 | DEBUG ("GET_REQUEST_START key %s \n", |
556 | GNUNET_h2s((struct GNUNET_HashCode *) ac->put_data)); | ||
596 | ac->dht_get = GNUNET_DHT_get_start (ac->dht, | 557 | ac->dht_get = GNUNET_DHT_get_start (ac->dht, |
597 | GNUNET_BLOCK_TYPE_TEST, | 558 | GNUNET_BLOCK_TYPE_TEST, |
598 | &get_ac->hash, | 559 | &get_ac->hash, |
599 | 1, /* replication level */ | 560 | 1, /* replication level */ |
600 | GNUNET_DHT_RO_NONE, | 561 | GNUNET_DHT_RO_NONE, |
601 | NULL, 0, /* extended query and size */ | 562 | NULL, |
602 | get_iter, ac); /* GET iterator and closure | 563 | 0, /* extended query and size */ |
603 | */ | 564 | get_iter, |
565 | ac); /* GET iterator and closure */ | ||
604 | n_gets++; | 566 | n_gets++; |
605 | 567 | ||
606 | /* schedule the timeout task for GET */ | 568 | /* schedule the timeout task for GET */ |
607 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (timeout, &cancel_get, ac); | 569 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (timeout, |
570 | &cancel_get, | ||
571 | ac); | ||
608 | } | 572 | } |
609 | 573 | ||
610 | 574 | ||
611 | /** | 575 | /** |
612 | * Task to teardown the dht connection. We do it as a task because calling | 576 | * Task to do DHT PUTs. If the "put_count" hits zero, |
613 | * GNUNET_DHT_disconnect() from put_continutation_callback seems illegal (the | 577 | * we stop the TESTBED operation (connection to DHT) |
614 | * put_continuation_callback() is getting called again synchronously). Also, | 578 | * so that others PUTs have a chance. |
615 | * only free the operation when we are not shutting down; the shutdown task will | ||
616 | * clear the operation during shutdown. | ||
617 | * | 579 | * |
618 | * @param cls the context | 580 | * @param cls the active context |
619 | */ | 581 | */ |
620 | static void | 582 | static void |
621 | teardown_dht_connection (void *cls) | 583 | delayed_put (void *cls); |
622 | { | ||
623 | struct Context *ctx = cls; | ||
624 | struct GNUNET_TESTBED_Operation *op; | ||
625 | |||
626 | GNUNET_assert (NULL != ctx); | ||
627 | GNUNET_assert (NULL != (op = ctx->op)); | ||
628 | ctx->op = NULL; | ||
629 | GNUNET_TESTBED_operation_done (op); | ||
630 | } | ||
631 | 584 | ||
632 | 585 | ||
633 | /** | 586 | /** |
634 | * Queue up a delayed task for doing DHT GET | 587 | * Conclude individual PUT operation, schedule the |
588 | * next one. | ||
635 | * | 589 | * |
636 | * @param cls the active context | 590 | * @param cls the active context |
637 | */ | 591 | */ |
@@ -639,18 +593,18 @@ static void | |||
639 | put_cont (void *cls) | 593 | put_cont (void *cls) |
640 | { | 594 | { |
641 | struct ActiveContext *ac = cls; | 595 | struct ActiveContext *ac = cls; |
642 | struct Context *ctx = ac->ctx; | ||
643 | 596 | ||
644 | ac->dht_put = NULL; | 597 | ac->dht_put = NULL; |
645 | n_puts_ok++; | 598 | n_puts_ok++; |
646 | GNUNET_assert (NULL != ctx); | 599 | ac->delay_task = GNUNET_SCHEDULER_add_now (&delayed_put, |
647 | (void) GNUNET_SCHEDULER_add_now (&teardown_dht_connection, | 600 | ac); |
648 | ctx); | ||
649 | } | 601 | } |
650 | 602 | ||
651 | 603 | ||
652 | /** | 604 | /** |
653 | * Task to do DHT PUTs | 605 | * Task to do DHT PUTs. If the "put_count" hits zero, |
606 | * we stop the TESTBED operation (connection to DHT) | ||
607 | * so that others PUTs have a chance. | ||
654 | * | 608 | * |
655 | * @param cls the active context | 609 | * @param cls the active context |
656 | */ | 610 | */ |
@@ -660,16 +614,33 @@ delayed_put (void *cls) | |||
660 | struct ActiveContext *ac = cls; | 614 | struct ActiveContext *ac = cls; |
661 | 615 | ||
662 | ac->delay_task = NULL; | 616 | ac->delay_task = NULL; |
617 | if (0 == ac->put_count) | ||
618 | { | ||
619 | struct Context *ctx = ac->ctx; | ||
620 | struct GNUNET_TESTBED_Operation *op; | ||
621 | |||
622 | GNUNET_assert (NULL != ctx); | ||
623 | op = ctx->op; | ||
624 | ctx->op = NULL; | ||
625 | GNUNET_TESTBED_operation_done (op); | ||
626 | return; | ||
627 | } | ||
628 | |||
629 | |||
663 | /* Generate and DHT PUT some random data */ | 630 | /* Generate and DHT PUT some random data */ |
664 | ac->put_data_size = 16; /* minimum */ | 631 | ac->put_data_size = 16; /* minimum */ |
665 | ac->put_data_size += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 632 | ac->put_data_size += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
666 | (63*1024)); | 633 | (63*1024)); |
667 | ac->put_data = GNUNET_malloc (ac->put_data_size); | 634 | ac->put_data = GNUNET_malloc (ac->put_data_size); |
668 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | 635 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, |
669 | ac->put_data, ac->put_data_size); | 636 | ac->put_data, |
670 | GNUNET_CRYPTO_hash (ac->put_data, ac->put_data_size, &ac->hash); | 637 | ac->put_data_size); |
638 | GNUNET_CRYPTO_hash (ac->put_data, | ||
639 | ac->put_data_size, | ||
640 | &ac->hash); | ||
671 | DEBUG ("PUT_REQUEST_START key %s\n", | 641 | DEBUG ("PUT_REQUEST_START key %s\n", |
672 | GNUNET_h2s((struct GNUNET_HashCode *)ac->put_data)); | 642 | GNUNET_h2s ((struct GNUNET_HashCode *)ac->put_data)); |
643 | ac->put_count--; | ||
673 | ac->dht_put = GNUNET_DHT_put (ac->dht, | 644 | ac->dht_put = GNUNET_DHT_put (ac->dht, |
674 | &ac->hash, | 645 | &ac->hash, |
675 | replication, | 646 | replication, |
@@ -708,7 +679,9 @@ dht_connected (void *cls, | |||
708 | ac->dht = (struct GNUNET_DHT_Handle *) ca_result; | 679 | ac->dht = (struct GNUNET_DHT_Handle *) ca_result; |
709 | if (NULL != emsg) | 680 | if (NULL != emsg) |
710 | { | 681 | { |
711 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to DHT service failed: %s\n", emsg); | 682 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
683 | "Connection to DHT service failed: %s\n", | ||
684 | emsg); | ||
712 | GNUNET_TESTBED_operation_done (ctx->op); /* Calls dht_disconnect() */ | 685 | GNUNET_TESTBED_operation_done (ctx->op); /* Calls dht_disconnect() */ |
713 | ctx->op = NULL; | 686 | ctx->op = NULL; |
714 | return; | 687 | return; |
@@ -716,24 +689,31 @@ dht_connected (void *cls, | |||
716 | switch (mode) | 689 | switch (mode) |
717 | { | 690 | { |
718 | case MODE_PUT: | 691 | case MODE_PUT: |
719 | { | 692 | { |
720 | struct GNUNET_TIME_Relative peer_delay_put; | 693 | struct GNUNET_TIME_Relative peer_delay_put; |
721 | peer_delay_put.rel_value_us = | 694 | |
722 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 695 | peer_delay_put.rel_value_us = |
723 | delay_put.rel_value_us); | 696 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
724 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_put, &delayed_put, ac); | 697 | delay_put.rel_value_us); |
725 | break; | 698 | ac->put_count = num_puts_per_peer; |
726 | } | 699 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_put, |
700 | &delayed_put, | ||
701 | ac); | ||
702 | break; | ||
703 | } | ||
727 | case MODE_GET: | 704 | case MODE_GET: |
728 | { | 705 | { |
729 | struct GNUNET_TIME_Relative peer_delay_get; | 706 | struct GNUNET_TIME_Relative peer_delay_get; |
730 | peer_delay_get.rel_value_us = | 707 | |
731 | delay_get.rel_value_us + | 708 | peer_delay_get.rel_value_us = |
732 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 709 | delay_get.rel_value_us + |
733 | delay_get.rel_value_us); | 710 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
734 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_get, &delayed_get, ac); | 711 | delay_get.rel_value_us); |
735 | break; | 712 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_get, |
736 | } | 713 | &delayed_get, |
714 | ac); | ||
715 | break; | ||
716 | } | ||
737 | } | 717 | } |
738 | } | 718 | } |
739 | 719 | ||
@@ -748,10 +728,12 @@ dht_connected (void *cls, | |||
748 | * @return service handle to return in 'op_result', NULL on error | 728 | * @return service handle to return in 'op_result', NULL on error |
749 | */ | 729 | */ |
750 | static void * | 730 | static void * |
751 | dht_connect (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | 731 | dht_connect (void *cls, |
732 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
752 | { | 733 | { |
753 | n_dht++; | 734 | n_dht++; |
754 | return GNUNET_DHT_connect (cfg, 10); | 735 | return GNUNET_DHT_connect (cfg, |
736 | 10); | ||
755 | } | 737 | } |
756 | 738 | ||
757 | 739 | ||
@@ -763,7 +745,8 @@ dht_connect (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
763 | * @param op_result service handle returned from the connect adapter | 745 | * @param op_result service handle returned from the connect adapter |
764 | */ | 746 | */ |
765 | static void | 747 | static void |
766 | dht_disconnect (void *cls, void *op_result) | 748 | dht_disconnect (void *cls, |
749 | void *op_result) | ||
767 | { | 750 | { |
768 | struct ActiveContext *ac = cls; | 751 | struct ActiveContext *ac = cls; |
769 | 752 | ||
@@ -779,11 +762,10 @@ dht_disconnect (void *cls, void *op_result) | |||
779 | switch (mode) | 762 | switch (mode) |
780 | { | 763 | { |
781 | case MODE_PUT: | 764 | case MODE_PUT: |
782 | if (n_puts_ok != n_active) | 765 | if (n_puts_ok != n_active * num_puts_per_peer) |
783 | return; | 766 | return; |
784 | /* Start GETs if all PUTs have been made */ | 767 | /* Start GETs if all PUTs have been made */ |
785 | mode = MODE_GET; | 768 | mode = MODE_GET; |
786 | //(void) GNUNET_SCHEDULER_add_now (&call_start_profiling, NULL); | ||
787 | start_profiling (); | 769 | start_profiling (); |
788 | return; | 770 | return; |
789 | case MODE_GET: | 771 | case MODE_GET: |
@@ -793,6 +775,7 @@ dht_disconnect (void *cls, void *op_result) | |||
793 | } | 775 | } |
794 | } | 776 | } |
795 | 777 | ||
778 | |||
796 | /** | 779 | /** |
797 | * Connect to DHT services of active peers | 780 | * Connect to DHT services of active peers |
798 | */ | 781 | */ |
@@ -800,231 +783,24 @@ static void | |||
800 | start_profiling() | 783 | start_profiling() |
801 | { | 784 | { |
802 | struct Context *ctx; | 785 | struct Context *ctx; |
803 | unsigned int i; | ||
804 | 786 | ||
805 | DEBUG("GNUNET_TESTBED_service_connect \n"); | 787 | DEBUG ("GNUNET_TESTBED_service_connect\n"); |
806 | GNUNET_break (GNUNET_YES != in_shutdown); | 788 | GNUNET_break (GNUNET_YES != in_shutdown); |
807 | for(i = 0; i < n_active; i++) | 789 | for (unsigned int i = 0; i < n_active; i++) |
808 | { | 790 | { |
809 | struct ActiveContext *ac = &a_ac[i]; | 791 | struct ActiveContext *ac = &a_ac[i]; |
810 | GNUNET_assert (NULL != (ctx = ac->ctx)); | 792 | GNUNET_assert (NULL != (ctx = ac->ctx)); |
811 | GNUNET_assert (NULL == ctx->op); | 793 | GNUNET_assert (NULL == ctx->op); |
812 | ctx->op = | 794 | ctx->op = GNUNET_TESTBED_service_connect (ctx, |
813 | GNUNET_TESTBED_service_connect (ctx, | 795 | ctx->peer, |
814 | ctx->peer, | 796 | "dht", |
815 | "dht", | 797 | &dht_connected, ac, |
816 | &dht_connected, ac, | 798 | &dht_connect, |
817 | &dht_connect, | 799 | &dht_disconnect, |
818 | &dht_disconnect, | 800 | ac); |
819 | ac); | ||
820 | } | 801 | } |
821 | } | 802 | } |
822 | 803 | ||
823 | /** | ||
824 | * Start collecting relevant statistics. If ENABLE_MALICIOUS set, first | ||
825 | * set the malicious peers. If not, then start with PUT operation on active | ||
826 | * peers. | ||
827 | */ | ||
828 | static void | ||
829 | start_func() | ||
830 | { | ||
831 | start_profiling(); | ||
832 | } | ||
833 | |||
834 | |||
835 | /** | ||
836 | * Remove entry from successor peer hashmap. | ||
837 | * @param cls closure | ||
838 | * @param key current public key | ||
839 | * @param value value in the hash map | ||
840 | * @return #GNUNET_YES if we should continue to iterate, | ||
841 | * #GNUNET_NO if not. | ||
842 | */ | ||
843 | static int | ||
844 | hashmap_iterate_remove(void *cls, | ||
845 | const struct GNUNET_HashCode *key, | ||
846 | void *value) | ||
847 | { | ||
848 | GNUNET_assert (GNUNET_YES == | ||
849 | GNUNET_CONTAINER_multihashmap_remove(successor_peer_hashmap, key, value)); | ||
850 | return GNUNET_YES; | ||
851 | } | ||
852 | |||
853 | |||
854 | /** | ||
855 | * Stats callback. Iterate over the hashmap and check if all th peers form | ||
856 | * a virtual ring topology. | ||
857 | * | ||
858 | * @param cls closure | ||
859 | * @param op the operation that has been finished | ||
860 | * @param emsg error message in case the operation has failed; will be NULL if | ||
861 | * operation has executed successfully. | ||
862 | */ | ||
863 | static void | ||
864 | successor_stats_cont (void *cls, | ||
865 | struct GNUNET_TESTBED_Operation *op, | ||
866 | const char *emsg) | ||
867 | { | ||
868 | struct GNUNET_HashCode *val; | ||
869 | struct GNUNET_HashCode *start_val; | ||
870 | struct GNUNET_HashCode *key; | ||
871 | int count; | ||
872 | |||
873 | /* Don't schedule the task till we are looking for circle here. */ | ||
874 | successor_stats_task = NULL; | ||
875 | GNUNET_TESTBED_operation_done (successor_stats_op); | ||
876 | successor_stats_op = NULL; | ||
877 | if (0 == max_searches) | ||
878 | { | ||
879 | start_func (); | ||
880 | return; | ||
881 | } | ||
882 | |||
883 | GNUNET_assert (NULL != start_key); | ||
884 | start_val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap, | ||
885 | start_key); | ||
886 | GNUNET_assert (NULL != start_val); | ||
887 | val = start_val; | ||
888 | for (count = 0; count < num_peers; count++) | ||
889 | { | ||
890 | key = val; | ||
891 | val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap, | ||
892 | key); | ||
893 | if (NULL == val) | ||
894 | break; | ||
895 | /* Remove the entry from hashmap. This is done to take care of loop. */ | ||
896 | if (GNUNET_NO == | ||
897 | GNUNET_CONTAINER_multihashmap_remove (successor_peer_hashmap, | ||
898 | key, val)) | ||
899 | { | ||
900 | DEBUG ("Failed to remove entry from hashmap\n"); | ||
901 | break; | ||
902 | } | ||
903 | /* If a peer has its own identity as its successor. */ | ||
904 | if (0 == memcmp(key, val, sizeof (struct GNUNET_HashCode))) | ||
905 | break; | ||
906 | } | ||
907 | |||
908 | GNUNET_assert (GNUNET_SYSERR != | ||
909 | GNUNET_CONTAINER_multihashmap_iterate (successor_peer_hashmap, | ||
910 | &hashmap_iterate_remove, | ||
911 | NULL)); | ||
912 | |||
913 | successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers, | ||
914 | GNUNET_NO); | ||
915 | if ((start_val == val) && (count == num_peers)) | ||
916 | { | ||
917 | DEBUG ("CIRCLE COMPLETED after %u tries", tries); | ||
918 | if(NULL == successor_stats_task) | ||
919 | { | ||
920 | start_func(); | ||
921 | } | ||
922 | return; | ||
923 | } | ||
924 | if (max_searches == ++tries) | ||
925 | { | ||
926 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
927 | "Maximum tries %u exceeded while checking successor TOTAL TRIES %u" | ||
928 | " circle formation. Exiting\n", | ||
929 | max_searches,tries); | ||
930 | start_func(); | ||
931 | return; | ||
932 | } | ||
933 | flag = 0; | ||
934 | successor_stats_task | ||
935 | = GNUNET_SCHEDULER_add_delayed (delay_stats, | ||
936 | &collect_stats, | ||
937 | cls); | ||
938 | } | ||
939 | |||
940 | |||
941 | /** | ||
942 | * Process successor statistic values. | ||
943 | * | ||
944 | * @param cls closure | ||
945 | * @param peer the peer the statistic belong to | ||
946 | * @param subsystem name of subsystem that created the statistic | ||
947 | * @param name the name of the datum | ||
948 | * @param value the current value | ||
949 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | ||
950 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | ||
951 | */ | ||
952 | static int | ||
953 | successor_stats_iterator (void *cls, | ||
954 | const struct GNUNET_TESTBED_Peer *peer, | ||
955 | const char *subsystem, | ||
956 | const char *name, | ||
957 | uint64_t value, | ||
958 | int is_persistent) | ||
959 | { | ||
960 | static const char *key_string = "XDHT"; | ||
961 | if (0 == max_searches) | ||
962 | return GNUNET_OK; | ||
963 | |||
964 | if (0 == strncmp (key_string, name, strlen (key_string))) | ||
965 | { | ||
966 | char *my_id_str; | ||
967 | char successor_str[13]; | ||
968 | char truncated_my_id_str[13]; | ||
969 | char truncated_successor_str[13]; | ||
970 | struct GNUNET_HashCode *my_id_key; | ||
971 | struct GNUNET_HashCode *succ_key; | ||
972 | |||
973 | strtok((char *)name,":"); | ||
974 | my_id_str = strtok(NULL,":"); | ||
975 | |||
976 | strncpy(truncated_my_id_str, my_id_str, 12); | ||
977 | truncated_my_id_str[12] = '\0'; | ||
978 | my_id_key = GNUNET_new(struct GNUNET_HashCode); | ||
979 | GNUNET_CRYPTO_hash (truncated_my_id_str, sizeof(truncated_my_id_str),my_id_key); | ||
980 | GNUNET_STRINGS_data_to_string(&value, sizeof(uint64_t), successor_str, 13); | ||
981 | strncpy(truncated_successor_str, successor_str, 12); | ||
982 | truncated_successor_str[12] ='\0'; | ||
983 | |||
984 | succ_key = GNUNET_new(struct GNUNET_HashCode); | ||
985 | GNUNET_CRYPTO_hash (truncated_successor_str, sizeof(truncated_successor_str),succ_key); | ||
986 | |||
987 | if (0 == flag) | ||
988 | { | ||
989 | GNUNET_assert(NULL != my_id_key); | ||
990 | start_key = my_id_key; | ||
991 | GNUNET_assert(NULL != start_key); | ||
992 | flag = 1; | ||
993 | } | ||
994 | GNUNET_CONTAINER_multihashmap_put (successor_peer_hashmap, | ||
995 | my_id_key, (void *)succ_key, | ||
996 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | ||
997 | } | ||
998 | |||
999 | return GNUNET_OK; | ||
1000 | } | ||
1001 | |||
1002 | |||
1003 | /* | ||
1004 | * Task that collects peer and its corresponding successors. | ||
1005 | * | ||
1006 | * @param cls Closure (NULL). | ||
1007 | */ | ||
1008 | static void | ||
1009 | collect_stats (void *cls) | ||
1010 | { | ||
1011 | successor_stats_task = NULL; | ||
1012 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1013 | "Start collecting statistics...\n"); | ||
1014 | GNUNET_assert(NULL != testbed_handles); | ||
1015 | |||
1016 | if (0 != max_searches) | ||
1017 | successor_peer_hashmap | ||
1018 | = GNUNET_CONTAINER_multihashmap_create (num_peers, | ||
1019 | GNUNET_NO); | ||
1020 | successor_stats_op | ||
1021 | = GNUNET_TESTBED_get_statistics (num_peers, testbed_handles, | ||
1022 | "dht", NULL, | ||
1023 | successor_stats_iterator, | ||
1024 | successor_stats_cont, cls); | ||
1025 | GNUNET_assert (NULL != successor_stats_op); | ||
1026 | } | ||
1027 | |||
1028 | 804 | ||
1029 | /** | 805 | /** |
1030 | * Callback called when DHT service on the peer is started | 806 | * Callback called when DHT service on the peer is started |
@@ -1046,19 +822,11 @@ service_started (void *cls, | |||
1046 | GNUNET_TESTBED_operation_done (ctx->op); | 822 | GNUNET_TESTBED_operation_done (ctx->op); |
1047 | ctx->op = NULL; | 823 | ctx->op = NULL; |
1048 | peers_started++; | 824 | peers_started++; |
1049 | DEBUG("Peers Started = %d; num_peers = %d \n", peers_started, num_peers); | 825 | DEBUG ("Peers Started = %d; num_peers = %d \n", |
1050 | if (NULL == successor_stats_task && peers_started == num_peers) | 826 | peers_started, |
1051 | { | 827 | num_peers); |
1052 | DEBUG("successor_stats_task \n"); | 828 | if (peers_started == num_peers) |
1053 | struct Collect_Stat_Context *collect_stat_cls = GNUNET_new(struct Collect_Stat_Context); | 829 | start_profiling (); |
1054 | collect_stat_cls->service_connect_ctx = cls; | ||
1055 | collect_stat_cls->op = op; | ||
1056 | |||
1057 | successor_stats_task | ||
1058 | = GNUNET_SCHEDULER_add_delayed (delay_stats, | ||
1059 | &collect_stats, | ||
1060 | collect_stat_cls); | ||
1061 | } | ||
1062 | } | 830 | } |
1063 | 831 | ||
1064 | 832 | ||
@@ -1076,36 +844,40 @@ service_started (void *cls, | |||
1076 | static void | 844 | static void |
1077 | test_run (void *cls, | 845 | test_run (void *cls, |
1078 | struct GNUNET_TESTBED_RunHandle *h, | 846 | struct GNUNET_TESTBED_RunHandle *h, |
1079 | unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, | 847 | unsigned int num_peers, |
848 | struct GNUNET_TESTBED_Peer **peers, | ||
1080 | unsigned int links_succeeded, | 849 | unsigned int links_succeeded, |
1081 | unsigned int links_failed) | 850 | unsigned int links_failed) |
1082 | { | 851 | { |
1083 | unsigned int cnt; | ||
1084 | unsigned int ac_cnt; | 852 | unsigned int ac_cnt; |
853 | |||
1085 | testbed_handles = peers; | 854 | testbed_handles = peers; |
1086 | if (NULL == peers) | 855 | if (NULL == peers) |
1087 | { | 856 | { |
1088 | /* exit */ | 857 | /* exit */ |
1089 | GNUNET_assert (0); | 858 | GNUNET_assert (0); |
1090 | } | 859 | } |
1091 | INFO ("%u peers started\n", num_peers); | 860 | MESSAGE ("%u peers started\n", |
1092 | a_ctx = GNUNET_malloc (sizeof (struct Context) * num_peers); | 861 | num_peers); |
1093 | 862 | a_ctx = GNUNET_new_array (num_peers, | |
863 | struct Context); | ||
1094 | /* select the peers which actively participate in profiling */ | 864 | /* select the peers which actively participate in profiling */ |
1095 | n_active = num_peers * PUT_PROBABILITY / 100; | 865 | n_active = num_peers * put_probability / 100; |
1096 | if (0 == n_active) | 866 | if (0 == n_active) |
1097 | { | 867 | { |
1098 | GNUNET_SCHEDULER_shutdown (); | 868 | GNUNET_SCHEDULER_shutdown (); |
1099 | GNUNET_free (a_ctx); | 869 | GNUNET_free (a_ctx); |
870 | a_ctx = NULL; | ||
1100 | return; | 871 | return; |
1101 | } | 872 | } |
1102 | 873 | ||
1103 | a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext)); | 874 | a_ac = GNUNET_new_array (n_active, |
875 | struct ActiveContext); | ||
1104 | ac_cnt = 0; | 876 | ac_cnt = 0; |
1105 | for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) | 877 | for (unsigned int cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) |
1106 | { | 878 | { |
1107 | if ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >= | 879 | if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1108 | PUT_PROBABILITY)) | 880 | 100) >= put_probability) |
1109 | continue; | 881 | continue; |
1110 | 882 | ||
1111 | a_ctx[cnt].ac = &a_ac[ac_cnt]; | 883 | a_ctx[cnt].ac = &a_ac[ac_cnt]; |
@@ -1113,10 +885,11 @@ test_run (void *cls, | |||
1113 | ac_cnt++; | 885 | ac_cnt++; |
1114 | } | 886 | } |
1115 | n_active = ac_cnt; | 887 | n_active = ac_cnt; |
1116 | INFO ("Active peers: %u\n", n_active); | 888 | MESSAGE ("Active peers: %u\n", |
889 | n_active); | ||
1117 | 890 | ||
1118 | /* start DHT service on all peers */ | 891 | /* start DHT service on all peers */ |
1119 | for (cnt = 0; cnt < num_peers; cnt++) | 892 | for (unsigned int cnt = 0; cnt < num_peers; cnt++) |
1120 | { | 893 | { |
1121 | a_ctx[cnt].peer = peers[cnt]; | 894 | a_ctx[cnt].peer = peers[cnt]; |
1122 | a_ctx[cnt].op = GNUNET_TESTBED_peer_manage_service (&a_ctx[cnt], | 895 | a_ctx[cnt].op = GNUNET_TESTBED_peer_manage_service (&a_ctx[cnt], |
@@ -1138,7 +911,9 @@ test_run (void *cls, | |||
1138 | * @param config configuration | 911 | * @param config configuration |
1139 | */ | 912 | */ |
1140 | static void | 913 | static void |
1141 | run (void *cls, char *const *args, const char *cfgfile, | 914 | run (void *cls, |
915 | char *const *args, | ||
916 | const char *cfgfile, | ||
1142 | const struct GNUNET_CONFIGURATION_Handle *config) | 917 | const struct GNUNET_CONFIGURATION_Handle *config) |
1143 | { | 918 | { |
1144 | uint64_t event_mask; | 919 | uint64_t event_mask; |
@@ -1152,8 +927,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1152 | } | 927 | } |
1153 | cfg = GNUNET_CONFIGURATION_dup (config); | 928 | cfg = GNUNET_CONFIGURATION_dup (config); |
1154 | event_mask = 0; | 929 | event_mask = 0; |
1155 | GNUNET_TESTBED_run (hosts_file, cfg, num_peers, event_mask, NULL, | 930 | GNUNET_TESTBED_run (hosts_file, |
1156 | NULL, &test_run, NULL); | 931 | cfg, |
932 | num_peers, | ||
933 | event_mask, | ||
934 | NULL, | ||
935 | NULL, | ||
936 | &test_run, | ||
937 | NULL); | ||
1157 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 938 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
1158 | NULL); | 939 | NULL); |
1159 | } | 940 | } |
@@ -1165,63 +946,68 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1165 | * @return 0 on success | 946 | * @return 0 on success |
1166 | */ | 947 | */ |
1167 | int | 948 | int |
1168 | main (int argc, char *const *argv) | 949 | main (int argc, |
950 | char *const *argv) | ||
1169 | { | 951 | { |
1170 | int rc; | 952 | int rc; |
1171 | |||
1172 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 953 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1173 | GNUNET_GETOPT_option_uint ('n', | 954 | GNUNET_GETOPT_option_uint ('n', |
1174 | "peers", | 955 | "peers", |
1175 | "COUNT", | 956 | "COUNT", |
1176 | gettext_noop ("number of peers to start"), | 957 | gettext_noop ("number of peers to start"), |
1177 | &num_peers), | 958 | &num_peers), |
1178 | 959 | GNUNET_GETOPT_option_uint ('p', | |
960 | "peer-put-count", | ||
961 | "COUNT", | ||
962 | gettext_noop ("number of PUTs to perform per peer"), | ||
963 | &num_puts_per_peer), | ||
1179 | GNUNET_GETOPT_option_uint ('s', | 964 | GNUNET_GETOPT_option_uint ('s', |
1180 | "searches", | 965 | "searches", |
1181 | "COUNT", | 966 | "COUNT", |
1182 | gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"), | 967 | gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"), |
1183 | &max_searches), | 968 | &max_searches), |
1184 | |||
1185 | GNUNET_GETOPT_option_string ('H', | 969 | GNUNET_GETOPT_option_string ('H', |
1186 | "hosts", | 970 | "hosts", |
1187 | "FILENAME", | 971 | "FILENAME", |
1188 | gettext_noop ("name of the file with the login information for the testbed"), | 972 | gettext_noop ("name of the file with the login information for the testbed"), |
1189 | &hosts_file), | 973 | &hosts_file), |
1190 | |||
1191 | GNUNET_GETOPT_option_relative_time ('D', | 974 | GNUNET_GETOPT_option_relative_time ('D', |
1192 | "delay", | 975 | "delay", |
1193 | "DELAY", | 976 | "DELAY", |
1194 | gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"), | 977 | gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"), |
1195 | &delay_stats), | 978 | &delay_stats), |
1196 | |||
1197 | GNUNET_GETOPT_option_relative_time ('P', | 979 | GNUNET_GETOPT_option_relative_time ('P', |
1198 | "PUT-delay", | 980 | "PUT-delay", |
1199 | "DELAY", | 981 | "DELAY", |
1200 | gettext_noop ("delay to start doing PUTs (default: 1 sec)"), | 982 | gettext_noop ("delay to start doing PUTs (default: 1 sec)"), |
1201 | &delay_put), | 983 | &delay_put), |
1202 | |||
1203 | GNUNET_GETOPT_option_relative_time ('G', | 984 | GNUNET_GETOPT_option_relative_time ('G', |
1204 | "GET-delay", | 985 | "GET-delay", |
1205 | "DELAY", | 986 | "DELAY", |
1206 | gettext_noop ("delay to start doing GETs (default: 5 min)"), | 987 | gettext_noop ("delay to start doing GETs (default: 5 min)"), |
1207 | &delay_get), | 988 | &delay_get), |
1208 | GNUNET_GETOPT_option_uint ('r', | 989 | GNUNET_GETOPT_option_uint ('r', |
1209 | "replication", | 990 | "replication", |
1210 | "DEGREE", | 991 | "DEGREE", |
1211 | gettext_noop ("replication degree for DHT PUTs"), | 992 | gettext_noop ("replication degree for DHT PUTs"), |
1212 | &replication), | 993 | &replication), |
1213 | 994 | GNUNET_GETOPT_option_uint ('R', | |
1214 | 995 | "random-chance", | |
996 | "PROBABILITY", | ||
997 | gettext_noop ("chance that a peer is selected at random for PUTs"), | ||
998 | &put_probability), | ||
1215 | GNUNET_GETOPT_option_relative_time ('t', | 999 | GNUNET_GETOPT_option_relative_time ('t', |
1216 | "timeout", | 1000 | "timeout", |
1217 | "TIMEOUT", | 1001 | "TIMEOUT", |
1218 | gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"), | 1002 | gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"), |
1219 | &timeout), | 1003 | &timeout), |
1220 | GNUNET_GETOPT_OPTION_END | 1004 | GNUNET_GETOPT_OPTION_END |
1221 | }; | 1005 | }; |
1222 | 1006 | ||
1223 | max_searches = 5; | 1007 | max_searches = 5; |
1224 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 1008 | if (GNUNET_OK != |
1009 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
1010 | &argc, &argv)) | ||
1225 | return 2; | 1011 | return 2; |
1226 | /* set default delays */ | 1012 | /* set default delays */ |
1227 | delay_stats = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); | 1013 | delay_stats = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
@@ -1231,10 +1017,13 @@ main (int argc, char *const *argv) | |||
1231 | replication = 1; /* default replication */ | 1017 | replication = 1; /* default replication */ |
1232 | rc = 0; | 1018 | rc = 0; |
1233 | if (GNUNET_OK != | 1019 | if (GNUNET_OK != |
1234 | GNUNET_PROGRAM_run (argc, argv, "dht-profiler", | 1020 | GNUNET_PROGRAM_run (argc, |
1235 | gettext_noop | 1021 | argv, |
1236 | ("Measure quality and performance of the DHT service."), | 1022 | "gnunet-dht-profiler", |
1237 | options, &run, NULL)) | 1023 | gettext_noop ("Measure quality and performance of the DHT service."), |
1024 | options, | ||
1025 | &run, | ||
1026 | NULL)) | ||
1238 | rc = 1; | 1027 | rc = 1; |
1239 | return rc; | 1028 | return rc; |
1240 | } | 1029 | } |