diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-03-19 09:58:55 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-03-19 09:58:55 +0000 |
commit | 5df7f24fe0f8371c931b78a135c864af8e167c6a (patch) | |
tree | 8eaf46f077969aeaacc1767ba6b3e5ea6f88b920 /src/nse/gnunet-nse-profiler.c | |
parent | 453364efe4a8f3d1bfd57bca478d8b0ebc1d1fc8 (diff) | |
download | gnunet-5df7f24fe0f8371c931b78a135c864af8e167c6a.tar.gz gnunet-5df7f24fe0f8371c931b78a135c864af8e167c6a.zip |
- working version of NSE profiler
Diffstat (limited to 'src/nse/gnunet-nse-profiler.c')
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 5777916a0..391a7656f 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -382,13 +382,16 @@ connect_nse_service () | |||
382 | { | 382 | { |
383 | struct NSEPeer *current_peer; | 383 | struct NSEPeer *current_peer; |
384 | unsigned int i; | 384 | unsigned int i; |
385 | unsigned int connections; | ||
385 | 386 | ||
387 | if (0 == connection_limit) | ||
388 | return; | ||
386 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to nse service of peers\n"); | 389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to nse service of peers\n"); |
387 | for (i = 0; i < num_peers; i++) | 390 | connections = 0; |
391 | for (i = 0; i < num_peers_in_round[current_round]; i++) | ||
388 | { | 392 | { |
389 | if ((connection_limit > 0) && | 393 | if ((num_peers_in_round[current_round] > connection_limit) && |
390 | (num_peers > connection_limit) && | 394 | (0 != (i % (num_peers_in_round[current_round] / connection_limit)))) |
391 | (0 != (i % (num_peers / connection_limit)))) | ||
392 | continue; | 395 | continue; |
393 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
394 | "nse-profiler: connecting to nse service of peer %d\n", i); | 397 | "nse-profiler: connecting to nse service of peer %d\n", i); |
@@ -401,8 +404,10 @@ connect_nse_service () | |||
401 | NULL, NULL, | 404 | NULL, NULL, |
402 | &nse_connect_adapter, | 405 | &nse_connect_adapter, |
403 | &nse_disconnect_adapter, | 406 | &nse_disconnect_adapter, |
404 | current_peer); | 407 | current_peer); |
405 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); | 408 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); |
409 | if (++connections == connection_limit) | ||
410 | break; | ||
406 | } | 411 | } |
407 | } | 412 | } |
408 | 413 | ||
@@ -448,6 +453,7 @@ stats_finished_callback (void *cls, | |||
448 | GNUNET_free (stats_context); | 453 | GNUNET_free (stats_context); |
449 | return; | 454 | return; |
450 | } | 455 | } |
456 | LOG_DEBUG ("Finished collecting statistics\n"); | ||
451 | if (NULL != data_file) | 457 | if (NULL != data_file) |
452 | { | 458 | { |
453 | /* Stats lookup successful, write out data */ | 459 | /* Stats lookup successful, write out data */ |
@@ -589,9 +595,7 @@ finish_round (void *cls, | |||
589 | char buf[1024]; | 595 | char buf[1024]; |
590 | size_t buf_len; | 596 | size_t buf_len; |
591 | 597 | ||
592 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 598 | LOG (GNUNET_ERROR_TYPE_INFO, "Have %u connections\n", total_connections); |
593 | "Have %u connections\n", | ||
594 | total_connections); | ||
595 | if (NULL != data_file) | 599 | if (NULL != data_file) |
596 | { | 600 | { |
597 | buf_len = GNUNET_snprintf (buf, sizeof (buf), | 601 | buf_len = GNUNET_snprintf (buf, sizeof (buf), |
@@ -655,6 +659,8 @@ peer_churn_cb (void *cls, const char *emsg) | |||
655 | GNUNET_TESTBED_operation_done (entry->op); | 659 | GNUNET_TESTBED_operation_done (entry->op); |
656 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | 660 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
657 | GNUNET_free (entry); | 661 | GNUNET_free (entry); |
662 | if (num_peers_in_round[current_round] == peers_running) | ||
663 | run_round (); | ||
658 | } | 664 | } |
659 | 665 | ||
660 | 666 | ||
@@ -707,6 +713,7 @@ next_round (void *cls, | |||
707 | if (current_round == num_rounds) | 713 | if (current_round == num_rounds) |
708 | { | 714 | { |
709 | /* this was the last round, terminate */ | 715 | /* this was the last round, terminate */ |
716 | ok = 0; | ||
710 | GNUNET_SCHEDULER_shutdown (); | 717 | GNUNET_SCHEDULER_shutdown (); |
711 | return; | 718 | return; |
712 | } | 719 | } |
@@ -735,13 +742,9 @@ master_controller_cb (void *cls, | |||
735 | { | 742 | { |
736 | case GNUNET_TESTBED_ET_PEER_START: | 743 | case GNUNET_TESTBED_ET_PEER_START: |
737 | peers_running++; | 744 | peers_running++; |
738 | if (num_peers_in_round[current_round] == peers_running) | ||
739 | run_round (); | ||
740 | break; | 745 | break; |
741 | case GNUNET_TESTBED_ET_PEER_STOP: | 746 | case GNUNET_TESTBED_ET_PEER_STOP: |
742 | peers_running--; | 747 | peers_running--; |
743 | if (num_peers_in_round[current_round] == peers_running) | ||
744 | run_round (); | ||
745 | break; | 748 | break; |
746 | case GNUNET_TESTBED_ET_CONNECT: | 749 | case GNUNET_TESTBED_ET_CONNECT: |
747 | total_connections++; | 750 | total_connections++; |
@@ -817,7 +820,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
817 | fprintf (stderr, "Refusing to run a round with 0 peers\n"); | 820 | fprintf (stderr, "Refusing to run a round with 0 peers\n"); |
818 | return; | 821 | return; |
819 | } | 822 | } |
820 | GNUNET_array_grow (num_peers_in_round, num_rounds, num); | 823 | GNUNET_array_append (num_peers_in_round, num_rounds, num); |
821 | num_peers = GNUNET_MAX (num_peers, num); | 824 | num_peers = GNUNET_MAX (num_peers, num); |
822 | } | 825 | } |
823 | if (0 == num_peers) | 826 | if (0 == num_peers) |
@@ -875,7 +878,7 @@ main (int argc, char *const *argv) | |||
875 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 878 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
876 | {'C', "connections", "COUNT", | 879 | {'C', "connections", "COUNT", |
877 | gettext_noop ("limit to the number of connections to NSE services, 0 for none"), | 880 | gettext_noop ("limit to the number of connections to NSE services, 0 for none"), |
878 | 1, &GNUNET_GETOPT_set_string, &num_peer_spec}, | 881 | 1, &GNUNET_GETOPT_set_uint, &connection_limit}, |
879 | {'d', "details", "FILENAME", | 882 | {'d', "details", "FILENAME", |
880 | gettext_noop ("name of the file for writing connection information and statistics"), | 883 | gettext_noop ("name of the file for writing connection information and statistics"), |
881 | 1, &GNUNET_GETOPT_set_string, &data_filename}, | 884 | 1, &GNUNET_GETOPT_set_string, &data_filename}, |