aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dht/gnunet-dht-driver.c32
-rw-r--r--src/include/gnunet_testing_lib.h14
-rw-r--r--src/testing/testing_group.c30
3 files changed, 70 insertions, 6 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 14c119ff9..07cbf7981 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -716,6 +716,11 @@ static unsigned int total_connections;
716static unsigned int previous_connections; 716static unsigned int previous_connections;
717 717
718/** 718/**
719 * For counting failed connections during some duration.
720 */
721static unsigned int previous_failed_connections;
722
723/**
719 * Global used to count how many failed connections we have 724 * Global used to count how many failed connections we have
720 * been notified about (how many times has topology_callback 725 * been notified about (how many times has topology_callback
721 * been called with failure?) 726 * been called with failure?)
@@ -2597,8 +2602,11 @@ topology_callback (void *cls,
2597 unsigned long long duration; 2602 unsigned long long duration;
2598 unsigned long long total_duration; 2603 unsigned long long total_duration;
2599 unsigned int new_connections; 2604 unsigned int new_connections;
2605 unsigned int new_failed_connections;
2600 float conns_per_sec_recent; 2606 float conns_per_sec_recent;
2601 float conns_per_sec_total; 2607 float conns_per_sec_total;
2608 float failed_conns_per_sec_recent;
2609 float failed_conns_per_sec_total;
2602 2610
2603#if ONLY_TESTING 2611#if ONLY_TESTING
2604 if (repeat_connect_mode == GNUNET_YES) 2612 if (repeat_connect_mode == GNUNET_YES)
@@ -2615,26 +2623,40 @@ topology_callback (void *cls,
2615 repeat_connect_peer1 = NULL; 2623 repeat_connect_peer1 = NULL;
2616 repeat_connect_peer2 = NULL; 2624 repeat_connect_peer2 = NULL;
2617 repeat_connect_mode = GNUNET_NO; 2625 repeat_connect_mode = GNUNET_NO;
2626 GNUNET_TESTING_resume_connections(pg);
2627 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Resuming normal connection mode, debug connection was successful!\n");
2618 } 2628 }
2619 } 2629 }
2620 } 2630 }
2621#endif 2631#endif
2622 2632
2633
2634
2623 if (GNUNET_TIME_absolute_get_difference (connect_last_time, 2635 if (GNUNET_TIME_absolute_get_difference (connect_last_time,
2624 GNUNET_TIME_absolute_get()).rel_value > GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, CONN_UPDATE_DURATION).rel_value) 2636 GNUNET_TIME_absolute_get()).rel_value > GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, CONN_UPDATE_DURATION).rel_value)
2625 { 2637 {
2626 /* Get number of new connections */ 2638 /* Get number of new connections */
2627 new_connections = total_connections - previous_connections; 2639 new_connections = total_connections - previous_connections;
2640
2641 /* Get number of new FAILED connections */
2642 new_failed_connections = failed_connections - previous_failed_connections;
2643
2628 /* Get duration in seconds */ 2644 /* Get duration in seconds */
2629 duration = GNUNET_TIME_absolute_get_difference (connect_last_time, 2645 duration = GNUNET_TIME_absolute_get_difference (connect_last_time,
2630 GNUNET_TIME_absolute_get()).rel_value / 1000; 2646 GNUNET_TIME_absolute_get()).rel_value / 1000;
2631 total_duration = GNUNET_TIME_absolute_get_difference (connect_start_time, 2647 total_duration = GNUNET_TIME_absolute_get_difference (connect_start_time,
2632 GNUNET_TIME_absolute_get()).rel_value / 1000; 2648 GNUNET_TIME_absolute_get()).rel_value / 1000;
2649
2650 failed_conns_per_sec_recent = (float)new_failed_connections / duration;
2651 failed_conns_per_sec_total = (float)failed_connections / total_duration;
2633 conns_per_sec_recent = (float)new_connections / duration; 2652 conns_per_sec_recent = (float)new_connections / duration;
2634 conns_per_sec_total = (float)total_connections / total_duration; 2653 conns_per_sec_total = (float)total_connections / total_duration;
2635 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Conns/sec in last %d seconds: %f, Conns/sec for entire duration: %f\n", CONN_UPDATE_DURATION, (float)new_connections / duration, (float)total_connections / total_duration); 2654 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Recent: %f/s, Total: %f/s, Recent failed: %f/s, total failed %f/s\n",
2655 conns_per_sec_recent, CONN_UPDATE_DURATION, conns_per_sec_total,
2656 failed_conns_per_sec_recent, failed_conns_per_sec_total);
2636 connect_last_time = GNUNET_TIME_absolute_get(); 2657 connect_last_time = GNUNET_TIME_absolute_get();
2637 previous_connections = total_connections; 2658 previous_connections = total_connections;
2659 previous_failed_connections = failed_connections;
2638 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n", total_connections); 2660 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n", total_connections);
2639#if ONLY_TESTING 2661#if ONLY_TESTING
2640 /* These conditions likely mean we've entered the death spiral of doom */ 2662 /* These conditions likely mean we've entered the death spiral of doom */
@@ -2645,11 +2667,12 @@ topology_callback (void *cls,
2645 (repeat_connect_mode == GNUNET_NO)) 2667 (repeat_connect_mode == GNUNET_NO))
2646 { 2668 {
2647 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Entering repeat connection attempt mode!\n"); 2669 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Entering repeat connection attempt mode!\n");
2648
2649 repeat_connect_peer1 = first_daemon; 2670 repeat_connect_peer1 = first_daemon;
2650 repeat_connect_peer2 = second_daemon; 2671 repeat_connect_peer2 = second_daemon;
2651 repeat_connect_mode = GNUNET_YES; 2672 repeat_connect_mode = GNUNET_YES;
2652 repeat_connect_task = GNUNET_SCHEDULER_add_now(&repeat_connect, NULL); 2673 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Stopping NEW connections from being scheduled!\n");
2674 GNUNET_TESTING_stop_connections(pg);
2675 repeat_connect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60), &repeat_connect, NULL);
2653 } 2676 }
2654 2677
2655#endif 2678#endif
@@ -2667,10 +2690,11 @@ topology_callback (void *cls,
2667 else 2690 else
2668 { 2691 {
2669 failed_connections++; 2692 failed_connections++;
2693#if VERBOSE
2670 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n", 2694 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n",
2671 first_daemon->shortname, 2695 first_daemon->shortname,
2672 second_daemon->shortname, emsg); 2696 second_daemon->shortname, emsg);
2673#if VERBOSE 2697
2674 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n", 2698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n",
2675 first_daemon->shortname, 2699 first_daemon->shortname,
2676 second_daemon->shortname, emsg); 2700 second_daemon->shortname, emsg);
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index 6ddc4ea74..14a0bbd86 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -889,6 +889,20 @@ GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg,
889 GNUNET_TESTING_NotifyTopology cb, void *cls); 889 GNUNET_TESTING_NotifyTopology cb, void *cls);
890 890
891/** 891/**
892 * Stop the connection process temporarily.
893 *
894 * @param pg the peer group to stop connecting
895 */
896void GNUNET_TESTING_stop_connections(struct GNUNET_TESTING_PeerGroup *pg);
897
898/**
899 * Resume the connection process.
900 *
901 * @param pg the peer group to resume connecting
902 */
903void GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg);
904
905/**
892 * There are many ways to connect peers that are supported by this function. 906 * There are many ways to connect peers that are supported by this function.
893 * To connect peers in the same topology that was created via the 907 * To connect peers in the same topology that was created via the
894 * GNUNET_TESTING_create_topology, the topology variable must be set to 908 * GNUNET_TESTING_create_topology, the topology variable must be set to
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index f9b3cc3fc..fc527efe3 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -702,6 +702,11 @@ struct GNUNET_TESTING_PeerGroup
702 * ssh connections per peer. 702 * ssh connections per peer.
703 */ 703 */
704 struct OutstandingSSH *ssh_tail; 704 struct OutstandingSSH *ssh_tail;
705
706 /**
707 * Stop scheduling peers connecting.
708 */
709 unsigned int stop_connects;
705}; 710};
706 711
707struct UpdateContext 712struct UpdateContext
@@ -2904,8 +2909,9 @@ static void preschedule_connect(struct ConnectTopologyContext *ct_ctx)
2904 random_peer = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, pg->total); 2909 random_peer = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
2905 2910
2906 connection_iter = pg->peers[random_peer].connect_peers_head; 2911 connection_iter = pg->peers[random_peer].connect_peers_head;
2912#if DEBUG_TESTING
2907 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling connection between %d and %d\n", random_peer, connection_iter->index); 2913 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling connection between %d and %d\n", random_peer, connection_iter->index);
2908 2914#endif
2909 connect_context = GNUNET_malloc (sizeof (struct ConnectContext)); 2915 connect_context = GNUNET_malloc (sizeof (struct ConnectContext));
2910 connect_context->first = pg->peers[random_peer].daemon; 2916 connect_context->first = pg->peers[random_peer].daemon;
2911 connect_context->second = pg->peers[connection_iter->index].daemon; 2917 connect_context->second = pg->peers[connection_iter->index].daemon;
@@ -2967,7 +2973,7 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2967 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) 2973 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
2968 return; 2974 return;
2969 2975
2970 if (pg->outstanding_connects > pg->max_outstanding_connections) 2976 if ((pg->outstanding_connects > pg->max_outstanding_connections) || (pg->stop_connects == GNUNET_YES))
2971 { 2977 {
2972#if VERBOSE_TESTING > 2 2978#if VERBOSE_TESTING > 2
2973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2979 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4443,6 +4449,26 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
4443} 4449}
4444 4450
4445/** 4451/**
4452 * Stop the connection process temporarily.
4453 *
4454 * @param pg the peer group to stop connecting
4455 */
4456void GNUNET_TESTING_stop_connections(struct GNUNET_TESTING_PeerGroup *pg)
4457{
4458 pg->stop_connects = GNUNET_YES;
4459}
4460
4461/**
4462 * Resume the connection process temporarily.
4463 *
4464 * @param pg the peer group to resume connecting
4465 */
4466void GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg)
4467{
4468 pg->stop_connects = GNUNET_NO;
4469}
4470
4471/**
4446 * There are many ways to connect peers that are supported by this function. 4472 * There are many ways to connect peers that are supported by this function.
4447 * To connect peers in the same topology that was created via the 4473 * To connect peers in the same topology that was created via the
4448 * GNUNET_TESTING_create_topology, the topology variable must be set to 4474 * GNUNET_TESTING_create_topology, the topology variable must be set to