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.

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

Referenced by GDS_NSE_init().

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 }
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_MAX(a, b)
Definition: gnunet_common.h:82
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 gettext_noop(String)
Definition: gettext.h:69
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.

References log_of_network_size_estimate.

Referenced by get_forward_count(), and select_peer().

73 {
75 }
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...
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.

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

Referenced by run().

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 }
int 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.
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
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int 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.
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.
static struct GNUNET_NSE_Handle * nse
Network size estimation handle.
#define GNUNET_YES
Definition: gnunet_common.h:77
const struct GNUNET_CONFIGURATION_Handle * GDS_cfg
Configuration we use.
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...
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.

References GNUNET_NSE_disconnect().

Referenced by shutdown_task().

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
static struct GNUNET_NSE_Handle * nse
Network size estimation handle.
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.