gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34126 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r34126 - gnunet/src/dht
Date: Fri, 8 Aug 2014 15:29:20 +0200

Author: supriti
Date: 2014-08-08 15:29:20 +0200 (Fri, 08 Aug 2014)
New Revision: 34126

Modified:
   gnunet/src/dht/gnunet-service-xdht_neighbours.c
   gnunet/src/dht/gnunet_dht_profiler.c
Log:
Using statistics to collect current successor of a peer in profiler


Modified: gnunet/src/dht/gnunet-service-xdht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-08 09:26:01 UTC 
(rev 34125)
+++ gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-08 13:29:20 UTC 
(rev 34126)
@@ -52,6 +52,8 @@
  * hashing.
  */
 
+#define DEBUG(...)                                           \
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 
 /**
  * Maximum possible fingers (including predecessor) of a peer
@@ -2220,7 +2222,10 @@
 
   msize = sizeof (struct PeerGetMessage) +
           (get_path_length * sizeof (struct GNUNET_PeerIdentity));
-
+  
+  //GNUNET_SERVER_MAX_MESSAGE_SIZE
+  /* FIXME:TODO:URGENTHere you can try to optimize it a bit. In case the get 
path contains you
+   or your friend then shorten the path. */
   /* In this case we don't make get_path_length = 0, as we need get path to
    * return the message back to querying client. */
   if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
@@ -3054,25 +3059,7 @@
   return new_trail;
 }
 
-#if 0
-/* Store the successor for path tracking */
-  if (track_topology &&  (NULL != GDS_stats))
-  {
-    char *my_id_str;
-    char *succ_id_str;
-    char *key;
 
-    my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity));
-    succ_id_str = GNUNET_strdup (GNUNET_i2s
-                                 (&successor->finger_identity));
-    GNUNET_asprintf (&key, "XDHT:0:%.4s:%.4s", my_id_str, succ_id_str);
-    GNUNET_free (my_id_str);
-    GNUNET_free (succ_id_str);
-    GNUNET_STATISTICS_update (GDS_stats, "key", 1, 0);
-    GNUNET_free (key);
-  }
-#endif
-
 /**
  * Periodic task to verify current successor. There can be multiple trails to 
reach
  * to successor, choose the shortest one and send verify successor message
@@ -3119,10 +3106,27 @@
 
   /* Trail stored at this index. */
   GNUNET_assert (GNUNET_YES == trail->is_present);
-
+  
+  /* Code for testing ONLY: Store the successor for path tracking */
+  if (track_topology &&  (NULL != GDS_stats))
+  {
+    char *my_id_str;
+    char *succ_id_str;
+    char *key;
+    
+    my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity));
+    succ_id_str = GNUNET_strdup (GNUNET_i2s
+                                 (&successor->finger_identity));
+    GNUNET_asprintf (&key, "XDHT:%s:%s", my_id_str, succ_id_str);
+    GNUNET_free (my_id_str);
+    GNUNET_free (succ_id_str);
+    GNUNET_STATISTICS_update (GDS_stats, key, 1, 0);
+    GNUNET_free (key);
+  }
+  
   trail_id = trail->trail_id;
   trail_length = trail->trail_length;
-
+  
   if (trail_length > 0)
   {
      /* Copy the trail into peer list. */

Modified: gnunet/src/dht/gnunet_dht_profiler.c
===================================================================
--- gnunet/src/dht/gnunet_dht_profiler.c        2014-08-08 09:26:01 UTC (rev 
34125)
+++ gnunet/src/dht/gnunet_dht_profiler.c        2014-08-08 13:29:20 UTC (rev 
34126)
@@ -208,9 +208,14 @@
 /**
  * Testbed Operation (to get stats).
  */
-static struct GNUNET_TESTBED_Operation *stats_op;
+static struct GNUNET_TESTBED_Operation *bandwidth_stats_op;
 
 /**
+ * To get successor stats.
+ */
+static struct GNUNET_TESTBED_Operation *successor_stats_op;
+
+/**
  * Testbed peer handles.
  */
 static struct GNUNET_TESTBED_Peer **testbed_handles;
@@ -235,10 +240,32 @@
  */
 static unsigned int average_get_path_length;
 
+/**
+ * 
+ */
 static unsigned int total_put_path_length;
 
+/**
+ *
+ */
 static unsigned int total_get_path_length;
+
 /**
+ *
+ */
+static struct GNUNET_CONTAINER_MultiHashMap *successor_peer_hashmap;
+
+/**
+ *
+ */
+static struct GNUNET_HashCode *start_key;
+
+/**
+ *
+ */
+static int flag = 0;
+
+/**
  * Shutdown task.  Cleanup all resources and operations.
  *
  * @param cls NULL
@@ -273,9 +300,9 @@
     GNUNET_free (a_ctx);
     a_ctx = NULL;
   }
-  if(NULL != stats_op)
-    GNUNET_TESTBED_operation_done (stats_op);
-  stats_op = NULL;
+  if(NULL != bandwidth_stats_op)
+    GNUNET_TESTBED_operation_done (bandwidth_stats_op);
+  bandwidth_stats_op = NULL;
   GNUNET_free_non_null (a_ac);
 }
 
@@ -353,10 +380,10 @@
     return;
   }
   /* Collect Stats*/
-  stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
-                                            "dht", NULL,
-                                            bandwidth_stats_iterator, 
-                                            bandwidth_stats_cont, NULL);
+  bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, 
testbed_handles,
+                                                      "dht", NULL,
+                                                       
bandwidth_stats_iterator, 
+                                                       bandwidth_stats_cont, 
NULL);
 }
 
 
