gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10818 - in gnunet/src: fs transport util


From: gnunet
Subject: [GNUnet-SVN] r10818 - in gnunet/src: fs transport util
Date: Tue, 6 Apr 2010 13:09:44 +0200

Author: grothoff
Date: 2010-04-06 13:09:44 +0200 (Tue, 06 Apr 2010)
New Revision: 10818

Modified:
   gnunet/src/fs/fs_test_lib_data.conf
   gnunet/src/fs/test_fs_data.conf
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/util/bandwidth.c
Log:
bwtracking

Modified: gnunet/src/fs/fs_test_lib_data.conf
===================================================================
--- gnunet/src/fs/fs_test_lib_data.conf 2010-04-06 10:53:25 UTC (rev 10817)
+++ gnunet/src/fs/fs_test_lib_data.conf 2010-04-06 11:09:44 UTC (rev 10818)
@@ -12,7 +12,7 @@
 [transport]
 PORT = 43465
 PLUGINS = tcp
-#DEBUG = YES
+DEBUG = YES
 
 [arm]
 PORT = 43466
@@ -32,6 +32,7 @@
 ALLOW_SHUTDOWN = NO
 TIMEOUT = 300000
 #PORT = 43468
+DEBUG = YES
 
 [peerinfo]
 PORT = 43469

Modified: gnunet/src/fs/test_fs_data.conf
===================================================================
--- gnunet/src/fs/test_fs_data.conf     2010-04-06 10:53:25 UTC (rev 10817)
+++ gnunet/src/fs/test_fs_data.conf     2010-04-06 11:09:44 UTC (rev 10818)
@@ -12,6 +12,7 @@
 [transport]
 PORT = 42465
 PLUGINS = 
+DEBUG = YES
 
 [arm]
 PORT = 42466

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-04-06 10:53:25 UTC 
(rev 10817)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-04-06 11:09:44 UTC 
(rev 10818)
@@ -1161,6 +1161,7 @@
       addresses = head->addresses;
       while (addresses != NULL)
         {
+#if DEBUG_TRANSPORT > 1
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                      "Have address `%s' for peer `%4s' (status: %d, %d, %d, 
%u, %llums, %u)\n",
                      GNUNET_a2s (addresses->addr,
@@ -1172,6 +1173,7 @@
                      addresses->connect_attempts,
                      (unsigned long long) addresses->timeout.value,
                      (unsigned int) addresses->distance);
