- changes
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 16 Apr 2012 15:37:46 +0000 (15:37 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 16 Apr 2012 15:37:46 +0000 (15:37 +0000)
src/ats/ats_api_scheduling.c
src/ats/gnunet-service-ats_addresses.c
src/ats/gnunet-service-ats_addresses_mlp.c
src/ats/perf_ats_mlp.c
src/ats/test_ats_api.conf

index 123398992bed2ac0d6a511ced7737d1d02624d6a..ec14e0e132f0aab534a22e2820658bc22eac54eb 100644 (file)
@@ -418,9 +418,13 @@ static void
 remove_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
                 const struct GNUNET_PeerIdentity *peer)
 {
+  GNUNET_assert (peer != NULL);
+  GNUNET_assert (sh != NULL);
+
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
-              "Remove sessionID %u from peer %s in %p\n", "ats-scheduling-api",
+              "Release sessionID %u from peer %s in %p\n",
               (unsigned int) session_id, GNUNET_i2s (peer), sh);
+
   if (0 == session_id)
     return;
   GNUNET_assert (session_id < sh->session_array_size);
index fec55b69d1ff36d5e7a2bf36fb53af4f2c901a47..6ed625bf427809704e5b36cde558150bc7d1b8c7 100644 (file)
@@ -615,7 +615,7 @@ void request_address_mlp (const struct GNUNET_PeerIdentity *peer)
 
   if (aa == NULL)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
                 "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
     return;
   }
@@ -648,7 +648,7 @@ void request_address_simple (const struct GNUNET_PeerIdentity *peer)
                                               &find_address_it, &aa);
   if (aa == NULL)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
                 "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
     return;
   }
index 175d4f41a79eacf49df43ecdf9d9716191753af1..57692440bd7dd07d7210d010be40bcf9f6316c4a 100644 (file)
@@ -869,8 +869,8 @@ lp_solv:
   mlp->lp_total_duration =+ duration.rel_value;
 
   GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO);
-  GNUNET_STATISTICS_set (mlp->stats,"# LP execution time", duration.rel_value, GNUNET_NO);
-  GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average",
+  GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO);
+  GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)",
                          mlp->lp_total_duration / mlp->lp_solved,  GNUNET_NO);
 
 
@@ -945,8 +945,8 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
   mlp->mlp_total_duration =+ duration.rel_value;
 
   GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO);
-  GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time", duration.rel_value, GNUNET_NO);
-  GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time average",
+  GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO);
+  GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time average (ms)",
                          mlp->mlp_total_duration / mlp->mlp_solved,  GNUNET_NO);
 
   /* Analyze problem status  */
@@ -1244,7 +1244,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
     }
     else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
     {
-      quota_out = 0;
+      quota_out = mlp->BIG_M;
     }
     else
     {
@@ -1262,7 +1262,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
     }
     else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
     {
-      quota_in = 0;
+      quota_in = mlp->BIG_M;
     }
     else
     {
@@ -1510,7 +1510,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
   int new;
   struct MLP_information *mlpi;
 
-  GNUNET_STATISTICS_update (mlp->stats,"# LP address updates", 1, GNUNET_NO);
+  GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO);
 
   /* We add a new address */
   if (address->mlp_information == NULL)
@@ -1536,6 +1536,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
 
     address->mlp_information = mlpi;
     mlp->addr_in_problem ++;
+    GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", 1, GNUNET_NO);
 
     /* Check for and add peer */
     struct ATS_Peer *peer = mlp_find_peer (mlp, &address->peer);
@@ -1562,6 +1563,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
       GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address);
       GNUNET_CONTAINER_DLL_insert (mlp->peer_head, mlp->peer_tail, peer);
       mlp->c_p ++;
+      GNUNET_STATISTICS_update (mlp->stats, "# peers in MLP", 1, GNUNET_NO);
     }
     else
     {
@@ -1617,6 +1619,7 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
     address->mlp_information = NULL;
 
     mlp->addr_in_problem --;
+    GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", -1, GNUNET_NO);
   }
 
   /* Remove from peer list */
@@ -1635,6 +1638,7 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
     GNUNET_CONTAINER_DLL_remove (mlp->peer_head, mlp->peer_tail, head);
     GNUNET_free (head);
     mlp->c_p --;
+    GNUNET_STATISTICS_update (mlp->stats, "# peers in MLP", -1, GNUNET_NO);
   }
 
   /* Update problem */
