gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r18220 - gnunet/src/dv


From: gnunet
Subject: [GNUnet-SVN] r18220 - gnunet/src/dv
Date: Sat, 19 Nov 2011 20:08:37 +0100

Author: nevans
Date: 2011-11-19 20:08:37 +0100 (Sat, 19 Nov 2011)
New Revision: 18220

Modified:
   gnunet/src/dv/plugin_transport_dv.c
   gnunet/src/dv/test_transport_api_dv.c
   gnunet/src/dv/test_transport_dv_data.conf
Log:
debugging dv/transport problems

Modified: gnunet/src/dv/plugin_transport_dv.c
===================================================================
--- gnunet/src/dv/plugin_transport_dv.c 2011-11-19 18:52:25 UTC (rev 18219)
+++ gnunet/src/dv/plugin_transport_dv.c 2011-11-19 19:08:37 UTC (rev 18220)
@@ -160,18 +160,21 @@
                    my_id, GNUNET_i2s (sender),
                    ntohs (((struct GNUNET_MessageHeader *) msg)->type),
                    distance);
+  if (sender_address_len == (2 * sizeof(struct GNUNET_PeerIdentity)))
+    {
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "plugin_transport_dv", "Parsed 
sender address: %s:%s\n", GNUNET_i2s((struct GNUNET_PeerIdentity 
*)sender_address), GNUNET_h2s(&((struct GNUNET_PeerIdentity 
*)&sender_address[sizeof(struct GNUNET_PeerIdentity)])->hashPubKey));
+    }
+
   GNUNET_free_non_null (my_id);
 #endif
-  struct GNUNET_ATS_Information ats[2];
+  struct GNUNET_ATS_Information ats[1];
 
   ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
   ats[0].value = htonl (distance);
-  ats[1].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
-  ats[1].value = htonl (0);
 
   plugin->env->receive (plugin->env->cls, sender,
                         (struct GNUNET_MessageHeader *) msg,
-                        (const struct GNUNET_ATS_Information *) &ats, 2, NULL,
+                        (const struct GNUNET_ATS_Information *) &ats, 1, NULL,
                         sender_address, sender_address_len);
 
 }
@@ -367,6 +370,7 @@
     }
     return GNUNET_SYSERR;
   }
+
   return GNUNET_OK;
 }
 

Modified: gnunet/src/dv/test_transport_api_dv.c
===================================================================
--- gnunet/src/dv/test_transport_api_dv.c       2011-11-19 18:52:25 UTC (rev 
18219)
+++ gnunet/src/dv/test_transport_api_dv.c       2011-11-19 19:08:37 UTC (rev 
18220)
@@ -25,7 +25,7 @@
 #include "gnunet_testing_lib.h"
 #include "gnunet_core_service.h"
 
-#define VERBOSE GNUNET_EXTRA_LOGGING
+#define VERBOSE 1
 
 #define TEST_ALL GNUNET_NO
 
@@ -394,24 +394,28 @@
  * @return connected transport distance
  */
 static uint32_t
-get_atsi_distance (const struct GNUNET_ATS_Information *atsi)
+get_atsi_distance (const struct GNUNET_ATS_Information *atsi, unsigned int 
atsi_count)
 {
-  while ((ntohl (atsi->type) != GNUNET_ATS_ARRAY_TERMINATOR) &&
-         (ntohl (atsi->type) != GNUNET_ATS_QUALITY_NET_DISTANCE))
-    atsi++;
-  if (ntohl (atsi->type) == GNUNET_ATS_ARRAY_TERMINATOR)
-  {
-    GNUNET_break (0);
-    /* FIXME: we do not have distance data? Assume direct neighbor. */
-    return 1;
-  }
-  return ntohl (atsi->value);
+  unsigned int i;
+
+  for (i = 0; i < atsi_count; i++)
+    {
+      if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
+        return ntohl (atsi->value);
+    }
+
+  GNUNET_break (0);
+  /* FIXME: we do not have distance data? Assume direct neighbor. */
+  return 1;
 }
 
+
 static int
