fix correction according to paper, minimum NSE should be our neighour set
authorChristian Grothoff <christian@grothoff.org>
Wed, 5 Oct 2011 19:55:20 +0000 (19:55 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 5 Oct 2011 19:55:20 +0000 (19:55 +0000)
src/nse/gnunet-service-nse.c
src/nse/nse_api.c

index e70d6c29e82e3a0bc9992749f5a6fd3da71f2ce8..bc46a537cdd3b2f5b614740c3b4dd07f4c433d75 100644 (file)
@@ -308,6 +308,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em)
   double q;
   double r;
   double temp;
+  double nsize;
 
   /* Weighted incremental algorithm for stddev according to West (1979) */
   mean = 0.0;
@@ -333,12 +334,15 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em)
   std_dev = sqrt (variance);
   current_std_dev = std_dev;
   current_size_estimate = mean;
-
+  
   em->header.size = htons (sizeof (struct GNUNET_NSE_ClientMessage));
   em->header.type = htons (GNUNET_MESSAGE_TYPE_NSE_ESTIMATE);
   em->reserved = htonl (0);
   em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
-  em->size_estimate = mean - 1.0 / 3.0;
+  em->size_estimate = mean - 0.332747;
+  nsize = log2 (GNUNET_CONTAINER_multihashmap_size (peers) + 1);
+  if (em->size_estimate < nsize)
+    em->size_estimate = nsize;
   em->std_deviation = std_dev;
   GNUNET_STATISTICS_set (stats, "# nodes in the network (estimate)",
                          (uint64_t) pow (2, mean - 1.0 / 3.0), GNUNET_NO);
index 0eb165fe5c883667d45a2b80f039bbce0d5fe8e8..476c77c2a0b59b2d312d298798a0454ad1302d37 100644 (file)
@@ -119,7 +119,8 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
   }
   client_msg = (const struct GNUNET_NSE_ClientMessage *) msg;
   h->recv_cb (h->recv_cb_cls, GNUNET_TIME_absolute_ntoh (client_msg->timestamp),
-              client_msg->size_estimate, client_msg->std_deviation);
+              client_msg->size_estimate,
+             client_msg->std_deviation);
   GNUNET_CLIENT_receive (h->client, &message_handler, h,
                          GNUNET_TIME_UNIT_FOREVER_REL);
 }