gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8565 - in gnunet: . contrib src/include src/topology src/u


From: gnunet
Subject: [GNUnet-SVN] r8565 - in gnunet: . contrib src/include src/topology src/util
Date: Sun, 14 Jun 2009 14:21:18 -0600

Author: grothoff
Date: 2009-06-14 14:21:18 -0600 (Sun, 14 Jun 2009)
New Revision: 8565

Modified:
   gnunet/TODO
   gnunet/contrib/defaults.conf
   gnunet/src/include/gnunet_common.h
   gnunet/src/topology/gnunet-daemon-topology.c
   gnunet/src/util/common_allocation.c
Log:
more topology implementation

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2009-06-14 12:45:22 UTC (rev 8564)
+++ gnunet/TODO 2009-06-14 20:21:18 UTC (rev 8565)
@@ -1,13 +1,6 @@
 PHASE #1: (Goal: settle key design questions)
 
-Hostlist:
-* hostlist server (MHD-side)
-* hostlist client (CURL-side); monitoring of number of active connections (to 
establish need for bootstrapping)
-* hostlist server URL advertising & learning via P2P
-
 Topology:
-* Selecting peers from peerinfo for connects; blacklisting
-* Managing connections, F2F configuration obedience, rejecting prohibited 
connections
 * Forwarding of known HELLOs to neighbours (advertising)
   [ Inbound HELLOs are processed by transport, right?  
     But what about inbound encrypted HELLOs? ]
@@ -61,8 +54,11 @@
   - set_key_retry_task
   - align_and_deliver
   - handle_transport_notify_disconnect
+* hostlist (everything)
+* topology (everything)
 
 
+
 PHASE #2: (Goal: recover basic file-sharing functionality)
 
 Datastores:
@@ -167,7 +163,12 @@
 * GAP improvements:
   - active reply route caching design & implementation of service,
     gap extension!
+* HOSTLIST:
+  - implement advertising of hostlist URL
+  - implement learning of hostlist URLs
 
+
+
 => PRE-RELEASE
 
 PHASE #4: [completion-goal: mid 2010]

Modified: gnunet/contrib/defaults.conf
===================================================================
--- gnunet/contrib/defaults.conf        2009-06-14 12:45:22 UTC (rev 8564)
+++ gnunet/contrib/defaults.conf        2009-06-14 20:21:18 UTC (rev 8565)
@@ -138,3 +138,22 @@
 # REJECT_FROM =
 # REJECT_FROM6 =
 # PREFIX =
+
+
+[topology]
+MINIMUM-FRIENDS = 0
+FRIENDS-ONLY = NO
+AUTOCONNECT = YES
+TARGET-CONNECTION-COUNT = 16
+FRIENDS = $SERVICEHOME/friends
+
+
+[hostlist]
+# consider having "-e" as default as well once implemented
+OPTIONS = -b
+SERVERS = http://gnunet.org:8080/
+# proxy for downloading hostlists
+HTTP-PROXY = 
+# port for hostlist server
+PORT = 8080
+

Modified: gnunet/src/include/gnunet_common.h
===================================================================
--- gnunet/src/include/gnunet_common.h  2009-06-14 12:45:22 UTC (rev 8564)
+++ gnunet/src/include/gnunet_common.h  2009-06-14 20:21:18 UTC (rev 8565)
@@ -301,7 +301,7 @@
 /**
  * Maximum allocation with GNUNET_malloc macro.
  */
-#define GNUNET_MAX_GNUNET_MALLOC_CHECKED (1024 * 1024 * 40)
+#define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40)
 
 /**
  * Wrapper around malloc. Allocates size bytes of memory.

Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c        2009-06-14 12:45:22 UTC 
(rev 8564)
+++ gnunet/src/topology/gnunet-daemon-topology.c        2009-06-14 20:21:18 UTC 
(rev 8565)
@@ -22,11 +22,6 @@
  * @file topology/gnunet-daemon-topology.c
  * @brief code for bootstrapping via topology servers
  * @author Christian Grothoff
- *
- * TODO: 
- * - blacklisting & respect for blacklist
- * - calculate target_connection_count!
- * - calculate peer_search retry delay 
  */
 
 #include <stdlib.h>
@@ -39,17 +34,29 @@
 
 #define DEBUG_TOPOLOGY GNUNET_NO
 
