/* c 10) obey network specific quotas
* (1)*b_1 + ... + (1)*b_m <= quota_n
*/
+
int cur_row = 0;
int c;
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
{
mlp->r_quota[c] = glp_add_rows (mlp->prob, 1);
+ char * text;
+ GNUNET_asprintf(&text, "quota_ats_%i", mlp->quota_index[c]);
+ glp_set_row_name (mlp->prob, mlp->r_quota[c], text);
+ GNUNET_free (text);
/* Set bounds to 0 <= x <= quota_out */
- glp_set_row_bnds (mlp->prob, mlp->r_quota[c], GLP_DB, 0.0, mlp->quota_out[c]);
+ glp_set_row_bnds (mlp->prob, mlp->r_quota[c], GLP_UP, 0.0, mlp->quota_out[c]);
}
GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp);
/* Set row bound == 0 */
glp_set_row_bnds (mlp->prob, mlp->r_c8, GLP_FX, 0.0, 0.0);
/* -u */
+
ia[mlp->ci] = mlp->r_c8;
ja[mlp->ci] = mlp->c_u;
ar[mlp->ci] = -1;
ar[mlp->ci] = -1;
mlp->ci++;
+
+
while (addr != NULL)
{
mlpi = (struct MLP_information *) addr->mlp_information;
/* coefficient for c 2) */
+
ia[mlp->ci] = peer->r_c2;
ja[mlp->ci] = mlpi->c_n;
ar[mlp->ci] = 1;
mlpi->c_b = col;
mlpi->c_n = col + 1;
+
GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin);
glp_set_col_name (mlp->prob, mlpi->c_b , name);
GNUNET_free (name);
unsigned int b_min;
unsigned int n_min;
struct GNUNET_TIME_Relative i_exec;
+ int c;
/* Init GLPK environment */
GNUNET_assert (glp_init_env() == 0);
else
U = 1.0;
+ /* Get quality metric coefficients from configuration */
+ int i_delay = -1;
+ int i_distance = -1;
+ int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties;
+ for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
+ {
+ /* initialize quality coefficients with default value 1.0 */
+ mlp->co_Q[c] = 1.0;
+
+ mlp->q[c] = q[c];
+ if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY)
+ i_delay = c;
+ if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE)
+ i_distance = c;
+ }
+
+ if ((i_delay != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
+ "COEFFICIENT_QUALITY_DELAY",
+ &tmp)))
+
+ mlp->co_Q[i_delay] = (double) tmp / 100;
+ else
+ mlp->co_Q[i_delay] = 1.0;
+
+ if ((i_distance != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
+ "COEFFICIENT_QUALITY_DISTANCE",
+ &tmp)))
+ mlp->co_Q[i_distance] = (double) tmp / 100;
+ else
+ mlp->co_Q[i_distance] = 1.0;
+
+ /* Get minimum bandwidth per used address from configuration */
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
+ "MIN_BANDWIDTH",
+ &tmp))
+ b_min = tmp;
+ else
+ {
+ b_min = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
+ }
+
+ /* Get minimum number of connections from configuration */
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
+ "MIN_CONNECTIONS",
+ &tmp))
+ n_min = tmp;
+ else
+ n_min = 4;
+
/* Init network quotas */
int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
- int c;
-
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
{
mlp->quota_index[c] = quotas[c];
{
quota_in = UINT32_MAX;
}
+ /* Check if defined quota could make problem unsolvable */
+ if ((n_min * b_min) > quota_out)
+ {
+ 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);
+ }
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n",
entry_out, quota_out, entry_in, quota_in);
mlp->quota_in[c] = quota_in;
}
- /* Get quality metric coefficients from configuration */
- int i_delay = -1;
- int i_distance = -1;
- int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties;
- for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
- {
- /* initialize quality coefficients with default value 1.0 */
- mlp->co_Q[c] = 1.0;
-
- mlp->q[c] = q[c];
- if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY)
- i_delay = c;
- if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE)
- i_distance = c;
- }
-
- if ((i_delay != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
- "COEFFICIENT_QUALITY_DELAY",
- &tmp)))
-
- mlp->co_Q[i_delay] = (double) tmp / 100;
- else
- mlp->co_Q[i_delay] = 1.0;
-
- if ((i_distance != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
- "COEFFICIENT_QUALITY_DISTANCE",
- &tmp)))
- mlp->co_Q[i_distance] = (double) tmp / 100;
- else
- mlp->co_Q[i_distance] = 1.0;
-
- /* Get minimum bandwidth per used address from configuration */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
- "MIN_BANDWIDTH",
- &tmp))
- b_min = tmp;
- else
- {
- b_min = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
- }
-
- /* Get minimum number of connections from configuration */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
- "MIN_CONNECTIONS",
- &tmp))
- n_min = tmp;
- else
- n_min = 4;
-
/* Get minimum number of connections from configuration */
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (cfg, "ats",
"ATS_EXEC_INTERVAL",