aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_topo.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-11-02 10:19:00 +0000
committerChristian Grothoff <christian@grothoff.org>2012-11-02 10:19:00 +0000
commitc6ef80f13164795b0b53bc7c4c7cae2452cf861e (patch)
tree9205d3cf10cc02c359b229e291375ca483f93090 /src/dht/test_dht_topo.c
parent2100eaeefbccd6cb2b6f952320092542f82a2051 (diff)
downloadgnunet-c6ef80f13164795b0b53bc7c4c7cae2452cf861e.tar.gz
gnunet-c6ef80f13164795b0b53bc7c4c7cae2452cf861e.zip
-major DHT test cleanup
Diffstat (limited to 'src/dht/test_dht_topo.c')
-rw-r--r--src/dht/test_dht_topo.c160
1 files changed, 145 insertions, 15 deletions
diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c
index 0934d7abd..c9036d2c1 100644
--- a/src/dht/test_dht_topo.c
+++ b/src/dht/test_dht_topo.c
@@ -30,11 +30,6 @@
30#include "dht_test_lib.h" 30#include "dht_test_lib.h"
31 31
32/** 32/**
33 * Number of peers to run.
34 */
35#define NUM_PEERS 5
36
37/**
38 * How long until we give up on fetching the data? 33 * How long until we give up on fetching the data?
39 */ 34 */
40#define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) 35#define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
@@ -93,6 +88,131 @@ static struct GetOperation *get_head;
93 */ 88 */
94static struct GetOperation *get_tail; 89static struct GetOperation *get_tail;
95 90
91/**
92 * Array of the testbed's peers.
93 */
94static struct GNUNET_TESTBED_Peer **my_peers;
95
96/**
97 * Number of peers to run.
98 */
99static unsigned int NUM_PEERS;
100
101
102/**
103 * Statistics we print out.
104 */
105static struct
106{
107 const char *subsystem;
108 const char *name;
109 unsigned long long total;
110} stats[] = {
111 {"core", "# bytes decrypted", 0},
112 {"core", "# bytes encrypted", 0},
113 {"core", "# type maps received", 0},
114 {"core", "# session keys confirmed via PONG", 0},
115 {"core", "# peers connected", 0},
116 {"core", "# key exchanges initiated", 0},
117 {"core", "# send requests dropped (disconnected)", 0},
118 {"core", "# transmissions delayed due to corking", 0},
119 {"core", "# messages discarded (expired prior to transmission)", 0},
120 {"core", "# messages discarded (disconnected)", 0},
121 {"core", "# discarded CORE_SEND requests", 0},
122 {"core", "# discarded lower priority CORE_SEND requests", 0},
123 {"transport", "# bytes received via TCP", 0},
124 {"transport", "# bytes transmitted via TCP", 0},
125 {"dht", "# PUT messages queued for transmission", 0},
126 {"dht", "# P2P PUT requests received", 0},
127 {"dht", "# GET messages queued for transmission", 0},
128 {"dht", "# P2P GET requests received", 0},
129 {"dht", "# RESULT messages queued for transmission", 0},
130 {"dht", "# P2P RESULTS received", 0},
131 {"dht", "# Queued messages discarded (peer disconnected)", 0},
132 {"dht", "# Peers excluded from routing due to Bloomfilter", 0},
133 {"dht", "# Peer selection failed", 0},
134 {"dht", "# FIND PEER requests ignored due to Bloomfilter", 0},
135 {"dht", "# FIND PEER requests ignored due to lack of HELLO", 0},
136 {"dht", "# P2P FIND PEER requests processed", 0},
137 {"dht", "# P2P GET requests ONLY routed", 0},
138 {"dht", "# Preference updates given to core", 0},
139 {"dht", "# REPLIES ignored for CLIENTS (no match)", 0},
140 {"dht", "# GET requests from clients injected", 0},
141 {"dht", "# GET requests received from clients", 0},
142 {"dht", "# GET STOP requests received from clients", 0},
143 {"dht", "# ITEMS stored in datacache", 0},
144 {"dht", "# Good RESULTS found in datacache", 0},
145 {"dht", "# GET requests given to datacache", 0},
146 {NULL, NULL, 0}
147};
148
149
150/**
151 * Function called once we're done processing stats.
152 *
153 * @param cls the test context
154 * @param op the stats operation
155 * @param emsg error message on failure
156 */
157static void
158stats_finished (void *cls,
159 struct GNUNET_TESTBED_Operation *op,
160 const char *emsg)
161{
162 struct GNUNET_DHT_TEST_Context *ctx = cls;
163 unsigned int i;
164
165 if (NULL != op)
166 GNUNET_TESTBED_operation_done (op); // needed?
167 if (NULL != emsg)
168 {
169 fprintf (stderr, _("Gathering statistics failed: %s\n"),
170 emsg);
171 GNUNET_SCHEDULER_cancel (put_task);
172 GNUNET_DHT_TEST_cleanup (ctx);
173 return;
174 }
175 for (i = 0; NULL != stats[i].name; i++)
176 FPRINTF (stderr,
177 "%6s/%60s = %12llu\n",
178 stats[i].subsystem,
179 stats[i].name,
180 stats[i].total);
181 GNUNET_SCHEDULER_cancel (put_task);
182 GNUNET_DHT_TEST_cleanup (ctx);
183}
184
185
186/**
187 * Function called to process statistic values from all peers.
188 *
189 * @param cls closure
190 * @param peer the peer the statistic belong to
191 * @param subsystem name of subsystem that created the statistic
192 * @param name the name of the datum
193 * @param value the current value
194 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
195 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
196 */
197static int
198handle_stats (void *cls,
199 const struct GNUNET_TESTBED_Peer *peer,
200 const char *subsystem,
201 const char *name,
202 uint64_t value,
203 int is_persistent)
204{
205 unsigned int i;
206
207 for (i = 0; NULL != stats[i].name; i++)
208 if ( (0 == strcasecmp (subsystem,
209 stats[i].subsystem)) &&
210 (0 == strcasecmp (name,
211 stats[i].name)) )
212 stats[i].total += value;
213 return GNUNET_OK;
214}
215
96 216
97/** 217/**
98 * Task run on success or timeout to clean up. 218 * Task run on success or timeout to clean up.
@@ -117,8 +237,11 @@ shutdown_task (void *cls,
117 get_op); 237 get_op);
118 GNUNET_free (get_op); 238 GNUNET_free (get_op);
119 } 239 }
120 GNUNET_SCHEDULER_cancel (put_task); 240 (void) GNUNET_TESTBED_get_statistics (NUM_PEERS,
121 GNUNET_DHT_TEST_cleanup (ctx); 241 my_peers,
242 &handle_stats,
243 &stats_finished,
244 ctx);
122} 245}
123 246
124 247
@@ -249,16 +372,9 @@ run (void *cls,
249 struct GetOperation *get_op; 372 struct GetOperation *get_op;
250 373
251 GNUNET_assert (NUM_PEERS == num_peers); 374 GNUNET_assert (NUM_PEERS == num_peers);
375 my_peers = peers;
252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
253 "Peers setup, starting test\n"); 377 "Peers setup, starting test\n");
254 /* FIXME: once testbed is finished, this call should
255 no longer be needed */
256 GNUNET_TESTBED_overlay_configure_topology (NULL,
257 num_peers,
258 peers,
259 GNUNET_TESTBED_TOPOLOGY_LINE,
260 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
261
262 put_task = GNUNET_SCHEDULER_add_now (&do_puts, dhts); 378 put_task = GNUNET_SCHEDULER_add_now (&do_puts, dhts);
263 for (i=0;i<num_peers;i++) 379 for (i=0;i<num_peers;i++)
264 { 380 {
@@ -297,11 +413,25 @@ main (int xargc, char *xargv[])
297 { 413 {
298 cfg_filename = "test_dht_2dtorus.conf"; 414 cfg_filename = "test_dht_2dtorus.conf";
299 test_name = "test-dht-2dtorus"; 415 test_name = "test-dht-2dtorus";
416 NUM_PEERS = 16;
300 } 417 }
301 else if (NULL != strstr (xargv[0], "test_dht_line")) 418 else if (NULL != strstr (xargv[0], "test_dht_line"))
302 { 419 {
303 cfg_filename = "test_dht_line.conf"; 420 cfg_filename = "test_dht_line.conf";
304 test_name = "test-dht-line"; 421 test_name = "test-dht-line";
422 NUM_PEERS = 5;
423 }
424 else if (NULL != strstr (xargv[0], "test_dht_twopeer"))
425 {
426 cfg_filename = "test_dht_line.conf";
427 test_name = "test-dht-twopeer";
428 NUM_PEERS = 2;
429 }
430 else if (NULL != strstr (xargv[0], "test_dht_multipeer"))
431 {
432 cfg_filename = "test_dht_multipeer.conf";
433 test_name = "test-dht-multipeer";
434 NUM_PEERS = 10;
305 } 435 }
306 else 436 else
307 { 437 {