2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file dht/gnunet-service-dht_nse.c
23 * @brief GNUnet DHT integration with NSE
24 * @author Christian Grothoff
27 #include "gnunet_nse_service.h"
28 #include "gnunet-service-dht.h"
29 #include "gnunet-service-dht_nse.h"
32 * log of the current network size estimate, used as the point where
33 * we switch between random and deterministic routing. Default
34 * value of 4.0 is used if NSE module is not available (i.e. not
37 static double log_of_network_size_estimate = 4.0;
40 * Network size estimation handle.
42 static struct GNUNET_NSE_Handle *nse;
46 * Callback that is called when network size estimate is updated.
49 * @param timestamp time when the estimate was received from the server (or created by the server)
50 * @param logestimate the log(Base 2) value of the current network size estimate
51 * @param std_dev standard deviation for the estimate
55 update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp,
56 double logestimate, double std_dev)
58 GNUNET_STATISTICS_update (GDS_stats,
59 gettext_noop ("# Network size estimates received"),
61 /* do not allow estimates < 0.5 */
62 log_of_network_size_estimate = GNUNET_MAX (0.5, logestimate);
67 * Return the log of the current network size estimate.
74 return log_of_network_size_estimate;
79 * Initialize NSE subsystem.
84 nse = GNUNET_NSE_connect (GDS_cfg, &update_network_size_estimate, NULL);
89 * Shutdown NSE subsystem.
96 GNUNET_NSE_disconnect (nse);
101 /* end of gnunet-service-dht_nse.c */