diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-06 14:27:26 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-06 14:27:26 +0000 |
commit | ba830bbe8fe27e46ac748a2e02bdc7dfeb1f3b5c (patch) | |
tree | c0a030ea0dd2a791e6ab9062ef025c4e40c118cf /src/transport/test_transport_ats.c | |
parent | 50ffbcc86ee995fa741860bcdd9546a231edf2a7 (diff) | |
download | gnunet-ba830bbe8fe27e46ac748a2e02bdc7dfeb1f3b5c.tar.gz gnunet-ba830bbe8fe27e46ac748a2e02bdc7dfeb1f3b5c.zip |
changes
Diffstat (limited to 'src/transport/test_transport_ats.c')
-rw-r--r-- | src/transport/test_transport_ats.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index ac10ba1c8..d86fbbf4a 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c | |||
@@ -41,7 +41,7 @@ static int peers_left; | |||
41 | 41 | ||
42 | static int failed_peers; | 42 | static int failed_peers; |
43 | 43 | ||
44 | static int measurement_started; | 44 | static int measurement_started = GNUNET_NO; |
45 | 45 | ||
46 | static struct GNUNET_TESTING_PeerGroup *pg; | 46 | static struct GNUNET_TESTING_PeerGroup *pg; |
47 | 47 | ||
@@ -62,6 +62,7 @@ struct TEST_result | |||
62 | 62 | ||
63 | static int r_index; | 63 | static int r_index; |
64 | //static int measurements; | 64 | //static int measurements; |
65 | static int connected; | ||
65 | static int peers; | 66 | static int peers; |
66 | static struct TEST_result results[MEASUREMENTS]; | 67 | static struct TEST_result results[MEASUREMENTS]; |
67 | 68 | ||
@@ -136,6 +137,11 @@ static void shutdown_peers() | |||
136 | GNUNET_STATISTICS_get_cancel(s_duration); | 137 | GNUNET_STATISTICS_get_cancel(s_duration); |
137 | s_duration = NULL; | 138 | s_duration = NULL; |
138 | } | 139 | } |
140 | if (s_invalid != NULL) | ||
141 | { | ||
142 | GNUNET_STATISTICS_get_cancel(s_invalid); | ||
143 | s_invalid = NULL; | ||
144 | } | ||
139 | 145 | ||
140 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 146 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
141 | } | 147 | } |
@@ -180,7 +186,6 @@ int stats_cb (void *cls, | |||
180 | uint64_t value, | 186 | uint64_t value, |
181 | int is_persistent) | 187 | int is_persistent) |
182 | { | 188 | { |
183 | |||
184 | if (0 == strcmp (name,"ATS invalid solutions")) | 189 | if (0 == strcmp (name,"ATS invalid solutions")) |
185 | { | 190 | { |
186 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | 191 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -193,7 +198,6 @@ int stats_cb (void *cls, | |||
193 | return GNUNET_SYSERR; | 198 | return GNUNET_SYSERR; |
194 | } | 199 | } |
195 | 200 | ||
196 | |||
197 | if (0 == strcmp (name,"ATS solution")) | 201 | if (0 == strcmp (name,"ATS solution")) |
198 | { | 202 | { |
199 | s_solution = NULL; | 203 | s_solution = NULL; |
@@ -224,6 +228,7 @@ int stats_cb (void *cls, | |||
224 | r_index = 0; | 228 | r_index = 0; |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); | 229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); |
226 | } | 230 | } |
231 | |||
227 | if (measurement_started == GNUNET_YES) | 232 | if (measurement_started == GNUNET_YES) |
228 | { | 233 | { |
229 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); | 234 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); |
@@ -244,38 +249,37 @@ int stats_cb (void *cls, | |||
244 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 249 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
245 | } | 250 | } |
246 | evaluate_measurements(); | 251 | evaluate_measurements(); |
247 | return GNUNET_NO; | 252 | return GNUNET_SYSERR; |
248 | } | 253 | } |
249 | fprintf(stderr, ".."); | 254 | fprintf(stderr, ".."); |
250 | 255 | ||
251 | results[r_index].timestamp = value; | 256 | results[r_index].timestamp = value; |
252 | return GNUNET_SYSERR; | 257 | return GNUNET_OK; |
253 | } | 258 | } |
254 | //GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS solution: %s %llu \n", r_index, name, value); | ||
255 | } | 259 | } |
256 | 260 | ||
257 | if (0 == strcmp (name,"ATS solution")) | 261 | if (0 == strcmp (name,"ATS solution")) |
258 | { | 262 | { |
259 | results[r_index].solution = value; | 263 | results[r_index].solution = value; |
260 | //GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS solution: %s %llu \n", r_index, name, value); | 264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS solution: %s %llu \n", r_index, name, value); |
261 | } | 265 | } |
262 | 266 | ||
263 | if (0 == strcmp (name,"ATS peers")) | 267 | if (0 == strcmp (name,"ATS peers")) |
264 | { | 268 | { |
265 | results[r_index].peers = value; | 269 | results[r_index].peers = value; |
266 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS peers: %s %llu \n", r_index, name, value); | 270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS peers: %s %llu \n", r_index, name, value); |
267 | } | 271 | } |
268 | 272 | ||
269 | if (0 == strcmp (name,"ATS mechanisms")) | 273 | if (0 == strcmp (name,"ATS mechanisms")) |
270 | { | 274 | { |
271 | results[r_index].mechs = value; | 275 | results[r_index].mechs = value; |
272 | //GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS mechanisms: %s %llu \n", r_index, name, value); | 276 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS mechanisms: %s %llu \n", r_index, name, value); |
273 | } | 277 | } |
274 | 278 | ||
275 | if (0 == strcmp (name,"ATS duration")) | 279 | if (0 == strcmp (name,"ATS duration")) |
276 | { | 280 | { |
277 | results[r_index].duration = value; | 281 | results[r_index].duration = value; |
278 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS duration: %s %llu \n", r_index, name, value); | 282 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS duration: %s %llu \n", r_index, name, value); |
279 | } | 283 | } |
280 | } | 284 | } |
281 | return GNUNET_OK; | 285 | return GNUNET_OK; |
@@ -295,7 +299,7 @@ stats_get_task (void *cls, | |||
295 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); | 299 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); |
296 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); | 300 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); |
297 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); | 301 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); |
298 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); | 302 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); |
299 | 303 | ||
300 | 304 | ||
301 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); | 305 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); |
@@ -333,7 +337,8 @@ void daemon_connect_cb(void *cls, | |||
333 | { | 337 | { |
334 | char * firstc = strdup(GNUNET_i2s(first)); | 338 | char * firstc = strdup(GNUNET_i2s(first)); |
335 | char * secondc = strdup(GNUNET_i2s(second)); | 339 | char * secondc = strdup(GNUNET_i2s(second)); |
336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s'\n", firstc, secondc); | 340 | connected++; |
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s' (%i/%i)\n", firstc, secondc, connected, peers-1); | ||
337 | GNUNET_free(firstc); | 342 | GNUNET_free(firstc); |
338 | GNUNET_free(secondc); | 343 | GNUNET_free(secondc); |
339 | } | 344 | } |
@@ -459,8 +464,6 @@ main (int argc, char *argv[]) | |||
459 | { | 464 | { |
460 | peers = atoi(argv[1]); | 465 | peers = atoi(argv[1]); |
461 | peers++; | 466 | peers++; |
462 | if(peers <1) | ||
463 | peers = NUM_PEERS; | ||
464 | } | 467 | } |
465 | ret = check (); | 468 | ret = check (); |
466 | /** | 469 | /** |