aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats_proportional.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/plugin_ats_proportional.c')
-rw-r--r--src/ats/plugin_ats_proportional.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index 77c7315aa..5798fd82e 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -573,13 +573,15 @@ distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s,
573 unsigned long long assigned_quota_out = 0; 573 unsigned long long assigned_quota_out = 0;
574 574
575 575
576 LOG(GNUNET_ERROR_TYPE_DEBUG, 576 LOG(GNUNET_ERROR_TYPE_INFO,
577 "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n", 577 "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n",
578 net->desc, net->active_addresses, net->total_quota_in, 578 net->desc, net->active_addresses, net->total_quota_in,
579 net->total_quota_in); 579 net->total_quota_in);
580 580
581 if (net->active_addresses == 0) 581 if (net->active_addresses == 0)
582 {
582 return; /* no addresses to update */ 583 return; /* no addresses to update */
584 }
583 585
584 /* Idea 586 /* Idea
585 * Assign every peer in network minimum Bandwidth 587 * Assign every peer in network minimum Bandwidth
@@ -641,7 +643,7 @@ distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s,
641 assigned_quota_out = min_bw 643 assigned_quota_out = min_bw
642 + ((cur_pref / total_prefs) * remaining_quota_out); 644 + ((cur_pref / total_prefs) * remaining_quota_out);
643 645
644 LOG(GNUNET_ERROR_TYPE_DEBUG, 646 LOG (GNUNET_ERROR_TYPE_INFO,
645 "New quota for peer `%s' with preference (cur/total) %.3f/%.3f (in/out): %llu / %llu\n", 647 "New quota for peer `%s' with preference (cur/total) %.3f/%.3f (in/out): %llu / %llu\n",
646 GNUNET_i2s (&cur->addr->peer), cur_pref, total_prefs, 648 GNUNET_i2s (&cur->addr->peer), cur_pref, total_prefs,
647 assigned_quota_in, assigned_quota_out); 649 assigned_quota_in, assigned_quota_out);
@@ -829,7 +831,20 @@ propagate_bandwidth (struct GAS_PROPORTIONAL_Handle *s,
829 (cur->addr->assigned_bw_out.value__ != asi->calculated_quota_out_NBO) ) 831 (cur->addr->assigned_bw_out.value__ != asi->calculated_quota_out_NBO) )
830 { 832 {
831 cur->addr->assigned_bw_in.value__ = asi->calculated_quota_in_NBO; 833 cur->addr->assigned_bw_in.value__ = asi->calculated_quota_in_NBO;
832 cur->addr->assigned_bw_out.value__ = asi->calculated_quota_in_NBO; 834 cur->addr->assigned_bw_out.value__ = asi->calculated_quota_out_NBO;
835
836 /* Reset for next iteration */
837 asi->calculated_quota_in_NBO = htonl (0);
838 asi->calculated_quota_out_NBO = htonl (0);
839
840 LOG (GNUNET_ERROR_TYPE_DEBUG,
841 "Bandwidth for %s address %p for peer `%s' changed to %u/%u\n",
842 (GNUNET_NO == cur->addr->active) ? "inactive" : "active",
843 cur->addr,
844 GNUNET_i2s (&cur->addr->peer),
845 ntohl (cur->addr->assigned_bw_in.value__),
846 ntohl (cur->addr->assigned_bw_out.value__ ));
847
833 /* Notify on change */ 848 /* Notify on change */
834 if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except)) 849 if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except))
835 s->bw_changed (s->bw_changed_cls, cur->addr); 850 s->bw_changed (s->bw_changed_cls, cur->addr);
@@ -856,6 +871,11 @@ distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s,
856 871
857 if (NULL != n) 872 if (NULL != n)
858 { 873 {
874 LOG (GNUNET_ERROR_TYPE_INFO,
875 "Redistributing bandwidth in network %s with %u active and %u total addresses\n",
876 GNUNET_ATS_print_network_type(n->type),
877 n->active_addresses, n->total_addresses);
878
859 if (NULL != s->env->info_cb) 879 if (NULL != s->env->info_cb)
860 s->env->info_cb(s->env->info_cb_cls, GAS_OP_SOLVE_START, 880 s->env->info_cb(s->env->info_cb_cls, GAS_OP_SOLVE_START,
861 GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE); 881 GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
@@ -1174,6 +1194,7 @@ GAS_proportional_get_preferred_address (void *solver,
1174 prev->active = GNUNET_NO; /* No active any longer */ 1194 prev->active = GNUNET_NO; /* No active any longer */
1175 prev->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */ 1195 prev->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
1176 prev->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */ 1196 prev->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
1197
1177 if (GNUNET_SYSERR == addresse_decrement (s, net_prev, GNUNET_NO, GNUNET_YES)) 1198 if (GNUNET_SYSERR == addresse_decrement (s, net_prev, GNUNET_NO, GNUNET_YES))
1178 GNUNET_break(0); 1199 GNUNET_break(0);
1179 distribute_bandwidth_in_network (s, net_prev, NULL); 1200 distribute_bandwidth_in_network (s, net_prev, NULL);
@@ -1212,18 +1233,24 @@ GAS_proportional_stop_get_preferred_address (void *solver,
1212 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (s->requests, peer, 1233 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (s->requests, peer,
1213 NULL)); 1234 NULL));
1214 1235
1215 cur = get_active_address (s, 1236 cur = get_active_address (s, s->addresses, peer);
1216 s->addresses, peer);
1217 if (NULL != cur) 1237 if (NULL != cur)
1218 { 1238 {
1239 LOG(GNUNET_ERROR_TYPE_INFO,
1240 "Disabling %s address %p for peer `%s'\n",
1241 (GNUNET_NO == cur->active) ? "inactive" : "active", cur,
1242 GNUNET_i2s (&cur->peer));
1243
1219 /* Disabling current address */ 1244 /* Disabling current address */
1220 asi = cur->solver_information; 1245 asi = cur->solver_information;
1221 cur_net = asi->network ; 1246 cur_net = asi->network ;
1222 cur->active = GNUNET_NO; /* No active any longer */ 1247 cur->active = GNUNET_NO; /* No active any longer */
1223 cur->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */ 1248 cur->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
1224 cur->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */ 1249 cur->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
1250
1225 if (GNUNET_SYSERR == addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES)) 1251 if (GNUNET_SYSERR == addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES))
1226 GNUNET_break(0); 1252 GNUNET_break(0);
1253
1227 distribute_bandwidth_in_network (s, cur_net, NULL ); 1254 distribute_bandwidth_in_network (s, cur_net, NULL );
1228 } 1255 }
1229 return; 1256 return;
@@ -1304,6 +1331,8 @@ GAS_proportional_address_delete (void *solver, struct ATS_Address *address,
1304 address->active = GNUNET_NO; 1331 address->active = GNUNET_NO;
1305 address->assigned_bw_in = BANDWIDTH_ZERO; 1332 address->assigned_bw_in = BANDWIDTH_ZERO;
1306 address->assigned_bw_out = BANDWIDTH_ZERO; 1333 address->assigned_bw_out = BANDWIDTH_ZERO;
1334 asi->calculated_quota_in_NBO = htonl (0);
1335 asi->calculated_quota_out_NBO = htonl (0);
1307 1336
1308 if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) 1337 if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES))
1309 GNUNET_break(0); 1338 GNUNET_break(0);
@@ -1604,8 +1633,8 @@ GAS_proportional_address_add (void *solver, struct ATS_Address *address,
1604 1633
1605 asi = GNUNET_new (struct AddressSolverInformation); 1634 asi = GNUNET_new (struct AddressSolverInformation);
1606 asi->network = net; 1635 asi->network = net;
1607 asi->calculated_quota_in_NBO = 0; 1636 asi->calculated_quota_in_NBO = htonl (0);
1608 asi->calculated_quota_out_NBO = 0; 1637 asi->calculated_quota_out_NBO = htonl (0);
1609 aw->addr->solver_information = asi; 1638 aw->addr->solver_information = asi;
1610 1639
1611 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer)) 1640 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer))