aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-03-17 11:02:47 +0000
committerBart Polot <bart@net.in.tum.de>2014-03-17 11:02:47 +0000
commita102b218f0b17e6247a93405a365de4ed649335a (patch)
tree9a3390b0571728edcb76e921f14b1c73f63258cc /src
parent284af945ccbdc0ca5442227b1c895c25dde6671b (diff)
downloadgnunet-a102b218f0b17e6247a93405a365de4ed649335a.tar.gz
gnunet-a102b218f0b17e6247a93405a365de4ed649335a.zip
- only ping from select peers, do not shut them down
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-mesh-profiler.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c
index 08de6056d..9d017d8fd 100644
--- a/src/mesh/gnunet-mesh-profiler.c
+++ b/src/mesh/gnunet-mesh-profiler.c
@@ -33,11 +33,17 @@
33#define PONG 2 33#define PONG 2
34 34
35/** 35/**
36 * How namy peers to run 36 * How many peers to run
37 */ 37 */
38#define TOTAL_PEERS 10 38#define TOTAL_PEERS 10
39 39
40/** 40/**
41 * How many peers do pinging
42 */
43#define PING_PEERS 1
44
45
46/**
41 * Duration of each round. 47 * Duration of each round.
42 */ 48 */
43#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 49#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
@@ -405,8 +411,10 @@ adjust_running_peers (unsigned int target)
405 for (i = 0; i < delta; i++) 411 for (i = 0; i < delta; i++)
406 { 412 {
407 do { 413 do {
408 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, TOTAL_PEERS); 414 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
409 } while (peers[r].up == run); 415 TOTAL_PEERS - PING_PEERS);
416 r += PING_PEERS;
417 } while (peers[r].up == run || NULL != peers[r].incoming);
410 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n", 418 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n",
411 run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id)); 419 run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id));
412 420
@@ -416,10 +424,15 @@ adjust_running_peers (unsigned int target)
416 424
417 peers[r].up = run; 425 peers[r].up = run;
418 426
419 GNUNET_MESH_channel_destroy (peers[r].ch); 427 if (NULL != peers[r].ch)
428 GNUNET_MESH_channel_destroy (peers[r].ch);
420 peers[r].ch = NULL; 429 peers[r].ch = NULL;
421 GNUNET_MESH_channel_destroy (peers[r].dest->incoming_ch); 430 if (NULL != peers[r].dest)
422 peers[r].dest->incoming_ch = NULL; 431 {
432 if (NULL != peers[r].dest->incoming_ch)
433 GNUNET_MESH_channel_destroy (peers[r].dest->incoming_ch);
434 peers[r].dest->incoming_ch = NULL;
435 }
423 GNUNET_MESH_disconnect (peers[r].mesh); 436 GNUNET_MESH_disconnect (peers[r].mesh);
424 peers[r].mesh = NULL; 437 peers[r].mesh = NULL;
425 438
@@ -725,7 +738,7 @@ start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
725 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n"); 738 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n");
726 739
727 flags = GNUNET_MESH_OPTION_DEFAULT; 740 flags = GNUNET_MESH_OPTION_DEFAULT;
728 for (i = 0; i < TOTAL_PEERS; i++) 741 for (i = 0; i < PING_PEERS; i++)
729 { 742 {
730 743
731 peers[i].dest = select_random_peer (&peers[i]); 744 peers[i].dest = select_random_peer (&peers[i]);
@@ -804,6 +817,7 @@ tmain (void *cls,
804 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n"); 817 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
805 ok = 0; 818 ok = 0;
806 test_ctx = ctx; 819 test_ctx = ctx;
820 GNUNET_assert (TOTAL_PEERS > 2 * PING_PEERS);
807 GNUNET_assert (TOTAL_PEERS == num_peers); 821 GNUNET_assert (TOTAL_PEERS == num_peers);
808 peers_running = num_peers; 822 peers_running = num_peers;
809 testbed_handles = testbed_peers; 823 testbed_handles = testbed_peers;