[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25702 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25702 - gnunet/src/testbed |
Date: |
Sun, 6 Jan 2013 01:13:33 +0100 |
Author: harsha
Date: 2013-01-06 01:13:33 +0100 (Sun, 06 Jan 2013)
New Revision: 25702
Modified:
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/test_testbed_api.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologyclique.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologyfromfile.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologyline.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologyring.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologyscalefree.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworld.conf
gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf
gnunet/src/testbed/testbed.conf.in
Log:
cache HELLO's of peers
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2013-01-05 18:15:14 UTC (rev
25701)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2013-01-06 00:13:33 UTC (rev
25702)
@@ -816,7 +816,33 @@
};
+/**
+ * Hello cache entry
+ */
+struct HelloCacheEntry
+{
+ /**
+ * DLL next ptr for least recently used hello cache entries
+ */
+ struct HelloCacheEntry *next;
+ /**
+ * DLL prev ptr for least recently used hello cache entries
+ */
+ struct HelloCacheEntry *prev;
+
+ /**
+ * The key for this entry
+ */
+ struct GNUNET_HashCode key;
+
+ /**
+ * The HELLO message
+ */
+ struct GNUNET_MessageHeader *hello;
+};
+
+
/**
* The master context; generated with the first INIT message
*/
@@ -898,6 +924,18 @@
static struct ForwardedOperationContext *fopcq_tail;
/**
+ * DLL head for least recently used hello cache entries; least recently used
+ * cache items are at the head
+ */
+static struct HelloCacheEntry *lru_hcache_head;
+
+/**
+ * DLL tail for least recently used hello cache entries; recently used cache
+ * items are at the tail
+ */
+static struct HelloCacheEntry *lru_hcache_tail;
+
+/**
* Array of hosts
*/
static struct GNUNET_TESTBED_Host **host_list;
@@ -923,6 +961,11 @@
static struct GNUNET_CONTAINER_MultiHashMap *ss_map;
/**
+ * Hashmap to maintain HELLO cache
+ */
+static struct GNUNET_CONTAINER_MultiHashMap *hello_cache;
+
+/**
* The event mask for the events we listen from sub-controllers
*/
static uint64_t event_mask;
@@ -947,6 +990,11 @@
*/
static unsigned int peer_list_size;
+/**
+ * The size of hello cache
+ */
+static unsigned int hello_cache_size;
+
/*********/
/* Tasks */
/*********/
@@ -963,6 +1011,87 @@
/**
+ * Looks up in the hello cache and returns the HELLO of the given peer
+ *
+ * @param id the peer identity of the peer whose HELLO has to be looked up
+ * @return the HELLO message; NULL if not found
+ */
+static const struct GNUNET_MessageHeader *
+hello_cache_lookup (const struct GNUNET_PeerIdentity *id)
+{
+ struct HelloCacheEntry *entry;
+
+ if (NULL == hello_cache)
+ return NULL;
+ entry = GNUNET_CONTAINER_multihashmap_get (hello_cache, &id->hashPubKey);
+ if (NULL == entry)
+ return NULL;
+ GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry);
+ GNUNET_CONTAINER_DLL_insert_tail (lru_hcache_head, lru_hcache_tail, entry);
+ return entry->hello;
+}
+
+
+/**
+ * Removes the given hello cache centry from hello cache and frees its
resources
+ *
+ * @param entry the entry to remove
+ */
+static void
+hello_cache_remove (struct HelloCacheEntry *entry)
+{
+ GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (hello_cache,
+ &entry->key,
+ entry));
+ GNUNET_free (entry->hello);
+ GNUNET_free (entry);
+}
+
+
+/**
+ * Caches the HELLO of the given peer. Updates the HELLO if it was already
+ * cached before
+ *
+ * @param id the peer identity of the peer whose HELLO has to be cached
+ * @param hello the HELLO message
+ */
+static void
+hello_cache_add (const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_MessageHeader *hello)
+{
+ struct HelloCacheEntry *entry;
+
+ if (NULL == hello_cache)
+ return;
+ entry = GNUNET_CONTAINER_multihashmap_get (hello_cache, &id->hashPubKey);
+ if (NULL == entry)
+ {
+ entry = GNUNET_malloc (sizeof (struct HelloCacheEntry));
+ memcpy (&entry->key, &id->hashPubKey, sizeof (struct GNUNET_HashCode));
+ if (GNUNET_CONTAINER_multihashmap_size (hello_cache) == hello_cache_size)
+ {
+ GNUNET_assert (NULL != lru_hcache_head);
+ hello_cache_remove (lru_hcache_head);
+ }
+ GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put
+ (hello_cache,
+ &entry->key,
+ entry,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
+ }
+ else
+ {
+ GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry);
+ GNUNET_free (entry->hello);
+ }
+ entry->hello = GNUNET_copy_message (hello);
+ GNUNET_CONTAINER_DLL_insert_tail (lru_hcache_head, lru_hcache_tail, entry);
+}
+
+
+/**
* Function called to notify a client about the connection begin ready to queue
* more data. "buf" will be NULL and "size" zero if the connection was closed
* for writing in the meantime.
@@ -3069,7 +3198,43 @@
GNUNET_free (other_peer_str);
}
+
/**
+ * Connects to the transport of the other peer if it is a local peer and
+ * schedules the send hello task
+ *
+ * @param occ the overlay connect context
+ */
+static void
+p2_transport_connect (struct OverlayConnectContext *occ)
+{
+ GNUNET_assert (NULL == occ->emsg);
+ GNUNET_assert (NULL != occ->hello);
+ GNUNET_assert (NULL == occ->ghh);
+ GNUNET_assert (NULL == occ->p1th);
+ if (NULL == occ->peer2_controller)
+ {
+ peer_list[occ->other_peer_id]->reference_cnt++;
+ occ->tcc.th =
+ GNUNET_TRANSPORT_connect
(peer_list[occ->other_peer_id]->details.local.cfg,
+ &occ->other_peer_identity, NULL, NULL, NULL,
+ NULL);
+ if (NULL == occ->tcc.th)
+ {
+ GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s",
+ occ->op_id, GNUNET_i2s (&occ->other_peer_identity));
+ GNUNET_SCHEDULER_cancel (occ->timeout_task);
+ occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect,
occ);
+ return;
+ }
+ }
+ GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while offering HELLO to %s",
+ occ->op_id, GNUNET_i2s (&occ->other_peer_identity));
+ occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ);
+}
+
+
+/**
* Test for checking whether HELLO message is empty
*
* @param cls empty flag to set
@@ -3117,6 +3282,7 @@
LOG_DEBUG ("0x%llx: Received HELLO of %s\n",
occ->op_id, GNUNET_i2s (&occ->peer_identity));
occ->hello = GNUNET_malloc (msize);
+ hello_cache_add (&occ->peer_identity, hello);
memcpy (occ->hello, hello, msize);
GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
occ->ghh = NULL;
@@ -3124,25 +3290,8 @@
occ->p1th = NULL;
occ->peer->reference_cnt--;
GNUNET_free_non_null (occ->emsg);
- if (NULL == occ->peer2_controller)
- {
- peer_list[occ->other_peer_id]->reference_cnt++;
- occ->tcc.th =
- GNUNET_TRANSPORT_connect
(peer_list[occ->other_peer_id]->details.local.cfg,
- &occ->other_peer_identity, NULL, NULL, NULL,
- NULL);
- if (NULL == occ->tcc.th)
- {
- GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s",
- occ->op_id, GNUNET_i2s (&occ->other_peer_identity));
- GNUNET_SCHEDULER_cancel (occ->timeout_task);
- occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect,
occ);
- return;
- }
- }
- GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while offering HELLO to %s",
- occ->op_id, GNUNET_i2s (&occ->other_peer_identity));
- occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ);
+ occ->emsg = NULL;
+ p2_transport_connect (occ);
}
@@ -3162,6 +3311,7 @@
const struct GNUNET_PeerIdentity *my_identity)
{
struct OverlayConnectContext *occ = cls;
+ const struct GNUNET_MessageHeader *hello;
GNUNET_free_non_null (occ->emsg);
(void) GNUNET_asprintf (&occ->emsg,
@@ -3174,6 +3324,17 @@
occ->emsg = NULL;
memcpy (&occ->peer_identity, my_identity,
sizeof (struct GNUNET_PeerIdentity));
+ LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
+ occ->op_id, GNUNET_i2s (&occ->peer_identity));
+ /* Lookup for HELLO in hello cache */
+ if (NULL != (hello = hello_cache_lookup (&occ->peer_identity)))
+ {
+ LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n",
+ occ->op_id, GNUNET_i2s (&occ->peer_identity));
+ occ->hello = GNUNET_copy_message (hello);
+ p2_transport_connect (occ);
+ return;
+ }
occ->peer->reference_cnt++;
occ->p1th =
GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg,
@@ -3184,9 +3345,7 @@
"0x%llx: Cannot connect to TRANSPORT of peer %4s",
occ->op_id, GNUNET_i2s (&occ->peer_identity));
goto error_return;
- }
- LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
- occ->op_id, GNUNET_i2s (&occ->peer_identity));
+ }
GNUNET_asprintf (&occ->emsg,
"0x%llx: Timeout while acquiring HELLO of peer %4s",
occ->op_id, GNUNET_i2s (&occ->peer_identity));
@@ -4052,9 +4211,20 @@
GNUNET_SERVER_client_drop (mq_entry->client);
GNUNET_CONTAINER_DLL_remove (mq_head, mq_tail, mq_entry);
GNUNET_free (mq_entry);
- }
+ }
GNUNET_free_non_null (hostname);
GNUNET_CONFIGURATION_destroy (our_config);
+ /* Free hello cache */
+ if (NULL != hello_cache)
+ GNUNET_assert
+ (GNUNET_CONTAINER_multihashmap_size (hello_cache) <= hello_cache_size);
+ while (NULL != lru_hcache_head)
+ hello_cache_remove (lru_hcache_head);
+ if (NULL != hello_cache)
+ {
+ GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (hello_cache));
+ GNUNET_CONTAINER_multihashmap_destroy (hello_cache);
+ }
}
@@ -4118,6 +4288,7 @@
{NULL}
};
char *logfile;
+ unsigned long long num;
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
"TESTBED",
@@ -4127,12 +4298,20 @@
GNUNET_break (GNUNET_OK == GNUNET_log_setup ("testbed", "DEBUG", logfile));
GNUNET_free (logfile);
}
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
+ "HELLO_CACHE_SIZE",
+ &num));
+ hello_cache_size = (unsigned int) num;
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string
(cfg, "testbed", "HOSTNAME", &hostname));
our_config = GNUNET_CONFIGURATION_dup (cfg);
GNUNET_SERVER_add_handlers (server, message_handlers);
GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL);
ss_map = GNUNET_CONTAINER_multihashmap_create (5, GNUNET_NO);
+ if (1 < hello_cache_size)
+ hello_cache = GNUNET_CONTAINER_multihashmap_create (hello_cache_size / 2,
+ GNUNET_YES);
shutdown_task_id =
GNUNET_SCHEDULER_add_delayed_with_priority (GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_SCHEDULER_PRIORITY_IDLE,
Modified: gnunet/src/testbed/test_testbed_api.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api.conf 2013-01-05 18:15:14 UTC (rev
25701)
+++ gnunet/src/testbed/test_testbed_api.conf 2013-01-06 00:13:33 UTC (rev
25702)
@@ -4,7 +4,6 @@
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
NEIGHBOUR_LIMIT = 100
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
TOPOLOGY = RANDOM
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
Modified: gnunet/src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topology2dtorus.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -4,7 +4,6 @@
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
NEIGHBOUR_LIMIT = 100
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
OVERLAY_TOPOLOGY = 2D_TORUS
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
@@ -77,4 +76,4 @@
RETURN_LOCAL_ADDRESSES = YES
[gns-helper-service-w32]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
Modified: gnunet/src/testbed/test_testbed_api_testbed_run_topologyclique.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologyclique.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologyclique.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -4,7 +4,6 @@
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
NEIGHBOUR_LIMIT = 100
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
OVERLAY_TOPOLOGY = CLIQUE
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
@@ -77,4 +76,4 @@
RETURN_LOCAL_ADDRESSES = YES
[gns-helper-service-w32]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
Modified: gnunet/src/testbed/test_testbed_api_testbed_run_topologyfromfile.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologyfromfile.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologyfromfile.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -6,7 +6,6 @@
NEIGHBOUR_LIMIT = 100
OVERLAY_TOPOLOGY = FROM_FILE
OVERLAY_TOPOLOGY_FILE = overlay_topology.txt
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
[fs]
Modified: gnunet/src/testbed/test_testbed_api_testbed_run_topologyline.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologyline.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologyline.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -5,7 +5,6 @@
HOSTNAME = localhost
NEIGHBOUR_LIMIT = 100
OVERLAY_TOPOLOGY = LINE
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
[fs]
Modified: gnunet/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -3,7 +3,6 @@
PORT = 12113
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
OVERLAY_TOPOLOGY = RANDOM
OVERLAY_RANDOM_LINKS = 5
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
@@ -77,4 +76,4 @@
RETURN_LOCAL_ADDRESSES = YES
[gns-helper-service-w32]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
Modified: gnunet/src/testbed/test_testbed_api_testbed_run_topologyring.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologyring.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologyring.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -4,7 +4,6 @@
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
NEIGHBOUR_LIMIT = 100
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
OVERLAY_TOPOLOGY = RING
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
@@ -77,4 +76,4 @@
RETURN_LOCAL_ADDRESSES = YES
[gns-helper-service-w32]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
Modified: gnunet/src/testbed/test_testbed_api_testbed_run_topologyscalefree.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologyscalefree.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologyscalefree.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -4,7 +4,6 @@
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
NEIGHBOUR_LIMIT = 100
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
OVERLAY_TOPOLOGY = RING
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
@@ -77,4 +76,4 @@
RETURN_LOCAL_ADDRESSES = YES
[gns-helper-service-w32]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
Modified:
gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworld.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworld.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworld.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -3,7 +3,6 @@
PORT = 12113
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
OVERLAY_TOPOLOGY = SMALL_WORLD
OVERLAY_RANDOM_LINKS = 3
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
Modified:
gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf
===================================================================
--- gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf
2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/test_testbed_api_testbed_run_topologysmallworldring.conf
2013-01-06 00:13:33 UTC (rev 25702)
@@ -3,7 +3,6 @@
PORT = 12113
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 2
OVERLAY_TOPOLOGY = SMALL_WORLD_RING
OVERLAY_RANDOM_LINKS = 3
#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
Modified: gnunet/src/testbed/testbed.conf.in
===================================================================
--- gnunet/src/testbed/testbed.conf.in 2013-01-05 18:15:14 UTC (rev 25701)
+++ gnunet/src/testbed/testbed.conf.in 2013-01-06 00:13:33 UTC (rev 25702)
@@ -13,5 +13,5 @@
UNIX_MATCH_GID = YES
MAX_PARALLEL_OPERATIONS = 1000
MAX_PARALLEL_SERVICE_CONNECTIONS = 1000
-MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 5
-PARALLEL_OVERLAY_CONNECT_THRESHOLD = 16
+MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1
+HELLO_CACHE_SIZE = 30
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25702 - gnunet/src/testbed,
gnunet <=