+#endif
           if ( ( (best_address == NULL) || 
                 (addresses->connected == GNUNET_YES) ||
                 (best_address->connected == GNUNET_NO) ) &&
@@ -1237,9 +1239,11 @@
 
   if (neighbour->messages_head == NULL)
     {
+#if DEBUG_TRANSPORT
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Transmission queue for `%4s' is empty\n",
                  GNUNET_i2s (&neighbour->id));
+#endif
       return;                     /* nothing to do */
     }
   rl = NULL;
@@ -3174,6 +3178,12 @@
                                                              (ssize_t) msize))
            {
              n->quota_violation_count++;
+             GNUNET_log (GNUNET_ERROR_TYPE_WARNING |
+                         GNUNET_ERROR_TYPE_BULK,
+                         _
+                         ("Bandwidth quota (%u b/s) violation detected (total 
of %u).\n"), 
+                         n->in_tracker.available_bytes_per_s__,
+                         n->quota_violation_count);
              if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD)
                {
                  /* since we'll be dropping, only count this message for half 
so that

Modified: gnunet/src/util/bandwidth.c
===================================================================
--- gnunet/src/util/bandwidth.c 2010-04-06 10:53:25 UTC (rev 10817)
+++ gnunet/src/util/bandwidth.c 2010-04-06 11:09:44 UTC (rev 10818)
@@ -27,6 +27,8 @@
 #include "gnunet_bandwidth_lib.h"
 #include "gnunet_server_lib.h"
 
+#define DEBUG_BANDWIDTH GNUNET_YES
+
 /**
  * Create a new bandwidth value.
  *
@@ -38,6 +40,11 @@
 {
   struct GNUNET_BANDWIDTH_Value32NBO ret;
 
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Initializing bandwidth of %u bps\n",
+             (unsigned int) bytes_per_second);
+#endif
   ret.value__ = htonl (bytes_per_second);
   return ret;
 }
@@ -74,6 +81,12 @@
   uint64_t b;
 
   b = ntohl (bps.value__);
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Bandwidth has %llu bytes available until deadline in %llums\n",
+             (unsigned long long) (b * deadline.value / 1000LL),
+             deadline.value);
+#endif
   return b * deadline.value / 1000LL;
 }
 
@@ -95,8 +108,20 @@
 
   b = ntohl (bps.value__);
   if (b == 0)
-    return GNUNET_TIME_UNIT_FOREVER_REL;
+    {
+#if DEBUG_BANDWIDTH
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Bandwidth suggests delay of infinity (zero bandwidth)\n");
+#endif
+      return GNUNET_TIME_UNIT_FOREVER_REL;
+    }
   ret.value = size * 1000LL / b;
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n",
+             (unsigned long long) ret.value,
+             (unsigned long long) size);
+#endif
   return ret;
 }
 
@@ -124,6 +149,13 @@
   av->last_update__ = GNUNET_TIME_absolute_get ();
   av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__);
   av->max_carry_s__ = max_carry_s;
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Tracker %p initialized with %u bps and max carry %u\n",
+             av,
+             (unsigned int) av->available_bytes_per_s__,
+             (unsigned int) max_carry_s);
+#endif
 }
 
 
@@ -178,6 +210,13 @@
       av->consumption_since_last_update__ = 0;
       av->last_update__.value = now.value - left_time_ms;
     }
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Tracker %p  updated, have %u bps last update was %llu ms ago\n",
+             av,
+             (unsigned int) av->available_bytes_per_s__,
+             (unsigned long long) (now.value - av->last_update__.value));
+#endif
 }
 
 
@@ -198,6 +237,12 @@
 {
   uint64_t nc;
 
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Tracker %p consumes %d bytes\n",
+             av,
+             (int) size);
+#endif
   if (size > 0)
     {
       nc = av->consumption_since_last_update__ + size;
@@ -209,7 +254,14 @@
       av->consumption_since_last_update__ = nc;
       update_tracker (av);
       if (av->consumption_since_last_update__ > 0)
-       return GNUNET_YES;
+       {
+#if DEBUG_BANDWIDTH
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "Tracker %p consumption is above limit\n",
+                     av);
+#endif
+         return GNUNET_YES;
+       }
     }
   else
     {
@@ -240,15 +292,37 @@
   uint64_t bytes_needed;
 
   if (av->available_bytes_per_s__ == 0)
-    return GNUNET_TIME_UNIT_FOREVER_REL;
+    {
+#if DEBUG_BANDWIDTH
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Tracker %p delay is infinity\n",
+                 av);
+#endif
+      return GNUNET_TIME_UNIT_FOREVER_REL;
+    }
   update_tracker (av);
   now = GNUNET_TIME_absolute_get ();
   delta_time = now.value - av->last_update__.value;
   delta_avail = (delta_time * ((unsigned long long) 
av->available_bytes_per_s__)) / 1000LL;
   if (delta_avail >= size)
-    return GNUNET_TIME_UNIT_ZERO;
+    {
+#if DEBUG_BANDWIDTH
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Tracker %p delay for %u bytes is zero\n",
+                 av,
+                 (unsigned int) size);
+#endif
+      return GNUNET_TIME_UNIT_ZERO;
+    }
   bytes_needed = size - delta_avail;
   ret.value = 1000LL * bytes_needed / (unsigned long long) 
av->available_bytes_per_s__;
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Tracker %p delay for %u bytes is %llu ms\n",
+             av,
+             (unsigned int) size,
+             (unsigned long long) ret.value);
+#endif
   return ret;
 }
 
@@ -272,6 +346,12 @@
   avail = GNUNET_BANDWIDTH_value_get_available_until (bps,
                                                      
GNUNET_TIME_absolute_get_duration (av->last_update__));
   used = av->consumption_since_last_update__;
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Tracker %p  available bandwith is %lld ms\n",
+             av,             
+             (long long) (int64_t) (avail - used));
+#endif
   return (int64_t) (avail - used);
 }
 
@@ -290,6 +370,12 @@
   uint32_t new_limit;
 
   new_limit = ntohl (bytes_per_second_limit.value__);
+#if DEBUG_BANDWIDTH
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Tracker %p bandwith changed to %u bps\n",
+             av,             
+             (unsigned int) new_limit);
+#endif
   update_tracker (av);
   old_limit = av->available_bytes_per_s__;
   av->available_bytes_per_s__ = new_limit;





reply via email to

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