gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r162 - in GNUnet/src: applications/fs/module include


From: grothoff
Subject: [GNUnet-SVN] r162 - in GNUnet/src: applications/fs/module include
Date: Thu, 3 Feb 2005 00:25:32 -0800 (PST)

Author: grothoff
Date: 2005-02-03 00:25:31 -0800 (Thu, 03 Feb 2005)
New Revision: 162

Modified:
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/include/gnunet_dht.h
   GNUnet/src/include/gnunet_dht_lib.h
Log:
better resolution of migration time

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-02-02 12:52:59 UTC (rev 
161)
+++ GNUnet/src/applications/fs/module/fs.c      2005-02-03 08:25:31 UTC (rev 
162)
@@ -44,8 +44,45 @@
 #include "fs.h"
 
 /**
- * What is the maximum expiration time for migrated
- * content?
+ * What is the maximum expiration time for migrated content? 
+ *
+ * This is a non-trivial issue.  If we have a ceiling for migration
+ * time, it would violate anonymity if we send out content with an
+ * expiration time above that ceiling (since it would expose the
+ * content to originate from this peer).  But we want to store a
+ * higher expiration time for our content in the DB.
+ * 
+ * A first idea would be to pick a random time smaller than the limit
+ * for outgoing content; that does not _quite_ work since that could
+ * also expose us as the originator: only for our own content the
+ * expiration time would randomly go up and down.
+ * 
+ * The current best solution is to first bound the expiration time by
+ * this ceiling (for inbound and outbound ETs, not for the database
+ * entries locally) using modulo (to, in practice, get a constant
+ * bound for the local content just like for the migrated content).
+ * Then that number is randomized for _all_ outgoing content.  This
+ * way, the time left changes for all entries, but statistically
+ * always decreases on average as time progresses (also for all
+ * entries).
+ *
+ * Now, for local content eventually modulo will rebound to the MAX
+ * (whereas for migrated content it will hit 0 and disappear).  But
+ * that is OK: the adversary cannot distinguish the modulo wraparound
+ * from content migration (refresh with higher lifetime) which could
+ * plausibly happen from the original node (and in fact would happen
+ * around the same time!).  This design also achieves the design goal
+ * that if the original node disappears, the migrated content will
+ * eventually time-out (which is good since we don't want dangling
+ * search results to stay around).
+ *
+ * However, this does NOT mean that migrated content cannot live
+ * longer than 1 month -- remember, GNUnet peers discard expired
+ * content _if they run out of space_.  So it is perfectly plausible
+ * that content stays around longer.  Finally, clients (UI) may want
+ * to filter / rank / display search results with their current
+ * expiration to give the user some indication about availability.
+ * 
  */
 #define MAX_MIGRATION_EXP (1L * cronMONTHS)
 
@@ -343,6 +380,8 @@
   GapWrapper * gw;
   int ret;
   unsigned int size;
+  cron_t et;
+  cron_t now;
 
   ret = isDatumApplicable(ntohl(value->type),
                          ntohl(value->size) - sizeof(Datastore_Value),
@@ -409,7 +448,17 @@
   gw = MALLOC(size);
   gw->dc.size = htonl(size);
   gw->type = value->type;
-  gw->timeout = value->expirationTime;
+  et = ntohll(value->expirationTime);
+  /* expiration time normalization and randomization */
+  cronTime(&now);
+  if (et > now) {
+    et -= now;
+    et = et % MAX_MIGRATION_EXP;
+    if (et > 0)
+      et = randomi(et);
+    et = et + now;
+  }
+  gw->timeout = htonll(et);
   memcpy(&gw[1],
         &value[1],
         size - sizeof(GapWrapper));
@@ -478,6 +527,8 @@
   unsigned int size;
   int ret;
   HashCode160 hc;
+  cron_t et;
+  cron_t now;
 
   if (ntohl(value->size) < sizeof(GapWrapper)) {
     BREAK();
@@ -502,14 +553,15 @@
   dv->type = gw->type;
   dv->prio = htonl(prio);
   dv->anonymityLevel = htonl(0);
-  if ( (ntohll(gw->timeout) > cronTime(NULL) + MAX_MIGRATION_EXP) &&
-       (randomi(1+prio) == 0) /* allow _ocasionally_ to keep an extremely high
-                                expiration time, to make it plausible for 
-                                content we originate that it has such high 
-                                expiration times! */ )
-    dv->expirationTime = htonll(cronTime(NULL) + randomi(MAX_MIGRATION_EXP));
-  else
-    dv->expirationTime = gw->timeout;
+  et = ntohll(gw->timeout);
+  cronTime(&now);
+  /* bound ET to MAX_MIGRATION_EXP from now */ 
+  if (et > now) {
+    et -= now;
+    et = et % MAX_MIGRATION_EXP;
+    et += now;
+  }
+  dv->expirationTime = htonll(et);
   memcpy(&dv[1],
         &gw[1],
         size - sizeof(Datastore_Value));

Modified: GNUnet/src/include/gnunet_dht.h
===================================================================
--- GNUnet/src/include/gnunet_dht.h     2005-02-02 12:52:59 UTC (rev 161)
+++ GNUnet/src/include/gnunet_dht.h     2005-02-03 08:25:31 UTC (rev 162)
@@ -30,6 +30,7 @@
 #define GNUNET_DHT_H 
 
 #include "gnunet_util.h"
+#include "gnunet_blockstore.h"
 
 /* ************* API specific errorcodes *********** */
 
@@ -61,8 +62,6 @@
 
   CS_HEADER header;
 
-  unsigned long long timeout;  /* nbo */
-
   DHT_TableId table;  
 
 } DHT_CS_REQUEST_JOIN;
@@ -74,10 +73,10 @@
 
   CS_HEADER header;
   
-  unsigned long long timeout;  /* nbo */
-
   DHT_TableId table;  
 
+  unsigned long long timeout;  /* nbo */
+
 } DHT_CS_REQUEST_LEAVE; 
 
 
