gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11567 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r11567 - gnunet/src/transport
Date: Mon, 31 May 2010 13:25:31 +0200

Author: grothoff
Date: 2010-05-31 13:25:31 +0200 (Mon, 31 May 2010)
New Revision: 11567

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/test_transport_api_reliability.c
   gnunet/src/transport/test_transport_api_tcp_peer1.conf
   gnunet/src/transport/test_transport_api_tcp_peer2.conf
   gnunet/src/transport/transport.h
   gnunet/src/transport/transport_api.c
Log:
fixes

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-05-31 11:07:48 UTC 
(rev 11566)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-05-31 11:25:31 UTC 
(rev 11567)
@@ -58,9 +58,12 @@
  * messages, so the number should be chosen rather generously.
  *
  * The expectation here is that most of the time the queue is large
- * enough so that a drop is virtually never required.
+ * enough so that a drop is virtually never required.  Note that
+ * this value must be about as large as 'TOTAL_MSGS' in the
+ * 'test_transport_api_reliability.c', otherwise that testcase may
+ * fail.
  */
-#define MAX_PENDING 128
+#define MAX_PENDING (128 * 1024)
 
 /**
  * Size of the per-transport blacklist hash maps.
@@ -1225,6 +1228,32 @@
 
 
 /**
+ * Convert an address to a string.
+ *
+ * @param plugin name of the plugin responsible for the address
+ * @param addr binary address
+ * @param addr_len number of bytes in addr
+ * @return NULL on error, otherwise address string
+ */
+static const char*
+a2s (const char *plugin,
+     const void *addr,
+     uint16_t addr_len)
+{
+  struct TransportPlugin *p;
+
+  if (plugin == NULL)
+    return NULL;
+  p = find_transport (plugin);
+  if (p == NULL)
+    return NULL;
+  return p->api->address_to_string (p->api->cls,
+                                   addr,
+                                   addr_len);
+}   
+
+
+/**
  * Mark the given FAL entry as 'connected' (and hence preferred for
  * sending); also mark all others for the same peer as 'not connected'
  * (since only one can be preferred).
@@ -1246,9 +1275,20 @@
     {
       if (GNUNET_YES == pos->connected)
        {
+#if DEBUG_TRANSPORT
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "Marking address `%s' as no longer connected (due to 
connect on other address)\n",
+                     a2s (pos->ready_list->plugin->short_name,
+                          pos->addr,
+                          pos->addrlen));
+#endif
          GNUNET_break (cnt == GNUNET_YES);
          cnt = GNUNET_NO;
          pos->connected = GNUNET_NO;
+         GNUNET_STATISTICS_update (stats,
+                                   gettext_noop ("# connected addresses"),
+                                   -1,
+                                   GNUNET_NO);
        }
       pos = pos->next;
     }
@@ -1284,9 +1324,15 @@
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   _
-                  ("Dropping message, have %u messages pending (%u is the soft 
limit)\n"),
-                  client->message_count, MAX_PENDING);
-      /* TODO: call to statistics... */
+                  ("Dropping message of type %u and size %u, have %u messages 
pending (%u is the soft limit)\n"),
+                 ntohs (msg->type),
+                 ntohs (msg->size),
+                  client->message_count, 
+                 MAX_PENDING);
+      GNUNET_STATISTICS_update (stats,
+                               gettext_noop ("# messages dropped due to slow 
client"),
+                               1,
+                               GNUNET_NO);
       return;
     }
   msize = ntohs (msg->size);
