aboutsummaryrefslogtreecommitdiff
path: root/src/topology
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-25 12:44:42 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-25 12:44:42 +0000
commit7ad847a982ccfb46b3f785c17185b53cbceb0c63 (patch)
tree64816b088e947ea8b31aa0cc6d1ab7324b5146a8 /src/topology
parent9ac0acb2484d3b73542315f2164e1a08f80d989c (diff)
downloadgnunet-7ad847a982ccfb46b3f785c17185b53cbceb0c63.tar.gz
gnunet-7ad847a982ccfb46b3f785c17185b53cbceb0c63.zip
-fixing advertising constants, code cleanup
Diffstat (limited to 'src/topology')
-rw-r--r--src/topology/gnunet-daemon-topology.c40
1 files changed, 5 insertions, 35 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index 4e332496c..bab91f71a 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -23,8 +23,6 @@
23 * @brief code for maintaining the mesh topology 23 * @brief code for maintaining the mesh topology
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
27#include <stdlib.h>
28#include "platform.h" 26#include "platform.h"
29#include "gnunet_constants.h" 27#include "gnunet_constants.h"
30#include "gnunet_core_service.h" 28#include "gnunet_core_service.h"
@@ -35,8 +33,6 @@
35#include "gnunet_util_lib.h" 33#include "gnunet_util_lib.h"
36 34
37 35
38#define DEBUG_TOPOLOGY GNUNET_YES
39
40/** 36/**
41 * For how long do we blacklist a peer after a failed connection 37 * For how long do we blacklist a peer after a failed connection
42 * attempt? 38 * attempt?
@@ -50,24 +46,24 @@
50#define GREYLIST_AFTER_ATTEMPT_FRIEND GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) 46#define GREYLIST_AFTER_ATTEMPT_FRIEND GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
51 47
52/** 48/**
53 * For how long do we blacklist anyone under any cirumstances after a failed connection 49 * For how long do we blacklist anyone under any cirumstances at least after a failed connection
54 * attempt? 50 * attempt?
55 */ 51 */
56#define GREYLIST_AFTER_ATTEMPT_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) 52#define GREYLIST_AFTER_ATTEMPT_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
57 53
58/** 54/**
59 * For how long do we blacklist anyone under any cirumstances after a failed connection 55 * For how long do we blacklist anyone under any cirumstances at most after a failed connection
60 * attempt? 56 * attempt?
61 */ 57 */
62#define GREYLIST_AFTER_ATTEMPT_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1) 58#define GREYLIST_AFTER_ATTEMPT_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1)
63 59
64/** 60/**
65 * How often do we at most advertise any HELLO to a peer? 61 * At what frequency do we sent HELLOs to a peer?
66 */ 62 */
67#define HELLO_ADVERTISEMENT_MIN_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) 63#define HELLO_ADVERTISEMENT_MIN_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
68 64
69/** 65/**
70 * How often do we at most advertise the same HELLO to the same peer? 66 * After what time period do we expire the HELLO Bloom filter?
71 */ 67 */
72#define HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) 68#define HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
73 69
@@ -278,20 +274,16 @@ is_connection_allowed (struct Peer *peer)
278 return GNUNET_OK; 274 return GNUNET_OK;
279 if (GNUNET_YES == friends_only) 275 if (GNUNET_YES == friends_only)
280 { 276 {
281#if DEBUG_TOPOLOGY
282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
283 "Determined that `%s' is not allowed to connect (not a friend)\n", 278 "Determined that `%s' is not allowed to connect (not a friend)\n",
284 GNUNET_i2s (&peer->pid)); 279 GNUNET_i2s (&peer->pid));
285#endif
286 return GNUNET_SYSERR; 280 return GNUNET_SYSERR;
287 } 281 }
288 if (friend_count >= minimum_friend_count) 282 if (friend_count >= minimum_friend_count)
289 return GNUNET_OK; 283 return GNUNET_OK;
290#if DEBUG_TOPOLOGY
291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
292 "Determined that `%s' is not allowed to connect (not enough connected friends)\n", 285 "Determined that `%s' is not allowed to connect (not enough connected friends)\n",
293 GNUNET_i2s (&peer->pid)); 286 GNUNET_i2s (&peer->pid));
294#endif
295 return GNUNET_SYSERR; 287 return GNUNET_SYSERR;
296} 288}
297 289
@@ -371,10 +363,8 @@ attempt_connect (struct Peer *pos)
371 GNUNET_SCHEDULER_cancel (pos->greylist_clean_task); 363 GNUNET_SCHEDULER_cancel (pos->greylist_clean_task);
372 pos->greylist_clean_task = 364 pos->greylist_clean_task =
373 GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos); 365 GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos);
374#if DEBUG_TOPOLOGY
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to connect to `%s'\n", 366 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to connect to `%s'\n",
376 GNUNET_i2s (&pos->pid)); 367 GNUNET_i2s (&pos->pid));
377#endif
378 GNUNET_STATISTICS_update (stats, 368 GNUNET_STATISTICS_update (stats,
379 gettext_noop 369 gettext_noop
380 ("# connect requests issued to transport"), 1, 370 ("# connect requests issued to transport"), 1,
@@ -642,11 +632,9 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
642{ 632{
643 struct Peer *pos; 633 struct Peer *pos;
644 634
645#if DEBUG_TOPOLOGY
646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
647 "Core told us that we are connecting to `%s'\n", 636 "Core told us that we are connecting to `%s'\n",
648 GNUNET_i2s (peer)); 637 GNUNET_i2s (peer));
649#endif
650 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) 638 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
651 return; 639 return;
652 640
@@ -725,11 +713,9 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
725 713
726 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) 714 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
727 return; 715 return;
728#if DEBUG_TOPOLOGY
729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
730 "Core told us that we disconnected from `%s'\n", 717 "Core told us that we disconnected from `%s'\n",
731 GNUNET_i2s (peer)); 718 GNUNET_i2s (peer));
732#endif
733 pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); 719 pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
734 if (pos == NULL) 720 if (pos == NULL)
735 { 721 {
@@ -828,11 +814,9 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello)
828 if (dt.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) 814 if (dt.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
829 return; /* nothing new here */ 815 return; /* nothing new here */
830 } 816 }
831#if DEBUG_TOPOLOGY
832 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 817 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
833 "Found `%s' from peer `%s' for advertising\n", "HELLO", 818 "Found `%s' from peer `%s' for advertising\n", "HELLO",
834 GNUNET_i2s (&pid)); 819 GNUNET_i2s (&pid));
835#endif
836 if (peer->hello != NULL) 820 if (peer->hello != NULL)
837 { 821 {
838 nh = GNUNET_HELLO_merge (peer->hello, hello); 822 nh = GNUNET_HELLO_merge (peer->hello, hello);
@@ -909,24 +893,18 @@ process_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
909 GNUNET_assert (NULL != pos); 893 GNUNET_assert (NULL != pos);
910 if (GNUNET_YES == pos->is_connected) 894 if (GNUNET_YES == pos->is_connected)
911 { 895 {
912#if DEBUG_TOPOLOGY
913 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Already connected to peer `%s'\n", 896 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Already connected to peer `%s'\n",
914 GNUNET_i2s (peer)); 897 GNUNET_i2s (peer));
915#endif
916 return; 898 return;
917 } 899 }
918 if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0) 900 if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0)
919 { 901 {
920#if DEBUG_TOPOLOGY
921 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Already tried peer `%s' recently\n", 902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Already tried peer `%s' recently\n",
922 GNUNET_i2s (peer)); 903 GNUNET_i2s (peer));
923#endif
924 return; /* peer still greylisted */ 904 return; /* peer still greylisted */
925 } 905 }
926#if DEBUG_TOPOLOGY
927 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Considering connecting to peer `%s'\n", 906 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Considering connecting to peer `%s'\n",
928 GNUNET_i2s (peer)); 907 GNUNET_i2s (peer));
929#endif
930 attempt_connect (pos); 908 attempt_connect (pos);
931} 909}
932 910
@@ -953,9 +931,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
953 } 931 }
954 handle = server; 932 handle = server;
955 my_identity = *my_id; 933 my_identity = *my_id;
956#if DEBUG_TOPOLOGY
957 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id)); 934 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id));
958#endif
959 peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, NULL); 935 peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, NULL);
960} 936}
961 937
@@ -1114,10 +1090,8 @@ handle_encrypted_hello (void *cls, const struct GNUNET_PeerIdentity *other,
1114 struct Peer *peer; 1090 struct Peer *peer;
1115 struct GNUNET_PeerIdentity pid; 1091 struct GNUNET_PeerIdentity pid;
1116 1092
1117#if DEBUG_TOPOLOGY
1118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received encrypted `%s' from peer `%s'", 1093 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received encrypted `%s' from peer `%s'",
1119 "HELLO", GNUNET_i2s (other)); 1094 "HELLO", GNUNET_i2s (other));
1120#endif
1121 if (GNUNET_OK != 1095 if (GNUNET_OK !=
1122 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) message, &pid)) 1096 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) message, &pid))
1123 { 1097 {
@@ -1176,10 +1150,8 @@ hello_advertising_ready (void *cls, size_t size, void *buf)
1176 GNUNET_assert (want <= size); 1150 GNUNET_assert (want <= size);
1177 memcpy (buf, fah.result->hello, want); 1151 memcpy (buf, fah.result->hello, want);
1178 GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, &pl->pid.hashPubKey); 1152 GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, &pl->pid.hashPubKey);
1179#if DEBUG_TOPOLOGY
1180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' with %u bytes", "HELLO", 1153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' with %u bytes", "HELLO",
1181 (unsigned int) want); 1154 (unsigned int) want);
1182#endif
1183 GNUNET_STATISTICS_update (stats, 1155 GNUNET_STATISTICS_update (stats,
1184 gettext_noop ("# HELLO messages gossipped"), 1, 1156 gettext_noop ("# HELLO messages gossipped"), 1,
1185 GNUNET_NO); 1157 GNUNET_NO);
@@ -1270,12 +1242,10 @@ run (void *cls, char *const *args, const char *cfgfile,
1270 1242
1271 if ((friends_only == GNUNET_YES) || (minimum_friend_count > 0)) 1243 if ((friends_only == GNUNET_YES) || (minimum_friend_count > 0))
1272 read_friends_file (cfg); 1244 read_friends_file (cfg);
1273#if DEBUG_TOPOLOGY
1274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1275 "Topology would like %u connections with at least %u friends (%s)\n", 1246 "Topology would like %u connections with at least %u friends (%s)\n",
1276 target_connection_count, minimum_friend_count, 1247 target_connection_count, minimum_friend_count,
1277 autoconnect ? "autoconnect enabled" : "autoconnect disabled"); 1248 autoconnect ? "autoconnect enabled" : "autoconnect disabled");
1278#endif
1279 if ((friend_count < minimum_friend_count) && (blacklist == NULL)) 1249 if ((friend_count < minimum_friend_count) && (blacklist == NULL))
1280 blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL); 1250 blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL);
1281 transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); 1251 transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL);