aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-08 17:24:44 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-08 17:24:44 +0000
commit958faaf07bb35e765f34cf8dc45487483e71fb23 (patch)
treefe45ff1ca3eb05a842165cc31d760803b30ead5b /src
parent09794f7d0dc2fe43878b88d0d65eb053e3928419 (diff)
downloadgnunet-958faaf07bb35e765f34cf8dc45487483e71fb23.tar.gz
gnunet-958faaf07bb35e765f34cf8dc45487483e71fb23.zip
- combining performance selection and stability in proportional address selection
- adding stbility tolerance configuration setting
Diffstat (limited to 'src')
-rw-r--r--src/ats/ats.conf.in7
-rw-r--r--src/ats/gnunet-service-ats_normalization.c1
-rw-r--r--src/ats/plugin_ats_proportional.c107
-rw-r--r--src/ats/plugin_ats_proportional.h2
4 files changed, 92 insertions, 25 deletions
diff --git a/src/ats/ats.conf.in b/src/ats/ats.conf.in
index aa938e4c3..e5bda20bc 100644
--- a/src/ats/ats.conf.in
+++ b/src/ats/ats.conf.in
@@ -35,8 +35,11 @@ BLUETOOTH_QUOTA_OUT = 128 KiB
35# Proportional specific settings 35# Proportional specific settings
36# How proportional to preferences is bandwidth distribution in a network 36# How proportional to preferences is bandwidth distribution in a network
37# 1: Fair with respect to addresses without preferences 37# 1: Fair with respect to addresses without preferences
38# > 1: The bigger, the more respect is payed to preferences 38# > 100: The bigger, the more respect is payed to preferences
39PROP_PROPORTIONALITY_FACTOR = 4 39PROP_PROPORTIONALITY_FACTOR = 200
40# Should we stick to existing connections are prefer to switch?
41# [100...200], lower value prefers to switch, bigger value is more tolerant
42PROP_STABILITY_FACTOR = 125
40 43
41# MLP specific settings 44# MLP specific settings
42# MLP defaults 45# MLP defaults
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c
index f29646260..1adc4811f 100644
--- a/src/ats/gnunet-service-ats_normalization.c
+++ b/src/ats/gnunet-service-ats_normalization.c
@@ -733,6 +733,7 @@ normalize_address (void *cls, const struct GNUNET_PeerIdentity *h, void *k)
733 backup = address->atsin[p->prop_type].norm; 733 backup = address->atsin[p->prop_type].norm;
734 avg_value = address->atsin[p->prop_type].avg; 734 avg_value = address->atsin[p->prop_type].avg;
735 delta = p->max - p->min; 735 delta = p->max - p->min;
736 /* max - 2 * min + avg_value / max - min */
736 address->atsin[p->prop_type].norm = (delta + (avg_value - p->min)) / (delta); 737 address->atsin[p->prop_type].norm = (delta + (avg_value - p->min)) / (delta);
737 738
738 if (backup == address->atsin[p->prop_type].norm) 739 if (backup == address->atsin[p->prop_type].norm)
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index 71223417f..0fde58acc 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -291,6 +291,11 @@ struct GAS_PROPORTIONAL_Handle
291 * Proportionality factor 291 * Proportionality factor
292 */ 292 */
293 double prop_factor; 293 double prop_factor;
294
295 /**
296 * Stability factor
297 */
298 double stability_factor;
294}; 299};
295 300
296/** 301/**
@@ -400,6 +405,7 @@ libgnunet_plugin_ats_proportional_init (void *cls)
400 struct Network * cur; 405 struct Network * cur;
401 char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; 406 char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
402 unsigned long long prop_factor; 407 unsigned long long prop_factor;
408 unsigned long long stability_factor;
403 int c; 409 int c;
404 410
405 GNUNET_assert (NULL != env); 411 GNUNET_assert (NULL != env);
@@ -441,10 +447,31 @@ libgnunet_plugin_ats_proportional_init (void *cls)
441 s->requests = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 447 s->requests = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
442 448
443 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number(s->env->cfg, "ats", 449 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number(s->env->cfg, "ats",
450 "PROP_STABILITY_FACTOR", &stability_factor))
451 {
452 if ((stability_factor >= 100) && (stability_factor <= 200))
453 {
454 s->stability_factor = ((double) stability_factor) / 100;
455 }
456 else
457 {
458 GNUNET_break (0);
459 s->stability_factor = PROP_STABILITY_FACTOR;
460 }
461 }
462 else
463 {
464 GNUNET_break (0);
465 s->stability_factor = PROP_STABILITY_FACTOR;
466 }
467 LOG (GNUNET_ERROR_TYPE_INFO, "Using stability factor %.3f\n",
468 s->stability_factor);
469
470 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number(s->env->cfg, "ats",
444 "PROP_PROPORTIONALITY_FACTOR", &prop_factor)) 471 "PROP_PROPORTIONALITY_FACTOR", &prop_factor))
445 { 472 {
446 if (prop_factor > 1) 473 if (prop_factor >= 100)
447 s->prop_factor = (double) prop_factor; 474 s->prop_factor = ((double) prop_factor) / 100;
448 else 475 else
449 { 476 {
450 GNUNET_break (0); 477 GNUNET_break (0);
@@ -453,7 +480,7 @@ libgnunet_plugin_ats_proportional_init (void *cls)
453 } 480 }
454 else 481 else
455 s->prop_factor = PROPORTIONALITY_FACTOR; 482 s->prop_factor = PROPORTIONALITY_FACTOR;
456 LOG (GNUNET_ERROR_TYPE_INFO, "Using proportionality factor %.0f\n", 483 LOG (GNUNET_ERROR_TYPE_INFO, "Using proportionality factor %.3f\n",
457 s->prop_factor); 484 s->prop_factor);
458 485
459 486
@@ -743,6 +770,10 @@ find_best_address_it (void *cls,
743 struct AddressSolverInformation *asi; 770 struct AddressSolverInformation *asi;
744 const double *norm_prop_cur; 771 const double *norm_prop_cur;
745 const double *norm_prop_best; 772 const double *norm_prop_best;
773 double best_delay;
774 double best_distance;
775 double cur_delay;
776 double cur_distance;
746 int index; 777 int index;
747 778
748 current_best = NULL; 779 current_best = NULL;
@@ -790,45 +821,75 @@ find_best_address_it (void *cls,
790 goto end; 821 goto end;
791 } 822 }
792 } 823 }
793 if (NULL == ctx->best) 824 else
794 { 825 {
795 /* We do not have a 'best' address so take this address */ 826 /* We do not have a 'best' address so take this address */
827 LOG (GNUNET_ERROR_TYPE_DEBUG, "Setting initial address %p\n", current);
796 current_best = current; 828 current_best = current;
797 goto end; 829 goto end;
798 } 830 }
799 831
800 if ( (ntohl (ctx->best->assigned_bw_in.value__) == 0) &&
801 (ntohl (current->assigned_bw_in.value__) > 0) )
802 {
803 /* stick to existing connection */
804 current_best = current;
805 }
806
807 /* Now compare ATS information */ 832 /* Now compare ATS information */
808 norm_prop_cur = ctx->s->get_properties (ctx->s->get_properties_cls, 833 norm_prop_cur = ctx->s->get_properties (ctx->s->get_properties_cls,
809 (const struct ATS_Address *) current); 834 (const struct ATS_Address *) current);
835 index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
836 cur_distance = norm_prop_cur[index];
837 index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
838 cur_delay = norm_prop_cur[index];
839
810 norm_prop_best = ctx->s->get_properties (ctx->s->get_properties_cls, 840 norm_prop_best = ctx->s->get_properties (ctx->s->get_properties_cls,
811 (const struct ATS_Address *) ctx->best); 841 (const struct ATS_Address *) ctx->best);
812
813 index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE); 842 index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
814 if (GNUNET_SYSERR != index) 843 best_distance = norm_prop_best[index];
844 index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
845 best_delay = norm_prop_best[index];
846
847 /* user shorter distance */
848
849
850 if (cur_distance < best_distance)
815 { 851 {
816 /* user shorter distance */ 852
817 if (norm_prop_cur[index] < norm_prop_best[index]) 853 if (GNUNET_NO == ctx->best->active)
854 {
855 current_best = current; /* Use current */
856 }
857 else if ((best_distance / cur_distance) > ctx->s->stability_factor)
858 {
859 /* Best and active address performs worse */
818 current_best = current; 860 current_best = current;
819 else 861 }
820 current_best = ctx->best; 862 }
863 else
864 {
865 /* Use current best */
866 current_best = ctx->best;
821 } 867 }
822 868
823 index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY); 869 /* User connection with less delay */
824 if (GNUNET_SYSERR != index) 870 if (cur_delay < best_delay)
825 { 871 {
826 /* User connection with less delay */ 872
827 if (norm_prop_cur[index] < norm_prop_best[index]) 873 if (GNUNET_NO == ctx->best->active)
874 {
875 current_best = current; /* Use current */
876 }
877 else if ((best_delay / cur_delay) > ctx->s->stability_factor)
878 {
879 /* Best and active address performs worse */
828 current_best = current; 880 current_best = current;
881 }
829 else 882 else
830 current_best = ctx->best; 883 {
884 //GNUNET_break (0);
885 }
831 } 886 }
887 else
888 {
889 /* Use current best */
890 current_best = ctx->best;
891 }
892
832end: 893end:
833 ctx->best = current_best; 894 ctx->best = current_best;
834 return GNUNET_OK; 895 return GNUNET_OK;
@@ -1523,7 +1584,7 @@ GAS_proportional_address_property_changed (void *solver,
1523 return; 1584 return;
1524 } 1585 }
1525 1586
1526 LOG(GNUNET_ERROR_TYPE_DEBUG, 1587 LOG(GNUNET_ERROR_TYPE_INFO,
1527 "Property `%s' for peer `%s' address %p changed to %.2f \n", 1588 "Property `%s' for peer `%s' address %p changed to %.2f \n",
1528 GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer), 1589 GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
1529 address, rel_value); 1590 address, rel_value);
diff --git a/src/ats/plugin_ats_proportional.h b/src/ats/plugin_ats_proportional.h
index 371c4077c..999f42f3f 100644
--- a/src/ats/plugin_ats_proportional.h
+++ b/src/ats/plugin_ats_proportional.h
@@ -29,6 +29,8 @@
29#include "gnunet_ats_plugin.h" 29#include "gnunet_ats_plugin.h"
30#include "gnunet-service-ats_addresses.h" 30#include "gnunet-service-ats_addresses.h"
31 31
32#define PROP_STABILITY_FACTOR 1.25
33
32/** 34/**
33 * ATS proportional solver 35 * ATS proportional solver
34 * 36 *