gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12693 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r12693 - gnunet/src/dht
Date: Fri, 20 Aug 2010 17:35:46 +0200

Author: nevans
Date: 2010-08-20 17:35:45 +0200 (Fri, 20 Aug 2010)
New Revision: 12693

Modified:
   gnunet/src/dht/dht.h
   gnunet/src/dht/gnunet-service-dht.c
   gnunet/src/dht/plugin_dhtlog_mysql_dump.c
Log:
minor dht alterations

Modified: gnunet/src/dht/dht.h
===================================================================
--- gnunet/src/dht/dht.h        2010-08-20 14:03:17 UTC (rev 12692)
+++ gnunet/src/dht/dht.h        2010-08-20 15:35:45 UTC (rev 12693)
@@ -57,6 +57,7 @@
 #define STAT_FIND_PEER_REPLY "# DHT FIND_PEER Responses Received"
 #define STAT_GET_REPLY "# DHT GET Responses Received"
 #define STAT_FIND_PEER_ANSWER "# DHT FIND_PEER Responses Initiated"
+#define STAT_BLOOM_FIND_PEER "# DHT FIND_PEER Responses Ignored (bloom match)"
 #define STAT_GET_RESPONSE_START "# DHT GET Responses Initiated"
 #define STAT_HELLOS_PROVIDED "# HELLO Messages given to transport"
 #define STAT_DISCONNECTS "# Disconnects received"
@@ -347,6 +348,24 @@
 };
 
 /**
+ * Generic DHT message, indicates that a route request
+ * should be issued, if coming from a client.  Shared
+ * usage for api->server and P2P message passing.
+ */
+struct GNUNET_DHT_FindPeerMessage
+{
+  /**
+   * Type: GNUNET_MESSAGE_TYPE_DHT_FIND_PEER
+   */
+  struct GNUNET_MessageHeader header;
+
+  /*
+   * Bloomfilter to reduce find peer responses
+   */
+  char bloomfilter[DHT_BLOOM_SIZE];
+};
+
+/**
  * Message to return data either to the client API
  * or to respond to a request received from another
  * peer.  Shared format, different types.

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-08-20 14:03:17 UTC (rev 12692)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-08-20 15:35:45 UTC (rev 12693)
@@ -1934,10 +1934,12 @@
                       struct DHT_MessageContext *message_context)
 {
   struct GNUNET_MessageHeader *find_peer_result;
+  struct GNUNET_DHT_FindPeerMessage *find_peer_message;
   struct DHT_MessageContext *new_msg_ctx;
+  struct GNUNET_CONTAINER_BloomFilter *incoming_bloom;
   size_t hello_size;
   size_t tsize;
-
+  find_peer_message = (struct GNUNET_DHT_FindPeerMessage *)find_msg;
 #if DEBUG_DHT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "`%s:%s': Received `%s' request from client, key %s (msg size 
%d, we expected %d)\n",
@@ -1955,10 +1957,15 @@
     return;
   }
 
+  incoming_bloom = 
GNUNET_CONTAINER_bloomfilter_init(find_peer_message->bloomfilter, 
DHT_BLOOM_SIZE, DHT_BLOOM_K);
+  if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(incoming_bloom, 
&my_identity.hashPubKey))
+    {
+      increment_stats(STAT_BLOOM_FIND_PEER);
+      GNUNET_CONTAINER_bloomfilter_free(incoming_bloom);
+      return; /* We match the bloomfilter, do not send a response to this peer 
(they likely already know us!)*/
+    }
+  GNUNET_CONTAINER_bloomfilter_free(incoming_bloom);
 
-  if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(message_context->bloom, 
&my_identity.hashPubKey))
-    return; /* We match the bloomfilter, do not send a response to this peer 
(they likely already know us!)*/
-
   /* Simplistic find_peer functionality, always return our hello */
   hello_size = ntohs(my_hello->size);
   tsize = hello_size + sizeof (struct GNUNET_MessageHeader);
@@ -1996,7 +2003,6 @@
                                    message_context->key);
     }
 #endif
-  //send_reply_to_client(message_context->client, find_peer_result, 
message_context->unique_id);
   GNUNET_free(find_peer_result);
 }
 
@@ -2269,8 +2275,7 @@
           count = 0;
           while ((pos != NULL) && (count < bucket_size))
             {
-            /* If we are doing strict Kademlia like routing, then checking the 
bloomfilter is basically cheating! */
-
+              /* If we are doing strict Kademlia like routing, then checking 
the bloomfilter is basically cheating! */
               if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (bloom, 
&pos->id.hashPubKey))
                 {
                   distance = inverse_distance (target, &pos->id.hashPubKey);
@@ -2462,7 +2467,9 @@
  * Main function that handles whether or not to route a message to other
  * peers.
  *
+ * @param cls closure for dht service (NULL)
  * @param msg the message to be routed
+ * @param message_context the context containing all pertinent information 
about the message
  *
  * @return the number of peers the message was routed to,
  *         GNUNET_SYSERR on failure
@@ -2505,7 +2512,6 @@
 
   if (message_context->bloom == NULL)
     message_context->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, 
DHT_BLOOM_SIZE, DHT_BLOOM_K);
-  GNUNET_CONTAINER_bloomfilter_add (message_context->bloom, 
&my_identity.hashPubKey);
 
   if ((stop_on_closest == GNUNET_YES) && (message_context->closest == 
GNUNET_YES) && (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT))
 /*      || ((strict_kademlia == GNUNET_YES) && (message_context->closest == 
GNUNET_YES))) */
@@ -2562,6 +2568,8 @@
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "`%s': Message type (%d) not handled\n", "DHT", 
ntohs(msg->type));
     }
