gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20985 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r20985 - gnunet/src/ats
Date: Mon, 16 Apr 2012 15:15:35 +0200

Author: wachs
Date: 2012-04-16 15:15:35 +0200 (Mon, 16 Apr 2012)
New Revision: 20985

Modified:
   gnunet/src/ats/ats.conf.in
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
   gnunet/src/ats/test_ats_api.conf
Log:
- improved configuration and statistics handling


Modified: gnunet/src/ats/ats.conf.in
===================================================================
--- gnunet/src/ats/ats.conf.in  2012-04-16 11:37:53 UTC (rev 20984)
+++ gnunet/src/ats/ats.conf.in  2012-04-16 13:15:35 UTC (rev 20985)
@@ -10,10 +10,24 @@
 UNIXPATH = /tmp/gnunet-service-ats.sock
 UNIX_MATCH_UID = YES
 UNIX_MATCH_GID = YES
+
+# Enable MLP mode (default: NO)
 MLP = NO
-WAN_QUOTA_IN = 65536
-WAN_QUOTA_OUT = 65536
+# Network specific inbound/outbound quotas
+# LOOPBACK
+LOOPBACK_QUOTA_IN = unlimited
+LOOPBACK_QUOTA_OUT = unlimited
+# LAN
+LAN_QUOTA_IN = unlimited
+LAN_QUOTA_OUT = unlimited
+# WAN
+WAN_QUOTA_IN = 64 KiB
+WAN_QUOTA_OUT = 64 KiB
+# WLAN
+WLAN_QUOTA_IN = 1 MiB
+WLAN_QUOTA_OUT = 1 MiB
 # ATS options
+
 DUMP_MLP = NO
 DUMP_SOLUTION = NO
 DUMP_OVERWRITE = NO 

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2012-04-16 11:37:53 UTC 
(rev 20984)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2012-04-16 13:15:35 UTC 
(rev 20985)
@@ -713,41 +713,81 @@
 GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
                     const struct GNUNET_STATISTICS_Handle *stats)
 {
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
-                                                      "WAN_QUOTA_IN",
-                                                      &wan_quota_in));
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
-                                                      "WAN_QUOTA_OUT",
-                                                      &wan_quota_out));
+  int mode;
 
-  switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"))
+  char *quota_wan_in_str;
+  char *quota_wan_out_str;
+
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", 
"WAN_QUOTA_IN", &quota_wan_in_str))
   {
-       /* MLP = YES */
-       case GNUNET_YES:
+    if (0 == strcmp(quota_wan_in_str, "unlimited") ||
+        (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes 
(quota_wan_in_str, &wan_quota_in)))
+      wan_quota_in = (UINT32_MAX) /10;
+
+    GNUNET_free (quota_wan_in_str);
+    quota_wan_in_str = NULL;
+  }
+  else
+  {
+    wan_quota_in = (UINT32_MAX) /10;
+  }
+
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", 
"WAN_QUOTA_OUT", &quota_wan_out_str))
+  {
+    if (0 == strcmp(quota_wan_out_str, "unlimited") ||
+        (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes 
(quota_wan_out_str, &wan_quota_out)))
+      wan_quota_out = (UINT32_MAX) /10;
+
+    GNUNET_free (quota_wan_out_str);
+    quota_wan_out_str = NULL;
+  }
+  else
+  {
+    wan_quota_out = (UINT32_MAX) /10;
+  }
+
+
+  mode = GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP");
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode %u", mode);
+  switch (mode)
+  {
+    /* MLP = YES */
+    case GNUNET_YES:
 #if HAVE_LIBGLPK
-          ats_mode = MLP;
-          /* Init the MLP solver with default values */
-          mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, 
MLP_MAX_ITERATIONS);
-          break;
+      ats_mode = MLP;
+      /* Init the MLP solver with default values */
+      mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, 
MLP_MAX_ITERATIONS);
+      if (NULL == mlp)
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but 
libglpk is not installed, switching to simple mode\n");
+        GNUNET_STATISTICS_update (GSA_stats, "MLP mode enabled", 0, GNUNET_NO);
+        break;
+      }
+      else
+      {
+        GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 1, GNUNET_NO);
+        break;
+      }
 #else
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but 
libglpk is not installed, switching to simple mode");
-          ats_mode = SIMPLE;
-          break;
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but 
libglpk is not installed, switching to simple mode");
+      GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
+      ats_mode = SIMPLE;
+      break;
 #endif
-       /* MLP = NO */
-       case GNUNET_NO:
-               ats_mode = SIMPLE;
-               break;
-       /* No configuration value */
-       case GNUNET_SYSERR:
-               ats_mode = SIMPLE;
-               break;
-       default:
-               break;
+    /* MLP = NO */
+    case GNUNET_NO:
+      GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
+      ats_mode = SIMPLE;
+      break;
+    /* No configuration value */
+    case GNUNET_SYSERR:
+      GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
+      ats_mode = SIMPLE;
+      break;
+    default:
+      break;
   }
-
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started with %s mode\n", (SIMPLE 
== ats_mode) ? "SIMPLE" : "MLP");
   addresses = GNUNET_CONTAINER_multihashmap_create (128);
 }
 

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-04-16 11:37:53 UTC 
(rev 20984)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-04-16 13:15:35 UTC 
(rev 20985)
@@ -1110,6 +1110,8 @@
   unsigned int n_min;
   struct GNUNET_TIME_Relative i_exec;
   int c;