@@ -1390,6 +1436,13 @@
        {
          if (mq->specific_address->connected != GNUNET_NO)
            {
+#if DEBUG_TRANSPORT
+             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                         "Marking address `%s' as no longer connected (due to 
transmission problem)\n",
+                         a2s 
(mq->specific_address->ready_list->plugin->short_name,
+                              mq->specific_address->addr,
+                              mq->specific_address->addrlen));
+#endif
              GNUNET_STATISTICS_update (stats,
                                        gettext_noop ("# connected addresses"),
                                        -1,
@@ -1408,32 +1461,6 @@
 
 
 /**
- * Convert an address to a string.
- *
- * @param plugin name of the plugin responsible for the address
- * @param addr binary address
- * @param addr_len number of bytes in addr
- * @return NULL on error, otherwise address string
- */
-static const char*
-a2s (const char *plugin,
-     const void *addr,
-     uint16_t addr_len)
-{
-  struct TransportPlugin *p;
-
-  if (plugin == NULL)
-    return NULL;
-  p = find_transport (plugin);
-  if (p == NULL)
-    return NULL;
-  return p->api->address_to_string (p->api->cls,
-                                   addr,
-                                   addr_len);
-}   
-
-
-/**
  * Find an address in any of the available transports for
  * the given neighbour that would be good for message
  * transmission.  This is essentially the transport selection
@@ -1508,7 +1535,10 @@
     {
 #if DEBUG_TRANSPORT
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Best address found has latency of %llu ms.\n",
+                  "Best address found (`%s') has latency of %llu ms.\n",
+                 a2s (best_address->ready_list->plugin->short_name,
+                      best_address->addr,
+                      best_address->addrlen),
                   best_address->latency.value);
 #endif
     }
@@ -3228,8 +3258,9 @@
     }
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Received message of type %u from `%4s', sending to all 
clients.\n",
+             "Received message of type %u and size %u from `%4s', sending to 
all clients.\n",
              ntohs (message->type), 
+             ntohs (message->size), 
              GNUNET_i2s (&n->id));
 #endif
   if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
@@ -3718,7 +3749,7 @@
                                             NULL);
          GNUNET_PEERINFO_add_peer (peerinfo, plain_hello);
          GNUNET_free (plain_hello);
-#if DEBUG_TRANSPORT || 1
+#if DEBUG_TRANSPORT
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                      "PEERINFO had no `%s' message for peer `%4s', full 
validation needed.\n",
                      "HELLO",
@@ -4248,8 +4279,10 @@
        }
 #if DEBUG_PING_PONG
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      "Received message of type %u from `%4s', sending to all 
clients.\n",
-                      ntohs (message->type), GNUNET_i2s (peer));
+                      "Received message of type %u and size %u from `%4s', 
sending to all clients.\n",
+                      ntohs (message->type), 
+                      ntohs (message->size), 
+                     GNUNET_i2s (peer));
 #endif
       switch (ntohs (message->type))
        {

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-05-31 11:07:48 UTC (rev 
11566)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-05-31 11:25:31 UTC (rev 
11567)
@@ -37,7 +37,7 @@
 #include "plugin_transport.h"
 #include "transport.h"
 
-#define DEBUG_TCP GNUNET_YES
+#define DEBUG_TCP GNUNET_NO
 
 /**
  * How long until we give up on transmitting the welcome message?

Modified: gnunet/src/transport/test_transport_api_reliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_reliability.c       2010-05-31 
11:07:48 UTC (rev 11566)
+++ gnunet/src/transport/test_transport_api_reliability.c       2010-05-31 
11:25:31 UTC (rev 11567)
@@ -35,12 +35,17 @@
 #include "gnunet_transport_service.h"
 #include "transport.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define VERBOSE_ARM GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
+/**
+ * Note that this value must not significantly exceed
+ * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise
+ * messages may be dropped even for a reliable transport.
+ */
 #define TOTAL_MSGS (60000 * 2)
 
 /**
@@ -72,6 +77,10 @@
 
 static int is_http;
 
+static unsigned long long total_bytes;
+
+static struct GNUNET_TIME_Absolute start_time;
+
 static GNUNET_SCHEDULER_TaskIdentifier die_task;
 
 #if VERBOSE
@@ -84,15 +93,23 @@
 static void
 end ()
 {
-  GNUNET_assert (ok == 6);
+  unsigned long long delta;
+
   GNUNET_SCHEDULER_cancel (sched, die_task);
+  die_task = GNUNET_SCHEDULER_NO_TASK;
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
+#endif
   GNUNET_TRANSPORT_disconnect (p1.th);
   GNUNET_TRANSPORT_disconnect (p2.th);
-
-  die_task = GNUNET_SCHEDULER_NO_TASK;
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
              "Transports disconnected, returning success!\n");
+#endif
+  delta = GNUNET_TIME_absolute_get_duration (start_time).value;
+  fprintf (stderr,
+          "\nThroughput was %llu kb/s\n",
+          total_bytes * 1000 / 1024 / delta);
   ok = 0;
 }
 
@@ -175,11 +192,15 @@
       die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
       return;
     }
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Got message %u of size %u\n",
              ntohl (hdr->num),
              ntohs (message->size));         
+#endif
   n++;
+  if (0 == (n % (TOTAL_MSGS/100)))
+    fprintf (stderr, ".");
   if (n == TOTAL_MSGS)
     end ();
 }
@@ -214,10 +235,12 @@
       ret += sizeof (struct TestMessage);
       memset (&cbuf[ret], n, s - sizeof (struct TestMessage));
       ret += s - sizeof (struct TestMessage);
+#if VERBOSE
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Sending message %u of size %u\n",
                  n,
                  s);
+#endif
       n++;
       s = get_size (n);
       if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
@@ -233,6 +256,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Returning total message block of size %u\n",
              ret);
+  total_bytes += ret;
   return ret;
 }
 
@@ -251,6 +275,7 @@
                                  GNUNET_BANDWIDTH_value_init (1024 * 1024 * 
1024),
                                  GNUNET_TIME_UNIT_FOREVER_REL,
                                  NULL, NULL);
+      start_time = GNUNET_TIME_absolute_get ();
       GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
                                              &p2.id,
                                              get_size (0), 0, TIMEOUT, 
@@ -266,17 +291,21 @@
                                  GNUNET_TIME_UNIT_FOREVER_REL,
                                  NULL, NULL);
     }
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
+#endif
 }
 
 
 static void
 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Peer `%4s' disconnected (%p)!\n",
              GNUNET_i2s (peer), cls);
+#endif
 }
 
 
@@ -310,8 +339,10 @@
   struct PeerContext *me = cls;
 
   GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Exchanging HELLO with peer (%p)!\n", cls);
+#endif
   GNUNET_assert (ok >= 3);
   OKPP;
   GNUNET_assert (message != NULL);
@@ -331,8 +362,10 @@
   struct PeerContext *me = cls;
 
   GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Exchanging HELLO with peer (%p)!\n", cls);
+#endif
   GNUNET_assert (ok >= 2);
   OKPP;
   GNUNET_assert (message != NULL);
@@ -340,9 +373,11 @@
                  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
                                       message, &me->id));
 
+#if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received HELLO size %d\n", GNUNET_HELLO_size((const struct 
GNUNET_HELLO_Message *)message));
-
+              "Received HELLO size %d\n", 
+             GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
+#endif
   GNUNET_TRANSPORT_offer_hello (p2.th, message);
   GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
 }
@@ -399,7 +434,7 @@
 #endif
   ok = 1;
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
-                      argv, "test-transport-api", "nohelp",
+                      argv, "test-transport-api-reliability", "nohelp",
                       options, &run, &ok);
   stop_arm (&p1);
   stop_arm (&p2);

Modified: gnunet/src/transport/test_transport_api_tcp_peer1.conf
===================================================================
--- gnunet/src/transport/test_transport_api_tcp_peer1.conf      2010-05-31 
11:07:48 UTC (rev 11566)
+++ gnunet/src/transport/test_transport_api_tcp_peer1.conf      2010-05-31 
11:25:31 UTC (rev 11567)
@@ -1,5 +1,6 @@
 [transport-tcp]
 PORT = 12368
+BINDTO = 127.0.0.1
 
 [fs]
 AUTOSTART = NO
@@ -31,7 +32,7 @@
 
 [transport]
 PLUGINS = tcp
-#DEBUG = YES
+DEBUG = NO
 #PREFIX = xterm -T transport2 -e gdb --command=cmd --args
 #PREFIX = valgrind --leak-check=full
 ACCEPT_FROM6 = ::1;
@@ -73,7 +74,7 @@
 PORT = 12367
 
 [arm]
-DEFAULTSERVICES = 
+DEFAULTSERVICES = transport statistics
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
 BINARY = gnunet-service-arm

Modified: gnunet/src/transport/test_transport_api_tcp_peer2.conf
===================================================================
--- gnunet/src/transport/test_transport_api_tcp_peer2.conf      2010-05-31 
11:07:48 UTC (rev 11566)
+++ gnunet/src/transport/test_transport_api_tcp_peer2.conf      2010-05-31 
11:25:31 UTC (rev 11567)
@@ -1,5 +1,6 @@
 [transport-tcp]
 PORT = 22368
+BINDTO = 127.0.0.1
 
 [core]
 AUTOSTART = NO
@@ -31,7 +32,7 @@
 
 [transport]
 PLUGINS = tcp
-#DEBUG = YES
+DEBUG = NO
 # PREFIX = 
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
@@ -74,7 +75,7 @@
 PORT = 22367
 
 [arm]
-DEFAULTSERVICES = 
+DEFAULTSERVICES = transport statistics
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
 BINARY = gnunet-service-arm

Modified: gnunet/src/transport/transport.h
===================================================================
--- gnunet/src/transport/transport.h    2010-05-31 11:07:48 UTC (rev 11566)
+++ gnunet/src/transport/transport.h    2010-05-31 11:25:31 UTC (rev 11567)
@@ -30,9 +30,9 @@
 #include "gnunet_time_lib.h"
 #include "gnunet_transport_service.h"
 
-#define DEBUG_TRANSPORT GNUNET_YES
-#define DEBUG_TRANSPORT_TIMEOUT GNUNET_YES
-#define DEBUG_TRANSPORT_DISCONNECT GNUNET_YES
+#define DEBUG_TRANSPORT GNUNET_NO
+#define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO
+#define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO
 
 /**
  * For how long do we allow unused bandwidth

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2010-05-31 11:07:48 UTC (rev 
11566)
+++ gnunet/src/transport/transport_api.c        2010-05-31 11:25:31 UTC (rev 
11567)
@@ -548,10 +548,12 @@
                                   h->control_tail,
                                   cm);      
       nret = cm->notify (cm->notify_cls, size, &cbuf[ret]);
+#if DEBUG_TRANSPORT
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Added %u bytes of control message at %u\n",
                  nret,
                  ret);
+#endif
       GNUNET_free (cm);
       ret += nret;
       size -= nret;




reply via email to

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