diff options
Diffstat (limited to 'src/transport/test_transport_ats_multiple_peers.c')
-rw-r--r-- | src/transport/test_transport_ats_multiple_peers.c | 991 |
1 files changed, 489 insertions, 502 deletions
diff --git a/src/transport/test_transport_ats_multiple_peers.c b/src/transport/test_transport_ats_multiple_peers.c index 9d30a061d..d060a4d4b 100644 --- a/src/transport/test_transport_ats_multiple_peers.c +++ b/src/transport/test_transport_ats_multiple_peers.c | |||
@@ -46,17 +46,17 @@ static int peers_left; | |||
46 | static int failed_peers; | 46 | static int failed_peers; |
47 | 47 | ||
48 | static int measurement_started = GNUNET_NO; | 48 | static int measurement_started = GNUNET_NO; |
49 | static char * config_file; | 49 | static char *config_file; |
50 | 50 | ||
51 | static struct GNUNET_TESTING_PeerGroup *pg; | 51 | static struct GNUNET_TESTING_PeerGroup *pg; |
52 | 52 | ||
53 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | 53 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; |
54 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; | 54 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; |
55 | static GNUNET_SCHEDULER_TaskIdentifier send_task; | 55 | static GNUNET_SCHEDULER_TaskIdentifier send_task; |
56 | struct GNUNET_TESTING_Daemon * master_deamon; | 56 | struct GNUNET_TESTING_Daemon *master_deamon; |
57 | struct GNUNET_TESTING_Daemon * ping_deamon; | 57 | struct GNUNET_TESTING_Daemon *ping_deamon; |
58 | 58 | ||
59 | struct GNUNET_STATISTICS_Handle * stats; | 59 | struct GNUNET_STATISTICS_Handle *stats; |
60 | 60 | ||
61 | struct TEST_result | 61 | struct TEST_result |
62 | { | 62 | { |
@@ -87,21 +87,21 @@ static int force_rebuild; | |||
87 | static int send_msg; | 87 | static int send_msg; |
88 | static int machine_parsable; | 88 | static int machine_parsable; |
89 | 89 | ||
90 | static struct TEST_result results_new [MEASUREMENTS+1]; | 90 | static struct TEST_result results_new[MEASUREMENTS + 1]; |
91 | static struct TEST_result results_modified [MEASUREMENTS+1]; | 91 | static struct TEST_result results_modified[MEASUREMENTS + 1]; |
92 | static struct TEST_result results_unmodified[MEASUREMENTS+1]; | 92 | static struct TEST_result results_unmodified[MEASUREMENTS + 1]; |
93 | static struct TEST_result current; | 93 | static struct TEST_result current; |
94 | 94 | ||
95 | static struct GNUNET_STATISTICS_GetHandle * s_solution; | 95 | static struct GNUNET_STATISTICS_GetHandle *s_solution; |
96 | static struct GNUNET_STATISTICS_GetHandle * s_time; | 96 | static struct GNUNET_STATISTICS_GetHandle *s_time; |
97 | static struct GNUNET_STATISTICS_GetHandle * s_peers; | 97 | static struct GNUNET_STATISTICS_GetHandle *s_peers; |
98 | static struct GNUNET_STATISTICS_GetHandle * s_mechs; | 98 | static struct GNUNET_STATISTICS_GetHandle *s_mechs; |
99 | static struct GNUNET_STATISTICS_GetHandle * s_duration; | 99 | static struct GNUNET_STATISTICS_GetHandle *s_duration; |
100 | static struct GNUNET_STATISTICS_GetHandle * s_invalid; | 100 | static struct GNUNET_STATISTICS_GetHandle *s_invalid; |
101 | static struct GNUNET_STATISTICS_GetHandle * s_state; | 101 | static struct GNUNET_STATISTICS_GetHandle *s_state; |
102 | 102 | ||
103 | struct GNUNET_TRANSPORT_TransmitHandle * t; | 103 | struct GNUNET_TRANSPORT_TransmitHandle *t; |
104 | struct GNUNET_TRANSPORT_Handle * th; | 104 | struct GNUNET_TRANSPORT_Handle *th; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * Check whether peers successfully shut down. | 107 | * Check whether peers successfully shut down. |
@@ -110,463 +110,459 @@ static void | |||
110 | shutdown_callback (void *cls, const char *emsg) | 110 | shutdown_callback (void *cls, const char *emsg) |
111 | { | 111 | { |
112 | if (emsg != NULL) | 112 | if (emsg != NULL) |
113 | { | 113 | { |
114 | #if VERBOSE | 114 | #if VERBOSE |
115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); |
116 | "Shutdown of peers failed!\n"); | ||
117 | #endif | 116 | #endif |
118 | if (ok == 0) | 117 | if (ok == 0) |
119 | ok = 666; | 118 | ok = 666; |
120 | } | 119 | } |
121 | else | 120 | else |
122 | { | 121 | { |
123 | #if VERBOSE | 122 | #if VERBOSE |
124 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 123 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n"); |
125 | "All peers successfully shut down!\n"); | 124 | if (stats != NULL) |
126 | if (stats != NULL) | 125 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
127 | GNUNET_STATISTICS_destroy(stats, GNUNET_NO); | 126 | stats = NULL; |
128 | stats = NULL; | ||
129 | #endif | 127 | #endif |
130 | } | 128 | } |
131 | } | 129 | } |
132 | 130 | ||
133 | static void | 131 | static void |
134 | shutdown_peers() | 132 | shutdown_peers () |
135 | { | 133 | { |
136 | if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) | 134 | if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) |
137 | { | 135 | { |
138 | GNUNET_SCHEDULER_cancel(shutdown_task); | 136 | GNUNET_SCHEDULER_cancel (shutdown_task); |
139 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 137 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; |
140 | } | 138 | } |
141 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | 139 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) |
142 | { | 140 | { |
143 | GNUNET_SCHEDULER_cancel(stats_task); | 141 | GNUNET_SCHEDULER_cancel (stats_task); |
144 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 142 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
145 | } | 143 | } |
146 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 144 | if (send_task != GNUNET_SCHEDULER_NO_TASK) |
147 | { | 145 | { |
148 | GNUNET_SCHEDULER_cancel(send_task); | 146 | GNUNET_SCHEDULER_cancel (send_task); |
149 | send_task = GNUNET_SCHEDULER_NO_TASK; | 147 | send_task = GNUNET_SCHEDULER_NO_TASK; |
150 | } | 148 | } |
151 | 149 | ||
152 | if (t != NULL) | 150 | if (t != NULL) |
153 | { | 151 | { |
154 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | 152 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (t); |
155 | t = NULL; | 153 | t = NULL; |
156 | } | 154 | } |
157 | GNUNET_TRANSPORT_disconnect(th); | 155 | GNUNET_TRANSPORT_disconnect (th); |
158 | if (s_time != NULL) | 156 | if (s_time != NULL) |
159 | { | 157 | { |
160 | GNUNET_STATISTICS_get_cancel(s_time); | 158 | GNUNET_STATISTICS_get_cancel (s_time); |
161 | s_time = NULL; | 159 | s_time = NULL; |
162 | } | 160 | } |
163 | if (s_peers != NULL) | 161 | if (s_peers != NULL) |
164 | { | 162 | { |
165 | GNUNET_STATISTICS_get_cancel(s_peers); | 163 | GNUNET_STATISTICS_get_cancel (s_peers); |
166 | s_peers = NULL; | 164 | s_peers = NULL; |
167 | } | 165 | } |
168 | if (s_mechs != NULL) | 166 | if (s_mechs != NULL) |
169 | { | 167 | { |
170 | GNUNET_STATISTICS_get_cancel(s_mechs); | 168 | GNUNET_STATISTICS_get_cancel (s_mechs); |
171 | s_mechs = NULL; | 169 | s_mechs = NULL; |
172 | } | 170 | } |
173 | if (s_solution != NULL) | 171 | if (s_solution != NULL) |
174 | { | 172 | { |
175 | GNUNET_STATISTICS_get_cancel(s_solution); | 173 | GNUNET_STATISTICS_get_cancel (s_solution); |
176 | s_solution = NULL; | 174 | s_solution = NULL; |
177 | } | 175 | } |
178 | if (s_duration != NULL) | 176 | if (s_duration != NULL) |
179 | { | 177 | { |
180 | GNUNET_STATISTICS_get_cancel(s_duration); | 178 | GNUNET_STATISTICS_get_cancel (s_duration); |
181 | s_duration = NULL; | 179 | s_duration = NULL; |
182 | } | 180 | } |
183 | if (s_invalid != NULL) | 181 | if (s_invalid != NULL) |
184 | { | 182 | { |
185 | GNUNET_STATISTICS_get_cancel(s_invalid); | 183 | GNUNET_STATISTICS_get_cancel (s_invalid); |
186 | s_invalid = NULL; | 184 | s_invalid = NULL; |
187 | } | 185 | } |
188 | if (s_state != NULL) | 186 | if (s_state != NULL) |
189 | { | 187 | { |
190 | GNUNET_STATISTICS_get_cancel(s_state); | 188 | GNUNET_STATISTICS_get_cancel (s_state); |
191 | s_state = NULL; | 189 | s_state = NULL; |
192 | } | 190 | } |
193 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 191 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
194 | } | 192 | } |
195 | 193 | ||
196 | static void | 194 | static void |
197 | evaluate_measurements() | 195 | evaluate_measurements () |
198 | { | 196 | { |
199 | int c; | 197 | int c; |
198 | |||
200 | //int mechs = 0; | 199 | //int mechs = 0; |
201 | double average[3]; | 200 | double average[3]; |
202 | double stddev[3]; | 201 | double stddev[3]; |
202 | |||
203 | //char * output; | 203 | //char * output; |
204 | c = 1; | 204 | c = 1; |
205 | 205 | ||
206 | //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs, | 206 | //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs, |
207 | 207 | ||
208 | average[0] = 0.0; | 208 | average[0] = 0.0; |
209 | for (c=0; c<c_new;c++) | 209 | for (c = 0; c < c_new; c++) |
210 | { | 210 | { |
211 | average[0] += (double) results_new[c].duration; | 211 | average[0] += (double) results_new[c].duration; |
212 | } | 212 | } |
213 | average[0] /= c_new; | 213 | average[0] /= c_new; |
214 | 214 | ||
215 | stddev[0] = 0.0; | 215 | stddev[0] = 0.0; |
216 | for (c=0; c<c_new;c++) | 216 | for (c = 0; c < c_new; c++) |
217 | { | 217 | { |
218 | stddev[0] += (results_new[c].duration - average[0]) * | 218 | stddev[0] += (results_new[c].duration - average[0]) * |
219 | (results_new[c].duration - average[0]); | 219 | (results_new[c].duration - average[0]); |
220 | } | 220 | } |
221 | stddev[0] /= c_new; | 221 | stddev[0] /= c_new; |
222 | stddev[0] = sqrt (stddev[0]); | 222 | stddev[0] = sqrt (stddev[0]); |
223 | if (!machine_parsable) | 223 | if (!machine_parsable) |
224 | fprintf (stderr, | 224 | fprintf (stderr, |
225 | "new, %i measurements, average: %f stddev: %f\n", | 225 | "new, %i measurements, average: %f stddev: %f\n", |
226 | c_new, average[0], stddev[0]); | 226 | c_new, average[0], stddev[0]); |
227 | 227 | ||
228 | average[1] = 0.0; | 228 | average[1] = 0.0; |
229 | for (c=0; c<c_modified;c++) | 229 | for (c = 0; c < c_modified; c++) |
230 | { | 230 | { |
231 | average[1] += (double) results_modified[c].duration; | 231 | average[1] += (double) results_modified[c].duration; |
232 | } | 232 | } |
233 | average[1] /= c_modified; | 233 | average[1] /= c_modified; |
234 | 234 | ||
235 | stddev[1] = 0.0; | 235 | stddev[1] = 0.0; |
236 | for (c=0; c<c_modified;c++) | 236 | for (c = 0; c < c_modified; c++) |
237 | { | 237 | { |
238 | stddev[1] += (results_modified[c].duration - average[1]) * | 238 | stddev[1] += (results_modified[c].duration - average[1]) * |
239 | (results_modified[c].duration - average[1]); | 239 | (results_modified[c].duration - average[1]); |
240 | } | 240 | } |
241 | stddev[1] /= c_modified; | 241 | stddev[1] /= c_modified; |
242 | stddev[1] = sqrt (stddev[1]); | 242 | stddev[1] = sqrt (stddev[1]); |
243 | if (!machine_parsable) | 243 | if (!machine_parsable) |
244 | fprintf (stderr, | 244 | fprintf (stderr, |
245 | "modified, %i measurements, average: %f stddev: %f\n", | 245 | "modified, %i measurements, average: %f stddev: %f\n", |
246 | c_modified, average[1], stddev[1]); | 246 | c_modified, average[1], stddev[1]); |
247 | 247 | ||
248 | average[2] = 0.0; | 248 | average[2] = 0.0; |
249 | for (c=0; c<c_unmodified;c++) | 249 | for (c = 0; c < c_unmodified; c++) |
250 | { | 250 | { |
251 | average[2] += (double) results_unmodified[c].duration; | 251 | average[2] += (double) results_unmodified[c].duration; |
252 | } | 252 | } |
253 | average[2] /= c_unmodified; | 253 | average[2] /= c_unmodified; |
254 | stddev[2] = 0.0; | 254 | stddev[2] = 0.0; |
255 | for (c=0; c<c_unmodified;c++) | 255 | for (c = 0; c < c_unmodified; c++) |
256 | { | 256 | { |
257 | stddev[2] += (results_unmodified[c].duration - average[2]) * | 257 | stddev[2] += (results_unmodified[c].duration - average[2]) * |
258 | (results_unmodified[c].duration - average[2]); | 258 | (results_unmodified[c].duration - average[2]); |
259 | } | 259 | } |
260 | stddev[2] /= c_unmodified; | 260 | stddev[2] /= c_unmodified; |
261 | stddev[2] = sqrt (stddev[2]); | 261 | stddev[2] = sqrt (stddev[2]); |
262 | 262 | ||
263 | if (!machine_parsable) | 263 | if (!machine_parsable) |
264 | fprintf (stderr, | 264 | fprintf (stderr, |
265 | "unmodified, %i measurements, average: %f stddev: %f\n", | 265 | "unmodified, %i measurements, average: %f stddev: %f\n", |
266 | c_unmodified, average[2], stddev[2]); | 266 | c_unmodified, average[2], stddev[2]); |
267 | 267 | ||
268 | if (machine_parsable) | 268 | if (machine_parsable) |
269 | fprintf (stderr, | 269 | fprintf (stderr, |
270 | "peers,%i,mechs,%llu," | 270 | "peers,%i,mechs,%llu," |
271 | "new,%i,%f,%f," | 271 | "new,%i,%f,%f," |
272 | "mod,%i,%f,%f," | 272 | "mod,%i,%f,%f," |
273 | "unmod,%i,%f,%f\n", | 273 | "unmod,%i,%f,%f\n", |
274 | peers-1, (unsigned long long) results_unmodified[0].mechs, | 274 | peers - 1, (unsigned long long) results_unmodified[0].mechs, |
275 | c_new, average[0], stddev[0], | 275 | c_new, average[0], stddev[0], |
276 | c_modified, average[1], stddev[1], | 276 | c_modified, average[1], stddev[1], |
277 | c_unmodified, average[2], stddev[2]); | 277 | c_unmodified, average[2], stddev[2]); |
278 | shutdown_peers(); | 278 | shutdown_peers (); |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
282 | static int | 282 | static int |
283 | stats_cb (void *cls, | 283 | stats_cb (void *cls, |
284 | const char *subsystem, | 284 | const char *subsystem, |
285 | const char *name, | 285 | const char *name, uint64_t value, int is_persistent) |
286 | uint64_t value, | ||
287 | int is_persistent) | ||
288 | { | 286 | { |
289 | static int printed = GNUNET_NO; | 287 | static int printed = GNUNET_NO; |
288 | |||
290 | #if VERBOSE_ATS | 289 | #if VERBOSE_ATS |
291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value); | 290 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name, value); |
292 | #endif | 291 | #endif |
293 | if (0 == strcmp (name,"ATS invalid solutions")) | 292 | if (0 == strcmp (name, "ATS invalid solutions")) |
294 | { | 293 | { |
295 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | 294 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) |
296 | { | ||
297 | GNUNET_SCHEDULER_cancel(stats_task); | ||
298 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
299 | } | ||
300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", | ||
301 | value); | ||
302 | shutdown_peers(); | ||
303 | return GNUNET_SYSERR; | ||
304 | } | ||
305 | |||
306 | if (0 == strcmp (name,"ATS solution")) | ||
307 | { | 295 | { |
308 | s_solution = NULL; | 296 | GNUNET_SCHEDULER_cancel (stats_task); |
309 | } | 297 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
310 | |||
311 | if (0 == strcmp (name,"ATS peers")) | ||
312 | { | ||
313 | s_peers = NULL; | ||
314 | } | 298 | } |
315 | 299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
316 | if (0 == strcmp (name,"ATS mechanisms")) | 300 | "MLP produced invalid %llu result(s)!\n", value); |
317 | { | 301 | shutdown_peers (); |
318 | s_mechs = NULL; | 302 | return GNUNET_SYSERR; |
303 | } | ||
304 | |||
305 | if (0 == strcmp (name, "ATS solution")) | ||
306 | { | ||
307 | s_solution = NULL; | ||
308 | } | ||
309 | |||
310 | if (0 == strcmp (name, "ATS peers")) | ||
311 | { | ||
312 | s_peers = NULL; | ||
313 | } | ||
314 | |||
315 | if (0 == strcmp (name, "ATS mechanisms")) | ||
316 | { | ||
317 | s_mechs = NULL; | ||
318 | } | ||
319 | |||
320 | if (0 == strcmp (name, "ATS duration")) | ||
321 | { | ||
322 | s_duration = NULL; | ||
323 | } | ||
324 | if (0 == strcmp (name, "ATS timestamp")) | ||
325 | { | ||
326 | s_time = NULL; | ||
327 | } | ||
328 | if (0 == strcmp (name, "ATS state")) | ||
329 | { | ||
330 | s_state = NULL; | ||
331 | } | ||
332 | |||
333 | if ((measurement_started == GNUNET_NO) && | ||
334 | (0 == strcmp (name, "ATS peers")) && (value == peers - 1)) | ||
335 | { | ||
336 | measurement_started = GNUNET_YES; | ||
337 | count = 1; | ||
338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); | ||
339 | #if !VERBOSE | ||
340 | if (!machine_parsable) | ||
341 | fprintf (stderr, "%i", count); | ||
342 | #endif | ||
343 | } | ||
344 | |||
345 | if (measurement_started == GNUNET_YES) | ||
346 | { | ||
347 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); | ||
348 | if (0 == strcmp (name, "ATS timestamp")) | ||
349 | { | ||
350 | if (current.timestamp == 0) | ||
351 | { | ||
352 | printed = GNUNET_NO; | ||
353 | current.timestamp = value; | ||
354 | } | ||
355 | if (current.timestamp == value) | ||
356 | { | ||
357 | printed = GNUNET_YES; | ||
358 | } | ||
359 | if (current.timestamp != value) | ||
360 | { | ||
361 | if (current.state == ATS_NEW) | ||
362 | { | ||
363 | if (c_new < MEASUREMENTS) | ||
364 | { | ||
365 | results_new[c_new] = current; | ||
366 | c_new++; | ||
367 | } | ||
368 | else | ||
369 | { | ||
370 | force_rebuild = GNUNET_NO; | ||
371 | force_q_updates = GNUNET_NO; | ||
372 | send_msg = GNUNET_NO; | ||
373 | } | ||
374 | } | ||
375 | if (current.state == ATS_UNMODIFIED) | ||
376 | { | ||
377 | if (c_unmodified < MEASUREMENTS) | ||
378 | { | ||
379 | results_unmodified[c_unmodified] = current; | ||
380 | c_unmodified++; | ||
381 | } | ||
382 | |||
383 | } | ||
384 | if (current.state == ATS_QUALITY_UPDATED) | ||
385 | { | ||
386 | if (c_modified < MEASUREMENTS) | ||
387 | { | ||
388 | results_modified[c_modified] = current; | ||
389 | c_modified++; | ||
390 | } | ||
391 | else | ||
392 | { | ||
393 | force_q_updates = GNUNET_NO; | ||
394 | force_rebuild = GNUNET_YES; | ||
395 | } | ||
396 | } | ||
397 | count++; | ||
398 | #if VERBOSE | ||
399 | fprintf (stderr, | ||
400 | "(new: %i / modified: %i / unmodified: %i) of %i \n", | ||
401 | c_new, c_modified, c_unmodified, MEASUREMENTS); | ||
402 | #endif | ||
403 | if ((c_modified >= MEASUREMENTS) && | ||
404 | (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)) | ||
405 | { | ||
406 | #if !VERBOSE | ||
407 | if (!machine_parsable) | ||
408 | fprintf (stdout, "\n"); | ||
409 | #endif | ||
410 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
411 | { | ||
412 | GNUNET_SCHEDULER_cancel (stats_task); | ||
413 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
414 | } | ||
415 | evaluate_measurements (); | ||
416 | return GNUNET_SYSERR; | ||
417 | } | ||
418 | |||
419 | printed = GNUNET_NO; | ||
420 | current.timestamp = value; | ||
421 | #if !VERBOSE | ||
422 | if (!machine_parsable) | ||
423 | fprintf (stderr, "..%i", count); | ||
424 | #endif | ||
425 | return GNUNET_OK; | ||
426 | } | ||
319 | } | 427 | } |
320 | 428 | ||
321 | if (0 == strcmp (name,"ATS duration")) | 429 | if (0 == strcmp (name, "ATS solution")) |
322 | { | 430 | { |
323 | s_duration = NULL; | 431 | current.solution = value; |
432 | if (printed == GNUNET_NO) | ||
433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
434 | count, name, value); | ||
324 | } | 435 | } |
325 | if (0 == strcmp (name,"ATS timestamp")) | 436 | |
437 | if (0 == strcmp (name, "ATS peers")) | ||
326 | { | 438 | { |
327 | s_time = NULL; | 439 | current.peers = value; |
440 | if (printed == GNUNET_NO) | ||
441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
442 | count, name, value); | ||
328 | } | 443 | } |
329 | if (0 == strcmp (name,"ATS state")) | 444 | |
445 | if (0 == strcmp (name, "ATS mechanisms")) | ||
330 | { | 446 | { |
331 | s_state = NULL; | 447 | current.mechs = value; |
448 | if (printed == GNUNET_NO) | ||
449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
450 | count, name, value); | ||
332 | } | 451 | } |
333 | 452 | ||
334 | if ( (measurement_started == GNUNET_NO) && | 453 | if (0 == strcmp (name, "ATS duration")) |
335 | (0 == strcmp (name, "ATS peers")) && | ||
336 | (value == peers-1) ) | ||
337 | { | 454 | { |
338 | measurement_started = GNUNET_YES; | 455 | current.duration = value; |
339 | count = 1; | 456 | if (printed == GNUNET_NO) |
340 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", |
341 | "All %llu peers connected\n", | 458 | count, name, value); |
342 | value); | ||
343 | #if !VERBOSE | ||
344 | if (! machine_parsable) | ||
345 | fprintf(stderr, "%i", count); | ||
346 | #endif | ||
347 | } | 459 | } |
348 | 460 | if (0 == strcmp (name, "ATS state")) | |
349 | if (measurement_started == GNUNET_YES) | ||
350 | { | 461 | { |
351 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); | 462 | current.state = value; |
352 | if (0 == strcmp (name,"ATS timestamp")) | 463 | const char *cont; |
353 | { | 464 | |
354 | if (current.timestamp == 0) | 465 | switch (value) |
355 | { | 466 | { |
356 | printed = GNUNET_NO; | 467 | case ATS_NEW: |
357 | current.timestamp = value; | 468 | cont = "NEW"; |
358 | } | 469 | break; |
359 | if (current.timestamp == value) | 470 | case ATS_COST_UPDATED: |
360 | { | 471 | cont = "C_UPDATED"; |
361 | printed = GNUNET_YES; | 472 | break; |
362 | } | 473 | case ATS_QUALITY_UPDATED: |
363 | if (current.timestamp != value) | 474 | cont = "Q_UPDATED"; |
364 | { | 475 | break; |
365 | if (current.state == ATS_NEW) | 476 | case ATS_QUALITY_COST_UPDATED: |
366 | { | 477 | cont = "QC_UPDATED"; |
367 | if (c_new < MEASUREMENTS) | 478 | break; |
368 | { | 479 | case ATS_UNMODIFIED: |
369 | results_new[c_new] = current; | 480 | cont = "UNMODIFIED"; |
370 | c_new++; | 481 | break; |
371 | } | 482 | default: |
372 | else | 483 | GNUNET_break (0); |
373 | { | 484 | cont = "<undefined>"; |
374 | force_rebuild = GNUNET_NO; | 485 | break; |
375 | force_q_updates = GNUNET_NO; | 486 | } |
376 | send_msg = GNUNET_NO; | 487 | if (printed == GNUNET_NO) |
377 | } | 488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
378 | } | 489 | "[%i] ATS state: %s\n", count, cont); |
379 | if (current.state == ATS_UNMODIFIED) | ||
380 | { | ||
381 | if (c_unmodified < MEASUREMENTS) | ||
382 | { | ||
383 | results_unmodified[c_unmodified] = current; | ||
384 | c_unmodified++; | ||
385 | } | ||
386 | |||
387 | } | ||
388 | if (current.state == ATS_QUALITY_UPDATED) | ||
389 | { | ||
390 | if (c_modified < MEASUREMENTS) | ||
391 | { | ||
392 | results_modified[c_modified] = current; | ||
393 | c_modified++; | ||
394 | } | ||
395 | else | ||
396 | { | ||
397 | force_q_updates = GNUNET_NO; | ||
398 | force_rebuild = GNUNET_YES; | ||
399 | } | ||
400 | } | ||
401 | count ++; | ||
402 | #if VERBOSE | ||
403 | fprintf (stderr, | ||
404 | "(new: %i / modified: %i / unmodified: %i) of %i \n", | ||
405 | c_new, c_modified, c_unmodified , MEASUREMENTS); | ||
406 | #endif | ||
407 | if ((c_modified >= MEASUREMENTS) && | ||
408 | (c_new >= MEASUREMENTS) && | ||
409 | (c_unmodified >= MEASUREMENTS)) | ||
410 | { | ||
411 | #if !VERBOSE | ||
412 | if (!machine_parsable) | ||
413 | fprintf(stdout, "\n"); | ||
414 | #endif | ||
415 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
416 | { | ||
417 | GNUNET_SCHEDULER_cancel(stats_task); | ||
418 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
419 | } | ||
420 | evaluate_measurements(); | ||
421 | return GNUNET_SYSERR; | ||
422 | } | ||
423 | |||
424 | printed = GNUNET_NO; | ||
425 | current.timestamp = value; | ||
426 | #if !VERBOSE | ||
427 | if (! machine_parsable) | ||
428 | fprintf(stderr, "..%i", count); | ||
429 | #endif | ||
430 | return GNUNET_OK; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | if (0 == strcmp (name,"ATS solution")) | ||
435 | { | ||
436 | current.solution = value; | ||
437 | if (printed == GNUNET_NO) | ||
438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
439 | count, name, value); | ||
440 | } | ||
441 | |||
442 | if (0 == strcmp (name,"ATS peers")) | ||
443 | { | ||
444 | current.peers = value; | ||
445 | if (printed == GNUNET_NO) | ||
446 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
447 | count, name, value); | ||
448 | } | ||
449 | |||
450 | if (0 == strcmp (name,"ATS mechanisms")) | ||
451 | { | ||
452 | current.mechs = value; | ||
453 | if (printed == GNUNET_NO) | ||
454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
455 | count, name, value); | ||
456 | } | ||
457 | |||
458 | if (0 == strcmp (name,"ATS duration")) | ||
459 | { | ||
460 | current.duration = value; | ||
461 | if (printed == GNUNET_NO) | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
463 | count, name, value); | ||
464 | } | ||
465 | if (0 == strcmp (name,"ATS state")) | ||
466 | { | ||
467 | current.state = value; | ||
468 | const char * cont; | ||
469 | switch (value) | ||
470 | { | ||
471 | case ATS_NEW: | ||
472 | cont = "NEW"; | ||
473 | break; | ||
474 | case ATS_COST_UPDATED: | ||
475 | cont = "C_UPDATED"; | ||
476 | break; | ||
477 | case ATS_QUALITY_UPDATED: | ||
478 | cont = "Q_UPDATED"; | ||
479 | break; | ||
480 | case ATS_QUALITY_COST_UPDATED: | ||
481 | cont = "QC_UPDATED"; | ||
482 | break; | ||
483 | case ATS_UNMODIFIED: | ||
484 | cont = "UNMODIFIED"; | ||
485 | break; | ||
486 | default: | ||
487 | GNUNET_break (0); | ||
488 | cont = "<undefined>"; | ||
489 | break; | ||
490 | } | ||
491 | if (printed == GNUNET_NO) | ||
492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
493 | "[%i] ATS state: %s\n", | ||
494 | count, | ||
495 | cont); | ||
496 | } | ||
497 | } | 490 | } |
491 | } | ||
498 | return GNUNET_OK; | 492 | return GNUNET_OK; |
499 | } | 493 | } |
500 | 494 | ||
501 | 495 | ||
502 | static void | 496 | static void |
503 | stats_get_task (void *cls, | 497 | stats_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
504 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
505 | { | 498 | { |
506 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 499 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
507 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 500 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
508 | return; | 501 | return; |
509 | 502 | ||
510 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", | 503 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", |
511 | TIMEOUT, NULL, &stats_cb, NULL); | 504 | TIMEOUT, NULL, &stats_cb, NULL); |
512 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", | 505 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", |
513 | TIMEOUT, NULL, &stats_cb, NULL); | 506 | TIMEOUT, NULL, &stats_cb, NULL); |
514 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", | 507 | s_duration = GNUNET_STATISTICS_get (stats, "transport", "ATS duration", |
515 | TIMEOUT, NULL, &stats_cb, NULL); | 508 | TIMEOUT, NULL, &stats_cb, NULL); |
516 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", | 509 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", |
517 | TIMEOUT, NULL, &stats_cb, NULL); | 510 | TIMEOUT, NULL, &stats_cb, NULL); |
518 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", | 511 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", |
519 | TIMEOUT, NULL, &stats_cb, NULL); | 512 | TIMEOUT, NULL, &stats_cb, NULL); |
520 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", | 513 | s_invalid = |
521 | TIMEOUT, NULL, &stats_cb, NULL); | 514 | GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", |
522 | s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", | 515 | TIMEOUT, NULL, &stats_cb, NULL); |
523 | TIMEOUT, NULL, &stats_cb, NULL); | 516 | s_state = |
524 | 517 | GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, | |
525 | stats_task = GNUNET_SCHEDULER_add_delayed( | 518 | &stats_cb, NULL); |
526 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), | 519 | |
527 | &stats_get_task, | 520 | stats_task = |
528 | NULL); | 521 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
522 | (GNUNET_TIME_UNIT_MILLISECONDS, 100), | ||
523 | &stats_get_task, NULL); | ||
529 | } | 524 | } |
530 | 525 | ||
531 | 526 | ||
532 | static void | 527 | static void |
533 | delay (void *cls, | 528 | delay (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
534 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
535 | { | 529 | { |
536 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 530 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; |
537 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 531 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
538 | return; | 532 | return; |
539 | #if VERBOSE | 533 | #if VERBOSE |
540 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 534 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Delay over\n"); |
541 | "Delay over\n"); | ||
542 | #endif | 535 | #endif |
543 | shutdown_peers (); | 536 | shutdown_peers (); |
544 | } | 537 | } |
545 | 538 | ||
546 | static void | 539 | static void |
547 | connect_peers() | 540 | connect_peers () |
548 | { | 541 | { |
549 | shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL); | 542 | shutdown_task = GNUNET_SCHEDULER_add_delayed (DELAY, &delay, NULL); |
550 | } | 543 | } |
551 | 544 | ||
552 | 545 | ||
553 | /* To make compiler happy */ | 546 | /* To make compiler happy */ |
554 | void dummy(void) | 547 | void |
548 | dummy (void) | ||
555 | { | 549 | { |
556 | struct ATS_quality_metric * q = qm; | 550 | struct ATS_quality_metric *q = qm; |
551 | |||
557 | q = NULL; | 552 | q = NULL; |
558 | q++; | 553 | q++; |
559 | struct ATS_ressource * r = ressources; | 554 | struct ATS_ressource *r = ressources; |
555 | |||
560 | r = NULL; | 556 | r = NULL; |
561 | r++; | 557 | r++; |
562 | } | 558 | } |
563 | 559 | ||
564 | static size_t | 560 | static size_t |
565 | send_dummy_data_task (void *cls, size_t size, void *buf) | 561 | send_dummy_data_task (void *cls, size_t size, void *buf) |
566 | { | 562 | { |
567 | int s = sizeof (struct TestMessage); | 563 | int s = sizeof (struct TestMessage); |
568 | struct TestMessage hdr; | 564 | struct TestMessage hdr; |
569 | 565 | ||
570 | hdr.header.size = htons (s); | 566 | hdr.header.size = htons (s); |
571 | hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); | 567 | hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); |
572 | if (force_rebuild) | 568 | if (force_rebuild) |
@@ -574,7 +570,7 @@ send_dummy_data_task (void *cls, size_t size, void *buf) | |||
574 | else if (force_q_updates) | 570 | else if (force_q_updates) |
575 | hdr.num = htonl (2); | 571 | hdr.num = htonl (2); |
576 | else | 572 | else |
577 | hdr.num = htonl (0); | 573 | hdr.num = htonl (0); |
578 | memcpy (buf, &hdr, s); | 574 | memcpy (buf, &hdr, s); |
579 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s); | 575 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s); |
580 | t = NULL; | 576 | t = NULL; |
@@ -582,30 +578,29 @@ send_dummy_data_task (void *cls, size_t size, void *buf) | |||
582 | } | 578 | } |
583 | 579 | ||
584 | 580 | ||
585 | static void | 581 | static void |
586 | send_task_f (void *cls, | 582 | send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
587 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
588 | { | 583 | { |
589 | send_task = GNUNET_SCHEDULER_NO_TASK; | 584 | send_task = GNUNET_SCHEDULER_NO_TASK; |
590 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 585 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
591 | return; | 586 | return; |
592 | 587 | ||
593 | if (t!=NULL) | 588 | if (t != NULL) |
594 | { | 589 | { |
595 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | 590 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (t); |
596 | t = NULL; | 591 | t = NULL; |
597 | } | 592 | } |
598 | 593 | ||
599 | if (send_msg == GNUNET_YES) | 594 | if (send_msg == GNUNET_YES) |
600 | t = GNUNET_TRANSPORT_notify_transmit_ready(th, | 595 | t = GNUNET_TRANSPORT_notify_transmit_ready (th, |
601 | &master_deamon->id, | 596 | &master_deamon->id, |
602 | sizeof (struct TestMessage), 0, | 597 | sizeof (struct TestMessage), 0, |
603 | SEND_TIMEOUT, | 598 | SEND_TIMEOUT, |
604 | &send_dummy_data_task, NULL); | 599 | &send_dummy_data_task, NULL); |
605 | send_task = GNUNET_SCHEDULER_add_delayed( | 600 | send_task = |
606 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000), | 601 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
607 | &send_task_f, | 602 | (GNUNET_TIME_UNIT_MILLISECONDS, 1000), |
608 | NULL); | 603 | &send_task_f, NULL); |
609 | 604 | ||
610 | } | 605 | } |
611 | 606 | ||
@@ -615,135 +610,127 @@ notify_connect (void *cls, | |||
615 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 610 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
616 | uint32_t ats_count) | 611 | uint32_t ats_count) |
617 | { | 612 | { |
618 | send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL); | 613 | send_task = GNUNET_SCHEDULER_add_now (&send_task_f, NULL); |
619 | } | 614 | } |
620 | 615 | ||
621 | static void | 616 | static void |
622 | notify_disconnect (void *cls, | 617 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
623 | const struct GNUNET_PeerIdentity *peer) | ||
624 | { | 618 | { |
625 | if (GNUNET_SCHEDULER_NO_TASK != send_task) | 619 | if (GNUNET_SCHEDULER_NO_TASK != send_task) |
626 | { | 620 | { |
627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 621 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
628 | "Disconnect event before transmission request could be scheduled!\n"); | 622 | "Disconnect event before transmission request could be scheduled!\n"); |
629 | GNUNET_SCHEDULER_cancel (send_task); | 623 | GNUNET_SCHEDULER_cancel (send_task); |
630 | send_task = GNUNET_SCHEDULER_NO_TASK; | 624 | send_task = GNUNET_SCHEDULER_NO_TASK; |
631 | } | 625 | } |
632 | if (NULL != t) | 626 | if (NULL != t) |
633 | { | 627 | { |
634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
635 | "Disconnect event before transmission request could be completed!\n"); | 629 | "Disconnect event before transmission request could be completed!\n"); |
636 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (t); | 630 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (t); |
637 | t = NULL; | 631 | t = NULL; |
638 | } | 632 | } |
639 | } | 633 | } |
640 | 634 | ||
641 | static void | 635 | static void |
642 | daemon_connect_cb(void *cls, | 636 | daemon_connect_cb (void *cls, |
643 | const struct GNUNET_PeerIdentity *first, | 637 | const struct GNUNET_PeerIdentity *first, |
644 | const struct GNUNET_PeerIdentity *second, | 638 | const struct GNUNET_PeerIdentity *second, |
645 | uint32_t distance, | 639 | uint32_t distance, |
646 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 640 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
647 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 641 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
648 | struct GNUNET_TESTING_Daemon *first_daemon, | 642 | struct GNUNET_TESTING_Daemon *first_daemon, |
649 | struct GNUNET_TESTING_Daemon *second_daemon, | 643 | struct GNUNET_TESTING_Daemon *second_daemon, |
650 | const char *emsg) | 644 | const char *emsg) |
651 | { | 645 | { |
652 | char * firstc = strdup(GNUNET_i2s(first)); | 646 | char *firstc = strdup (GNUNET_i2s (first)); |
653 | char * secondc = strdup(GNUNET_i2s(second)); | 647 | char *secondc = strdup (GNUNET_i2s (second)); |
648 | |||
654 | connected++; | 649 | connected++; |
655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 650 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
656 | "Connected peers `%s'<->`%s' (%i/%i)\n", | 651 | "Connected peers `%s'<->`%s' (%i/%i)\n", |
657 | firstc, secondc, connected, peers-1); | 652 | firstc, secondc, connected, peers - 1); |
658 | GNUNET_free(firstc); | 653 | GNUNET_free (firstc); |
659 | GNUNET_free(secondc); | 654 | GNUNET_free (secondc); |
660 | 655 | ||
661 | if ( ( (first_daemon == ping_deamon) || | 656 | if (((first_daemon == ping_deamon) || |
662 | (second_daemon == ping_deamon) ) && | 657 | (second_daemon == ping_deamon)) && |
663 | (master_deamon != NULL) && | 658 | (master_deamon != NULL) && (ping_deamon != NULL)) |
664 | (ping_deamon != NULL) ) | 659 | { |
665 | { | 660 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, |
666 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, | 661 | &ping_deamon->id, |
667 | &ping_deamon->id, | 662 | NULL, NULL, |
668 | NULL, NULL, | 663 | ¬ify_connect, ¬ify_disconnect); |
669 | ¬ify_connect, | 664 | force_q_updates = GNUNET_YES; |
670 | ¬ify_disconnect); | 665 | send_msg = GNUNET_YES; |
671 | force_q_updates = GNUNET_YES; | 666 | } |
672 | send_msg = GNUNET_YES; | ||
673 | } | ||
674 | } | 667 | } |
675 | 668 | ||
676 | 669 | ||
677 | 670 | ||
678 | static void | 671 | static void |
679 | daemon_start_cb (void *cls, | 672 | daemon_start_cb (void *cls, |
680 | const struct GNUNET_PeerIdentity *id, | 673 | const struct GNUNET_PeerIdentity *id, |
681 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 674 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
682 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 675 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
683 | { | 676 | { |
684 | if (id == NULL) | 677 | if (id == NULL) |
678 | { | ||
679 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
680 | "Start callback called with error (too long starting peers), aborting test!\n"); | ||
681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error from testing: `%s'\n"); | ||
682 | failed_peers++; | ||
683 | if (failed_peers == peers_left) | ||
685 | { | 684 | { |
686 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 685 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
687 | "Start callback called with error (too long starting peers), aborting test!\n"); | 686 | "Too many peers failed, ending test!\n"); |
688 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 687 | ok = 1; |
689 | "Error from testing: `%s'\n"); | 688 | shutdown_peers (); |
690 | failed_peers++; | ||
691 | if (failed_peers == peers_left) | ||
692 | { | ||
693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
694 | "Too many peers failed, ending test!\n"); | ||
695 | ok = 1; | ||
696 | shutdown_peers (); | ||
697 | } | ||
698 | return; | ||
699 | } | 689 | } |
690 | return; | ||
691 | } | ||
700 | peers_left--; | 692 | peers_left--; |
701 | 693 | ||
702 | if (master_deamon == NULL) | 694 | if (master_deamon == NULL) |
703 | { | 695 | { |
704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 696 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
705 | "Master peer `%s' '%s'\n", | 697 | "Master peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); |
706 | GNUNET_i2s(id), d->cfgfile); | 698 | master_deamon = d; |
707 | master_deamon = d; | 699 | stats = GNUNET_STATISTICS_create ("transport", master_deamon->cfg); |
708 | stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg); | 700 | GNUNET_assert (stats != NULL); |
709 | GNUNET_assert (stats != NULL); | 701 | stats_task = GNUNET_SCHEDULER_add_now (&stats_get_task, NULL); |
710 | stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL); | 702 | } |
711 | } | ||
712 | else | 703 | else |
713 | { | 704 | { |
714 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 705 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
715 | "Connecting peer `%s'\n", | 706 | "Connecting peer `%s'\n", |
716 | GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id)); | 707 | GNUNET_i2s (id), GNUNET_i2s (&master_deamon->id)); |
717 | GNUNET_TESTING_daemons_connect(d, | 708 | GNUNET_TESTING_daemons_connect (d, |
718 | master_deamon, | 709 | master_deamon, |
719 | TIMEOUT, | 710 | TIMEOUT, |
720 | 0, | 711 | 0, GNUNET_YES, &daemon_connect_cb, NULL); |
721 | GNUNET_YES, | 712 | } |
722 | &daemon_connect_cb, | 713 | |
723 | NULL); | ||
724 | } | ||
725 | |||
726 | if (peers_left == 0) | 714 | if (peers_left == 0) |
715 | { | ||
716 | if (ping_deamon == NULL) | ||
727 | { | 717 | { |
728 | if (ping_deamon == NULL) | 718 | ping_deamon = d; |
729 | { | ||
730 | ping_deamon = d; | ||
731 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
732 | "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); | ||
733 | } | ||
734 | |||
735 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 719 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
736 | "All peers started successfully!\n"); | 720 | "Ping peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); |
737 | connect_peers(); | ||
738 | ok = 0; | ||
739 | } | 721 | } |
722 | |||
723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully!\n"); | ||
724 | connect_peers (); | ||
725 | ok = 0; | ||
726 | } | ||
740 | else if (failed_peers == peers_left) | 727 | else if (failed_peers == peers_left) |
741 | { | 728 | { |
742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 729 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
743 | "Too many peers failed, ending test!\n"); | 730 | "Too many peers failed, ending test!\n"); |
744 | shutdown_peers(); | 731 | shutdown_peers (); |
745 | ok = 1; | 732 | ok = 1; |
746 | } | 733 | } |
747 | } | 734 | } |
748 | 735 | ||
749 | 736 | ||
@@ -758,10 +745,9 @@ run (void *cls, | |||
758 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", peers); | 745 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", peers); |
759 | #endif | 746 | #endif |
760 | peers_left = peers; | 747 | peers_left = peers; |
761 | pg = GNUNET_TESTING_daemons_start (cfg, | 748 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ |
762 | peers_left, /* Total number of peers */ | 749 | peers_left, /* Number of outstanding connections */ |
763 | peers_left, /* Number of outstanding connections */ | 750 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ |
764 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | ||
765 | TIMEOUT, | 751 | TIMEOUT, |
766 | NULL, NULL, | 752 | NULL, NULL, |
767 | &daemon_start_cb, NULL, NULL, NULL, NULL); | 753 | &daemon_start_cb, NULL, NULL, NULL, NULL); |
@@ -808,28 +794,29 @@ main (int argc, char *argv[]) | |||
808 | config_file = "test_transport_ats_4addr.conf"; | 794 | config_file = "test_transport_ats_4addr.conf"; |
809 | 795 | ||
810 | int c = 0; | 796 | int c = 0; |
797 | |||
811 | if (argc >= 2) | 798 | if (argc >= 2) |
812 | { | 799 | { |
813 | for (c=0; c<argc; c++) | 800 | for (c = 0; c < argc; c++) |
814 | { | 801 | { |
815 | /* set peers */ | 802 | /* set peers */ |
816 | if ((strcmp(argv[c], "-p") == 0) && c < (argc-1)) | 803 | if ((strcmp (argv[c], "-p") == 0) && c < (argc - 1)) |
817 | { | 804 | { |
818 | peers = atoi(argv[c+1]); | 805 | peers = atoi (argv[c + 1]); |
819 | peers++; | 806 | peers++; |
820 | } | 807 | } |
821 | /* set machine parsable */ | 808 | /* set machine parsable */ |
822 | if (strcmp(argv[c], "-m") == 0) | 809 | if (strcmp (argv[c], "-m") == 0) |
823 | { | 810 | { |
824 | machine_parsable = GNUNET_YES; | 811 | machine_parsable = GNUNET_YES; |
825 | } | 812 | } |
826 | /* set config file */ | 813 | /* set config file */ |
827 | if ((strcmp(argv[c], "-c") == 0) && c < (argc-1)) | 814 | if ((strcmp (argv[c], "-c") == 0) && c < (argc - 1)) |
828 | { | 815 | { |
829 | config_file = argv[c+1]; | 816 | config_file = argv[c + 1]; |
830 | } | 817 | } |
831 | } | 818 | } |
832 | } | 819 | } |
833 | 820 | ||
834 | ret = check (); | 821 | ret = check (); |
835 | /** | 822 | /** |