aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-03-21 18:44:45 +0000
committerBart Polot <bart@net.in.tum.de>2014-03-21 18:44:45 +0000
commit6fab84f7191c94148e34d6f6b64e944c64073e72 (patch)
tree78b674439f23486705b59fffec6f2dff7981b22e /src/mesh
parent981320da074353c74a90d3b77c4a4a750de710bb (diff)
downloadgnunet-6fab84f7191c94148e34d6f6b64e944c64073e72.tar.gz
gnunet-6fab84f7191c94148e34d6f6b64e944c64073e72.zip
- move pings to cli
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-mesh-profiler.c30
-rwxr-xr-xsrc/mesh/run_profiler.sh6
2 files changed, 19 insertions, 17 deletions
diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c
index f0c55b495..0a92c857c 100644
--- a/src/mesh/gnunet-mesh-profiler.c
+++ b/src/mesh/gnunet-mesh-profiler.c
@@ -34,11 +34,6 @@
34 34
35 35
36/** 36/**
37 * How many peers do pinging
38 */
39#define PING_PEERS 3
40
41/**
42 * Duration of each round. 37 * Duration of each round.
43 */ 38 */
44#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 39#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
@@ -66,7 +61,7 @@
66/** 61/**
67 * Ratio of peers active. First round always is 1.0. 62 * Ratio of peers active. First round always is 1.0.
68 */ 63 */
69static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.0}; 64static float rounds[] = {0.8, 0.6, 0.4, 0.2, 0.0};
70 65
71/** 66/**
72 * Message type for pings. 67 * Message type for pings.
@@ -197,6 +192,11 @@ static unsigned long long peers_total;
197static unsigned long long peers_running; 192static unsigned long long peers_running;
198 193
199/** 194/**
195 * Number of peers doing pings.
196 */
197static unsigned long long peers_pinging;
198
199/**
200 * Test context (to shut down). 200 * Test context (to shut down).
201 */ 201 */
202static struct GNUNET_MESH_TEST_Context *test_ctx; 202static struct GNUNET_MESH_TEST_Context *test_ctx;
@@ -269,7 +269,7 @@ show_end_data (void)
269 269
270 for (i = 0; i < number_rounds; i++) 270 for (i = 0; i < number_rounds; i++)
271 { 271 {
272 for (j = 0; j < PING_PEERS; j++) 272 for (j = 0; j < peers_pinging; j++)
273 { 273 {
274 peer = &peers[j]; 274 peer = &peers[j];
275 FPRINTF (stdout, 275 FPRINTF (stdout,
@@ -472,8 +472,8 @@ adjust_running_peers (unsigned int target)
472 { 472 {
473 do { 473 do {
474 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 474 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
475 peers_total - PING_PEERS); 475 peers_total - peers_pinging);
476 r += PING_PEERS; 476 r += peers_pinging;
477 } while (peers[r].up == run || NULL != peers[r].incoming); 477 } while (peers[r].up == run || NULL != peers[r].incoming);
478 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n", 478 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n",
479 run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id)); 479 run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id));
@@ -822,7 +822,7 @@ start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
822 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n"); 822 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n");
823 823
824 flags = GNUNET_MESH_OPTION_DEFAULT; 824 flags = GNUNET_MESH_OPTION_DEFAULT;
825 for (i = 0; i < PING_PEERS; i++) 825 for (i = 0; i < peers_pinging; i++)
826 { 826 {
827 827
828 peers[i].dest = select_random_peer (&peers[i]); 828 peers[i].dest = select_random_peer (&peers[i]);
@@ -913,10 +913,10 @@ tmain (void *cls,
913 913
914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n"); 914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
915 test_ctx = ctx; 915 test_ctx = ctx;
916 if (peers_total < 2 * PING_PEERS) 916 if (peers_total < 2 * peers_pinging)
917 { 917 {
918 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 918 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
919 "not enough peers, total should be > 2 * PING_PEERS\n"); 919 "not enough peers, total should be > 2 * peers_pinging\n");
920 GNUNET_MESH_TEST_cleanup (ctx); 920 GNUNET_MESH_TEST_cleanup (ctx);
921 return; 921 return;
922 } 922 }
@@ -954,9 +954,9 @@ main (int argc, char *argv[])
954 954
955 config_file = ".profiler.conf"; 955 config_file = ".profiler.conf";
956 956
957 if (2 > argc) 957 if (3 > argc)
958 { 958 {
959 fprintf (stderr, "usage: %s PEERS\n", argv[0]); 959 fprintf (stderr, "usage: %s PEERS PINGS\n", argv[0]);
960 return 1; 960 return 1;
961 } 961 }
962 peers_total = atoll (argv[1]); 962 peers_total = atoll (argv[1]);
@@ -967,6 +967,8 @@ main (int argc, char *argv[])
967 } 967 }
968 peers = GNUNET_malloc (sizeof (struct MeshPeer) * peers_total); 968 peers = GNUNET_malloc (sizeof (struct MeshPeer) * peers_total);
969 969
970 peers_pinging = atoll (argv[2]);
971
970 ids = GNUNET_CONTAINER_multipeermap_create (2 * peers_total, GNUNET_YES); 972 ids = GNUNET_CONTAINER_multipeermap_create (2 * peers_total, GNUNET_YES);
971 GNUNET_assert (NULL != ids); 973 GNUNET_assert (NULL != ids);
972 p_ids = 0; 974 p_ids = 0;
diff --git a/src/mesh/run_profiler.sh b/src/mesh/run_profiler.sh
index ba0a946b9..a202567f0 100755
--- a/src/mesh/run_profiler.sh
+++ b/src/mesh/run_profiler.sh
@@ -1,7 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2 2
3if [ "$#" -lt "1" ]; then 3if [ "$#" -lt "2" ]; then
4 echo "usage: $0 PEERS"; 4 echo "usage: $0 PEERS PINGING_PEERS";
5 exit 1; 5 exit 1;
6fi 6fi
7 7
@@ -18,4 +18,4 @@ echo "using $PEERS peers, $LINKS links";
18 18
19sed -e "s/%LINKS%/$LINKS/g" profiler.conf > .profiler.conf 19sed -e "s/%LINKS%/$LINKS/g" profiler.conf > .profiler.conf
20 20
21./gnunet-mesh-profiler $PEERS |& tee log 21./gnunet-mesh-profiler $PEERS $2 |& tee log