+  char * quota_out_str;
+  char * quota_in_str;
 
   /* Init GLPK environment */
   GNUNET_assert (glp_init_env() == 0);
@@ -1118,7 +1120,7 @@
   mlp->prob = glp_create_prob();
   GNUNET_assert (mlp->prob != NULL);
 
-  mlp->BIG_M = (double) (UINT32_MAX) /10;
+  mlp->BIG_M = (double) BIG_M_VALUE;
 
   /* Get diversity coefficient from configuration */
   if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
@@ -1231,37 +1233,57 @@
     if ((entry_in == NULL) || (entry_out == NULL))
       continue;
 
-    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 
entry_out, &quota_out))
+    if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", 
entry_out, &quota_out_str))
     {
+      if (0 == strcmp(quota_out_str, BIG_M_STRING) ||
+          (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, 
&quota_out)))
+        quota_out = mlp->BIG_M;
+
+      GNUNET_free (quota_out_str);
+      quota_out_str = NULL;
+    }
+    else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
+    {
+      quota_out = 0;
+    }
+    else
+    {
       quota_out = mlp->BIG_M;
     }
-    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 
entry_in, &quota_in))
+
+    if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", 
entry_in, &quota_in_str))
     {
+      if (0 == strcmp(quota_in_str, BIG_M_STRING) ||
+          (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, 
&quota_in)))
+        quota_in = mlp->BIG_M;
+
+      GNUNET_free (quota_in_str);
+      quota_in_str = NULL;
+    }
+    else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
+    {
+      quota_in = 0;
+    }
+    else
+    {
       quota_in = mlp->BIG_M;
     }
+
     /* Check if defined quota could make problem unsolvable */
-    if ((n_min * b_min) > quota_out)
+    if (((n_min * b_min) > quota_out) && (GNUNET_ATS_NET_UNSPECIFIED != 
quotas[c]))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration 
value `%s': " \
           "outbound quota (%u Bps) too small for combination of minimum 
connections and minimum bandwidth per peer (%u * %u Bps = %u)\n", entry_out, 
quota_out, n_min, b_min, n_min * b_min);
-      unsigned int default_min = ntohl 
(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
-      if ((quota_out / n_min) > default_min)
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,  "Reducing minimum bandwidth per 
peer to %u Bps\n",
-            (quota_out / n_min));
-        b_min = (quota_out / n_min);
-      }
-      else
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,  "Reducing minimum bandwidth per 
peer to %u Bps and minimum connections to %u \n",
-            default_min, (quota_out / default_min));
-        b_min = default_min;
-        n_min = (quota_out / default_min);
-      }
+
+      GAS_mlp_done(mlp);
+      mlp = NULL;
+      return NULL;
     }
 
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota 
%llu\n",
                 entry_out, quota_out, entry_in, quota_in);
+    GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, 
entry_out, quota_out, GNUNET_NO);
+    GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, 
entry_in, quota_in, GNUNET_NO);
     mlp->quota_out[c] = quota_out;
     mlp->quota_in[c] = quota_in;
   }

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-04-16 11:37:53 UTC 
(rev 20984)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-04-16 13:15:35 UTC 
(rev 20985)
@@ -36,6 +36,9 @@
 
 #define DEBUG_MLP GNUNET_EXTRA_LOGGING
 
+#define BIG_M_VALUE (UINT32_MAX) /10
+#define BIG_M_STRING "unlimited"
+
 #define MLP_AVERAGING_QUEUE_LENGTH 3
 
 #define MLP_MAX_EXEC_DURATION   
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)

Modified: gnunet/src/ats/test_ats_api.conf
===================================================================
--- gnunet/src/ats/test_ats_api.conf    2012-04-16 11:37:53 UTC (rev 20984)
+++ gnunet/src/ats/test_ats_api.conf    2012-04-16 13:15:35 UTC (rev 20985)
@@ -8,9 +8,7 @@
 
 [ats]
 #DEBUG = YES
-#PREFIX = valgrind --leak-check=full
-#WAN_QUOTA_OUT = 4294967295
-#WAN_QUOTA_IN = 4294967295
+PREFIX = valgrind --leak-check=full
 AUTOSTART = YES
 PORT = 12002
 HOSTNAME = localhost
@@ -21,4 +19,30 @@
 ACCEPT_FROM6 = ::1;
 UNIXPATH = /tmp/test-ats-scheduling-ats.sock
 UNIX_MATCH_UID = YES
-UNIX_MATCH_GID = YES
\ No newline at end of file
+UNIX_MATCH_GID = YES
+
+# Enable MLP mode (default: NO)
+MLP = YES
+# Network specific inbound/outbound quotas
+# LOOPBACK
+LOOPBACK_QUOTA_IN = unlimited
+LOOPBACK_QUOTA_OUT = unlimited
+# LAN
+LAN_QUOTA_IN = unlimited
+LAN_QUOTA_OUT = unlimited
+# WAN
+WAN_QUOTA_IN = 64 KiB
+WAN_QUOTA_OUT = 64 KiB
+# WLAN
+WLAN_QUOTA_IN = 1 MiB
+WLAN_QUOTA_OUT = 1 MiB
+
+# ATS extended options
+DUMP_MLP = NO
+DUMP_SOLUTION = NO
+DUMP_OVERWRITE = NO 
+DUMP_MIN_PEERS = 0
+DUMP_MIN_ADDRS = 0
+DUMP_OVERWRITE = NO
+ATS_MIN_INTERVAL = 15000
+ATS_EXEC_INTERVAL = 30000




reply via email to

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