diff options
Diffstat (limited to 'src/dht/gnunet_dht_profiler.c')
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 141 |
1 files changed, 140 insertions, 1 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index 62e8acf02..0bfe609d8 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -205,6 +205,15 @@ static unsigned int n_gets_fail; | |||
205 | */ | 205 | */ |
206 | static unsigned int replication; | 206 | static unsigned int replication; |
207 | 207 | ||
208 | /** | ||
209 | * Testbed Operation (to get stats). | ||
210 | */ | ||
211 | static struct GNUNET_TESTBED_Operation *stats_op; | ||
212 | |||
213 | /** | ||
214 | * Testbed peer handles. | ||
215 | */ | ||
216 | static struct GNUNET_TESTBED_Peer **testbed_handles; | ||
208 | 217 | ||
209 | /** | 218 | /** |
210 | * Shutdown task. Cleanup all resources and operations. | 219 | * Shutdown task. Cleanup all resources and operations. |
@@ -245,6 +254,64 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
245 | } | 254 | } |
246 | 255 | ||
247 | 256 | ||
257 | /** | ||
258 | * Stats callback. Finish the stats testbed operation and when all stats have | ||
259 | * been iterated, shutdown the test. | ||
260 | * | ||
261 | * @param cls closure | ||
262 | * @param op the operation that has been finished | ||
263 | * @param emsg error message in case the operation has failed; will be NULL if | ||
264 | * operation has executed successfully. | ||
265 | */ | ||
266 | static void | ||
267 | bandwidth_stats_cont (void *cls, | ||
268 | struct GNUNET_TESTBED_Operation *op, const char *emsg) | ||
269 | { | ||
270 | |||
271 | } | ||
272 | |||
273 | |||
274 | /** | ||
275 | * Process statistic values. | ||
276 | * | ||
277 | * @param cls closure | ||
278 | * @param peer the peer the statistic belong to | ||
279 | * @param subsystem name of subsystem that created the statistic | ||
280 | * @param name the name of the datum | ||
281 | * @param value the current value | ||
282 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | ||
283 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | ||
284 | */ | ||
285 | static int | ||
286 | bandwidth_stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer, | ||
287 | const char *subsystem, const char *name, | ||
288 | uint64_t value, int is_persistent) | ||
289 | { | ||
290 | return GNUNET_OK; | ||
291 | } | ||
292 | |||
293 | |||
294 | /** | ||
295 | * Task that collects bandwidth used by all the peers. | ||
296 | * | ||
297 | * @param cls Closure (NULL). | ||
298 | * @param tc Task Context. | ||
299 | */ | ||
300 | static void | ||
301 | collect_bandwidth_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
302 | { | ||
303 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
304 | return; | ||
305 | |||
306 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting bandwidth statistics...\n"); | ||
307 | //FIXME: what is the name of transport subsystem? | ||
308 | stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles, | ||
309 | NULL, NULL, | ||
310 | bandwidth_stats_iterator, | ||
311 | bandwidth_stats_cont, NULL); | ||
312 | } | ||
313 | |||
314 | |||
248 | static void | 315 | static void |
249 | summarize () | 316 | summarize () |
250 | { | 317 | { |
@@ -254,7 +321,9 @@ summarize () | |||
254 | INFO ("# GETS made: %u\n", n_gets); | 321 | INFO ("# GETS made: %u\n", n_gets); |
255 | INFO ("# GETS succeeded: %u\n", n_gets_ok); | 322 | INFO ("# GETS succeeded: %u\n", n_gets_ok); |
256 | INFO ("# GETS failed: %u\n", n_gets_fail); | 323 | INFO ("# GETS failed: %u\n", n_gets_fail); |
257 | GNUNET_SCHEDULER_shutdown (); | 324 | //FIXME: is this the right place to call b/w stats? |
325 | GNUNET_SCHEDULER_add_now (&collect_bandwidth_stats, NULL); | ||
326 | GNUNET_SCHEDULER_shutdown (); | ||
258 | } | 327 | } |
259 | 328 | ||
260 | 329 | ||
@@ -398,6 +467,70 @@ put_cont (void *cls, int success) | |||
398 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac); | 467 | ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac); |
399 | } | 468 | } |
400 | 469 | ||
470 | /** | ||
471 | * Stats callback. Finish the stats testbed operation and when all stats have | ||
472 | * been iterated, shutdown the test. | ||
473 | * | ||
474 | * @param cls closure | ||
475 | * @param op the operation that has been finished | ||
476 | * @param emsg error message in case the operation has failed; will be NULL if | ||
477 | * operation has executed successfully. | ||
478 | */ | ||
479 | static void | ||
480 | finger_stats_cont (void *cls, | ||
481 | struct GNUNET_TESTBED_Operation *op, | ||
482 | const char *emsg) | ||
483 | { | ||
484 | |||
485 | } | ||
486 | |||
487 | |||
488 | /** | ||
489 | * Process statistic values. | ||
490 | * | ||
491 | * @param cls closure | ||
492 | * @param peer the peer the statistic belong to | ||
493 | * @param subsystem name of subsystem that created the statistic | ||
494 | * @param name the name of the datum | ||
495 | * @param value the current value | ||
496 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | ||
497 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | ||
498 | */ | ||
499 | static int | ||
500 | finger_stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer, | ||
501 | const char *subsystem, const char *name, | ||
502 | uint64_t value, int is_persistent) | ||
503 | { | ||
504 | uint32_t i; | ||
505 | |||
506 | i = GNUNET_TESTBED_get_index (peer); | ||
507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " STATS %u - %s [%s]: %llu\n", | ||
508 | i, subsystem, name, value); | ||
509 | |||
510 | return GNUNET_OK; | ||
511 | } | ||
512 | |||
513 | |||
514 | /** | ||
515 | * Task check that keepalives were sent and received. | ||
516 | * | ||
517 | * @param cls Closure (NULL). | ||
518 | * @param tc Task Context. | ||
519 | */ | ||
520 | static void | ||
521 | collect_finger_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
522 | { | ||
523 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
524 | return; | ||
525 | |||
526 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n"); | ||
527 | /* FIXME: Write subsystem name. */ | ||
528 | stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles, | ||
529 | "dht", NULL, | ||
530 | finger_stats_iterator, | ||
531 | finger_stats_cont, NULL); | ||
532 | } | ||
533 | |||
401 | 534 | ||
402 | /** | 535 | /** |
403 | * Task to do DHT PUTS | 536 | * Task to do DHT PUTS |
@@ -410,6 +543,12 @@ delayed_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
410 | { | 543 | { |
411 | struct ActiveContext *ac = cls; | 544 | struct ActiveContext *ac = cls; |
412 | 545 | ||
546 | /*FIXME: Before doing anything else, first collect statistics from each peer | ||
547 | DHT and check if circle is formed. If yes then go ahead with more puts, | ||
548 | else wait for 'delay' time. This function does not return anything, so we | ||
549 | should have some way to notify that circle is done or we need to wait.*/ | ||
550 | GNUNET_SCHEDULER_add_now(collect_finger_stats,NULL); | ||
551 | |||
413 | ac->delay_task = GNUNET_SCHEDULER_NO_TASK; | 552 | ac->delay_task = GNUNET_SCHEDULER_NO_TASK; |
414 | /* Generate and DHT PUT some random data */ | 553 | /* Generate and DHT PUT some random data */ |
415 | ac->put_data_size = 16; /* minimum */ | 554 | ac->put_data_size = 16; /* minimum */ |