-process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
+process_mtype (void *cls,
+               const struct GNUNET_PeerIdentity *peer,
                const struct GNUNET_MessageHeader *message,
-               const struct GNUNET_ATS_Information *atsi)
+               const struct GNUNET_ATS_Information *atsi,
+               unsigned int atsi_count)
 {
   struct TestMessageContext *pos = cls;
   struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message;
@@ -423,7 +427,7 @@
     return GNUNET_OK;
 
 #if VERBOSE
-  distance = get_atsi_distance (atsi);
+  distance = get_atsi_distance (atsi, atsi_count);
 #endif
   GNUNET_assert (0 ==
                  memcmp (peer, &pos->peer1->id,
@@ -450,7 +454,7 @@
                 GNUNET_i2s (peer), ntohs (message->type), ntohl (msg->uid),
                 distance);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Total messages received %d, expected %d.\n",
+                "Total OTHER messages received %d, expected %d.\n",
                 total_other_messages, total_other_expected_messages);
 #endif
   }
@@ -459,18 +463,12 @@
       (total_other_messages == 0))
   {
     GNUNET_SCHEDULER_cancel (die_task);
+#if VERBOSE
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling timeout from DV 
connections.\n");
+#endif
     die_task =
         GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
                                       "waiting for DV peers to connect!");
-    /*
-     * if ((num_peers == 3) && (total_other_expected_messages == 2))
-     * {
-     * GNUNET_SCHEDULER_add_now (&send_other_messages, NULL);
-     * }
-     * else
-     * {
-     * GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
-     * } */
   }
   else if ((total_other_expected_messages > 0) &&
            (total_other_messages == total_other_expected_messages))
@@ -524,10 +522,12 @@
  * @param cls closure
  * @param peer peer identity this notification is about
  * @param atsi performance data for the connection
+ * @param atsi_count number of ATS information included
  */
 static void
 connect_notify_peer2 (void *cls, const struct GNUNET_PeerIdentity *peer,
-                      const struct GNUNET_ATS_Information *atsi)
+                      const struct GNUNET_ATS_Information *atsi,
+                      unsigned int atsi_count)
 {
   struct TestMessageContext *pos = cls;
 
@@ -577,10 +577,12 @@
  * @param cls closure
  * @param peer peer identity this notification is about
  * @param atsi performance data for the connection
+ * @param atsi_count number of atsi datums
  */
 static void
 connect_notify_peer1 (void *cls, const struct GNUNET_PeerIdentity *peer,
-                      const struct GNUNET_ATS_Information *atsi)
+                      const struct GNUNET_ATS_Information *atsi,
+                      unsigned int atsi_count)
 {
   struct TestMessageContext *pos = cls;
 
@@ -835,12 +837,14 @@
  *
  * @param cls closure
  * @param peer peer identity this notification is about
- * @param latency reported latency of the connection with 'other'
- * @param distance reported distance (DV) to 'other'
+ * @param atsi performance data about this peer's connection
+ * @param atsi_count number of atsi datums
+ *
  */
 static void
 all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
-                     const struct GNUNET_ATS_Information *atsi)
+                     const struct GNUNET_ATS_Information *atsi,
+                     unsigned int atsi_count)
 {
   struct GNUNET_TESTING_Daemon *d = cls;
   struct GNUNET_TESTING_Daemon *second_daemon;
@@ -854,7 +858,7 @@
   if (0 == memcmp (&d->id, peer, sizeof (struct GNUNET_PeerIdentity)))
     return;
   second_shortname = GNUNET_strdup (GNUNET_i2s (peer));
-  distance = get_atsi_distance (atsi);
+  distance = get_atsi_distance (atsi, atsi_count);
 
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,

Modified: gnunet/src/dv/test_transport_dv_data.conf
===================================================================
--- gnunet/src/dv/test_transport_dv_data.conf   2011-11-19 18:52:25 UTC (rev 
18219)
+++ gnunet/src/dv/test_transport_dv_data.conf   2011-11-19 19:08:37 UTC (rev 
18220)
@@ -6,7 +6,7 @@
 PORT = 2564
 
 [transport]
-DEBUG = NO
+DEBUG = YES
 PORT = 2565
 PLUGINS = tcp dv
 BLACKLIST_FILE = $SERVICEHOME/blacklist
@@ -45,7 +45,7 @@
 PORT = 2571
 
 [testing]
-NUM_PEERS = 5
+NUM_PEERS = 3
 ADDITIONAL_MESSAGES = 10
 DEBUG = NO
 WEAKRANDOM = YES




reply via email to

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