2 This file is part of GNUnet
3 Copyright (C) 2008--2014, 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file nse/gnunet-nse.c
23 * @brief Program to display network size estimates from the NSE service
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
28 #include "gnunet_nse_service.h"
31 * The handle to the NSE service
33 static struct GNUNET_NSE_Handle *nse;
36 * The program status; 0 for success.
42 * Task to shutdown and clean up all state
47 do_shutdown (void *cls)
52 GNUNET_NSE_disconnect (nse);
59 * Callback to call when network size estimate is updated.
62 * @param timestamp server timestamp
63 * @param estimate the value of the current network size estimate
64 * @param std_dev standard deviation (rounded down to nearest integer)
65 * of the size estimation values seen
68 handle_estimate (void *cls,
69 struct GNUNET_TIME_Absolute timestamp,
77 (unsigned long long) timestamp.abs_value_us,
78 GNUNET_NSE_log_estimate_to_n (estimate),
85 * Actual main function that runs the emulation.
88 * @param args remaining args, unused
89 * @param cfgfile name of the configuration
90 * @param cfg configuration handle
96 const struct GNUNET_CONFIGURATION_Handle *cfg)
101 nse = GNUNET_NSE_connect (cfg, &handle_estimate, NULL);
102 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
109 * @return 0 on success
112 main (int argc, char *const *argv)
114 static struct GNUNET_GETOPT_CommandLineOption options[] = {
115 GNUNET_GETOPT_OPTION_END
120 GNUNET_PROGRAM_run (argc,
124 "Show network size estimates from NSE service."),