commit 6b50d0090dfda491214c64569e64bb8a03b4648e
parent 51de20f3d259aec376595e625eac5c78c628e2fc
Author: Bart Polot <bart@net.in.tum.de>
Date: Fri, 21 Mar 2014 18:44:48 +0000
-move round time to cli, fix config file
Diffstat:
3 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c
@@ -34,11 +34,6 @@
/**
- * 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)
*/
#define PING_PERIOD 1000
@@ -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.
@@ -157,6 +152,11 @@ struct MeshPeer
};
/**
+ * Duration of each round.
+ */
+static struct GNUNET_TIME_Relative round_time;
+
+/**
* GNUNET_PeerIdentity -> MeshPeer
*/
static struct GNUNET_CONTAINER_MultiPeerMap *ids;
@@ -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
@@ -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
@@ -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