aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats_ril.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-10 23:24:01 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-10 23:24:01 +0000
commit1c323bd4cbb388a9e7515a1f733a3062bf093aee (patch)
tree7cc525d79149d44840b9f7a0040aaf3e69ecd665 /src/ats/plugin_ats_ril.c
parentaedaaed687db1ff20b447378f01ad7306921450c (diff)
downloadgnunet-1c323bd4cbb388a9e7515a1f733a3062bf093aee.tar.gz
gnunet-1c323bd4cbb388a9e7515a1f733a3062bf093aee.zip
fixing #3657 (replace ATS_Information with struct), but WIHTOUT fixing ATS testcases yet
Diffstat (limited to 'src/ats/plugin_ats_ril.c')
-rw-r--r--src/ats/plugin_ats_ril.c50
1 files changed, 6 insertions, 44 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c
index 78f58e609..0d8b2290c 100644
--- a/src/ats/plugin_ats_ril.c
+++ b/src/ats/plugin_ats_ril.c
@@ -934,29 +934,6 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
934 return state; 934 return state;
935} 935}
936 936
937/**
938 * Retrieves an ATS information value of an address
939 *
940 * @param address the address in question
941 * @param type the ATS information type
942 * @return the value
943 */
944static unsigned int
945ril_get_atsi (struct ATS_Address *address, uint32_t type)
946{
947 int c1;
948 GNUNET_assert(NULL != address);
949
950 if ((NULL == address->atsi) || (0 == address->atsi_count))
951 return GNUNET_ATS_QUALITY_NET_DELAY == type ? UINT32_MAX : 1;
952
953 for (c1 = 0; c1 < address->atsi_count; c1++)
954 {
955 if (ntohl (address->atsi[c1].type) == type)
956 return ntohl (address->atsi[c1].value);
957 }
958 return GNUNET_ATS_QUALITY_NET_DELAY == type ? UINT32_MAX : 1;
959}
960 937
961/** 938/**
962 * Returns the utility value of the connection an agent manages 939 * Returns the utility value of the connection an agent manages
@@ -975,16 +952,12 @@ agent_get_utility (struct RIL_Peer_Agent *agent)
975 preferences = agent->envi->env->get_preferences (agent->envi->env->cls, 952 preferences = agent->envi->env->get_preferences (agent->envi->env->cls,
976 &agent->peer); 953 &agent->peer);
977 954
978 delay_atsi = (double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_QUALITY_NET_DELAY); 955 delay_atsi = agent->address_inuse->norm_delay.norm;
979 delay_norm = RIL_UTILITY_DELAY_MAX*exp(-delay_atsi*0.00001); 956 delay_norm = RIL_UTILITY_DELAY_MAX*exp(-delay_atsi*0.00001);
980 957
981 pref_match = preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm; 958 pref_match = preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm;
982 pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * 959 pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] *
983 sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW)); 960 sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW));
984// sqrt((double) (ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_IN)/RIL_MIN_BW) * (double) (ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_OUT)/RIL_MIN_BW));
985
986// return (double) (agent->bw_in/RIL_MIN_BW);
987// return sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW));
988 return pref_match; 961 return pref_match;
989} 962}
990 963
@@ -1799,9 +1772,9 @@ ril_network_get_utilized (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network
1799 if (net->type == type) 1772 if (net->type == type)
1800 { 1773 {
1801 if (direction_in) 1774 if (direction_in)
1802 sum += ril_get_atsi (cur->address_inuse, GNUNET_ATS_UTILIZATION_IN); 1775 sum += cur->address_inuse->norm_utilization_in.norm;
1803 else 1776 else
1804 sum += ril_get_atsi (cur->address_inuse, GNUNET_ATS_UTILIZATION_OUT); 1777 sum += cur->address_inuse->norm_utilization_out.norm;
1805 } 1778 }
1806 } 1779 }
1807 } 1780 }
@@ -2373,27 +2346,16 @@ GAS_ril_address_delete (void *solver,
2373 * 2346 *
2374 * @param solver solver handle 2347 * @param solver solver handle
2375 * @param address the address 2348 * @param address the address
2376 * @param type the ATSI type
2377 * @param abs_value the absolute value of the property
2378 * @param rel_value the normalized value
2379 */ 2349 */
2380static void 2350static void
2381GAS_ril_address_property_changed (void *solver, 2351GAS_ril_address_property_changed (void *solver,
2382 struct ATS_Address *address, 2352 struct ATS_Address *address)
2383 enum GNUNET_ATS_Property type,
2384 uint32_t abs_value,
2385 double rel_value)
2386{ 2353{
2387 struct GAS_RIL_Handle *s = solver; 2354 struct GAS_RIL_Handle *s = solver;
2388 2355
2389 LOG(GNUNET_ERROR_TYPE_DEBUG, 2356 LOG(GNUNET_ERROR_TYPE_DEBUG,
2390 "API_address_property_changed() Property '%s' for peer '%s' address %s changed " 2357 "Properties for peer '%s' address changed\n",
2391 "to %.2f \n", 2358 GNUNET_i2s (&address->peer));
2392 GNUNET_ATS_print_property_type (type),
2393 GNUNET_i2s (&address->peer),
2394 address->addr, rel_value);
2395
2396
2397 s->parameters.temperature = s->parameters.temperature_init; 2359 s->parameters.temperature = s->parameters.temperature_init;
2398 s->parameters.epsilon = s->parameters.epsilon_init; 2360 s->parameters.epsilon = s->parameters.epsilon_init;
2399 ril_step (s); 2361 ril_step (s);