aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transport/gnunet-service-transport.c377
1 files changed, 218 insertions, 159 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index fb08ee816..eb48f8474 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -48,6 +48,10 @@
48 48
49#define DEBUG_TRANSPORT_HELLO GNUNET_NO 49#define DEBUG_TRANSPORT_HELLO GNUNET_NO
50 50
51#define DEBUG_ATS GNUNET_NO
52
53#define VERBOSE_ATS GNUNET_NO
54
51/** 55/**
52 * Should we do some additional checks (to validate behavior 56 * Should we do some additional checks (to validate behavior
53 * of clients)? 57 * of clients)?
@@ -2614,7 +2618,7 @@ add_peer_address (struct NeighbourList *neighbour,
2614 return NULL; 2618 return NULL;
2615 ret = GNUNET_malloc(sizeof(struct ForeignAddressList) + addrlen); 2619 ret = GNUNET_malloc(sizeof(struct ForeignAddressList) + addrlen);
2616 ret->session = session; 2620 ret->session = session;
2617 if (addrlen > 0) 2621 if ((addrlen > 0) && (addr != NULL))
2618 { 2622 {
2619 ret->addr = (const char*) &ret[1]; 2623 ret->addr = (const char*) &ret[1];
2620 memcpy (&ret[1], addr, addrlen); 2624 memcpy (&ret[1], addr, addrlen);
@@ -5780,11 +5784,69 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5780 GNUNET_break (bc_head == NULL); 5784 GNUNET_break (bc_head == NULL);
5781} 5785}
5782 5786
5787#if HAVE_LIBGLPK
5788static int ats_evaluate_results (int result, int solution, char * problem)
5789{
5790 int cont = GNUNET_NO;
5791 int error_kind = GNUNET_ERROR_TYPE_DEBUG;
5792#if DEBUG_ATS
5793 error_kind = GNUNET_ERROR_TYPE_ERROR;
5794#endif
5783 5795
5796 switch (result) {
5797 case GLP_ESTOP : /* search terminated by application */
5798 GNUNET_log (error_kind, "%s , Search terminated by application ", problem);
5799 break;
5800 case GLP_EITLIM : /* iteration limit exceeded */
5801 GNUNET_log (error_kind, "%s Iteration limit exceeded ", problem);
5802 break;
5803 break;
5804 case GLP_ETMLIM : /* time limit exceeded */
5805 GNUNET_log (error_kind, "%s Time limit exceeded ", problem);
5806 break;
5807 case GLP_ENOPFS : /* no primal feasible solution */
5808 case GLP_ENODFS : /* no dual feasible solution */
5809 GNUNET_log (error_kind, "%s No feasible solution", problem);
5810 break;
5784 5811
5785#define DEBUG_ATS GNUNET_NO 5812 case GLP_EBADB : /* invalid basis */
5786#define VERBOSE_ATS GNUNET_NO 5813 case GLP_ESING : /* singular matrix */
5814 case GLP_ECOND : /* ill-conditioned matrix */
5815 case GLP_EBOUND : /* invalid bounds */
5816 case GLP_EFAIL : /* solver failed */
5817 case GLP_EOBJLL : /* objective lower limit reached */
5818 case GLP_EOBJUL : /* objective upper limit reached */
5819 case GLP_EROOT : /* root LP optimum not provided */
5820 GNUNET_log (error_kind, "%s Invalid Input data: %i\n", problem, result);
5821 break;
5822
5823 case 0:
5824 GNUNET_log (error_kind, "%s Problem has been solved\n", problem);
5825 break;
5826 }
5787 5827
5828 switch (solution) {
5829 case GLP_UNDEF:
5830 GNUNET_log (error_kind, "%s solution is undefined\n", problem);
5831 break;
5832 case GLP_OPT:
5833 GNUNET_log (error_kind, "%s solution is optimal\n", problem);
5834 cont=GNUNET_YES;
5835 break;
5836 case GLP_FEAS:
5837 GNUNET_log (error_kind, "%s solution is integer feasible, however, its optimality (or non-optimality) has not been proven, \n", problem);
5838 cont=GNUNET_YES;
5839 break;
5840 case GLP_NOFEAS:
5841 GNUNET_log (error_kind, "%s problem has no integer feasible solution\n", problem);
5842 break;
5843 break;
5844 default:
5845 break;
5846 }
5847return cont;
5848}
5849#endif
5788 5850
5789/** solve the bandwidth distribution problem 5851/** solve the bandwidth distribution problem
5790 * @param max_it maximum iterations 5852 * @param max_it maximum iterations
@@ -5800,10 +5862,13 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5800static int ats_solve_problem (int max_it, int max_dur , double D, double U, double R, int v_b_min, int v_n_min, struct ATS_result *res) 5862static int ats_solve_problem (int max_it, int max_dur , double D, double U, double R, int v_b_min, int v_n_min, struct ATS_result *res)
5801{ 5863{
5802#if !HAVE_LIBGLPK 5864#if !HAVE_LIBGLPK
5803 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no glpk installed\n"); 5865 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no glpk installed\n");
5804 return GNUNET_SYSERR; 5866 return GNUNET_SYSERR;
5805#else 5867#else
5806 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "glpk installed\n"); 5868#if DEBUG_ATS
5869 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "glpk installed\n");
5870#endif
5871
5807 5872
5808 glp_prob *prob; 5873 glp_prob *prob;
5809 5874
@@ -5816,9 +5881,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5816 int c_c_ressources = available_ressources; 5881 int c_c_ressources = available_ressources;
5817 int c_q_metrics = available_quality_metrics; 5882 int c_q_metrics = available_quality_metrics;
5818 5883
5819 //double M = 10000000000; // ~10 GB 5884 double M = VERY_BIG_DOUBLE_VALUE;
5820 //double M = VERY_BIG_DOUBLE_VALUE;
5821 double M = 100000;
5822 double Q[c_q_metrics+1]; 5885 double Q[c_q_metrics+1];
5823 for (c=1; c<=c_q_metrics; c++) 5886 for (c=1; c<=c_q_metrics; c++)
5824 { 5887 {
@@ -5845,14 +5908,15 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5845 5908
5846 if (c_mechs==0) 5909 if (c_mechs==0)
5847 { 5910 {
5848 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No addresses for bw distribution available\n", c_peers); 5911#if DEBUG_ATS
5849 return 0; 5912 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No addresses for bw distribution available\n", c_peers);
5913#endif
5914 return GNUNET_SYSERR;
5850 } 5915 }
5851 5916
5852 struct ATS_mechanism * mechanisms = GNUNET_malloc((1+c_mechs) * sizeof (struct ATS_mechanism)); 5917 struct ATS_mechanism * mechanisms = GNUNET_malloc((1+c_mechs) * sizeof (struct ATS_mechanism));
5853 struct ATS_peer * peers = GNUNET_malloc((1+c_peers) * sizeof (struct ATS_peer)); 5918 struct ATS_peer * peers = GNUNET_malloc((1+c_peers) * sizeof (struct ATS_peer));
5854 5919
5855 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found mechanisms: %i\n", c_mechs);
5856 c_mechs = 1; 5920 c_mechs = 1;
5857 c_peers = 1; 5921 c_peers = 1;
5858 next = neighbours; 5922 next = neighbours;
@@ -5870,7 +5934,6 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5870 struct ForeignAddressList * a_next = r_next->addresses; 5934 struct ForeignAddressList * a_next = r_next->addresses;
5871 while (a_next != NULL) 5935 while (a_next != NULL)
5872 { 5936 {
5873 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%i Peer: `%s' plugin `%s' %x:\n", c_mechs, GNUNET_i2s(&next->id), r_next->plugin->short_name, a_next);
5874 mechanisms[c_mechs].addr = a_next; 5937 mechanisms[c_mechs].addr = a_next;
5875 mechanisms[c_mechs].col_index = c_mechs; 5938 mechanisms[c_mechs].col_index = c_mechs;
5876 mechanisms[c_mechs].peer = &peers[c_peers]; 5939 mechanisms[c_mechs].peer = &peers[c_peers];
@@ -5892,15 +5955,11 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5892 if (v_n_min > c_peers) 5955 if (v_n_min > c_peers)
5893 v_n_min = c_peers; 5956 v_n_min = c_peers;
5894 5957
5895 /* number of variables == coloumns */ 5958#if VERBOSE_ATS
5896 //int c_cols = 2 * c_mechs + 3 + c_q_metrics; 5959 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms, %i resource entries, %i quality metrics \n", c_peers, c_mechs, c_c_ressources, c_q_metrics);
5897 /* number of constraints == rows */ 5960#endif
5898 //int c_rows = 2 * c_peers + 2 * c_mechs + c_c_ressources + c_q_metrics + 3;
5899
5900 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms, %i resource entries, %i quality metrics \n", c_peers, c_mechs, c_c_ressources, c_q_metrics);
5901 5961
5902 int size = 1 + 3 + 10 *c_mechs + c_peers + (c_q_metrics*c_mechs)+ c_q_metrics + c_c_ressources * c_mechs ; 5962 int size = 1 + 3 + 10 *c_mechs + c_peers + (c_q_metrics*c_mechs)+ c_q_metrics + c_c_ressources * c_mechs ;
5903 //int size = 1 + 8 *c_mechs +2 + c_mechs + c_peers + (c_q_metrics*c_mechs)+c_q_metrics + c_c_ressources ;
5904 int row_index; 5963 int row_index;
5905 int array_index=1; 5964 int array_index=1;
5906 int * ia = GNUNET_malloc (size * sizeof (int)); 5965 int * ia = GNUNET_malloc (size * sizeof (int));
@@ -5937,7 +5996,6 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5937 5996
5938 /* feasibility constraints */ 5997 /* feasibility constraints */
5939 /* Constraint 1: one address per peer*/ 5998 /* Constraint 1: one address per peer*/
5940 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 1\n");
5941 row_index = 1; 5999 row_index = 1;
5942 glp_add_rows(prob, c_peers); 6000 glp_add_rows(prob, c_peers);
5943 for (c=1; c<=c_peers; c++) 6001 for (c=1; c<=c_peers; c++)
@@ -5950,7 +6008,9 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5950 ia[array_index] = row_index; 6008 ia[array_index] = row_index;
5951 ja[array_index] = (c_mechs + m->col_index); 6009 ja[array_index] = (c_mechs + m->col_index);
5952 ar[array_index] = 1; 6010 ar[array_index] = 1;
5953 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6011#if VERBOSE_ATS
6012 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6013#endif
5954 array_index++; 6014 array_index++;
5955 m = m->next; 6015 m = m->next;
5956 } 6016 }
@@ -5958,54 +6018,62 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5958 } 6018 }
5959 6019
5960 /* Constraint 2: only active mechanism gets bandwidth assigned */ 6020 /* Constraint 2: only active mechanism gets bandwidth assigned */
5961 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 2\n");
5962 glp_add_rows(prob, c_mechs); 6021 glp_add_rows(prob, c_mechs);
5963 for (c=1; c<=c_mechs; c++) 6022 for (c=1; c<=c_mechs; c++)
5964 { 6023 {
5965 /* b_t - n_t * M <= 0 */ 6024 /* b_t - n_t * M <= 0 */
5966 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); 6025#if VERBOSE_ATS
6026 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
6027#endif
5967 glp_set_row_bnds(prob, row_index, GLP_UP, 0.0, 0.0); 6028 glp_set_row_bnds(prob, row_index, GLP_UP, 0.0, 0.0);
5968 6029
5969 ia[array_index] = row_index; 6030 ia[array_index] = row_index;
5970 ja[array_index] = mechanisms[c].col_index; 6031 ja[array_index] = mechanisms[c].col_index;
5971 ar[array_index] = 1; 6032 ar[array_index] = 1;
5972 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6033#if VERBOSE_ATS
6034 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6035#endif
5973 array_index++; 6036 array_index++;
5974 ia[array_index] = row_index; 6037 ia[array_index] = row_index;
5975 ja[array_index] = c_mechs + mechanisms[c].col_index; 6038 ja[array_index] = c_mechs + mechanisms[c].col_index;
5976 ar[array_index] = -M; 6039 ar[array_index] = -M;
5977 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6040#if VERBOSE_ATS
6041 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6042#endif
5978 array_index++; 6043 array_index++;
5979 row_index ++; 6044 row_index ++;
5980 } 6045 }
5981 6046
5982 /* Constraint 3: minimum bandwidth*/ 6047 /* Constraint 3: minimum bandwidth*/
5983 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 3\n");
5984 glp_add_rows(prob, c_mechs); 6048 glp_add_rows(prob, c_mechs);
5985 for (c=1; c<=c_mechs; c++) 6049 for (c=1; c<=c_mechs; c++)
5986 { 6050 {
5987 /* b_t - n_t * b_min <= 0 */ 6051 /* b_t - n_t * b_min <= 0 */
5988 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); 6052#if VERBOSE_ATS
6053 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
6054#endif
5989 glp_set_row_bnds(prob, row_index, GLP_LO, 0.0, 0.0); 6055 glp_set_row_bnds(prob, row_index, GLP_LO, 0.0, 0.0);
5990 6056
5991 ia[array_index] = row_index; 6057 ia[array_index] = row_index;
5992 ja[array_index] = mechanisms[c].col_index; 6058 ja[array_index] = mechanisms[c].col_index;
5993 ar[array_index] = 1; 6059 ar[array_index] = 1;
5994 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6060#if VERBOSE_ATS
6061 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6062#endif
5995 array_index++; 6063 array_index++;
5996 ia[array_index] = row_index; 6064 ia[array_index] = row_index;
5997 ja[array_index] = c_mechs + mechanisms[c].col_index; 6065 ja[array_index] = c_mechs + mechanisms[c].col_index;
5998 ar[array_index] = -v_b_min; 6066 ar[array_index] = -v_b_min;
5999 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6067#if VERBOSE_ATS
6068 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6069#endif
6000 array_index++; 6070 array_index++;
6001 row_index ++; 6071 row_index ++;
6002 } 6072 }
6003 int c2; 6073 int c2;
6004 /* Constraint 4: max ressource capacity */ 6074 /* Constraint 4: max ressource capacity */
6005 /* V cr: bt * ct_r <= cr_max 6075 /* V cr: bt * ct_r <= cr_maxsolution
6006 * */ 6076 * */
6007
6008 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 4\n");
6009 glp_add_rows(prob, available_ressources); 6077 glp_add_rows(prob, available_ressources);
6010 double ct_max = VERY_BIG_DOUBLE_VALUE; 6078 double ct_max = VERY_BIG_DOUBLE_VALUE;
6011 double ct_min = 0.0; 6079 double ct_min = 0.0;
@@ -6014,7 +6082,9 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6014 { 6082 {
6015 ct_max = ressources[c].c_max; 6083 ct_max = ressources[c].c_max;
6016 ct_min = ressources[c].c_min; 6084 ct_min = ressources[c].c_min;
6017 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] %f..%f\n",row_index, ct_min, ct_max); 6085#if VERBOSE_ATS
6086 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] %f..%f\n",row_index, ct_min, ct_max);
6087#endif
6018 glp_set_row_bnds(prob, row_index, GLP_DB, ct_min, ct_max); 6088 glp_set_row_bnds(prob, row_index, GLP_DB, ct_min, ct_max);
6019 6089
6020 for (c2=1; c2<=c_mechs; c2++) 6090 for (c2=1; c2<=c_mechs; c2++)
@@ -6024,25 +6094,30 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6024 ja[array_index] = c2; 6094 ja[array_index] = c2;
6025 value = mechanisms[c2].addr->ressources[c].c; 6095 value = mechanisms[c2].addr->ressources[c].c;
6026 ar[array_index] = value; 6096 ar[array_index] = value;
6027 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6097#if VERBOSE_ATS
6098 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6099#endif
6028 array_index++; 6100 array_index++;
6029 } 6101 }
6030 row_index ++; 6102 row_index ++;
6031 } 6103 }
6032 6104
6033 /* Constraint 5: min number of connections*/ 6105 /* Constraint 5: min number of connections*/
6034 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 5\n");
6035 glp_add_rows(prob, 1); 6106 glp_add_rows(prob, 1);
6036 for (c=1; c<=c_mechs; c++) 6107 for (c=1; c<=c_mechs; c++)
6037 { 6108 {
6038 // b_t - n_t * b_min >= 0 6109 // b_t - n_t * b_min >= 0
6039 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); 6110#if VERBOSE_ATS
6111 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
6112#endif
6040 glp_set_row_bnds(prob, row_index, GLP_LO, v_n_min, 0.0); 6113 glp_set_row_bnds(prob, row_index, GLP_LO, v_n_min, 0.0);
6041 6114
6042 ia[array_index] = row_index; 6115 ia[array_index] = row_index;
6043 ja[array_index] = c_mechs + mechanisms[c].col_index; 6116 ja[array_index] = c_mechs + mechanisms[c].col_index;
6044 ar[array_index] = 1; 6117 ar[array_index] = 1;
6045 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6118#if VERBOSE_ATS
6119 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6120#endif
6046 array_index++; 6121 array_index++;
6047 } 6122 }
6048 row_index ++; 6123 row_index ++;
@@ -6072,35 +6147,39 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6072 } 6147 }
6073 6148
6074 // Constraint 6: optimize for diversity 6149 // Constraint 6: optimize for diversity
6075 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 6\n");
6076 glp_add_rows(prob, 1); 6150 glp_add_rows(prob, 1);
6077 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); 6151#if VERBOSE_ATS
6152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
6153#endif
6078 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0); 6154 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0);
6079 //glp_set_row_bnds(prob, row_index, GLP_UP, 0.0, 0.0);
6080 for (c=1; c<=c_mechs; c++) 6155 for (c=1; c<=c_mechs; c++)
6081 { 6156 {
6082 // b_t - n_t * b_min >= 0 6157 // b_t - n_t * b_min >= 0
6083 ia[array_index] = row_index; 6158 ia[array_index] = row_index;
6084 ja[array_index] = c_mechs + mechanisms[c].col_index; 6159 ja[array_index] = c_mechs + mechanisms[c].col_index;
6085 ar[array_index] = 1; 6160 ar[array_index] = 1;
6086 //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6161#if VERBOSE_ATS
6162 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6163#endif
6087 array_index++; 6164 array_index++;
6088 } 6165 }
6089 ia[array_index] = row_index; 6166 ia[array_index] = row_index;
6090 ja[array_index] = (2*c_mechs) + 1; 6167 ja[array_index] = (2*c_mechs) + 1;
6091 ar[array_index] = -1; 6168 ar[array_index] = -1;
6092 //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6169#if VERBOSE_ATS
6170 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6171#endif
6093 array_index++; 6172 array_index++;
6094 row_index ++; 6173 row_index ++;
6095 6174
6096 6175
6097 // Constraint 7: optimize for quality 6176 // Constraint 7: optimize for quality
6098
6099 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 7\n");
6100 glp_add_rows(prob, available_quality_metrics); 6177 glp_add_rows(prob, available_quality_metrics);
6101 for (c=1; c <= c_q_metrics; c++) 6178 for (c=1; c <= c_q_metrics; c++)
6102 { 6179 {
6103 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); 6180#if VERBOSE_ATS
6181 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
6182#endif
6104 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0); 6183 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0);
6105 6184
6106 for (c2=1; c2<=c_mechs; c2++) 6185 for (c2=1; c2<=c_mechs; c2++)
@@ -6133,32 +6212,38 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6133 value = (double) 10 / value; 6212 value = (double) 10 / value;
6134 else 6213 else
6135 value = 10; 6214 value = 10;
6136 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DISTANCE VALUE %f\n",value);
6137 } 6215 }
6138 ar[array_index] = (mechanisms[c2].peer->f) * value ; 6216 ar[array_index] = (mechanisms[c2].peer->f) * value ;
6139 //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",array_index, qm[c-1].name, ia[array_index], ja[array_index], ar[array_index]); 6217#if VERBOSE_ATS
6218 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",array_index, qm[c-1].name, ia[array_index], ja[array_index], ar[array_index]);
6219#endif
6140 array_index++; 6220 array_index++;
6141 } 6221 }
6142 6222
6143 ia[array_index] = row_index; 6223 ia[array_index] = row_index;
6144 ja[array_index] = (2*c_mechs) + 3 +c; 6224 ja[array_index] = (2*c_mechs) + 3 +c;
6145 ar[array_index] = -1; 6225 ar[array_index] = -1;
6146 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6226#if VERBOSE_ATS
6227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6228#endif
6147 array_index++; 6229 array_index++;
6148 row_index++; 6230 row_index++;
6149 } 6231 }
6150 6232
6151 // Constraint 8: optimize bandwidth utility 6233 // Constraint 8: optimize bandwidth utility
6152 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 8\n");
6153 glp_add_rows(prob, 1); 6234 glp_add_rows(prob, 1);
6154 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); 6235#if VERBOSE_ATS
6236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
6237#endif
6155 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0); 6238 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0);
6156 for (c=1; c<=c_mechs; c++) 6239 for (c=1; c<=c_mechs; c++)
6157 { 6240 {
6158 ia[array_index] = row_index; 6241 ia[array_index] = row_index;
6159 ja[array_index] = c; 6242 ja[array_index] = c;
6160 ar[array_index] = mechanisms[c].peer->f; 6243 ar[array_index] = mechanisms[c].peer->f;
6161 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6244#if VERBOSE_ATS
6245 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6246#endif
6162 array_index++; 6247 array_index++;
6163 } 6248 }
6164 ia[array_index] = row_index; 6249 ia[array_index] = row_index;
@@ -6172,7 +6257,6 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6172 row_index ++; 6257 row_index ++;
6173 6258
6174 // Constraint 9: optimize relativity 6259 // Constraint 9: optimize relativity
6175 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 9\n");
6176 glp_add_rows(prob, c_peers); 6260 glp_add_rows(prob, c_peers);
6177 for (c=1; c<=c_peers; c++) 6261 for (c=1; c<=c_peers; c++)
6178 { 6262 {
@@ -6184,41 +6268,56 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6184 ia[array_index] = row_index; 6268 ia[array_index] = row_index;
6185 ja[array_index] = m->col_index; 6269 ja[array_index] = m->col_index;
6186 ar[array_index] = 1; 6270 ar[array_index] = 1;
6187 //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6271#if VERBOSE_ATS
6272 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6273#endif
6188 array_index++; 6274 array_index++;
6189 m = m->next; 6275 m = m->next;
6190 } 6276 }
6191 ia[array_index] = row_index; 6277 ia[array_index] = row_index;
6192 ja[array_index] = (2*c_mechs) + 3; 6278 ja[array_index] = (2*c_mechs) + 3;
6193 ar[array_index] = -1; 6279 ar[array_index] = -1;
6194 //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 6280#if VERBOSE_ATS
6281 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
6282#endif
6195 array_index++; 6283 array_index++;
6196 6284
6197 row_index++; 6285 row_index++;
6198 } 6286 }
6287 /* Loading the matrix */
6199 glp_load_matrix(prob, array_index-1, ia, ja, ar); 6288 glp_load_matrix(prob, array_index-1, ia, ja, ar);
6200 6289
6290 /* Solving simplex */
6201 glp_smcp opt_lp; 6291 glp_smcp opt_lp;
6202 glp_init_smcp(&opt_lp); 6292 glp_init_smcp(&opt_lp);
6203 if (VERBOSE_ATS) 6293
6294
6295#if VERBOSE_ATS
6204 opt_lp.msg_lev = GLP_MSG_ALL; 6296 opt_lp.msg_lev = GLP_MSG_ALL;
6205 else 6297#else
6206 opt_lp.msg_lev = GLP_MSG_OFF; 6298 opt_lp.msg_lev = GLP_MSG_OFF;
6299#endif
6207 result = glp_simplex(prob, &opt_lp); 6300 result = glp_simplex(prob, &opt_lp);
6301 solution = glp_get_status (prob);
6208 6302
6209 glp_iocp opt_mlp; 6303 if (GNUNET_YES == ats_evaluate_results(result, solution, "LP"))
6210 glp_init_iocp(&opt_mlp); 6304 {
6211 /* maximum duration */ 6305 /* Solving mlp */
6212 opt_mlp.tm_lim = max_dur; 6306 glp_iocp opt_mlp;
6213 /* output level */ 6307 glp_init_iocp(&opt_mlp);
6214 if (VERBOSE_ATS) 6308 /* maximum duration */
6215 opt_mlp.msg_lev = GLP_MSG_ALL; 6309 opt_mlp.tm_lim = max_dur;
6216 else 6310 /* output level */
6217 opt_mlp.msg_lev = GLP_MSG_OFF; 6311#if VERBOSE_ATS
6218 6312 opt_mlp.msg_lev = GLP_MSG_ALL;
6219 result = glp_intopt (prob, &opt_mlp); 6313#else
6220 solution = glp_mip_status (prob); 6314 opt_mlp.msg_lev = GLP_MSG_OFF;
6221 6315#endif
6316 result = glp_intopt (prob, &opt_mlp);
6317 solution = glp_mip_status (prob);
6318 ats_evaluate_results(result, solution, "MLP");
6319 /* done */
6320 }
6222#if WRITE_MLP 6321#if WRITE_MLP
6223 if (c_peers > 1) 6322 if (c_peers > 1)
6224 { 6323 {
@@ -6230,61 +6329,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6230 GNUNET_free (filename); 6329 GNUNET_free (filename);
6231 } 6330 }
6232#endif 6331#endif
6233#if VERBOSE_ATS
6234
6235
6236
6237 switch (result) {
6238 case GLP_ESTOP : /* search terminated by application */
6239 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Search terminated by application ");
6240 break;
6241 case GLP_EITLIM : /* iteration limit exceeded */
6242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Iteration limit exceeded ");
6243 break;
6244 break;
6245 case GLP_ETMLIM : /* time limit exceeded */
6246 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Time limit exceeded ");
6247 break;
6248 case GLP_ENOPFS : /* no primal feasible solution */
6249 case GLP_ENODFS : /* no dual feasible solution */
6250 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No feasible solution");
6251 break;
6252
6253 case GLP_EBADB : /* invalid basis */
6254 case GLP_ESING : /* singular matrix */
6255 case GLP_ECOND : /* ill-conditioned matrix */
6256 case GLP_EBOUND : /* invalid bounds */
6257 case GLP_EFAIL : /* solver failed */
6258 case GLP_EOBJLL : /* objective lower limit reached */
6259 case GLP_EOBJUL : /* objective upper limit reached */
6260 case GLP_EROOT : /* root LP optimum not provided */
6261 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid Input data: %i\n", result);
6262 break;
6263
6264 break;
6265 default:
6266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem has been solved\n");
6267 break;
6268 }
6269 6332
6270 switch (solution) {
6271 case GLP_UNDEF:
6272 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MIP solution is undefined\n");
6273 break;
6274 case GLP_OPT:
6275 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MIP solution is integer optimal\n");
6276 break;
6277 case GLP_FEAS:
6278 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MIP solution is integer feasible, however, its optimality (or non-optimality) has not been proven, \n");
6279 break;
6280 case GLP_NOFEAS:
6281 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MI problem has no integer feasible solution\n");
6282 break;
6283 break;
6284 default:
6285 break;
6286 }
6287#endif
6288 int check; 6333 int check;
6289 int error = GNUNET_NO; 6334 int error = GNUNET_NO;
6290 double bw; 6335 double bw;
@@ -6298,7 +6343,9 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6298 bw = glp_get_col_prim(prob, t->col_index); 6343 bw = glp_get_col_prim(prob, t->col_index);
6299 if (bw > 1.0) 6344 if (bw > 1.0)
6300 { 6345 {
6301 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[%i][%i] `%s' %s %s %f\n", c, t->col_index, GNUNET_h2s(&peers[c].peer.hashPubKey), t->plugin->short_name, glp_get_col_name(prob,t->col_index), bw); 6346#if VERBOSE_ATS
6347 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[%i][%i] `%s' %s %s %f\n", c, t->col_index, GNUNET_h2s(&peers[c].peer.hashPubKey), t->plugin->short_name, glp_get_col_name(prob,t->col_index), bw);
6348#endif
6302 if (check ==GNUNET_YES) 6349 if (check ==GNUNET_YES)
6303 { 6350 {
6304 glp_write_sol(prob, "invalid_solution.mlp"); 6351 glp_write_sol(prob, "invalid_solution.mlp");
@@ -6313,21 +6360,23 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6313 } 6360 }
6314 } 6361 }
6315 6362
6363#if VERBOSE_ATS
6316 for (c=1; c<= c_q_metrics; c++ ) 6364 for (c=1; c<= c_q_metrics; c++ )
6317 { 6365 {
6318 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+3+c), glp_get_col_prim(prob,2*c_mechs+3+c));
6319 }
6320 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+1), glp_get_col_prim(prob,2*c_mechs+1));
6321 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+2), glp_get_col_prim(prob,2*c_mechs+2));
6322 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+3), glp_get_col_prim(prob,2*c_mechs+3));
6323 6366
6367 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+3+c), glp_get_col_prim(prob,2*c_mechs+3+c));
6368
6369 }
6370 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+1), glp_get_col_prim(prob,2*c_mechs+1));
6371 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+2), glp_get_col_prim(prob,2*c_mechs+2));
6372 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+3), glp_get_col_prim(prob,2*c_mechs+3));
6373#endif
6324 res->c_mechs = c_mechs; 6374 res->c_mechs = c_mechs;
6325 res->c_peers = c_peers; 6375 res->c_peers = c_peers;
6326 res->solution = solution; 6376 res->solution = solution;
6327 6377
6328 /* clean up */ 6378 /* clean up */
6329 6379
6330
6331 glp_delete_prob(prob); 6380 glp_delete_prob(prob);
6332 6381
6333 GNUNET_free (ja); 6382 GNUNET_free (ja);
@@ -6335,9 +6384,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6335 GNUNET_free (ar); 6384 GNUNET_free (ar);
6336 6385
6337 for (c=0; c<c_mechs; c++) 6386 for (c=0; c<c_mechs; c++)
6338 {
6339 GNUNET_free_non_null (mechanisms[c].rc); 6387 GNUNET_free_non_null (mechanisms[c].rc);
6340 }
6341 6388
6342 GNUNET_free(mechanisms); 6389 GNUNET_free(mechanisms);
6343 GNUNET_free(peers); 6390 GNUNET_free(peers);
@@ -6348,7 +6395,6 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6348 6395
6349void ats_calculate_bandwidth_distribution () 6396void ats_calculate_bandwidth_distribution ()
6350{ 6397{
6351 static int glpk = GNUNET_YES;
6352 struct GNUNET_TIME_Absolute start; 6398 struct GNUNET_TIME_Absolute start;
6353 struct GNUNET_TIME_Relative duration; 6399 struct GNUNET_TIME_Relative duration;
6354 struct ATS_result result; 6400 struct ATS_result result;
@@ -6358,7 +6404,7 @@ void ats_calculate_bandwidth_distribution ()
6358 if (delta.rel_value < ats->min_delta.rel_value) 6404 if (delta.rel_value < ats->min_delta.rel_value)
6359 { 6405 {
6360#if DEBUG_ATS 6406#if DEBUG_ATS
6361 //GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n"); 6407 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n");
6362#endif 6408#endif
6363 return; 6409 return;
6364 } 6410 }
@@ -6370,28 +6416,26 @@ void ats_calculate_bandwidth_distribution ()
6370 dur = (int) ats->max_exec_duration.rel_value; 6416 dur = (int) ats->max_exec_duration.rel_value;
6371 6417
6372 start = GNUNET_TIME_absolute_get(); 6418 start = GNUNET_TIME_absolute_get();
6419 c_mechs = ats_solve_problem(5000, 5000, 1.0, 1.0, 1.0, 1000, 5, &result);
6420 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
6373 6421
6374 if (glpk==GNUNET_YES) 6422 if (c_mechs > 0)
6375 { 6423 {
6376 start = GNUNET_TIME_absolute_get(); 6424#if DEBUG_ATS
6377 c_mechs = ats_solve_problem(5000, 5000, 1.0, 1.0, 1.0, 1000, 5, &result); 6425 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value);
6378 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); 6426#endif
6379 6427 GNUNET_STATISTICS_set (stats, "ATS duration", duration.rel_value, GNUNET_NO);
6380 if (c_mechs > 0) 6428 GNUNET_STATISTICS_set (stats, "ATS mechanisms", result.c_mechs, GNUNET_NO);
6381 { 6429 GNUNET_STATISTICS_set (stats, "ATS peers", result.c_peers, GNUNET_NO);
6382 if (DEBUG_ATS) {GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value);} 6430 GNUNET_STATISTICS_set (stats, "ATS solution", result.solution, GNUNET_NO);
6383 GNUNET_STATISTICS_set (stats, "ATS duration", duration.rel_value, GNUNET_NO); 6431 GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO);
6384 GNUNET_STATISTICS_set (stats, "ATS mechanisms", result.c_mechs, GNUNET_NO); 6432 }
6385 GNUNET_STATISTICS_set (stats, "ATS peers", result.c_peers, GNUNET_NO); 6433#if DEBUG_ATS
6386 GNUNET_STATISTICS_set (stats, "ATS solution", result.solution, GNUNET_NO); 6434 else if (c_mechs == 0)
6387 GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO); 6435 {
6388 } 6436 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n");
6389 else if (c_mechs == 0)
6390 {
6391 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n");
6392 }
6393 else glpk = GNUNET_NO;
6394 } 6437 }
6438#endif
6395 ats->last = GNUNET_TIME_absolute_get(); 6439 ats->last = GNUNET_TIME_absolute_get();
6396} 6440}
6397 6441
@@ -6412,6 +6456,7 @@ ats_schedule_calculation (void *cls,
6412#if DEBUG_ATS 6456#if DEBUG_ATS
6413 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Running scheduled calculation\n"); 6457 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Running scheduled calculation\n");
6414#endif 6458#endif
6459
6415 ats_calculate_bandwidth_distribution (ats); 6460 ats_calculate_bandwidth_distribution (ats);
6416 6461
6417 ats->ats_task = GNUNET_SCHEDULER_add_delayed (ats->exec_intervall, 6462 ats->ats_task = GNUNET_SCHEDULER_add_delayed (ats->exec_intervall,
@@ -6428,6 +6473,12 @@ void ats_init ()
6428 ats->max_iterations = ATS_MAX_ITERATIONS; 6473 ats->max_iterations = ATS_MAX_ITERATIONS;
6429 ats->ats_task = GNUNET_SCHEDULER_NO_TASK; 6474 ats->ats_task = GNUNET_SCHEDULER_NO_TASK;
6430 6475
6476#if !HAVE_LIBGLPK
6477 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, ATS not active");
6478 return;
6479#endif
6480
6481
6431 int c = 0; 6482 int c = 0;
6432 unsigned long long value; 6483 unsigned long long value;
6433 char * section; 6484 char * section;
@@ -6437,17 +6488,25 @@ void ats_init ()
6437 GNUNET_asprintf(&section,"%s_UP",ressources[c].cfg_param); 6488 GNUNET_asprintf(&section,"%s_UP",ressources[c].cfg_param);
6438 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", section)) 6489 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", section))
6439 { 6490 {
6440 GNUNET_CONFIGURATION_get_value_number(cfg, "transport",section, &value); 6491 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "transport",section, &value))
6441 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found ressource cost: [%s] = %llu\n", section, value); 6492 {
6442 ressources[c].c_max = value; 6493#if DEBUG_ATS
6494 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found ressource cost: [%s] = %llu\n", section, value);
6495#endif
6496 ressources[c].c_max = value;
6497 }
6443 } 6498 }
6444 GNUNET_free (section); 6499 GNUNET_free (section);
6445 GNUNET_asprintf(&section,"%s_DOWN",ressources[c].cfg_param); 6500 GNUNET_asprintf(&section,"%s_DOWN",ressources[c].cfg_param);
6446 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", section)) 6501 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", section))
6447 { 6502 {
6448 GNUNET_CONFIGURATION_get_value_number(cfg, "transport",section, &value); 6503 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "transport",section, &value))
6449 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found ressource cost: [%s] = %llu\n", section, value); 6504 {
6450 ressources[c].c_min = value; 6505#if DEBUG_ATS
6506 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found ressource cost: [%s] = %llu\n", section, value);
6507#endif
6508 ressources[c].c_min = value;
6509 }
6451 } 6510 }
6452 GNUNET_free (section); 6511 GNUNET_free (section);
6453 } 6512 }