/*
This file is part of GNUnet.
(C) 2009, 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file nse/gnunet-service-nse.c
* @brief network size estimation service
* @author Nathan Evans
* @author Christian Grothoff
*
* The purpose of this service is to estimate the size of the network.
* Given a specified interval, each peer hashes the most recent
* timestamp which is evenly divisible by that interval. This hash is
* compared in distance to the peer identity to choose an offset. The
* closer the peer identity to the hashed timestamp, the earlier the
* peer sends out a "nearest peer" message. The closest peer's
* message should thus be received before any others, which stops
* those peer from sending their messages at a later duration. So
* every peer should receive the same nearest peer message, and from
* this can calculate the expected number of peers in the network.
*/
#include "platform.h"
#include <math.h>
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_statistics_service.h"
#include "gnunet_core_service.h"
#include "gnunet_nse_service.h"
#include "nse.h"
/**
* Should messages be delayed randomly? This option should be set to
* GNUNET_NO only for experiments, not in production. It should also
* be removed once the initial experiments have been completed.
*/
#define USE_RANDOM_DELAYS GNUNET_YES
/**
* Should we generate a histogram with the time stamps of when w