+/**
+ * For how long do we blacklist a peer after a failed
+ * connection attempt?
+ */ 
+#define BLACKLIST_AFTER_ATTEMPT GNUNET_TIME_UNIT_HOURS
 
 /**
- * List of neighbours and friends.
+ * For how long do we blacklist a friend after a failed
+ * connection attempt?
+ */ 
+#define BLACKLIST_AFTER_ATTEMPT_FRIEND GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MINUTES, 15)
+
+
+/**
+ * List of neighbours, friends and blacklisted peers.
  */
-struct FriendList
+struct PeerList
 {
 
   /**
    * This is a linked list.
    */
-  struct FriendList *next;
+  struct PeerList *next;
 
   /**
    * Is this peer listed here because he is a friend?
@@ -99,7 +106,7 @@
  * Linked list of all of our friends and all of our current
  * neighbours.
  */
-static struct FriendList *friends;
+static struct PeerList *friends;
 
 /**
  * Flag to disallow non-friend connections (pure F2F mode).
@@ -170,9 +177,28 @@
  */
 static void
 attempt_connect (const struct GNUNET_PeerIdentity *peer,
-                struct FriendList *pos)
+                struct PeerList *pos)
 {
-  /* FIXME: do blacklist! */
+  if (pos == NULL)
+    {
+      pos = friends;
+      while (pos != NULL)
+       {
+         if (0 == memcmp (&pos->id, peer, sizeof (struct GNUNET_PeerIdentity)))
+           break;
+       }
+    }
+  if (pos == NULL)
+    {
+      pos = GNUNET_malloc (sizeof(struct PeerList));
+      pos->id = *peer;
+      pos->next = friends;
+      friends = pos;
+    }
+  if (GNUNET_YES == pos->is_friend)
+    pos->blacklisted_until = GNUNET_TIME_relative_to_absolute 
(BLACKLIST_AFTER_ATTEMPT_FRIEND);
+  else
+    pos->blacklisted_until = GNUNET_TIME_relative_to_absolute 
(BLACKLIST_AFTER_ATTEMPT);
   GNUNET_CORE_notify_transmit_ready (handle,
                                     0 /* priority */,
                                     GNUNET_TIME_UNIT_MINUTES,
@@ -189,7 +215,7 @@
 static int
 is_friend (const struct GNUNET_PeerIdentity * peer)
 {
-  struct FriendList *pos;
+  struct PeerList *pos;
 
   pos = friends;
   while (pos != NULL)
@@ -231,7 +257,7 @@
                            const struct
                            GNUNET_PeerIdentity * peer)
 {
-  struct FriendList *pos;
+  struct PeerList *pos;
 
   connection_count++;
   pos = friends;
@@ -242,12 +268,13 @@
        {
          GNUNET_assert (GNUNET_NO == pos->is_connected);
          pos->is_connected = GNUNET_YES;
+         pos->blacklisted_until.value = 0; /* remove blacklisting */
          friend_count++;         
          return;
        }
       pos = pos->next;
     }
-  pos = GNUNET_malloc (sizeof(struct FriendList));
+  pos = GNUNET_malloc (sizeof(struct PeerList));
   pos->id = *peer;
   pos->is_connected = GNUNET_YES;
   pos->next = friends;
@@ -263,7 +290,7 @@
 static void 
 drop_non_friends () 
 {
-  struct FriendList *pos;
+  struct PeerList *pos;
 
   pos = friends;
   while (pos != NULL)
@@ -288,8 +315,8 @@
                               const struct
                               GNUNET_PeerIdentity * peer)
 {
-  struct FriendList *pos;
-  struct FriendList *prev;
+  struct PeerList *pos;
+  struct PeerList *prev;
 
   connection_count--;
   pos = friends;
@@ -327,6 +354,7 @@
   GNUNET_break (0);
 }
 
+
 /**
  * Find more peers that we should connect to and ask the
  * core to establish connections.
@@ -345,9 +373,16 @@
 {
   struct GNUNET_TIME_Relative delay;
   
-  /* FIXME: calculate reasonable delay here */
-  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES,
-                                        42);
+  /* Typically, we try again every 15 minutes; the minimum period is
+     15s; if we are above the connection target, we reduce re-trying
+     by the square of how much we are above; so for example, with 200%
+     of the connection target we would only look for more peers once
+     every hour (after all, we're quite busy processing twice as many
+     connections as we intended to have); similarly, if we are at only
+     25% of our connectivity goal, we will try 16x as hard to connect
+     (so roughly once a minute, plus the 15s minimum delay */
+  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+                                        15 + 15 * 60 * connection_count * 
connection_count / target_connection_count / target_connection_count);
   GNUNET_SCHEDULER_add_delayed (sched,
                                GNUNET_NO,
                                GNUNET_SCHEDULER_PRIORITY_DEFAULT,
@@ -368,7 +403,7 @@
              const struct GNUNET_HELLO_Message * hello,
              uint32_t trust)
 {
-  struct FriendList *pos;
+  struct PeerList *pos;
 
   if (peer == NULL)
     {
@@ -392,7 +427,8 @@
        {
          if (GNUNET_YES == pos->is_connected)
            return;
-         /* FIXME: check blacklisted... */
+         if (GNUNET_TIME_absolute_get_remaining (pos->blacklisted_until).value 
> 0)
+           return; /* peer still blacklisted */
          if (GNUNET_YES == pos->is_friend)
            {
              attempt_connect (peer, pos);
@@ -415,13 +451,13 @@
 static void
 try_add_friends ()
 {
-  struct FriendList *pos;
+  struct PeerList *pos;
 
   pos = friends;
   while (pos != NULL)
     {
-      /* FIXME: check friends for blacklisting... */
-      if ( (GNUNET_YES == pos->is_friend) &&
+      if ( (GNUNET_TIME_absolute_get_remaining (pos->blacklisted_until).value 
== 0) &&
+          (GNUNET_YES == pos->is_friend) &&
           (GNUNET_YES != pos->is_connected) )
        attempt_connect (&pos->id, pos);
       pos = pos->next;
@@ -430,6 +466,41 @@
 
 
 /**
+ * Discard peer entries for blacklisted peers
+ * where the blacklisting has expired.
+ */
+static void
+discard_old_blacklist_entries ()
+{
+  struct PeerList *pos;
+  struct PeerList *next;
+  struct PeerList *prev;
+
+  next = friends;
+  prev = NULL;
+  while (NULL != (pos = next))
+    {
+      next = pos->next;
+      if ( (GNUNET_NO == pos->is_friend) &&
+          (GNUNET_NO == pos->is_connected) &&
+          (0 == GNUNET_TIME_absolute_get_remaining 
(pos->blacklisted_until).value) )
+       {
+         /* delete 'pos' from list */
+         if (prev == NULL)
+           friends = next;
+         else
+           prev->next = next;
+         GNUNET_free (pos);
+       }
+      else
+       {
+         prev = pos;
+       }
+    }
+}
+
+
+/**
  * Find more peers that we should connect to and ask the
  * core to establish connections.
  */
@@ -437,6 +508,7 @@
 find_more_peers (void *cls,
                 const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  discard_old_blacklist_entries ();
   if (target_connection_count <= connection_count)
     {
       schedule_peer_search ();
@@ -515,7 +587,7 @@
   struct stat frstat;
   struct GNUNET_CRYPTO_HashAsciiEncoded enc;
   unsigned int entries_found;
-  struct FriendList *fl;
+  struct PeerList *fl;
 
   fn = NULL;
   GNUNET_CONFIGURATION_get_value_filename (cfg,
@@ -581,7 +653,7 @@
       else
        {
          entries_found++;
-         fl = GNUNET_malloc (sizeof(struct FriendList));
+         fl = GNUNET_malloc (sizeof(struct PeerList));
          fl->is_friend = GNUNET_YES;
          fl->id.hashPubKey = hc;
          fl->next = friends;
@@ -644,6 +716,12 @@
                                         "MINIMUM-FRIENDS",
                                         &opt);
   minimum_friend_count = (unsigned int) opt;
+  opt = 16;
+  GNUNET_CONFIGURATION_get_value_number (cfg,
+                                        "TOPOLOGY",
+                                        "TARGET-CONNECTION-COUNT",
+                                        &opt);
+  target_connection_count = (unsigned int) opt;
 
   if ( (friends_only == GNUNET_YES) ||
        (minimum_friend_count > 0) )

Modified: gnunet/src/util/common_allocation.c
===================================================================
--- gnunet/src/util/common_allocation.c 2009-06-14 12:45:22 UTC (rev 8564)
+++ gnunet/src/util/common_allocation.c 2009-06-14 20:21:18 UTC (rev 8565)
@@ -48,7 +48,7 @@
 {
   /* As a security precaution, we generally do not allow very large
      allocations using the default 'GNUNET_malloc' macro */
-  GNUNET_assert_at (size <= GNUNET_MAX_GNUNET_MALLOC_CHECKED, filename,
+  GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename,
                     linenumber);
   return GNUNET_xmalloc_unchecked_ (size, filename, linenumber);
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]