enum ATS_Mode
{
- SIMPLE,
- MLP
+ /**
+ * Assign each peer an equal amount of bandwidth (bw)
+ *
+ * bw_per_peer = bw_total / #active addresses
+ */
+ SIMPLE,
+
+ /**
+ * Use MLP solver to assign bandwidth
+ */
+ MLP
};
static struct GNUNET_CONTAINER_MultiHashMap *addresses;
+#if HAVE_LIBGLPK
+static struct GAS_MLP_Handle *mlp;
+#endif
+
static unsigned long long wan_quota_in;
static unsigned long long wan_quota_out;
static int ats_mode;
+
/**
* Update a bandwidth assignment for a peer. This trivial method currently
* simply assigns the same share to all active connections.
{
struct ATS_Address *aa = value;
+
+ /* Simple method */
if (GNUNET_YES != aa->active)
return GNUNET_OK;
GNUNET_assert (active_addr_count > 0);
GNUNET_CONTAINER_multihashmap_remove (addresses,
&addr->peer.hashPubKey,
addr));
+
+#if HAVE_LIBGLPK
+ if (ats_mode == MLP)
+ GAS_mlp_address_delete (mlp, addresses, addr);
+#endif
+
if (GNUNET_YES == addr->active)
{
active_addr_count--;
}
#if HAVE_LIBGLPK
if (ats_mode == MLP)
- GAS_mlp_address_update (addresses, old);
+ GAS_mlp_address_update (mlp, addresses, old);
#endif
}
/* session == 0 and addrlen == 0 : destroy address */
if (aa->addr_len == 0)
+ {
(void) destroy_address (aa);
+ }
+ else
+ {
+ /* session was set to 0, update address */
+#if HAVE_LIBGLPK
+ if (ats_mode == MLP)
+ GAS_mlp_address_update (mlp, addresses, aa);
+#endif
+ }
return GNUNET_OK;
}
-
void
GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *plugin_addr,
#if HAVE_LIBGLPK
if (ats_mode == MLP)
- GAS_mlp_address_update (addresses, old);
+ GAS_mlp_address_update (mlp, addresses, old);
#endif
}
"WAN_QUOTA_OUT",
&wan_quota_out));
-
-
switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"))
{
/* MLP = YES */
#if HAVE_LIBGLPK
ats_mode = MLP;
/* Init the MLP solver with default values */
- GAS_mlp_init (stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
+ mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
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;
#if HAVE_LIBGLPK
if (ats_mode == MLP)
{
- GAS_mlp_done ();
+ GAS_mlp_done (mlp);
}
#endif