diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-14 16:48:37 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-14 16:48:37 +0000 |
commit | 3c2d8c16ca76ac45db471f3c66bc24257b849dd5 (patch) | |
tree | 5aa7eb3d2bd08b5e849cf8843c6311c875affe60 /src/transport | |
parent | 57a074bce8ef0c538d1b1906c9de7482275232fb (diff) | |
download | gnunet-3c2d8c16ca76ac45db471f3c66bc24257b849dd5.tar.gz gnunet-3c2d8c16ca76ac45db471f3c66bc24257b849dd5.zip |
many changes...improvements
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 438 | ||||
-rw-r--r-- | src/transport/test_transport_ats.c | 286 |
2 files changed, 534 insertions, 190 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 7a2d1a647..474cfe2e2 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -154,6 +154,12 @@ | |||
154 | 154 | ||
155 | #define VERY_BIG_DOUBLE_VALUE 100000000000LL | 155 | #define VERY_BIG_DOUBLE_VALUE 100000000000LL |
156 | 156 | ||
157 | #define ATS_NEW 0 | ||
158 | #define ATS_Q_UPDATED 1 | ||
159 | #define ATS_C_UPDATED 2 | ||
160 | #define ATS_QC_UPDATED 3 | ||
161 | #define ATS_UNMODIFIED 4 | ||
162 | |||
157 | /** | 163 | /** |
158 | * List of addresses of other peers | 164 | * List of addresses of other peers |
159 | */ | 165 | */ |
@@ -875,19 +881,54 @@ struct ATS_peer | |||
875 | int t; | 881 | int t; |
876 | }; | 882 | }; |
877 | 883 | ||
878 | struct ATS_result | 884 | struct ATS_stat |
879 | { | 885 | { |
886 | /** | ||
887 | * result of last GLPK run | ||
888 | * 5 == OPTIMAL | ||
889 | */ | ||
890 | int solution; | ||
891 | |||
892 | /** | ||
893 | * is problem currently valid and can it be solved | ||
894 | */ | ||
895 | int valid; | ||
896 | |||
897 | /** | ||
898 | * Number of transport mechanisms in the problem | ||
899 | */ | ||
880 | int c_mechs; | 900 | int c_mechs; |
901 | |||
902 | /** | ||
903 | * Number of transport mechanisms in the problem | ||
904 | */ | ||
881 | int c_peers; | 905 | int c_peers; |
882 | 906 | ||
907 | /** | ||
908 | * row index where quality related rows start | ||
909 | */ | ||
883 | int begin_qm; | 910 | int begin_qm; |
911 | |||
912 | /** | ||
913 | * row index where quality related rows end | ||
914 | */ | ||
884 | int end_qm; | 915 | int end_qm; |
885 | 916 | ||
917 | /** | ||
918 | * row index where ressource cost related rows start | ||
919 | */ | ||
886 | int begin_cr; | 920 | int begin_cr; |
921 | |||
922 | /** | ||
923 | * row index where ressource cost related rows end | ||
924 | */ | ||
887 | int end_cr; | 925 | int end_cr; |
888 | 926 | ||
889 | int solution; | 927 | int col_d; |
890 | int valid; | 928 | int col_u; |
929 | int col_r; | ||
930 | int col_qm; | ||
931 | int col_cr; | ||
891 | }; | 932 | }; |
892 | 933 | ||
893 | struct ATS_ressource_entry | 934 | struct ATS_ressource_entry |
@@ -960,44 +1001,94 @@ struct ATS_info | |||
960 | * Maximum execution time per calculation | 1001 | * Maximum execution time per calculation |
961 | */ | 1002 | */ |
962 | struct GNUNET_TIME_Relative max_exec_duration; | 1003 | struct GNUNET_TIME_Relative max_exec_duration; |
1004 | |||
1005 | #if HAVE_LIBGLPK | ||
1006 | /** | ||
1007 | * GLPK (MLP) problem object | ||
1008 | */ | ||
1009 | glp_prob *prob; | ||
1010 | #endif | ||
1011 | |||
1012 | /** | ||
1013 | * task to recalculate the bandwidth assignment | ||
1014 | */ | ||
1015 | GNUNET_SCHEDULER_TaskIdentifier ats_task; | ||
1016 | |||
1017 | /** | ||
1018 | * Current state of the GLPK problem | ||
1019 | */ | ||
1020 | struct ATS_stat stat; | ||
1021 | |||
1022 | /** | ||
1023 | * mechanisms used in current problem | ||
1024 | * needed for problem modification | ||
1025 | */ | ||
1026 | struct ATS_mechanism * mechanisms; | ||
1027 | |||
1028 | /** | ||
1029 | * peers used in current problem | ||
1030 | * needed for problem modification | ||
1031 | */ | ||
1032 | struct ATS_peer * peers; | ||
1033 | |||
1034 | |||
963 | /** | 1035 | /** |
964 | * Maximum number of LP iterations per calculation | 1036 | * Maximum number of LP iterations per calculation |
965 | */ | 1037 | */ |
966 | int max_iterations; | 1038 | int max_iterations; |
967 | 1039 | ||
1040 | /** | ||
1041 | * Dump problem to a file? | ||
1042 | */ | ||
968 | int save_mlp; | 1043 | int save_mlp; |
1044 | |||
1045 | /** | ||
1046 | * Dump solution to a file | ||
1047 | */ | ||
969 | int save_solution; | 1048 | int save_solution; |
970 | 1049 | ||
971 | /** | 1050 | /** |
972 | * Ressource costs or quality metrics changed, update matrix | 1051 | * Ressource costs or quality metrics changed |
1052 | * update problem before solving | ||
973 | */ | 1053 | */ |
974 | int modified_resources; | 1054 | int modified_resources; |
975 | 1055 | ||
976 | /** | 1056 | /** |
977 | * Ressource costs or quality metrics changed, update matrix | 1057 | * Ressource costs or quality metrics changed, update matrix |
1058 | * update problem before solving | ||
978 | */ | 1059 | */ |
979 | int modified_quality; | 1060 | int modified_quality; |
980 | 1061 | ||
981 | /** | 1062 | /** |
982 | * Peers have connected or disconnected, problem has to be recreated | 1063 | * Peers have connected or disconnected |
1064 | * problem has to be recreated | ||
983 | */ | 1065 | */ |
984 | int modified_addr; | 1066 | int modified_addr; |
985 | 1067 | ||
1068 | /** | ||
1069 | * Diversity weight | ||
1070 | */ | ||
986 | double D; | 1071 | double D; |
1072 | |||
1073 | /** | ||
1074 | * Utility weight | ||
1075 | */ | ||
987 | double U; | 1076 | double U; |
988 | double R; | ||
989 | int v_b_min; | ||
990 | int v_n_min; | ||
991 | 1077 | ||
992 | GNUNET_SCHEDULER_TaskIdentifier ats_task; | 1078 | /** |
1079 | * Relativity weight | ||
1080 | */ | ||
1081 | double R; | ||
993 | 1082 | ||
994 | struct ATS_result res; | 1083 | /** |
995 | #if HAVE_LIBGLPK | 1084 | * Minimum bandwidth per peer |
996 | glp_prob *prob; | 1085 | */ |
997 | #endif | 1086 | int v_b_min; |
998 | 1087 | ||
999 | struct ATS_mechanism * mechanisms; | 1088 | /** |
1000 | struct ATS_peer * peers; | 1089 | * Minimum number of connections per peer |
1090 | */ | ||
1091 | int v_n_min; | ||
1001 | }; | 1092 | }; |
1002 | 1093 | ||
1003 | 1094 | ||
@@ -5103,9 +5194,11 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5103 | distance = ntohl(ats_data[c].value); | 5194 | distance = ntohl(ats_data[c].value); |
5104 | } | 5195 | } |
5105 | } | 5196 | } |
5197 | |||
5106 | /* notify ATS about incoming data */ | 5198 | /* notify ATS about incoming data */ |
5107 | //ats_notify_ats_data(peer, ats_data); | 5199 | //ats_notify_ats_data(peer, ats_data); |
5108 | 5200 | ||
5201 | |||
5109 | if (message != NULL) | 5202 | if (message != NULL) |
5110 | { | 5203 | { |
5111 | if ( (session != NULL) || | 5204 | if ( (session != NULL) || |
@@ -5132,6 +5225,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5132 | } | 5225 | } |
5133 | /* update traffic received amount ... */ | 5226 | /* update traffic received amount ... */ |
5134 | msize = ntohs (message->size); | 5227 | msize = ntohs (message->size); |
5228 | |||
5135 | GNUNET_STATISTICS_update (stats, | 5229 | GNUNET_STATISTICS_update (stats, |
5136 | gettext_noop ("# bytes received from other peers"), | 5230 | gettext_noop ("# bytes received from other peers"), |
5137 | msize, | 5231 | msize, |
@@ -5159,6 +5253,27 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5159 | GNUNET_NO); | 5253 | GNUNET_NO); |
5160 | return GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT; | 5254 | return GNUNET_CONSTANTS_QUOTA_VIOLATION_TIMEOUT; |
5161 | } | 5255 | } |
5256 | if ((ntohs(message->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ATS) && | ||
5257 | (ntohs(message->size) == (sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t)))) | ||
5258 | { | ||
5259 | uint32_t value = ntohl(*((uint32_t *) &message[1])); | ||
5260 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_MESSAGE_TYPE_TRANSPORT_ATS: %i \n", value); | ||
5261 | /* Force ressource and quality update */ | ||
5262 | if (value == 4) | ||
5263 | { | ||
5264 | ats->modified_resources = GNUNET_YES; | ||
5265 | ats->modified_quality = GNUNET_YES; | ||
5266 | } | ||
5267 | /* Force cost update */ | ||
5268 | if (value == 3) | ||
5269 | ats->modified_resources = GNUNET_YES; | ||
5270 | /* Force quality update */ | ||
5271 | if (value == 2) | ||
5272 | ats->modified_quality = GNUNET_YES; | ||
5273 | /* Force full rebuild */ | ||
5274 | if (value == 1) | ||
5275 | ats->modified_addr = GNUNET_YES; | ||
5276 | } | ||
5162 | 5277 | ||
5163 | #if DEBUG_PING_PONG | 5278 | #if DEBUG_PING_PONG |
5164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -5182,6 +5297,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5182 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: | 5297 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: |
5183 | handle_pong (plugin, message, peer, sender_address, sender_address_len); | 5298 | handle_pong (plugin, message, peer, sender_address, sender_address_len); |
5184 | break; | 5299 | break; |
5300 | case GNUNET_MESSAGE_TYPE_TRANSPORT_ATS: | ||
5301 | break; | ||
5185 | default: | 5302 | default: |
5186 | handle_payload_message (message, n); | 5303 | handle_payload_message (message, n); |
5187 | break; | 5304 | break; |
@@ -5902,7 +6019,7 @@ return cont; | |||
5902 | } | 6019 | } |
5903 | 6020 | ||
5904 | 6021 | ||
5905 | static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsigned int c_peers, unsigned int c_mechs, struct ATS_result *res) | 6022 | static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsigned int c_peers, unsigned int c_mechs, struct ATS_stat *stat) |
5906 | { | 6023 | { |
5907 | int result; | 6024 | int result; |
5908 | int solution; | 6025 | int solution; |
@@ -5938,10 +6055,10 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
5938 | #endif | 6055 | #endif |
5939 | result = glp_intopt (prob, &opt_mlp); | 6056 | result = glp_intopt (prob, &opt_mlp); |
5940 | solution = glp_mip_status (prob); | 6057 | solution = glp_mip_status (prob); |
5941 | res->solution = solution; | 6058 | stat->solution = solution; |
5942 | res->valid = GNUNET_NO; | 6059 | stat->valid = GNUNET_NO; |
5943 | if (ats_evaluate_results(result, solution, "MLP") == GNUNET_YES) | 6060 | if (ats_evaluate_results(result, solution, "MLP") == GNUNET_YES) |
5944 | res->valid = GNUNET_YES; | 6061 | stat->valid = GNUNET_YES; |
5945 | /* done */ | 6062 | /* done */ |
5946 | } | 6063 | } |
5947 | 6064 | ||
@@ -6013,7 +6130,7 @@ static void ats_delete_problem () | |||
6013 | { | 6130 | { |
6014 | int c; | 6131 | int c; |
6015 | 6132 | ||
6016 | for (c=0; c< (ats->res).c_mechs; c++) | 6133 | for (c=0; c< (ats->stat).c_mechs; c++) |
6017 | GNUNET_free_non_null (ats->mechanisms[c].rc); | 6134 | GNUNET_free_non_null (ats->mechanisms[c].rc); |
6018 | 6135 | ||
6019 | if (ats->mechanisms!=NULL) | 6136 | if (ats->mechanisms!=NULL) |
@@ -6033,14 +6150,14 @@ static void ats_delete_problem () | |||
6033 | ats->prob = NULL; | 6150 | ats->prob = NULL; |
6034 | } | 6151 | } |
6035 | 6152 | ||
6036 | ats->res.begin_cr = GNUNET_SYSERR; | 6153 | ats->stat.begin_cr = GNUNET_SYSERR; |
6037 | ats->res.begin_qm = GNUNET_SYSERR; | 6154 | ats->stat.begin_qm = GNUNET_SYSERR; |
6038 | ats->res.c_mechs = 0; | 6155 | ats->stat.c_mechs = 0; |
6039 | ats->res.c_peers = 0; | 6156 | ats->stat.c_peers = 0; |
6040 | ats->res.end_cr = GNUNET_SYSERR; | 6157 | ats->stat.end_cr = GNUNET_SYSERR; |
6041 | ats->res.end_qm = GNUNET_SYSERR; | 6158 | ats->stat.end_qm = GNUNET_SYSERR; |
6042 | ats->res.solution = GNUNET_SYSERR; | 6159 | ats->stat.solution = GNUNET_SYSERR; |
6043 | ats->res.valid = GNUNET_SYSERR; | 6160 | ats->stat.valid = GNUNET_SYSERR; |
6044 | } | 6161 | } |
6045 | 6162 | ||
6046 | static void ats_update_problem_qm () | 6163 | static void ats_update_problem_qm () |
@@ -6050,11 +6167,12 @@ static void ats_update_problem_qm () | |||
6050 | int c, c2; | 6167 | int c, c2; |
6051 | int c_q_metrics = available_quality_metrics; | 6168 | int c_q_metrics = available_quality_metrics; |
6052 | 6169 | ||
6053 | int *ja = GNUNET_malloc ((1 + ats->res.c_mechs*2 + 3 + available_quality_metrics) * sizeof (int)); | 6170 | int *ja = GNUNET_malloc ((1 + ats->stat.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)); | 6171 | double *ar = GNUNET_malloc ((1 + ats->stat.c_mechs*2 + 3 + available_quality_metrics) * sizeof (double)); |
6055 | if (ats->res.c_mechs>10) | 6172 | #if DEBUG_ATS |
6056 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); | 6173 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); |
6057 | row_index = ats->res.begin_qm; | 6174 | #endif |
6175 | row_index = ats->stat.begin_qm; | ||
6058 | 6176 | ||
6059 | for (c=1; c <= c_q_metrics; c++) | 6177 | for (c=1; c <= c_q_metrics; c++) |
6060 | { | 6178 | { |
@@ -6065,7 +6183,7 @@ static void ats_update_problem_qm () | |||
6065 | #endif | 6183 | #endif |
6066 | 6184 | ||
6067 | glp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0); | 6185 | glp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0); |
6068 | for (c2=1; c2<=ats->res.c_mechs; c2++) | 6186 | for (c2=1; c2<=ats->stat.c_mechs; c2++) |
6069 | { | 6187 | { |
6070 | ja[array_index] = c2; | 6188 | ja[array_index] = c2; |
6071 | 6189 | ||
@@ -6102,7 +6220,7 @@ static void ats_update_problem_qm () | |||
6102 | #endif | 6220 | #endif |
6103 | array_index++; | 6221 | array_index++; |
6104 | } | 6222 | } |
6105 | ja[array_index] = (2*ats->res.c_mechs) + 3 +c; | 6223 | ja[array_index] = ats->stat.col_qm + c - 1; |
6106 | ar[array_index] = -1; | 6224 | ar[array_index] = -1; |
6107 | 6225 | ||
6108 | #if VERBOSE_ATS | 6226 | #if VERBOSE_ATS |
@@ -6128,11 +6246,11 @@ static void ats_update_problem_cr () | |||
6128 | int c, c2; | 6246 | int c, c2; |
6129 | double ct_max, ct_min; | 6247 | double ct_max, ct_min; |
6130 | 6248 | ||
6131 | int *ja = GNUNET_malloc ((1 + ats->res.c_mechs*2 + 3 + available_quality_metrics) * sizeof (int)); | 6249 | int *ja = GNUNET_malloc ((1 + ats->stat.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)); | 6250 | double *ar = GNUNET_malloc ((1 + ats->stat.c_mechs*2 + 3 + available_quality_metrics) * sizeof (double)); |
6133 | 6251 | ||
6134 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); | 6252 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); |
6135 | row_index = ats->res.begin_cr; | 6253 | row_index = ats->stat.begin_cr; |
6136 | 6254 | ||
6137 | for (c=0; c<available_ressources; c++) | 6255 | for (c=0; c<available_ressources; c++) |
6138 | { | 6256 | { |
@@ -6143,14 +6261,14 @@ static void ats_update_problem_cr () | |||
6143 | #endif | 6261 | #endif |
6144 | glp_set_row_bnds(ats->prob, row_index, GLP_DB, ct_min, ct_max); | 6262 | glp_set_row_bnds(ats->prob, row_index, GLP_DB, ct_min, ct_max); |
6145 | 6263 | ||
6146 | for (c2=1; c2<=ats->res.c_mechs; c2++) | 6264 | for (c2=1; c2<=ats->stat.c_mechs; c2++) |
6147 | { | 6265 | { |
6148 | double value = 0; | 6266 | double value = 0; |
6149 | ja[array_index] = c2; | 6267 | ja[array_index] = c2; |
6150 | value = ats->mechanisms[c2].addr->ressources[c].c; | 6268 | value = ats->mechanisms[c2].addr->ressources[c].c; |
6151 | ar[array_index] = value; | 6269 | ar[array_index] = value; |
6152 | #if VERBOSE_ATS | 6270 | #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]); | 6271 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, row_index, ja[array_index], ar[array_index]); |
6154 | #endif | 6272 | #endif |
6155 | array_index++; | 6273 | array_index++; |
6156 | } | 6274 | } |
@@ -6173,10 +6291,10 @@ static void ats_update_problem_cr () | |||
6173 | * @param R weight for relativity | 6291 | * @param R weight for relativity |
6174 | * @param v_b_min minimal bandwidth per peer | 6292 | * @param v_b_min minimal bandwidth per peer |
6175 | * @param v_n_min minimum number of connections | 6293 | * @param v_n_min minimum number of connections |
6176 | * @param res result struct | 6294 | * @param stat result struct |
6177 | * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used | 6295 | * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used |
6178 | */ | 6296 | */ |
6179 | static int ats_create_problem (double D, double U, double R, int v_b_min, int v_n_min, struct ATS_result *res) | 6297 | static int ats_create_problem (double D, double U, double R, int v_b_min, int v_n_min, struct ATS_stat *stat) |
6180 | { | 6298 | { |
6181 | if (ats->prob != NULL) | 6299 | if (ats->prob != NULL) |
6182 | glp_delete_prob(ats->prob); | 6300 | glp_delete_prob(ats->prob); |
@@ -6220,9 +6338,9 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6220 | #if DEBUG_ATS | 6338 | #if DEBUG_ATS |
6221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No addresses for bw distribution available\n", c_peers); | 6339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No addresses for bw distribution available\n", c_peers); |
6222 | #endif | 6340 | #endif |
6223 | res->valid = GNUNET_NO; | 6341 | stat->valid = GNUNET_NO; |
6224 | res->c_peers = 0; | 6342 | stat->c_peers = 0; |
6225 | res->c_mechs = 0; | 6343 | stat->c_mechs = 0; |
6226 | return GNUNET_SYSERR; | 6344 | return GNUNET_SYSERR; |
6227 | } | 6345 | } |
6228 | 6346 | ||
@@ -6393,7 +6511,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6393 | double ct_max = VERY_BIG_DOUBLE_VALUE; | 6511 | double ct_max = VERY_BIG_DOUBLE_VALUE; |
6394 | double ct_min = 0.0; | 6512 | double ct_min = 0.0; |
6395 | 6513 | ||
6396 | res->begin_cr = array_index; | 6514 | stat->begin_cr = array_index; |
6397 | 6515 | ||
6398 | for (c=0; c<available_ressources; c++) | 6516 | for (c=0; c<available_ressources; c++) |
6399 | { | 6517 | { |
@@ -6418,7 +6536,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6418 | } | 6536 | } |
6419 | row_index ++; | 6537 | row_index ++; |
6420 | } | 6538 | } |
6421 | res->end_cr = array_index--; | 6539 | stat->end_cr = array_index--; |
6422 | 6540 | ||
6423 | /* Constraint 5: min number of connections*/ | 6541 | /* Constraint 5: min number of connections*/ |
6424 | glp_add_rows(ats->prob, 1); | 6542 | glp_add_rows(ats->prob, 1); |
@@ -6445,10 +6563,13 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6445 | // adding columns | 6563 | // adding columns |
6446 | 6564 | ||
6447 | // Constraint 6: optimize for diversity | 6565 | // Constraint 6: optimize for diversity |
6448 | glp_add_cols(ats->prob, 1); | 6566 | int col_d; |
6449 | glp_set_col_name(ats->prob, (2*c_mechs) + 1, "d"); | 6567 | col_d = glp_add_cols(ats->prob, 1); |
6450 | glp_set_obj_coef(ats->prob, (2*c_mechs) + 1, D); | 6568 | stat->col_d = col_d; |
6451 | glp_set_col_bnds(ats->prob, (2*c_mechs) + 1, GLP_LO, 0.0, 0.0); | 6569 | //GNUNET_assert (col_d == (2*c_mechs) + 1); |
6570 | glp_set_col_name(ats->prob, col_d, "d"); | ||
6571 | glp_set_obj_coef(ats->prob, col_d, D); | ||
6572 | glp_set_col_bnds(ats->prob, col_d, GLP_LO, 0.0, 0.0); | ||
6452 | glp_add_rows(ats->prob, 1); | 6573 | glp_add_rows(ats->prob, 1); |
6453 | #if VERBOSE_ATS | 6574 | #if VERBOSE_ATS |
6454 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); | 6575 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); |
@@ -6466,7 +6587,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6466 | array_index++; | 6587 | array_index++; |
6467 | } | 6588 | } |
6468 | ia[array_index] = row_index; | 6589 | ia[array_index] = row_index; |
6469 | ja[array_index] = (2*c_mechs) + 1; | 6590 | ja[array_index] = col_d; |
6470 | ar[array_index] = -1; | 6591 | ar[array_index] = -1; |
6471 | #if VERBOSE_ATS | 6592 | #if VERBOSE_ATS |
6472 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | 6593 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); |
@@ -6474,81 +6595,22 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6474 | array_index++; | 6595 | array_index++; |
6475 | row_index ++; | 6596 | row_index ++; |
6476 | 6597 | ||
6477 | // Constraint 8: optimize bandwidth utility | ||
6478 | glp_add_cols(ats->prob, 1); | ||
6479 | glp_set_col_name(ats->prob, (2*c_mechs) + 2, "u"); | ||
6480 | glp_set_obj_coef(ats->prob, (2*c_mechs) + 2, U); | ||
6481 | glp_set_col_bnds(ats->prob, (2*c_mechs) + 2, GLP_LO, 0.0, 0.0); | ||
6482 | glp_add_rows(ats->prob, 1); | ||
6483 | #if VERBOSE_ATS | ||
6484 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); | ||
6485 | #endif | ||
6486 | glp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0); | ||
6487 | for (c=1; c<=c_mechs; c++) | ||
6488 | { | ||
6489 | ia[array_index] = row_index; | ||
6490 | ja[array_index] = c; | ||
6491 | ar[array_index] = mechanisms[c].peer->f; | ||
6492 | #if VERBOSE_ATS | ||
6493 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6494 | #endif | ||
6495 | array_index++; | ||
6496 | } | ||
6497 | ia[array_index] = row_index; | ||
6498 | ja[array_index] = (2*c_mechs) + 2; | ||
6499 | ar[array_index] = -1; | ||
6500 | #if VERBOSE_ATS | ||
6501 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6502 | #endif | ||
6503 | |||
6504 | array_index++; | ||
6505 | row_index ++; | ||
6506 | |||
6507 | // Constraint 9: optimize relativity | ||
6508 | glp_add_cols(ats->prob, 1); | ||
6509 | glp_set_col_name(ats->prob, (2*c_mechs) + 3, "r"); | ||
6510 | glp_set_obj_coef(ats->prob, (2*c_mechs) + 3, R); | ||
6511 | glp_set_col_bnds(ats->prob, (2*c_mechs) + 3, GLP_LO, 0.0, 0.0); | ||
6512 | glp_add_rows(ats->prob, c_peers); | ||
6513 | for (c=1; c<=c_peers; c++) | ||
6514 | { | ||
6515 | glp_set_row_bnds(ats->prob, row_index, GLP_LO, 0.0, 0.0); | ||
6516 | |||
6517 | struct ATS_mechanism *m = peers[c].m_head; | ||
6518 | while (m!=NULL) | ||
6519 | { | ||
6520 | ia[array_index] = row_index; | ||
6521 | ja[array_index] = m->col_index; | ||
6522 | ar[array_index] = 1 / mechanisms[c].peer->f; | ||
6523 | #if VERBOSE_ATS | ||
6524 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6525 | #endif | ||
6526 | array_index++; | ||
6527 | m = m->next; | ||
6528 | } | ||
6529 | ia[array_index] = row_index; | ||
6530 | ja[array_index] = (2*c_mechs) + 3; | ||
6531 | ar[array_index] = -1; | ||
6532 | #if VERBOSE_ATS | ||
6533 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6534 | #endif | ||
6535 | array_index++; | ||
6536 | |||
6537 | row_index++; | ||
6538 | } | ||
6539 | 6598 | ||
6540 | // Constraint 7: optimize for quality | 6599 | // Constraint 7: optimize for quality |
6541 | glp_add_cols(ats->prob, c_q_metrics); | 6600 | int col_qm; |
6542 | for (c=1; c<= c_q_metrics; c++) | 6601 | col_qm = glp_add_cols(ats->prob, c_q_metrics); |
6602 | stat->col_qm = col_qm; | ||
6603 | //GNUNET_assert (col_qm == (2*c_mechs) + 3 + 1); | ||
6604 | for (c=0; c< c_q_metrics; c++) | ||
6543 | { | 6605 | { |
6544 | GNUNET_asprintf(&name, "Q_%s",qm[c-1].name); | 6606 | GNUNET_asprintf(&name, "Q_%s",qm[c].name); |
6545 | glp_set_col_name(ats->prob, (2*c_mechs) + 3 + c, name); | 6607 | glp_set_col_name(ats->prob, col_qm + c, name); |
6546 | glp_set_col_bnds(ats->prob, (2*c_mechs) + 3 + c, GLP_LO, 0.0, 0.0); | 6608 | glp_set_col_bnds(ats->prob, col_qm + c, GLP_LO, 0.0, 0.0); |
6547 | GNUNET_free (name); | 6609 | GNUNET_free (name); |
6548 | glp_set_obj_coef(ats->prob, (2*c_mechs) + 3 + c, Q[c]); | 6610 | glp_set_obj_coef(ats->prob, col_qm + c, Q[c]); |
6549 | } | 6611 | } |
6550 | glp_add_rows(ats->prob, available_quality_metrics); | 6612 | glp_add_rows(ats->prob, available_quality_metrics); |
6551 | res->begin_qm = row_index; | 6613 | stat->begin_qm = row_index; |
6552 | for (c=1; c <= c_q_metrics; c++) | 6614 | for (c=1; c <= c_q_metrics; c++) |
6553 | { | 6615 | { |
6554 | #if VERBOSE_ATS | 6616 | #if VERBOSE_ATS |
@@ -6596,23 +6658,92 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6596 | } | 6658 | } |
6597 | 6659 | ||
6598 | ia[array_index] = row_index; | 6660 | ia[array_index] = row_index; |
6599 | ja[array_index] = (2*c_mechs) + 3 +c; | 6661 | ja[array_index] = col_qm + c - 1; |
6662 | ar[array_index] = -1; | ||
6663 | #if VERBOSE_ATS | ||
6664 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6665 | #endif | ||
6666 | array_index++; | ||
6667 | row_index++; | ||
6668 | } | ||
6669 | stat->end_qm = row_index-1; | ||
6670 | |||
6671 | // Constraint 8: optimize bandwidth utility | ||
6672 | int col_u; | ||
6673 | col_u = glp_add_cols(ats->prob, 1); | ||
6674 | stat->col_u = col_u; | ||
6675 | //GNUNET_assert (col_u == (2*c_mechs) + 2); | ||
6676 | glp_set_col_name(ats->prob, col_u, "u"); | ||
6677 | glp_set_obj_coef(ats->prob, col_u, U); | ||
6678 | glp_set_col_bnds(ats->prob, col_u, GLP_LO, 0.0, 0.0); | ||
6679 | glp_add_rows(ats->prob, 1); | ||
6680 | #if VERBOSE_ATS | ||
6681 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); | ||
6682 | #endif | ||
6683 | glp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0); | ||
6684 | for (c=1; c<=c_mechs; c++) | ||
6685 | { | ||
6686 | ia[array_index] = row_index; | ||
6687 | ja[array_index] = c; | ||
6688 | ar[array_index] = mechanisms[c].peer->f; | ||
6689 | #if VERBOSE_ATS | ||
6690 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6691 | #endif | ||
6692 | array_index++; | ||
6693 | } | ||
6694 | ia[array_index] = row_index; | ||
6695 | ja[array_index] = col_u; | ||
6696 | ar[array_index] = -1; | ||
6697 | #if VERBOSE_ATS | ||
6698 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6699 | #endif | ||
6700 | |||
6701 | array_index++; | ||
6702 | row_index ++; | ||
6703 | |||
6704 | // Constraint 9: optimize relativity | ||
6705 | int col_r; | ||
6706 | col_r = glp_add_cols(ats->prob, 1); | ||
6707 | stat->col_r = col_r; | ||
6708 | //GNUNET_assert (col_r == (2*c_mechs) + 3); | ||
6709 | glp_set_col_name(ats->prob, col_r, "r"); | ||
6710 | glp_set_obj_coef(ats->prob, col_r, R); | ||
6711 | glp_set_col_bnds(ats->prob, col_r, GLP_LO, 0.0, 0.0); | ||
6712 | glp_add_rows(ats->prob, c_peers); | ||
6713 | for (c=1; c<=c_peers; c++) | ||
6714 | { | ||
6715 | glp_set_row_bnds(ats->prob, row_index, GLP_LO, 0.0, 0.0); | ||
6716 | |||
6717 | struct ATS_mechanism *m = peers[c].m_head; | ||
6718 | while (m!=NULL) | ||
6719 | { | ||
6720 | ia[array_index] = row_index; | ||
6721 | ja[array_index] = m->col_index; | ||
6722 | ar[array_index] = 1 / mechanisms[c].peer->f; | ||
6723 | #if VERBOSE_ATS | ||
6724 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | ||
6725 | #endif | ||
6726 | array_index++; | ||
6727 | m = m->next; | ||
6728 | } | ||
6729 | ia[array_index] = row_index; | ||
6730 | ja[array_index] = col_r; | ||
6600 | ar[array_index] = -1; | 6731 | ar[array_index] = -1; |
6601 | #if VERBOSE_ATS | 6732 | #if VERBOSE_ATS |
6602 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); | 6733 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); |
6603 | #endif | 6734 | #endif |
6604 | array_index++; | 6735 | array_index++; |
6736 | |||
6605 | row_index++; | 6737 | row_index++; |
6606 | } | 6738 | } |
6607 | res->end_qm = row_index-1; | ||
6608 | 6739 | ||
6609 | /* Loading the matrix */ | 6740 | /* Loading the matrix */ |
6610 | glp_load_matrix(ats->prob, array_index-1, ia, ja, ar); | 6741 | glp_load_matrix(ats->prob, array_index-1, ia, ja, ar); |
6611 | 6742 | ||
6612 | res->c_mechs = c_mechs; | 6743 | stat->c_mechs = c_mechs; |
6613 | res->c_peers = c_peers; | 6744 | stat->c_peers = c_peers; |
6614 | res->solution = 0; | 6745 | stat->solution = 0; |
6615 | res->valid = GNUNET_YES; | 6746 | stat->valid = GNUNET_YES; |
6616 | 6747 | ||
6617 | /* clean up */ | 6748 | /* clean up */ |
6618 | 6749 | ||
@@ -6640,8 +6771,10 @@ static void | |||
6640 | ats_calculate_bandwidth_distribution () | 6771 | ats_calculate_bandwidth_distribution () |
6641 | { | 6772 | { |
6642 | #if HAVE_LIBGLPK | 6773 | #if HAVE_LIBGLPK |
6774 | #endif | ||
6643 | struct GNUNET_TIME_Absolute start; | 6775 | struct GNUNET_TIME_Absolute start; |
6644 | struct GNUNET_TIME_Relative duration; | 6776 | struct GNUNET_TIME_Relative creation; |
6777 | struct GNUNET_TIME_Relative solving; | ||
6645 | 6778 | ||
6646 | struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get()); | 6779 | struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get()); |
6647 | if (delta.rel_value < ats->min_delta.rel_value) | 6780 | if (delta.rel_value < ats->min_delta.rel_value) |
@@ -6661,11 +6794,10 @@ ats_calculate_bandwidth_distribution () | |||
6661 | start = GNUNET_TIME_absolute_get(); | 6794 | start = GNUNET_TIME_absolute_get(); |
6662 | if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL)) | 6795 | if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL)) |
6663 | { | 6796 | { |
6664 | ats->modified_addr = GNUNET_NO; | ||
6665 | ats_delete_problem (); | 6797 | ats_delete_problem (); |
6666 | ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->res); | 6798 | ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->stat); |
6667 | #if DEBUG_ATS | 6799 | #if DEBUG_ATS |
6668 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers/Addresses were modified... new problem: %i peer, %i mechs\n", ats->res.c_peers, ats->res.c_mechs); | 6800 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers/Addresses were modified... new problem: %i peer, %i mechs\n", ats->stat.c_peers, ats->stat.c_mechs); |
6669 | #endif | 6801 | #endif |
6670 | } | 6802 | } |
6671 | else if (ats->modified_resources == GNUNET_YES) | 6803 | else if (ats->modified_resources == GNUNET_YES) |
@@ -6680,31 +6812,43 @@ ats_calculate_bandwidth_distribution () | |||
6680 | else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n"); | 6812 | else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n"); |
6681 | #endif | 6813 | #endif |
6682 | 6814 | ||
6683 | if (ats->res.valid == GNUNET_YES) | 6815 | creation = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); |
6816 | start = GNUNET_TIME_absolute_get(); | ||
6817 | |||
6818 | if (ats->stat.valid == GNUNET_YES) | ||
6684 | { | 6819 | { |
6685 | ats->res.solution = GNUNET_SYSERR; | 6820 | ats->stat.solution = GNUNET_SYSERR; |
6686 | ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->res.c_peers, ats->res.c_mechs, &ats->res); | 6821 | ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, &ats->stat); |
6687 | if (ats->res.solution != 5) | 6822 | if (ats->stat.solution != 5) |
6688 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solution is not optimal: %i\n", ats->res.solution); | 6823 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solution is not optimal: %i\n", ats->stat.solution); |
6689 | } | 6824 | } |
6690 | 6825 | ||
6691 | duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); | 6826 | solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); |
6692 | 6827 | ||
6693 | if (ats->res.valid == GNUNET_YES) | 6828 | if (ats->stat.valid == GNUNET_YES) |
6694 | { | 6829 | { |
6695 | #if DEBUG_ATS | 6830 | #if DEBUG_ATS |
6831 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP: creation time in [ms] %llu execution time in [ms] %llu for %i mechanisms\n", creation.rel_value, solving.rel_value, ats->stat.c_mechs); | ||
6696 | #endif | 6832 | #endif |
6697 | if (ats->res.c_mechs > 8) | 6833 | GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO); |
6698 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", ats->res.c_mechs, duration.rel_value); | 6834 | GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->stat.c_mechs, GNUNET_NO); |
6699 | 6835 | GNUNET_STATISTICS_set (stats, "ATS peers", ats->stat.c_peers, GNUNET_NO); | |
6700 | GNUNET_STATISTICS_set (stats, "ATS duration", duration.rel_value, GNUNET_NO); | 6836 | GNUNET_STATISTICS_set (stats, "ATS solution", ats->stat.solution, GNUNET_NO); |
6701 | GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->res.c_mechs, GNUNET_NO); | ||
6702 | GNUNET_STATISTICS_set (stats, "ATS peers", ats->res.c_peers, GNUNET_NO); | ||
6703 | GNUNET_STATISTICS_set (stats, "ATS solution", ats->res.solution, GNUNET_NO); | ||
6704 | GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO); | 6837 | GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO); |
6838 | if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL)) | ||
6839 | GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO); | ||
6840 | else if ((ats->modified_resources == GNUNET_YES) && (ats->modified_quality == GNUNET_NO)) | ||
6841 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_C_UPDATED, GNUNET_NO); | ||
6842 | else if ((ats->modified_resources == GNUNET_NO) && (ats->modified_quality == GNUNET_YES)) | ||
6843 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_Q_UPDATED, GNUNET_NO); | ||
6844 | else if ((ats->modified_resources == GNUNET_YES) && (ats->modified_quality == GNUNET_YES)) | ||
6845 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_QC_UPDATED, GNUNET_NO); | ||
6846 | else | ||
6847 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO); | ||
6848 | |||
6705 | } | 6849 | } |
6706 | #if DEBUG_ATS | 6850 | #if DEBUG_ATS |
6707 | else if (ats->res.valid == GNUNET_NO) | 6851 | else if (ats->stat.valid == GNUNET_NO) |
6708 | { | 6852 | { |
6709 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n"); | 6853 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n"); |
6710 | } | 6854 | } |
@@ -6714,8 +6858,6 @@ ats_calculate_bandwidth_distribution () | |||
6714 | ats->modified_addr = GNUNET_NO; | 6858 | ats->modified_addr = GNUNET_NO; |
6715 | ats->modified_resources = GNUNET_NO; | 6859 | ats->modified_resources = GNUNET_NO; |
6716 | ats->modified_quality = GNUNET_NO; | 6860 | ats->modified_quality = GNUNET_NO; |
6717 | |||
6718 | #endif | ||
6719 | } | 6861 | } |
6720 | 6862 | ||
6721 | 6863 | ||
@@ -6757,7 +6899,7 @@ void ats_init () | |||
6757 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; | 6899 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; |
6758 | 6900 | ||
6759 | #if !HAVE_LIBGLPK | 6901 | #if !HAVE_LIBGLPK |
6760 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, ATS not active"); | 6902 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, ATS not active\n"); |
6761 | return; | 6903 | return; |
6762 | #endif | 6904 | #endif |
6763 | 6905 | ||
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index 5c5334812..e83080a1a 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c | |||
@@ -23,6 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
26 | #include "gnunet_transport_service.h" | ||
26 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
27 | #include "gauger.h" | 28 | #include "gauger.h" |
28 | 29 | ||
@@ -33,7 +34,13 @@ | |||
33 | 34 | ||
34 | #define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | 35 | #define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) |
35 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | 36 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) |
37 | #define SEND_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | ||
36 | 38 | ||
39 | #define ATS_NEW 0 | ||
40 | #define ATS_Q_UPDATED 1 | ||
41 | #define ATS_C_UPDATED 2 | ||
42 | #define ATS_QC_UPDATED 3 | ||
43 | #define ATS_UNMODIFIED 4 | ||
37 | 44 | ||
38 | static int ok; | 45 | static int ok; |
39 | 46 | ||
@@ -47,7 +54,9 @@ static struct GNUNET_TESTING_PeerGroup *pg; | |||
47 | 54 | ||
48 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | 55 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; |
49 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; | 56 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; |
57 | static GNUNET_SCHEDULER_TaskIdentifier send_task; | ||
50 | struct GNUNET_TESTING_Daemon * master_deamon; | 58 | struct GNUNET_TESTING_Daemon * master_deamon; |
59 | struct GNUNET_TESTING_Daemon * ping_deamon; | ||
51 | 60 | ||
52 | struct GNUNET_STATISTICS_Handle * stats; | 61 | struct GNUNET_STATISTICS_Handle * stats; |
53 | 62 | ||
@@ -58,14 +67,31 @@ struct TEST_result | |||
58 | uint64_t mechs; | 67 | uint64_t mechs; |
59 | uint64_t peers; | 68 | uint64_t peers; |
60 | uint64_t solution; | 69 | uint64_t solution; |
70 | uint64_t state; | ||
61 | }; | 71 | }; |
62 | 72 | ||
63 | static int r_index; | 73 | struct TestMessage |
64 | //static int measurements; | 74 | { |
75 | struct GNUNET_MessageHeader header; | ||
76 | uint32_t num; | ||
77 | }; | ||
78 | |||
79 | |||
80 | static int count; | ||
81 | static int c_new; | ||
82 | static int c_unmodified; | ||
83 | static int c_modified; | ||
65 | static int connected; | 84 | static int connected; |
66 | static int peers; | 85 | static int peers; |
67 | 86 | ||
68 | static struct TEST_result results[MEASUREMENTS]; | 87 | static int force_q_updates; |
88 | static int force_rebuild; | ||
89 | static int send_msg; | ||
90 | |||
91 | static struct TEST_result results_new [MEASUREMENTS+1]; | ||
92 | static struct TEST_result results_modified [MEASUREMENTS+1]; | ||
93 | static struct TEST_result results_unmodified[MEASUREMENTS+1]; | ||
94 | static struct TEST_result current; | ||
69 | 95 | ||
70 | static struct GNUNET_STATISTICS_GetHandle * s_solution; | 96 | static struct GNUNET_STATISTICS_GetHandle * s_solution; |
71 | static struct GNUNET_STATISTICS_GetHandle * s_time; | 97 | static struct GNUNET_STATISTICS_GetHandle * s_time; |
@@ -73,6 +99,10 @@ static struct GNUNET_STATISTICS_GetHandle * s_peers; | |||
73 | static struct GNUNET_STATISTICS_GetHandle * s_mechs; | 99 | static struct GNUNET_STATISTICS_GetHandle * s_mechs; |
74 | static struct GNUNET_STATISTICS_GetHandle * s_duration; | 100 | static struct GNUNET_STATISTICS_GetHandle * s_duration; |
75 | static struct GNUNET_STATISTICS_GetHandle * s_invalid; | 101 | static struct GNUNET_STATISTICS_GetHandle * s_invalid; |
102 | static struct GNUNET_STATISTICS_GetHandle * s_state; | ||
103 | |||
104 | struct GNUNET_TRANSPORT_TransmitHandle * t; | ||
105 | struct GNUNET_TRANSPORT_Handle * th; | ||
76 | 106 | ||
77 | /** | 107 | /** |
78 | * Check whether peers successfully shut down. | 108 | * Check whether peers successfully shut down. |
@@ -112,6 +142,19 @@ static void shutdown_peers() | |||
112 | GNUNET_SCHEDULER_cancel(stats_task); | 142 | GNUNET_SCHEDULER_cancel(stats_task); |
113 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 143 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
114 | } | 144 | } |
145 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | ||
146 | { | ||
147 | GNUNET_SCHEDULER_cancel(send_task); | ||
148 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
149 | } | ||
150 | |||
151 | if (t!=NULL) | ||
152 | { | ||
153 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | ||
154 | t = NULL; | ||
155 | } | ||
156 | |||
157 | GNUNET_TRANSPORT_disconnect(th); | ||
115 | 158 | ||
116 | if (s_time != NULL) | 159 | if (s_time != NULL) |
117 | { | 160 | { |
@@ -143,6 +186,11 @@ static void shutdown_peers() | |||
143 | GNUNET_STATISTICS_get_cancel(s_invalid); | 186 | GNUNET_STATISTICS_get_cancel(s_invalid); |
144 | s_invalid = NULL; | 187 | s_invalid = NULL; |
145 | } | 188 | } |
189 | if (s_state != NULL) | ||
190 | { | ||
191 | GNUNET_STATISTICS_get_cancel(s_state); | ||
192 | s_state = NULL; | ||
193 | } | ||
146 | 194 | ||
147 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 195 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
148 | } | 196 | } |
@@ -150,34 +198,62 @@ static void shutdown_peers() | |||
150 | static void evaluate_measurements() | 198 | static void evaluate_measurements() |
151 | { | 199 | { |
152 | int c; | 200 | int c; |
153 | char * output = NULL; | 201 | double average ; |
154 | char * temp; | ||
155 | double average; | ||
156 | double stddev; | 202 | double stddev; |
157 | double measure = MEASUREMENTS; | 203 | |
158 | for (c=0; c<MEASUREMENTS;c++) | 204 | c = 1; |
205 | |||
206 | average = 0.0; | ||
207 | for (c=0; c<c_new;c++) | ||
159 | { | 208 | { |
160 | average += (double) results[c].duration; | 209 | average += (double) results_new[c].duration; |
161 | GNUNET_asprintf(&temp, "%sm%i,%llu,%llu,%llu,%llu,", (output==NULL) ? "" : output, c, results[c].peers, results[c].mechs, results[c].duration, results[c].solution); | ||
162 | GNUNET_free_non_null (output); | ||
163 | output = temp; | ||
164 | } | 210 | } |
165 | average /= measure; | 211 | average /= c_new; |
166 | 212 | ||
167 | for (c=0; c<MEASUREMENTS;c++) | 213 | stddev = 0.0; |
214 | for (c=0; c<c_new;c++) | ||
168 | { | 215 | { |
169 | stddev += (results[c].duration - average) * (results[c].duration - average); | 216 | stddev += (results_new[c].duration - average) * (results_new[c].duration - average); |
170 | } | 217 | } |
171 | stddev /= measure; | 218 | stddev /= c_new; |
172 | stddev = sqrt (stddev); | 219 | stddev = sqrt (stddev); |
220 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"new average: %f stddev: %f\n", average, stddev); | ||
221 | |||
222 | average = 0.0; | ||
223 | for (c=0; c<c_modified;c++) | ||
224 | { | ||
225 | average += (double) results_modified[c].duration; | ||
226 | } | ||
227 | average /= c_modified; | ||
228 | |||
229 | stddev = 0.0; | ||
230 | for (c=0; c<c_modified;c++) | ||
231 | { | ||
232 | stddev += (results_modified[c].duration - average) * (results_modified[c].duration - average); | ||
233 | } | ||
234 | stddev /= c_modified; | ||
235 | stddev = sqrt (stddev); | ||
236 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"modified average: %f stddev: %f\n", average, stddev); | ||
237 | |||
238 | average = 0.0; | ||
239 | for (c=0; c<c_unmodified;c++) | ||
240 | { | ||
241 | average += (double) results_unmodified[c].duration; | ||
242 | } | ||
243 | average /= c_unmodified; | ||
244 | stddev = 0.0; | ||
245 | for (c=0; c<c_unmodified;c++) | ||
246 | { | ||
247 | stddev += (results_unmodified[c].duration - average) * (results_unmodified[c].duration - average); | ||
248 | } | ||
249 | stddev /= c_unmodified; | ||
250 | stddev = sqrt (stddev); | ||
251 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"unmodified average: %f stddev: %f\n", average, stddev); | ||
252 | |||
253 | |||
254 | |||
255 | |||
173 | 256 | ||
174 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%savg,%f,stddev,%f\n",output,average,stddev); | ||
175 | /* only log benchmark time for 10 peers */ | ||
176 | if (results[MEASUREMENTS-1].peers == (10)) | ||
177 | { | ||
178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Send data to gauger: %f \n", average); | ||
179 | GAUGER ("TRANSPORT", "ATS execution time 10 peers", average , "ms"); | ||
180 | } | ||
181 | shutdown_peers(); | 257 | shutdown_peers(); |
182 | } | 258 | } |
183 | 259 | ||
@@ -187,6 +263,8 @@ int stats_cb (void *cls, | |||
187 | uint64_t value, | 263 | uint64_t value, |
188 | int is_persistent) | 264 | int is_persistent) |
189 | { | 265 | { |
266 | static int printed = GNUNET_NO; | ||
267 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value); | ||
190 | if (0 == strcmp (name,"ATS invalid solutions")) | 268 | if (0 == strcmp (name,"ATS invalid solutions")) |
191 | { | 269 | { |
192 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | 270 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -222,11 +300,15 @@ int stats_cb (void *cls, | |||
222 | { | 300 | { |
223 | s_time = NULL; | 301 | s_time = NULL; |
224 | } | 302 | } |
303 | if (0 == strcmp (name,"ATS state")) | ||
304 | { | ||
305 | s_state = NULL; | ||
306 | } | ||
225 | 307 | ||
226 | if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) | 308 | if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) |
227 | { | 309 | { |
228 | measurement_started = GNUNET_YES; | 310 | measurement_started = GNUNET_YES; |
229 | r_index = 0; | 311 | count = 1; |
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); | 312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); |
231 | } | 313 | } |
232 | 314 | ||
@@ -235,13 +317,57 @@ int stats_cb (void *cls, | |||
235 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); | 317 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); |
236 | if (0 == strcmp (name,"ATS timestamp")) | 318 | if (0 == strcmp (name,"ATS timestamp")) |
237 | { | 319 | { |
238 | if (results[r_index].timestamp == 0) | 320 | if (current.timestamp == 0) |
239 | results[r_index].timestamp = value; | 321 | { |
240 | if (results[r_index].timestamp != value) | 322 | printed = GNUNET_NO; |
323 | current.timestamp = value; | ||
324 | } | ||
325 | if (current.timestamp == value) | ||
326 | { | ||
327 | printed = GNUNET_YES; | ||
328 | } | ||
329 | if (current.timestamp != value) | ||
241 | { | 330 | { |
242 | r_index++; | 331 | if (current.state == ATS_NEW) |
243 | fprintf(stdout, "(%i/%i)", r_index, MEASUREMENTS); | 332 | { |
244 | if (r_index >= MEASUREMENTS) | 333 | if (c_new < MEASUREMENTS) |
334 | { | ||
335 | results_new[c_new] = current; | ||
336 | c_new++; | ||
337 | } | ||
338 | else | ||
339 | { | ||
340 | force_rebuild = GNUNET_NO; | ||
341 | force_q_updates = GNUNET_NO; | ||
342 | send_msg = GNUNET_NO; | ||
343 | } | ||
344 | } | ||
345 | if (current.state == ATS_UNMODIFIED) | ||
346 | { | ||
347 | if (c_unmodified < MEASUREMENTS) | ||
348 | { | ||
349 | results_unmodified[c_unmodified] = current; | ||
350 | c_unmodified++; | ||
351 | } | ||
352 | |||
353 | } | ||
354 | if (current.state == ATS_Q_UPDATED) | ||
355 | { | ||
356 | if (c_modified < MEASUREMENTS) | ||
357 | { | ||
358 | results_modified[c_modified] = current; | ||
359 | c_modified++; | ||
360 | } | ||
361 | else | ||
362 | { | ||
363 | force_q_updates = GNUNET_NO; | ||
364 | force_rebuild = GNUNET_YES; | ||
365 | } | ||
366 | } | ||
367 | count ++; | ||
368 | |||
369 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(new: %i / modified: %i / unmodified: %i) of %i \n", c_new, c_modified, c_unmodified , MEASUREMENTS); | ||
370 | if ((count > MEASUREMENTS * 4) || ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS))) | ||
245 | { | 371 | { |
246 | fprintf(stdout, "\n"); | 372 | fprintf(stdout, "\n"); |
247 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | 373 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -252,35 +378,51 @@ int stats_cb (void *cls, | |||
252 | evaluate_measurements(); | 378 | evaluate_measurements(); |
253 | return GNUNET_SYSERR; | 379 | return GNUNET_SYSERR; |
254 | } | 380 | } |
255 | fprintf(stdout, ".."); | ||
256 | 381 | ||
257 | results[r_index].timestamp = value; | 382 | printed = GNUNET_NO; |
383 | current.timestamp = value; | ||
258 | return GNUNET_OK; | 384 | return GNUNET_OK; |
259 | } | 385 | } |
260 | } | 386 | } |
261 | 387 | ||
262 | if (0 == strcmp (name,"ATS solution")) | 388 | if (0 == strcmp (name,"ATS solution")) |
263 | { | 389 | { |
264 | results[r_index].solution = value; | 390 | current.solution = value; |
265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS solution: %s %llu \n", r_index, name, value); | 391 | if (printed == GNUNET_NO) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); |
266 | } | 392 | } |
267 | 393 | ||
268 | if (0 == strcmp (name,"ATS peers")) | 394 | if (0 == strcmp (name,"ATS peers")) |
269 | { | 395 | { |
270 | results[r_index].peers = value; | 396 | current.peers = value; |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS peers: %s %llu \n", r_index, name, value); | 397 | if (printed == GNUNET_NO) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); |
272 | } | 398 | } |
273 | 399 | ||
274 | if (0 == strcmp (name,"ATS mechanisms")) | 400 | if (0 == strcmp (name,"ATS mechanisms")) |
275 | { | 401 | { |
276 | results[r_index].mechs = value; | 402 | current.mechs = value; |
277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS mechanisms: %s %llu \n", r_index, name, value); | 403 | if (printed == GNUNET_NO) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); |
278 | } | 404 | } |
279 | 405 | ||
280 | if (0 == strcmp (name,"ATS duration")) | 406 | if (0 == strcmp (name,"ATS duration")) |
281 | { | 407 | { |
282 | results[r_index].duration = value; | 408 | current.duration = value; |
283 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS duration: %s %llu \n", r_index, name, value); | 409 | if (printed == GNUNET_NO) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); |
410 | } | ||
411 | if (0 == strcmp (name,"ATS state")) | ||
412 | { | ||
413 | current.state = value; | ||
414 | char * cont; | ||
415 | if (value == ATS_NEW) | ||
416 | cont = "NEW"; | ||
417 | if (value == ATS_C_UPDATED) | ||
418 | cont = "C_UPDATED"; | ||
419 | if (value == ATS_Q_UPDATED) | ||
420 | cont = "Q_UPDATED"; | ||
421 | if (value == ATS_QC_UPDATED) | ||
422 | cont = "QC_UPDATED"; | ||
423 | if (value == ATS_UNMODIFIED) | ||
424 | cont = "UNMODIFIED"; | ||
425 | if (printed == GNUNET_NO) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS state: %s\n", count, cont); | ||
284 | } | 426 | } |
285 | } | 427 | } |
286 | return GNUNET_OK; | 428 | return GNUNET_OK; |
@@ -301,7 +443,7 @@ stats_get_task (void *cls, | |||
301 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); | 443 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); |
302 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); | 444 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); |
303 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); | 445 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); |
304 | 446 | s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL); | |
305 | 447 | ||
306 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); | 448 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); |
307 | } | 449 | } |
@@ -326,6 +468,46 @@ static void connect_peers() | |||
326 | 468 | ||
327 | } | 469 | } |
328 | 470 | ||
471 | size_t send_dummy_data_task (void *cls, size_t size, void *buf) | ||
472 | { | ||
473 | |||
474 | int s = sizeof (struct TestMessage); | ||
475 | struct TestMessage hdr; | ||
476 | |||
477 | hdr.header.size = htons (s); | ||
478 | hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); | ||
479 | if (force_rebuild) | ||
480 | hdr.num = htonl (1); | ||
481 | if (force_q_updates) | ||
482 | hdr.num = htonl (2); | ||
483 | |||
484 | |||
485 | memcpy (buf,&hdr, s); | ||
486 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s); | ||
487 | t = NULL; | ||
488 | return s; | ||
489 | } | ||
490 | |||
491 | void send_task_f (void *cls, | ||
492 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
493 | { | ||
494 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
495 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
496 | return; | ||
497 | |||
498 | if (t!=NULL) | ||
499 | { | ||
500 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | ||
501 | t = NULL; | ||
502 | } | ||
503 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i to %s\n", size, GNUNET_i2s(&master_deamon->id)); | ||
504 | if (send_msg == GNUNET_YES) | ||
505 | t = GNUNET_TRANSPORT_notify_transmit_ready(th, &master_deamon->id, sizeof (struct TestMessage), 0, SEND_TIMEOUT, &send_dummy_data_task, NULL); | ||
506 | send_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000), &send_task_f, NULL); | ||
507 | } | ||
508 | |||
509 | |||
510 | |||
329 | void daemon_connect_cb(void *cls, | 511 | void daemon_connect_cb(void *cls, |
330 | const struct GNUNET_PeerIdentity *first, | 512 | const struct GNUNET_PeerIdentity *first, |
331 | const struct GNUNET_PeerIdentity *second, | 513 | const struct GNUNET_PeerIdentity *second, |
@@ -342,6 +524,15 @@ void daemon_connect_cb(void *cls, | |||
342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s' (%i/%i)\n", firstc, secondc, connected, peers-1); | 524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s' (%i/%i)\n", firstc, secondc, connected, peers-1); |
343 | GNUNET_free(firstc); | 525 | GNUNET_free(firstc); |
344 | GNUNET_free(secondc); | 526 | GNUNET_free(secondc); |
527 | |||
528 | if (((first_daemon == ping_deamon) || (second_daemon == ping_deamon)) && (master_deamon != NULL) && (ping_deamon != NULL)) | ||
529 | { | ||
530 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg,&ping_deamon->id, NULL, NULL,NULL, NULL); | ||
531 | t = NULL; | ||
532 | force_q_updates = GNUNET_YES; | ||
533 | send_msg = GNUNET_YES; | ||
534 | send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL); | ||
535 | } | ||
345 | } | 536 | } |
346 | 537 | ||
347 | void cont_cb (void *cls, int success) | 538 | void cont_cb (void *cls, int success) |
@@ -390,7 +581,13 @@ daemon_start_cb (void *cls, | |||
390 | 581 | ||
391 | if (peers_left == 0) | 582 | if (peers_left == 0) |
392 | { | 583 | { |
393 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 584 | if (ping_deamon == NULL) |
585 | { | ||
586 | ping_deamon = d; | ||
587 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); | ||
588 | } | ||
589 | |||
590 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
394 | "All peers started successfully!\n"); | 591 | "All peers started successfully!\n"); |
395 | connect_peers(); | 592 | connect_peers(); |
396 | ok = 0; | 593 | ok = 0; |
@@ -449,6 +646,11 @@ check () | |||
449 | int | 646 | int |
450 | main (int argc, char *argv[]) | 647 | main (int argc, char *argv[]) |
451 | { | 648 | { |
649 | #if !HAVE_LIBGLPK | ||
650 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n"); | ||
651 | return 0; | ||
652 | #endif | ||
653 | |||
452 | int ret; | 654 | int ret; |
453 | 655 | ||
454 | GNUNET_log_setup ("test-transport-ats", | 656 | GNUNET_log_setup ("test-transport-ats", |