aboutsummaryrefslogtreecommitdiff
path: root/src/fs/perf_gnunet_service_fs_p2p_trust.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/perf_gnunet_service_fs_p2p_trust.c')
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p_trust.c347
1 files changed, 154 insertions, 193 deletions
diff --git a/src/fs/perf_gnunet_service_fs_p2p_trust.c b/src/fs/perf_gnunet_service_fs_p2p_trust.c
index 0128e281d..a78ff0571 100644
--- a/src/fs/perf_gnunet_service_fs_p2p_trust.c
+++ b/src/fs/perf_gnunet_service_fs_p2p_trust.c
@@ -87,11 +87,9 @@ static struct GNUNET_FS_Uri *uri1;
87static struct GNUNET_FS_Uri *uri2; 87static struct GNUNET_FS_Uri *uri2;
88 88
89static void 89static void
90do_stop (void *cls, 90do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
91 const struct GNUNET_SCHEDULER_TaskContext *tc)
92{ 91{
93 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, 92 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons);
94 daemons);
95} 93}
96 94
97 95
@@ -100,7 +98,7 @@ do_stop (void *cls,
100 */ 98 */
101struct StatMaster 99struct StatMaster
102{ 100{
103 struct GNUNET_STATISTICS_Handle *stat; 101 struct GNUNET_STATISTICS_Handle *stat;
104 unsigned int daemon; 102 unsigned int daemon;
105 unsigned int value; 103 unsigned int value;
106}; 104};
@@ -114,30 +112,29 @@ struct StatValues
114/** 112/**
115 * Statistics we print out. 113 * Statistics we print out.
116 */ 114 */
117static struct StatValues stats[] = 115static struct StatValues stats[] = {
118 { 116 {"fs", "# artificial delays introduced (ms)"},
119 { "fs", "# artificial delays introduced (ms)"}, 117 {"fs", "# queries forwarded"},
120 { "fs", "# queries forwarded"}, 118 {"fs", "# replies received and matched"},
121 { "fs", "# replies received and matched"}, 119 {"fs", "# results found locally"},
122 { "fs", "# results found locally"}, 120 {"fs", "# requests forwarded due to high load"},
123 { "fs", "# requests forwarded due to high load"}, 121 {"fs", "# requests done for free (low load)"},
124 { "fs", "# requests done for free (low load)"}, 122 {"fs", "# requests dropped, priority insufficient"},
125 { "fs", "# requests dropped, priority insufficient"}, 123 {"fs", "# requests done for a price (normal load)"},
126 { "fs", "# requests done for a price (normal load)"}, 124 {"fs", "# requests dropped by datastore (queue length limit)"},
127 { "fs", "# requests dropped by datastore (queue length limit)"}, 125 {"fs", "# P2P searches received"},
128 { "fs", "# P2P searches received"}, 126 {"fs", "# P2P searches discarded (queue length bound)"},
129 { "fs", "# P2P searches discarded (queue length bound)"}, 127 {"fs", "# replies received for local clients"},
130 { "fs", "# replies received for local clients"}, 128 {"fs", "# queries retransmitted to same target"},
131 { "fs", "# queries retransmitted to same target"}, 129 {"core", "# bytes decrypted"},
132 { "core", "# bytes decrypted"}, 130 {"core", "# bytes encrypted"},
133 { "core", "# bytes encrypted"}, 131 {"core", "# discarded CORE_SEND requests"},
134 { "core", "# discarded CORE_SEND requests"}, 132 {"core", "# discarded lower priority CORE_SEND requests"},
135 { "core", "# discarded lower priority CORE_SEND requests"}, 133 {"transport", "# bytes received via TCP"},
136 { "transport", "# bytes received via TCP"}, 134 {"transport", "# bytes transmitted via TCP"},
137 { "transport", "# bytes transmitted via TCP"}, 135 {"datacache", "# bytes stored"},
138 { "datacache", "# bytes stored"}, 136 {NULL, NULL}
139 { NULL, NULL} 137};
140 };
141 138
142 139
143/** 140/**
@@ -152,18 +149,14 @@ static struct StatValues stats[] =
152 */ 149 */
153static int 150static int
154print_stat (void *cls, 151print_stat (void *cls,
155 const char *subsystem, 152 const char *subsystem,
156 const char *name, 153 const char *name, uint64_t value, int is_persistent)
157 uint64_t value,
158 int is_persistent)
159{ 154{
160 struct StatMaster *sm = cls; 155 struct StatMaster *sm = cls;
156
161 fprintf (stderr, 157 fprintf (stderr,
162 "Peer %2u: %12s/%50s = %12llu\n", 158 "Peer %2u: %12s/%50s = %12llu\n",
163 sm->daemon, 159 sm->daemon, subsystem, name, (unsigned long long) value);
164 subsystem,
165 name,
166 (unsigned long long) value);
167 return GNUNET_OK; 160 return GNUNET_OK;
168} 161}
169 162
@@ -171,20 +164,18 @@ print_stat (void *cls,
171/** 164/**
172 * Function that gathers stats from all daemons. 165 * Function that gathers stats from all daemons.
173 */ 166 */
174static void 167static void stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
175stat_run (void *cls,
176 const struct GNUNET_SCHEDULER_TaskContext *tc);
177 168
178 169
179/** 170/**
180 * Function called when GET operation on stats is done. 171 * Function called when GET operation on stats is done.
181 */ 172 */
182static void 173static void
183get_done (void *cls, 174get_done (void *cls, int success)
184 int success)
185{ 175{
186 struct StatMaster *sm = cls; 176 struct StatMaster *sm = cls;
187 GNUNET_break (GNUNET_OK == success); 177
178 GNUNET_break (GNUNET_OK == success);
188 sm->value++; 179 sm->value++;
189 GNUNET_SCHEDULER_add_now (&stat_run, sm); 180 GNUNET_SCHEDULER_add_now (&stat_run, sm);
190} 181}
@@ -194,154 +185,140 @@ get_done (void *cls,
194 * Function that gathers stats from all daemons. 185 * Function that gathers stats from all daemons.
195 */ 186 */
196static void 187static void
197stat_run (void *cls, 188stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
198 const struct GNUNET_SCHEDULER_TaskContext *tc)
199{ 189{
200 struct StatMaster *sm = cls; 190 struct StatMaster *sm = cls;
201 191
202 if (stats[sm->value].name != NULL) 192 if (stats[sm->value].name != NULL)
203 { 193 {
204 GNUNET_STATISTICS_get (sm->stat, 194 GNUNET_STATISTICS_get (sm->stat,
205#if 0 195#if 0
206 NULL, NULL, 196 NULL, NULL,
207#else 197#else
208 stats[sm->value].subsystem, 198 stats[sm->value].subsystem, stats[sm->value].name,
209 stats[sm->value].name,
210#endif 199#endif
211 GNUNET_TIME_UNIT_FOREVER_REL, 200 GNUNET_TIME_UNIT_FOREVER_REL,
212 &get_done, 201 &get_done, &print_stat, sm);
213 &print_stat, sm); 202 return;
214 return; 203 }
215 }
216 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); 204 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO);
217 sm->value = 0; 205 sm->value = 0;
218 sm->daemon++; 206 sm->daemon++;
219 if (sm->daemon == NUM_DAEMONS) 207 if (sm->daemon == NUM_DAEMONS)
220 { 208 {
221 GNUNET_free (sm); 209 GNUNET_free (sm);
222 GNUNET_SCHEDULER_add_now (&do_stop, NULL); 210 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
223 return; 211 return;
224 } 212 }
225 sm->stat = GNUNET_STATISTICS_create ("<driver>", 213 sm->stat = GNUNET_STATISTICS_create ("<driver>",
226 GNUNET_FS_TEST_get_configuration (daemons, 214 GNUNET_FS_TEST_get_configuration
227 sm->daemon)); 215 (daemons, sm->daemon));
228 GNUNET_SCHEDULER_add_now (&stat_run, sm); 216 GNUNET_SCHEDULER_add_now (&stat_run, sm);
229} 217}
230 218
231 219
232static void 220static void
233do_report (void *cls, 221do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
234 const struct GNUNET_SCHEDULER_TaskContext *tc)
235{ 222{
236 static int download_counter; 223 static int download_counter;
237 const char *type = cls; 224 const char *type = cls;
238 struct GNUNET_TIME_Relative del; 225 struct GNUNET_TIME_Relative del;
239 char *fancy; 226 char *fancy;
240 struct StatMaster *sm; 227 struct StatMaster *sm;
241 228
242 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 229 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
243 { 230 {
244 del = GNUNET_TIME_absolute_get_duration (start_time); 231 del = GNUNET_TIME_absolute_get_duration (start_time);
245 if (del.rel_value == 0) 232 if (del.rel_value == 0)
246 del.rel_value = 1; 233 del.rel_value = 1;
247 fancy = GNUNET_STRINGS_byte_size_fancy (((unsigned long long)FILESIZE) * 1000LL / del.rel_value); 234 fancy =
248 fprintf (stderr, 235 GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
249 "Download speed of type `%s' was %s/s\n", 236 1000LL / del.rel_value);
250 type, 237 fprintf (stderr, "Download speed of type `%s' was %s/s\n", type, fancy);
251 fancy); 238 GNUNET_free (fancy);
252 GNUNET_free (fancy); 239 if (NUM_DAEMONS != ++download_counter)
253 if (NUM_DAEMONS != ++download_counter) 240 return; /* more downloads to come */
254 return; /* more downloads to come */ 241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
255 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 242 "Finished all downloads, shutting down\n",
256 "Finished all downloads, shutting down\n", 243 (unsigned long long) FILESIZE);
257 (unsigned long long) FILESIZE); 244 sm = GNUNET_malloc (sizeof (struct StatMaster));
258 sm = GNUNET_malloc (sizeof (struct StatMaster)); 245 sm->stat = GNUNET_STATISTICS_create ("<driver>",
259 sm->stat = GNUNET_STATISTICS_create ("<driver>", 246 GNUNET_FS_TEST_get_configuration
260 GNUNET_FS_TEST_get_configuration (daemons, 247 (daemons, sm->daemon));
261 sm->daemon)); 248 GNUNET_SCHEDULER_add_now (&stat_run, sm);
262 GNUNET_SCHEDULER_add_now (&stat_run, sm); 249 }
263 }
264 else 250 else
265 { 251 {
266 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 252 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
267 "Timeout during download for type `%s', shutting down with error\n", 253 "Timeout during download for type `%s', shutting down with error\n",
268 type); 254 type);
269 ok = 1; 255 ok = 1;
270 GNUNET_SCHEDULER_add_now (&do_stop, NULL); 256 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
271 } 257 }
272} 258}
273 259
274 260
275static void 261static void
276do_downloads (void *cls, 262do_downloads (void *cls, const struct GNUNET_FS_Uri *u2)
277 const struct GNUNET_FS_Uri *u2)
278{ 263{
279 int anonymity; 264 int anonymity;
280 unsigned int i; 265 unsigned int i;
281 266
282 if (NULL == u2) 267 if (NULL == u2)
283 { 268 {
284 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, 269 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons);
285 daemons); 270 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
286 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 271 "Timeout during upload attempt, shutting down with error\n");
287 "Timeout during upload attempt, shutting down with error\n"); 272 ok = 1;
288 ok = 1; 273 return;
289 return; 274 }
290 }
291 uri2 = GNUNET_FS_uri_dup (u2); 275 uri2 = GNUNET_FS_uri_dup (u2);
292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
293 "Downloading %llu bytes\n", 277 "Downloading %llu bytes\n", (unsigned long long) FILESIZE);
294 (unsigned long long) FILESIZE);
295 start_time = GNUNET_TIME_absolute_get (); 278 start_time = GNUNET_TIME_absolute_get ();
296 if (NULL != strstr (progname, "dht")) 279 if (NULL != strstr (progname, "dht"))
297 anonymity = 0; 280 anonymity = 0;
298 else 281 else
299 anonymity = 1; 282 anonymity = 1;
300 /* (semi) leach-download(s); not true leaches since 283 /* (semi) leach-download(s); not true leaches since
301 these peers do participate in sharing, they just 284 * these peers do participate in sharing, they just
302 don't have to offer anything *initially*. */ 285 * don't have to offer anything *initially*. */
303 for (i=0;i<NUM_DAEMONS-2;i++) 286 for (i = 0; i < NUM_DAEMONS - 2; i++)
304 GNUNET_FS_TEST_download (daemons[i], 287 GNUNET_FS_TEST_download (daemons[i],
305 TIMEOUT, 288 TIMEOUT,
306 anonymity, 289 anonymity,
307 0 == (i%2) ? SEED1 : SEED2, 290 0 == (i % 2) ? SEED1 : SEED2,
308 0 == (i%2) ? uri1 : uri2, 291 0 == (i % 2) ? uri1 : uri2,
309 VERBOSE, 292 VERBOSE, &do_report, "leach");
310 &do_report, "leach");
311 /* mutual downloads of (primary) sharing peers */ 293 /* mutual downloads of (primary) sharing peers */
312 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS-2], 294 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2],
313 TIMEOUT, 295 TIMEOUT,
314 anonymity, SEED1, uri1, 296 anonymity, SEED1, uri1,
315 VERBOSE, 297 VERBOSE, &do_report, "seeder 2");
316 &do_report, "seeder 2"); 298 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1],
317 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS-1], 299 TIMEOUT,
318 TIMEOUT, 300 anonymity, SEED2, uri2,
319 anonymity, SEED2, uri2, 301 VERBOSE, &do_report, "seeder 1");
320 VERBOSE,
321 &do_report, "seeder 1");
322} 302}
323 303
324 304
325static void 305static void
326do_publish2 (void *cls, 306do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1)
327 const struct GNUNET_FS_Uri *u1)
328{ 307{
329 int do_index; 308 int do_index;
330 int anonymity; 309 int anonymity;
331 310
332 if (NULL == u1) 311 if (NULL == u1)
333 { 312 {
334 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, 313 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons);
335 daemons); 314 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
336 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 315 "Timeout during upload attempt, shutting down with error\n");
337 "Timeout during upload attempt, shutting down with error\n"); 316 ok = 1;
338 ok = 1; 317 return;
339 return; 318 }
340 }
341 uri1 = GNUNET_FS_uri_dup (u1); 319 uri1 = GNUNET_FS_uri_dup (u1);
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
343 "Publishing %llu bytes\n", 321 "Publishing %llu bytes\n", (unsigned long long) FILESIZE);
344 (unsigned long long) FILESIZE);
345 if (NULL != strstr (progname, "index")) 322 if (NULL != strstr (progname, "index"))
346 do_index = GNUNET_YES; 323 do_index = GNUNET_YES;
347 else 324 else
@@ -350,35 +327,29 @@ do_publish2 (void *cls,
350 anonymity = 0; 327 anonymity = 0;
351 else 328 else
352 anonymity = 1; 329 anonymity = 1;
353 330
354 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS-2], 331 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2],
355 TIMEOUT, 332 TIMEOUT,
356 anonymity, 333 anonymity,
357 do_index, FILESIZE, SEED2, 334 do_index, FILESIZE, SEED2,
358 VERBOSE, 335 VERBOSE, &do_downloads, NULL);
359 &do_downloads, NULL);
360} 336}
361 337
362static void 338static void
363do_publish1 (void *cls, 339do_publish1 (void *cls, const char *emsg)
364 const char *emsg)
365{ 340{
366 int do_index; 341 int do_index;
367 int anonymity; 342 int anonymity;
368 343
369 if (NULL != emsg) 344 if (NULL != emsg)
370 { 345 {
371 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, 346 GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons);
372 daemons); 347 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error trying to connect: %s\n", emsg);
373 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 348 ok = 1;
374 "Error trying to connect: %s\n", 349 return;
375 emsg); 350 }
376 ok = 1;
377 return;
378 }
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
380 "Publishing %llu bytes\n", 352 "Publishing %llu bytes\n", (unsigned long long) FILESIZE);
381 (unsigned long long) FILESIZE);
382 if (NULL != strstr (progname, "index")) 353 if (NULL != strstr (progname, "index"))
383 do_index = GNUNET_YES; 354 do_index = GNUNET_YES;
384 else 355 else
@@ -387,60 +358,50 @@ do_publish1 (void *cls,
387 anonymity = 0; 358 anonymity = 0;
388 else 359 else
389 anonymity = 1; 360 anonymity = 1;
390 361
391 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS-1], 362 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1],
392 TIMEOUT, 363 TIMEOUT,
393 anonymity, 364 anonymity,
394 do_index, FILESIZE, SEED1, 365 do_index, FILESIZE, SEED1,
395 VERBOSE, 366 VERBOSE, &do_publish2, NULL);
396 &do_publish2, NULL);
397} 367}
398 368
399 369
400static void 370static void
401do_connect (void *cls, 371do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
402 const struct GNUNET_SCHEDULER_TaskContext *tc)
403{ 372{
404 struct GNUNET_TESTING_PeerGroup *pg; 373 struct GNUNET_TESTING_PeerGroup *pg;
405 374
406 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); 375 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
408 "Daemons started, will now try to connect them\n"); 377 "Daemons started, will now try to connect them\n");
409 pg = GNUNET_FS_TEST_get_group (daemons); 378 pg = GNUNET_FS_TEST_get_group (daemons);
410 GNUNET_TESTING_create_topology (pg, 379 GNUNET_TESTING_create_topology (pg,
411 GNUNET_TESTING_TOPOLOGY_CLIQUE, 380 GNUNET_TESTING_TOPOLOGY_CLIQUE,
412 GNUNET_TESTING_TOPOLOGY_NONE, 381 GNUNET_TESTING_TOPOLOGY_NONE, NULL);
413 NULL);
414 GNUNET_TESTING_connect_topology (pg, 382 GNUNET_TESTING_connect_topology (pg,
415 GNUNET_TESTING_TOPOLOGY_CLIQUE, 383 GNUNET_TESTING_TOPOLOGY_CLIQUE,
416 GNUNET_TESTING_TOPOLOGY_OPTION_NONE, 384 GNUNET_TESTING_TOPOLOGY_OPTION_NONE,
417 0.0, 385 0.0,
418 TIMEOUT, 386 TIMEOUT, NUM_DAEMONS, &do_publish1, NULL);
419 NUM_DAEMONS,
420 &do_publish1,
421 NULL);
422} 387}
423 388
424 389
425static void 390static void
426run (void *cls, 391run (void *cls,
427 char *const *args, 392 char *const *args,
428 const char *cfgfile, 393 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
429 const struct GNUNET_CONFIGURATION_Handle *cfg)
430{ 394{
431 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", 395 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf",
432 TIMEOUT, 396 TIMEOUT,
433 NUM_DAEMONS, 397 NUM_DAEMONS, daemons, &do_connect, NULL);
434 daemons,
435 &do_connect,
436 NULL);
437} 398}
438 399
439 400
440int 401int
441main (int argc, char *argv[]) 402main (int argc, char *argv[])
442{ 403{
443 char *const argvx[] = { 404 char *const argvx[] = {
444 "perf-gnunet-service-fs-p2p", 405 "perf-gnunet-service-fs-p2p",
445 "-c", 406 "-c",
446 "fs_test_lib_data.conf", 407 "fs_test_lib_data.conf",
@@ -454,16 +415,16 @@ main (int argc, char *argv[])
454 }; 415 };
455 progname = argv[0]; 416 progname = argv[0];
456 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 417 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
457 GNUNET_log_setup ("perf_gnunet_service_fs_p2p_trust", 418 GNUNET_log_setup ("perf_gnunet_service_fs_p2p_trust",
458#if VERBOSE 419#if VERBOSE
459 "DEBUG", 420 "DEBUG",
460#else 421#else
461 "WARNING", 422 "WARNING",
462#endif 423#endif
463 NULL); 424 NULL);
464 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 425 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
465 argvx, "perf-gnunet-service-fs-p2p-trust", 426 argvx, "perf-gnunet-service-fs-p2p-trust",
466 "nohelp", options, &run, NULL); 427 "nohelp", options, &run, NULL);
467 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 428 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
468 return ok; 429 return ok;
469} 430}