gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r4118 - GNUnet/src/applications/dht/module


From: grothoff
Subject: [GNUnet-SVN] r4118 - GNUnet/src/applications/dht/module
Date: Fri, 29 Dec 2006 21:38:48 -0800 (PST)

Author: grothoff
Date: 2006-12-29 21:38:46 -0800 (Fri, 29 Dec 2006)
New Revision: 4118

Modified:
   GNUnet/src/applications/dht/module/routing.c
   GNUnet/src/applications/dht/module/table.c
Log:
more stats and more aggressive discovery with few peers, less with more peers

Modified: GNUnet/src/applications/dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dht/module/routing.c        2006-12-30 05:27:53 UTC 
(rev 4117)
+++ GNUnet/src/applications/dht/module/routing.c        2006-12-30 05:38:46 UTC 
(rev 4118)
@@ -189,6 +189,8 @@
 
 static unsigned int stat_replies_routed;
 
+static unsigned int stat_results_received;
+
 static unsigned int stat_requests_routed;
 
 static unsigned int stat_get_requests_received;
@@ -355,14 +357,25 @@
   int total;
   int routed;
   int i;
+#if DEBUG_ROUTING
+  EncName enc;
+#endif
 
   if (ntohs(msg->size) != sizeof(DHT_GET_MESSAGE)) {
     GE_BREAK(NULL, 0);
     return SYSERR;
   }
+#if DEBUG_ROUTING
+  hash2enc(&get->key, &enc);
+  GE_LOG(coreAPI->ectx,
+        GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+        "Received DHT GET for key `%s'.\n",
+        &enc);
+#endif
   if (stats != NULL)
     stats->change(stat_get_requests_received, 1);
   get = (const DHT_GET_MESSAGE*) msg;
+  
   total = dht_store_get(&get->key,
                        ntohl(get->type),
                        &routeResult,
@@ -421,6 +434,9 @@
   cron_t now;
   int store;
   int i;
+#if DEBUG_ROUTING
+  EncName enc;
+#endif
 
   if (ntohs(msg->size) < sizeof(DHT_PUT_MESSAGE)) {
     GE_BREAK(NULL, 0);
@@ -429,6 +445,13 @@
   if (stats != NULL)
     stats->change(stat_put_requests_received, 1);
   put = (const DHT_PUT_MESSAGE*) msg;
+#if DEBUG_ROUTING
+  hash2enc(&put->key, &enc);
+  GE_LOG(coreAPI->ectx,
+        GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+        "Received DHT PUT for key `%s'.\n",
+        &enc);
+#endif
   store = 0;
   for (i=0;i<PUT_TRIES;i++) {
     if (OK != select_dht_peer(&next[i],
@@ -482,12 +505,24 @@
 static int handleResult(const PeerIdentity * sender,
                        const MESSAGE_HEADER * msg) {
   const DHT_RESULT_MESSAGE * result;
+#if DEBUG_ROUTING
+  EncName enc;
+#endif
 
   if (ntohs(msg->size) < sizeof(DHT_RESULT_MESSAGE)) {
     GE_BREAK(NULL, 0);
     return SYSERR;
   }
+  if (stats != NULL)
+    stats->change(stat_results_received, 1);
   result = (const DHT_RESULT_MESSAGE*) msg;
+#if DEBUG_ROUTING
+  hash2enc(&result->key, &enc);
+  GE_LOG(coreAPI->ectx,
+        GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+        "Received DHT RESULT for key `%s'.\n",
+        &enc);
+#endif
   routeResult(&result->key,
              ntohl(result->type),
              ntohs(result->header.size) - sizeof(DHT_RESULT_MESSAGE),
@@ -595,6 +630,7 @@
     stat_requests_routed = stats->create(gettext_noop("# dht requests 
routed"));
     stat_get_requests_received = stats->create(gettext_noop("# dht get 
requests received"));
     stat_put_requests_received = stats->create(gettext_noop("# dht put 
requests received"));
+    stat_results_received = stats->create(gettext_noop("# dht results 
received"));
   }
   GE_LOG(coreAPI->ectx,
         GE_DEBUG | GE_REQUEST | GE_USER,

Modified: GNUnet/src/applications/dht/module/table.c
===================================================================
--- GNUnet/src/applications/dht/module/table.c  2006-12-30 05:27:53 UTC (rev 
4117)
+++ GNUnet/src/applications/dht/module/table.c  2006-12-30 05:38:46 UTC (rev 
4118)
@@ -63,7 +63,7 @@
  * What is the chance (1 in XXX) that we send DISCOVERY messages
  * to another peer?
  */
-#define MAINTAIN_CHANCE 100
+#define MAINTAIN_CHANCE (10 + 100 * total_peers)
 
 /**
  * How long can a peer be inactive before we tiem it out?
@@ -191,6 +191,8 @@
 
 static int stat_dht_route_looks;
 
+static int stat_dht_advertisements;
+
 /**
  * The struct is followed by zero or more
  * PeerIdentities that the sender knows to
@@ -405,6 +407,8 @@
   unsigned int i;
   PeerIdentity * pos;
 
+  if (stats != NULL)
+    stats->change(stat_dht_advertisements, 1);
   if (disco != NULL) {
     coreAPI->unicast(other,
                     &disco->header,
@@ -696,6 +700,7 @@
     stat_dht_total_peers = stats->create(gettext_noop("# dht connections"));
     stat_dht_discoveries = stats->create(gettext_noop("# dht discovery 
messages received"));
     stat_dht_route_looks = stats->create(gettext_noop("# dht route host 
lookups performed"));
+    stat_dht_advertisements = stats->create(gettext_noop("# dht discovery 
messages sent"));
   }
   identity = coreAPI->requestService("identity");
   GE_ASSERT(coreAPI->ectx, identity != NULL);





reply via email to

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