[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32743 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32743 - gnunet/src/mesh |
Date: |
Fri, 21 Mar 2014 19:44:54 +0100 |
Author: bartpolot
Date: 2014-03-21 19:44:54 +0100 (Fri, 21 Mar 2014)
New Revision: 32743
Modified:
gnunet/src/mesh/gnunet-mesh-profiler.c
Log:
- add warmup phase
Modified: gnunet/src/mesh/gnunet-mesh-profiler.c
===================================================================
--- gnunet/src/mesh/gnunet-mesh-profiler.c 2014-03-21 18:44:52 UTC (rev
32742)
+++ gnunet/src/mesh/gnunet-mesh-profiler.c 2014-03-21 18:44:54 UTC (rev
32743)
@@ -115,6 +115,11 @@
struct GNUNET_MESH_Channel *incoming_ch;
/**
+ * Channel handle for a warmup channel.
+ */
+ struct GNUNET_MESH_Channel *warmup_ch;
+
+ /**
* Number of payload packes sent
*/
int data_sent;
@@ -221,7 +226,13 @@
*/
static unsigned int current_round;
+
/**
+ * Do preconnect? (Each peer creates a tunnel to one other peer).
+ */
+static int do_warmup;
+
+/**
* Flag to notify callbacks not to generate any new traffic anymore.
*/
static int test_finished;
@@ -323,6 +334,12 @@
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: channel %p\n", i, peers[i].ch);
GNUNET_MESH_channel_destroy (peers[i].ch);
}
+ if (NULL != peers[i].warmup_ch)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: warmup channel %p\n",
+ i, peers[i].warmup_ch);
+ GNUNET_MESH_channel_destroy (peers[i].warmup_ch);
+ }
if (NULL != peers[i].incoming_ch)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: incoming channel %p\n",
@@ -755,6 +772,12 @@
peer = GNUNET_CONTAINER_multipeermap_get (ids, initiator);
GNUNET_assert (NULL != peer);
+ if (NULL == peers[n].incoming)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "WARMUP %u <= %u\n",
+ n, get_index (peer), channel);
+ return NULL;
+ }
GNUNET_assert (peer == peers[n].incoming);
GNUNET_assert (peer->dest == &peers[n]);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <= %u %p\n",
@@ -787,6 +810,13 @@
}
+/**
+ * Select a random peer that has no incoming channel
+ *
+ * @param peer ID of the peer connecting. NULL if irrelevant (warmup).
+ *
+ * @return Random peer not yet connected to.
+ */
static struct MeshPeer *
select_random_peer (struct MeshPeer *peer)
{
@@ -824,7 +854,6 @@
flags = GNUNET_MESH_OPTION_DEFAULT;
for (i = 0; i < peers_pinging; i++)
{
-
peers[i].dest = select_random_peer (&peers[i]);
peers[i].ch = GNUNET_MESH_channel_create (peers[i].mesh, NULL,
&peers[i].dest->id,
@@ -832,7 +861,7 @@
if (NULL == peers[i].ch)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Channel %lu failed\n", i);
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_MESH_TEST_cleanup (test_ctx);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u => %u %p\n",
@@ -853,6 +882,32 @@
/**
+ * Do warmup: create some channels to spread information about the topology.
+ */
+static void
+warmup (void)
+{
+ struct MeshPeer *peer;
+ unsigned int i;
+
+ for (i = 0; i < peers_total; i++)
+ {
+ peer = select_random_peer (NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "WARMUP %u => %u\n",
+ i, get_index (peer));
+ peers[i].warmup_ch =
+ GNUNET_MESH_channel_create (peers[i].mesh, NULL, &peer->id,
+ 1, GNUNET_MESH_OPTION_DEFAULT);
+ if (NULL == peers[i].warmup_ch)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Warmup %u failed\n", i);
+ GNUNET_MESH_TEST_cleanup (test_ctx);
+ return;
+ }
+ }
+}
+
+/**
* Callback to be called when the requested peer information is available
*
* @param cls the closure from GNUNET_TESTBED_peer_get_information()
@@ -868,6 +923,7 @@
const char *emsg)
{
long n = (long) cls;
+ struct GNUNET_TIME_Relative delay;
if (NULL == pinfo || NULL != emsg)
{
@@ -889,8 +945,11 @@
if (p_ids < peers_total)
return;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got all IDs, starting profiler\n");
- test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &start_test, NULL);
+ if (do_warmup)
+ warmup();
+ delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+ 150 * peers_total);
+ test_task = GNUNET_SCHEDULER_add_delayed (delay, &start_test, NULL);
}
/**
@@ -949,8 +1008,8 @@
if (4 > argc)
{
- fprintf (stderr, "usage: %s ROUND_TIME PEERS PINGS\n", argv[0]);
- fprintf (stderr, "example: %s 30s 16 1\n", argv[0]);
+ fprintf (stderr, "usage: %s ROUND_TIME PEERS PINGS [DO_WARMUP]\n",
argv[0]);
+ fprintf (stderr, "example: %s 30s 16 1 Y\n", argv[0]);
return 1;
}
@@ -977,6 +1036,8 @@
return 1;
}
+ do_warmup = (5 > argc || argv[4][0] == 'N');
+
ids = GNUNET_CONTAINER_multipeermap_create (2 * peers_total, GNUNET_YES);
GNUNET_assert (NULL != ids);
p_ids = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32743 - gnunet/src/mesh,
gnunet <=