aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_addresses.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-11-18 16:20:51 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-11-18 16:20:51 +0000
commite3da33beafd9468cdf6a8137d0e98db9cb6af70e (patch)
tree2b0edaa1ab4d2967d734e4722171a2933b662433 /src/ats/gnunet-service-ats_addresses.c
parentb0351323dbd163801300ab7fc1b108fcdc1e1fc0 (diff)
downloadgnunet-e3da33beafd9468cdf6a8137d0e98db9cb6af70e.tar.gz
gnunet-e3da33beafd9468cdf6a8137d0e98db9cb6af70e.zip
preference iteration
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses.c')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c111
1 files changed, 82 insertions, 29 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 33fac8a06..154838a00 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -626,6 +626,34 @@ find_exact_address (struct GAS_Addresses_Handle *handle,
626} 626}
627 627
628/** 628/**
629 * Function allowing the solver to obtain normalized preference
630 * values from solver
631 *
632 * @param cls unused
633 * @param id the peer to return the normalized properties for
634 * @return array of double values with |GNUNET_ATS_PreferenceCount| elements
635 */
636const double *
637get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
638{
639 return GAS_normalization_get_preferences (id);
640}
641
642/**
643 * Function allowing the solver to obtain normalized property
644 * values for an address from solver
645 *
646 * @param cls unused
647 * @param address the address
648 * @return array of double values with |GNUNET_ATS_QualityPropertiesCount| elements
649 */
650const double *
651get_property_cb (void *cls, const struct ATS_Address *address)
652{
653 return GAS_normalization_get_properties ((struct ATS_Address *) address);
654}
655
656/**
629 * Extract an ATS performance info from an address 657 * Extract an ATS performance info from an address
630 * 658 *
631 * @param address the address 659 * @param address the address
@@ -1278,9 +1306,23 @@ eval_count_active_it (void *cls, const struct GNUNET_PeerIdentity *id, void *obj
1278 return GNUNET_YES; 1306 return GNUNET_YES;
1279} 1307}
1280 1308
1309/**
1310 * Summary context
1311 */
1281struct SummaryContext { 1312struct SummaryContext {
1313 /**
1314 * Sum of the utilized inbound bandwidth per network
1315 */
1282 unsigned long long bandwidth_in_assigned[GNUNET_ATS_NetworkTypeCount]; 1316 unsigned long long bandwidth_in_assigned[GNUNET_ATS_NetworkTypeCount];
1317
1318 /**
1319 * Sum of the utilized outbound bandwidth per network
1320 */
1283 unsigned long long bandwidth_out_assigned[GNUNET_ATS_NetworkTypeCount]; 1321 unsigned long long bandwidth_out_assigned[GNUNET_ATS_NetworkTypeCount];
1322
1323 /**
1324 * Sum addresses within a network
1325 */
1284 unsigned int addresses_in_network[GNUNET_ATS_NetworkTypeCount]; 1326 unsigned int addresses_in_network[GNUNET_ATS_NetworkTypeCount];
1285}; 1327};
1286 1328
@@ -1315,6 +1357,40 @@ eval_sum_bw_used (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
1315 return GNUNET_OK; 1357 return GNUNET_OK;
1316} 1358}
1317 1359
1360/**
1361 * Summary context
1362 */
1363struct RelativityContext {
1364
1365 struct GAS_Addresses_Handle *ah;
1366};
1367
1368
1369static int
1370eval_preference_relativity (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
1371{
1372 struct RelativityContext *rc = cls;
1373 struct ATS_Address *addr = obj;
1374 int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType ;
1375 int c;
1376 const double *preferences;
1377
1378 if (GNUNET_YES == addr->active)
1379 {
1380 preferences = get_preferences_cb (rc->ah->env.get_preference_cls, id);
1381 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1382 {
1383 if (prefs[c] == GNUNET_ATS_PREFERENCE_END)
1384 continue;
1385 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preference for peer `%s' type %s: %f\n",
1386 GNUNET_i2s (id), GNUNET_ATS_print_preference_type(prefs[c]),
1387 preferences[c]);
1388 }
1389 }
1390
1391 return GNUNET_OK;
1392}
1393
1318 1394
1319/** 1395/**
1320 * Evaluate current bandwidth assignment 1396 * Evaluate current bandwidth assignment
@@ -1415,9 +1491,12 @@ GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah)
1415 } 1491 }
1416 1492
1417 /* 3) How well does selection match application requirements */ 1493 /* 3) How well does selection match application requirements */
1418 /* TODO */ 1494 for (cur = ah->pending_requests_head; NULL != cur; cur = cur->next)
1419 include_requirements = GNUNET_NO; 1495 {
1420 1496 GNUNET_CONTAINER_multipeermap_get_multiple (ah->addresses,
1497 &cur->id, &eval_preference_relativity, ah);
1498 include_requirements = GNUNET_NO;
1499 }
1421 /* GUQ */ 1500 /* GUQ */
1422 1501
1423 if (include_requests + include_utilization + include_requirements > 0) 1502 if (include_requests + include_utilization + include_requirements > 0)
@@ -1577,33 +1656,7 @@ normalized_property_changed_cb (void *cls, struct ATS_Address *address,
1577 ah->env.sf.s_address_update_property (ah->solver, address, type, 0, prop_rel); 1656 ah->env.sf.s_address_update_property (ah->solver, address, type, 0, prop_rel);
1578} 1657}
1579 1658
1580/**
1581 * Function allowing the solver to obtain normalized preference
1582 * values from solver
1583 *
1584 * @param cls unused
1585 * @param id the peer to return the normalized properties for
1586 * @return array of double values with |GNUNET_ATS_PreferenceCount| elements
1587 */
1588const double *
1589get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
1590{
1591 return GAS_normalization_get_preferences (id);
1592}
1593 1659
1594/**
1595 * Function allowing the solver to obtain normalized property
1596 * values for an address from solver
1597 *
1598 * @param cls unused
1599 * @param address the address
1600 * @return array of double values with |GNUNET_ATS_QualityPropertiesCount| elements
1601 */
1602const double *
1603get_property_cb (void *cls, const struct ATS_Address *address)
1604{
1605 return GAS_normalization_get_properties ((struct ATS_Address *) address);
1606}
1607 1660
1608/** 1661/**
1609 * Change the preference for a peer 1662 * Change the preference for a peer