@@ -89,12 +88,16 @@
 
   CS_HEADER header;
   
-  unsigned long long timeout;  /* nbo */
-  
   DHT_TableId table; 
 
+  unsigned long long timeout;  /* nbo */
+  
   HashCode160 key;
 
+  unsigned int type; /* nbo */
+
+  unsigned int priority; /* nbo */
+
 } DHT_CS_REQUEST_PUT;
 
 /**
@@ -117,14 +120,16 @@
 
   CS_HEADER header;
 
-  unsigned int type;
+  unsigned int type; /* nbo */
 
   unsigned long long timeout;  /* nbo */
 
   DHT_TableId table; 
 
+  unsigned int priority; /* nbo */
+
   /* one or more keys */
-  HashCode160 keys;
+  HashCode160 keys;  
 
 } DHT_CS_REQUEST_GET;
 
@@ -135,10 +140,12 @@
 
   CS_HEADER header;
   
-  unsigned long long timeout; /* nbo */
-
   DHT_TableId table; 
   
+  unsigned long long timeout; /* nbo */
+
+  unsigned int type; /* nbo */
+
   HashCode160 key;
 
 } DHT_CS_REQUEST_REMOVE;
@@ -178,25 +185,12 @@
 
   DHT_TableId table; 
 
-} DHT_CS_REPLY_RESULTS;
+  HashCode160 key;
 
-/**
- * TCP communication: Results for a request.  If not all results fit
- * into a single message, DHT_CS_REPLY_RESULTS maybe repeated many
- * times.
- */
-typedef struct {
+  DataContainer data;
 
-  DHT_CS_REPLY_RESULTS dht_cs_reply_results;
+} DHT_CS_REPLY_RESULTS;
 
-  /**
-   * Results data; serialized version of DataContainer.
-   */
-  char data[1]; 
-
-} DHT_CS_REPLY_RESULTS_GENERIC;
-
-
 /**
  * TCP communication: status response for a request
  */

Modified: GNUnet/src/include/gnunet_dht_lib.h
===================================================================
--- GNUnet/src/include/gnunet_dht_lib.h 2005-02-02 12:52:59 UTC (rev 161)
+++ GNUnet/src/include/gnunet_dht_lib.h 2005-02-03 08:25:31 UTC (rev 162)
@@ -52,8 +52,7 @@
  * @return SYSERR on error, OK on success
  */
 int DHT_LIB_join(Blockstore * store,
-                DHT_TableId * table,
-                cron_t timeout);
+                DHT_TableId * table);
 
 
 /**
@@ -94,6 +93,7 @@
  */
 int DHT_LIB_get(const DHT_TableId * table,
                unsigned int type,
+               unsigned int prio,
                unsigned int keyCount,
                const HashCode160 * keys,
                cron_t timeout,
@@ -114,6 +114,7 @@
 int DHT_LIB_put(const DHT_TableId * table,
                const HashCode160 * key,
                unsigned int type,
+               unsigned int prio,
                cron_t timeout,
                const DataContainer * value);
 





reply via email to

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