[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: build: more post-tng unused source clean
From: |
gnunet |
Subject: |
[gnunet] branch master updated: build: more post-tng unused source cleanup |
Date: |
Thu, 28 Dec 2023 14:22:11 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new e3d27ecd2 build: more post-tng unused source cleanup
e3d27ecd2 is described below
commit e3d27ecd2e1a8d6089f523fee1cce04d0a015236
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Thu Dec 28 14:21:53 2023 +0100
build: more post-tng unused source cleanup
---
po/POTFILES.in | 10 -
src/contrib/service/rps/Makefile.am | 18 -
src/contrib/service/rps/gnunet-rps-profiler.c | 3199 --------------------
src/contrib/service/secretsharing/Makefile.am | 13 -
.../secretsharing/gnunet-secretsharing-profiler.c | 662 ----
src/service/cadet/cadet_test_lib.c | 376 ---
src/service/cadet/cadet_test_lib.h | 106 -
src/service/dht/dht_test_lib.c | 202 --
src/service/dht/dht_test_lib.h | 95 -
src/service/dht/test_dht_monitor.c | 439 ---
src/service/dht/test_dht_monitor.conf | 39 -
src/service/dht/test_dht_topo.c | 637 ----
src/service/fs/Makefile.am | 9 -
src/service/fs/fs_test_lib.c | 630 ----
src/service/fs/fs_test_lib.h | 102 -
src/service/fs/fs_test_lib_data.conf | 17 -
src/service/nse/Makefile.am | 14 -
src/service/nse/gnunet-nse-profiler.c | 921 ------
src/service/regex/Makefile.am | 16 -
.../regex/gnunet-regex-simulation-profiler.c | 727 -----
.../regex/regex_simulation_profiler_test.conf | 7 -
21 files changed, 8239 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ed3d397ed..261b50000 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -70,7 +70,6 @@ src/contrib/service/conversation/gnunet_gst_test.c
src/contrib/service/conversation/microphone.c
src/contrib/service/conversation/plugin_gnsrecord_conversation.c
src/contrib/service/conversation/speaker.c
-src/contrib/service/rps/gnunet-rps-profiler.c
src/contrib/service/rps/gnunet-rps.c
src/contrib/service/rps/gnunet-service-rps.c
src/contrib/service/rps/gnunet-service-rps_custommap.c
@@ -87,7 +86,6 @@
src/contrib/service/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
src/contrib/service/scalarproduct/gnunet-service-scalarproduct_alice.c
src/contrib/service/scalarproduct/gnunet-service-scalarproduct_bob.c
src/contrib/service/scalarproduct/scalarproduct_api.c
-src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c
src/contrib/service/secretsharing/gnunet-service-secretsharing.c
src/contrib/service/secretsharing/secretsharing_api.c
src/contrib/service/secretsharing/secretsharing_common.c
@@ -96,7 +94,6 @@ src/contrib/service/set/gnunet-service-set_intersection.c
src/contrib/service/set/gnunet-service-set_union.c
src/contrib/service/set/gnunet-service-set_union_strata_estimator.c
src/contrib/service/set/gnunet-set-ibf-profiler.c
-src/contrib/service/set/gnunet-set-profiler.c
src/contrib/service/set/ibf.c
src/contrib/service/set/ibf_sim.c
src/contrib/service/set/plugin_block_set_test.c
@@ -251,7 +248,6 @@ src/service/cadet/cadet_api_get_path.c
src/service/cadet/cadet_api_helper.c
src/service/cadet/cadet_api_list_peers.c
src/service/cadet/cadet_api_list_tunnels.c
-src/service/cadet/cadet_test_lib.c
src/service/cadet/desirability_table.c
src/service/cadet/gnunet-service-cadet.c
src/service/cadet/gnunet-service-cadet_channel.c
@@ -273,7 +269,6 @@ src/service/datacache/datacache.c
src/service/datastore/datastore_api.c
src/service/datastore/gnunet-service-datastore.c
src/service/dht/dht_api.c
-src/service/dht/dht_test_lib.c
src/service/dht/gnunet-service-dht.c
src/service/dht/gnunet-service-dht_clients.c
src/service/dht/gnunet-service-dht_datacache.c
@@ -305,7 +300,6 @@ src/service/fs/fs_publish_ksk.c
src/service/fs/fs_publish_ublock.c
src/service/fs/fs_search.c
src/service/fs/fs_sharetree.c
-src/service/fs/fs_test_lib.c
src/service/fs/fs_tree.c
src/service/fs/fs_unindex.c
src/service/fs/fs_uri.c
@@ -395,7 +389,6 @@ src/service/nat/gnunet-service-nat_mini.c
src/service/nat/gnunet-service-nat_stun.c
src/service/nat/nat_api.c
src/service/nat/nat_api_stun.c
-src/service/nse/gnunet-nse-profiler.c
src/service/nse/gnunet-service-nse.c
src/service/nse/nse_api.c
src/service/peerstore/gnunet-service-peerstore.c
@@ -412,7 +405,6 @@ src/service/reclaim/reclaim_attribute.c
src/service/reclaim/reclaim_credential.c
src/service/regex/gnunet-daemon-regexprofiler.c
src/service/regex/gnunet-regex-profiler.c
-src/service/regex/gnunet-regex-simulation-profiler.c
src/service/regex/gnunet-service-regex.c
src/service/regex/perf-regex.c
src/service/regex/regex_api_announce.c
@@ -437,12 +429,10 @@ src/service/rest/rest.c
src/service/revocation/gnunet-service-revocation.c
src/service/revocation/revocation_api.c
src/service/seti/gnunet-service-seti.c
-src/service/seti/gnunet-seti-profiler.c
src/service/seti/seti_api.c
src/service/setu/gnunet-service-setu.c
src/service/setu/gnunet-service-setu_strata_estimator.c
src/service/setu/gnunet-setu-ibf-profiler.c
-src/service/setu/gnunet-setu-profiler.c
src/service/setu/ibf.c
src/service/setu/ibf_sim.c
src/service/setu/setu_api.c
diff --git a/src/contrib/service/rps/Makefile.am
b/src/contrib/service/rps/Makefile.am
index 28aa3e050..1a3c9fa3a 100644
--- a/src/contrib/service/rps/Makefile.am
+++ b/src/contrib/service/rps/Makefile.am
@@ -45,10 +45,6 @@ libgnunetrps_la_CFLAGS = $(AM_CFLAGS)
libexec_PROGRAMS = \
gnunet-service-rps
-#noinst_PROGRAMS = \
-# gnunet-rps-profiler
-
-
gnunet_service_rps_SOURCES = \
gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
rps-sampler_common.h rps-sampler_common.c \
@@ -149,19 +145,5 @@ test_service_rps_sampler_elem_LDADD =
$(top_builddir)/src/lib/util/libgnunetutil
#test_rps_malicious_3_SOURCES = $(rps_test_src)
#test_rps_malicious_3_LDADD = $(ld_rps_test_lib)
-#gnunet_rps_profiler_SOURCES = \
-# gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
-# rps-sampler_common.h rps-sampler_common.c \
-# gnunet-service-rps_sampler.h gnunet-service-rps_sampler.c \
-# rps-test_util.h rps-test_util.c \
-# gnunet-rps-profiler.c
-#gnunet_rps_profiler_LDADD = \
-# $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
-# libgnunetrps.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# -lm
-
-
EXTRA_DIST = \
test_rps.conf
diff --git a/src/contrib/service/rps/gnunet-rps-profiler.c
b/src/contrib/service/rps/gnunet-rps-profiler.c
deleted file mode 100644
index df10ad5da..000000000
--- a/src/contrib/service/rps/gnunet-rps-profiler.c
+++ /dev/null
@@ -1,3199 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2009, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file rps/test_rps.c
- * @brief Testcase for the random peer sampling service. Starts
- * a peergroup with a given number of peers, then waits to
- * receive size pushes/pulls from each peer. Expects to wait
- * for one message from each peer.
- */
-#include "platform.h"
-// #include "rps_test_lib.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testbed_service.h"
-
-#include "gnunet_rps_service.h"
-#include "rps-test_util.h"
-#include "gnunet-service-rps_sampler_elem.h"
-
-#include <inttypes.h>
-
-
-#define BIT(n) (1 << (n))
-
-/**
- * How many peers do we start?
- */
-static uint32_t num_peers;
-
-/**
- * @brief number of bits required to represent the largest peer id
- */
-static unsigned bits_needed;
-
-/**
- * How long do we run the test?
- */
-static struct GNUNET_TIME_Relative duration;
-
-/**
- * When do we do a hard shutdown?
- */
-static struct GNUNET_TIME_Relative timeout;
-
-
-// /**
-// * Portion of malicious peers
-// */
-// static double portion = .1;
-
-/**
- * Type of malicious peer to test
- */
-static unsigned int mal_type = 0;
-
-/**
- * Handles to all of the running peers
- */
-static struct GNUNET_TESTBED_Peer **testbed_peers;
-
-enum STAT_TYPE
-{
- STAT_TYPE_ROUNDS, /* 0 */
- STAT_TYPE_BLOCKS, /* 1 */
- STAT_TYPE_BLOCKS_MANY_PUSH, /* 2 */
- STAT_TYPE_BLOCKS_NO_PUSH, /* 3 */
- STAT_TYPE_BLOCKS_NO_PULL, /* 4 */
- STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL, /* 5 */
- STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL, /* 6 */
- STAT_TYPE_ISSUED_PUSH_SEND, /* 7 */
- STAT_TYPE_ISSUED_PUSH_SEND_MH, /* 8 */
- STAT_TYPE_ISSUED_PULL_REQ, /* 9 */
- STAT_TYPE_ISSUED_PULL_REQ_MH, /* 10 */
- STAT_TYPE_ISSUED_PULL_REP, /* 11 */
- STAT_TYPE_SENT_PUSH_SEND, /* 12 */
- STAT_TYPE_SENT_PULL_REQ, /* 13 */
- STAT_TYPE_SENT_PULL_REQ_MH, /* 14 */
- STAT_TYPE_SENT_PULL_REP, /* 15 */
- STAT_TYPE_RECV_PUSH_SEND, /* 16 */
- STAT_TYPE_RECV_PUSH_SEND_MH, /* 17 */
- STAT_TYPE_RECV_PULL_REQ, /* 18 */
- STAT_TYPE_RECV_PULL_REQ_MH, /* 19 */
- STAT_TYPE_RECV_PULL_REP, /* 20 */
- STAT_TYPE_RECV_PULL_REP_MH, /* 21 */
- STAT_TYPE_VIEW_SIZE, /* 22 */
- STAT_TYPE_KNOWN_PEERS, /* 23 */
- STAT_TYPE_VALID_PEERS, /* 24 */
- STAT_TYPE_LEARND_PEERS, /* 25 */
- STAT_TYPE_PENDING_ONLINE_CHECKS, /* 26 */
- STAT_TYPE_UNREQUESTED_PULL_REPLIES, /* 27 */
- STAT_TYPE_PEERS_IN_PUSH_MAP, /* 28 */
- STAT_TYPE_PEERS_IN_PULL_MAP, /* 29 */
- STAT_TYPE_PEERS_IN_VIEW, /* 30 */
- STAT_TYPE_VIEW_SIZE_AIM, /* 31 */
- STAT_TYPE_MAX, /* 32 */
-};
-
-static char*stat_type_strings[] = {
- "# rounds",
- "# rounds blocked",
- "# rounds blocked - too many pushes",
- "# rounds blocked - no pushes",
- "# rounds blocked - no pull replies",
- "# rounds blocked - too many pushes, no pull replies",
- "# rounds blocked - no pushes, no pull replies",
- "# push send issued",
- "# push send issued (multi-hop peer)",
- "# pull request send issued",
- "# pull request send issued (multi-hop peer)",
- "# pull reply send issued",
- "# pushes sent",
- "# pull requests sent",
- "# pull requests sent (multi-hop peer)",
- "# pull replies sent",
- "# push message received",
- "# push message received (multi-hop peer)",
- "# pull request message received",
- "# pull request message received (multi-hop peer)",
- "# pull reply messages received",
- "# pull reply messages received (multi-hop peer)",
- "view size",
- "# known peers",
- "# valid peers",
- "# learnd peers",
- "# pending online checks",
- "# unrequested pull replies",
- "# peers in push map at end of round",
- "# peers in pull map at end of round",
- "# peers in view at end of round",
- "view size aim",
-};
-
-struct STATcls
-{
- struct RPSPeer *rps_peer;
- enum STAT_TYPE stat_type;
-};
-
-
-/**
- * @brief Converts string representation to the corresponding #STAT_TYPE enum.
- *
- * @param stat_str string representation of statistics specifier
- *
- * @return corresponding enum
- */
-enum STAT_TYPE
-stat_str_2_type (const char *stat_str)
-{
- if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL])))
- {
- return STAT_TYPE_BLOCKS_NO_PULL;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
- stat_str,
- strlen (
-
stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL])))
- {
- return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH])))
- {
- return STAT_TYPE_BLOCKS_MANY_PUSH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
- stat_str,
- strlen (
-
stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL])))
- {
- return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH])))
- {
- return STAT_TYPE_BLOCKS_NO_PUSH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_BLOCKS])))
- {
- return STAT_TYPE_BLOCKS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ROUNDS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_ROUNDS])))
- {
- return STAT_TYPE_ROUNDS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND])))
- {
- return STAT_TYPE_ISSUED_PUSH_SEND;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH])))
- {
- return STAT_TYPE_ISSUED_PUSH_SEND_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ],
- stat_str,
- strlen
(stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ])))
- {
- return STAT_TYPE_ISSUED_PULL_REQ;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH])))
- {
- return STAT_TYPE_ISSUED_PULL_REQ_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REP],
- stat_str,
- strlen
(stat_type_strings[STAT_TYPE_ISSUED_PULL_REP])))
- {
- return STAT_TYPE_ISSUED_PULL_REP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PUSH_SEND],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_SENT_PUSH_SEND])))
- {
- return STAT_TYPE_SENT_PUSH_SEND;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REQ],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_SENT_PULL_REQ])))
- {
- return STAT_TYPE_SENT_PULL_REQ;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH])))
- {
- return STAT_TYPE_SENT_PULL_REQ_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REP],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_SENT_PULL_REP])))
- {
- return STAT_TYPE_SENT_PULL_REP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND])))
- {
- return STAT_TYPE_RECV_PUSH_SEND;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH])))
- {
- return STAT_TYPE_RECV_PUSH_SEND_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REQ],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_RECV_PULL_REQ])))
- {
- return STAT_TYPE_RECV_PULL_REQ;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH])))
- {
- return STAT_TYPE_RECV_PULL_REQ_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REP],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_RECV_PULL_REP])))
- {
- return STAT_TYPE_RECV_PULL_REP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH])))
- {
- return STAT_TYPE_RECV_PULL_REP_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_VIEW_SIZE],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_VIEW_SIZE])))
- {
- return STAT_TYPE_VIEW_SIZE;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_KNOWN_PEERS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_KNOWN_PEERS])))
- {
- return STAT_TYPE_KNOWN_PEERS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_VALID_PEERS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_VALID_PEERS])))
- {
- return STAT_TYPE_VALID_PEERS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_LEARND_PEERS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_LEARND_PEERS])))
- {
- return STAT_TYPE_LEARND_PEERS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS],
- stat_str,
- strlen (
-
stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS])))
- {
- return STAT_TYPE_PENDING_ONLINE_CHECKS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES],
- stat_str,
- strlen (
-
stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES])))
- {
- return STAT_TYPE_UNREQUESTED_PULL_REPLIES;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP])))
- {
- return STAT_TYPE_PEERS_IN_PUSH_MAP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP])))
- {
- return STAT_TYPE_PEERS_IN_PULL_MAP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_VIEW],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_PEERS_IN_VIEW])))
- {
- return STAT_TYPE_PEERS_IN_VIEW;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM])))
- {
- return STAT_TYPE_VIEW_SIZE_AIM;
- }
- return STAT_TYPE_MAX;
-}
-
-
-/**
- * @brief Indicates whether peer should go off- or online
- */
-enum PEER_ONLINE_DELTA
-{
- /**
- * @brief Indicates peer going online
- */
- PEER_GO_ONLINE = 1,
- /**
- * @brief Indicates peer going offline
- */
- PEER_GO_OFFLINE = -1,
-};
-
-/**
- * Operation map entry
- */
-struct OpListEntry
-{
- /**
- * DLL next ptr
- */
- struct OpListEntry *next;
-
- /**
- * DLL prev ptr
- */
- struct OpListEntry *prev;
-
- /**
- * The testbed operation
- */
- struct GNUNET_TESTBED_Operation *op;
-
- /**
- * Depending on whether we start or stop RPS service at the peer, set this to
- * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1)
- */
- enum PEER_ONLINE_DELTA delta;
-
- /**
- * Index of the regarding peer
- */
- unsigned int index;
-};
-
-/**
- * OpList DLL head
- */
-static struct OpListEntry *oplist_head;
-
-/**
- * OpList DLL tail
- */
-static struct OpListEntry *oplist_tail;
-
-
-/**
- * A pending reply: A request was sent and the reply is pending.
- */
-struct PendingReply
-{
- /**
- * DLL next,prev ptr
- */
- struct PendingReply *next;
- struct PendingReply *prev;
-
- /**
- * Handle to the request we are waiting for
- */
- struct GNUNET_RPS_Request_Handle_Single_Info *req_handle;
-
- /**
- * The peer that requested
- */
- struct RPSPeer *rps_peer;
-};
-
-
-/**
- * A pending request: A request was not made yet but is scheduled for later.
- */
-struct PendingRequest
-{
- /**
- * DLL next,prev ptr
- */
- struct PendingRequest *next;
- struct PendingRequest *prev;
-
- /**
- * Handle to the request we are waiting for
- */
- struct GNUNET_SCHEDULER_Task *request_task;
-
- /**
- * The peer that requested
- */
- struct RPSPeer *rps_peer;
-};
-
-
-/**
- * Information we track for each peer.
- */
-struct RPSPeer
-{
- /**
- * Index of the peer.
- */
- uint32_t index;
-
- /**
- * Handle for RPS connect operation.
- */
- struct GNUNET_TESTBED_Operation *op;
-
- /**
- * Handle to RPS service.
- */
- struct GNUNET_RPS_Handle *rps_handle;
-
- /**
- * ID of the peer.
- */
- struct GNUNET_PeerIdentity *peer_id;
-
- /**
- * A request handle to check for an request
- */
- // struct GNUNET_RPS_Request_Handle *req_handle;
-
- /**
- * Peer on- or offline?
- */
- int online;
-
- /**
- * Number of Peer IDs to request during the whole test
- */
- unsigned int num_ids_to_request;
-
- /**
- * Pending requests DLL
- */
- struct PendingRequest *pending_req_head;
- struct PendingRequest *pending_req_tail;
-
- /**
- * Number of pending requests
- */
- unsigned int num_pending_reqs;
-
- /**
- * Pending replies DLL
- */
- struct PendingReply *pending_rep_head;
- struct PendingReply *pending_rep_tail;
-
- /**
- * Number of pending replies
- */
- unsigned int num_pending_reps;
-
- /**
- * Number of received PeerIDs
- */
- unsigned int num_recv_ids;
-
- /**
- * Pending operation on that peer
- */
- const struct OpListEntry *entry_op_manage;
-
- /**
- * Testbed operation to connect to statistics service
- */
- struct GNUNET_TESTBED_Operation *stat_op;
-
- /**
- * Handle to the statistics service
- */
- struct GNUNET_STATISTICS_Handle *stats_h;
-
- /**
- * @brief flags to indicate which statistics values have been already
- * collected from the statistics service.
- * Used to check whether we are able to shutdown.
- */
- uint32_t stat_collected_flags;
-
- /**
- * @brief File name of the file the stats are finally written to
- */
- const char *file_name_stats;
-
- /**
- * @brief File name of the file the stats are finally written to
- */
- const char *file_name_probs;
-
- /**
- * @brief File name of the file the stats are finally written to
- */
- const char *file_name_probs_hist;
-
- /**
- * @brief The current view
- */
- struct GNUNET_PeerIdentity *cur_view;
-
- /**
- * @brief Number of peers in the #cur_view.
- */
- uint32_t cur_view_count;
-
- /**
- * @brief Number of occurrences in other peer's view
- */
- uint32_t count_in_views;
-
- /**
- * @brief statistics values
- */
- uint64_t stats[STAT_TYPE_MAX];
- /**
- * @brief Handle for the statistics get request
- */
- struct GNUNET_STATISTICS_GetHandle *h_stat_get[STAT_TYPE_MAX];
-
- /**
- * @brief Keep the probabilities in cache for computing the probabilities
- * with respect to history.
- */
- double *eval_probs_cache;
-};
-
-/**
- * Information for all the peers.
- */
-static struct RPSPeer *rps_peers;
-
-/**
- * Peermap to get the index of a given peer ID quick.
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
-
-/**
- * IDs of the peers.
- */
-static struct GNUNET_PeerIdentity *rps_peer_ids;
-
-/**
- * ID of the targeted peer.
- */
-static struct GNUNET_PeerIdentity *target_peer;
-
-/**
- * Number of online peers.
- */
-static unsigned int num_peers_online;
-
-/**
- * @brief The added sizes of the peer's views
- */
-static unsigned int view_sizes;
-
-/**
- * Return value from 'main'.
- */
-static int ok;
-
-/**
- * Identifier for the task that runs after the test to collect results
- */
-static struct GNUNET_SCHEDULER_Task *post_test_task;
-
-/**
- * Identifier for the shutdown task
- */
-static struct GNUNET_SCHEDULER_Task *shutdown_task;
-
-
-/**
- * Identifier for the churn task that runs periodically
- */
-static struct GNUNET_SCHEDULER_Task *churn_task;
-
-/**
- * Called to initialise the given RPSPeer
- */
-typedef void (*InitPeer) (struct RPSPeer *rps_peer);
-
-/**
- * @brief Called directly after connecting to the service
- *
- * @param rps_peer Specific peer the function is called on
- * @param h the handle to the rps service
- */
-typedef void (*PreTest) (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle
*h);
-
-/**
- * @brief Executes functions to test the api/service for a given peer
- *
- * Called from within #rps_connect_complete_cb ()
- * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb,
- * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb
- *
- * @param rps_peer the peer the task runs on
- */
-typedef void (*MainTest) (struct RPSPeer *rps_peer);
-
-/**
- * Callback called once the requested random peers are available
- */
-typedef void (*ReplyHandle) (void *cls,
- uint64_t n,
- const struct GNUNET_PeerIdentity *recv_peers);
-
-/**
- * Called directly before disconnecting from the service
- */
-typedef void (*PostTest) (struct RPSPeer *peer);
-
-/**
- * Function called after disconnect to evaluate test success
- */
-typedef int (*EvaluationCallback) (void);
-
-/**
- * @brief Do we have Churn?
- */
-enum OPTION_CHURN
-{
- /**
- * @brief If we have churn this is set
- */
- HAVE_CHURN,
- /**
- * @brief If we have no churn this is set
- */
- HAVE_NO_CHURN,
-};
-
-/**
- * @brief Is it ok to quit the test before the timeout?
- */
-enum OPTION_QUICK_QUIT
-{
- /**
- * @brief It is ok for the test to quit before the timeout triggers
- */
- HAVE_QUICK_QUIT,
-
- /**
- * @brief It is NOT ok for the test to quit before the timeout triggers
- */
- HAVE_NO_QUICK_QUIT,
-};
-
-/**
- * @brief Do we collect statistics at the end?
- */
-enum OPTION_COLLECT_STATISTICS
-{
- /**
- * @brief We collect statistics at the end
- */
- COLLECT_STATISTICS,
-
- /**
- * @brief We do not collect statistics at the end
- */
- NO_COLLECT_STATISTICS,
-};
-
-/**
- * @brief Do we collect views during run?
- */
-enum OPTION_COLLECT_VIEW
-{
- /**
- * @brief We collect view during run
- */
- COLLECT_VIEW,
-
- /**
- * @brief We do not collect the view during run
- */
- NO_COLLECT_VIEW,
-};
-
-/**
- * Structure to define a single test
- */
-struct SingleTestRun
-{
- /**
- * Name of the test
- */
- char *name;
-
- /**
- * Called with a single peer in order to initialise that peer
- */
- InitPeer init_peer;
-
- /**
- * Called directly after connecting to the service
- */
- PreTest pre_test;
-
- /**
- * Main function for each peer
- */
- MainTest main_test;
-
- /**
- * Callback called once the requested peers are available
- */
- ReplyHandle reply_handle;
-
- /**
- * Called directly before disconnecting from the service
- */
- PostTest post_test;
-
- /**
- * Function to evaluate the test results
- */
- EvaluationCallback eval_cb;
-
- /**
- * Request interval
- */
- uint32_t request_interval;
-
- /**
- * Number of Requests to make.
- */
- uint32_t num_requests;
-
- /**
- * Run with (-out) churn
- */
- enum OPTION_CHURN have_churn;
-
- /**
- * Quit test before timeout?
- */
- enum OPTION_QUICK_QUIT have_quick_quit;
-
- /**
- * Collect statistics at the end?
- */
- enum OPTION_COLLECT_STATISTICS have_collect_statistics;
-
- /**
- * Collect view during run?
- */
- enum OPTION_COLLECT_VIEW have_collect_view;
-
- /**
- * @brief Mark which values from the statistics service to collect at the end
- * of the run
- */
- uint32_t stat_collect_flags;
-} cur_test_run;
-
-/**
- * Did we finish the test?
- */
-static int post_test;
-
-/**
- * Are we shutting down?
- */
-static int in_shutdown;
-
-/**
- * Append arguments to file
- */
-static void
-tofile_ (const char *file_name, const char *line)
-{
- struct GNUNET_DISK_FileHandle *f;
- /* char output_buffer[512]; */
- size_t size;
- /* int size; */
- size_t size2;
-
- if (NULL == (f = GNUNET_DISK_file_open (file_name,
- GNUNET_DISK_OPEN_APPEND
- | GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE
- | GNUNET_DISK_PERM_GROUP_READ
- | GNUNET_DISK_PERM_OTHER_READ)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Not able to open file %s\n",
- file_name);
- return;
- }
- /* size = GNUNET_snprintf (output_buffer,
- sizeof (output_buffer),
- "%llu %s\n",
- GNUNET_TIME_absolute_get ().abs_value_us,
- line);
- if (0 > size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Failed to write string to buffer (size: %i)\n",
- size);
- return;
- } */size = strlen (line) * sizeof(char);
-
- size2 = GNUNET_DISK_file_write (f, line, size);
- if (size != size2)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unable to write to file! (Size: %lu, size2: %lu)\n",
- size,
- size2);
- if (GNUNET_YES != GNUNET_DISK_file_close (f))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unable to close file\n");
- }
- return;
- }
-
- if (GNUNET_YES != GNUNET_DISK_file_close (f))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unable to close file\n");
- }
-}
-
-
-/**
- * This function is used to facilitate writing important information to disk
- */
-#define tofile(file_name, ...) do { \
- char tmp_buf[512]; \
- int size; \
- size = GNUNET_snprintf (tmp_buf, sizeof(tmp_buf), __VA_ARGS__); \
- if (0 > size) \
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \
- "Failed to create tmp_buf\n"); \
- else \
- tofile_ (file_name, tmp_buf); \
-} while (0);
-
-
-/**
- * Write the ids and their according index in the given array to a file
- * Unused
- */
-/* static void
- ids_to_file (char *file_name,
- struct GNUNET_PeerIdentity *peer_ids,
- unsigned int num_peer_ids)
- {
- unsigned int i;
-
- for (i=0 ; i < num_peer_ids ; i++)
- {
- to_file (file_name,
- "%u\t%s",
- i,
- GNUNET_i2s_full (&peer_ids[i]));
- }
- } */
-
-/**
- * Test the success of a single test
- */
-static int
-evaluate (void)
-{
- unsigned int i;
- int tmp_ok;
-
- tmp_ok = 1;
-
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u. peer [%s] received %u of %u expected peer_ids: %i\n",
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- rps_peers[i].num_recv_ids,
- rps_peers[i].num_ids_to_request,
- (rps_peers[i].num_ids_to_request ==
rps_peers[i].num_recv_ids));
- tmp_ok &= (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids);
- }
- return tmp_ok ? 0 : 1;
-}
-
-
-/**
- * Creates an oplist entry and adds it to the oplist DLL
- */
-static struct OpListEntry *
-make_oplist_entry ()
-{
- struct OpListEntry *entry;
-
- entry = GNUNET_new (struct OpListEntry);
- GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry);
- return entry;
-}
-
-
-/**
- * @brief Checks if given peer already received its statistics value from the
- * statistics service.
- *
- * @param rps_peer the peer to check for
- *
- * @return #GNUNET_YES if so
- * #GNUNET_NO otherwise
- */
-static int
-check_statistics_collect_completed_single_peer (
- const struct RPSPeer *rps_peer)
-{
- if (cur_test_run.stat_collect_flags !=
- (cur_test_run.stat_collect_flags
- & rps_peer->stat_collected_flags))
- {
- return GNUNET_NO;
- }
- return GNUNET_YES;
-}
-
-
-/**
- * @brief Checks if all peers already received their statistics value from the
- * statistics service.
- *
- * @return #GNUNET_YES if so
- * #GNUNET_NO otherwise
- */
-static int
-check_statistics_collect_completed ()
-{
- uint32_t i;
-
- for (i = 0; i < num_peers; i++)
- {
- if (GNUNET_NO == check_statistics_collect_completed_single_peer (
- &rps_peers[i]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At least Peer %" PRIu32
- " did not yet receive all statistics values\n",
- i);
- return GNUNET_NO;
- }
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "All peers received their statistics values\n");
- return GNUNET_YES;
-}
-
-
-static void
-rps_disconnect_adapter (void *cls,
- void *op_result);
-
-static void
-cancel_pending_req (struct PendingRequest *pending_req)
-{
- struct RPSPeer *rps_peer;
-
- rps_peer = pending_req->rps_peer;
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
- rps_peer->pending_req_tail,
- pending_req);
- rps_peer->num_pending_reqs--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelling pending rps get request\n");
- GNUNET_SCHEDULER_cancel (pending_req->request_task);
- GNUNET_free (pending_req);
-}
-
-
-static void
-cancel_request (struct PendingReply *pending_rep)
-{
- struct RPSPeer *rps_peer;
-
- rps_peer = pending_rep->rps_peer;
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
- rps_peer->pending_rep_tail,
- pending_rep);
- rps_peer->num_pending_reps--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelling rps get reply\n");
- GNUNET_assert (NULL != pending_rep->req_handle);
- GNUNET_RPS_request_single_info_cancel (pending_rep->req_handle);
- pending_rep->req_handle = NULL;
- GNUNET_free (pending_rep);
- pending_rep = NULL;
-}
-
-
-void
-clean_peer (unsigned peer_index)
-{
- struct PendingRequest *pending_req;
-
- while (NULL != (pending_req = rps_peers[peer_index].pending_req_head))
- {
- cancel_pending_req (pending_req);
- }
- pending_req = rps_peers[peer_index].pending_req_head;
- rps_disconnect_adapter (&rps_peers[peer_index],
- &rps_peers[peer_index].rps_handle);
- for (unsigned stat_type = STAT_TYPE_ROUNDS;
- stat_type < STAT_TYPE_MAX;
- stat_type++)
- {
- if (NULL != rps_peers[peer_index].h_stat_get[stat_type])
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "(%u) did not yet receive stat value for `%s'\n",
- rps_peers[peer_index].index,
- stat_type_strings[stat_type]);
- GNUNET_STATISTICS_get_cancel (
- rps_peers[peer_index].h_stat_get[stat_type]);
- }
- }
- if (NULL != rps_peers[peer_index].op)
- {
- GNUNET_TESTBED_operation_done (rps_peers[peer_index].op);
- rps_peers[peer_index].op = NULL;
- }
-}
-
-
-/**
- * Task run on timeout to shut everything down.
- */
-static void
-shutdown_op (void *cls)
-{
- unsigned int i;
- struct OpListEntry *entry;
-
- (void) cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Shutdown task scheduled, going down.\n");
- in_shutdown = GNUNET_YES;
-
- if (NULL != shutdown_task)
- {
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = NULL;
- }
- if (NULL != post_test_task)
- {
- GNUNET_SCHEDULER_cancel (post_test_task);
- post_test_task = NULL;
- }
- if (NULL != churn_task)
- {
- GNUNET_SCHEDULER_cancel (churn_task);
- churn_task = NULL;
- }
- entry = oplist_head;
- while (NULL != (entry = oplist_head))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Operation still pending on shutdown (%u)\n",
- entry->index);
- GNUNET_TESTBED_operation_done (entry->op);
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- GNUNET_free (entry);
- }
- for (i = 0; i < num_peers; i++)
- {
- clean_peer (i);
- }
- close_all_files ();
-}
-
-
-static void
-trigger_shutdown (void *cls)
-{
- (void) cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Shutdown was triggered by timeout, going down.\n");
- shutdown_task = NULL;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Task run after #duration to collect statistics and potentially shut down.
- */
-static void
-post_test_op (void *cls)
-{
- unsigned int i;
-
- (void) cls;
-
- post_test_task = NULL;
- post_test = GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Executing post test op.\n");
- if (NULL != churn_task)
- {
- GNUNET_SCHEDULER_cancel (churn_task);
- churn_task = NULL;
- }
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Executing post test op. (peer %" PRIu32 ")\n",
- rps_peers[i].index);
- if (NULL != rps_peers[i].op)
- {
- GNUNET_TESTBED_operation_done (rps_peers[i].op);
- rps_peers[i].op = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelled testbed operation\n");
- }
- if (NULL != cur_test_run.post_test)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n",
- i);
- cur_test_run.post_test (&rps_peers[i]);
- }
- }
- /* If we do not collect statistics, shut down directly */
- if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics) ||
- (GNUNET_YES == check_statistics_collect_completed ()) )
- {
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = NULL;
- GNUNET_SCHEDULER_shutdown ();
- }
-}
-
-
-/**
- * Get the id of peer i.
- */
-void
-info_cb (void *cb_cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct OpListEntry *entry = (struct OpListEntry *) cb_cls;
-
- (void) op;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- if ((NULL == pinfo) || (NULL != emsg))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
- GNUNET_TESTBED_operation_done (entry->op);
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u is %s\n",
- entry->index,
- GNUNET_i2s (pinfo->result.id));
-
- rps_peer_ids[entry->index] = *(pinfo->result.id);
- rps_peers[entry->index].peer_id = &rps_peer_ids[entry->index];
-
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (peer_map,
-
&rps_peer_ids[entry->index],
- &rps_peers[entry->index],
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- tofile ("/tmp/rps/peer_ids",
- "%u\t%s\n",
- entry->index,
- GNUNET_i2s_full (&rps_peer_ids[entry->index]));
-
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- GNUNET_TESTBED_operation_done (entry->op);
- GNUNET_free (entry);
-}
-
-
-/**
- * Callback to be called when RPS service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the RPS service handle returned from rps_connect_adapter
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-rps_connect_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct RPSPeer *rps_peer = cls;
- struct GNUNET_RPS_Handle *rps = ca_result;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- rps_peer->rps_handle = rps;
- rps_peer->online = GNUNET_YES;
- num_peers_online++;
-
- GNUNET_assert (op == rps_peer->op);
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to connect to RPS service: %s\n",
- emsg);
- ok = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Started client successfully (%u)\n",
- rps_peer->index);
-
- cur_test_run.main_test (rps_peer);
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * the RPS service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-rps_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_RPS_Handle *h;
-
- h = GNUNET_RPS_connect (cfg);
-
- if (NULL != cur_test_run.pre_test)
- cur_test_run.pre_test (cls, h);
-
- return h;
-}
-
-
-/**
- * Called to open a connection to the peer's statistics
- *
- * @param cls peer context
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-stat_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct RPSPeer *peer = cls;
-
- peer->stats_h = GNUNET_STATISTICS_create ("rps-profiler", cfg);
- return peer->stats_h;
-}
-
-
-/**
- * Called to disconnect from peer's statistics service
- *
- * @param cls peer context
- * @param op_result service handle returned from the connect adapter
- */
-static void
-stat_disconnect_adapter (void *cls, void *op_result)
-{
- struct RPSPeer *peer = cls;
-
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
- // (peer->stats_h, "core", "# peers connected",
- // stat_iterator, peer));
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
- // (peer->stats_h, "nse", "# peers connected",
- // stat_iterator, peer));
- GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
- peer->stats_h = NULL;
-}
-
-
-/**
- * Called after successfully opening a connection to a peer's statistics
- * service; we register statistics monitoring for CORE and NSE here.
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from
GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-stat_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- // struct GNUNET_STATISTICS_Handle *sh = ca_result;
- // struct RPSPeer *peer = (struct RPSPeer *) cls;
- (void) cls;
- (void) op;
- (void) ca_result;
-
- if (NULL != emsg)
- {
- GNUNET_break (0);
- return;
- }
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
- // (sh, "core", "# peers connected",
- // stat_iterator, peer));
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
- // (sh, "nse", "# peers connected",
- // stat_iterator, peer));
-}
-
-
-/**
- * Adapter function called to destroy connection to
- * RPS service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-rps_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct RPSPeer *peer = cls;
- struct GNUNET_RPS_Handle *h = op_result;
- struct PendingReply *pending_rep;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "disconnect_adapter (%u)\n",
- peer->index);
- GNUNET_assert (NULL != peer);
- if (NULL != peer->rps_handle)
- {
- while (NULL != (pending_rep = peer->pending_rep_head))
- {
- cancel_request (pending_rep);
- }
- GNUNET_assert (h == peer->rps_handle);
- if (NULL != h)
- {
- GNUNET_RPS_disconnect (h);
- h = NULL;
- }
- peer->rps_handle = NULL;
- }
-}
-
-
-/***********************************************************************
-* Definition of tests
-***********************************************************************/
-
-/**
- * Callback to call on receipt of a reply
- *
- * @param cls closure
- * @param n number of peers
- * @param recv_peers the received peers
- */
-static void
-default_reply_handle (void *cls,
- uint64_t n,
- const struct GNUNET_PeerIdentity *recv_peers)
-{
- struct RPSPeer *rps_peer;
- struct PendingReply *pending_rep = (struct PendingReply *) cls;
- unsigned int i;
-
- rps_peer = pending_rep->rps_peer;
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
- rps_peer->pending_rep_tail,
- pending_rep);
- rps_peer->num_pending_reps--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "[%s] got %" PRIu64 " peers:\n",
- GNUNET_i2s (rps_peer->peer_id),
- n);
-
- for (i = 0; i < n; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u: %s\n",
- i,
- GNUNET_i2s (&recv_peers[i]));
-
- rps_peer->num_recv_ids++;
- }
-
- if (GNUNET_YES != post_test)
- return;
- if (HAVE_QUICK_QUIT != cur_test_run.have_quick_quit)
- return;
- if (0 == evaluate ())
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Test succeeded before end of duration\n");
- if (NULL != post_test_task)
- GNUNET_SCHEDULER_cancel (post_test_task);
- post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL);
- GNUNET_assert (NULL != post_test_task);
- }
-}
-
-
-static void
-profiler_reply_handle_info (void *cls,
- const struct GNUNET_PeerIdentity *recv_peer,
- double probability,
- uint32_t num_observed);
-
-/**
- * Request random peers.
- */
-static void
-request_peers (void *cls)
-{
- struct PendingRequest *pending_req = cls;
- struct RPSPeer *rps_peer;
- struct PendingReply *pending_rep;
-
- rps_peer = pending_req->rps_peer;
- GNUNET_assert (1 <= rps_peer->num_pending_reqs);
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
- rps_peer->pending_req_tail,
- pending_req);
- rps_peer->num_pending_reqs--;
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- return;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting one peer\n");
- pending_rep = GNUNET_new (struct PendingReply);
- pending_rep->rps_peer = rps_peer;
- // pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle,
- // 1,
- // cur_test_run.reply_handle,
- // pending_rep);
- pending_rep->req_handle = GNUNET_RPS_request_peer_info (rps_peer->rps_handle,
-
profiler_reply_handle_info,
- pending_rep);
- GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head,
- rps_peer->pending_rep_tail,
- pending_rep);
- rps_peer->num_pending_reps++;
-}
-
-
-/**
- * Schedule requests for peer @a rps_peer that have neither been scheduled, nor
- * issued, nor replied
- */
-void
-schedule_missing_requests (struct RPSPeer *rps_peer)
-{
- unsigned int i;
- struct PendingRequest *pending_req;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Scheduling %u - %u missing requests\n",
- rps_peer->num_ids_to_request,
- rps_peer->num_pending_reqs + rps_peer->num_pending_reps);
- GNUNET_assert (rps_peer->num_pending_reqs + rps_peer->num_pending_reps <=
- rps_peer->num_ids_to_request);
- for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps;
- i < rps_peer->num_ids_to_request; i++)
- {
- pending_req = GNUNET_new (struct PendingRequest);
- pending_req->rps_peer = rps_peer;
- pending_req->request_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- cur_test_run.request_interval * i),
- request_peers,
- pending_req);
- GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_req_head,
- rps_peer->pending_req_tail,
- pending_req);
- rps_peer->num_pending_reqs++;
- }
-}
-
-
-void
-cancel_pending_req_rep (struct RPSPeer *rps_peer)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelling all (pending) requests.\n");
- while (NULL != rps_peer->pending_req_head)
- cancel_pending_req (rps_peer->pending_req_head);
- GNUNET_assert (0 == rps_peer->num_pending_reqs);
- while (NULL != rps_peer->pending_rep_head)
- cancel_request (rps_peer->pending_rep_head);
- GNUNET_assert (0 == rps_peer->num_pending_reps);
-}
-
-
-/***********************************
-* MALICIOUS
-***********************************/
-
-///**
-// * Initialise only non-mal RPSPeers
-// */
-//static void
-//mal_init_peer (struct RPSPeer *rps_peer)
-//{
-// if (rps_peer->index >= round (portion * num_peers))
-// rps_peer->num_ids_to_request = 1;
-//}
-
-
-///**
-// * @brief Set peers to (non-)malicious before execution
-// *
-// * Of signature #PreTest
-// *
-// * @param rps_peer the peer to set (non-) malicious
-// * @param h the handle to the service
-// */
-//static void
-//mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
-//{
-// #if ENABLE_MALICIOUS
-// uint32_t num_mal_peers;
-//
-// GNUNET_assert ((1 >= portion) &&
-// (0 < portion));
-// num_mal_peers = round (portion * num_peers);
-//
-// if (rps_peer->index < num_mal_peers)
-// {
-// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-// "%u. peer [%s] of %" PRIu32
-// " malicious peers turning malicious\n",
-// rps_peer->index,
-// GNUNET_i2s (rps_peer->peer_id),
-// num_mal_peers);
-//
-// GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
-// rps_peer_ids, target_peer);
-// }
-// #endif /* ENABLE_MALICIOUS */
-//}
-
-
-// static void
-// mal_cb (struct RPSPeer *rps_peer)
-// {
-// if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
-// {
-// return;
-// }
-//
-// #if ENABLE_MALICIOUS
-// uint32_t num_mal_peers;
-//
-// GNUNET_assert ((1 >= portion) &&
-// (0 < portion));
-// num_mal_peers = round (portion * num_peers);
-//
-// if (rps_peer->index >= num_mal_peers)
-// { /* It's useless to ask a malicious peer about a random sample -
-// it's not sampling */
-// GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
-// GNUNET_TIME_UNIT_SECONDS, 2),
-// seed_peers, rps_peer);
-// schedule_missing_requests (rps_peer);
-// }
-// #endif /* ENABLE_MALICIOUS */
-// }
-
-
-/***********************************
-* CHURN
-***********************************/
-
-static void
-churn (void *cls);
-
-
-/***********************************
-* PROFILER
-***********************************/
-
-/**
- * Callback to be called when RPS service is started or stopped at peers
- *
- * @param cls NULL
- * @param op the operation handle
- * @param emsg NULL on success; otherwise an error description
- */
-static void
-churn_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const char *emsg)
-{
- // FIXME
- struct OpListEntry *entry = cls;
-
- (void) op;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- GNUNET_TESTBED_operation_done (entry->op);
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to start/stop RPS at a peer\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_assert (0 != entry->delta);
-
- num_peers_online += entry->delta;
-
- if (PEER_GO_OFFLINE == entry->delta)
- { /* Peer hopefully just went offline */
- if (GNUNET_YES != rps_peers[entry->index].online)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "peer %s was expected to go offline but is still marked as
online\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- GNUNET_break (0);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "peer %s probably went offline as expected\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- }
- rps_peers[entry->index].online = GNUNET_NO;
- }
-
- else if (PEER_GO_ONLINE < entry->delta)
- { /* Peer hopefully just went online */
- if (GNUNET_NO != rps_peers[entry->index].online)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "peer %s was expected to go online but is still marked as
offline\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- GNUNET_break (0);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "peer %s probably went online as expected\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- if (NULL != cur_test_run.pre_test)
- {
- cur_test_run.pre_test (&rps_peers[entry->index],
- rps_peers[entry->index].rps_handle);
- schedule_missing_requests (&rps_peers[entry->index]);
- }
- }
- rps_peers[entry->index].online = GNUNET_YES;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Invalid value for delta: %i\n", entry->delta);
- GNUNET_break (0);
- }
-
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- rps_peers[entry->index].entry_op_manage = NULL;
- GNUNET_free (entry);
- // if (num_peers_in_round[current_round] == peers_running)
- // run_round ();
-}
-
-
-/**
- * @brief Set the rps-service up or down for a specific peer
- *
- * @param i index of action
- * @param j index of peer
- * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1)
- * @param prob_go_on_off the probability of the action
- */
-static void
-manage_service_wrapper (unsigned int i, unsigned int j,
- enum PEER_ONLINE_DELTA delta,
- double prob_go_on_off)
-{
- struct OpListEntry *entry = NULL;
- uint32_t prob;
-
- /* make sure that management operation is not already scheduled */
- if (NULL != rps_peers[j].entry_op_manage)
- {
- return;
- }
-
- prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u. selected peer (%u: %s) is %s.\n",
- i,
- j,
- GNUNET_i2s (rps_peers[j].peer_id),
- (PEER_GO_ONLINE == delta) ? "online" : "offline");
- if (prob < prob_go_on_off * UINT32_MAX)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s goes %s\n",
- GNUNET_i2s (rps_peers[j].peer_id),
- (PEER_GO_OFFLINE == delta) ? "offline" : "online");
-
- if (PEER_GO_OFFLINE == delta)
- cancel_pending_req_rep (&rps_peers[j]);
- entry = make_oplist_entry ();
- entry->delta = delta;
- entry->index = j;
- entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
- testbed_peers[j],
- "rps",
- &churn_cb,
- entry,
- (PEER_GO_OFFLINE == delta)
?
- 0 : 1);
- rps_peers[j].entry_op_manage = entry;
- }
-}
-
-
-static void
-churn (void *cls)
-{
- unsigned int i;
- unsigned int j;
- double portion_online;
- unsigned int *permut;
- double prob_go_offline;
- double portion_go_online;
- double portion_go_offline;
-
- (void) cls;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Churn function executing\n");
-
- churn_task = NULL; /* Should be invalid by now */
-
- /* Compute the probability for an online peer to go offline
- * this round */
- portion_online = num_peers_online * 1.0 / num_peers;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Portion online: %f\n",
- portion_online);
- portion_go_online = ((1 - portion_online) * .5 * .66);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Portion that should go online: %f\n",
- portion_go_online);
- portion_go_offline = (portion_online + portion_go_online) - .75;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Portion that probably goes offline: %f\n",
- portion_go_offline);
- prob_go_offline = portion_go_offline / (portion_online * .5);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Probability of a selected online peer to go offline: %f\n",
- prob_go_offline);
-
- permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
- (unsigned int) num_peers);
-
- /* Go over 50% randomly chosen peers */
- for (i = 0; i < .5 * num_peers; i++)
- {
- j = permut[i];
-
- /* If online, shut down with certain probability */
- if (GNUNET_YES == rps_peers[j].online)
- {
- manage_service_wrapper (i, j, -1, prob_go_offline);
- }
-
- /* If offline, restart with certain probability */
- else if (GNUNET_NO == rps_peers[j].online)
- {
- manage_service_wrapper (i, j, 1, 0.66);
- }
- }
-
- GNUNET_free (permut);
-
- churn_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
- churn,
- NULL);
-}
-
-
-/**
- * Initialise given RPSPeer
- */
-static void
-profiler_init_peer (struct RPSPeer *rps_peer)
-{
- rps_peer->num_ids_to_request = cur_test_run.num_requests;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n",
- rps_peer->num_ids_to_request);
-}
-
-
-/**
- * Callback to call on receipt of a reply
- *
- * @param cls closure
- * @param n number of peers
- * @param recv_peers the received peers
- */
-static void
-profiler_reply_handle (void *cls,
- uint64_t n,
- const struct GNUNET_PeerIdentity *recv_peers)
-{
- struct RPSPeer *rps_peer;
- struct RPSPeer *rcv_rps_peer;
- char file_name_buf[128];
- char file_name_dh_buf[128];
- char file_name_dhr_buf[128];
- char file_name_dhru_buf[128];
- char *file_name = file_name_buf;
- char *file_name_dh = file_name_dh_buf;
- char *file_name_dhr = file_name_dhr_buf;
- char *file_name_dhru = file_name_dhru_buf;
- unsigned int i;
- struct PendingReply *pending_rep = (struct PendingReply *) cls;
-
- pending_rep->req_handle = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n");
- rps_peer = pending_rep->rps_peer;
- (void) GNUNET_asprintf (&file_name,
- "/tmp/rps/received_ids-%u",
- rps_peer->index);
-
- (void) GNUNET_asprintf (&file_name_dh,
- "/tmp/rps/diehard_input-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhr,
- "/tmp/rps/diehard_input_raw-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhru,
- "/tmp/rps/diehard_input_raw_aligned-%u",
- rps_peer->index);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "[%s] got %" PRIu64 " peers:\n",
- GNUNET_i2s (rps_peer->peer_id),
- n);
- for (i = 0; i < n; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u: %s\n",
- i,
- GNUNET_i2s (&recv_peers[i]));
- tofile (file_name,
- "%s\n",
- GNUNET_i2s_full (&recv_peers[i]));
- rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map,
&recv_peers[i]);
- GNUNET_assert (NULL != rcv_rps_peer);
- tofile (file_name_dh,
- "%" PRIu32 "\n",
- (uint32_t) rcv_rps_peer->index);
-#ifdef TO_FILE
- to_file_raw (file_name_dhr,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t));
- to_file_raw_unaligned (file_name_dhru,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t),
- bits_needed);
-#endif /* TO_FILE */
- }
- default_reply_handle (cls, n, recv_peers);
-}
-
-
-/**
- * Callback to call on receipt of a reply
- *
- * @param cls closure
- * @param n number of peers
- * @param recv_peers the received peers
- */
-static void
-profiler_reply_handle_info (void *cls,
- const struct GNUNET_PeerIdentity *recv_peer,
- double probability,
- uint32_t num_observed)
-{
- struct RPSPeer *rps_peer;
- struct RPSPeer *rcv_rps_peer;
- char file_name_buf[128];
- char file_name_dh_buf[128];
- char file_name_dhr_buf[128];
- char file_name_dhru_buf[128];
- char *file_name = file_name_buf;
- char *file_name_dh = file_name_dh_buf;
- char *file_name_dhr = file_name_dhr_buf;
- char *file_name_dhru = file_name_dhru_buf;
- struct PendingReply *pending_rep = (struct PendingReply *) cls;
-
- pending_rep->req_handle = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n");
- rps_peer = pending_rep->rps_peer;
- (void) GNUNET_asprintf (&file_name,
- "/tmp/rps/received_ids-%u",
- rps_peer->index);
-
- (void) GNUNET_asprintf (&file_name_dh,
- "/tmp/rps/diehard_input-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhr,
- "/tmp/rps/diehard_input_raw-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhru,
- "/tmp/rps/diehard_input_raw_aligned-%u",
- rps_peer->index);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "[%s] got peer with info:\n",
- GNUNET_i2s (rps_peer->peer_id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- " %s\n",
- GNUNET_i2s (recv_peer));
- tofile (file_name,
- "%s %f %" PRIu32 " \n",
- GNUNET_i2s_full (recv_peer),
- probability,
- num_observed);
- rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, recv_peer);
- GNUNET_assert (NULL != rcv_rps_peer);
- tofile (file_name_dh,
- "%" PRIu32 "\n",
- (uint32_t) rcv_rps_peer->index);
-#ifdef TO_FILE
- to_file_raw (file_name_dhr,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t));
- to_file_raw_unaligned (file_name_dhru,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t),
- bits_needed);
-#endif /* TO_FILE */
- default_reply_handle (cls, 1, recv_peer);
-}
-
-
-static void
-profiler_cb (struct RPSPeer *rps_peer)
-{
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- /* Start churn */
- if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting churn task\n");
- churn_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
- churn,
- NULL);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Not starting churn task\n");
- }
-
- /* Only request peer ids at one peer.
- * (It's the before-last because last one is target of the focused attack.)
- */
- if (0 < rps_peer->num_ids_to_request)
- schedule_missing_requests (rps_peer);
-}
-
-
-/**
- * Function called from #profiler_eval with a filename.
- *
- * @param cls closure
- * @param filename complete filename (absolute path)
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_NO to stop iteration with no error,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-file_name_cb (void *cls, const char *filename)
-{
- if (NULL != strstr (filename, "sampler_el"))
- {
- struct RPS_SamplerElement *s_elem;
- struct GNUNET_CRYPTO_AuthKey auth_key;
- const char *key_char;
- uint32_t i;
- (void) cls;
-
- key_char = filename + 20; /* Length of "/tmp/rps/sampler_el-" */
- tofile (filename, "--------------------------\n");
-
- auth_key = string_to_auth_key (key_char);
- s_elem = RPS_sampler_elem_create ();
- RPS_sampler_elem_set (s_elem, auth_key);
-
- for (i = 0; i < num_peers; i++)
- {
- RPS_sampler_elem_next (s_elem, &rps_peer_ids[i]);
- }
- RPS_sampler_elem_destroy (s_elem);
- }
- return GNUNET_OK;
-}
-
-
-/**
- * This is run after the test finished.
- *
- * Compute all perfect samples.
- */
-static int
-profiler_eval (void)
-{
-#ifdef TO_FILE
- /* Compute perfect sample for each sampler element */
- if (-1 == GNUNET_DISK_directory_scan ("/tmp/rps/", file_name_cb, NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Scan of directory failed\n");
- }
-#endif /* TO_FILE */
-
- return evaluate ();
-}
-
-
-/** @brief is b in view of a?
- *
- * @param a
- * @param b
- *
- * @return
- */
-static int
-is_in_view (uint32_t a, uint32_t b)
-{
- uint32_t i;
-
- for (i = 0; i < rps_peers[a].cur_view_count; i++)
- {
- if (0 == memcmp (rps_peers[b].peer_id,
- &rps_peers[a].cur_view[i],
- sizeof(struct GNUNET_PeerIdentity)))
- {
- return GNUNET_YES;
- }
- }
- return GNUNET_NO;
-}
-
-
-static uint32_t
-get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
-{
- uint32_t i;
-
- for (i = 0; i < num_peers; i++)
- {
- if (0 == memcmp (pid,
- rps_peers[i].peer_id,
- sizeof(struct GNUNET_PeerIdentity)))
- {
- return i;
- }
- }
- // return 0; /* Should not happen - make compiler happy */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No known _PeerIdentity %s!\n",
- GNUNET_i2s_full (pid));
- GNUNET_assert (0);
-}
-
-
-/**
- * @brief Counts number of peers in view of a that have b in their view
- *
- * @param a
- * @param b
- *
- * @return
- */
-static uint32_t
-count_containing_views (uint32_t a, uint32_t b)
-{
- uint32_t i;
- uint32_t peer_idx;
- uint32_t count = 0;
-
- for (i = 0; i < rps_peers[a].cur_view_count; i++)
- {
- peer_idx = get_idx_of_pid (&rps_peers[a].cur_view[i]);
- if (GNUNET_YES == is_in_view (peer_idx, b))
- {
- count++;
- }
- }
- return count;
-}
-
-
-/**
- * @brief Computes the probability for each other peer to be selected by the
- * sampling process based on the views of all peers
- *
- * @param peer_idx index of the peer that is about to sample
- */
-static void
-compute_probabilities (uint32_t peer_idx)
-{
- // double probs[num_peers] = { 0 };
- double probs[num_peers];
- double probs_hist[num_peers]; /* Probability respecting the history */
- size_t probs_as_str_size = (num_peers * 10 + 2) * sizeof(char);
- char *probs_as_str = GNUNET_malloc (probs_as_str_size);
- char *probs_as_str_cpy;
- uint32_t i;
- double prob_push;
- double prob_pull;
- uint32_t view_size;
- uint32_t cont_views;
- uint32_t number_of_being_in_pull_events;
- int tmp;
- double sum_non_zero_prob = 0;
- double sum_non_zero_prob_hist = 0;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Computing probabilities for peer %" PRIu32 "\n", peer_idx);
- /* Firstly without knowledge of old views */
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\tfor peer %" PRIu32 ":\n", i);
- view_size = rps_peers[i].cur_view_count;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tview_size: %" PRIu32 "\n", view_size);
- /* For peer i the probability of being sampled is
- * evenly distributed among all possibly observed peers. */
- /* We could have observed a peer in three cases:
- * 1. peer sent a push
- * 2. peer was contained in a pull reply
- * 3. peer was in history (sampler) - ignored for now */
- /* 1. Probability of having received a push from peer i */
- if ((GNUNET_YES == is_in_view (i, peer_idx)) &&
- (1 <= (0.45 * view_size)))
- {
- if (0 == binom (view_size, 0.45 * view_size))
- prob_push = 0;
- else
- {
- prob_push = 1.0 * binom (0.45 * view_size, 1)
- /
- binom (view_size, 0.45 * view_size);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n",
- peer_idx,
- i,
- prob_push);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tposs choices from view: %" PRIu32 ", containing i: %"
- PRIu32 "\n",
- binom (view_size, 0.45 * view_size),
- binom (0.45 * view_size, 1));
- }
- else
- {
- prob_push = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\t%" PRIu32 " is not in %" PRIu32 "'s view, prob: 0\n",
- peer_idx,
- i);
- }
- /* 2. Probability of peer i being contained in pulls */
- view_size = rps_peers[peer_idx].cur_view_count;
- cont_views = count_containing_views (peer_idx, i);
- number_of_being_in_pull_events =
- (binom (view_size, 0.45 * view_size)
- - binom (view_size - cont_views, 0.45 * view_size));
- if (0 != number_of_being_in_pull_events)
- {
- prob_pull = number_of_being_in_pull_events
- /
- (1.0 * binom (view_size, 0.45 * view_size));
- }
- else
- {
- prob_pull = 0;
- }
- probs[i] = prob_push + prob_pull - (prob_push * prob_pull);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\t%" PRIu32 " has %" PRIu32 " of %" PRIu32
- " peers in its view who know %" PRIu32 " prob: %f\n",
- peer_idx,
- cont_views,
- view_size,
- i,
- prob_pull);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tnumber of possible pull combinations: %" PRIu32 "\n",
- binom (view_size, 0.45 * view_size));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tnumber of possible pull combinations without %" PRIu32
- ": %" PRIu32 "\n",
- i,
- binom (view_size - cont_views, 0.45 * view_size));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tnumber of possible pull combinations with %" PRIu32
- ": %" PRIu32 "\n",
- i,
- number_of_being_in_pull_events);
-
- probs_hist[i] = 0.9 * rps_peers[peer_idx].eval_probs_cache[i] + probs[i];
- rps_peers[peer_idx].eval_probs_cache[i] = probs_hist[i];
-
- sum_non_zero_prob += probs[i];
- sum_non_zero_prob_hist += probs_hist[i];
- }
- /* normalize */
- if (0 != sum_non_zero_prob)
- {
- for (i = 0; i < num_peers; i++)
- {
- probs[i] = probs[i] * (1.0 / sum_non_zero_prob);
- }
- }
- if (0 != sum_non_zero_prob_hist)
- {
- for (i = 0; i < num_peers; i++)
- {
- probs_hist[i] = probs_hist[i] * (1.0 / sum_non_zero_prob_hist);
- }
- }
-
- /* str repr */
- for (i = 0; i < num_peers; i++)
- {
- probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
- tmp = GNUNET_snprintf (probs_as_str,
- probs_as_str_size,
- "%s %7.6f", probs_as_str_cpy, probs[i]);
- GNUNET_free (probs_as_str_cpy);
- GNUNET_assert (0 <= tmp);
- }
-
- to_file_w_len (rps_peers[peer_idx].file_name_probs,
- probs_as_str_size,
- "%s",
- probs_as_str);
-
- probs_as_str[0] = '\0';
- for (i = 0; i < num_peers; i++)
- {
- probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
- tmp = GNUNET_snprintf (probs_as_str,
- probs_as_str_size,
- "%s %7.6f", probs_as_str_cpy, probs_hist[i]);
- GNUNET_free (probs_as_str_cpy);
- GNUNET_assert (0 <= tmp);
- }
-
- to_file_w_len (rps_peers[peer_idx].file_name_probs_hist,
- probs_as_str_size,
- "%s",
- probs_as_str);
- GNUNET_free (probs_as_str);
-}
-
-
-/**
- * @brief This counts the number of peers in which views a given peer occurs.
- *
- * It also stores this value in the rps peer.
- *
- * @param peer_idx the index of the peer to count the representation
- *
- * @return the number of occurrences
- */
-static uint32_t
-count_peer_in_views_2 (uint32_t peer_idx)
-{
- uint32_t i, j;
- uint32_t count = 0;
-
- for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
- {
- for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
- {
- if (0 == memcmp (rps_peers[peer_idx].peer_id,
- &rps_peers[i].cur_view[j],
- sizeof(struct GNUNET_PeerIdentity)))
- {
- count++;
- break;
- }
- }
- }
- rps_peers[peer_idx].count_in_views = count;
- return count;
-}
-
-
-static uint32_t
-cumulated_view_sizes ()
-{
- uint32_t i;
-
- view_sizes = 0;
- for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
- {
- view_sizes += rps_peers[i].cur_view_count;
- }
- return view_sizes;
-}
-
-
-static void
-count_peer_in_views (uint32_t *count_peers)
-{
- uint32_t i, j;
-
- for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
- {
- for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
- {
- if (0 == memcmp (rps_peers[i].peer_id,
- &rps_peers[i].cur_view[j],
- sizeof(struct GNUNET_PeerIdentity)))
- {
- count_peers[i]++;
- }
- }
- }
-}
-
-
-void
-compute_diversity ()
-{
- uint32_t i;
- /* ith entry represents the number of occurrences in other peer's views */
- uint32_t *count_peers = GNUNET_new_array (num_peers, uint32_t);
- uint32_t views_total_size;
- double expected;
- /* deviation from expected number of peers */
- double *deviation = GNUNET_new_array (num_peers, double);
-
- views_total_size = 0;
- expected = 0;
-
- /* For each peer count its representation in other peer's views*/
- for (i = 0; i < num_peers; i++) /* Peer to count */
- {
- views_total_size += rps_peers[i].cur_view_count;
- count_peer_in_views (count_peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Counted representation of %" PRIu32 "th peer [%s]: %" PRIu32
- "\n",
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- count_peers[i]);
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "size of all views combined: %" PRIu32 "\n",
- views_total_size);
- expected = ((double) 1 / num_peers) * views_total_size;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Expected number of occurrences of each peer in all views: %f\n",
- expected);
- for (i = 0; i < num_peers; i++) /* Peer to count */
- {
- deviation[i] = expected - count_peers[i];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deviation from expectation: %f\n", deviation[i]);
- }
- GNUNET_free (count_peers);
- GNUNET_free (deviation);
-}
-
-
-void
-print_view_sizes ()
-{
- uint32_t i;
-
- for (i = 0; i < num_peers; i++) /* Peer to count */
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n",
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- rps_peers[i].cur_view_count);
- }
-}
-
-
-void
-all_views_updated_cb ()
-{
- compute_diversity ();
- print_view_sizes ();
-}
-
-
-void
-view_update_cb (void *cls,
- uint64_t view_size,
- const struct GNUNET_PeerIdentity *peers)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "View was updated (%" PRIu64 ")\n", view_size);
- struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
- to_file ("/tmp/rps/view_sizes.txt",
- "%" PRIu32 " %" PRIu64 "",
- rps_peer->index,
- view_size);
- for (uint64_t i = 0; i < view_size; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t%s\n", GNUNET_i2s (&peers[i]));
- }
- GNUNET_array_grow (rps_peer->cur_view,
- rps_peer->cur_view_count,
- view_size);
- // *rps_peer->cur_view = *peers;
- GNUNET_memcpy (rps_peer->cur_view,
- peers,
- view_size * sizeof(struct GNUNET_PeerIdentity));
- to_file ("/tmp/rps/count_in_views.txt",
- "%" PRIu32 " %" PRIu32 "",
- rps_peer->index,
- count_peer_in_views_2 (rps_peer->index));
- cumulated_view_sizes ();
- if (0 != view_size)
- {
- to_file ("/tmp/rps/repr.txt",
- "%" PRIu32 /* index */
- " %" PRIu32 /* occurrence in views */
- " %" PRIu32 /* view sizes */
- " %f" /* fraction of repr in views */
- " %f" /* average view size */
- " %f" /* prob of occurrence in view slot */
- " %f" "", /* exp frac of repr in views */
- rps_peer->index,
- count_peer_in_views_2 (rps_peer->index),
- view_sizes,
- count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /*
fraction of representation in views */
- view_sizes / (view_size * 1.0), /* average view size */
- 1.0 / view_size, /* prob of occurrence in view slot */
- (1.0 / view_size) * (view_sizes / view_size) /* expected
fraction of repr in views */
- );
- }
- compute_probabilities (rps_peer->index);
- all_views_updated_cb ();
-}
-
-
-static void
-pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
-{
- rps_peer->file_name_probs =
- store_prefix_file_name (rps_peer->index, "probs");
- rps_peer->file_name_probs_hist =
- store_prefix_file_name (rps_peer->index, "probs_hist");
- rps_peer->eval_probs_cache = GNUNET_new_array (num_peers, double);
- memset (rps_peer->eval_probs_cache, 0, num_peers * sizeof (double));
- GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
-}
-
-void
-write_final_stats (void)
-{
- uint64_t sums[STAT_TYPE_MAX] = { 0 };
-
- for (uint32_t i = 0; i < num_peers; i++)
- {
- to_file ("/tmp/rps/final_stats.csv",
- "%" PRIu32 ", " /* index */
- "%s, %" /* id */
- PRIu64 ", %" /* rounds */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %"
- PRIu64 ", %"
/* blocking */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %"
/* issued */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %"
- PRIu64 ", %"
/* recv */
- PRIu64 ", %" /* view size */
- PRIu64 ", %" /* known peers */
- PRIu64 ", %" /* valid peers */
- PRIu64 ", %" /* learned peers */
- PRIu64 ", %" /* pending online checks */
- PRIu64 ", %" /* unrequested pull replies */
- PRIu64 ", %" /* peers in push map */
- PRIu64 ", %" /* peers in pull map */
- PRIu64 ", %" /* peers in view */
- PRIu64 "\n" /* view size aim */,
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- rps_peers[i].stats[STAT_TYPE_ROUNDS],
- rps_peers[i].stats[STAT_TYPE_BLOCKS],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PULL],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND_MH],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ_MH],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REP],
- rps_peers[i].stats[STAT_TYPE_SENT_PUSH_SEND],
- rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ],
- rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ_MH],
- rps_peers[i].stats[STAT_TYPE_SENT_PULL_REP],
- rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND],
- rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND_MH],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ_MH],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP_MH],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP],
- rps_peers[i].stats[STAT_TYPE_VIEW_SIZE],
- rps_peers[i].stats[STAT_TYPE_KNOWN_PEERS],
- rps_peers[i].stats[STAT_TYPE_VALID_PEERS],
- rps_peers[i].stats[STAT_TYPE_LEARND_PEERS],
- rps_peers[i].stats[STAT_TYPE_PENDING_ONLINE_CHECKS],
- rps_peers[i].stats[STAT_TYPE_UNREQUESTED_PULL_REPLIES],
- rps_peers[i].stats[STAT_TYPE_PEERS_IN_PUSH_MAP],
- rps_peers[i].stats[STAT_TYPE_PEERS_IN_PULL_MAP],
- rps_peers[i].stats[STAT_TYPE_PEERS_IN_VIEW],
- rps_peers[i].stats[STAT_TYPE_VIEW_SIZE_AIM]);
- for (enum STAT_TYPE stat_type = STAT_TYPE_ROUNDS;
- stat_type < STAT_TYPE_MAX;
- stat_type++)
- {
- sums[stat_type] += rps_peers[i].stats[stat_type];
- }
- }
- to_file ("/tmp/rps/final_stats.dat",
- "SUM %"
- PRIu64 " %" /* rounds */
- PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64
- " %"
/* blocking */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /*
issued */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %"
- PRIu64 ", %"
/* recv */
- PRIu64 ", %" /* view size */
- PRIu64 ", %" /* known peers */
- PRIu64 ", %" /* valid peers */
- PRIu64 ", %" /* learned peers */
- PRIu64 ", %" /* pending online checks */
- PRIu64 ", %" /* unrequested pull replies */
- PRIu64 ", %" /* peers in push map */
- PRIu64 ", %" /* peers in pull map */
- PRIu64 ", %" /* peers in view */
- PRIu64 "\n" /* view size aim */,
- sums[STAT_TYPE_ROUNDS],
- sums[STAT_TYPE_BLOCKS],
- sums[STAT_TYPE_BLOCKS_MANY_PUSH],
- sums[STAT_TYPE_BLOCKS_NO_PUSH],
- sums[STAT_TYPE_BLOCKS_NO_PULL],
- sums[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
- sums[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
- sums[STAT_TYPE_ISSUED_PUSH_SEND],
- sums[STAT_TYPE_ISSUED_PUSH_SEND_MH],
- sums[STAT_TYPE_ISSUED_PULL_REQ],
- sums[STAT_TYPE_ISSUED_PULL_REQ_MH],
- sums[STAT_TYPE_ISSUED_PULL_REP],
- sums[STAT_TYPE_SENT_PUSH_SEND],
- sums[STAT_TYPE_SENT_PULL_REQ],
- sums[STAT_TYPE_SENT_PULL_REQ_MH],
- sums[STAT_TYPE_SENT_PULL_REP],
- sums[STAT_TYPE_RECV_PUSH_SEND],
- sums[STAT_TYPE_RECV_PUSH_SEND_MH],
- sums[STAT_TYPE_RECV_PULL_REQ],
- sums[STAT_TYPE_RECV_PULL_REQ_MH],
- sums[STAT_TYPE_RECV_PULL_REP],
- sums[STAT_TYPE_RECV_PULL_REP_MH],
- sums[STAT_TYPE_VIEW_SIZE],
- sums[STAT_TYPE_KNOWN_PEERS],
- sums[STAT_TYPE_VALID_PEERS],
- sums[STAT_TYPE_LEARND_PEERS],
- sums[STAT_TYPE_PENDING_ONLINE_CHECKS],
- sums[STAT_TYPE_UNREQUESTED_PULL_REPLIES],
- sums[STAT_TYPE_PEERS_IN_PUSH_MAP],
- sums[STAT_TYPE_PEERS_IN_PULL_MAP],
- sums[STAT_TYPE_PEERS_IN_VIEW],
- sums[STAT_TYPE_VIEW_SIZE_AIM]);
-}
-
-
-/**
- * Continuation called by #GNUNET_STATISTICS_get() functions.
- *
- * Remembers that this specific statistics value was received for this peer.
- * Checks whether all peers received their statistics yet.
- * Issues the shutdown.
- *
- * @param cls closure
- * @param success #GNUNET_OK if statistics were
- * successfully obtained, #GNUNET_SYSERR if not.
- */
-void
-post_test_shutdown_ready_cb (void *cls,
- int success)
-{
- struct STATcls *stat_cls = (struct STATcls *) cls;
- struct RPSPeer *rps_peer = stat_cls->rps_peer;
-
- rps_peer->h_stat_get[stat_cls->stat_type] = NULL;
- if (GNUNET_OK == success)
- {
- /* set flag that we we got the value */
- rps_peer->stat_collected_flags |= BIT (stat_cls->stat_type);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Peer %u did not receive statistics value\n",
- rps_peer->index);
- GNUNET_free (stat_cls);
- GNUNET_break (0);
- return;
- }
-
- if ((NULL != rps_peer->stat_op) &&
- (GNUNET_YES == check_statistics_collect_completed_single_peer (
- rps_peer)) )
- {
- GNUNET_TESTBED_operation_done (rps_peer->stat_op);
- }
-
- write_final_stats ();
- if (GNUNET_YES == check_statistics_collect_completed ())
- {
- // write_final_stats ();
- GNUNET_free (stat_cls);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down\n");
- GNUNET_SCHEDULER_shutdown ();
- }
- else
- {
- GNUNET_free (stat_cls);
- }
-}
-
-
-/**
- * Callback function to process statistic values.
- *
- * @param cls closure
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if
not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-int
-stat_iterator (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- const struct STATcls *stat_cls = (const struct STATcls *) cls;
- struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
- enum STAT_TYPE stat_type;
-
- (void) subsystem;
- (void) is_persistent;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got stat value: %s - %" PRIu64 " (%u)\n",
- name,
- value,
- rps_peer->index);
- to_file (rps_peer->file_name_stats,
- "%s: %" PRIu64 "\n",
- name,
- value);
- stat_type = stat_str_2_type (name);
- GNUNET_assert (STAT_TYPE_ROUNDS <= stat_type &&
- STAT_TYPE_MAX > stat_type);
- rps_peer->stats[stat_type] = value;
- return GNUNET_OK;
-}
-
-
-void
-post_profiler (struct RPSPeer *rps_peer)
-{
- if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics)
- {
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Going to request statistic values with mask 0x%" PRIx32 "\n",
- cur_test_run.stat_collect_flags);
-
- struct STATcls *stat_cls;
- uint32_t stat_type;
- for (stat_type = STAT_TYPE_ROUNDS;
- stat_type < STAT_TYPE_MAX;
- stat_type++)
- {
- if (BIT (stat_type) & cur_test_run.stat_collect_flags)
- {
- stat_cls = GNUNET_malloc (sizeof(struct STATcls));
- stat_cls->rps_peer = rps_peer;
- stat_cls->stat_type = stat_type;
- rps_peer->file_name_stats =
- store_prefix_file_name (rps_peer->index, "stats");
- rps_peer->h_stat_get[stat_type] =
- GNUNET_STATISTICS_get (rps_peer->stats_h,
- "rps",
- stat_type_strings [stat_type],
- post_test_shutdown_ready_cb,
- stat_iterator,
- (struct STATcls *) stat_cls);
- GNUNET_assert (NULL != rps_peer->h_stat_get);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requested statistics for %s (peer %" PRIu32 ")\n",
- stat_type_strings [stat_type],
- rps_peer->index);
- }
- }
- GNUNET_free (rps_peer->eval_probs_cache);
-}
-
-
-/***********************************************************************
-* /Definition of tests
-***********************************************************************/
-
-
-/**
- * Actual "main" function for the testcase.
- *
- * @param cls closure
- * @param h the run handle
- * @param n_peers number of peers in 'peers'
- * @param peers handle to peers run in the testbed
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-test_run (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int n_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- unsigned int i;
- struct OpListEntry *entry;
-
- (void) cls;
- (void) h;
- (void) links_failed;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
-
- /* Check whether we timed out */
- if ((n_peers != num_peers) ||
- (NULL == peers) ||
- (0 == links_succeeded) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Going down due to args (eg. timeout)\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tn_peers: %u\n", n_peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n",
- num_peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n",
- links_succeeded);
- ok = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
-
- /* Initialize peers */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "going to initialise peers\n");
- testbed_peers = peers;
- num_peers_online = 0;
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "initialising %u\n", i);
- entry = make_oplist_entry ();
- entry->index = i;
- rps_peers[i].index = i;
- if (NULL != cur_test_run.init_peer)
- cur_test_run.init_peer (&rps_peers[i]);
- if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
- {
- rps_peers->cur_view_count = 0;
- rps_peers->cur_view = NULL;
- }
- entry->op = GNUNET_TESTBED_peer_get_information (peers[i],
-
GNUNET_TESTBED_PIT_IDENTITY,
- &info_cb,
- entry);
- }
-
- /* Bring peers up */
- GNUNET_assert (num_peers == n_peers);
- for (i = 0; i < n_peers; i++)
- {
- rps_peers[i].index = i;
- rps_peers[i].op =
- GNUNET_TESTBED_service_connect (&rps_peers[i],
- peers[i],
- "rps",
- &rps_connect_complete_cb,
- &rps_peers[i],
- &rps_connect_adapter,
- &rps_disconnect_adapter,
- &rps_peers[i]);
- /* Connect all peers to statistics service */
- if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting to statistics service\n");
- rps_peers[i].stat_op =
- GNUNET_TESTBED_service_connect (NULL,
- peers[i],
- "statistics",
- stat_complete_cb,
- &rps_peers[i],
- &stat_connect_adapter,
- &stat_disconnect_adapter,
- &rps_peers[i]);
- }
- }
-
- if (NULL != churn_task)
- GNUNET_SCHEDULER_cancel (churn_task);
- post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op,
NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n",
- timeout.rel_value_us / 1000000);
- shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout,
- &trigger_shutdown,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL);
-}
-
-
-/**
- * Entry point for the testcase, sets up the testbed.
- *
- * @param argc unused
- * @param argv unused
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- // int ret_value;
- (void) cls;
- (void) args;
- (void) cfgfile;
-
- /* Defaults for tests */
- churn_task = NULL;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n");
- cur_test_run.name = "test-rps-profiler";
- if (0 == num_peers)
- num_peers = 10;
- mal_type = 3;
- cur_test_run.init_peer = profiler_init_peer;
- // cur_test_run.pre_test = mal_pre;
- cur_test_run.pre_test = pre_profiler;
- cur_test_run.main_test = profiler_cb;
- cur_test_run.reply_handle = profiler_reply_handle;
- cur_test_run.eval_cb = profiler_eval;
- cur_test_run.post_test = post_profiler;
- cur_test_run.request_interval = 2;
- if (0 == cur_test_run.num_requests)
- cur_test_run.num_requests = 5;
- // cur_test_run.have_churn = HAVE_CHURN;
- cur_test_run.have_churn = HAVE_NO_CHURN;
- cur_test_run.have_quick_quit = HAVE_QUICK_QUIT;
- cur_test_run.have_collect_statistics = COLLECT_STATISTICS;
- cur_test_run.stat_collect_flags = BIT (STAT_TYPE_ROUNDS)
- | BIT (STAT_TYPE_BLOCKS)
- | BIT (STAT_TYPE_BLOCKS_MANY_PUSH)
- | BIT (STAT_TYPE_BLOCKS_NO_PUSH)
- | BIT (STAT_TYPE_BLOCKS_NO_PULL)
- | BIT (STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL)
- | BIT (STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL)
- | BIT (STAT_TYPE_ISSUED_PUSH_SEND)
- | BIT (STAT_TYPE_ISSUED_PUSH_SEND_MH)
- | BIT (STAT_TYPE_ISSUED_PULL_REQ)
- | BIT (STAT_TYPE_ISSUED_PULL_REQ_MH)
- | BIT (STAT_TYPE_ISSUED_PULL_REP)
- | BIT (STAT_TYPE_SENT_PUSH_SEND)
- | BIT (STAT_TYPE_SENT_PULL_REQ)
- | BIT (STAT_TYPE_SENT_PULL_REQ_MH)
- | BIT (STAT_TYPE_SENT_PULL_REP)
- | BIT (STAT_TYPE_RECV_PUSH_SEND)
- | BIT (STAT_TYPE_RECV_PUSH_SEND_MH)
- | BIT (STAT_TYPE_RECV_PULL_REQ)
- | BIT (STAT_TYPE_RECV_PULL_REQ_MH)
- | BIT (STAT_TYPE_RECV_PULL_REP)
- | BIT (STAT_TYPE_RECV_PULL_REP_MH)
- | BIT (STAT_TYPE_VIEW_SIZE)
- | BIT (STAT_TYPE_KNOWN_PEERS)
- | BIT (STAT_TYPE_VALID_PEERS)
- | BIT (STAT_TYPE_LEARND_PEERS)
- | BIT (STAT_TYPE_PENDING_ONLINE_CHECKS)
- | BIT (STAT_TYPE_UNREQUESTED_PULL_REPLIES)
- | BIT (STAT_TYPE_PEERS_IN_PUSH_MAP)
- | BIT (STAT_TYPE_PEERS_IN_PULL_MAP)
- | BIT (STAT_TYPE_PEERS_IN_VIEW)
- | BIT (STAT_TYPE_VIEW_SIZE_AIM);
- cur_test_run.have_collect_view = COLLECT_VIEW;
-
- /* 'Clean' directory */
- (void) GNUNET_DISK_directory_remove ("/tmp/rps/");
- GNUNET_DISK_directory_create ("/tmp/rps/");
- if (0 == duration.rel_value_us)
- {
- if (0 == timeout.rel_value_us)
- {
- duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90);
- timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- (90 * 1.2)
- + (0.01 * num_peers));
- }
- else
- {
- duration = GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_SECONDS,
- ( (double) timeout.rel_value_us / (double) 1000000)
- * 0.75);
- }
- }
- else
- {
- if (0 == timeout.rel_value_us)
- {
- timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- ((duration.rel_value_us
- / 1000000)
- * 1.2) + (0.01 * num_peers));
- }
- }
- GNUNET_assert (duration.rel_value_us < timeout.rel_value_us);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "duration is %lus\n",
- duration.rel_value_us / 1000000);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "timeout is %lus\n",
- timeout.rel_value_us / 1000000);
-
- /* Compute number of bits for representing largest peer id */
- for (bits_needed = 1; (uint32_t) (1 << bits_needed) < num_peers;
bits_needed++)
- ;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Need %u bits to represent %" PRIu32 " peers\n",
- bits_needed,
- num_peers);
-
- rps_peers = GNUNET_new_array (num_peers, struct RPSPeer);
- peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO);
- rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity);
- if ((2 == mal_type) ||
- (3 == mal_type))
- target_peer = &rps_peer_ids[num_peers - 2];
-
- ok = 1;
- GNUNET_TESTBED_run (NULL,
- cfg,
- num_peers,
- 0, /* event mask */
- NULL,
- NULL,
- &test_run,
- NULL);
-}
-
-
-/**
- * Entry point for the testcase, sets up the testbed.
- *
- * @param argc unused
- * @param argv unused
- * @return 0 on success
- */
-int
-main (int argc, char *argv[])
-{
- int ret_value;
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint ('n',
- "num-peers",
- "COUNT",
- gettext_noop ("number of peers to start"),
- &num_peers),
- GNUNET_GETOPT_option_relative_time ('d',
- "duration",
- "DURATION",
- gettext_noop (
- "duration of the profiling"),
- &duration),
- GNUNET_GETOPT_option_relative_time ('t',
- "timeout",
- "TIMEOUT",
- gettext_noop (
- "timeout for the profiling"),
- &timeout),
- GNUNET_GETOPT_option_uint ('r',
- "num-requests",
- "COUNT",
- gettext_noop ("number of PeerIDs to request"),
- &cur_test_run.num_requests),
- GNUNET_GETOPT_OPTION_END
- };
-
- unsetenv ("XDG_DATA_HOME");
- unsetenv ("XDG_CONFIG_HOME");
- // if (GNUNET_OK !=
- // GNUNET_STRINGS_get_utf8_args (argc, argv,
- // &argc, &argv))
- // return 2;
- ret_value = 0;
- if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-rps-profiler",
- gettext_noop (
- "Measure quality and performance of the RPS
service."),
- options,
- &run,
- NULL))
- {
- ret_value = 1;
- }
- if (0 != ret_value)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Test did not run successfully!\n");
- }
- else
- {
- ret_value = cur_test_run.eval_cb ();
- if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
- {
- GNUNET_array_grow (rps_peers->cur_view,
- rps_peers->cur_view_count,
- 0);
- }
- GNUNET_free (rps_peers);
- GNUNET_free (rps_peer_ids);
- GNUNET_CONTAINER_multipeermap_destroy (peer_map);
- }
- return ret_value;
-}
-
-
-/* end of test_rps.c */
diff --git a/src/contrib/service/secretsharing/Makefile.am
b/src/contrib/service/secretsharing/Makefile.am
index afc42309c..d9c2b37b4 100644
--- a/src/contrib/service/secretsharing/Makefile.am
+++ b/src/contrib/service/secretsharing/Makefile.am
@@ -16,23 +16,10 @@ endif
libexec_PROGRAMS = \
gnunet-service-secretsharing
-#noinst_PROGRAMS = \
-# gnunet-secretsharing-profiler
-
lib_LTLIBRARIES = \
libgnunetsecretsharing.la
-# TNG
-#gnunet_secretsharing_profiler_SOURCES = \
-# gnunet-secretsharing-profiler.c
-#gnunet_secretsharing_profiler_LDADD = \
-# libgnunetsecretsharing.la \
-# $(top_builddir)/src/service/testing/libgnunettesting.la \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(GN_LIBINTL)
-
gnunet_service_secretsharing_SOURCES = \
gnunet-service-secretsharing.c \
secretsharing_common.c \
diff --git a/src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c
b/src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c
deleted file mode 100644
index 432d6da89..000000000
--- a/src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c
+++ /dev/null
@@ -1,662 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2014 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file secretsharing/gnunet-secretsharing-profiler.c
- * @brief profiling tool for distributed key generation and decryption
- * @author Florian Dold
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_secretsharing_service.h"
-#include "gnunet_testbed_service.h"
-
-/**
- * How many peers should participate in the key generation?
- */
-static unsigned int num_peers = 3;
-
-/**
- * What should the threshold for then key be?
- */
-static unsigned int threshold = 2;
-
-/**
- * Should we try to decrypt a value after the key generation?
- */
-static int decrypt = GNUNET_NO;
-
-/**
- * When would we like to see the operation finished?
- */
-static struct GNUNET_TIME_Relative timeout;
-
-/**
- * When should dkg communication start?
- */
-static struct GNUNET_TIME_Relative delay;
-
-/**
- * Handles for secretsharing sessions.
- */
-static struct GNUNET_SECRETSHARING_Session **session_handles;
-
-static struct GNUNET_SECRETSHARING_DecryptionHandle **decrypt_handles;
-
-/**
- * Shares we got from the distributed key generation.
- */
-static struct GNUNET_SECRETSHARING_Share **shares;
-
-static struct GNUNET_SECRETSHARING_PublicKey common_pubkey;
-
-
-static unsigned int num_connected_sessions;
-
-static unsigned int num_connected_decrypt;
-
-/**
- * Handles to the running peers.
- * When peers[i] is NULL, the i-th peer has stopped.
- */
-static struct GNUNET_TESTBED_Peer **peers;
-
-static struct GNUNET_PeerIdentity *peer_ids;
-
-static unsigned int num_retrieved_peer_ids;
-
-static unsigned int num_generated;
-
-static unsigned int num_decrypted;
-
-static struct GNUNET_HashCode session_id;
-
-static unsigned int verbose;
-
-static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext;
-
-static struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
-
-static struct GNUNET_TIME_Absolute dkg_start;
-
-static struct GNUNET_TIME_Absolute dkg_deadline;
-
-
-static struct GNUNET_TIME_Absolute decrypt_start;
-
-static struct GNUNET_TIME_Absolute decrypt_deadline;
-
-/**
- * Connect operations, one for every peer.
- */
-static struct GNUNET_TESTBED_Operation **connect_ops;
-
-/**
- * Are we performing a shutdown right now?
- */
-static int in_shutdown;
-
-
-/**
- * Signature of the event handler function called by the
- * respective event controller.
- *
- * @param cls closure
- * @param event information about the event
- */
-static void
-controller_cb (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
-{
- GNUNET_assert (0);
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from
GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-session_connect_complete (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "testbed connect emsg: %s\n",
- emsg);
- GNUNET_assert (0);
- }
-
- num_connected_sessions++;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "dkg: session connect complete\n");
-
- if (num_connected_sessions == num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "dkg: all peers connected\n");
- }
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from
GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-decrypt_connect_complete (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "testbed connect emsg: %s\n",
- emsg);
- GNUNET_assert (0);
- }
-
- num_connected_decrypt++;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt: session connect complete\n");
-
- if (num_connected_decrypt == num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt: all peers connected\n");
- }
-}
-
-
-/**
- * Called when a decryption has succeeded.
- *
- * @param cls Plaintext
- * @param plaintext Plaintext
- */
-static void
-decrypt_cb (void *cls,
- const struct GNUNET_SECRETSHARING_Plaintext *plaintext)
-{
- struct GNUNET_SECRETSHARING_DecryptionHandle **dhp = cls;
- unsigned int n = dhp - decrypt_handles;
-
- num_decrypted++;
-
- *dhp = NULL;
-
- // we should still be connected if this is called
- GNUNET_assert (NULL != connect_ops[n]);
-
- GNUNET_TESTBED_operation_done (connect_ops[n]);
-
- if (NULL == plaintext)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt failed for peer %u\n", n);
- return;
- }
- else if (0 == GNUNET_memcmp (&reference_plaintext, plaintext))
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt got correct result for peer %u\n", n);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "decrypt got wrong result for peer %u\n", n);
-
- if (num_decrypted == num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "every peer decrypted\n");
- GNUNET_SCHEDULER_shutdown ();
- }
-
- *dhp = NULL;
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * a service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-decrypt_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_SECRETSHARING_DecryptionHandle **hp = cls;
- unsigned int n = hp - decrypt_handles;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt connect adapter, %d peers\n",
- num_peers);
- *hp = GNUNET_SECRETSHARING_decrypt (cfg, shares[n], &ciphertext,
- decrypt_start, decrypt_deadline,
- decrypt_cb,
- hp);
-
- return *hp;
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * a service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-decrypt_disconnect_adapter (void *cls, void *op_result)
-{
- struct GNUNET_SECRETSHARING_DecryptionHandle **dh = cls;
- unsigned int n = dh - decrypt_handles;
-
- GNUNET_assert (*dh == decrypt_handles[n]);
-
- if (NULL != *dh)
- {
- GNUNET_SECRETSHARING_decrypt_cancel (*dh);
- *dh = NULL;
- }
-
- GNUNET_assert (NULL != connect_ops[n]);
- connect_ops[n] = NULL;
-}
-
-
-static void
-secret_ready_cb (void *cls,
- struct GNUNET_SECRETSHARING_Share *my_share,
- struct GNUNET_SECRETSHARING_PublicKey *public_key,
- unsigned int num_ready_peers,
- const struct GNUNET_PeerIdentity *ready_peers)
-{
- struct GNUNET_SECRETSHARING_Session **sp = cls;
- unsigned int n = sp - session_handles;
- char pubkey_str[1024];
- char *ret;
-
- num_generated++;
- *sp = NULL;
- shares[n] = my_share;
- if (NULL == my_share)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "key generation failed for peer #%u\n",
- n);
- }
- else
- {
- ret = GNUNET_STRINGS_data_to_string (public_key, sizeof *public_key,
- pubkey_str, 1024);
- GNUNET_assert (NULL != ret);
- *ret = '\0';
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "key generation successful for peer #%u, pubkey %s\n", n,
- pubkey_str);
-
- /* we're the first to get the key -> store it */
- if (num_generated == 1)
- {
- common_pubkey = *public_key;
- }
- else if (0 != GNUNET_memcmp (public_key, &common_pubkey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "generated public keys do not match\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- }
-
- // we should still be connected
- GNUNET_assert (NULL != connect_ops[n]);
-
- // disconnect from the service, will call the disconnect callback
- GNUNET_TESTBED_operation_done (connect_ops[n]);
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * a service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-session_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_SECRETSHARING_Session **sp = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "connect adapter, %d peers\n",
- num_peers);
- *sp = GNUNET_SECRETSHARING_create_session (cfg,
- num_peers,
- peer_ids,
- &session_id,
- dkg_start,
- dkg_deadline,
- threshold,
- &secret_ready_cb, sp);
- return *sp;
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * a service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-session_disconnect_adapter (void *cls, void *op_result)
-{
- struct GNUNET_SECRETSHARING_Session **sp = cls;
- unsigned int n = (sp - session_handles);
-
- GNUNET_assert (*sp == session_handles[n]);
-
- if (NULL != *sp)
- {
- GNUNET_SECRETSHARING_session_destroy (*sp);
- *sp = NULL;
- }
-
- GNUNET_assert (NULL != connect_ops[n]);
- connect_ops[n] = NULL;
-
- if (GNUNET_YES == in_shutdown)
- return;
-
- // all peers received their secret
- if (num_generated == num_peers)
- {
- int i;
-
- // only do decryption if requested by the user
- if (GNUNET_NO == decrypt)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- decrypt_start = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
- delay);
- decrypt_deadline = GNUNET_TIME_absolute_add (decrypt_start, timeout);
-
- // compute g^42 as the plaintext which we will decrypt and then
- // cooperatively decrypt
- GNUNET_SECRETSHARING_plaintext_generate_i (&reference_plaintext, 42);
- GNUNET_SECRETSHARING_encrypt (&common_pubkey, &reference_plaintext,
- &ciphertext);
-
- for (i = 0; i < num_peers; i++)
- connect_ops[i] =
- GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing",
- &decrypt_connect_complete, NULL,
- &decrypt_connect_adapter,
- &decrypt_disconnect_adapter,
- &decrypt_handles[i]);
- }
-}
-
-
-/**
- * Callback to be called when the requested peer information is available
- *
- * @param cb_cls the closure from GNUNET_TESTBED_peer_get_information()
- * @param op the operation this callback corresponds to
- * @param pinfo the result; will be NULL if the operation has failed
- * @param emsg error message if the operation has failed; will be NULL if the
- * operation is successful
- */
-static void
-peer_info_cb (void *cb_cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct GNUNET_PeerIdentity *p;
- int i;
-
- GNUNET_assert (NULL == emsg);
-
- p = (struct GNUNET_PeerIdentity *) cb_cls;
-
- if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY)
- {
- *p = *pinfo->result.id;
- num_retrieved_peer_ids++;
- if (num_retrieved_peer_ids == num_peers)
- for (i = 0; i < num_peers; i++)
- connect_ops[i] =
- GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing",
- session_connect_complete, NULL,
- session_connect_adapter,
- session_disconnect_adapter,
- &session_handles[i]);
- }
- else
- {
- GNUNET_assert (0);
- }
-
- GNUNET_TESTBED_operation_done (op);
-}
-
-
-/**
- * Signature of the main function of a task.
- *
- * @param cls closure
- */
-static void
-handle_shutdown (void *cls)
-{
- in_shutdown = GNUNET_YES;
-
- if (NULL != connect_ops)
- {
- unsigned int i;
- for (i = 0; i < num_peers; i++)
- if (NULL != connect_ops[i])
- {
- // the disconnect callback will set the op to NULL
- GNUNET_TESTBED_operation_done (connect_ops[i]);
- }
- GNUNET_free (connect_ops);
- }
-
- // killing the testbed operation will take care of remaining
- // service handles in the disconnect callback
-}
-
-
-/**
- * Signature of a main function for a testcase.
- *
- * @param cls closure
- * @param h the run handle
- * @param num_peers number of peers in 'peers'
- * @param started_peers handle to peers run in the testbed. NULL upon timeout
(see
- * GNUNET_TESTBED_test_run()).
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-test_master (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **started_peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- int i;
-
- GNUNET_log_setup ("gnunet-secretsharing-profiler", "INFO", NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n");
-
- GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL);
-
- peers = started_peers;
-
- peer_ids = GNUNET_malloc (num_peers * sizeof(struct GNUNET_PeerIdentity));
-
- session_handles = GNUNET_new_array (num_peers, struct
- GNUNET_SECRETSHARING_Session *);
- decrypt_handles = GNUNET_new_array (num_peers, struct
- GNUNET_SECRETSHARING_DecryptionHandle *);
- connect_ops = GNUNET_new_array (num_peers, struct GNUNET_TESTBED_Operation
*);
- shares = GNUNET_new_array (num_peers, struct GNUNET_SECRETSHARING_Share *);
-
- for (i = 0; i < num_peers; i++)
- {
- // we do not store the returned operation, as peer_info_cb
- // will receive it as a parameter and call GNUNET_TESTBED_operation_done.
- GNUNET_TESTBED_peer_get_information (peers[i],
- GNUNET_TESTBED_PIT_IDENTITY,
- peer_info_cb,
- &peer_ids[i]);
- }
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- static char *session_str = "gnunet-secretsharing/test";
- char *topology;
- int topology_cmp_result;
-
- dkg_start = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay);
- dkg_deadline = GNUNET_TIME_absolute_add (dkg_start, timeout);
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
- "OVERLAY_TOPOLOGY",
- &topology))
- {
- fprintf (stderr,
- "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, "
- "seems like you passed the wrong configuration file\n");
- return;
- }
-
- topology_cmp_result = strcasecmp (topology, "NONE");
- GNUNET_free (topology);
-
- if (0 == topology_cmp_result)
- {
- fprintf (stderr,
- "'OVERLAY_TOPOLOGY' set to 'NONE', "
- "seems like you passed the wrong configuration file\n");
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "running gnunet-secretsharing-profiler\n");
-
- GNUNET_CRYPTO_hash (session_str, strlen (session_str), &session_id);
-
- (void) GNUNET_TESTBED_test_run ("gnunet-secretsharing-profiler",
- cfgfile,
- num_peers,
- 0,
- controller_cb,
- NULL,
- test_master,
- NULL);
-}
-
-
-int
-main (int argc, char **argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint ('n',
- "num-peers",
- NULL,
- gettext_noop ("number of peers in consensus"),
- &num_peers),
-
- GNUNET_GETOPT_option_relative_time ('D',
- "delay",
- NULL,
- gettext_noop ("dkg start delay"),
- &delay),
-
- GNUNET_GETOPT_option_relative_time ('t',
- "timeout",
- NULL,
- gettext_noop ("dkg timeout"),
- &timeout),
-
- GNUNET_GETOPT_option_uint ('k',
- "threshold",
- NULL,
- gettext_noop ("threshold"),
- &threshold),
-
- GNUNET_GETOPT_option_flag ('d',
- "descrypt",
- gettext_noop ("also profile decryption"),
- &decrypt),
-
-
- GNUNET_GETOPT_option_verbose (&verbose),
-
- GNUNET_GETOPT_OPTION_END
- };
-
- delay = GNUNET_TIME_UNIT_ZERO;
- timeout = GNUNET_TIME_UNIT_MINUTES;
- GNUNET_PROGRAM_run2 (argc, argv, "gnunet-secretsharing-profiler",
- "help",
- options, &run, NULL, GNUNET_YES);
- return 0;
-}
diff --git a/src/service/cadet/cadet_test_lib.c
b/src/service/cadet/cadet_test_lib.c
deleted file mode 100644
index 9c7b9063d..000000000
--- a/src/service/cadet/cadet_test_lib.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012, 2017 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file cadet/cadet_test_lib.c
- * @author Bartlomiej Polot
- * @brief library for writing CADET tests
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "cadet_test_lib.h"
-#include "gnunet_cadet_service.h"
-
-
-/**
- * Test context for a CADET Test.
- */
-struct GNUNET_CADET_TEST_Context
-{
- /**
- * Array of running peers.
- */
- struct GNUNET_TESTBED_Peer **peers;
-
- /**
- * Array of handles to the CADET for each peer.
- */
- struct GNUNET_CADET_Handle **cadets;
-
- /**
- * Operation associated with the connection to the CADET.
- */
- struct GNUNET_TESTBED_Operation **ops;
-
- /**
- * Number of peers running, size of the arrays above.
- */
- unsigned int num_peers;
-
- /**
- * Main function of the test to run once all CADETs are available.
- */
- GNUNET_CADET_TEST_AppMain app_main;
-
- /**
- * Closure for 'app_main'.
- */
- void *app_main_cls;
-
- /**
- * Handler for incoming tunnels.
- */
- GNUNET_CADET_ConnectEventHandler connects;
-
- /**
- * Function called when the transmit window size changes.
- */
- GNUNET_CADET_WindowSizeEventHandler window_changes;
-
- /**
- * Cleaner for destroyed incoming tunnels.
- */
- GNUNET_CADET_DisconnectEventHandler disconnects;
-
- /**
- * Message handlers.
- */
- struct GNUNET_MQ_MessageHandler *handlers;
-
- /**
- * Application ports.
- */
- const struct GNUNET_HashCode **ports;
-
- /**
- * Number of ports in #ports.
- */
- unsigned int port_count;
-};
-
-
-/**
- * Context for a cadet adapter callback.
- */
-struct GNUNET_CADET_TEST_AdapterContext
-{
- /**
- * Peer number for the particular peer.
- */
- unsigned int peer;
-
- /**
- * Port handlers for open ports.
- */
- struct GNUNET_CADET_Port **ports;
-
- /**
- * General context.
- */
- struct GNUNET_CADET_TEST_Context *ctx;
-};
-
-
-/**
- * Adapter function called to establish a connection to
- * the CADET service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-cadet_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_CADET_TEST_AdapterContext *actx = cls;
- struct GNUNET_CADET_TEST_Context *ctx = actx->ctx;
- struct GNUNET_CADET_Handle *h;
-
- h = GNUNET_CADET_connect (cfg);
- if (NULL == h)
- {
- GNUNET_break (0);
- return NULL;
- }
- if (NULL == ctx->ports)
- return h;
- actx->ports = GNUNET_new_array (ctx->port_count,
- struct GNUNET_CADET_Port *);
- for (unsigned int i = 0; i < ctx->port_count; i++)
- {
- actx->ports[i] = GNUNET_CADET_open_port (h,
- ctx->ports[i],
- ctx->connects,
- (void *) (long) actx->peer,
- ctx->window_changes,
- ctx->disconnects,
- ctx->handlers);
- }
- return h;
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * the CADET service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-cadet_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct GNUNET_CADET_Handle *cadet = op_result;
- struct GNUNET_CADET_TEST_AdapterContext *actx = cls;
-
- if (NULL != actx->ports)
- {
- for (unsigned int i = 0; i < actx->ctx->port_count; i++)
- {
- GNUNET_CADET_close_port (actx->ports[i]);
- actx->ports[i] = NULL;
- }
- GNUNET_free (actx->ports);
- }
- GNUNET_free (actx);
- GNUNET_CADET_disconnect (cadet);
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed.
- *
- * @param cls The callback closure from functions generating an operation.
- * @param op The operation that has been finished.
- * @param ca_result The service handle returned from
- * GNUNET_TESTBED_ConnectAdapter() (cadet handle).
- * @param emsg Error message in case the operation has failed.
- * NULL if operation has executed successfully.
- */
-static void
-cadet_connect_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct GNUNET_CADET_TEST_Context *ctx = cls;
-
- if (NULL != emsg)
- {
- fprintf (stderr,
- "Failed to connect to CADET service: %s\n",
- emsg);
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (op == ctx->ops[i])
- {
- ctx->cadets[i] = ca_result;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "...cadet %u connected\n",
- i);
- }
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (NULL == ctx->cadets[i])
- return;
- /* still some CADET connections missing */
- /* all CADET connections ready! */
- ctx->app_main (ctx->app_main_cls,
- ctx,
- ctx->num_peers,
- ctx->peers,
- ctx->cadets);
-}
-
-
-void
-GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx)
-{
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- {
- GNUNET_assert (NULL != ctx->ops[i]);
- GNUNET_TESTBED_operation_done (ctx->ops[i]);
- ctx->ops[i] = NULL;
- }
- GNUNET_free (ctx->ops);
- GNUNET_free (ctx->cadets);
- GNUNET_free (ctx->handlers);
- GNUNET_free (ctx);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Callback run when the testbed is ready (peers running and connected to
- * each other)
- *
- * @param cls Closure (context).
- * @param h the run handle
- * @param num_peers Number of peers that are running.
- * @param peers Handles to each one of the @c num_peers peers.
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-cadet_test_run (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- struct GNUNET_CADET_TEST_Context *ctx = cls;
-
- if (0 != links_failed)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Some links failed (%u), ending\n",
- links_failed);
- exit (77);
- }
- if (num_peers != ctx->num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Peers started %u/%u, ending\n",
- num_peers,
- ctx->num_peers);
- exit (1);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Testbed up, %u peers and %u links\n",
- num_peers,
- links_succeeded);
- ctx->peers = peers;
- for (unsigned int i = 0; i < num_peers; i++)
- {
- struct GNUNET_CADET_TEST_AdapterContext *newctx;
-
- newctx = GNUNET_new (struct GNUNET_CADET_TEST_AdapterContext);
- newctx->peer = i;
- newctx->ctx = ctx;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Connecting to cadet %u\n",
- i);
- ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx,
- peers[i],
- "cadet",
- &cadet_connect_cb,
- ctx,
- &cadet_connect_adapter,
- &cadet_disconnect_adapter,
- newctx);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "op handle %p\n",
- ctx->ops[i]);
- }
-}
-
-
-/**
- * Run a test using the given name, configuration file and number of peers.
- * All cadet callbacks will receive the peer number (long) as the closure.
- *
- * @param testname Name of the test (for logging).
- * @param cfgfile Name of the configuration file.
- * @param num_peers Number of peers to start.
- * @param tmain Main function to run once the testbed is ready.
- * @param tmain_cls Closure for @a tmain.
- * @param connects Handler for incoming channels.
- * @param window_changes Handler for the window size change notification.
- * @param disconnects Cleaner for destroyed incoming channels.
- * @param handlers Message handlers.
- * @param ports Ports the peers offer, NULL-terminated.
- */
-void
-GNUNET_CADET_TEST_ruN (const char *testname,
- const char *cfgfile,
- unsigned int num_peers,
- GNUNET_CADET_TEST_AppMain tmain,
- void *tmain_cls,
- GNUNET_CADET_ConnectEventHandler connects,
- GNUNET_CADET_WindowSizeEventHandler window_changes,
- GNUNET_CADET_DisconnectEventHandler disconnects,
- struct GNUNET_MQ_MessageHandler *handlers,
- const struct GNUNET_HashCode **ports)
-{
- struct GNUNET_CADET_TEST_Context *ctx;
-
- ctx = GNUNET_new (struct GNUNET_CADET_TEST_Context);
- ctx->num_peers = num_peers;
- ctx->ops = GNUNET_new_array (num_peers,
- struct GNUNET_TESTBED_Operation *);
- ctx->cadets = GNUNET_new_array (num_peers,
- struct GNUNET_CADET_Handle *);
- ctx->app_main = tmain;
- ctx->app_main_cls = tmain_cls;
- ctx->connects = connects;
- ctx->window_changes = window_changes;
- ctx->disconnects = disconnects;
- ctx->handlers = GNUNET_MQ_copy_handlers (handlers);
- ctx->ports = ports;
- ctx->port_count = 0;
- while (NULL != ctx->ports[ctx->port_count])
- ctx->port_count++;
- GNUNET_TESTBED_test_run (testname,
- cfgfile,
- num_peers,
- 0LL, NULL, NULL,
- &cadet_test_run,
- ctx);
-}
-
-
-/* end of cadet_test_lib.c */
diff --git a/src/service/cadet/cadet_test_lib.h
b/src/service/cadet/cadet_test_lib.h
deleted file mode 100644
index 7d446801a..000000000
--- a/src/service/cadet/cadet_test_lib.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012,2017 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file cadet/cadet_test_lib.h
- * @author Bartlomiej Polot
- * @brief library for writing CADET tests
- */
-#ifndef CADET_TEST_LIB_H
-#define CADET_TEST_LIB_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-#include "gnunet_testbed_service.h"
-#include "gnunet_cadet_service.h"
-
-/**
- * Test context for a CADET Test.
- */
-struct GNUNET_CADET_TEST_Context;
-
-
-/**
- * Main function of a CADET test.
- *
- * @param cls Closure.
- * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
- * @param num_peers Number of peers that are running.
- * @param peers Array of peers.
- * @param cadets Handle to each of the CADETs of the peers.
- */
-typedef void (*GNUNET_CADET_TEST_AppMain) (void *cls,
- struct GNUNET_CADET_TEST_Context
*ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_CADET_Handle
**cadets);
-
-
-/**
- * Run a test using the given name, configuration file and number of peers.
- * All cadet callbacks will receive the peer number (long) as the closure.
- *
- * @param testname Name of the test (for logging).
- * @param cfgfile Name of the configuration file.
- * @param num_peers Number of peers to start.
- * @param tmain Main function to run once the testbed is ready.
- * @param tmain_cls Closure for @a tmain.
- * @param connects Handler for incoming channels.
- * @param window_changes Handler for the window size change notification.
- * @param disconnects Cleaner for destroyed incoming channels.
- * @param handlers Message handlers.
- * @param ports Ports the peers offer, NULL-terminated.
- */
-void
-GNUNET_CADET_TEST_ruN (const char *testname,
- const char *cfgfile,
- unsigned int num_peers,
- GNUNET_CADET_TEST_AppMain tmain,
- void *tmain_cls,
- GNUNET_CADET_ConnectEventHandler connects,
- GNUNET_CADET_WindowSizeEventHandler window_changes,
- GNUNET_CADET_DisconnectEventHandler disconnects,
- struct GNUNET_MQ_MessageHandler *handlers,
- const struct GNUNET_HashCode **ports);
-
-/**
- * Clean up the testbed.
- *
- * @param ctx handle for the testbed
- */
-void
-GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx);
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-
-/* ifndef CADET_TEST_LIB_H */
-#endif
diff --git a/src/service/dht/dht_test_lib.c b/src/service/dht/dht_test_lib.c
deleted file mode 100644
index 29c5088d1..000000000
--- a/src/service/dht/dht_test_lib.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/dht_test_lib.c
- * @author Christian Grothoff
- * @brief library for writing DHT tests
- */
-#include "platform.h"
-#include "dht_test_lib.h"
-
-/**
- * Test context for a DHT Test.
- */
-struct GNUNET_DHT_TEST_Context
-{
- /**
- * Array of running peers.
- */
- struct GNUNET_TESTBED_Peer **peers;
-
- /**
- * Array of handles to the DHT for each peer.
- */
- struct GNUNET_DHT_Handle **dhts;
-
- /**
- * Operation associated with the connection to the DHT.
- */
- struct GNUNET_TESTBED_Operation **ops;
-
- /**
- * Main function of the test to run once all DHTs are available.
- */
- GNUNET_DHT_TEST_AppMain app_main;
-
- /**
- * Closure for 'app_main'.
- */
- void *app_main_cls;
-
- /**
- * Number of peers running, size of the arrays above.
- */
- unsigned int num_peers;
-};
-
-
-/**
- * Adapter function called to establish a connection to
- * the DHT service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-dht_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- return GNUNET_DHT_connect (cfg, 16);
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * the DHT service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-dht_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct GNUNET_DHT_Handle *dht = op_result;
-
- GNUNET_DHT_disconnect (dht);
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from
GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-dht_connect_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- if (NULL != emsg)
- {
- fprintf (stderr,
- "Failed to connect to DHT service: %s\n",
- emsg);
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (op == ctx->ops[i])
- ctx->dhts[i] = ca_result;
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (NULL == ctx->dhts[i])
- return;
- /* still some DHT connections missing */
- /* all DHT connections ready! */
- ctx->app_main (ctx->app_main_cls,
- ctx,
- ctx->num_peers,
- ctx->peers,
- ctx->dhts);
-}
-
-
-void
-GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx)
-{
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- GNUNET_TESTBED_operation_done (ctx->ops[i]);
- GNUNET_free (ctx->ops);
- GNUNET_free (ctx->dhts);
- GNUNET_free (ctx);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-static void
-dht_test_run (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- GNUNET_assert (num_peers == ctx->num_peers);
- ctx->peers = peers;
- for (unsigned int i = 0; i < num_peers; i++)
- ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx,
- peers[i],
- "dht",
- &dht_connect_cb,
- ctx,
- &dht_connect_adapter,
- &dht_disconnect_adapter,
- ctx);
-}
-
-
-void
-GNUNET_DHT_TEST_run (const char *testname,
- const char *cfgname,
- unsigned int num_peers,
- GNUNET_DHT_TEST_AppMain tmain,
- void *tmain_cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx;
-
- ctx = GNUNET_new (struct GNUNET_DHT_TEST_Context);
- ctx->num_peers = num_peers;
- ctx->ops = GNUNET_new_array (num_peers,
- struct GNUNET_TESTBED_Operation *);
- ctx->dhts = GNUNET_new_array (num_peers,
- struct GNUNET_DHT_Handle *);
- ctx->app_main = tmain;
- ctx->app_main_cls = tmain_cls;
- (void) GNUNET_TESTBED_test_run (testname,
- cfgname,
- num_peers,
- 0LL, NULL, NULL,
- &dht_test_run, ctx);
-}
-
-
-/* end of dht_test_lib.c */
diff --git a/src/service/dht/dht_test_lib.h b/src/service/dht/dht_test_lib.h
deleted file mode 100644
index efffc9ef7..000000000
--- a/src/service/dht/dht_test_lib.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/dht_test_lib.h
- * @author Christian Grothoff
- * @brief library for writing DHT tests
- */
-#ifndef DHT_TEST_LIB_H
-#define DHT_TEST_LIB_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-#include "gnunet_testbed_service.h"
-#include "gnunet_dht_service.h"
-
-/**
- * Test context for a DHT Test.
- */
-struct GNUNET_DHT_TEST_Context;
-
-
-/**
- * Main function of a DHT test.
- *
- * @param cls closure
- * @param ctx argument to give to GNUNET_DHT_TEST_cleanup on test end
- * @param num_peers number of peers that are running
- * @param peers array of peers
- * @param dhts handle to each of the DHTs of the peers
- */
-typedef void (*GNUNET_DHT_TEST_AppMain) (void *cls,
- struct GNUNET_DHT_TEST_Context *ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_DHT_Handle **dhts);
-
-
-/**
- * Run a test using the given name, configuration file and number of
- * peers.
- *
- * @param testname name of the test (for logging)
- * @param cfgname name of the configuration file
- * @param num_peers number of peers to start
- * @param tmain main function to run once the testbed is ready
- * @param tmain_cls closure for 'tmain'
- */
-void
-GNUNET_DHT_TEST_run (const char *testname,
- const char *cfgname,
- unsigned int num_peers,
- GNUNET_DHT_TEST_AppMain tmain,
- void *tmain_cls);
-
-
-/**
- * Clean up the testbed.
- *
- * @param ctx handle for the testbed
- */
-void
-GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx);
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-/* ifndef DHT_TEST_LIB_H */
-#endif
diff --git a/src/service/dht/test_dht_monitor.c
b/src/service/dht/test_dht_monitor.c
deleted file mode 100644
index 3960a2235..000000000
--- a/src/service/dht/test_dht_monitor.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/test_dht_monitor.c
- * @brief Test for the dht monitoring API; checks that we receive "some"
monitor events
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_testbed_service.h"
-#include "gnunet_dht_service.h"
-#include "dht_test_lib.h"
-
-
-/**
- * How long do we run the test at most?
- */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
-
-/**
- * How often do we run the PUTs?
- */
-#define PUT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
\
- 10)
-
-
-/**
- * Information we keep for each GET operation.
- */
-struct GetOperation
-{
- /**
- * DLL.
- */
- struct GetOperation *next;
-
- /**
- * DLL.
- */
- struct GetOperation *prev;
-
- /**
- * Handle for the operation.
- */
- struct GNUNET_DHT_GetHandle *get;
-};
-
-
-/**
- * Return value from 'main'.
- */
-static int ok;
-
-/**
- * Head of list of active GET operations.
- */
-static struct GetOperation *get_head;
-
-/**
- * Tail of list of active GET operations.
- */
-static struct GetOperation *get_tail;
-
-/**
- * Array of the testbed's peers.
- */
-static struct GNUNET_TESTBED_Peer **my_peers;
-
-/**
- * Number of peers to run.
- */
-static unsigned int NUM_PEERS = 3;
-
-/**
- * Task called to disconnect peers.
- */
-static struct GNUNET_SCHEDULER_Task *timeout_task;
-
-/**
- * Task to do DHT_puts
- */
-static struct GNUNET_SCHEDULER_Task *put_task;
-
-static struct GNUNET_DHT_MonitorHandle **monitors;
-
-static unsigned int monitor_counter;
-
-
-/**
- * Task run on success or timeout to clean up.
- * Terminates active get operations and shuts down
- * the testbed.
- *
- * @param cls the `struct GNUNET_DHT_TEST_Context`
- */
-static void
-shutdown_task (void *cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
- unsigned int i;
- struct GetOperation *get_op;
-
- ok = (monitor_counter > NUM_PEERS) ? 0 : 2;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Received %u monitor events\n",
- monitor_counter);
- while (NULL != (get_op = get_tail))
- {
- GNUNET_DHT_get_stop (get_op->get);
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- }
- for (i = 0; i < NUM_PEERS; i++)
- GNUNET_DHT_monitor_stop (monitors[i]);
- GNUNET_free (monitors);
- GNUNET_SCHEDULER_cancel (put_task);
- GNUNET_DHT_TEST_cleanup (ctx);
- if (NULL != timeout_task)
- {
- GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = NULL;
- }
-}
-
-
-/**
- * Task run on success or timeout to clean up.
- * Terminates active get operations and shuts down
- * the testbed.
- *
- * @param cls NULL
- */
-static void
-timeout_task_cb (void *cls)
-{
- timeout_task = NULL;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Iterator called on each result obtained for a DHT
- * operation that expects a reply
- *
- * @param cls closure with our 'struct GetOperation'
- * @param exp when will this value expire
- * @param key key of the result
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param get_path peers on reply path (or NULL if not recorded)
- * @param get_path_length number of entries in get_path
- * @param put_path peers on the PUT path (or NULL if not recorded)
- * @param put_path_length number of entries in get_path
- * @param type type of the result
- * @param size number of bytes in data
- * @param data pointer to the result data
- */
-static void
-dht_get_handler (void *cls, struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *key,
- const struct GNUNET_PeerIdentity *trunc_peer,
- const struct GNUNET_DHT_PathElement *get_path,
- unsigned int get_path_length,
- const struct GNUNET_DHT_PathElement *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type,
- size_t size, const void *data)
-{
- struct GetOperation *get_op = cls;
- struct GNUNET_HashCode want;
-
- if (sizeof(struct GNUNET_HashCode) != size)
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_CRYPTO_hash (key,
- sizeof(*key),
- &want);
- if (0 != memcmp (&want, data, sizeof(want)))
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Get successful\n");
- GNUNET_DHT_get_stop (get_op->get);
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- if (NULL != get_head)
- return;
- /* all DHT GET operations successful; terminate! */
- ok = 0;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Task to put the id of each peer into the DHT.
- *
- * @param cls array with NUM_PEERS DHT handles
- */
-static void
-do_puts (void *cls)
-{
- struct GNUNET_DHT_Handle **hs = cls;
- struct GNUNET_HashCode key;
- struct GNUNET_HashCode value;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Putting values into DHT\n");
- for (unsigned int i = 0; i < NUM_PEERS; i++)
- {
- GNUNET_CRYPTO_hash (&i, sizeof(i), &key);
- GNUNET_CRYPTO_hash (&key, sizeof(key), &value);
- GNUNET_DHT_put (hs[i], &key, 10U,
- GNUNET_DHT_RO_RECORD_ROUTE
- | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- GNUNET_BLOCK_TYPE_TEST,
- sizeof(value), &value,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- NULL, NULL);
- }
- put_task = GNUNET_SCHEDULER_add_delayed (PUT_FREQUENCY,
- &do_puts, hs);
-}
-
-
-/**
- * Callback called on each GET request going through the DHT.
- * Prints the info about the intercepted packet and increments a counter.
- *
- * @param cls Closure.
- * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
- * @param type The type of data in the request.
- * @param hop_count Hop count so far.
- * @param desired_replication_level Desired replication level.
- * @param key Key of the requested data.
- */
-static void
-monitor_get_cb (void *cls,
- enum GNUNET_DHT_RouteOption options,
- enum GNUNET_BLOCK_Type type,
- uint32_t hop_count,
- uint32_t desired_replication_level,
- const struct GNUNET_HashCode *key)
-{
- unsigned int i;
-
- i = (unsigned int) (long) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "%u got a GET message for key %s\n",
- i,
- GNUNET_h2s (key));
- monitor_counter++;
-}
-
-
-/**
- * Callback called on each PUT request going through the DHT.
- * Prints the info about the intercepted packet and increments a counter.
- *
- * @param cls Closure.
- * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
- * @param type The type of data in the request.
- * @param hop_count Hop count so far.
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param path_length number of entries in path (or 0 if not recorded).
- * @param path peers on the PUT path (or NULL if not recorded).
- * @param desired_replication_level Desired replication level.
- * @param exp Expiration time of the data.
- * @param key Key under which data is to be stored.
- * @param data Pointer to the data carried.
- * @param size Number of bytes in data.
- */
-static void
-monitor_put_cb (void *cls,
- enum GNUNET_DHT_RouteOption options,
- enum GNUNET_BLOCK_Type type,
- uint32_t hop_count,
- uint32_t desired_replication_level,
- const struct GNUNET_PeerIdentity *trunc_peer,
- unsigned int path_length,
- const struct GNUNET_DHT_PathElement *path,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *key,
- const void *data,
- size_t size)
-{
- unsigned int i;
-
- i = (unsigned int) (long) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "%u got a PUT message for key %s with %u bytes\n",
- i,
- GNUNET_h2s (key),
- (unsigned int) size);
- monitor_counter++;
-}
-
-
-/**
- * Callback called on each GET reply going through the DHT.
- * Prints the info about the intercepted packet and increments a counter.
- *
- * @param cls Closure.
- * @param type The type of data in the result.
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param get_path Peers on GET path (or NULL if not recorded).
- * @param get_path_length number of entries in get_path.
- * @param put_path peers on the PUT path (or NULL if not recorded).
- * @param put_path_length number of entries in get_path.
- * @param exp Expiration time of the data.
- * @param key Key of the data.
- * @param data Pointer to the result data.
- * @param size Number of bytes in data.
- */
-static void
-monitor_res_cb (void *cls,
- enum GNUNET_BLOCK_Type type,
- const struct GNUNET_PeerIdentity *trunc_peer,
- const struct GNUNET_DHT_PathElement *get_path,
- unsigned int get_path_length,
- const struct GNUNET_DHT_PathElement *put_path,
- unsigned int put_path_length,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *key,
- const void *data,
- size_t size)
-{
- unsigned int i;
-
- i = (unsigned int) (long) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "%u got a REPLY message for key %s with %u bytes\n",
- i,
- GNUNET_h2s (key),
- (unsigned int) size);
- monitor_counter++;
-}
-
-
-/**
- * Main function of the test.
- *
- * @param cls closure (NULL)
- * @param ctx argument to give to GNUNET_DHT_TEST_cleanup on test end
- * @param num_peers number of peers that are running
- * @param peers array of peers
- * @param dhts handle to each of the DHTs of the peers
- */
-static void
-run (void *cls,
- struct GNUNET_DHT_TEST_Context *ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_DHT_Handle **dhts)
-{
- unsigned int i;
- unsigned int j;
- struct GNUNET_HashCode key;
- struct GetOperation *get_op;
-
- GNUNET_assert (NUM_PEERS == num_peers);
- my_peers = peers;
- monitors = GNUNET_new_array (num_peers,
- struct GNUNET_DHT_MonitorHandle *);
- for (i = 0; i < num_peers; i++)
- monitors[i] = GNUNET_DHT_monitor_start (dhts[i],
- GNUNET_BLOCK_TYPE_ANY,
- NULL,
- &monitor_get_cb,
- &monitor_res_cb,
- &monitor_put_cb,
- (void *) (long) i);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peers setup, starting test\n");
- put_task = GNUNET_SCHEDULER_add_now (&do_puts, dhts);
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_CRYPTO_hash (&i, sizeof(i), &key);
- for (j = 0; j < num_peers; j++)
- {
- get_op = GNUNET_new (struct GetOperation);
- GNUNET_CONTAINER_DLL_insert (get_head,
- get_tail,
- get_op);
- get_op->get = GNUNET_DHT_get_start (dhts[j],
- GNUNET_BLOCK_TYPE_TEST, /* type */
- &key, /*key to search */
- 4U, /* replication level */
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_handler, get_op);
- }
- }
- timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &timeout_task_cb,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- ctx);
-}
-
-
-/**
- * Main: start test
- */
-int
-main (int xargc, char *xargv[])
-{
- GNUNET_DHT_TEST_run ("test-dht-monitor",
- "test_dht_monitor.conf",
- NUM_PEERS,
- &run, NULL);
- return ok;
-}
-
-
-/* end of test_dht_monitor.c */
diff --git a/src/service/dht/test_dht_monitor.conf
b/src/service/dht/test_dht_monitor.conf
deleted file mode 100644
index 703065f00..000000000
--- a/src/service/dht/test_dht_monitor.conf
+++ /dev/null
@@ -1,39 +0,0 @@
-@INLINE@ ../../../contrib/conf/gnunet/no_forcestart.conf
-@INLINE@ ../../../contrib/conf/gnunet/no_autostart_above_core.conf
-
-
-[dhtcache]
-QUOTA = 1 MB
-DATABASE = heap
-
-[transport]
-PLUGINS = tcp
-
-[ats]
-WAN_QUOTA_IN = 1 GB
-WAN_QUOTA_OUT = 1 GB
-
-[testbed]
-OVERLAY_TOPOLOGY = LINE
-
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-monitor/
-
-[nat]
-DISABLEV6 = YES
-ENABLE_UPNP = NO
-BEHIND_NAT = NO
-ALLOW_NAT = NO
-INTERNAL_ADDRESS = 127.0.0.1
-EXTERNAL_ADDRESS = 127.0.0.1
-USE_LOCALADDR = YES
-RETURN_LOCAL_ADDRESSES = YES
-
-
-[dht]
-START_ON_DEMAND = YES
-IMMEDIATE_START = YES
-
-[nse]
-START_ON_DEMAND = YES
-WORKBITS = 1
diff --git a/src/service/dht/test_dht_topo.c b/src/service/dht/test_dht_topo.c
deleted file mode 100644
index a8294c65d..000000000
--- a/src/service/dht/test_dht_topo.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012, 2016 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/test_dht_topo.c
- * @author Christian Grothoff
- * @brief Test for the dht service: store and retrieve in various topologies.
- * Each peer stores a value from the DHT and then each peer tries to get each
- * value from each other peer.
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_dht_service.h"
-#include "dht_test_lib.h"
-
-/**
- * How long until we give up on fetching the data?
- */
-#define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
- 120)
-
-/**
- * How frequently do we execute the PUTs?
- */
-#define PUT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
\
- 5)
-
-
-/**
- * Information we keep for each GET operation.
- */
-struct GetOperation
-{
- /**
- * DLL.
- */
- struct GetOperation *next;
-
- /**
- * DLL.
- */
- struct GetOperation *prev;
-
- /**
- * Operation to fetch @a me.
- */
- struct GNUNET_TESTBED_Operation *to;
-
- /**
- * Handle for the operation.
- */
- struct GNUNET_DHT_GetHandle *get;
-
- /**
- * DHT used by this operation.
- */
- struct GNUNET_DHT_Handle *dht;
-
- /**
- * Key we are looking up.
- */
- struct GNUNET_HashCode key;
-
- /**
- * At which peer is this operation being performed?
- */
- struct GNUNET_PeerIdentity me;
-};
-
-
-/**
- * Result of the test.
- */
-static int ok;
-
-/**
- * Task to do DHT_puts
- */
-static struct GNUNET_SCHEDULER_Task *put_task;
-
-/**
- * Task to do DHT_gets
- */
-static struct GNUNET_SCHEDULER_Task *get_task;
-
-/**
- * Task to time out / regular shutdown.
- */
-static struct GNUNET_SCHEDULER_Task *timeout_task;
-
-/**
- * Head of list of active GET operations.
- */
-static struct GetOperation *get_head;
-
-/**
- * Tail of list of active GET operations.
- */
-static struct GetOperation *get_tail;
-
-/**
- * Array of the testbed's peers.
- */
-static struct GNUNET_TESTBED_Peer **my_peers;
-
-/**
- * Number of peers to run.
- */
-static unsigned int NUM_PEERS;
-
-
-/**
- * Statistics we print out.
- */
-static struct
-{
- const char *subsystem;
- const char *name;
- unsigned long long total;
-} stats[] = {
- { "core", "# bytes decrypted", 0 },
- { "core", "# bytes encrypted", 0 },
- { "core", "# type maps received", 0 },
- { "core", "# session keys confirmed via PONG", 0 },
- { "core", "# peers connected", 0 },
- { "core", "# key exchanges initiated", 0 },
- { "core", "# send requests dropped (disconnected)", 0 },
- { "core", "# transmissions delayed due to corking", 0 },
- { "core", "# messages discarded (expired prior to transmission)", 0 },
- { "core", "# messages discarded (disconnected)", 0 },
- { "core", "# discarded CORE_SEND requests", 0 },
- { "core", "# discarded lower priority CORE_SEND requests", 0 },
- { "transport", "# bytes received via TCP", 0 },
- { "transport", "# bytes transmitted via TCP", 0 },
- { "dht", "# PUT messages queued for transmission", 0 },
- { "dht", "# P2P PUT requests received", 0 },
- { "dht", "# GET messages queued for transmission", 0 },
- { "dht", "# P2P GET requests received", 0 },
- { "dht", "# RESULT messages queued for transmission", 0 },
- { "dht", "# P2P RESULTS received", 0 },
- { "dht", "# Queued messages discarded (peer disconnected)", 0 },
- { "dht", "# Peers excluded from routing due to Bloomfilter", 0 },
- { "dht", "# Peer selection failed", 0 },
- { "dht", "# FIND PEER requests ignored due to Bloomfilter", 0 },
- { "dht", "# FIND PEER requests ignored due to lack of HELLO", 0 },
- { "dht", "# P2P FIND PEER requests processed", 0 },
- { "dht", "# P2P GET requests ONLY routed", 0 },
- { "dht", "# Preference updates given to core", 0 },
- { "dht", "# REPLIES ignored for CLIENTS (no match)", 0 },
- { "dht", "# GET requests from clients injected", 0 },
- { "dht", "# GET requests received from clients", 0 },
- { "dht", "# GET STOP requests received from clients", 0 },
- { "dht", "# ITEMS stored in datacache", 0 },
- { "dht", "# Good RESULTS found in datacache", 0 },
- { "dht", "# GET requests given to datacache", 0 },
- { NULL, NULL, 0 }
-};
-
-
-static struct GNUNET_DHT_TEST_Context *
-stop_ops (void)
-{
- struct GetOperation *get_op;
- struct GNUNET_DHT_TEST_Context *ctx = NULL;
-
- if (NULL != timeout_task)
- {
- ctx = GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = NULL;
- }
- if (NULL != put_task)
- {
- GNUNET_SCHEDULER_cancel (put_task);
- put_task = NULL;
- }
- if (NULL != get_task)
- {
- GNUNET_SCHEDULER_cancel (get_task);
- get_task = NULL;
- }
- while (NULL != (get_op = get_tail))
- {
- if (NULL != get_op->to)
- {
- GNUNET_TESTBED_operation_done (get_op->to);
- get_op->to = NULL;
- }
- if (NULL != get_op->get)
- {
- GNUNET_DHT_get_stop (get_op->get);
- get_op->get = NULL;
- }
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- }
- return ctx;
-}
-
-
-/**
- * Function called once we're done processing stats.
- *
- * @param cls the test context
- * @param op the stats operation
- * @param emsg error message on failure
- */
-static void
-stats_finished (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const char *emsg)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- if (NULL != op)
- GNUNET_TESTBED_operation_done (op);
- if (NULL != emsg)
- {
- fprintf (stderr,
- _ ("Gathering statistics failed: %s\n"),
- emsg);
- GNUNET_SCHEDULER_cancel (put_task);
- GNUNET_DHT_TEST_cleanup (ctx);
- return;
- }
- for (unsigned int i = 0; NULL != stats[i].name; i++)
- fprintf (stderr,
- "%6s/%60s = %12llu\n",
- stats[i].subsystem,
- stats[i].name,
- stats[i].total);
- GNUNET_DHT_TEST_cleanup (ctx);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Function called to process statistic values from all peers.
- *
- * @param cls closure
- * @param peer the peer the statistic belong to
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if
not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-static enum GNUNET_GenericReturnValue
-handle_stats (void *cls,
- const struct GNUNET_TESTBED_Peer *peer,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- for (unsigned int i = 0; NULL != stats[i].name; i++)
- if ((0 == strcasecmp (subsystem,
- stats[i].subsystem)) &&
- (0 == strcasecmp (name,
- stats[i].name)))
- stats[i].total += value;
- return GNUNET_OK;
-}
-
-
-/**
- * Task run on shutdown to clean up. Terminates active get operations
- * and shuts down the testbed.
- *
- * @param cls the 'struct GNUNET_DHT_TestContext'
- */
-static void
-shutdown_task (void *cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx;
-
- (void) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Performing shutdown\n");
- ctx = stop_ops ();
- if (NULL != ctx)
- GNUNET_DHT_TEST_cleanup (ctx);
-}
-
-
-/**
- * Task run on timeout to clean up. Terminates active get operations
- * and shuts down the testbed.
- *
- * @param cls the `struct GNUNET_DHT_TestContext`
- */
-static void
-timeout_cb (void *cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- timeout_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT,
- &timeout_cb,
- ctx);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout\n");
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Iterator called on each result obtained for a DHT
- * operation that expects a reply
- *
- * @param cls closure with our 'struct GetOperation'
- * @param exp when will this value expire
- * @param query query hash
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param get_path peers on reply path (or NULL if not recorded)
- * @param get_path_length number of entries in @a get_path
- * @param put_path peers on the PUT path (or NULL if not recorded)
- * @param put_path_length number of entries in @a put_path
- * @param type type of the result
- * @param size number of bytes in @a data
- * @param data pointer to the result data
- */
-static void
-dht_get_handler (void *cls,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *query,
- const struct GNUNET_PeerIdentity *trunc_peer,
- const struct GNUNET_DHT_PathElement *get_path,
- unsigned int get_path_length,
- const struct GNUNET_DHT_PathElement *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type,
- size_t size,
- const void *data)
-{
- struct GetOperation *get_op = cls;
- struct GNUNET_HashCode want;
- struct GNUNET_DHT_TEST_Context *ctx;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GET HANDLER called on PID %s\n",
- GNUNET_i2s (&get_op->me));
- if (sizeof(struct GNUNET_HashCode) != size)
- {
- GNUNET_break (0);
- return;
- }
- if (0 != GNUNET_memcmp (query,
- &get_op->key))
- {
- /* exact search should only yield exact results */
- GNUNET_break (0);
- return;
- }
- GNUNET_CRYPTO_hash (query,
- sizeof(*query),
- &want);
- if (0 != memcmp (&want,
- data,
- sizeof(want)))
- {
- GNUNET_break (0);
- return;
- }
- if (0 !=
- GNUNET_DHT_verify_path (data,
- size,
- exp,
- trunc_peer,
- put_path,
- put_path_length,
- get_path,
- get_path_length,
- &get_op->me))
- {
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Path signature (%u/%u) verification failed for peer %s!\n",
- get_path_length,
- put_path_length,
- GNUNET_i2s (&get_op->me));
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Get successful\n");
- ok--;
- }
- GNUNET_DHT_get_stop (get_op->get);
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- if (NULL != get_head)
- return;
- /* all DHT GET operations successful; get stats! */
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "All DHT operations successful. Obtaining stats!\n");
- ctx = stop_ops ();
- GNUNET_assert (NULL != ctx);
- (void) GNUNET_TESTBED_get_statistics (NUM_PEERS,
- my_peers,
- NULL, NULL,
- &handle_stats,
- &stats_finished,
- ctx);
-}
-
-
-/**
- * Task to put the id of each peer into the DHT.
- *
- * @param cls array with NUM_PEERS DHT handles
- * @param tc Task context
- */
-static void
-do_puts (void *cls)
-{
- struct GNUNET_DHT_Handle **hs = cls;
- struct GNUNET_HashCode key;
- struct GNUNET_HashCode value;
-
- put_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Putting %u values into DHT\n",
- NUM_PEERS);
- for (unsigned int i = 0; i < NUM_PEERS; i++)
- {
- GNUNET_CRYPTO_hash (&i,
- sizeof(i),
- &key);
- GNUNET_CRYPTO_hash (&key,
- sizeof(key),
- &value);
- GNUNET_DHT_put (hs[i],
- &key,
- 10U,
- GNUNET_DHT_RO_RECORD_ROUTE
- | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- GNUNET_BLOCK_TYPE_TEST,
- sizeof(value),
- &value,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- NULL,
- NULL);
- }
- put_task = GNUNET_SCHEDULER_add_delayed (PUT_FREQUENCY,
- &do_puts,
- hs);
-}
-
-
-/**
- * Callback to be called when the requested peer information is available
- * The peer information in the callback is valid until the operation 'op' is
canceled.
- *
- * @param cls a `struct GetOperation *`
- * @param op the operation this callback corresponds to
- * @param pinfo the result; will be NULL if the operation has failed
- * @param emsg error message if the operation has failed; will be NULL if the
- * operation is successful
- */
-static void
-pid_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct GetOperation *get_op = cls;
-
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Testbed failure: %s\n",
- emsg);
- GNUNET_TESTBED_operation_done (get_op->to);
- get_op->to = NULL;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Testbed provided PID %s\n",
- GNUNET_i2s (pinfo->result.id));
- get_op->me = *pinfo->result.id;
- GNUNET_TESTBED_operation_done (get_op->to);
- get_op->to = NULL;
- get_op->get = GNUNET_DHT_get_start (get_op->dht,
- GNUNET_BLOCK_TYPE_TEST,
- &get_op->key,
- 4U, /* replication level */
- GNUNET_DHT_RO_RECORD_ROUTE
- | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_handler,
- get_op);
-}
-
-
-/**
- * Start GET operations.
- */
-static void
-start_get (void *cls)
-{
- struct GNUNET_DHT_Handle **dhts = cls;
-
- get_task = NULL;
- for (unsigned int i = 0; i < NUM_PEERS; i++)
- {
- struct GNUNET_HashCode key;
-
- GNUNET_CRYPTO_hash (&i,
- sizeof(i),
- &key);
- for (unsigned int j = 0; j < NUM_PEERS; j++)
- {
- struct GetOperation *get_op;
-
- get_op = GNUNET_new (struct GetOperation);
- ok++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting GET %p\n",
- get_op);
- get_op->key = key;
- get_op->dht = dhts[j];
- get_op->to = GNUNET_TESTBED_peer_get_information (my_peers[j],
-
GNUNET_TESTBED_PIT_IDENTITY,
- &pid_cb,
- get_op);
- GNUNET_CONTAINER_DLL_insert (get_head,
- get_tail,
- get_op);
- }
- }
-}
-
-
-/**
- * Main function of the test.
- *
- * @param cls closure (NULL)
- * @param ctx argument to give to #GNUNET_DHT_TEST_cleanup on test end
- * @param num_peers number of @a peers that are running
- * @param peers array of peers
- * @param dhts handle to each of the DHTs of the peers
- */
-static void
-run (void *cls,
- struct GNUNET_DHT_TEST_Context *ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_DHT_Handle **dhts)
-{
- GNUNET_assert (NUM_PEERS == num_peers);
- my_peers = peers;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peers setup, starting test\n");
- put_task = GNUNET_SCHEDULER_add_now (&do_puts,
- dhts);
- get_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &start_get,
- dhts);
- timeout_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT,
- &timeout_cb,
- ctx);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- ctx);
-}
-
-
-/**
- * Main: start test
- */
-int
-main (int xargc, char *xargv[])
-{
- const char *cfg_filename;
- const char *test_name;
-
- unsetenv ("XDG_DATA_HOME");
- unsetenv ("XDG_CONFIG_HOME");
- unsetenv ("XDG_CACHE_HOME");
- if (NULL != strstr (xargv[0], "test_dht_2dtorus"))
- {
- cfg_filename = "test_dht_2dtorus.conf";
- test_name = "test-dht-2dtorus";
- NUM_PEERS = 16;
- }
- else if (NULL != strstr (xargv[0], "test_dht_line"))
- {
- cfg_filename = "test_dht_line.conf";
- test_name = "test-dht-line";
- NUM_PEERS = 5;
- }
- else if (NULL != strstr (xargv[0], "test_dht_twopeer"))
- {
- cfg_filename = "test_dht_line.conf";
- test_name = "test-dht-twopeer";
- NUM_PEERS = 2;
- }
- else if (NULL != strstr (xargv[0], "test_dht_multipeer"))
- {
- cfg_filename = "test_dht_multipeer.conf";
- test_name = "test-dht-multipeer";
- NUM_PEERS = 10;
- }
- else
- {
- GNUNET_break (0);
- return 1;
- }
- GNUNET_DHT_TEST_run (test_name,
- cfg_filename,
- NUM_PEERS,
- &run, NULL);
- return ok;
-}
-
-
-/* end of test_dht_topo.c */
diff --git a/src/service/fs/Makefile.am b/src/service/fs/Makefile.am
index 93c8814ca..c1d545af1 100644
--- a/src/service/fs/Makefile.am
+++ b/src/service/fs/Makefile.am
@@ -118,7 +118,6 @@ check_PROGRAMS = \
test_fs_search_probes \
test_fs_search_persistence \
test_fs_start_stop \
- test_fs_test_lib \
test_fs_unindex \
test_fs_unindex_persistence \
test_fs_uri \
@@ -298,13 +297,6 @@ test_fs_uri_LDADD = \
$(top_builddir)/src/lib/util/libgnunetutil.la
# TNG
-#test_fs_test_lib_SOURCES = \
-# test_fs_test_lib.c
-#test_fs_test_lib_LDADD = \
-# libgnunetfstest.a \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# libgnunetfs.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la
#test_gnunet_service_fs_p2p_SOURCES = \
# test_gnunet_service_fs_p2p.c
@@ -367,7 +359,6 @@ test_fs_uri_LDADD = \
# $(top_builddir)/src/lib/util/libgnunetutil.la
EXTRA_DIST = \
- fs_test_lib_data.conf \
perf_gnunet_service_fs_p2p.conf \
test_fs_data.conf \
test_fs_defaults.conf \
diff --git a/src/service/fs/fs_test_lib.c b/src/service/fs/fs_test_lib.c
deleted file mode 100644
index f80a2859c..000000000
--- a/src/service/fs/fs_test_lib.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2010, 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file fs/fs_test_lib.c
- * @brief library routines for testing FS publishing and downloading;
- * this code is limited to flat files
- * and no keywords (those functions can be tested with
- * single-peer setups; this is for testing routing).
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "fs_api.h"
-#include "fs_test_lib.h"
-
-
-#define CONTENT_LIFETIME GNUNET_TIME_UNIT_HOURS
-
-
-/**
- * Handle for a publishing operation started for testing FS.
- */
-struct TestPublishOperation
-{
- /**
- * Handle for the operation to connect to the peer's 'fs' service.
- */
- struct GNUNET_TESTBED_Operation *fs_op;
-
- /**
- * Handle to the file sharing context using this daemon.
- */
- struct GNUNET_FS_Handle *fs;
-
- /**
- * Function to call when upload is done.
- */
- GNUNET_FS_TEST_UriContinuation publish_cont;
-
- /**
- * Closure for publish_cont.
- */
- void *publish_cont_cls;
-
- /**
- * Task to abort publishing (timeout).
- */
- struct GNUNET_SCHEDULER_Task *publish_timeout_task;
-
- /**
- * Seed for file generation.
- */
- uint32_t publish_seed;
-
- /**
- * Context for current publishing operation.
- */
- struct GNUNET_FS_PublishContext *publish_context;
-
- /**
- * Result URI.
- */
- struct GNUNET_FS_Uri *publish_uri;
-
- /**
- * Name of the temporary file used, or NULL for none.
- */
- char *publish_tmp_file;
-
- /**
- * Size of the file.
- */
- uint64_t size;
-
- /**
- * Anonymity level used.
- */
- uint32_t anonymity;
-
- /**
- * Verbosity level of the current operation.
- */
- unsigned int verbose;
-
- /**
- * Are we testing indexing? (YES: index, NO: insert, SYSERR: simulate)
- */
- int do_index;
-};
-
-
-/**
- * Handle for a download operation started for testing FS.
- */
-struct TestDownloadOperation
-{
- /**
- * Handle for the operation to connect to the peer's 'fs' service.
- */
- struct GNUNET_TESTBED_Operation *fs_op;
-
- /**
- * Handle to the file sharing context using this daemon.
- */
- struct GNUNET_FS_Handle *fs;
-
- /**
- * Handle to the daemon via testing.
- */
- struct GNUNET_TESTING_Daemon *daemon;
-
- /**
- * Function to call when download is done.
- */
- GNUNET_SCHEDULER_TaskCallback download_cont;
-
- /**
- * Closure for download_cont.
- */
- void *download_cont_cls;
-
- /**
- * URI to download.
- */
- struct GNUNET_FS_Uri *uri;
-
- /**
- * Task to abort downloading (timeout).
- */
- struct GNUNET_SCHEDULER_Task *download_timeout_task;
-
- /**
- * Context for current download operation.
- */
- struct GNUNET_FS_DownloadContext *download_context;
-
- /**
- * Size of the file.
- */
- uint64_t size;
-
- /**
- * Anonymity level used.
- */
- uint32_t anonymity;
-
- /**
- * Seed for download verification.
- */
- uint32_t download_seed;
-
- /**
- * Verbosity level of the current operation.
- */
- unsigned int verbose;
-};
-
-
-/**
- * Task scheduled to report on the completion of our publish operation.
- *
- * @param cls the publish operation context
- */
-static void
-report_uri (void *cls)
-{
- struct TestPublishOperation *po = cls;
-
- GNUNET_FS_publish_stop (po->publish_context);
- GNUNET_TESTBED_operation_done (po->fs_op);
- po->publish_cont (po->publish_cont_cls,
- po->publish_uri,
- (GNUNET_YES == po->do_index)
- ? po->publish_tmp_file
- : NULL);
- GNUNET_FS_uri_destroy (po->publish_uri);
- if ((GNUNET_YES != po->do_index) &&
- (NULL != po->publish_tmp_file))
- (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
- GNUNET_free (po->publish_tmp_file);
- GNUNET_free (po);
-}
-
-
-/**
- * Task scheduled to run when publish operation times out.
- *
- * @param cls the publish operation context
- */
-static void
-publish_timeout (void *cls)
-{
- struct TestPublishOperation *po = cls;
-
- po->publish_timeout_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout while trying to publish data\n");
- GNUNET_TESTBED_operation_done (po->fs_op);
- GNUNET_FS_publish_stop (po->publish_context);
- po->publish_cont (po->publish_cont_cls, NULL, NULL);
- (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
- GNUNET_free (po->publish_tmp_file);
- GNUNET_free (po);
-}
-
-
-/**
- * Progress callback for file-sharing events while publishing.
- *
- * @param cls the publish operation context
- * @param info information about the event
- */
-static void *
-publish_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
-{
- struct TestPublishOperation *po = cls;
-
- switch (info->status)
- {
- case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
- GNUNET_SCHEDULER_cancel (po->publish_timeout_task);
- po->publish_timeout_task = NULL;
- po->publish_uri =
- GNUNET_FS_uri_dup (info->value.publish.specifics.completed.chk_uri);
- GNUNET_SCHEDULER_add_now (&report_uri,
- po);
- break;
-
- case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
- if (po->verbose)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Publishing at %llu/%llu bytes\n",
- (unsigned long long) info->value.publish.completed,
- (unsigned long long) info->value.publish.size);
- break;
-
- case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY:
- break;
-
- case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
- if (po->verbose)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n",
- (unsigned long long) info->value.download.completed,
- (unsigned long long) info->value.download.size);
- break;
-
- default:
- break;
- }
- return NULL;
-}
-
-
-/**
- * Generate test data for publishing test.
- *
- * @param cls pointer to uint32_t with publishing seed
- * @param offset offset to generate data for
- * @param max maximum number of bytes to generate
- * @param buf where to write generated data
- * @param emsg where to store error message (unused)
- * @return number of bytes written to buf
- */
-static size_t
-file_generator (void *cls,
- uint64_t offset,
- size_t max,
- void *buf,
- char **emsg)
-{
- uint32_t *publish_seed = cls;
- uint64_t pos;
- uint8_t *cbuf = buf;
- int mod;
-
- if (emsg != NULL)
- *emsg = NULL;
- if (buf == NULL)
- return 0;
- for (pos = 0; pos < 8; pos++)
- cbuf[pos] = (uint8_t) (offset >> pos * 8);
- for (pos = 8; pos < max; pos++)
- {
- mod = (255 - (offset / 1024 / 32));
- if (mod == 0)
- mod = 1;
- cbuf[pos] = (uint8_t) ((offset * (*publish_seed)) % mod);
- }
- return max;
-}
-
-
-/**
- * Connect adapter for publishing operation.
- *
- * @param cls the 'struct TestPublishOperation'
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-publish_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct TestPublishOperation *po = cls;
-
- return GNUNET_FS_start (cfg,
- "fs-test-publish",
- &publish_progress_cb, po,
- GNUNET_FS_FLAGS_NONE,
- GNUNET_FS_OPTIONS_END);
-}
-
-
-/**
- * Adapter function called to destroy connection to file-sharing service.
- *
- * @param cls the 'struct GNUNET_FS_Handle'
- * @param op_result unused (different for publish/download!)
- */
-static void
-fs_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct GNUNET_FS_Handle *fs = op_result;
-
- GNUNET_FS_stop (fs);
-}
-
-
-/**
- * Callback to be called when testbed has connected to the fs service
- *
- * @param cls the 'struct TestPublishOperation'
- * @param op the operation that has been finished
- * @param ca_result the 'struct GNUNET_FS_Handle ' (NULL on error)
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-publish_fs_connect_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct TestPublishOperation *po = cls;
- struct GNUNET_FS_FileInformation *fi;
- struct GNUNET_DISK_FileHandle *fh;
- char *em;
- uint64_t off;
- char buf[DBLOCK_SIZE];
- size_t bsize;
- struct GNUNET_FS_BlockOptions bo;
-
- if (NULL == ca_result)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to connect to FS for publishing: %s\n", emsg);
- po->publish_cont (po->publish_cont_cls,
- NULL, NULL);
- GNUNET_TESTBED_operation_done (po->fs_op);
- GNUNET_free (po);
- return;
- }
- po->fs = ca_result;
-
- bo.expiration_time = GNUNET_TIME_relative_to_absolute (CONTENT_LIFETIME);
- bo.anonymity_level = po->anonymity;
- bo.content_priority = 42;
- bo.replication_level = 1;
- if (GNUNET_YES == po->do_index)
- {
- po->publish_tmp_file = GNUNET_DISK_mktemp ("fs-test-publish-index");
- GNUNET_assert (po->publish_tmp_file != NULL);
- fh = GNUNET_DISK_file_open (po->publish_tmp_file,
- GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE);
- GNUNET_assert (NULL != fh);
- off = 0;
- while (off < po->size)
- {
- bsize = GNUNET_MIN (sizeof(buf), po->size - off);
- emsg = NULL;
- GNUNET_assert (bsize == file_generator (&po->publish_seed, off, bsize,
- buf, &em));
- GNUNET_assert (em == NULL);
- GNUNET_assert (bsize == GNUNET_DISK_file_write (fh, buf, bsize));
- off += bsize;
- }
- GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
- fi = GNUNET_FS_file_information_create_from_file (po->fs, po,
- po->publish_tmp_file,
- NULL, NULL, po->do_index,
- &bo);
- GNUNET_assert (NULL != fi);
- }
- else
- {
- fi = GNUNET_FS_file_information_create_from_reader (po->fs, po,
- po->size,
- &file_generator,
- &po->publish_seed,
- NULL, NULL,
- po->do_index, &bo);
- GNUNET_assert (NULL != fi);
- }
- po->publish_context =
- GNUNET_FS_publish_start (po->fs, fi, NULL, NULL, NULL,
- GNUNET_FS_PUBLISH_OPTION_NONE);
-}
-
-
-void
-GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout, uint32_t
anonymity,
- int do_index, uint64_t size, uint32_t seed,
- unsigned int verbose,
- GNUNET_FS_TEST_UriContinuation cont, void *cont_cls)
-{
- struct TestPublishOperation *po;
-
- po = GNUNET_new (struct TestPublishOperation);
- po->publish_cont = cont;
- po->publish_cont_cls = cont_cls;
- po->publish_seed = seed;
- po->anonymity = anonymity;
- po->size = size;
- po->verbose = verbose;
- po->do_index = do_index;
- po->fs_op = GNUNET_TESTBED_service_connect (po,
- peer,
- "fs",
- &publish_fs_connect_complete_cb,
- po,
- &publish_connect_adapter,
- &fs_disconnect_adapter,
- po);
- po->publish_timeout_task =
- GNUNET_SCHEDULER_add_delayed (timeout, &publish_timeout, po);
-}
-
-
-/* ************************** download ************************ */
-
-
-/**
- * Task scheduled to run when download operation times out.
- *
- * @param cls the download operation context
- */
-static void
-download_timeout (void *cls)
-{
- struct TestDownloadOperation *dop = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout while trying to download file\n");
- dop->download_timeout_task = NULL;
- GNUNET_FS_download_stop (dop->download_context,
- GNUNET_YES);
- GNUNET_SCHEDULER_add_now (dop->download_cont,
- dop->download_cont_cls);
- GNUNET_TESTBED_operation_done (dop->fs_op);
- GNUNET_FS_uri_destroy (dop->uri);
- GNUNET_free (dop);
-}
-
-
-/**
- * Task scheduled to report on the completion of our download operation.
- *
- * @param cls the download operation context
- */
-static void
-report_success (void *cls)
-{
- struct TestDownloadOperation *dop = cls;
-
- GNUNET_FS_download_stop (dop->download_context,
- GNUNET_YES);
- GNUNET_SCHEDULER_add_now (dop->download_cont,
- dop->download_cont_cls);
- GNUNET_TESTBED_operation_done (dop->fs_op);
- GNUNET_FS_uri_destroy (dop->uri);
- GNUNET_free (dop);
-}
-
-
-/**
- * Progress callback for file-sharing events while downloading.
- *
- * @param cls the download operation context
- * @param info information about the event
- */
-static void *
-download_progress_cb (void *cls,
- const struct GNUNET_FS_ProgressInfo *info)
-{
- struct TestDownloadOperation *dop = cls;
-
- switch (info->status)
- {
- case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
- if (dop->verbose)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Download at %llu/%llu bytes\n",
- (unsigned long long) info->value.download.completed,
- (unsigned long long) info->value.download.size);
- break;
-
- case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
- GNUNET_SCHEDULER_cancel (dop->download_timeout_task);
- dop->download_timeout_task = NULL;
- GNUNET_SCHEDULER_add_now (&report_success, dop);
- break;
-
- case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
- case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
- break;
-
- /* FIXME: monitor data correctness during download progress */
- /* FIXME: do performance reports given sufficient verbosity */
- /* FIXME: advance timeout task to "immediate" on error */
- default:
- break;
- }
- return NULL;
-}
-
-
-/**
- * Connect adapter for download operation.
- *
- * @param cls the 'struct TestDownloadOperation'
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-download_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct TestPublishOperation *po = cls;
-
- return GNUNET_FS_start (cfg,
- "fs-test-download",
- &download_progress_cb, po,
- GNUNET_FS_FLAGS_NONE,
- GNUNET_FS_OPTIONS_END);
-}
-
-
-/**
- * Callback to be called when testbed has connected to the fs service
- *
- * @param cls the 'struct TestPublishOperation'
- * @param op the operation that has been finished
- * @param ca_result the 'struct GNUNET_FS_Handle ' (NULL on error)
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-download_fs_connect_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct TestDownloadOperation *dop = cls;
-
- dop->fs = ca_result;
- GNUNET_assert (NULL != dop->fs);
- dop->download_context =
- GNUNET_FS_download_start (dop->fs, dop->uri, NULL, NULL, NULL, 0,
dop->size,
- dop->anonymity, GNUNET_FS_DOWNLOAD_OPTION_NONE,
- NULL, NULL);
-}
-
-
-void
-GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout,
- uint32_t anonymity, uint32_t seed,
- const struct GNUNET_FS_Uri *uri, unsigned int verbose,
- GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
-{
- struct TestDownloadOperation *dop;
-
- dop = GNUNET_new (struct TestDownloadOperation);
- dop->uri = GNUNET_FS_uri_dup (uri);
- dop->size = GNUNET_FS_uri_chk_get_file_size (uri);
- dop->verbose = verbose;
- dop->anonymity = anonymity;
- dop->download_cont = cont;
- dop->download_cont_cls = cont_cls;
- dop->download_seed = seed;
-
- dop->fs_op = GNUNET_TESTBED_service_connect (dop,
- peer,
- "fs",
-
&download_fs_connect_complete_cb,
- dop,
- &download_connect_adapter,
- &fs_disconnect_adapter,
- dop);
- dop->download_timeout_task =
- GNUNET_SCHEDULER_add_delayed (timeout, &download_timeout, dop);
-}
-
-
-/* end of fs_test_lib.c */
diff --git a/src/service/fs/fs_test_lib.h b/src/service/fs/fs_test_lib.h
deleted file mode 100644
index 36244eb19..000000000
--- a/src/service/fs/fs_test_lib.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2010, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file fs/fs_test_lib.h
- * @brief library routines for testing FS publishing and downloading;
- * this code is limited to flat files
- * and no keywords (those functions can be tested with
- * single-peer setups; this is for testing routing).
- * @author Christian Grothoff
- */
-#ifndef FS_TEST_LIB_H
-#define FS_TEST_LIB_H
-
-#include "gnunet_util_lib.h"
-#include "gnunet_fs_service.h"
-#include "gnunet_testbed_service.h"
-
-
-/**
- * Function signature.
- *
- * @param cls closure (user defined)
- * @param uri a URI, NULL for errors
- * @param fn name of the file on disk to be removed upon
- * completion, or NULL for inserted files (also NULL on error)
- */
-typedef void
-(*GNUNET_FS_TEST_UriContinuation) (void *cls,
- const struct GNUNET_FS_Uri *uri,
- const char *fn);
-
-
-/**
- * Publish a file at the given daemon.
- *
- * @param peer where to publish
- * @param timeout if this operation cannot be completed within the
- * given period, call the continuation with an error code
- * @param anonymity option for publication
- * @param do_index #GNUNET_YES for index, #GNUNET_NO for insertion,
- * #GNUNET_SYSERR for simulation
- * @param size size of the file to publish
- * @param seed seed to use for file generation
- * @param verbose how verbose to be in reporting
- * @param cont function to call when done
- * @param cont_cls closure for @a cont
- */
-void
-GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout,
- uint32_t anonymity,
- int do_index,
- uint64_t size,
- uint32_t seed,
- unsigned int verbose,
- GNUNET_FS_TEST_UriContinuation cont,
- void *cont_cls);
-
-
-/**
- * Perform test download.
- *
- * @param peer which peer to download from
- * @param timeout if this operation cannot be completed within the
- * given period, call the continuation with an error code
- * @param anonymity option for download
- * @param seed used for file validation
- * @param uri URI of file to download (CHK/LOC only)
- * @param verbose how verbose to be in reporting
- * @param cont function to call when done
- * @param cont_cls closure for @a cont
- */
-void
-GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout,
- uint32_t anonymity,
- uint32_t seed,
- const struct GNUNET_FS_Uri *uri,
- unsigned int verbose,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls);
-
-
-#endif
diff --git a/src/service/fs/fs_test_lib_data.conf
b/src/service/fs/fs_test_lib_data.conf
deleted file mode 100644
index c99674798..000000000
--- a/src/service/fs/fs_test_lib_data.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-@INLINE@ test_fs_defaults.conf
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/gnunet-fs-test-lib/
-
-[ats]
-WAN_QUOTA_IN = 3932160
-WAN_QUOTA_OUT = 3932160
-
-[datastore]
-QUOTA = 2 GB
-#PLUGIN = heap
-#
-[fs]
-IMMEDIATE_START = YES
-
-[testbed]
-OVERLAY_TOPOLOGY = CLIQUE
diff --git a/src/service/nse/Makefile.am b/src/service/nse/Makefile.am
index 7b89ef635..40690e81c 100644
--- a/src/service/nse/Makefile.am
+++ b/src/service/nse/Makefile.am
@@ -28,20 +28,6 @@ libgnunetnse_la_LDFLAGS = \
libexec_PROGRAMS = \
gnunet-service-nse
-#noinst_PROGRAMS = \
-# gnunet-nse-profiler
-
-# FIXME no testbed in TNG
-#gnunet_nse_profiler_SOURCES = \
-# gnunet-nse-profiler.c
-#gnunet_nse_profiler_LDADD = -lm \
-# libgnunetnse.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
-# $(top_builddir)/src/service/testing/libgnunettesting.la \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# $(GN_LIBINTL)
-
gnunet_service_nse_SOURCES = \
gnunet-service-nse.c
gnunet_service_nse_LDADD = \
diff --git a/src/service/nse/gnunet-nse-profiler.c
b/src/service/nse/gnunet-nse-profiler.c
deleted file mode 100644
index 4b256bc52..000000000
--- a/src/service/nse/gnunet-nse-profiler.c
+++ /dev/null
@@ -1,921 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file nse/gnunet-nse-profiler.c
- *
- * @brief Profiling driver for the network size estimation service.
- * Generally, the profiler starts a given number of peers,
- * then churns some off, waits a certain amount of time, then
- * churns again, and repeats.
- * @author Christian Grothoff
- * @author Nathan Evans
- * @author Sree Harsha Totakura
- */
-
-#include "platform.h"
-#include "gnunet_testbed_service.h"
-#include "gnunet_nse_service.h"
-
-/**
- * Generic loggins shorthand
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-/**
- * Debug logging shorthand
- */
-#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
-
-
-/**
- * Information we track for a peer in the testbed.
- */
-struct NSEPeer
-{
- /**
- * Prev reference in DLL.
- */
- struct NSEPeer *prev;
-
- /**
- * Next reference in DLL.
- */
- struct NSEPeer *next;
-
- /**
- * Handle with testbed.
- */
- struct GNUNET_TESTBED_Peer *daemon;
-
- /**
- * Testbed operation to connect to NSE service.
- */
- struct GNUNET_TESTBED_Operation *nse_op;
-
- /**
- * Testbed operation to connect to statistics service
- */
- struct GNUNET_TESTBED_Operation *stat_op;
-
- /**
- * Handle to the statistics service
- */
- struct GNUNET_STATISTICS_Handle *sh;
-};
-
-
-/**
- * Operation map entry
- */
-struct OpListEntry
-{
- /**
- * DLL next ptr
- */
- struct OpListEntry *next;
-
- /**
- * DLL prev ptr
- */
- struct OpListEntry *prev;
-
- /**
- * The testbed operation
- */
- struct GNUNET_TESTBED_Operation *op;
-
- /**
- * Depending on whether we start or stop NSE service at the peer set this to
1
- * or -1
- */
- int delta;
-};
-
-
-/**
- * Head of DLL of peers we monitor closely.
- */
-static struct NSEPeer *peer_head;
-
-/**
- * Tail of DLL of peers we monitor closely.
- */
-static struct NSEPeer *peer_tail;
-
-/**
- * Return value from 'main' (0 == success)
- */
-static int ok;
-
-/**
- * Be verbose (configuration option)
- */
-static unsigned int verbose;
-
-/**
- * Name of the file with the hosts to run the test over (configuration option)
- */
-static char *hosts_file;
-
-/**
- * Maximum number of peers in the test.
- */
-static unsigned int num_peers;
-
-/**
- * Total number of rounds to execute.
- */
-static unsigned int num_rounds;
-
-/**
- * Current round we are in.
- */
-static unsigned int current_round;
-
-/**
- * Array of size 'num_rounds' with the requested number of peers in the given
round.
- */
-static unsigned int *num_peers_in_round;
-
-/**
- * How many peers are running right now?
- */
-static unsigned int peers_running;
-
-/**
- * Specification for the numbers of peers to have in each round.
- */
-static char *num_peer_spec;
-
-/**
- * Handles to all of the running peers.
- */
-static struct GNUNET_TESTBED_Peer **daemons;
-
-/**
- * Global configuration file
- */
-static struct GNUNET_CONFIGURATION_Handle *testing_cfg;
-
-/**
- * Maximum number of connections to NSE services.
- */
-static unsigned int connection_limit;
-
-/**
- * Total number of connections in the whole network.
- */
-static unsigned int total_connections;
-
-/**
- * File to report results to.
- */
-static struct GNUNET_DISK_FileHandle *output_file;
-
-/**
- * Filename to log results to.
- */
-static char *output_filename;
-
-/**
- * File to log connection info, statistics to.
- */
-static struct GNUNET_DISK_FileHandle *data_file;
-
-/**
- * Filename to log connection info, statistics to.
- */
-static char *data_filename;
-
-/**
- * How long to wait before triggering next round?
- * Default: 60 s.
- */
-static struct GNUNET_TIME_Relative wait_time = { 60 * 1000 };
-
-/**
- * DLL head for operation list
- */
-static struct OpListEntry *oplist_head;
-
-/**
- * DLL tail for operation list
- */
-static struct OpListEntry *oplist_tail;
-
-/**
- * Task running each round of the experiment.
- */
-static struct GNUNET_SCHEDULER_Task *round_task;
-
-
-/**
- * Clean up all of the monitoring connections to NSE and
- * STATISTICS that we keep to selected peers.
- */
-static void
-close_monitor_connections ()
-{
- struct NSEPeer *pos;
- struct OpListEntry *oplist_entry;
-
- while (NULL != (pos = peer_head))
- {
- if (NULL != pos->nse_op)
- GNUNET_TESTBED_operation_done (pos->nse_op);
- if (NULL != pos->stat_op)
- GNUNET_TESTBED_operation_done (pos->stat_op);
- GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos);
- GNUNET_free (pos);
- }
- while (NULL != (oplist_entry = oplist_head))
- {
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, oplist_entry);
- GNUNET_TESTBED_operation_done (oplist_entry->op);
- GNUNET_free (oplist_entry);
- }
-}
-
-
-/**
- * Task run on shutdown; cleans up everything.
- *
- * @param cls unused
- */
-static void
-shutdown_task (void *cls)
-{
- LOG_DEBUG ("Ending test.\n");
- close_monitor_connections ();
- if (NULL != round_task)
- {
- GNUNET_SCHEDULER_cancel (round_task);
- round_task = NULL;
- }
- if (NULL != data_file)
- {
- GNUNET_DISK_file_close (data_file);
- data_file = NULL;
- }
- if (NULL != output_file)
- {
- GNUNET_DISK_file_close (output_file);
- output_file = NULL;
- }
- if (NULL != testing_cfg)
- {
- GNUNET_CONFIGURATION_destroy (testing_cfg);
- testing_cfg = NULL;
- }
-}
-
-
-/**
- * Callback to call when network size estimate is updated.
- *
- * @param cls closure with the 'struct NSEPeer' providing the update
- * @param timestamp server timestamp
- * @param estimate the value of the current network size estimate
- * @param std_dev standard deviation (rounded down to nearest integer)
- * of the size estimation values seen
- */
-static void
-handle_estimate (void *cls,
- struct GNUNET_TIME_Absolute timestamp,
- double estimate,
- double std_dev)
-{
- struct NSEPeer *peer = cls;
- char output_buffer[512];
- size_t size;
-
- if (NULL == output_file)
- {
- fprintf (stderr,
- "Received network size estimate from peer %p. Size: %f std.dev.
%f\n",
- peer,
- estimate,
- std_dev);
- return;
- }
- size = GNUNET_snprintf (output_buffer,
- sizeof(output_buffer),
- "%p %u %llu %f %f %f\n",
- peer,
- peers_running,
- (unsigned long long) timestamp.abs_value_us,
- GNUNET_NSE_log_estimate_to_n (estimate),
- estimate,
- std_dev);
- if (size != GNUNET_DISK_file_write (output_file, output_buffer, size))
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * NSE service.
- *
- * @param cls closure (the 'struct NSEPeer')
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-nse_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct NSEPeer *current_peer = cls;
-
- return GNUNET_NSE_connect (cfg, &handle_estimate, current_peer);
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * NSE service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-nse_disconnect_adapter (void *cls, void *op_result)
-{
- GNUNET_NSE_disconnect (op_result);
-}
-
-
-/**
- * Callback function to process statistic values.
- *
- * @param cls `struct NSEPeer`
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if
not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-static int
-stat_iterator (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- char *output_buffer;
- struct GNUNET_TIME_Absolute now;
- int size;
- unsigned int flag;
-
- GNUNET_assert (NULL != data_file);
- now = GNUNET_TIME_absolute_get ();
- flag = strcasecmp (subsystem, "core");
- if (0 != flag)
- flag = 1;
- size = GNUNET_asprintf (&output_buffer,
- "%llu %llu %u\n",
- (unsigned long long) now.abs_value_us / 1000LL /
1000LL,
- (unsigned long long) value,
- flag);
- if (0 > size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Error formatting output
buffer.\n");
- GNUNET_free (output_buffer);
- return GNUNET_SYSERR;
- }
- if (size != GNUNET_DISK_file_write (data_file, output_buffer, (size_t) size))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
- GNUNET_free (output_buffer);
- return GNUNET_SYSERR;
- }
- GNUNET_free (output_buffer);
- return GNUNET_OK;
-}
-
-
-/**
- * Called to open a connection to the peer's statistics
- *
- * @param cls peer context
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-stat_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct NSEPeer *peer = cls;
-
- peer->sh = GNUNET_STATISTICS_create ("nse-profiler", cfg);
- return peer->sh;
-}
-
-
-/**
- * Called to disconnect from peer's statistics service
- *
- * @param cls peer context
- * @param op_result service handle returned from the connect adapter
- */
-static void
-stat_disconnect_adapter (void *cls, void *op_result)
-{
- struct NSEPeer *peer = cls;
-
- GNUNET_break (GNUNET_OK ==
- GNUNET_STATISTICS_watch_cancel (peer->sh,
- "core",
- "# peers connected",
- stat_iterator,
- peer));
- GNUNET_break (GNUNET_OK ==
- GNUNET_STATISTICS_watch_cancel (peer->sh,
- "nse",
- "# peers connected",
- stat_iterator,
- peer));
- GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
- peer->sh = NULL;
-}
-
-
-/**
- * Called after successfully opening a connection to a peer's statistics
- * service; we register statistics monitoring for CORE and NSE here.
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from
GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-stat_comp_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct GNUNET_STATISTICS_Handle *sh = ca_result;
- struct NSEPeer *peer = cls;
-
- if (NULL != emsg)
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch (sh,
- "core",
- "# peers connected",
- stat_iterator,
- peer));
- GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch (sh,
- "nse",
- "# peers connected",
- stat_iterator,
- peer));
-}
-
-
-/**
- * Task run to connect to the NSE and statistics services to a subset of
- * all of the running peers.
- */
-static void
-connect_nse_service ()
-{
- struct NSEPeer *current_peer;
- unsigned int i;
- unsigned int connections;
-
- if (0 == connection_limit)
- return;
- LOG_DEBUG ("Connecting to nse service of peers\n");
- connections = 0;
- for (i = 0; i < num_peers_in_round[current_round]; i++)
- {
- if ((num_peers_in_round[current_round] > connection_limit) &&
- (0 != (i % (num_peers_in_round[current_round] / connection_limit))))
- continue;
- LOG_DEBUG ("Connecting to nse service of peer %d\n", i);
- current_peer = GNUNET_new (struct NSEPeer);
- current_peer->daemon = daemons[i];
- current_peer->nse_op =
- GNUNET_TESTBED_service_connect (NULL,
- current_peer->daemon,
- "nse",
- NULL,
- NULL,
- &nse_connect_adapter,
- &nse_disconnect_adapter,
- current_peer);
- if (NULL != data_file)
- current_peer->stat_op =
- GNUNET_TESTBED_service_connect (NULL,
- current_peer->daemon,
- "statistics",
- stat_comp_cb,
- current_peer,
- &stat_connect_adapter,
- &stat_disconnect_adapter,
- current_peer);
- GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer);
- if (++connections == connection_limit)
- break;
- }
-}
-
-
-/**
- * Task that starts/stops peers to move to the next round.
- *
- * @param cls NULL, unused
- */
-static void
-next_round (void *cls);
-
-
-/**
- * We're at the end of a round. Stop monitoring, write total
- * number of connections to log and get full stats. Then trigger
- * the next round.
- *
- * @param cls unused, NULL
- */
-static void
-finish_round (void *cls)
-{
- LOG (GNUNET_ERROR_TYPE_INFO, "Have %u connections\n", total_connections);
- close_monitor_connections ();
- round_task = GNUNET_SCHEDULER_add_now (&next_round, NULL);
-}
-
-
-/**
- * We have reached the desired number of peers for the current round.
- * Run it (by connecting and monitoring a few peers and waiting the
- * specified delay before finishing the round).
- */
-static void
-run_round ()
-{
- LOG_DEBUG ("Running round %u\n", current_round);
- connect_nse_service ();
- GNUNET_SCHEDULER_add_delayed (wait_time, &finish_round, NULL);
-}
-
-
-/**
- * Creates an oplist entry and adds it to the oplist DLL
- */
-static struct OpListEntry *
-make_oplist_entry ()
-{
- struct OpListEntry *entry;
-
- entry = GNUNET_new (struct OpListEntry);
- GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry);
- return entry;
-}
-
-
-/**
- * Callback to be called when NSE service is started or stopped at peers
- *
- * @param cls NULL
- * @param op the operation handle
- * @param emsg NULL on success; otherwise an error description
- */
-static void
-manage_service_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const char *emsg)
-{
- struct OpListEntry *entry = cls;
-
- GNUNET_TESTBED_operation_done (entry->op);
- if (NULL != emsg)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop NSE at a peer\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_assert (0 != entry->delta);
- peers_running += entry->delta;
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- GNUNET_free (entry);
- if (num_peers_in_round[current_round] == peers_running)
- run_round ();
-}
-
-
-/**
- * Adjust the number of running peers to match the required number of running
- * peers for the round
- */
-static void
-adjust_running_peers ()
-{
- struct OpListEntry *entry;
- unsigned int i;
-
- /* start peers if we have too few */
- for (i = peers_running; i < num_peers_in_round[current_round]; i++)
- {
- entry = make_oplist_entry ();
- entry->delta = 1;
- entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
- daemons[i],
- "nse",
- &manage_service_cb,
- entry,
- 1);
- }
- /* stop peers if we have too many */
- for (i = num_peers_in_round[current_round]; i < peers_running; i++)
- {
- entry = make_oplist_entry ();
- entry->delta = -1;
- entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
- daemons[i],
- "nse",
- &manage_service_cb,
- entry,
- 0);
- }
-}
-
-
-/**
- * Task run at the end of a round. Disconnect from all monitored
- * peers; then get statistics from *all* peers.
- *
- * @param cls NULL, unused
- */
-static void
-next_round (void *cls)
-{
- round_task = NULL;
- LOG_DEBUG ("Disconnecting nse service of peers\n");
- current_round++;
- if (current_round == num_rounds)
- {
- /* this was the last round, terminate */
- ok = 0;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (num_peers_in_round[current_round] == peers_running)
- {
- /* no need to churn, just run next round */
- run_round ();
- return;
- }
- adjust_running_peers ();
-}
-
-
-/**
- * Function that will be called whenever something in the
- * testbed changes.
- *
- * @param cls closure, NULL
- * @param event information on what is happening
- */
-static void
-master_controller_cb (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
-{
- switch (event->type)
- {
- case GNUNET_TESTBED_ET_CONNECT:
- total_connections++;
- break;
-
- case GNUNET_TESTBED_ET_DISCONNECT:
- total_connections--;
- break;
-
- default:
- break;
- }
-}
-
-
-/**
- * Signature of a main function for a testcase.
- *
- * @param cls NULL
- * @param h the run handle
- * @param num_peers_ number of peers in 'peers'
- * @param peers handle to peers run in the testbed. NULL upon timeout (see
- * GNUNET_TESTBED_test_run()).
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-test_master (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers_,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- if (NULL == peers)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- daemons = peers;
- GNUNET_break (num_peers_ == num_peers);
- peers_running = num_peers;
- if (num_peers_in_round[current_round] == peers_running)
- {
- /* no need to churn, just run the starting round */
- run_round ();
- return;
- }
- adjust_running_peers ();
-}
-
-
-/**
- * Actual main function that runs the emulation.
- *
- * @param cls unused
- * @param args remaining args, unused
- * @param cfgfile name of the configuration
- * @param cfg configuration handle
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- char *tok;
- uint64_t event_mask;
- unsigned int num;
-
- ok = 1;
- testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
- LOG_DEBUG ("Starting daemons.\n");
- if (NULL == num_peer_spec)
- {
- fprintf (stderr, "You need to specify the number of peers to run\n");
- return;
- }
- for (tok = strtok (num_peer_spec, ","); NULL != tok; tok = strtok (NULL,
","))
- {
- if (1 != sscanf (tok, "%u", &num))
- {
- fprintf (stderr, "You need to specify numbers, not `%s'\n", tok);
- return;
- }
- if (0 == num)
- {
- fprintf (stderr, "Refusing to run a round with 0 peers\n");
- return;
- }
- GNUNET_array_append (num_peers_in_round, num_rounds, num);
- num_peers = GNUNET_MAX (num_peers, num);
- }
- if (0 == num_peers)
- {
- fprintf (stderr, "Refusing to run a testbed with no rounds\n");
- return;
- }
- if ((NULL != data_filename) &&
- (NULL ==
- (data_file = GNUNET_DISK_file_open (data_filename,
- GNUNET_DISK_OPEN_READWRITE
- | GNUNET_DISK_OPEN_TRUNCATE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE))))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", data_filename);
-
- if ((NULL != output_filename) &&
- (NULL ==
- (output_file = GNUNET_DISK_file_open (output_filename,
- GNUNET_DISK_OPEN_READWRITE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE))))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
output_filename);
- event_mask = 0LL;
- event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
- event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
- event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
- event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
- GNUNET_TESTBED_run (hosts_file,
- cfg,
- num_peers,
- event_mask,
- master_controller_cb,
- NULL, /* master_controller_cb cls */
- &test_master,
- NULL); /* test_master cls */
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
-}
-
-
-/**
- * Main function.
- *
- * @return 0 on success
- */
-int
-main (int argc, char *const *argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] =
- { GNUNET_GETOPT_option_uint (
- 'C',
- "connections",
- "COUNT",
- gettext_noop (
- "limit to the number of connections to NSE services, 0 for none"),
- &connection_limit),
- GNUNET_GETOPT_option_string (
- 'd',
- "details",
- "FILENAME",
- gettext_noop (
- "name of the file for writing connection information and statistics"),
- &data_filename),
-
- GNUNET_GETOPT_option_string (
- 'H',
- "hosts",
- "FILENAME",
- gettext_noop (
- "name of the file with the login information for the testbed"),
- &hosts_file),
-
- GNUNET_GETOPT_option_string (
- 'o',
- "output",
- "FILENAME",
- gettext_noop ("name of the file for writing the main results"),
- &output_filename),
-
-
- GNUNET_GETOPT_option_string (
- 'p',
- "peers",
- "NETWORKSIZESPEC",
- gettext_noop (
- "Number of peers to run in each round, separated by commas"),
- &num_peer_spec),
-
- GNUNET_GETOPT_option_increment_uint (
- 'V',
- "verbose",
- gettext_noop ("be verbose (print progress information)"),
- &verbose),
-
- GNUNET_GETOPT_option_relative_time ('w',
- "wait",
- "DELAY",
- gettext_noop ("delay between rounds"),
- &wait_time),
- GNUNET_GETOPT_OPTION_END };
-
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
- return 2;
- if (
- GNUNET_OK !=
- GNUNET_PROGRAM_run (argc,
- argv,
- "nse-profiler",
- gettext_noop (
- "Measure quality and performance of the NSE
service."),
- options,
- &run,
- NULL))
- ok = 1;
- return ok;
-}
-
-
-/* end of nse-profiler.c */
diff --git a/src/service/regex/Makefile.am b/src/service/regex/Makefile.am
index 255988889..0ce42880d 100644
--- a/src/service/regex/Makefile.am
+++ b/src/service/regex/Makefile.am
@@ -52,21 +52,6 @@ libgnunetregex_la_LDFLAGS = \
-version-info 3:1:0
-# FIXME we phased out mysql. If we want to keep, needs rewrite
-#if HAVE_MYSQL
-#noinst_mysql_progs = \
-# gnunet-regex-simulation-profiler
-
-#gnunet_regex_simulation_profiler_SOURCES = \
-# $(REGEX_INTERNAL) gnunet-regex-simulation-profiler.c
-#gnunet_regex_simulation_profiler_LDADD = \
-# libgnunetregexblock.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(top_builddir)/src/service/dht/libgnunetdht.la \
-# $(top_builddir)/src/lib/block/libgnunetblock.la \
-# $(top_builddir)/src/service/statistics/libgnunetstatistics.la
-#endif
-
noinst_PROGRAMS = $(noinst_mysql_progs) \
perf-regex
@@ -151,5 +136,4 @@ test_regex_graph_api_LDADD = -lm \
EXTRA_DIST = \
- regex_simulation_profiler_test.conf \
test_regex_api_data.conf
diff --git a/src/service/regex/gnunet-regex-simulation-profiler.c
b/src/service/regex/gnunet-regex-simulation-profiler.c
deleted file mode 100644
index abdb1abeb..000000000
--- a/src/service/regex/gnunet-regex-simulation-profiler.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-
-/**
- * @file regex/gnunet-regex-simulation-profiler.c
- * @brief Regex profiler that dumps all DFAs into a database instead of
- * using the DHT (with cadet).
- * @author Maximilian Szengel
- * @author Christophe Genevey
- *
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "regex_internal_lib.h"
-#include "gnunet_mysql_lib.h"
-#include "gnunet_mysql_compat.h"
-#include "gnunet_my_lib.h"
-#include <mysql/mysql.h>
-
-/**
- * MySQL statement to insert an edge.
- */
-#define INSERT_EDGE_STMT "INSERT IGNORE INTO `%s` " \
- "(`key`, `label`, `to_key`, `accepting`) " \
- "VALUES (?, ?, ?, ?);"
-
-/**
- * MySQL statement to select a key count.
- */
-#define SELECT_KEY_STMT "SELECT COUNT(*) FROM `%s` " \
- "WHERE `key` = ? AND `label` = ?;"
-
-/**
- * Simple struct to keep track of progress, and print a
- * nice little percentage meter for long running tasks.
- */
-struct ProgressMeter
-{
- /**
- * Total number of elements.
- */
- unsigned int total;
-
- /**
- * Interval for printing percentage.
- */
- unsigned int modnum;
-
- /**
- * Number of dots to print.
- */
- unsigned int dotnum;
-
- /**
- * Completed number.
- */
- unsigned int completed;
-
- /**
- * Should the meter be printed?
- */
- int print;
-
- /**
- * String to print on startup.
- */
- char *startup_string;
-};
-
-
-/**
- * Handle for the progress meter
- */
-static struct ProgressMeter *meter;
-
-/**
- * Scan task identifier;
- */
-static struct GNUNET_SCHEDULER_Task *scan_task;
-
-/**
- * Global testing status.
- */
-static int result;
-
-/**
- * MySQL context.
- */
-static struct GNUNET_MYSQL_Context *mysql_ctx;
-
-/**
- * MySQL prepared statement handle.
- */
-static struct GNUNET_MYSQL_StatementHandle *stmt_handle;
-
-/**
- * MySQL prepared statement handle for `key` select.
- */
-static struct GNUNET_MYSQL_StatementHandle *select_stmt_handle;
-
-/**
- * MySQL table name.
- */
-static char *table_name;
-
-/**
- * Policy dir containing files that contain policies.
- */
-static char *policy_dir;
-
-/**
- * Number of policy files.
- */
-static unsigned int num_policy_files;
-
-/**
- * Number of policies.
- */
-static unsigned int num_policies;
-
-/**
- * Maximal path compression length.
- */
-static unsigned int max_path_compression;
-
-/**
- * Number of merged transitions.
- */
-static unsigned long long num_merged_transitions;
-
-/**
- * Number of merged states from different policies.
- */
-static unsigned long long num_merged_states;
-
-/**
- * Prefix to add before every regex we're announcing.
- */
-static char *regex_prefix;
-
-
-/**
- * Create a meter to keep track of the progress of some task.
- *
- * @param total the total number of items to complete
- * @param start_string a string to prefix the meter with (if printing)
- * @param print GNUNET_YES to print the meter, GNUNET_NO to count
- * internally only
- *
- * @return the progress meter
- */
-static struct ProgressMeter *
-create_meter (unsigned int total, char *start_string, int print)
-{
- struct ProgressMeter *ret;
-
- ret = GNUNET_new (struct ProgressMeter);
- ret->print = print;
- ret->total = total;
- ret->modnum = total / 4;
- if (ret->modnum == 0) /* Divide by zero check */
- ret->modnum = 1;
- ret->dotnum = (total / 50) + 1;
- if (start_string != NULL)
- ret->startup_string = GNUNET_strdup (start_string);
- else
- ret->startup_string = GNUNET_strdup ("");
-
- return ret;
-}
-
-
-/**
- * Update progress meter (increment by one).
- *
- * @param meter the meter to update and print info for
- *
- * @return GNUNET_YES if called the total requested,
- * GNUNET_NO if more items expected
- */
-static int
-update_meter (struct ProgressMeter *meter)
-{
- if (meter->print == GNUNET_YES)
- {
- if (meter->completed % meter->modnum == 0)
- {
- if (meter->completed == 0)
- {
- fprintf (stdout, "%sProgress: [0%%", meter->startup_string);
- }
- else
- fprintf (stdout, "%d%%",
- (int) (((float) meter->completed / meter->total) * 100));
- }
- else if (meter->completed % meter->dotnum == 0)
- fprintf (stdout, "%s", ".");
-
- if (meter->completed + 1 == meter->total)
- fprintf (stdout, "%d%%]\n", 100);
- fflush (stdout);
- }
- meter->completed++;
-
- if (meter->completed == meter->total)
- return GNUNET_YES;
- if (meter->completed > meter->total)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Progress meter overflow!!\n");
- return GNUNET_NO;
-}
-
-
-/**
- * Reset progress meter.
- *
- * @param meter the meter to reset
- *
- * @return #GNUNET_YES if meter reset,
- * #GNUNET_SYSERR on error
- */
-static int
-reset_meter (struct ProgressMeter *meter)
-{
- if (meter == NULL)
- return GNUNET_SYSERR;
-
- meter->completed = 0;
- return GNUNET_YES;
-}
-
-
-/**
- * Release resources for meter
- *
- * @param meter the meter to free
- */
-static void
-free_meter (struct ProgressMeter *meter)
-{
- GNUNET_free (meter->startup_string);
- GNUNET_free (meter);
-}
-
-
-/**
- * Shutdown task.
- *
- * @param cls NULL
- */
-static void
-do_shutdown (void *cls)
-{
- if (NULL != mysql_ctx)
- {
- GNUNET_MYSQL_context_destroy (mysql_ctx);
- mysql_ctx = NULL;
- }
- if (NULL != meter)
- {
- free_meter (meter);
- meter = NULL;
- }
-}
-
-
-/**
- * Abort task to run on test timed out.
- *
- * FIXME: this doesn't actually work, it used to cancel
- * the already running 'scan_task', but now that should
- * always be NULL and do nothing. We instead need to set
- * a global variable and abort scan_task internally, not
- * via scheduler.
- *
- * @param cls NULL
- */
-static void
-do_abort (void *cls)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting\n");
- if (NULL != scan_task)
- {
- GNUNET_SCHEDULER_cancel (scan_task);
- scan_task = NULL;
- }
- result = GNUNET_SYSERR;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Iterator over all states that inserts each state into the MySQL db.
- *
- * @param cls closure.
- * @param key hash for current state.
- * @param proof proof for current state.
- * @param accepting #GNUNET_YES if this is an accepting state, #GNUNET_NO if
not.
- * @param num_edges number of edges leaving current state.
- * @param edges edges leaving current state.
- */
-static void
-regex_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- const char *proof,
- int accepting,
- unsigned int num_edges,
- const struct REGEX_BLOCK_Edge *edges)
-{
- unsigned int i;
- int result;
-
- uint32_t iaccepting = (uint32_t) accepting;
- uint64_t total;
-
- GNUNET_assert (NULL != mysql_ctx);
-
- for (i = 0; i < num_edges; i++)
- {
- struct GNUNET_MY_QueryParam params_select[] = {
- GNUNET_MY_query_param_auto_from_type (key),
- GNUNET_MY_query_param_string (edges[i].label),
- GNUNET_MY_query_param_end
- };
-
- struct GNUNET_MY_ResultSpec results_select[] = {
- GNUNET_MY_result_spec_uint64 (&total),
- GNUNET_MY_result_spec_end
- };
-
- result =
- GNUNET_MY_exec_prepared (mysql_ctx,
- select_stmt_handle,
- params_select);
-
- if (GNUNET_SYSERR == result)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error executing prepared mysql select statement\n");
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- return;
- }
-
- result =
- GNUNET_MY_extract_result (select_stmt_handle,
- results_select);
-
- if (GNUNET_SYSERR == result)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error extracting result mysql select statement\n");
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- return;
- }
-
- if ((-1 != total) && (total > 0) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Total: %llu (%s, %s)\n",
- (unsigned long long) total,
- GNUNET_h2s (key), edges[i].label);
- }
-
- struct GNUNET_MY_QueryParam params_stmt[] = {
- GNUNET_MY_query_param_auto_from_type (&key),
- GNUNET_MY_query_param_string (edges[i].label),
- GNUNET_MY_query_param_auto_from_type (&edges[i].destination),
- GNUNET_MY_query_param_uint32 (&iaccepting),
- GNUNET_MY_query_param_end
- };
-
- result =
- GNUNET_MY_exec_prepared (mysql_ctx,
- stmt_handle,
- params_stmt);
-
- if (0 == result)
- {
- char *key_str = GNUNET_strdup (GNUNET_h2s (key));
- char *to_key_str = GNUNET_strdup (GNUNET_h2s (&edges[i].destination));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Merged (%s, %s, %s, %i)\n",
- key_str,
- edges[i].label,
- to_key_str,
- accepting);
-
- GNUNET_free (key_str);
- GNUNET_free (to_key_str);
- num_merged_transitions++;
- }
- else if (-1 != total)
- {
- num_merged_states++;
- }
-
- if ((GNUNET_SYSERR == result) || ((1 != result) && (0 != result) ))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error executing prepared mysql statement for edge: Affected
rows: %i, expected 0 or 1!\n",
- result);
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- }
- }
-
- if (0 == num_edges)
- {
- struct GNUNET_MY_QueryParam params_stmt[] = {
- GNUNET_MY_query_param_auto_from_type (key),
- GNUNET_MY_query_param_string (""),
- GNUNET_MY_query_param_fixed_size (NULL, 0),
- GNUNET_MY_query_param_uint32 (&iaccepting),
- GNUNET_MY_query_param_end
- };
-
- result =
- GNUNET_MY_exec_prepared (mysql_ctx,
- stmt_handle,
- params_stmt);
-
- if ((1 != result) && (0 != result) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error executing prepared mysql statement for edge: Affected
rows: %i, expected 0 or 1!\n",
- result);
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- }
- }
-}
-
-
-/**
- * Announce a regex by creating the DFA and iterating over each state,
inserting
- * each state into a MySQL database.
- *
- * @param regex regular expression.
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure.
- */
-static int
-announce_regex (const char *regex)
-{
- struct REGEX_INTERNAL_Automaton *dfa;
-
- dfa =
- REGEX_INTERNAL_construct_dfa (regex,
- strlen (regex),
- max_path_compression);
-
- if (NULL == dfa)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to create DFA for regex %s\n",
- regex);
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- return GNUNET_SYSERR;
- }
- REGEX_INTERNAL_iterate_all_edges (dfa,
- ®ex_iterator, NULL);
- REGEX_INTERNAL_automaton_destroy (dfa);
-
- return GNUNET_OK;
-}
-
-
-/**
- * Function called with a filename.
- *
- * @param cls closure
- * @param filename complete filename (absolute path)
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-policy_filename_cb (void *cls, const char *filename)
-{
- char *regex;
- char *data;
- char *buf;
- uint64_t filesize;
- unsigned int offset;
-
- GNUNET_assert (NULL != filename);
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Announcing regexes from file %s\n",
- filename);
-
- if (GNUNET_YES != GNUNET_DISK_file_test (filename))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Could not find policy file %s\n",
- filename);
- return GNUNET_OK;
- }
- if (GNUNET_OK !=
- GNUNET_DISK_file_size (filename, &filesize,
- GNUNET_YES, GNUNET_YES))
- filesize = 0;
- if (0 == filesize)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Policy file %s is empty.\n",
- filename);
- return GNUNET_OK;
- }
- data = GNUNET_malloc (filesize);
- if (filesize != GNUNET_DISK_fn_read (filename, data, filesize))
- {
- GNUNET_free (data);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Could not read policy file %s.\n",
- filename);
- return GNUNET_OK;
- }
-
- update_meter (meter);
-
- buf = data;
- offset = 0;
- regex = NULL;
- while (offset < (filesize - 1))
- {
- offset++;
- if (((data[offset] == '\n')) && (buf != &data[offset]))
- {
- data[offset] = '|';
- num_policies++;
- buf = &data[offset + 1];
- }
- else if ((data[offset] == '\n') || (data[offset] == '\0'))
- buf = &data[offset + 1];
- }
- data[offset] = '\0';
- GNUNET_asprintf (®ex, "%s(%s)", regex_prefix, data);
- GNUNET_assert (NULL != regex);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Announcing regex: %s\n", regex);
-
- if (GNUNET_OK != announce_regex (regex))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not announce regex %s\n",
- regex);
- }
- GNUNET_free (regex);
- GNUNET_free (data);
- return GNUNET_OK;
-}
-
-
-/**
- * Iterate over files contained in policy_dir.
- *
- * @param cls NULL
- */
-static void
-do_directory_scan (void *cls)
-{
- struct GNUNET_TIME_Absolute start_time;
- struct GNUNET_TIME_Relative duration;
- char *stmt;
-
- /* Create an MySQL prepared statement for the inserts */
- scan_task = NULL;
- GNUNET_asprintf (&stmt, INSERT_EDGE_STMT, table_name);
- stmt_handle = GNUNET_MYSQL_statement_prepare (mysql_ctx, stmt);
- GNUNET_free (stmt);
-
- GNUNET_asprintf (&stmt, SELECT_KEY_STMT, table_name);
- select_stmt_handle = GNUNET_MYSQL_statement_prepare (mysql_ctx, stmt);
- GNUNET_free (stmt);
-
- GNUNET_assert (NULL != stmt_handle);
-
- meter = create_meter (num_policy_files,
- "Announcing policy files\n",
- GNUNET_YES);
- start_time = GNUNET_TIME_absolute_get ();
- GNUNET_DISK_directory_scan (policy_dir,
- &policy_filename_cb,
- stmt_handle);
- duration = GNUNET_TIME_absolute_get_duration (start_time);
- reset_meter (meter);
- free_meter (meter);
- meter = NULL;
-
- printf ("Announced %u files containing %u policies in %s\n"
- "Duplicate transitions: %llu\nMerged states: %llu\n",
- num_policy_files,
- num_policies,
- GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_NO),
- num_merged_transitions,
- num_merged_states);
- result = GNUNET_OK;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be
NULL!)
- * @param config configuration
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *config)
-{
- if (NULL == args[0])
- {
- fprintf (stderr,
- _ ("No policy directory specified on command line. Exiting.\n"));
- result = GNUNET_SYSERR;
- return;
- }
- if (GNUNET_YES !=
- GNUNET_DISK_directory_test (args[0], GNUNET_YES))
- {
- fprintf (stderr,
- _ ("Specified policies directory does not exist. Exiting.\n"));
- result = GNUNET_SYSERR;
- return;
- }
- policy_dir = args[0];
-
- num_policy_files = GNUNET_DISK_directory_scan (policy_dir,
- NULL, NULL);
- meter = NULL;
-
- if (NULL == table_name)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "No table name specified, using default \"NFA\".\n");
- table_name = "NFA";
- }
-
- mysql_ctx = GNUNET_MYSQL_context_create (config, "regex-mysql");
- if (NULL == mysql_ctx)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to create mysql context\n");
- result = GNUNET_SYSERR;
- return;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (config,
- "regex-mysql",
- "REGEX_PREFIX",
- ®ex_prefix))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "regex-mysql",
- "REGEX_PREFIX");
- result = GNUNET_SYSERR;
- return;
- }
-
- result = GNUNET_OK;
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
- scan_task = GNUNET_SCHEDULER_add_now (&do_directory_scan, NULL);
-}
-
-
-/**
- * Main function.
- *
- * @param argc argument count
- * @param argv argument values
- * @return 0 on success
- */
-int
-main (int argc, char *const *argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_string ('t',
- "table",
- "TABLENAME",
- gettext_noop (
- "name of the table to write DFAs"),
- &table_name),
-
- GNUNET_GETOPT_option_uint ('p',
- "max-path-compression",
- "MAX_PATH_COMPRESSION",
- gettext_noop ("maximum path compression
length"),
- &max_path_compression),
-
- GNUNET_GETOPT_OPTION_END
- };
- int ret;
-
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
- return 2;
-
- result = GNUNET_SYSERR;
- ret =
- GNUNET_PROGRAM_run (argc, argv,
- "gnunet-regex-simulationprofiler [OPTIONS] policy-dir",
- _ ("Profiler for regex library"), options, &run, NULL);
- if (GNUNET_OK != ret)
- return ret;
- if (GNUNET_OK != result)
- return 1;
- return 0;
-}
diff --git a/src/service/regex/regex_simulation_profiler_test.conf
b/src/service/regex/regex_simulation_profiler_test.conf
deleted file mode 100644
index 9384aa249..000000000
--- a/src/service/regex/regex_simulation_profiler_test.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-[regex-mysql]
-DATABASE = regex
-USER = gnunet
-PASSWORD =
-HOST = localhost
-PORT = 3306
-REGEX_PREFIX = GNVPN-0001-PAD
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: build: more post-tng unused source cleanup,
gnunet <=