@@ -504,6 +531,107 @@
 
 
 /**
+ * Stats callback. Finish the stats testbed operation and when all stats have
+ * been iterated, shutdown the test.
+ *
+ * @param cls closure
+ * @param op the operation that has been finished
+ * @param emsg error message in case the operation has failed; will be NULL if
+ *          operation has executed successfully.
+ */
+static void
+successor_stats_cont (void *cls, 
+                      struct GNUNET_TESTBED_Operation *op, 
+                      const char *emsg)
+{
+  /* Check if ring is formed. If yes then schedule put. */
+  struct GNUNET_HashCode *val;
+  struct GNUNET_HashCode *start_val;
+  int count = 0;
+  struct GNUNET_HashCode *key;
+  
+  start_val = GNUNET_CONTAINER_multihashmap_get(successor_peer_hashmap,
+                                                start_key);
+  
+  val = GNUNET_new(struct GNUNET_HashCode);
+  val = start_val;
+  while (count < n_active)
+  {
+    key = val;
+    val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap,
+                                             key);
+    count++;
+  }
+  
+  if (start_val == val)
+  {
+    DEBUG("Circle complete\n");
+  }
+  else
+  {
+    DEBUG("Circle not complete\n");
+  }
+}
+
+
+/**
+ * Process successor statistic values.
+ *
+ * @param cls closure
+ * @param peer the peer the statistic belong to
+ * @param subsystem name of subsystem that created the statistic
+ * @param name the name of the datum
+ * @param value the current value
+ * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
+ */
+static int
+successor_stats_iterator (void *cls, 
+                          const struct GNUNET_TESTBED_Peer *peer,
+                          const char *subsystem, 
+                          const char *name,
+                          uint64_t value, 
+                          int is_persistent)
+{
+  static const char *key_string = "XDHT";
+  
+  DEBUG (" Inside successor stats,name = %s\n",name);
+  if (0 == strncmp (key_string, name, strlen (key_string)))
+  {
+    char *my_id_str;
+    char *successor_id_str;
+    struct GNUNET_HashCode *my_id;
+    struct GNUNET_HashCode *successor_id;
+    
+    /* Parse the string to get the peer and its successor. */
+    strtok((char *)name,":");
+    my_id_str = strtok(NULL,":");
+    successor_id_str = strtok(NULL,":");
+    
+    /* Get Hash of my_id_str and successor_id_str */
+    my_id = GNUNET_new(struct GNUNET_HashCode);
+    successor_id = GNUNET_new(struct GNUNET_HashCode);
+    GNUNET_CRYPTO_hash (my_id_str, sizeof(my_id_str),my_id);
+    GNUNET_CRYPTO_hash (successor_id_str, 
sizeof(successor_id_str),successor_id);
+    
+    if (0 == flag)
+    {
+      start_key = my_id;
+      flag = 1;
+    }
+    
+    GNUNET_CONTAINER_multihashmap_put (successor_peer_hashmap,
+                                       my_id, (void *)successor_id,
+                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
+   
+
+  }
+  
+  return GNUNET_OK;
+}
+
+
+/**
  * Task to do DHT PUTS
  *
  * @param cls the active context
@@ -513,7 +641,17 @@
 delayed_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct ActiveContext *ac = cls;
-
+  
+  successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (n_active, 
+                                                                 GNUNET_NO);
+  /* Check for successor pointer, don't start put till the virtual ring 
topology
+   is not created. */
+  successor_stats_op = 
+          GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
+                                         "dht", NULL,
+                                          successor_stats_iterator, 
+                                          successor_stats_cont, NULL);
+  
   ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
   /* Generate and DHT PUT some random data */
   ac->put_data_size = 16;       /* minimum */
@@ -537,6 +675,7 @@
 }
 
 
+
 /**
  * Connection to DHT has been established.  Call the delay task.
  *
@@ -566,6 +705,9 @@
     ctx->op = NULL;
     return;
   }
+  
+  DEBUG (" Call stats \n");
+ 
   ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_put, ac);
 }
 
@@ -677,6 +819,7 @@
     GNUNET_free (a_ctx);
     return;
   }
+  
   a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext));
   ac_cnt = 0;
   for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++)
@@ -766,7 +909,7 @@
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
-  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); /* 
default delay */
+  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1); /* 
default delay */
   timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1); /* 
default timeout */
   replication = 1;      /* default replication */
   rc = 0;




reply via email to

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