GNUnet 0.22.2
gnunet-nse.c File Reference

Program to display network size estimates from the NSE service. More...

#include "platform.h"
#include "gnunet_nse_service.h"
#include <gnunet_util_lib.h>
Include dependency graph for gnunet-nse.c:

Go to the source code of this file.

Functions

static void do_shutdown (void *cls)
 Task to shutdown and clean up all state. More...
 
static void handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev)
 Callback to call when network size estimate is updated. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Actual main function that runs the emulation. More...
 
int main (int argc, char *const *argv)
 Main function. More...
 

Variables

static struct GNUNET_NSE_Handlense
 The handle to the NSE service. More...
 
static int status
 The program status; 0 for success. More...
 
static int monitor
 Monitor flag. More...
 

Detailed Description

Program to display network size estimates from the NSE service.

Author
Sree Harsha Totakura sreeh.nosp@m.arsh.nosp@m.a@tot.nosp@m.akur.nosp@m.a.in

Definition in file gnunet-nse.c.

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Task to shutdown and clean up all state.

Parameters
clsNULL

Definition at line 53 of file gnunet-nse.c.

54{
55 (void) cls;
56 if (NULL != nse)
57 {
59 nse = NULL;
60 }
61}
static struct GNUNET_NSE_Handle * nse
The handle to the NSE service.
Definition: gnunet-nse.c:34
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
Definition: nse_api.c:192

References GNUNET_NSE_disconnect(), and nse.

Referenced by run().

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

◆ handle_estimate()

static void handle_estimate ( void *  cls,
struct GNUNET_TIME_Absolute  timestamp,
double  estimate,
double  std_dev 
)
static

Callback to call when network size estimate is updated.

Parameters
clsNULL
timestampserver timestamp
estimatethe value of the current network size estimate
std_devstandard deviation (rounded down to nearest integer) of the size estimation values seen

Definition at line 74 of file gnunet-nse.c.

78{
79 (void) cls;
80 status = 0;
81 fprintf (stdout,
82 "%s: #peers=%f (ld(#peers)=%f, stddev=%f)\n",
85 estimate,
86 std_dev);
87 if (! monitor)
89}
static uint64_t timestamp(void)
Get current timestamp.
static int monitor
Monitor flag.
Definition: gnunet-nse.c:44
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:39
#define GNUNET_NSE_log_estimate_to_n(loge)
Convert the logarithmic estimated returned to the 'GNUNET_NSE_Callback' into an absolute estimate in ...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:640

References GNUNET_NSE_log_estimate_to_n, GNUNET_SCHEDULER_shutdown(), GNUNET_STRINGS_absolute_time_to_string(), monitor, status, and timestamp().

Referenced by run().

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

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Actual main function that runs the emulation.

Parameters
clsunused
argsremaining args, unused
cfgfilename of the configuration
cfgconfiguration handle

Definition at line 101 of file gnunet-nse.c.

105{
106 (void) cls;
107 (void) args;
108 (void) cfgfile;
111}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static void do_shutdown(void *cls)
Task to shutdown and clean up all state.
Definition: gnunet-nse.c:53
static void handle_estimate(void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev)
Callback to call when network size estimate is updated.
Definition: gnunet-nse.c:74
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:164
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1339

References consensus-simulation::args, cfg, do_shutdown(), GNUNET_NSE_connect(), GNUNET_SCHEDULER_add_shutdown(), handle_estimate(), and nse.

Referenced by main().

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

◆ main()

int main ( int  argc,
char *const *  argv 
)

Main function.

Returns
0 on success

Definition at line 120 of file gnunet-nse.c.

121{
124 "monitor",
126 "Monitor and output current estimates"),
127 &monitor),
129 };
130
131 status = 1;
132 if (GNUNET_OK !=
134 argc,
135 argv,
136 "gnunet-nse",
138 "Show network size estimates from NSE service."),
139 options,
140 &run,
141 NULL))
142 return 2;
143 return status;
144}
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:74
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Actual main function that runs the emulation.
Definition: gnunet-nse.c:101
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
@ GNUNET_OK
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:407
Definition of a command line option.

References gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), monitor, options, run(), and status.

Here is the call graph for this function:

Variable Documentation

◆ nse

struct GNUNET_NSE_Handle* nse
static

The handle to the NSE service.

Definition at line 34 of file gnunet-nse.c.

Referenced by DHTU_ip_init(), do_shutdown(), and run().

◆ status

◆ monitor

int monitor
static

Monitor flag.

Definition at line 44 of file gnunet-nse.c.

Referenced by handle_estimate(), and main().