+
+  GNUNET_CONTAINER_bloomfilter_add (message_context->bloom, 
&my_identity.hashPubKey);
 #if 0
   if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(recent->hashmap, 
message_context->key))
     {
@@ -2589,6 +2597,7 @@
       remove_oldest_recent();
     }
 #endif
+
   for (i = 0; i < forward_count; i++)
     {
       selected = select_peer(message_context->key, message_context->bloom);
@@ -2783,19 +2792,23 @@
 static void
 send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc)
 {
-  struct GNUNET_MessageHeader *find_peer_msg;
+  struct GNUNET_DHT_FindPeerMessage *find_peer_msg;
   struct DHT_MessageContext message_context;
   int ret;
   struct GNUNET_TIME_Relative next_send_time;
+  struct GNUNET_CONTAINER_BloomFilter *temp_bloom;
 
   if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
     return;
 
   increment_stats(STAT_FIND_PEER_START);
 
-  find_peer_msg = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
-  find_peer_msg->size = htons(sizeof(struct GNUNET_MessageHeader));
-  find_peer_msg->type = htons(GNUNET_MESSAGE_TYPE_DHT_FIND_PEER);
+  find_peer_msg = GNUNET_malloc(sizeof(struct GNUNET_DHT_FindPeerMessage));
+  find_peer_msg->header.size = htons(sizeof(struct 
GNUNET_DHT_FindPeerMessage));
+  find_peer_msg->header.type = htons(GNUNET_MESSAGE_TYPE_DHT_FIND_PEER);
+  temp_bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, 
DHT_BLOOM_K);
+  GNUNET_CONTAINER_multihashmap_iterate(all_known_peers, &add_known_to_bloom, 
temp_bloom);
+  GNUNET_assert(GNUNET_OK == 
GNUNET_CONTAINER_bloomfilter_get_raw_data(temp_bloom, 
find_peer_msg->bloomfilter, DHT_BLOOM_SIZE));
   memset(&message_context, 0, sizeof(struct DHT_MessageContext));
   message_context.key = &my_identity.hashPubKey;
   message_context.unique_id = GNUNET_ntohll 
(GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, (uint64_t)-1));
@@ -2806,11 +2819,7 @@
   message_context.importance = DHT_DEFAULT_FIND_PEER_IMPORTANCE;
   message_context.timeout = DHT_DEFAULT_FIND_PEER_TIMEOUT;
 
-  message_context.bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, 
DHT_BLOOM_SIZE, DHT_BLOOM_K);
-  GNUNET_CONTAINER_multihashmap_iterate(all_known_peers, &add_known_to_bloom, 
message_context.bloom);
-  /*GNUNET_CONTAINER_bloomfilter_add (message_context->bloom, 
&my_identity.hashPubKey);*/
-
-  ret = route_message(NULL, find_peer_msg, &message_context);
+  ret = route_message(NULL, &find_peer_msg->header, &message_context);
   GNUNET_free(find_peer_msg);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "`%s:%s': Sent `%s' request to %d peers\n", my_short_id, "DHT",
@@ -3021,7 +3030,6 @@
       GNUNET_break_op(0);
       return GNUNET_YES;
     }
-  //memset(&message_context, 0, sizeof(struct DHT_MessageContext));
   message_context = GNUNET_malloc(sizeof (struct DHT_MessageContext));
   message_context->bloom = 
GNUNET_CONTAINER_bloomfilter_init(incoming->bloomfilter, DHT_BLOOM_SIZE, 
DHT_BLOOM_K);
   GNUNET_assert(message_context->bloom != NULL);
@@ -3418,6 +3426,7 @@
     {
       GNUNET_STATISTICS_set(stats, STAT_ROUTES, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_ROUTE_FORWARDS, 0, GNUNET_NO);
+      GNUNET_STATISTICS_set(stats, STAT_ROUTE_FORWARDS_CLOSEST, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_RESULTS, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_RESULTS_TO_CLIENT, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_RESULT_FORWARDS, 0, GNUNET_NO);
@@ -3430,8 +3439,11 @@
       GNUNET_STATISTICS_set(stats, STAT_PUT_START, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_FIND_PEER_REPLY, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_FIND_PEER_ANSWER, 0, GNUNET_NO);
+      GNUNET_STATISTICS_set(stats, STAT_BLOOM_FIND_PEER, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_GET_REPLY, 0, GNUNET_NO);
       GNUNET_STATISTICS_set(stats, STAT_GET_RESPONSE_START, 0, GNUNET_NO);
+      GNUNET_STATISTICS_set(stats, STAT_HELLOS_PROVIDED, 0, GNUNET_NO);
+      GNUNET_STATISTICS_set(stats, STAT_DISCONNECTS, 0, GNUNET_NO);
     }
 #if DO_FIND_PEER
   next_send_time.value = DHT_MINIMUM_FIND_PEER_INTERVAL.value +

Modified: gnunet/src/dht/plugin_dhtlog_mysql_dump.c
===================================================================
--- gnunet/src/dht/plugin_dhtlog_mysql_dump.c   2010-08-20 14:03:17 UTC (rev 
12692)
+++ gnunet/src/dht/plugin_dhtlog_mysql_dump.c   2010-08-20 15:35:45 UTC (rev 
12693)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file src/dht/plugin_dhtlog_mysql.c
+ * @file src/dht/plugin_dhtlog_mysql_dump.c
  * @brief MySQL logging plugin to record DHT operations to MySQL server,
  *        but write all queries to file instead of the actual server
  *        so that they can be imported later.  The idea is that connecting




reply via email to

[Prev in Thread] Current Thread [Next in Thread]