diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-13 16:13:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-13 16:13:53 +0000 |
commit | 47f30b90cf1f18ac682b6fd3a8c9585811368ee9 (patch) | |
tree | 890943328df8ede8d553e6072fc3196554b560b1 /src/transport | |
parent | c8048958a43ce41ca611580111164ae2ca73f9aa (diff) | |
download | gnunet-47f30b90cf1f18ac682b6fd3a8c9585811368ee9.tar.gz gnunet-47f30b90cf1f18ac682b6fd3a8c9585811368ee9.zip |
quality and ressource updates
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 228 |
1 files changed, 161 insertions, 67 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 3b30b6096..7a2d1a647 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -1120,14 +1120,16 @@ static void ats_shutdown ( ); | |||
1120 | 1120 | ||
1121 | static void ats_notify_peer_connect ( | 1121 | static void ats_notify_peer_connect ( |
1122 | const struct GNUNET_PeerIdentity *peer, | 1122 | const struct GNUNET_PeerIdentity *peer, |
1123 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); | 1123 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data, int ats_count); |
1124 | 1124 | ||
1125 | static void ats_notify_peer_disconnect ( | 1125 | static void ats_notify_peer_disconnect ( |
1126 | const struct GNUNET_PeerIdentity *peer); | 1126 | const struct GNUNET_PeerIdentity *peer); |
1127 | 1127 | ||
1128 | #if 0 | ||
1128 | static void ats_notify_ats_data ( | 1129 | static void ats_notify_ats_data ( |
1129 | const struct GNUNET_PeerIdentity *peer, | 1130 | const struct GNUNET_PeerIdentity *peer, |
1130 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); | 1131 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); |
1132 | #endif | ||
1131 | 1133 | ||
1132 | struct ForeignAddressList * ats_get_preferred_address ( | 1134 | struct ForeignAddressList * ats_get_preferred_address ( |
1133 | struct NeighbourList *n); | 1135 | struct NeighbourList *n); |
@@ -1151,39 +1153,6 @@ find_neighbour (const struct GNUNET_PeerIdentity *key) | |||
1151 | return head; | 1153 | return head; |
1152 | } | 1154 | } |
1153 | 1155 | ||
1154 | static int update_addr_ats (struct ForeignAddressList *fal, const struct GNUNET_TRANSPORT_ATS_Information *ats_data, int ats_count) | ||
1155 | { | ||
1156 | int c1, c2, set; | ||
1157 | set = GNUNET_NO; | ||
1158 | for (c1=0; c1<ats_count; c1++) | ||
1159 | { | ||
1160 | for (c2=0; c2<available_quality_metrics; c2++) | ||
1161 | { | ||
1162 | if (ntohl(ats_data[c1].type) == qm[c2].atis_index) | ||
1163 | { | ||
1164 | /* shifting history */ | ||
1165 | // fal->quality[c2].values[0] = fal->quality[c2].values[1]; | ||
1166 | // fal->quality[c2].values[1] = fal->quality[c2].values[2]; | ||
1167 | /* setting latest value */ | ||
1168 | // fal->quality[c2].values[2] = ntohl(ats_data[c1].value); | ||
1169 | // set = GNUNET_YES; | ||
1170 | } | ||
1171 | } | ||
1172 | if (set == GNUNET_NO) | ||
1173 | { | ||
1174 | for (c2=0; c2<available_ressources; c2++) | ||
1175 | { | ||
1176 | if (ntohl(ats_data[c1].type) == ressources[c2].atis_index) | ||
1177 | { | ||
1178 | //fal->ressources[c2].c = ntohl(ats_data[c1].value); | ||
1179 | //set = GNUNET_YES; | ||
1180 | } | ||
1181 | } | ||
1182 | } | ||
1183 | } | ||
1184 | return set; | ||
1185 | } | ||
1186 | |||
1187 | static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , int ats_index) | 1156 | static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , int ats_index) |
1188 | { | 1157 | { |
1189 | int c; | 1158 | int c; |
@@ -1192,10 +1161,11 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i | |||
1192 | { | 1161 | { |
1193 | if (ats_index == qm[c].atis_index) | 1162 | if (ats_index == qm[c].atis_index) |
1194 | { | 1163 | { |
1195 | // fal->quality[c].values[0] = fal->quality[c].values[1]; | 1164 | fal->quality[c].values[0] = fal->quality[c].values[1]; |
1196 | // fal->quality[c].values[1] = fal->quality[c].values[2]; | 1165 | fal->quality[c].values[1] = fal->quality[c].values[2]; |
1197 | // fal->quality[c].values[2] = value; | 1166 | fal->quality[c].values[2] = value; |
1198 | set = GNUNET_YES; | 1167 | set = GNUNET_YES; |
1168 | ats->modified_quality = GNUNET_YES; | ||
1199 | } | 1169 | } |
1200 | } | 1170 | } |
1201 | if (set == GNUNET_NO) | 1171 | if (set == GNUNET_NO) |
@@ -1204,8 +1174,9 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i | |||
1204 | { | 1174 | { |
1205 | if (ats_index == ressources[c].atis_index) | 1175 | if (ats_index == ressources[c].atis_index) |
1206 | { | 1176 | { |
1207 | // fal->ressources[c].c = value; | 1177 | fal->ressources[c].c = value; |
1208 | // set = GNUNET_YES; | 1178 | set = GNUNET_YES; |
1179 | ats->modified_resources = GNUNET_YES; | ||
1209 | } | 1180 | } |
1210 | } | 1181 | } |
1211 | } | 1182 | } |
@@ -1213,6 +1184,17 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i | |||
1213 | return set; | 1184 | return set; |
1214 | } | 1185 | } |
1215 | 1186 | ||
1187 | static int update_addr_ats (struct ForeignAddressList *fal, const struct GNUNET_TRANSPORT_ATS_Information *ats_data, int ats_count) | ||
1188 | { | ||
1189 | int c1, set; | ||
1190 | set = GNUNET_NO; | ||
1191 | for (c1=0; c1<ats_count; c1++) | ||
1192 | { | ||
1193 | set = update_addr_value(fal, ntohl(ats_data[c1].value), ntohl(ats_data[c1].type)); | ||
1194 | } | ||
1195 | return set; | ||
1196 | } | ||
1197 | |||
1216 | /** | 1198 | /** |
1217 | * Find an entry in the transport list for a particular transport. | 1199 | * Find an entry in the transport list for a particular transport. |
1218 | * | 1200 | * |
@@ -2553,7 +2535,7 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, | |||
2553 | memcpy (&cim->id, peer, sizeof (struct GNUNET_PeerIdentity)); | 2535 | memcpy (&cim->id, peer, sizeof (struct GNUNET_PeerIdentity)); |
2554 | 2536 | ||
2555 | /* notify ats about connecting peer */ | 2537 | /* notify ats about connecting peer */ |
2556 | ats_notify_peer_connect (peer, &(cim->ats)); | 2538 | ats_notify_peer_connect (peer, &(cim->ats), 2); |
2557 | 2539 | ||
2558 | cpos = clients; | 2540 | cpos = clients; |
2559 | while (cpos != NULL) | 2541 | while (cpos != NULL) |
@@ -5924,7 +5906,6 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
5924 | { | 5906 | { |
5925 | int result; | 5907 | int result; |
5926 | int solution; | 5908 | int solution; |
5927 | int c; | ||
5928 | 5909 | ||
5929 | // Solving simplex | 5910 | // Solving simplex |
5930 | glp_prob *prob = ats->prob; | 5911 | glp_prob *prob = ats->prob; |
@@ -5932,9 +5913,9 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
5932 | glp_smcp opt_lp; | 5913 | glp_smcp opt_lp; |
5933 | glp_init_smcp(&opt_lp); | 5914 | glp_init_smcp(&opt_lp); |
5934 | 5915 | ||
5935 | opt_lp.msg_lev = GLP_MSG_ALL; | ||
5936 | #if VERBOSE_ATS | 5916 | #if VERBOSE_ATS |
5937 | #else | 5917 | opt_lp.msg_lev = GLP_MSG_ALL; |
5918 | #else | ||
5938 | opt_lp.msg_lev = GLP_MSG_OFF; | 5919 | opt_lp.msg_lev = GLP_MSG_OFF; |
5939 | #endif | 5920 | #endif |
5940 | //opt_lp.presolve = GLP_ON; | 5921 | //opt_lp.presolve = GLP_ON; |
@@ -5950,10 +5931,9 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
5950 | //opt_mlp.presolve = GLP_ON; | 5931 | //opt_mlp.presolve = GLP_ON; |
5951 | opt_mlp.tm_lim = max_dur; | 5932 | opt_mlp.tm_lim = max_dur; |
5952 | /* output level */ | 5933 | /* output level */ |
5953 | |||
5954 | opt_mlp.msg_lev = GLP_MSG_ALL; | ||
5955 | #if VERBOSE_ATS | 5934 | #if VERBOSE_ATS |
5956 | #else | 5935 | opt_mlp.msg_lev = GLP_MSG_ALL; |
5936 | #else | ||
5957 | opt_mlp.msg_lev = GLP_MSG_OFF; | 5937 | opt_mlp.msg_lev = GLP_MSG_OFF; |
5958 | #endif | 5938 | #endif |
5959 | result = glp_intopt (prob, &opt_mlp); | 5939 | result = glp_intopt (prob, &opt_mlp); |
@@ -5968,7 +5948,7 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
5968 | if ((ats->save_mlp == GNUNET_YES) && (c_peers > 1)) | 5948 | if ((ats->save_mlp == GNUNET_YES) && (c_peers > 1)) |
5969 | { | 5949 | { |
5970 | char * filename; | 5950 | char * filename; |
5971 | GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_llu.mlp",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value); | 5951 | GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value); |
5972 | //if (GNUNET_NO == GNUNET_DISK_file_test(filename)) | 5952 | //if (GNUNET_NO == GNUNET_DISK_file_test(filename)) |
5973 | glp_write_lp (prob, NULL, filename); | 5953 | glp_write_lp (prob, NULL, filename); |
5974 | GNUNET_free (filename); | 5954 | GNUNET_free (filename); |
@@ -5976,7 +5956,7 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
5976 | if ((ats->save_solution == GNUNET_YES) && (c_peers > 1)) | 5956 | if ((ats->save_solution == GNUNET_YES) && (c_peers > 1)) |
5977 | { | 5957 | { |
5978 | char * filename; | 5958 | char * filename; |
5979 | GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_llu.sol",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value); | 5959 | GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value); |
5980 | //if (GNUNET_NO == GNUNET_DISK_file_test(filename)) | 5960 | //if (GNUNET_NO == GNUNET_DISK_file_test(filename)) |
5981 | glp_print_sol (prob, filename); | 5961 | glp_print_sol (prob, filename); |
5982 | GNUNET_free (filename); | 5962 | GNUNET_free (filename); |
@@ -6014,6 +5994,9 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
6014 | }*/ | 5994 | }*/ |
6015 | 5995 | ||
6016 | #if VERBOSE_ATS | 5996 | #if VERBOSE_ATS |
5997 | if (glp_get_col_prim(prob,2*c_mechs+1) != 1) | ||
5998 | { | ||
5999 | int c; | ||
6017 | for (c=1; c<= available_quality_metrics; c++ ) | 6000 | for (c=1; c<= available_quality_metrics; c++ ) |
6018 | { | 6001 | { |
6019 | 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)); | 6002 | 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)); |
@@ -6021,6 +6004,8 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
6021 | 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)); | 6004 | 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)); |
6022 | 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)); | 6005 | 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)); |
6023 | 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)); | 6006 | 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)); |
6007 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "objective value: %f\n", glp_mip_obj_val(ats->prob)); | ||
6008 | } | ||
6024 | #endif | 6009 | #endif |
6025 | } | 6010 | } |
6026 | 6011 | ||
@@ -6058,9 +6043,125 @@ static void ats_delete_problem () | |||
6058 | ats->res.valid = GNUNET_SYSERR; | 6043 | ats->res.valid = GNUNET_SYSERR; |
6059 | } | 6044 | } |
6060 | 6045 | ||
6061 | static void ats_update_problem () | 6046 | static void ats_update_problem_qm () |
6062 | { | 6047 | { |
6048 | int array_index; | ||
6049 | int row_index; | ||
6050 | int c, c2; | ||
6051 | int c_q_metrics = available_quality_metrics; | ||
6052 | |||
6053 | int *ja = GNUNET_malloc ((1 + ats->res.c_mechs*2 + 3 + available_quality_metrics) * sizeof (int)); | ||
6054 | double *ar = GNUNET_malloc ((1 + ats->res.c_mechs*2 + 3 + available_quality_metrics) * sizeof (double)); | ||
6055 | if (ats->res.c_mechs>10) | ||
6056 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); | ||
6057 | row_index = ats->res.begin_qm; | ||
6058 | |||
6059 | for (c=1; c <= c_q_metrics; c++) | ||
6060 | { | ||
6061 | array_index = 1; | ||
6062 | double value = 1; | ||
6063 | #if VERBOSE_ATS | ||
6064 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); | ||
6065 | #endif | ||
6066 | |||
6067 | glp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0); | ||
6068 | for (c2=1; c2<=ats->res.c_mechs; c2++) | ||
6069 | { | ||
6070 | ja[array_index] = c2; | ||
6063 | 6071 | ||
6072 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) | ||
6073 | { | ||
6074 | double v0, v1, v2; | ||
6075 | v0 = ats->mechanisms[c2].addr->quality[c-1].values[0]; | ||
6076 | if (v1 < 1) v0 = 0.1; | ||
6077 | v1 = ats->mechanisms[c2].addr->quality[c-1].values[1]; | ||
6078 | if (v1 < 1) v0 = 0.1; | ||
6079 | v2 = ats->mechanisms[c2].addr->quality[c-1].values[2]; | ||
6080 | if (v1 < 1) v0 = 0.1; | ||
6081 | value = 100.0 / ((v0 + 2 * v1 + 3 * v2) / 6.0); | ||
6082 | //value = 1; | ||
6083 | } | ||
6084 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) | ||
6085 | { | ||
6086 | double v0, v1, v2; | ||
6087 | v0 = ats->mechanisms[c2].addr->quality[c-1].values[0]; | ||
6088 | if (v0 < 1) v0 = 1; | ||
6089 | v1 = ats->mechanisms[c2].addr->quality[c-1].values[1]; | ||
6090 | if (v1 < 1) v1 = 1; | ||
6091 | v2 = ats->mechanisms[c2].addr->quality[c-1].values[2]; | ||
6092 | if (v2 < 1) v2 = 1; | ||
6093 | value = (v0 + 2 * v1 + 3 * v2) / 6.0; | ||
6094 | if (value >= 1) | ||
6095 | value = (double) 10 / value; | ||
6096 | else | ||
6097 | value = 10; | ||
6098 | } | ||
6099 | ar[array_index] = (ats->mechanisms[c2].peer->f) * value; | ||
6100 | #if VERBOSE_ATS | ||
6101 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",array_index, qm[c-1].name, row_index, ja[array_index], ar[array_index]); | ||
6102 | #endif | ||
6103 | array_index++; | ||
6104 | } | ||
6105 | ja[array_index] = (2*ats->res.c_mechs) + 3 +c; | ||
6106 | ar[array_index] = -1; | ||
6107 | |||
6108 | #if VERBOSE_ATS | ||
6109 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, row_index, ja[array_index], ar[array_index]); | ||
6110 | #endif | ||
6111 | glp_set_mat_row (ats->prob, row_index, array_index, ja, ar); | ||
6112 | |||
6113 | array_index = 1; | ||
6114 | row_index++; | ||
6115 | } | ||
6116 | |||
6117 | GNUNET_free_non_null (ja); | ||
6118 | GNUNET_free_non_null (ar); | ||
6119 | } | ||
6120 | |||
6121 | |||
6122 | |||
6123 | static void ats_update_problem_cr () | ||
6124 | { | ||
6125 | |||
6126 | int array_index; | ||
6127 | int row_index; | ||
6128 | int c, c2; | ||
6129 | double ct_max, ct_min; | ||
6130 | |||
6131 | int *ja = GNUNET_malloc ((1 + ats->res.c_mechs*2 + 3 + available_quality_metrics) * sizeof (int)); | ||
6132 | double *ar = GNUNET_malloc ((1 + ats->res.c_mechs*2 + 3 + available_quality_metrics) * sizeof (double)); | ||
6133 | |||
6134 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); | ||
6135 | row_index = ats->res.begin_cr; | ||
6136 | |||
6137 | for (c=0; c<available_ressources; c++) | ||
6138 | { | ||
6139 | ct_max = ressources[c].c_max; | ||
6140 | ct_min = ressources[c].c_min; | ||
6141 | #if VERBOSE_ATS | ||
6142 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] %f..%f\n",row_index, ct_min, ct_max); | ||
6143 | #endif | ||
6144 | glp_set_row_bnds(ats->prob, row_index, GLP_DB, ct_min, ct_max); | ||
6145 | |||
6146 | for (c2=1; c2<=ats->res.c_mechs; c2++) | ||
6147 | { | ||
6148 | double value = 0; | ||
6149 | ja[array_index] = c2; | ||
6150 | value = ats->mechanisms[c2].addr->ressources[c].c; | ||
6151 | ar[array_index] = value; | ||
6152 | #if VERBOSE_ATS | ||
6153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, rowrow_indexs, ja[array_index], ar[array_index]); | ||
6154 | #endif | ||
6155 | array_index++; | ||
6156 | } | ||
6157 | glp_set_mat_row (ats->prob, row_index, array_index, ja, ar); | ||
6158 | |||
6159 | row_index ++; | ||
6160 | } | ||
6161 | |||
6162 | |||
6163 | GNUNET_free_non_null (ja); | ||
6164 | GNUNET_free_non_null (ar); | ||
6064 | } | 6165 | } |
6065 | 6166 | ||
6066 | 6167 | ||
@@ -6342,7 +6443,6 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6342 | // optimisation constraints | 6443 | // optimisation constraints |
6343 | 6444 | ||
6344 | // adding columns | 6445 | // adding columns |
6345 | //glp_add_cols(ats->prob, 3 + c_q_metrics); | ||
6346 | 6446 | ||
6347 | // Constraint 6: optimize for diversity | 6447 | // Constraint 6: optimize for diversity |
6348 | glp_add_cols(ats->prob, 1); | 6448 | glp_add_cols(ats->prob, 1); |
@@ -6448,7 +6548,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6448 | glp_set_obj_coef(ats->prob, (2*c_mechs) + 3 + c, Q[c]); | 6548 | glp_set_obj_coef(ats->prob, (2*c_mechs) + 3 + c, Q[c]); |
6449 | } | 6549 | } |
6450 | glp_add_rows(ats->prob, available_quality_metrics); | 6550 | glp_add_rows(ats->prob, available_quality_metrics); |
6451 | res->begin_qm = array_index; | 6551 | res->begin_qm = row_index; |
6452 | for (c=1; c <= c_q_metrics; c++) | 6552 | for (c=1; c <= c_q_metrics; c++) |
6453 | { | 6553 | { |
6454 | #if VERBOSE_ATS | 6554 | #if VERBOSE_ATS |
@@ -6504,7 +6604,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6504 | array_index++; | 6604 | array_index++; |
6505 | row_index++; | 6605 | row_index++; |
6506 | } | 6606 | } |
6507 | res->end_qm = array_index-1; | 6607 | res->end_qm = row_index-1; |
6508 | 6608 | ||
6509 | /* Loading the matrix */ | 6609 | /* Loading the matrix */ |
6510 | glp_load_matrix(ats->prob, array_index-1, ia, ja, ar); | 6610 | glp_load_matrix(ats->prob, array_index-1, ia, ja, ar); |
@@ -6523,7 +6623,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6523 | return GNUNET_OK; | 6623 | return GNUNET_OK; |
6524 | 6624 | ||
6525 | } | 6625 | } |
6526 | 6626 | #if 0 | |
6527 | void ats_notify_ats_data ( | 6627 | void ats_notify_ats_data ( |
6528 | const struct GNUNET_PeerIdentity *peer, | 6628 | const struct GNUNET_PeerIdentity *peer, |
6529 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data) | 6629 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data) |
@@ -6534,6 +6634,7 @@ void ats_notify_ats_data ( | |||
6534 | ats_calculate_bandwidth_distribution(ats); | 6634 | ats_calculate_bandwidth_distribution(ats); |
6535 | } | 6635 | } |
6536 | #endif | 6636 | #endif |
6637 | #endif | ||
6537 | 6638 | ||
6538 | static void | 6639 | static void |
6539 | ats_calculate_bandwidth_distribution () | 6640 | ats_calculate_bandwidth_distribution () |
@@ -6569,13 +6670,11 @@ ats_calculate_bandwidth_distribution () | |||
6569 | } | 6670 | } |
6570 | else if (ats->modified_resources == GNUNET_YES) | 6671 | else if (ats->modified_resources == GNUNET_YES) |
6571 | { | 6672 | { |
6572 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "RESSOURCE...modified problem\n"); | 6673 | ats_update_problem_cr(); |
6573 | ats_update_problem(); | ||
6574 | } | 6674 | } |
6575 | else if (ats->modified_quality == GNUNET_YES) | 6675 | else if (ats->modified_quality == GNUNET_YES) |
6576 | { | 6676 | { |
6577 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "RESSOURCE...quality problem\n"); | 6677 | ats_update_problem_qm(); |
6578 | ats_update_problem(); | ||
6579 | } | 6678 | } |
6580 | #if DEBUG_ATS | 6679 | #if DEBUG_ATS |
6581 | else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n"); | 6680 | else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n"); |
@@ -6594,8 +6693,10 @@ ats_calculate_bandwidth_distribution () | |||
6594 | if (ats->res.valid == GNUNET_YES) | 6693 | if (ats->res.valid == GNUNET_YES) |
6595 | { | 6694 | { |
6596 | #if DEBUG_ATS | 6695 | #if DEBUG_ATS |
6597 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", ats->res.c_mechs, duration.rel_value); | ||
6598 | #endif | 6696 | #endif |
6697 | if (ats->res.c_mechs > 8) | ||
6698 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", ats->res.c_mechs, duration.rel_value); | ||
6699 | |||
6599 | GNUNET_STATISTICS_set (stats, "ATS duration", duration.rel_value, GNUNET_NO); | 6700 | GNUNET_STATISTICS_set (stats, "ATS duration", duration.rel_value, GNUNET_NO); |
6600 | GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->res.c_mechs, GNUNET_NO); | 6701 | GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->res.c_mechs, GNUNET_NO); |
6601 | GNUNET_STATISTICS_set (stats, "ATS peers", ats->res.c_peers, GNUNET_NO); | 6702 | GNUNET_STATISTICS_set (stats, "ATS peers", ats->res.c_peers, GNUNET_NO); |
@@ -6725,20 +6826,13 @@ static void ats_shutdown () | |||
6725 | 6826 | ||
6726 | void ats_notify_peer_connect ( | 6827 | void ats_notify_peer_connect ( |
6727 | const struct GNUNET_PeerIdentity *peer, | 6828 | const struct GNUNET_PeerIdentity *peer, |
6728 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data) | 6829 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data, int ats_count) |
6729 | { | 6830 | { |
6730 | int c = 0; | ||
6731 | #if DEBUG_ATS | 6831 | #if DEBUG_ATS |
6732 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_connect: %s\n",GNUNET_i2s(peer)); | 6832 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_connect: %s\n",GNUNET_i2s(peer)); |
6733 | #endif | 6833 | #endif |
6734 | while (ntohl(ats_data[c].type)!=0) | ||
6735 | { | ||
6736 | #if DEBUG_ATS | ||
6737 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats type [%i]: %i\n",ntohl(ats_data[c].type), ntohl(ats_data[c].value)); | ||
6738 | #endif | ||
6739 | c++; | ||
6740 | } | ||
6741 | 6834 | ||
6835 | //update_addr_ats(); | ||
6742 | ats->modified_addr = GNUNET_YES; | 6836 | ats->modified_addr = GNUNET_YES; |
6743 | 6837 | ||
6744 | ats_calculate_bandwidth_distribution(ats); | 6838 | ats_calculate_bandwidth_distribution(ats); |