[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19835 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19835 - gnunet/src/ats |
Date: |
Fri, 17 Feb 2012 16:32:23 +0100 |
Author: wachs
Date: 2012-02-17 16:32:23 +0100 (Fri, 17 Feb 2012)
New Revision: 19835
Modified:
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_mlp.c
Log:
- changes to ats
Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c 2012-02-17 13:49:24 UTC
(rev 19834)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2012-02-17 15:32:23 UTC
(rev 19835)
@@ -77,17 +77,19 @@
* @return GNUNET_OK (continue to iterate)
*/
static int
-update_bw_it (void *cls, const GNUNET_HashCode * key, void *value)
+update_bw_simple_it (void *cls, const GNUNET_HashCode * key, void *value)
{
struct ATS_Address *aa = value;
-
- /* Simple method */
if (GNUNET_YES != aa->active)
return GNUNET_OK;
GNUNET_assert (active_addr_count > 0);
+
+
+ /* Simple method */
aa->assigned_bw_in.value__ = htonl (wan_quota_in / active_addr_count);
aa->assigned_bw_out.value__ = htonl (wan_quota_out / active_addr_count);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New bandwidth for peer %s is %u/%u\n",
GNUNET_i2s (&aa->peer), ntohl (aa->assigned_bw_in.value__),
ntohl (aa->assigned_bw_out.value__));
@@ -117,7 +119,8 @@
1, GNUNET_NO);
GNUNET_STATISTICS_set (GSA_stats, "# active addresses", active_addr_count,
GNUNET_NO);
- GNUNET_CONTAINER_multihashmap_iterate (addresses, &update_bw_it, NULL);
+
+ GNUNET_CONTAINER_multihashmap_iterate (addresses, &update_bw_simple_it,
NULL);
}
/**
@@ -591,14 +594,24 @@
struct ATS_Address *aa;
aa = NULL;
- GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
- &find_address_it, &aa);
- if (aa == NULL)
+
+ if (ats_mode == SIMPLE)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
- return;
+ /* Get address with: stick to current address, lower distance, lower
latency */
+ GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
+ &find_address_it, &aa);
+ if (aa == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
+ return;
+ }
}
+ if (ats_mode == MLP)
+ {
+ /* Get preferred address from MLP */
+ }
+
if (aa->active == GNUNET_NO)
{
aa->active = GNUNET_YES;
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-02-17 13:49:24 UTC
(rev 19834)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-02-17 15:32:23 UTC
(rev 19835)
@@ -1026,17 +1026,20 @@
mlpi = a->mlp_information;
b = glp_mip_col_val(mlp->prob, mlpi->c_b);
+ mlpi->b = b;
+
n = glp_mip_col_val(mlp->prob, mlpi->c_n);
+ if (n == 1.0)
+ mlpi->n = GNUNET_YES;
+ else
+ mlpi->n = GNUNET_NO;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tAddress %f %f\n", n, b);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tAddress %s %f\n",
+ (n == 1.0) ? "[x]" : "[ ]", b);
}
}
-
-
-
if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel(mlp->mlp_task);
@@ -1416,7 +1419,42 @@
}
}
+static int
+mlp_get_preferred_address_it (void *cls, const GNUNET_HashCode * key, void
*value)
+{
+
+ struct ATS_Address **aa = (struct ATS_Address **)cls;
+ struct ATS_Address *addr = value;
+ struct MLP_information *mlpi = addr->mlp_information;
+ if (mlpi->n == GNUNET_YES)
+ {
+ *aa = addr;
+ return GNUNET_NO;
+ }
+ return GNUNET_YES;
+}
+
+
/**
+ * Get the preferred address for a specific peer
+ *
+ * @param mlp the MLP Handle
+ * @param peer the peer
+ * @return suggested address
+ */
+struct ATS_Address *
+GAS_mlp_get_preferred_address (struct GAS_MLP_Handle *mlp,
+ struct GNUNET_CONTAINER_MultiHashMap *
addresses,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ struct ATS_Address * aa = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting preferred address for `%s'\n",
GNUNET_i2s (peer));
+ GNUNET_CONTAINER_multihashmap_get_multiple(addresses, &peer->hashPubKey,
mlp_get_preferred_address_it, &aa);
+ return aa;
+}
+
+
+/**
* Changes the preferences for a peer in the MLP problem
*
* @param mlp the MLP Handle
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-02-17 13:49:24 UTC
(rev 19834)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-02-17 15:32:23 UTC
(rev 19835)
@@ -251,6 +251,10 @@
*/
struct MLP_information
{
+ double b;
+
+ int n;
+
/* bandwidth column index */
signed int c_b;
@@ -349,6 +353,18 @@
/**
+ * Get the preferred address for a specific peer
+ *
+ * @param mlp the MLP Handle
+ * @param peer the peer
+ * @return suggested address
+ */
+struct ATS_Address *
+GAS_mlp_get_preferred_address (struct GAS_MLP_Handle *mlp,
+ struct GNUNET_CONTAINER_MultiHashMap *
addresses,
+ const struct GNUNET_PeerIdentity *peer);
+
+/**
* Shutdown the MLP problem solving component
*/
void
Modified: gnunet/src/ats/test_ats_mlp.c
===================================================================
--- gnunet/src/ats/test_ats_mlp.c 2012-02-17 13:49:24 UTC (rev 19834)
+++ gnunet/src/ats/test_ats_mlp.c 2012-02-17 15:32:23 UTC (rev 19835)
@@ -45,6 +45,7 @@
struct GAS_MLP_Handle *mlp;
+
static void
create_address (struct ATS_Address *addr, char * plugin, int ats_count, struct
GNUNET_ATS_Information *ats)
{
@@ -73,6 +74,7 @@
return;
#endif
struct ATS_Address addr[10];
+ struct ATS_Address *res[10];
stats = GNUNET_STATISTICS_create("ats", cfg);
@@ -138,6 +140,11 @@
GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp));
+ res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s'
\n",res[0]->plugin);
+ res[1] = GAS_mlp_get_preferred_address(mlp, addresses, &p[1]);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s'
\n",res[1]->plugin);
+
/* Delete an address */
GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey,
&addr[0]);
GAS_mlp_address_delete (mlp, addresses, &addr[0]);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19835 - gnunet/src/ats,
gnunet <=