aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-05-24 12:27:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-05-24 12:27:28 +0000
commit6c1e65fe29f0dbd66b38b6b0b489bd211fab9882 (patch)
tree12b2e3a74494b3dad5647bfa0b54a007cc0bc8ab
parent0544eb9dddba58527a559800ad399a65f225820f (diff)
downloadgnunet-6c1e65fe29f0dbd66b38b6b0b489bd211fab9882.tar.gz
gnunet-6c1e65fe29f0dbd66b38b6b0b489bd211fab9882.zip
issuer
-rw-r--r--src/experimentation/Makefile.am5
-rw-r--r--src/experimentation/experimentation.conf.in1
-rw-r--r--src/experimentation/gnunet-daemon-experimentation.c9
-rw-r--r--src/experimentation/gnunet-daemon-experimentation.h32
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_capabilities.c (renamed from src/experimentation/gnunet-daemon-experimentation_capabilites.c)15
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_experiments.c108
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_nodes.c2
-rw-r--r--src/experimentation/test_experimentation_clique.c16
-rw-r--r--src/experimentation/test_experimentation_clique.conf7
9 files changed, 181 insertions, 14 deletions
diff --git a/src/experimentation/Makefile.am b/src/experimentation/Makefile.am
index 8252e74cb..2521e48ba 100644
--- a/src/experimentation/Makefile.am
+++ b/src/experimentation/Makefile.am
@@ -34,8 +34,9 @@ libexec_PROGRAMS = \
34 34
35gnunet_daemon_experimentation_SOURCES = \ 35gnunet_daemon_experimentation_SOURCES = \
36 gnunet-daemon-experimentation.c \ 36 gnunet-daemon-experimentation.c \
37 gnunet-daemon-experimentation_capabilites.c \ 37 gnunet-daemon-experimentation_capabilities.c \
38 gnunet-daemon-experimentation_nodes.c 38 gnunet-daemon-experimentation_nodes.c \
39 gnunet-daemon-experimentation_experiments.c
39gnunet_daemon_experimentation_LDADD = \ 40gnunet_daemon_experimentation_LDADD = \
40 $(top_builddir)/src/core/libgnunetcore.la \ 41 $(top_builddir)/src/core/libgnunetcore.la \
41 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 42 $(top_builddir)/src/statistics/libgnunetstatistics.la \
diff --git a/src/experimentation/experimentation.conf.in b/src/experimentation/experimentation.conf.in
index 058dac035..6597dd0c1 100644
--- a/src/experimentation/experimentation.conf.in
+++ b/src/experimentation/experimentation.conf.in
@@ -9,3 +9,4 @@ ACCEPT_FROM6 = ::1;
9UNIXPATH = /tmp/gnunet-daemon-experimentation.sock 9UNIXPATH = /tmp/gnunet-daemon-experimentation.sock
10UNIX_MATCH_UID = YES 10UNIX_MATCH_UID = YES
11UNIX_MATCH_GID = YES 11UNIX_MATCH_GID = YES
12ISSUERS = TFRM29O2RQNKLVBQIGODJ6GD58LSQ2NM9TNFBC6N48BRJHQO38Q73N2OM3V4CLKDM6CILQV4CU8PMJDRG0FNB0PDI057DBRANMLPLRG \ No newline at end of file
diff --git a/src/experimentation/gnunet-daemon-experimentation.c b/src/experimentation/gnunet-daemon-experimentation.c
index 824eab580..78177f59c 100644
--- a/src/experimentation/gnunet-daemon-experimentation.c
+++ b/src/experimentation/gnunet-daemon-experimentation.c
@@ -46,6 +46,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
46{ 46{
47 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Experimentation daemon shutting down ...\n")); 47 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Experimentation daemon shutting down ...\n"));
48 GNUNET_EXPERIMENTATION_nodes_stop (); 48 GNUNET_EXPERIMENTATION_nodes_stop ();
49 GNUNET_EXPERIMENTATION_experiments_stop ();
49 GNUNET_EXPERIMENTATION_capabilities_stop (); 50 GNUNET_EXPERIMENTATION_capabilities_stop ();
50} 51}
51 52
@@ -73,12 +74,16 @@ run (void *cls, char *const *args, const char *cfgfile,
73 return; 74 return;
74 } 75 }
75 76
76 GNUNET_EXPERIMENTATION_capabilities_start(); 77 GNUNET_EXPERIMENTATION_capabilities_start ();
78 if (GNUNET_SYSERR == GNUNET_EXPERIMENTATION_experiments_start ())
79 {
80 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
81 return;
82 }
77 GNUNET_EXPERIMENTATION_nodes_start (); 83 GNUNET_EXPERIMENTATION_nodes_start ();
78 84
79 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 85 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
80 NULL); 86 NULL);
81
82} 87}
83 88
84 89
diff --git a/src/experimentation/gnunet-daemon-experimentation.h b/src/experimentation/gnunet-daemon-experimentation.h
index 81d70f668..d7508f9fc 100644
--- a/src/experimentation/gnunet-daemon-experimentation.h
+++ b/src/experimentation/gnunet-daemon-experimentation.h
@@ -120,6 +120,14 @@ GNUNET_EXPERIMENTATION_nodes_start ();
120void 120void
121GNUNET_EXPERIMENTATION_nodes_stop (); 121GNUNET_EXPERIMENTATION_nodes_stop ();
122 122
123/**
124 * Are the capabilities provided?
125 *
126 * @param have bitstring containing the provided capabilities
127 * @param have bitstring containing the desired capabilities
128 */
129int
130GNUNET_EXPERIMENTATION_capabilities_have (uint32_t have, uint32_t desired);
123 131
124/** 132/**
125 * Start the detecting capabilities 133 * Start the detecting capabilities
@@ -134,4 +142,28 @@ void
134GNUNET_EXPERIMENTATION_capabilities_stop (); 142GNUNET_EXPERIMENTATION_capabilities_stop ();
135 143
136 144
145/**
146 * Start experiments management
147 *
148 * @return GNUNET_YES or GNUNET_NO
149 */
150int
151GNUNET_EXPERIMENTATION_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID);
152
153
154/**
155 * Start experiments management
156 *
157 * @return GNUNET_OK on success, GNUNET_SYSERR on error
158 */
159int
160GNUNET_EXPERIMENTATION_experiments_start ();
161
162/**
163 * Stop experiments management
164 */
165void
166GNUNET_EXPERIMENTATION_experiments_stop ();
167
168
137/* end of gnunet-daemon-experimentation.h */ 169/* end of gnunet-daemon-experimentation.h */
diff --git a/src/experimentation/gnunet-daemon-experimentation_capabilites.c b/src/experimentation/gnunet-daemon-experimentation_capabilities.c
index e77dbfab7..74220435a 100644
--- a/src/experimentation/gnunet-daemon-experimentation_capabilites.c
+++ b/src/experimentation/gnunet-daemon-experimentation_capabilities.c
@@ -65,11 +65,16 @@ GNUNET_EXPERIMENTATION_capability_to_str (uint32_t cap)
65 65
66} 66}
67 67
68 68/**
69uint32_t 69 * Are the capabilities provided?
70GNUNET_EXPERIMENTATION_capabilities_have (uint32_t cap) 70 *
71 * @param have bitstring containing the provided capabilities
72 * @param have bitstring containing the desired capabilities
73 */
74int
75GNUNET_EXPERIMENTATION_capabilities_have (uint32_t have, uint32_t desired)
71{ 76{
72 if (cap == (cap & GSE_node_capabilities)) 77 if (desired == (desired & have))
73 return GNUNET_YES; 78 return GNUNET_YES;
74 else 79 else
75 return GNUNET_NO; 80 return GNUNET_NO;
@@ -132,7 +137,7 @@ GNUNET_EXPERIMENTATION_capabilities_start ()
132 { 137 {
133 index = 1; 138 index = 1;
134 index = index << c1; 139 index = index << c1;
135 if (GNUNET_YES == GNUNET_EXPERIMENTATION_capabilities_have (index)) 140 if (GNUNET_YES == GNUNET_EXPERIMENTATION_capabilities_have (GSE_node_capabilities, index))
136 { 141 {
137 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "We have `%s'\n", 142 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "We have `%s'\n",
138 GNUNET_EXPERIMENTATION_capability_to_str(index)); 143 GNUNET_EXPERIMENTATION_capability_to_str(index));
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c
new file mode 100644
index 000000000..9740e1f77
--- /dev/null
+++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c
@@ -0,0 +1,108 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file experimentation/gnunet-daemon-experimentation_experiments.c
23 * @brief experimentation daemon: experiment management
24 * @author Christian Grothoff
25 * @author Matthias Wachs
26 */
27#include "platform.h"
28#include "gnunet_getopt_lib.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_core_service.h"
31#include "gnunet_statistics_service.h"
32#include "gnunet-daemon-experimentation.h"
33
34struct GNUNET_CONTAINER_MultiHashMap *issuer;
35
36/**
37 * Is peer a valid issuer
38 *
39 * @return GNUNET_YES or GNUNET_NO
40 */
41int
42GNUNET_EXPERIMENTATION_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID)
43{
44 if (GNUNET_CONTAINER_multihashmap_contains (issuer, &issuer_ID->hashPubKey))
45 return GNUNET_YES;
46 else
47 return GNUNET_NO;
48}
49
50
51/**
52 * Start experiments management
53 */
54int
55GNUNET_EXPERIMENTATION_experiments_start ()
56{
57 char *issuers;
58 char *pos;
59 struct GNUNET_PeerIdentity issuer_ID;
60
61 /* Load valid issuer */
62 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (GSE_cfg, "EXPERIMENTATION", "ISSUERS", &issuers))
63 {
64 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n"));
65 return GNUNET_SYSERR;
66 }
67
68 issuer = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
69
70 for (pos = strtok (issuers, " "); pos != NULL; pos = strtok (NULL, " "))
71 {
72
73 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (pos, &issuer_ID.hashPubKey))
74 {
75 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid value `%s'\n"), pos);
76 }
77 else
78 {
79 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "`%s' is a valid issuer \n", GNUNET_i2s (&issuer_ID));
80 GNUNET_CONTAINER_multihashmap_put (issuer, &issuer_ID.hashPubKey,
81 NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
82 }
83 }
84 GNUNET_free (issuers);
85
86 if (0 == GNUNET_CONTAINER_multihashmap_size (issuer))
87 {
88 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n"));
89 GNUNET_EXPERIMENTATION_experiments_stop ();
90 return GNUNET_SYSERR;
91 }
92
93 GNUNET_STATISTICS_set (GSE_stats, "# issuer", GNUNET_CONTAINER_multihashmap_size (issuer), GNUNET_NO);
94 return GNUNET_OK;
95}
96
97/**
98 * Stop experiments management
99 */
100void
101GNUNET_EXPERIMENTATION_experiments_stop ()
102{
103 if (NULL != issuer)
104 GNUNET_CONTAINER_multihashmap_destroy (issuer);
105 issuer = NULL;
106}
107
108/* end of gnunet-daemon-experimentation_experiments.c */
diff --git a/src/experimentation/gnunet-daemon-experimentation_nodes.c b/src/experimentation/gnunet-daemon-experimentation_nodes.c
index cb94ddca0..2ddfb4dcb 100644
--- a/src/experimentation/gnunet-daemon-experimentation_nodes.c
+++ b/src/experimentation/gnunet-daemon-experimentation_nodes.c
@@ -410,8 +410,6 @@ core_receive_handler (void *cls,
410 410
411/** 411/**
412 * Start the nodes management 412 * Start the nodes management
413 *
414 * @param cfg configuration handle
415 */ 413 */
416void 414void
417GNUNET_EXPERIMENTATION_nodes_start () 415GNUNET_EXPERIMENTATION_nodes_start ()
diff --git a/src/experimentation/test_experimentation_clique.c b/src/experimentation/test_experimentation_clique.c
index a71010441..f4a195fb0 100644
--- a/src/experimentation/test_experimentation_clique.c
+++ b/src/experimentation/test_experimentation_clique.c
@@ -85,6 +85,7 @@ struct ExperimentationPeer
85 unsigned int active_nodes; 85 unsigned int active_nodes;
86 unsigned int requested_nodes; 86 unsigned int requested_nodes;
87 unsigned int inactive_nodes; 87 unsigned int inactive_nodes;
88 unsigned int issuer;
88}; 89};
89 90
90 91
@@ -160,18 +161,23 @@ check_end ()
160 unsigned int total_active = 0; 161 unsigned int total_active = 0;
161 unsigned int total_inactive = 0; 162 unsigned int total_inactive = 0;
162 unsigned int total_requested = 0; 163 unsigned int total_requested = 0;
164 unsigned int issuer = 0;
163 165
164 for (peer = 0; peer < NUM_PEERS; peer++) 166 for (peer = 0; peer < NUM_PEERS; peer++)
165 { 167 {
166 total_active += ph[peer].active_nodes; 168 total_active += ph[peer].active_nodes;
167 total_requested += ph[peer].requested_nodes; 169 total_requested += ph[peer].requested_nodes;
168 total_inactive += ph[peer].inactive_nodes; 170 total_inactive += ph[peer].inactive_nodes;
171 if (1 == ph[peer].issuer)
172 issuer ++;
173
169 } 174 }
170 if (last_value < total_active) 175 if (last_value < total_active)
171 fprintf (stderr, "."); 176 fprintf (stderr, ".");
172 177
173 if ((total_active == (NUM_PEERS * (NUM_PEERS -1))) && 178 if ((total_active == (NUM_PEERS * (NUM_PEERS -1))) &&
174 (total_requested == 0) && (total_inactive == 0)) 179 (total_requested == 0) && (total_inactive == 0) &&
180 (issuer == NUM_PEERS))
175 { 181 {
176 fprintf (stderr, "\n"); 182 fprintf (stderr, "\n");
177 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All %u peers active in a clique\n", NUM_PEERS); 183 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All %u peers active in a clique\n", NUM_PEERS);
@@ -209,6 +215,11 @@ stat_iterator (void *cls, const char *subsystem, const char *name,
209 { 215 {
210 peer->requested_nodes = value; 216 peer->requested_nodes = value;
211 } 217 }
218 if (0 == strcmp (name, "# issuer"))
219 {
220 peer->issuer = value;
221 }
222
212 check_end (); 223 check_end ();
213 224
214 return GNUNET_OK; 225 return GNUNET_OK;
@@ -246,6 +257,9 @@ stat_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
246 GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch 257 GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
247 (sh, "experimentation", "# nodes requested", 258 (sh, "experimentation", "# nodes requested",
248 stat_iterator, peer)); 259 stat_iterator, peer));
260 GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
261 (sh, "experimentation", "# issuer",
262 stat_iterator, peer));
249} 263}
250 264
251/** 265/**
diff --git a/src/experimentation/test_experimentation_clique.conf b/src/experimentation/test_experimentation_clique.conf
index fc4af4004..8380a31f8 100644
--- a/src/experimentation/test_experimentation_clique.conf
+++ b/src/experimentation/test_experimentation_clique.conf
@@ -17,7 +17,9 @@ AUTOSTART = NO
17AUTOSTART = NO 17AUTOSTART = NO
18 18
19[dht] 19[dht]
20AUTOSTART = NO 20AUTOSTART = YES
21DISABLE_TRY_CONNECT = NO
22
21 23
22[block] 24[block]
23plugins = dht test 25plugins = dht test
@@ -35,6 +37,7 @@ PORT = 12365
35 37
36[experimentation] 38[experimentation]
37#PREFIX = valgrind --leak-check=full 39#PREFIX = valgrind --leak-check=full
40ISSUERS = TFRM29O2RQNKLVBQIGODJ6GD58LSQ2NM9TNFBC6N48BRJHQO38Q73N2OM3V4CLKDM6CILQV4CU8PMJDRG0FNB0PDI057DBRANMLPLRG
38 41
39[ats] 42[ats]
40WAN_QUOTA_OUT = 3932160 43WAN_QUOTA_OUT = 3932160
@@ -46,7 +49,7 @@ AUTOSTART = YES
46USE_EPHEMERAL_KEYS = NO 49USE_EPHEMERAL_KEYS = NO
47 50
48[arm] 51[arm]
49DEFAULTSERVICES = core transport experimentation 52DEFAULTSERVICES = core transport experimentation dht
50PORT = 12366 53PORT = 12366
51 54
52[transport-udp] 55[transport-udp]