- improved configuration and statistics handling
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 16 Apr 2012 13:15:35 +0000 (13:15 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 16 Apr 2012 13:15:35 +0000 (13:15 +0000)
src/ats/ats.conf.in
src/ats/gnunet-service-ats_addresses.c
src/ats/gnunet-service-ats_addresses_mlp.c
src/ats/gnunet-service-ats_addresses_mlp.h
src/ats/test_ats_api.conf

index 6ea0d417f5b363659e60af7127e81850608e9cf6..f81016e2b908187b3a46d248666c32880e8c0a03 100644 (file)
@@ -10,10 +10,24 @@ ACCEPT_FROM6 = ::1;
 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 
index c5923a0997d8087b05d045cb784f84a974b85cad..fec55b69d1ff36d5e7a2bf36fb53af4f2c901a47 100644 (file)
@@ -713,41 +713,81 @@ void
 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));
-
-  switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"))
+  int mode;
+
+  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))
+  {
+    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))
   {
-       /* MLP = YES */
-       case GNUNET_YES:
+    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);
 }
 
index 61aa73397b3b140b7617a564db2b098873eef31b..175d4f41a79eacf49df43ecdf9d9716191753af1 100644 (file)
@@ -1110,6 +1110,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
   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 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
   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 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
     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;
   }
index 8f60a8598954d9968ec34ad77acc4af11df187b5..e8db35c27ed4a057160f90fc2d30d90905fbbba8 100644 (file)
@@ -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)
index fa379c92e1a984b440d2e788ce90c94f9d136664..85aabf37e2c2cd6da721d87dee2781a87191c282 100644 (file)
@@ -8,9 +8,7 @@ UNIXPATH = /tmp/test-ats-scheduling-arm.sock
 
 [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_FROM = 127.0.0.1;
 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