[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8811 - GNUnet/src/applications/dv_dht/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8811 - GNUnet/src/applications/dv_dht/module |
Date: |
Wed, 29 Jul 2009 14:25:21 -0600 |
Author: nevans
Date: 2009-07-29 14:25:21 -0600 (Wed, 29 Jul 2009)
New Revision: 8811
Modified:
GNUnet/src/applications/dv_dht/module/routing.c
GNUnet/src/applications/dv_dht/module/table.c
GNUnet/src/applications/dv_dht/module/table.h
Log:
high success rates, but too many message sent redundantly for gets and
responses.
Modified: GNUnet/src/applications/dv_dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/routing.c 2009-07-29 15:09:09 UTC
(rev 8810)
+++ GNUnet/src/applications/dv_dht/module/routing.c 2009-07-29 20:25:21 UTC
(rev 8811)
@@ -362,11 +362,15 @@
struct GNUNET_BloomFilter *bloom;
unsigned int routed;
unsigned int tracked;
+ unsigned int sent_other;
int match;
int cost;
DV_DHT_Source_Route *pos;
DV_DHT_Source_Route *prev;
+
+ GNUNET_PeerIdentity set;
+
#if DEBUG_ROUTING
GNUNET_EncName enc;
unsigned long long queryuid;
@@ -452,6 +456,7 @@
GNUNET_hash (data, size, &hc);
routed = 0;
tracked = 0;
+ sent_other = 0;
GNUNET_mutex_lock (lock);
if (GNUNET_multi_hash_map_contains (new_records.hashmap, key))
@@ -469,6 +474,7 @@
prev = NULL;
while (pos != NULL)
{
+ tracked++;
if (0 != memcmp (&pos->source,
coreAPI->my_identity,
sizeof (GNUNET_PeerIdentity)))
@@ -489,17 +495,36 @@
continue;
}
+ GNUNET_bloomfilter_add (bloom, &pos->source.hashPubKey);
+
cost = dvapi->dv_send (&pos->source,
&result->header, DV_DHT_PRIORITY,
DV_DHT_DELAY);
- /* Need to change this piece, because we may want to try another
path for the reply in the case of failure from
- * the DV subsystem. (Likely to another close peer that may know
of this request)
- */
if (cost == GNUNET_SYSERR)
- break;
+ {
+ if (GNUNET_OK ==
+ GNUNET_DV_DHT_select_peer (&set,
+ &pos->source.hashPubKey,
+ NULL, 0, bloom))
+ {
+#if DEBUG_ROUTING
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN |
+ GNUNET_GE_USER | GNUNET_GE_BULK,
+ "Failed to send result along return path,
choosing nearby peer!\n");
+#endif
+ cost = dvapi->dv_send (&set,
+ &result->header, DV_DHT_PRIORITY,
+ DV_DHT_DELAY);
+ if (cost != GNUNET_SYSERR)
+ sent_other++;
+ }
+ pos = pos->next;
+ continue;
+ }
+ routed++;
-
if ((debug_routes_extended) && (dhtlog != NULL))
{
queryuid = ntohl (result->queryuid);
@@ -543,6 +568,8 @@
}
if (stats != NULL)
stats->change (stat_replies_routed, 1);
+
+ routed++;
}
pos = pos->next;
}
@@ -552,8 +579,8 @@
GNUNET_GE_LOG (coreAPI->ectx,
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
GNUNET_GE_BULK,
- "Routed result to %u out of %u pending requests\n",
- routed, tracked);
+ "Routed result to %u out of %u pending requests. Sent %u to
nearest peer due to route failure.\n",
+ routed, tracked, sent_other);
#endif
GNUNET_bloomfilter_free (bloom);
if (cls == NULL)
@@ -569,17 +596,13 @@
GNUNET_ResultProcessor handler, void *cls,
const DV_DHT_MESSAGE * get)
{
-
-/*
- * TODO: Eventually change to using a hash
- * map for more efficient lookup of return routing information!
- */
DV_DHTQueryRecord *q;
unsigned int diameter;
unsigned int hops;
struct DV_DHT_Source_Route *pos;
unsigned int routes_size;
unsigned int heap_size;
+ unsigned int found;
GNUNET_CronTime now;
hops = ntohl (get->hop_count);
@@ -652,15 +675,49 @@
}
q->get = *get;
- pos = GNUNET_malloc (sizeof (DV_DHT_Source_Route));
- pos->next = q->sources;
- q->sources = pos;
- if (sender != NULL)
- pos->source = *sender;
+ pos = q->sources;
+ found = GNUNET_NO;
+ while (pos != NULL)
+ {
+ /* Check for return peer already in set */
+ if ((sender != NULL
+ && memcmp (&pos->source, sender,
+ sizeof (GNUNET_PeerIdentity)) == 0) || (sender == NULL
+ &&
+ memcmp (&pos->
+ source,
+ coreAPI->
+
my_identity,
+ sizeof
+
(GNUNET_PeerIdentity))
+ == 0))
+ {
+ found = GNUNET_YES;
+ }
+ pos = pos->next;
+ }
+
+ if (found == GNUNET_NO)
+ {
+ pos = GNUNET_malloc (sizeof (DV_DHT_Source_Route));
+ pos->next = q->sources;
+ q->sources = pos;
+ if (sender != NULL)
+ pos->source = *sender;
+ else
+ pos->source = *coreAPI->my_identity;
+ pos->receiver = handler;
+ pos->receiver_closure = cls;
+ }
else
- pos->source = *coreAPI->my_identity;
- pos->receiver = handler;
- pos->receiver_closure = cls;
+ {
+#if DEBUG_ROUTING
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "Already have this peer in return route!\n");
+#endif
+ }
GNUNET_CONTAINER_heap_insert (new_records.minHeap, q, now);
GNUNET_multi_hash_map_put (new_records.hashmap, &get->key, q,
@@ -700,6 +757,9 @@
GNUNET_GE_BREAK (NULL, 0);
return GNUNET_SYSERR;
}
+ if (sender != NULL)
+ GNUNET_DV_DHT_considerPeer (sender);
+
get = (const DV_DHT_MESSAGE *) msg;
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&get->key, &enc);
@@ -820,9 +880,15 @@
cost =
dvapi->dv_send (&next[j], &aget.header, DV_DHT_PRIORITY,
DV_DHT_DELAY);
+
+ GNUNET_bloomfilter_add (bloom, &coreAPI->my_identity->hashPubKey);
+
if (cost == GNUNET_SYSERR)
continue;
+ GNUNET_bloomfilter_get_raw_data (bloom, &aget.bloomfilter[0],
+ DV_DHT_BLOOM_SIZE);
+
if ((debug_routes_extended) && (dhtlog != NULL))
{
queryuid = ntohl (get->queryuid);
@@ -867,6 +933,9 @@
}
if (stats != NULL)
stats->change (stat_put_requests_received, 1);
+ if (sender != NULL)
+ GNUNET_DV_DHT_considerPeer (sender);
+
put = (const DV_DHT_MESSAGE *) msg;
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&put->key, &enc);
@@ -918,6 +987,7 @@
GNUNET_GE_BULK,
"Forwarding DV_DHT PUT request to peer `%s'.\n", &enc);
#endif
+ GNUNET_bloomfilter_add (bloom, &next[j].hashPubKey);
cost =
dvapi->dv_send (&next[j], &aput->header, DV_DHT_PRIORITY,
DV_DHT_DELAY);
@@ -937,6 +1007,9 @@
if (cost == GNUNET_SYSERR)
continue;
+ GNUNET_bloomfilter_get_raw_data (bloom, &aput->bloomfilter[0],
+ DV_DHT_BLOOM_SIZE);
+
if ((debug_routes_extended) && (dhtlog != NULL))
{
queryuid = ntohl (put->queryuid);
@@ -1039,6 +1112,8 @@
GNUNET_GE_BULK,
"Received REMOTE DV_DHT RESULT for key `%s'.\n", &enc);
#endif
+ if (sender != NULL)
+ GNUNET_DV_DHT_considerPeer (sender);
route_result (&result->key,
ntohl (result->type),
Modified: GNUnet/src/applications/dv_dht/module/table.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.c 2009-07-29 15:09:09 UTC
(rev 8810)
+++ GNUnet/src/applications/dv_dht/module/table.c 2009-07-29 20:25:21 UTC
(rev 8811)
@@ -383,7 +383,7 @@
will appropriately tell us whether one loc is closer than
another. I also don't get why we want 2^(d/512)!! Say we
should be in bucket 5 (5 matching bits), then we get 1
- as a retrun value, just as if we have 15 matching bits!!!
+ as a return value, just as if we have 15 matching bits!!!
15 matching should be closer than 5!!!!!!! */
d = exp2 (bucket);
if (d > ((unsigned int) -1))
@@ -832,12 +832,12 @@
}
}
+
/**
* Consider adding the given peer to the DV_DHT.
*/
-static void
-considerPeer (const GNUNET_PeerIdentity * sender,
- const GNUNET_PeerIdentity * peer)
+void
+GNUNET_DV_DHT_considerPeer (const GNUNET_PeerIdentity * peer)
{
PeerInfo *pi;
PeerBucket *bucket;
@@ -855,28 +855,7 @@
}
/* do we know how to contact this peer? */
/* This may not work with the dv implementation... */
-#if 0
- P2P_DV_DHT_ASK_HELLO ask;
- GNUNET_MessageHello *hello;
- hello =
- identity->identity2Hello (peer, GNUNET_TRANSPORT_PROTOCOL_NUMBER_ANY,
- GNUNET_NO);
- if (hello == NULL)
- {
- /* if identity not known, ask sender for HELLO of other peer */
- ask.header.size = htons (sizeof (P2P_DV_DHT_ASK_HELLO));
- ask.header.type = htons (sizeof (GNUNET_P2P_PROTO_DHT_ASK_HELLO));
- ask.reserved = 0;
- ask.peer = *peer;
- dvapi->dv_send (peer, &ask.header, 0, /* FIXME: priority */
- 5 * GNUNET_CRON_SECONDS);
- return;
- }
-
- GNUNET_free (hello);
-#endif
-
/* check if connected, if not, send discovery */
/* coreAPI->p2p_connection_status_check (peer, NULL, NULL); */
if (GNUNET_OK != dvapi->p2p_connection_status_check (peer, NULL, NULL))
@@ -888,6 +867,7 @@
return;
}
/* we are connected (in dv), add to bucket */
+ GNUNET_mutex_lock (lock);
pi = GNUNET_malloc (sizeof (PeerInfo));
memset (pi, 0, sizeof (PeerInfo));
pi->id = *peer;
@@ -898,6 +878,7 @@
total_peers++;
if (stats != NULL)
stats->change (stat_dht_total_peers, 1);
+ GNUNET_mutex_unlock (lock);
}
static void
@@ -907,7 +888,7 @@
print_entry ("broadcast_dht_discovery_prob");
#endif
- considerPeer (other, other);
+ GNUNET_DV_DHT_considerPeer (other);
#if DEBUG_TABLE
print_exit ("broadcast_dht_discovery_prob");
@@ -931,52 +912,7 @@
#endif
}
-#ifdef DISCOVERY
/**
- * Handle discovery message.
- */
-static int
-handleDiscovery (const GNUNET_PeerIdentity * sender,
- const GNUNET_MessageHeader * msg)
-{
- unsigned int pc;
- unsigned int i;
- const P2P_DV_DHT_Discovery *disco;
- const GNUNET_PeerIdentity *peers;
-
- pc =
- (ntohs (msg->size) -
- sizeof (P2P_DV_DHT_Discovery)) / sizeof (GNUNET_PeerIdentity);
- if (pc > MAINTAIN_ADV_CAP * 8)
- {
- GNUNET_GE_BREAK_OP (coreAPI->ectx, 0);
- return GNUNET_SYSERR; /* far too big */
- }
- if (ntohs (msg->size) !=
- sizeof (P2P_DV_DHT_Discovery) + pc * sizeof (GNUNET_PeerIdentity))
- {
- GNUNET_GE_BREAK_OP (coreAPI->ectx, 0);
- return GNUNET_SYSERR; /* malformed */
- }
- disco = (const P2P_DV_DHT_Discovery *) msg;
- if (stats != NULL)
- stats->change (stat_dht_discoveries, 1);
- if (pc == 0)
- {
- /* if peer has 0 connections, be sure to send discovery back */
- broadcast_dht_discovery (sender, NULL);
- }
- GNUNET_mutex_lock (lock);
- considerPeer (sender, sender);
- peers = (const GNUNET_PeerIdentity *) &disco[1];
- for (i = 0; i < pc; i++)
- considerPeer (sender, &peers[i]);
- GNUNET_mutex_unlock (lock);
- return GNUNET_OK;
-}
-#endif
-
-/**
* Handle ask hello message.
*/
static int
Modified: GNUnet/src/applications/dv_dht/module/table.h
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.h 2009-07-29 15:09:09 UTC
(rev 8810)
+++ GNUnet/src/applications/dv_dht/module/table.h 2009-07-29 20:25:21 UTC
(rev 8811)
@@ -79,4 +79,9 @@
*/
int GNUNET_DV_DHT_am_closest_peer (const GNUNET_HashCode * target);
+/*
+ * Consider adding the peer to table
+ */
+void GNUNET_DV_DHT_consider_peer (const GNUNET_PeerIdentity * peer);
+
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8811 - GNUnet/src/applications/dv_dht/module,
gnunet <=