index a15e4b4b8c14061bd8a8a95aa4d883836605cdb7..2daac4769542cc238d3fc72eb2092575bea1aedf 100644 (file)
 #define MLP_MAX_EXEC_DURATION   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
 #define MLP_MAX_ITERATIONS      INT_MAX
 
+#define DEF_PEERS 10
+#define DEF_ADDRESSES_PER_PEER 5
+
+static unsigned int peers;
+static unsigned int addresses;
 
 static int ret;
 
 struct GNUNET_STATISTICS_Handle * stats;
 
-struct GNUNET_CONTAINER_MultiHashMap * addresses;
+//struct GNUNET_CONTAINER_MultiHashMap * addresses;
 
 struct GAS_MLP_Handle *mlp;
 
@@ -53,56 +58,26 @@ check (void *cls, char *const *args, const char *cfgfile,
   ret = 1;
   return;
 #endif
-  struct ATS_Address addr[10];
-
-  stats = GNUNET_STATISTICS_create("ats", cfg);
 
-  addresses = GNUNET_CONTAINER_multihashmap_create (10);
+  if (peers == 0)
+    peers = DEF_PEERS;
+  if (addresses == 0)
+    addresses = DEF_ADDRESSES_PER_PEER;
 
-  GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &addr[0].peer.hashPubKey);
-  addr[0].mlp_information = NULL;
-  addr[0].next = NULL;
-  addr[0].prev = NULL;
-  addr[0].plugin = strdup ("dummy");
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses);
 
-  addr[1].peer = addr[0].peer;
-  addr[1].mlp_information = NULL;
-  addr[1].next = NULL;
-  addr[1].prev = NULL;
-  addr[1].plugin = strdup ("dummy2");
-
-  GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+  GNUNET_HashCode hash;
+  //memset (&hash, '\0', sizeof (GNUNET_HashCode));
+  //hash.bits[0] = 1;
+  //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "peer %s\n", GNUNET_h2s_full (&hash));
 
   mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
+  mlp->auto_solve = GNUNET_NO;
 
-  /* Add a new address */
-#if 0
-  GAS_mlp_address_update (mlp, addresses, &addr[0]);
-
-  GNUNET_assert (mlp != NULL);
-  GNUNET_assert (mlp->addr_in_problem == 1);
 
-  /* Update an new address */
-  GAS_mlp_address_update (mlp, addresses, &addr[0]);
-  GNUNET_assert (mlp->addr_in_problem == 1);
 
-  /* Add a second address for same peer */
-  GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-  GAS_mlp_address_update (mlp, addresses, &addr[1]);
-  GNUNET_assert (mlp->addr_in_problem == 2);
-
-  /* Delete an address */
-  GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]);
-  GAS_mlp_address_delete (mlp, addresses, &addr[0]);
-  GAS_mlp_address_delete (mlp, addresses, &addr[1]);
-#endif
   GAS_mlp_done (mlp);
 
-  GNUNET_free (addr[0].plugin);
-  GNUNET_free (addr[1].plugin);
-  GNUNET_CONTAINER_multihashmap_destroy (addresses);
-  GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
-
   ret = 0;
   return;
 }
@@ -124,6 +99,12 @@ main (int argc, char *argv[])
   };
 
   static struct GNUNET_GETOPT_CommandLineOption options[] = {
+    {'a', "addresses", NULL,
+     gettext_noop ("addresses per peer"), 1,
+     &GNUNET_GETOPT_set_uint, &addresses},
+    {'p', "peers", NULL,
+     gettext_noop ("peers"), 1,
+     &GNUNET_GETOPT_set_uint, &peers},
     GNUNET_GETOPT_OPTION_END
   };
 
index 85aabf37e2c2cd6da721d87dee2781a87191c282..efd7fc9c61d4772d4c4e34eedc7a905398a393c5 100644 (file)
@@ -8,7 +8,7 @@ UNIXPATH = /tmp/test-ats-scheduling-arm.sock
 
 [ats]
 #DEBUG = YES
-PREFIX = valgrind --leak-check=full
+#PREFIX = valgrind --leak-check=full
 AUTOSTART = YES
 PORT = 12002
 HOSTNAME = localhost
@@ -22,7 +22,7 @@ UNIX_MATCH_UID = YES
 UNIX_MATCH_GID = YES
 
 # Enable MLP mode (default: NO)
-MLP = YES
+MLP = NO
 # Network specific inbound/outbound quotas
 # LOOPBACK
 LOOPBACK_QUOTA_IN = unlimited