gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10697 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r10697 - gnunet/src/fs
Date: Thu, 25 Mar 2010 15:33:27 +0100

Author: grothoff
Date: 2010-03-25 15:33:27 +0100 (Thu, 25 Mar 2010)
New Revision: 10697

Modified:
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/test_fs_namespace.c
Log:
consider corking

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-03-25 14:33:18 UTC (rev 10696)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-03-25 14:33:27 UTC (rev 10697)
@@ -53,6 +53,13 @@
  */
 #define MAX_QUEUE_PER_PEER 2
 
+/**
+ * Inverse of the probability that we will submit the same query
+ * to the same peer again.  If the same peer already got the query
+ * repeatedly recently, the probability is multiplied by the inverse
+ * of this number each time.
+ */
+#define RETRY_PROBABILITY_INV 8
 
 /**
  * What is the maximum delay for a P2P FS message (in our interaction
@@ -631,7 +638,7 @@
   cont = pm->cont;
   cont_cls = pm->cont_cls;
   destroy_pending_message_list_entry (pml);
-  cont (cont_cls, 0);  
+  cont (cont_cls, tpid);  
 }
 
 
@@ -1128,19 +1135,22 @@
 
 /**
  * We use a random delay to make the timing of requests less
- * predictable.  This function returns such a random delay.
+ * predictable.  This function returns such a random delay.  We add a base
+ * delay of MAX_CORK_DELAY (1s).
  *
  * FIXME: make schedule dependent on the specifics of the request?
  * Or bandwidth and number of connected peers and load?
  *
- * @return random delay to use for some request, between 0 and TTL_DECREMENT ms
+ * @return random delay to use for some request, between 1s and 
1000+TTL_DECREMENT ms
  */
 static struct GNUNET_TIME_Relative
 get_processing_delay ()
 {
-  return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
-                                       GNUNET_CRYPTO_random_u32 
(GNUNET_CRYPTO_QUALITY_WEAK,
-                                                                 
TTL_DECREMENT));
+  return 
+    GNUNET_TIME_relative_add (GNUNET_CONSTANTS_MAX_CORK_DELAY,
+                             GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MILLISECONDS,
+                                                            
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+                                                                               
       TTL_DECREMENT)));
 }
 
 
@@ -1462,7 +1472,9 @@
   
   /* 1) check if we have already (recently) forwarded to this peer */
   for (i=0;i<pr->used_pids_off;i++)
-    if (pr->used_pids[i] == cp->pid)
+    if ( (pr->used_pids[i] == cp->pid) &&
+        (0 != GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+                                        RETRY_PROBABILITY_INV)) )
       return GNUNET_YES; /* skip */
   // 2) calculate how much we'd like to forward to this peer
   score = 42; // FIXME!
@@ -1513,7 +1525,8 @@
     {
 #if DEBUG_FS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "No peer selected for forwarding!\n");
+                 "No peer selected for forwarding of query `%s'!\n",
+                 GNUNET_h2s (&pr->query));
 #endif
       pr->task = GNUNET_SCHEDULER_add_delayed (sched,
                                               get_processing_delay (),

Modified: gnunet/src/fs/test_fs_namespace.c
===================================================================
--- gnunet/src/fs/test_fs_namespace.c   2010-03-25 14:33:18 UTC (rev 10696)
+++ gnunet/src/fs/test_fs_namespace.c   2010-03-25 14:33:27 UTC (rev 10697)
@@ -99,22 +99,51 @@
 
 static void
 publish_cont (void *cls,
-             const struct GNUNET_FS_Uri *uri,
+             const struct GNUNET_FS_Uri *ksk_uri,
              const char *emsg)
 {
   struct GNUNET_FS_SearchContext *search;
 
   GNUNET_assert (NULL == emsg);
-  fprintf (stderr, "Starting namespace search...\n");
-  search = GNUNET_FS_search_start (fs, uri, 1, "ns-search");
+  fprintf (stderr, "Starting keyword search...\n");
+  search = GNUNET_FS_search_start (fs, ksk_uri, 1, NULL);
 }
 
+
 static void
+sks_cont (void *cls,
+         const struct GNUNET_FS_Uri *uri,
+         const char *emsg)
+{
+  struct GNUNET_CONTAINER_MetaData *meta;
+  struct GNUNET_TIME_Absolute expiration;
+  struct GNUNET_FS_Uri *ksk_uri;
+  char * msg;
+
+  expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
+  meta = GNUNET_CONTAINER_meta_data_create ();
+  msg = NULL;
+  ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/ns-search", &msg);
+  GNUNET_assert (NULL == msg);
+  fprintf (stderr, "Advertising update 'this' namespace entry under 
keyword...\n");
+  GNUNET_FS_publish_ksk (fs,
+                        ksk_uri,
+                        meta,
+                        uri,
+                        expiration,
+                        1, 1,
+                        GNUNET_FS_PUBLISH_OPTION_NONE,
+                        &publish_cont,
+                        NULL);
+  GNUNET_CONTAINER_meta_data_destroy (meta);
+}
+
+
+static void
 adv_cont (void *cls,
              const struct GNUNET_FS_Uri *uri,
              const char *emsg)
 {
-  struct GNUNET_FS_SearchContext *search;
   struct GNUNET_CONTAINER_MetaData *meta;
   struct GNUNET_FS_Namespace *ns;
   struct GNUNET_TIME_Absolute expiration;
@@ -124,18 +153,17 @@
                                   "testNamespace");
   meta = GNUNET_CONTAINER_meta_data_create ();
   GNUNET_assert (NULL == emsg);
-  fprintf (stderr, "Starting namespace search...\n");
-  search = GNUNET_FS_search_start (fs, uri, 1, "ns-search");
+  fprintf (stderr, "Advertising update 'this->next' namespace update...\n");
   GNUNET_FS_publish_sks (fs,
                         ns,
                         "this",
                         "next",
                         meta,
-                        uri,
+                        uri, /* FIXME: this is non-sense (use CHK URI!) */
                         expiration,
                         1, 1,
                         GNUNET_FS_PUBLISH_OPTION_NONE,
-                        &publish_cont,
+                        &sks_cont,
                         NULL);
   GNUNET_CONTAINER_meta_data_destroy (meta);
   GNUNET_FS_namespace_delete (ns, GNUNET_NO);
@@ -153,6 +181,7 @@
   meta = GNUNET_CONTAINER_meta_data_create ();
   ns = GNUNET_FS_namespace_create (fs,
                                   "testNamespace");
+  fprintf (stderr, "Advertising namespace root...\n");
   GNUNET_FS_namespace_advertise (fs,
                                 ns,
                                 meta,





reply via email to

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