#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)
*/
/**
* 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.
};
+/**
+ * Duration of each round.
+ */
+static struct GNUNET_TIME_Relative round_time;
+
/**
* GNUNET_PeerIdentity -> MeshPeer
*/
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);
}
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);
}
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]);
}
peers = GNUNET_malloc (sizeof (struct MeshPeer) * peers_total);
- peers_pinging = atoll (argv[2]);
+ peers_pinging = atoll (argv[3]);
if (peers_total < 2 * peers_pinging)
{
#!/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";
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