GNUnet  0.11.x
Functions | Variables
gnunet-service-dht_nse.c File Reference

GNUnet DHT integration with NSE. More...

#include "platform.h"
#include "gnunet_nse_service.h"
#include "gnunet-service-dht.h"
#include "gnunet-service-dht_nse.h"
Include dependency graph for gnunet-service-dht_nse.c:

Go to the source code of this file.

Functions

static void update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
 Callback that is called when network size estimate is updated. More...
 
double GDS_NSE_get ()
 Return the log of the current network size estimate. More...
 
void GDS_NSE_init ()
 Initialize NSE subsystem. More...
 
void GDS_NSE_done ()
 Shutdown NSE subsystem. More...
 

Variables

static double log_of_network_size_estimate = 4.0
 log of the current network size estimate, used as the point where we switch between random and deterministic routing. More...
 
static struct GNUNET_NSE_Handlense
 Network size estimation handle. More...
 

Detailed Description

GNUnet DHT integration with NSE.

Author
Christian Grothoff

Definition in file gnunet-service-dht_nse.c.

Function Documentation

◆ update_network_size_estimate()

static void update_network_size_estimate ( void *  cls,
struct GNUNET_TIME_Absolute  timestamp,
double  logestimate,
double  std_dev 
)
static

Callback that is called when network size estimate is updated.

Parameters
clsclosure
timestamptime when the estimate was received from the server (or created by the server)
logestimatethe log(Base 2) value of the current network size estimate
std_devstandard deviation for the estimate

Definition at line 55 of file gnunet-service-dht_nse.c.

57 {
59  gettext_noop ("# Network size estimates received"),
60  1, GNUNET_NO);
61  /* do not allow estimates < 0.5 */
62  log_of_network_size_estimate = GNUNET_MAX (0.5, logestimate);
63 }
#define gettext_noop(String)
Definition: gettext.h:69
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
static double log_of_network_size_estimate
log of the current network size estimate, used as the point where we switch between random and determ...
#define GNUNET_MAX(a, b)
@ GNUNET_NO
Definition: gnunet_common.h:94
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.

References GDS_stats, gettext_noop, GNUNET_MAX, GNUNET_NO, GNUNET_STATISTICS_update(), and log_of_network_size_estimate.

Referenced by GDS_NSE_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_NSE_get()

double GDS_NSE_get ( void  )

Return the log of the current network size estimate.

Returns
log of NSE

Definition at line 72 of file gnunet-service-dht_nse.c.

73 {
75 }

References log_of_network_size_estimate.

Referenced by get_forward_count(), and select_peer().

Here is the caller graph for this function:

◆ GDS_NSE_init()

void GDS_NSE_init ( void  )

Initialize NSE subsystem.

Definition at line 82 of file gnunet-service-dht_nse.c.

83 {
84  unsigned long long hops;
85 
86  if ((GNUNET_YES ==
88  "dht",
89  "FORCE_NSE")) &&
90  (GNUNET_OK ==
92  "dht",
93  "FORCE_NSE",
94  &hops)))
95  {
96  log_of_network_size_estimate = (double) hops;
97  return;
98  }
100 }
const struct GNUNET_CONFIGURATION_Handle * GDS_cfg
Configuration we use.
static struct GNUNET_NSE_Handle * nse
Network size estimation handle.
static void update_network_size_estimate(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
Callback that is called when network size estimate is updated.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
struct GNUNET_NSE_Handle * GNUNET_NSE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_Callback func, void *func_cls)
Connect to the network size estimation service.
Definition: nse_api.c:165

References GDS_cfg, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_have_value(), GNUNET_NSE_connect(), GNUNET_OK, GNUNET_YES, log_of_network_size_estimate, nse, and update_network_size_estimate().

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_NSE_done()

void GDS_NSE_done ( void  )

Shutdown NSE subsystem.

Definition at line 107 of file gnunet-service-dht_nse.c.

108 {
109  if (NULL != nse)
110  {
112  nse = NULL;
113  }
114 }
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
Definition: nse_api.c:193

References GNUNET_NSE_disconnect(), and nse.

Referenced by shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ log_of_network_size_estimate

double log_of_network_size_estimate = 4.0
static

log of the current network size estimate, used as the point where we switch between random and deterministic routing.

Default value of 4.0 is used if NSE module is not available (i.e. not configured).

Definition at line 37 of file gnunet-service-dht_nse.c.

Referenced by GDS_NSE_get(), GDS_NSE_init(), and update_network_size_estimate().

◆ nse

struct GNUNET_NSE_Handle* nse
static

Network size estimation handle.

Definition at line 42 of file gnunet-service-dht_nse.c.

Referenced by GDS_NSE_done(), GDS_NSE_init(), and libgnunet_plugin_dhtu_ip_init().