GNUnet 0.22.2
NSE service

Network Size Estimation. More...

Collaboration diagram for NSE service:

Macros

#define GNUNET_NSE_VERSION   0x00000000
 Version of the network size estimation API. More...
 
#define GNUNET_NSE_log_estimate_to_n(loge)   pow (2.0, (loge))
 Convert the logarithmic estimated returned to the 'GNUNET_NSE_Callback' into an absolute estimate in terms of the number of peers in the network. More...
 

Typedefs

typedef void(* GNUNET_NSE_Callback) (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
 Callback to call when network size estimate is updated. More...
 

Functions

struct GNUNET_NSE_HandleGNUNET_NSE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_Callback func, void *func_cls)
 Connect to the network size estimation service. More...
 
void GNUNET_NSE_disconnect (struct GNUNET_NSE_Handle *h)
 Disconnect from network size estimation service. More...
 

Detailed Description

Network Size Estimation.

Provides an API to retrieve the current network size estimate, also to register for notifications whenever a new network size estimate is calculated.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_NSE_VERSION

#define GNUNET_NSE_VERSION   0x00000000

Version of the network size estimation API.

Definition at line 59 of file gnunet_nse_service.h.

◆ GNUNET_NSE_log_estimate_to_n

#define GNUNET_NSE_log_estimate_to_n (   loge)    pow (2.0, (loge))

Convert the logarithmic estimated returned to the 'GNUNET_NSE_Callback' into an absolute estimate in terms of the number of peers in the network.

Parameters
logelogarithmic estimate
Returns
absolute number of peers in the network (estimated)

Definition at line 88 of file gnunet_nse_service.h.

Typedef Documentation

◆ GNUNET_NSE_Callback

typedef void(* GNUNET_NSE_Callback) (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)

Callback to call 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 74 of file gnunet_nse_service.h.

Function Documentation

◆ GNUNET_NSE_connect()

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.

Parameters
cfgthe configuration to use
funcfunction to call with network size estimate
func_clsclosure to pass to func
Returns
handle to use in GNUNET_NSE_disconnect to stop NSE from invoking the callbacks
Parameters
cfgthe configuration to use
funcfunction to call with network size estimate
func_clsclosure to pass to func
Returns
handle to use

Definition at line 164 of file nse_api.c.

167{
168 struct GNUNET_NSE_Handle *h;
169
170 GNUNET_assert (NULL != func);
171 h = GNUNET_new (struct GNUNET_NSE_Handle);
172 h->cfg = cfg;
173 h->recv_cb = func;
174 h->recv_cb_cls = func_cls;
175 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
176 reconnect (h);
177 if (NULL == h->mq)
178 {
179 GNUNET_free (h);
180 return NULL;
181 }
182 return h;
183}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
static void reconnect(void *cls)
Try again to connect to network size estimation service.
Definition: nse_api.c:131
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Handle for talking with the NSE service.
Definition: nse_api.c:40

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_assert, GNUNET_free, GNUNET_new, GNUNET_TIME_UNIT_ZERO, h, GNUNET_ARM_Handle::mq, and reconnect().

Referenced by DHTU_gnunet_init(), reconnect(), and run().

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

◆ GNUNET_NSE_disconnect()

void GNUNET_NSE_disconnect ( struct GNUNET_NSE_Handle h)

Disconnect from network size estimation service.

Parameters
hhandle to destroy

Definition at line 192 of file nse_api.c.

193{
194 if (NULL != h->reconnect_task)
195 {
197 h->reconnect_task = NULL;
198 }
199 if (NULL != h->mq)
200 {
202 h->mq = NULL;
203 }
204 GNUNET_free (h);
205}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), h, GNUNET_ARM_Handle::mq, and GNUNET_ARM_Handle::reconnect_task.

Referenced by DHTU_gnunet_done(), do_shutdown(), GNUNET_RPS_disconnect(), reconnect(), and shutdown_task().

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