-move round time to cli, fix config file
authorBart Polot <bart@net.in.tum.de>
Fri, 21 Mar 2014 18:44:48 +0000 (18:44 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 21 Mar 2014 18:44:48 +0000 (18:44 +0000)
src/mesh/gnunet-mesh-profiler.c
src/mesh/profiler.conf
src/mesh/run_profiler.sh

index d93fa6081083c33c47edd3ca18685d518594e611..2f6026028cff65c964e06db076b08becf75b0cf8 100644 (file)
 #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)
   {
index 4dec9243177fd24cef5719ce7fc5ed60efd65894..7199cc403d561a2b2b7eaf41b599487ef103326d 100644 (file)
@@ -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
index a202567f0f8b625a5eff5d8232fbaf2c99ef1a45..cecbe0891f53ffd2727cb26e7ec285a2ce431b20 100755 (executable)
@@ -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