aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-12-03 14:50:15 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-12-03 14:50:15 +0000
commita3b64a461bf4e1638ffb0884ed42bde42c56c77e (patch)
tree66844dd0f90f3e68a9d215ff57d025ed4ec992a8
parent7098267e7ae29b19bc797c5c5c5f5a7e1b146a78 (diff)
downloadgnunet-a3b64a461bf4e1638ffb0884ed42bde42c56c77e.tar.gz
gnunet-a3b64a461bf4e1638ffb0884ed42bde42c56c77e.zip
changes
-rw-r--r--src/ats/Makefile.am1
-rw-r--r--src/ats/ats.conf.in7
-rw-r--r--src/ats/gnunet-service-ats_addresses.c159
-rw-r--r--src/ats/gnunet-service-ats_addresses_simplistic.c64
-rw-r--r--src/ats/gnunet-service-ats_addresses_simplistic.h53
-rw-r--r--src/ats/test_ats_api.conf2
6 files changed, 223 insertions, 63 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index 57ca63e08..bd6d6def2 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -44,6 +44,7 @@ libexec_PROGRAMS = \
44gnunet_service_ats_SOURCES = \ 44gnunet_service_ats_SOURCES = \
45 gnunet-service-ats.c gnunet-service-ats.h\ 45 gnunet-service-ats.c gnunet-service-ats.h\
46 gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \ 46 gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \
47 gnunet-service-ats_addresses_simplistic.c gnunet-service-ats_addresses_simplistic.h \
47 $(GN_MLP_SRC) \ 48 $(GN_MLP_SRC) \
48 gnunet-service-ats_performance.c gnunet-service-ats_performance.h \ 49 gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
49 gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \ 50 gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \
diff --git a/src/ats/ats.conf.in b/src/ats/ats.conf.in
index d99708174..d063af333 100644
--- a/src/ats/ats.conf.in
+++ b/src/ats/ats.conf.in
@@ -10,8 +10,9 @@ UNIXPATH = /tmp/gnunet-service-ats.sock
10UNIX_MATCH_UID = YES 10UNIX_MATCH_UID = YES
11UNIX_MATCH_GID = YES 11UNIX_MATCH_GID = YES
12 12
13# Enable MLP mode (default: NO) 13# Designated assigment mode: simplistic / MLP
14MLP = NO 14MODE = simplistic
15
15# Network specific inbound/outbound quotas 16# Network specific inbound/outbound quotas
16# LOOPBACK 17# LOOPBACK
17LOOPBACK_QUOTA_IN = unlimited 18LOOPBACK_QUOTA_IN = unlimited
@@ -27,6 +28,8 @@ WLAN_QUOTA_IN = 1 MiB
27WLAN_QUOTA_OUT = 1 MiB 28WLAN_QUOTA_OUT = 1 MiB
28# ATS options 29# ATS options
29 30
31
32# MLP specific settings
30DUMP_MLP = NO 33DUMP_MLP = NO
31DUMP_SOLUTION = NO 34DUMP_SOLUTION = NO
32DUMP_OVERWRITE = NO 35DUMP_OVERWRITE = NO
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 584978e2a..1262c0ad4 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -34,29 +34,37 @@
34#if HAVE_LIBGLPK 34#if HAVE_LIBGLPK
35#include "gnunet-service-ats_addresses_mlp.h" 35#include "gnunet-service-ats_addresses_mlp.h"
36#endif 36#endif
37#include "gnunet-service-ats_addresses_simplistic.h"
37 38
38#define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100) 39#define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
39 40
41
42/**
43 * Available ressource assignment modes
44 */
40enum ATS_Mode 45enum ATS_Mode
41{ 46{
42 /* 47 /*
48 * Simplistic mode:
49 *
43 * Assign each peer an equal amount of bandwidth (bw) 50 * Assign each peer an equal amount of bandwidth (bw)
44 * 51 *
45 * bw_per_peer = bw_total / #active addresses 52 * bw_per_peer = bw_total / #active addresses
46 */ 53 */
47 SIMPLE, 54 MODE_SIMPLISTIC,
48 55
49 /* 56 /*
50 * Use MLP solver to assign bandwidth 57 * MLP mode:
58 *
59 * Solve ressource assignment as an optimization problem
60 * Uses an mixed integer programming solver
51 */ 61 */
52 MLP 62 MODE_MLP
53}; 63};
54 64
55static struct GNUNET_CONTAINER_MultiHashMap *addresses; 65static struct GNUNET_CONTAINER_MultiHashMap *addresses;
56 66
57#if HAVE_LIBGLPK 67static void *solver;
58static struct GAS_MLP_Handle *mlp;
59#endif
60 68
61static unsigned long long wan_quota_in; 69static unsigned long long wan_quota_in;
62 70
@@ -223,8 +231,8 @@ destroy_address (struct ATS_Address *addr)
223 addr)); 231 addr));
224 232
225#if HAVE_LIBGLPK 233#if HAVE_LIBGLPK
226 if (ats_mode == MLP) 234 if (ats_mode == MODE_MLP)
227 GAS_mlp_address_delete (mlp, addresses, addr); 235 GAS_mlp_address_delete (solver, addresses, addr);
228#endif 236#endif
229 237
230 if (GNUNET_YES == addr->active) 238 if (GNUNET_YES == addr->active)
@@ -556,8 +564,8 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
556 break; 564 break;
557 } 565 }
558#if HAVE_LIBGLPK 566#if HAVE_LIBGLPK
559 if (ats_mode == MLP) 567 if (ats_mode == MODE_MLP)
560 GAS_mlp_address_update (mlp, addresses, old); 568 GAS_mlp_address_update (solver, addresses, old);
561#endif 569#endif
562} 570}
563 571
@@ -627,8 +635,8 @@ destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, void *valu
627 { 635 {
628 /* session was set to 0, update address */ 636 /* session was set to 0, update address */
629#if HAVE_LIBGLPK 637#if HAVE_LIBGLPK
630 if (ats_mode == MLP) 638 if (ats_mode == MODE_MLP)
631 GAS_mlp_address_update (mlp, addresses, aa); 639 GAS_mlp_address_update (solver, addresses, aa);
632#endif 640#endif
633 } 641 }
634 642
@@ -796,8 +804,8 @@ GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
796 } 804 }
797 old->used = in_use; 805 old->used = in_use;
798#if HAVE_LIBGLPK 806#if HAVE_LIBGLPK
799 if (ats_mode == MLP) 807 if (ats_mode == MODE_MLP)
800 GAS_mlp_address_update (mlp, addresses, old); 808 GAS_mlp_address_update (solver, addresses, old);
801#endif 809#endif
802 return GNUNET_OK; 810 return GNUNET_OK;
803} 811}
@@ -810,7 +818,7 @@ request_address_mlp (const struct GNUNET_PeerIdentity *peer)
810 aa = NULL; 818 aa = NULL;
811 819
812#if HAVE_GLPK 820#if HAVE_GLPK
813 /* Get preferred address from MLP */ 821 /* Get preferred address from MODE_MLP */
814 struct ATS_PreferedAddress * paddr = NULL; 822 struct ATS_PreferedAddress * paddr = NULL;
815 paddr = GAS_mlp_get_preferred_address (mlp, addresses, peer); 823 paddr = GAS_mlp_get_preferred_address (mlp, addresses, peer);
816 aa = paddr->address; 824 aa = paddr->address;
@@ -870,7 +878,7 @@ request_address_simple (const struct GNUNET_PeerIdentity *peer)
870 { 878 {
871 aa->active = GNUNET_YES; 879 aa->active = GNUNET_YES;
872 active_addr_count++; 880 active_addr_count++;
873 if (ats_mode == SIMPLE) 881 if (ats_mode == MODE_SIMPLISTIC)
874 { 882 {
875 recalculate_assigned_bw (); 883 recalculate_assigned_bw ();
876 } 884 }
@@ -893,11 +901,11 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
893 if (GNUNET_NO == running) 901 if (GNUNET_NO == running)
894 return; 902 return;
895 903
896 if (ats_mode == SIMPLE) 904 if (ats_mode == MODE_SIMPLISTIC)
897 { 905 {
898 request_address_simple (peer); 906 request_address_simple (peer);
899 } 907 }
900 if (ats_mode == MLP) 908 if (ats_mode == MODE_MLP)
901 { 909 {
902 request_address_mlp(peer); 910 request_address_mlp(peer);
903 } 911 }
@@ -939,8 +947,8 @@ GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
939 if (GNUNET_NO == running) 947 if (GNUNET_NO == running)
940 return; 948 return;
941#if HAVE_LIBGLPK 949#if HAVE_LIBGLPK
942 if (ats_mode == MLP) 950 if (ats_mode == MODE_MLP)
943 GAS_mlp_address_change_preference (mlp, peer, kind, score); 951 GAS_mlp_address_change_preference (solver, peer, kind, score);
944#endif 952#endif
945} 953}
946 954
@@ -956,16 +964,13 @@ void
956GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 964GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
957 const struct GNUNET_STATISTICS_Handle *stats) 965 const struct GNUNET_STATISTICS_Handle *stats)
958{ 966{
959 int mode; 967 int c;
960
961 char *quota_wan_in_str; 968 char *quota_wan_in_str;
962 char *quota_wan_out_str; 969 char *quota_wan_out_str;
963 970 char *mode_str;
964 running = GNUNET_NO; 971 running = GNUNET_NO;
965 972
966 addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); 973 /* Initialize the system with configuration values */
967 GNUNET_assert (NULL != addresses);
968
969 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", &quota_wan_in_str)) 974 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", &quota_wan_in_str))
970 { 975 {
971 if (0 == strcmp(quota_wan_in_str, "unlimited") || 976 if (0 == strcmp(quota_wan_in_str, "unlimited") ||
@@ -994,47 +999,72 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
994 wan_quota_out = (UINT32_MAX) /10; 999 wan_quota_out = (UINT32_MAX) /10;
995 } 1000 }
996 1001
997 mode = GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"); 1002 /* Initialize the addresses database */
998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP mode %u", mode); 1003 addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
999 switch (mode) 1004 GNUNET_assert (NULL != addresses);
1005
1006 /* Figure out configured solution method */
1007 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str))
1000 { 1008 {
1001 /* MLP = YES */ 1009 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "No ressource assignment method configured, using simplistic approch\n");
1002 case GNUNET_YES: 1010 ats_mode = MODE_SIMPLISTIC;
1003#if HAVE_LIBGLPK 1011 }
1004 ats_mode = MLP; 1012 else
1013 {
1014 for (c = 0; c < strlen (mode_str); c++)
1015 mode_str[c] = toupper (mode_str[c]);
1016 if (0 == strcmp (mode_str, "SIMPLISTIC"))
1017 {
1018 ats_mode = MODE_SIMPLISTIC;
1019 }
1020 else if (0 == strcmp (mode_str, "MLP"))
1021 {
1022 ats_mode = MODE_MLP;
1023#if !HAVE_LIBGLPK
1024 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Assignment method `%s' configured, but GLPK is not availabe, please install \n", mode_str);
1025 ats_mode = MODE_SIMPLISTIC;
1026#endif
1027 }
1028 else
1029 {
1030 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid ressource assignment method `%s' configured, using simplistic approch\n", mode_str);
1031 ats_mode = MODE_SIMPLISTIC;
1032 }
1033 }
1034
1035 /* Start configured solution method */
1036 switch (ats_mode)
1037 {
1038 case MODE_MLP:
1005 /* Init the MLP solver with default values */ 1039 /* Init the MLP solver with default values */
1006 mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); 1040 solver = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
1007 if (NULL == mlp) 1041 if (NULL != solver)
1008 { 1042 {
1009 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode\n"); 1043 ats_mode = MODE_MLP;
1010 GNUNET_STATISTICS_update (GSA_stats, "MLP mode enabled", 0, GNUNET_NO); 1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started in %s mode\n", "MLP");
1011 break; 1045 break;
1046 }
1047 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize MLP solver!\n");
1048 case MODE_SIMPLISTIC:
1049 /* Init the simplistic solver with default values */
1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started in %s mode\n", "SIMPLISTIC");
1051 solver = GAS_simplistic_init (cfg, stats);
1052 if (NULL != solver)
1053 {
1054 ats_mode = MODE_SIMPLISTIC;
1055 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started in %s mode\n", "SIMPLISTIC");
1056 break;
1012 } 1057 }
1013 else 1058 else
1014 { 1059 {
1015 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 1, GNUNET_NO); 1060 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize simplistic solver!\n");
1016 break; 1061 return;
1017 } 1062 }
1018#else
1019 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode");
1020 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
1021 ats_mode = SIMPLE;
1022 break;
1023#endif
1024 /* MLP = NO */
1025 case GNUNET_NO:
1026 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
1027 ats_mode = SIMPLE;
1028 break;
1029 /* No configuration value */
1030 case GNUNET_SYSERR:
1031 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
1032 ats_mode = SIMPLE;
1033 break; 1063 break;
1034 default: 1064 default:
1035 break; 1065 break;
1036 } 1066 }
1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started with %s mode\n", (SIMPLE == ats_mode) ? "SIMPLE" : "MLP"); 1067 /* up and running */
1038 running = GNUNET_YES; 1068 running = GNUNET_YES;
1039} 1069}
1040 1070
@@ -1079,12 +1109,21 @@ GAS_addresses_done ()
1079 running = GNUNET_NO; 1109 running = GNUNET_NO;
1080 GNUNET_CONTAINER_multihashmap_destroy (addresses); 1110 GNUNET_CONTAINER_multihashmap_destroy (addresses);
1081 addresses = NULL; 1111 addresses = NULL;
1082#if HAVE_LIBGLPK 1112
1083 if (ats_mode == MLP) 1113 /* Stop configured solution method */
1114 switch (ats_mode)
1084 { 1115 {
1085 GAS_mlp_done (mlp); 1116 case MODE_MLP:
1117 /* Init the MLP solver with default values */
1118 GAS_mlp_done (solver);
1119 break;
1120 case MODE_SIMPLISTIC:
1121 /* Init the simplistic solver with default values */
1122 GAS_simplistic_done (solver);
1123 break;
1124 default:
1125 break;
1086 } 1126 }
1087#endif
1088} 1127}
1089 1128
1090struct PeerIteratorContext 1129struct PeerIteratorContext
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c
new file mode 100644
index 000000000..ac9828f11
--- /dev/null
+++ b/src/ats/gnunet-service-ats_addresses_simplistic.c
@@ -0,0 +1,64 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file ats/gnunet-service-ats_addresses_simplistic.c
23 * @brief ats mlp problem solver
24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet-service-ats_addresses.h"
30#include "gnunet_statistics_service.h"
31#include "glpk.h"
32
33struct GAS_SIMPLISTIC_Handle
34{
35
36};
37
38/**
39 * Init the simplistic problem solving component
40 *
41 * @param cfg configuration handle
42 * @param stats the GNUNET_STATISTICS handle
43 * @param max_duration maximum numbers of iterations for the LP/MLP Solver
44 * @param max_iterations maximum time limit for the LP/MLP Solver
45 * @return struct GAS_MLP_Handle * on success, NULL on fail
46 */
47struct GAS_SIMPLISTIC_Handle *
48GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
49 const struct GNUNET_STATISTICS_Handle *stats)
50{
51 struct GAS_SIMPLISTIC_Handle *solver = GNUNET_malloc (sizeof (struct GAS_SIMPLISTIC_Handle));
52 return solver;
53}
54
55/**
56 * Shutdown the simplistic problem solving component
57 */
58void
59GAS_simplistic_done (struct GAS_SIMPLISTIC_Handle *solver)
60{
61 GNUNET_free (solver);
62}
63
64/* end of gnunet-service-ats_addresses_simplistic.c */
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.h b/src/ats/gnunet-service-ats_addresses_simplistic.h
new file mode 100644
index 000000000..654753a7f
--- /dev/null
+++ b/src/ats/gnunet-service-ats_addresses_simplistic.h
@@ -0,0 +1,53 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file ats/gnunet-service-ats_addresses_simplistic.h
23 * @brief ats mlp problem solver
24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */
27#include "platform.h"
28#include "gnunet_statistics_service.h"
29#include "gnunet-service-ats_addresses.h"
30
31struct GAS_SIMPLISTIC_Handle;
32
33/**
34 * Init the simplistic problem solving component
35 *
36 * @param cfg configuration handle
37 * @param stats the GNUNET_STATISTICS handle
38 * @param max_duration maximum numbers of iterations for the LP/MLP Solver
39 * @param max_iterations maximum time limit for the LP/MLP Solver
40 * @return struct GAS_MLP_Handle * on success, NULL on fail
41 */
42struct GAS_SIMPLISTIC_Handle *
43GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
44 const struct GNUNET_STATISTICS_Handle *stats);
45
46/**
47 * Shutdown the simplistic problem solving component
48 */
49void
50GAS_simplistic_done (struct GAS_SIMPLISTIC_Handle *);
51
52
53/* end of gnunet-service-ats_addresses_simplistic.h */
diff --git a/src/ats/test_ats_api.conf b/src/ats/test_ats_api.conf
index 2ac499c66..d55d9911c 100644
--- a/src/ats/test_ats_api.conf
+++ b/src/ats/test_ats_api.conf
@@ -20,7 +20,7 @@ UNIX_MATCH_UID = YES
20UNIX_MATCH_GID = YES 20UNIX_MATCH_GID = YES
21 21
22# Enable MLP mode (default: NO) 22# Enable MLP mode (default: NO)
23MLP = NO 23MODE = SIMPLISTIC
24# Network specific inbound/outbound quotas 24# Network specific inbound/outbound quotas
25# LOOPBACK 25# LOOPBACK
26LOOPBACK_QUOTA_IN = unlimited 26LOOPBACK_QUOTA_IN = unlimited