From: Bart Polot Date: Fri, 21 Mar 2014 18:44:48 +0000 (+0000) Subject: -move round time to cli, fix config file X-Git-Tag: initial-import-from-subversion-38251~4451 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6b50d0090dfda491214c64569e64bb8a03b4648e;p=oweals%2Fgnunet.git -move round time to cli, fix config file --- diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c index d93fa6081..2f6026028 100644 --- a/src/mesh/gnunet-mesh-profiler.c +++ b/src/mesh/gnunet-mesh-profiler.c @@ -33,11 +33,6 @@ #define PONG 2 -/** - * Duration of each round. - */ -#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) - /** * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD) */ @@ -61,7 +56,7 @@ /** * Ratio of peers active. First round always is 1.0. */ -static float rounds[] = {0.8, 0.6, 0.4, 0.2, 0.0}; +static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.0}; /** * Message type for pings. @@ -156,6 +151,11 @@ struct MeshPeer }; +/** + * Duration of each round. + */ +static struct GNUNET_TIME_Relative round_time; + /** * GNUNET_PeerIdentity -> MeshPeer */ @@ -525,7 +525,7 @@ next_rnd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) adjust_running_peers (rounds[current_round] * peers_total); current_round++; - GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL); + GNUNET_SCHEDULER_add_delayed (round_time, &next_rnd, NULL); } @@ -844,11 +844,11 @@ start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) GNUNET_SCHEDULER_cancel (disconnect_task); disconnect_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(ROUND_TIME, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(round_time, number_rounds + 1), &disconnect_mesh_peers, (void *) __LINE__); - GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL); + GNUNET_SCHEDULER_add_delayed (round_time, &next_rnd, NULL); } @@ -947,12 +947,20 @@ main (int argc, char *argv[]) config_file = ".profiler.conf"; - if (3 > argc) + if (4 > argc) + { + fprintf (stderr, "usage: %s ROUND_TIME PEERS PINGS\n", argv[0]); + fprintf (stderr, "example: %s 30s 16 1\n", argv[0]); + return 1; + } + + if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[1], &round_time)) { - fprintf (stderr, "usage: %s PEERS PINGS\n", argv[0]); + fprintf (stderr, "%s is not a valid time\n", argv[1]); return 1; } - peers_total = atoll (argv[1]); + + peers_total = atoll (argv[2]); if (2 > peers_total) { fprintf (stderr, "%s peers is not valid (> 2)\n", argv[1]); @@ -960,7 +968,7 @@ main (int argc, char *argv[]) } peers = GNUNET_malloc (sizeof (struct MeshPeer) * peers_total); - peers_pinging = atoll (argv[2]); + peers_pinging = atoll (argv[3]); if (peers_total < 2 * peers_pinging) { diff --git a/src/mesh/profiler.conf b/src/mesh/profiler.conf index 4dec92431..7199cc403 100644 --- a/src/mesh/profiler.conf +++ b/src/mesh/profiler.conf @@ -1,8 +1,8 @@ @INLINE@ test_mesh.conf [testbed] OVERLAY_TOPOLOGY = RANDOM -OVERLAY_RANDOM_LINKS = 200 +OVERLAY_RANDOM_LINKS = %LINKS% [transport] #MANIPULATE_DELAY_IN = 50 ms -MANIPULATE_DELAY_OUT = 100 ms \ No newline at end of file +MANIPULATE_DELAY_OUT = 100 ms diff --git a/src/mesh/run_profiler.sh b/src/mesh/run_profiler.sh index a202567f0..cecbe0891 100755 --- a/src/mesh/run_profiler.sh +++ b/src/mesh/run_profiler.sh @@ -1,11 +1,14 @@ #!/bin/sh -if [ "$#" -lt "2" ]; then - echo "usage: $0 PEERS PINGING_PEERS"; +if [ "$#" -lt "3" ]; then + echo "usage: $0 ROUND_TIME PEERS PINGING_PEERS"; + echo "example: $0 30s 16 1"; exit 1; fi -PEERS=$1 +ROUNDTIME=$1 +PEERS=$2 +PINGS=$3 if [ $PEERS -eq 1 ]; then echo "cannot run 1 peer"; @@ -18,4 +21,4 @@ echo "using $PEERS peers, $LINKS links"; sed -e "s/%LINKS%/$LINKS/g" profiler.conf > .profiler.conf -./gnunet-mesh-profiler $PEERS $2 |& tee log +./gnunet-mesh-profiler $ROUNDTIME $PEERS $PINGS |& tee log