diff options
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r-- | src/ats/perf_ats_solver.c | 1373 |
1 files changed, 690 insertions, 683 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 33180a953..6a4eadad7 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010,2011 GNUnet e.V. | 3 | Copyright (C) 2010,2011 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -49,8 +49,7 @@ struct GNUNET_STATISTICS_Handle *GSA_stats; | |||
49 | /** | 49 | /** |
50 | * Handle for ATS address component | 50 | * Handle for ATS address component |
51 | */ | 51 | */ |
52 | struct PerfHandle | 52 | struct PerfHandle { |
53 | { | ||
54 | /** | 53 | /** |
55 | * Performance peers | 54 | * Performance peers |
56 | */ | 55 | */ |
@@ -165,8 +164,7 @@ struct PerfHandle | |||
165 | /** | 164 | /** |
166 | * Data structure to store results for a single iteration | 165 | * Data structure to store results for a single iteration |
167 | */ | 166 | */ |
168 | struct Iteration | 167 | struct Iteration { |
169 | { | ||
170 | struct Result **results_array; | 168 | struct Result **results_array; |
171 | 169 | ||
172 | struct Result **update_results_array; | 170 | struct Result **update_results_array; |
@@ -176,8 +174,7 @@ struct Iteration | |||
176 | /** | 174 | /** |
177 | * Result for a solver calculcation | 175 | * Result for a solver calculcation |
178 | */ | 176 | */ |
179 | struct Result | 177 | struct Result { |
180 | { | ||
181 | /** | 178 | /** |
182 | * Previous element in the linked list | 179 | * Previous element in the linked list |
183 | */ | 180 | */ |
@@ -283,8 +280,7 @@ struct Result | |||
283 | /** | 280 | /** |
284 | * Peer used for the benchmarking | 281 | * Peer used for the benchmarking |
285 | */ | 282 | */ |
286 | struct PerfPeer | 283 | struct PerfPeer { |
287 | { | ||
288 | /** | 284 | /** |
289 | * Peer identitity | 285 | * Peer identitity |
290 | */ | 286 | */ |
@@ -317,19 +313,19 @@ static int ret; | |||
317 | * Do shutdown | 313 | * Do shutdown |
318 | */ | 314 | */ |
319 | static void | 315 | static void |
320 | end_now (int res) | 316 | end_now(int res) |
321 | { | 317 | { |
322 | if (NULL != ph.stat) | 318 | if (NULL != ph.stat) |
323 | { | 319 | { |
324 | GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO); | 320 | GNUNET_STATISTICS_destroy(ph.stat, GNUNET_NO); |
325 | ph.stat = NULL; | 321 | ph.stat = NULL; |
326 | } | 322 | } |
327 | 323 | ||
328 | GNUNET_free_non_null (ph.peers); | 324 | GNUNET_free_non_null(ph.peers); |
329 | GNUNET_free_non_null (ph.iterations_results); | 325 | GNUNET_free_non_null(ph.iterations_results); |
330 | 326 | ||
331 | GAS_normalization_stop (); | 327 | GAS_normalization_stop(); |
332 | GAS_preference_done (); | 328 | GAS_preference_done(); |
333 | ret = res; | 329 | ret = res; |
334 | } | 330 | } |
335 | 331 | ||
@@ -340,13 +336,12 @@ end_now (int res) | |||
340 | * @param cp the number of the peer | 336 | * @param cp the number of the peer |
341 | */ | 337 | */ |
342 | static void | 338 | static void |
343 | perf_create_peer (int cp) | 339 | perf_create_peer(int cp) |
344 | { | 340 | { |
345 | 341 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, | |
346 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | 342 | &ph.peers[cp].id, sizeof(struct GNUNET_PeerIdentity)); |
347 | &ph.peers[cp].id, sizeof (struct GNUNET_PeerIdentity)); | ||
348 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Creating peer #%u: %s \n", cp, | 343 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Creating peer #%u: %s \n", cp, |
349 | GNUNET_i2s (&ph.peers[cp].id)); | 344 | GNUNET_i2s(&ph.peers[cp].id)); |
350 | } | 345 | } |
351 | 346 | ||
352 | 347 | ||
@@ -356,91 +351,94 @@ perf_create_peer (int cp) | |||
356 | * @param cur the address to update | 351 | * @param cur the address to update |
357 | */ | 352 | */ |
358 | static void | 353 | static void |
359 | perf_update_address (struct ATS_Address *cur) | 354 | perf_update_address(struct ATS_Address *cur) |
360 | { | 355 | { |
361 | int r_type; | 356 | int r_type; |
362 | int abs_val; | 357 | int abs_val; |
363 | double rel_val; | 358 | double rel_val; |
364 | 359 | ||
365 | r_type = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2); | 360 | r_type = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2); |
366 | switch (r_type) | 361 | switch (r_type) |
367 | { | 362 | { |
368 | case 0: | 363 | case 0: |
369 | abs_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 364 | abs_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100); |
370 | rel_val = (100 + (double) abs_val) / 100; | 365 | rel_val = (100 + (double)abs_val) / 100; |
371 | 366 | ||
372 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 367 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
373 | "Updating peer `%s' address %p type %s abs val %u rel val %.3f\n", | 368 | "Updating peer `%s' address %p type %s abs val %u rel val %.3f\n", |
374 | GNUNET_i2s (&cur->peer), cur, | 369 | GNUNET_i2s(&cur->peer), cur, |
375 | "GNUNET_ATS_QUALITY_NET_DELAY", | 370 | "GNUNET_ATS_QUALITY_NET_DELAY", |
376 | abs_val, rel_val); | 371 | abs_val, rel_val); |
377 | ph.sf->s_address_update_property (ph.sf->cls, cur, | 372 | ph.sf->s_address_update_property(ph.sf->cls, cur, |
378 | GNUNET_ATS_QUALITY_NET_DELAY, | 373 | GNUNET_ATS_QUALITY_NET_DELAY, |
379 | abs_val, rel_val); | 374 | abs_val, rel_val); |
380 | break; | 375 | break; |
381 | case 1: | 376 | |
382 | abs_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10); | 377 | case 1: |
383 | rel_val = (100 + (double) abs_val) / 100; | 378 | abs_val = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10); |
384 | 379 | rel_val = (100 + (double)abs_val) / 100; | |
385 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 380 | |
386 | "Updating peer `%s' address %p type %s abs val %u rel val %.3f\n", | 381 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
387 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", | 382 | "Updating peer `%s' address %p type %s abs val %u rel val %.3f\n", |
388 | abs_val, rel_val); | 383 | GNUNET_i2s(&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", |
389 | ph.sf->s_address_update_property (ph.sf->cls, cur, | 384 | abs_val, rel_val); |
390 | GNUNET_ATS_QUALITY_NET_DISTANCE, | 385 | ph.sf->s_address_update_property(ph.sf->cls, cur, |
391 | abs_val, rel_val); | 386 | GNUNET_ATS_QUALITY_NET_DISTANCE, |
392 | break; | 387 | abs_val, rel_val); |
393 | default: | 388 | break; |
394 | break; | 389 | |
395 | } | 390 | default: |
391 | break; | ||
392 | } | ||
396 | } | 393 | } |
397 | 394 | ||
398 | 395 | ||
399 | static void | 396 | static void |
400 | bandwidth_changed_cb (void *cls, | 397 | bandwidth_changed_cb(void *cls, |
401 | struct ATS_Address *address) | 398 | struct ATS_Address *address) |
402 | { | 399 | { |
403 | if ( (0 == address->assigned_bw_out) && (0 == address->assigned_bw_in) ) | 400 | if ((0 == address->assigned_bw_out) && (0 == address->assigned_bw_in)) |
404 | return; | 401 | return; |
405 | 402 | ||
406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 403 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
407 | "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n", | 404 | "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n", |
408 | GNUNET_i2s (&address->peer), | 405 | GNUNET_i2s(&address->peer), |
409 | address, | 406 | address, |
410 | address->assigned_bw_out, | 407 | address->assigned_bw_out, |
411 | address->assigned_bw_in); | 408 | address->assigned_bw_in); |
412 | if (GNUNET_YES == ph.bulk_running) | 409 | if (GNUNET_YES == ph.bulk_running) |
413 | GNUNET_break (0); | 410 | GNUNET_break(0); |
414 | return; | 411 | return; |
415 | } | 412 | } |
416 | 413 | ||
417 | 414 | ||
418 | static const double * | 415 | static const double * |
419 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | 416 | get_preferences_cb(void *cls, const struct GNUNET_PeerIdentity *id) |
420 | { | 417 | { |
421 | return GAS_preference_get_by_peer (NULL, id); | 418 | return GAS_preference_get_by_peer(NULL, id); |
422 | } | 419 | } |
423 | 420 | ||
424 | 421 | ||
425 | static void | 422 | static void |
426 | perf_address_initial_update (void *dead, | 423 | perf_address_initial_update(void *dead, |
427 | struct GNUNET_CONTAINER_MultiPeerMap * addresses, | 424 | struct GNUNET_CONTAINER_MultiPeerMap * addresses, |
428 | struct ATS_Address *address) | 425 | struct ATS_Address *address) |
429 | { | 426 | { |
430 | double delay; | 427 | double delay; |
431 | double distance; | 428 | double distance; |
432 | uint32_t random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 429 | uint32_t random = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100); |
433 | delay = (100 + (double) random) / 100; | ||
434 | ph.sf->s_address_update_property (ph.sf->cls, | ||
435 | address, GNUNET_ATS_QUALITY_NET_DELAY, | ||
436 | 100, delay); | ||
437 | 430 | ||
438 | random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 431 | delay = (100 + (double)random) / 100; |
439 | distance = (100 + (double) random) / 100; | 432 | ph.sf->s_address_update_property(ph.sf->cls, |
433 | address, GNUNET_ATS_QUALITY_NET_DELAY, | ||
434 | 100, delay); | ||
440 | 435 | ||
441 | ph.sf->s_address_update_property (ph.sf->cls, address, | 436 | random = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100); |
442 | GNUNET_ATS_QUALITY_NET_DISTANCE, | 437 | distance = (100 + (double)random) / 100; |
443 | 10, distance); | 438 | |
439 | ph.sf->s_address_update_property(ph.sf->cls, address, | ||
440 | GNUNET_ATS_QUALITY_NET_DISTANCE, | ||
441 | 10, distance); | ||
444 | 442 | ||
445 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 443 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
446 | "Initial update address %p : %.2f %.2f\n", | 444 | "Initial update address %p : %.2f %.2f\n", |
@@ -448,23 +446,22 @@ perf_address_initial_update (void *dead, | |||
448 | } | 446 | } |
449 | 447 | ||
450 | 448 | ||
451 | struct DUA_Ctx | 449 | struct DUA_Ctx { |
452 | { | ||
453 | int r; | 450 | int r; |
454 | int c_cur_a; | 451 | int c_cur_a; |
455 | }; | 452 | }; |
456 | 453 | ||
457 | 454 | ||
458 | static int | 455 | static int |
459 | do_update_address (void *cls, | 456 | do_update_address(void *cls, |
460 | const struct GNUNET_PeerIdentity *pid, | 457 | const struct GNUNET_PeerIdentity *pid, |
461 | void *value) | 458 | void *value) |
462 | { | 459 | { |
463 | struct DUA_Ctx *ctx = cls; | 460 | struct DUA_Ctx *ctx = cls; |
464 | struct ATS_Address *addr = value; | 461 | struct ATS_Address *addr = value; |
465 | 462 | ||
466 | if (ctx->c_cur_a == ctx->r) | 463 | if (ctx->c_cur_a == ctx->r) |
467 | perf_update_address (addr); | 464 | perf_update_address(addr); |
468 | ctx->c_cur_a++; | 465 | ctx->c_cur_a++; |
469 | return GNUNET_OK; | 466 | return GNUNET_OK; |
470 | } | 467 | } |
@@ -478,7 +475,7 @@ do_update_address (void *cls, | |||
478 | * @param percentage_peers the percentage of peers to update | 475 | * @param percentage_peers the percentage of peers to update |
479 | */ | 476 | */ |
480 | static void | 477 | static void |
481 | perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percentage_peers) | 478 | perf_update_all_addresses(unsigned int cp, unsigned int ca, unsigned int percentage_peers) |
482 | { | 479 | { |
483 | int c_peer; | 480 | int c_peer; |
484 | int c_select; | 481 | int c_select; |
@@ -488,9 +485,9 @@ perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percen | |||
488 | unsigned int m[cp]; | 485 | unsigned int m[cp]; |
489 | struct DUA_Ctx dua_ctx; | 486 | struct DUA_Ctx dua_ctx; |
490 | 487 | ||
491 | count = cp * ((double) percentage_peers / 100); | 488 | count = cp * ((double)percentage_peers / 100); |
492 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 489 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
493 | "Updating %u of %u peers \n", count, cp); | 490 | "Updating %u of %u peers \n", count, cp); |
494 | 491 | ||
495 | for (c_peer = 0; c_peer < cp; c_peer++) | 492 | for (c_peer = 0; c_peer < cp; c_peer++) |
496 | m[c_peer] = 0; | 493 | m[c_peer] = 0; |
@@ -498,32 +495,32 @@ perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percen | |||
498 | c_select = 0; | 495 | c_select = 0; |
499 | 496 | ||
500 | while (c_select < count) | 497 | while (c_select < count) |
501 | { | ||
502 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, cp); | ||
503 | if (0 == m[r]) | ||
504 | { | 498 | { |
505 | m[r] = 1; | 499 | r = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, cp); |
506 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 500 | if (0 == m[r]) |
507 | "Updating peer [%u] \n", r); | 501 | { |
508 | c_select++; | 502 | m[r] = 1; |
503 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
504 | "Updating peer [%u] \n", r); | ||
505 | c_select++; | ||
506 | } | ||
509 | } | 507 | } |
510 | } | ||
511 | for (c_cur_p = 0; c_cur_p < cp; c_cur_p++) | 508 | for (c_cur_p = 0; c_cur_p < cp; c_cur_p++) |
512 | { | ||
513 | if (1 == m[c_cur_p]) | ||
514 | { | 509 | { |
515 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, ca); | 510 | if (1 == m[c_cur_p]) |
516 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 511 | { |
517 | "Updating peer [%u] address [%u]\n", c_cur_p, r); | 512 | r = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, ca); |
518 | 513 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | |
519 | dua_ctx.c_cur_a = 0; | 514 | "Updating peer [%u] address [%u]\n", c_cur_p, r); |
520 | dua_ctx.r = r; | 515 | |
521 | GNUNET_CONTAINER_multipeermap_get_multiple (ph.addresses, | 516 | dua_ctx.c_cur_a = 0; |
522 | &ph.peers[c_cur_p].id, | 517 | dua_ctx.r = r; |
523 | &do_update_address, | 518 | GNUNET_CONTAINER_multipeermap_get_multiple(ph.addresses, |
524 | &dua_ctx); | 519 | &ph.peers[c_cur_p].id, |
520 | &do_update_address, | ||
521 | &dua_ctx); | ||
522 | } | ||
525 | } | 523 | } |
526 | } | ||
527 | } | 524 | } |
528 | 525 | ||
529 | /** | 526 | /** |
@@ -534,14 +531,14 @@ perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percen | |||
534 | * @return the address | 531 | * @return the address |
535 | */ | 532 | */ |
536 | static struct ATS_Address * | 533 | static struct ATS_Address * |
537 | perf_create_address (int cp, int ca) | 534 | perf_create_address(int cp, int ca) |
538 | { | 535 | { |
539 | struct ATS_Address *a; | 536 | struct ATS_Address *a; |
540 | 537 | ||
541 | a = create_address (&ph.peers[cp].id, | 538 | a = create_address(&ph.peers[cp].id, |
542 | "Test 1", "test 1", strlen ("test 1") + 1, 0); | 539 | "Test 1", "test 1", strlen("test 1") + 1, 0); |
543 | GNUNET_CONTAINER_multipeermap_put (ph.addresses, &ph.peers[cp].id, a, | 540 | GNUNET_CONTAINER_multipeermap_put(ph.addresses, &ph.peers[cp].id, a, |
544 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 541 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
545 | return a; | 542 | return a; |
546 | } | 543 | } |
547 | 544 | ||
@@ -554,93 +551,100 @@ perf_create_address (int cp, int ca) | |||
554 | * @param add additional solver information | 551 | * @param add additional solver information |
555 | */ | 552 | */ |
556 | static void | 553 | static void |
557 | solver_info_cb (void *cls, | 554 | solver_info_cb(void *cls, |
558 | enum GAS_Solver_Operation op, | 555 | enum GAS_Solver_Operation op, |
559 | enum GAS_Solver_Status stat, | 556 | enum GAS_Solver_Status stat, |
560 | enum GAS_Solver_Additional_Information add) | 557 | enum GAS_Solver_Additional_Information add) |
561 | { | 558 | { |
562 | char *add_info; | 559 | char *add_info; |
563 | switch (add) { | 560 | |
561 | switch (add) | ||
562 | { | ||
564 | case GAS_INFO_NONE: | 563 | case GAS_INFO_NONE: |
565 | add_info = "GAS_INFO_NONE"; | 564 | add_info = "GAS_INFO_NONE"; |
566 | break; | 565 | break; |
566 | |||
567 | case GAS_INFO_FULL: | 567 | case GAS_INFO_FULL: |
568 | add_info = "GAS_INFO_MLP_FULL"; | 568 | add_info = "GAS_INFO_MLP_FULL"; |
569 | break; | 569 | break; |
570 | |||
570 | case GAS_INFO_UPDATED: | 571 | case GAS_INFO_UPDATED: |
571 | add_info = "GAS_INFO_MLP_UPDATED"; | 572 | add_info = "GAS_INFO_MLP_UPDATED"; |
572 | break; | 573 | break; |
574 | |||
573 | case GAS_INFO_PROP_ALL: | 575 | case GAS_INFO_PROP_ALL: |
574 | add_info = "GAS_INFO_PROP_ALL"; | 576 | add_info = "GAS_INFO_PROP_ALL"; |
575 | break; | 577 | break; |
578 | |||
576 | case GAS_INFO_PROP_SINGLE: | 579 | case GAS_INFO_PROP_SINGLE: |
577 | add_info = "GAS_INFO_PROP_SINGLE"; | 580 | add_info = "GAS_INFO_PROP_SINGLE"; |
578 | break; | 581 | break; |
582 | |||
579 | default: | 583 | default: |
580 | add_info = "INVALID"; | 584 | add_info = "INVALID"; |
581 | break; | 585 | break; |
582 | } | 586 | } |
583 | 587 | ||
584 | struct Result *tmp; | 588 | struct Result *tmp; |
585 | switch (op) | 589 | switch (op) |
586 | { | 590 | { |
587 | case GAS_OP_SOLVE_START: | 591 | case GAS_OP_SOLVE_START: |
588 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 592 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
589 | "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START", | 593 | "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START", |
590 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); | 594 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); |
591 | if (GNUNET_NO == ph.expecting_solution) | 595 | if (GNUNET_NO == ph.expecting_solution) |
592 | { | ||
593 | /* We do not expect a solution at the moment */ | ||
594 | GNUNET_break (0); | ||
595 | return; | ||
596 | } | ||
597 | |||
598 | if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result)) | ||
599 | { | ||
600 | tmp = GNUNET_new (struct Result); | ||
601 | /* Create new result */ | ||
602 | if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update)) | ||
603 | { | ||
604 | ph.current_result = tmp; | ||
605 | //fprintf (stderr,"UPDATE %u %u\n",ph.current_iteration-1, ph.current_p); | ||
606 | ph.iterations_results[ph.current_iteration-1].update_results_array[ph.current_p] = tmp; | ||
607 | } | ||
608 | else | ||
609 | { | 596 | { |
610 | ph.current_result = tmp; | 597 | /* We do not expect a solution at the moment */ |
611 | //fprintf (stderr,"FULL %u %u\n",ph.current_iteration-1, ph.current_p); | 598 | GNUNET_break(0); |
612 | ph.iterations_results[ph.current_iteration-1].results_array[ph.current_p] = tmp; | 599 | return; |
613 | } | 600 | } |
614 | 601 | ||
615 | ph.current_result->addresses = ph.current_a; | 602 | if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result)) |
616 | ph.current_result->peers = ph.current_p; | ||
617 | ph.current_result->s_total = GNUNET_TIME_absolute_get(); | ||
618 | ph.current_result->d_total_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
619 | ph.current_result->d_setup_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
620 | ph.current_result->d_lp_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
621 | ph.current_result->d_mlp_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
622 | ph.current_result->info = add; | ||
623 | if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update)) | ||
624 | { | ||
625 | ph.current_result->update = GNUNET_YES; | ||
626 | } | ||
627 | else | ||
628 | { | 603 | { |
629 | ph.current_result->update = GNUNET_NO; | 604 | tmp = GNUNET_new(struct Result); |
605 | /* Create new result */ | ||
606 | if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update)) | ||
607 | { | ||
608 | ph.current_result = tmp; | ||
609 | //fprintf (stderr,"UPDATE %u %u\n",ph.current_iteration-1, ph.current_p); | ||
610 | ph.iterations_results[ph.current_iteration - 1].update_results_array[ph.current_p] = tmp; | ||
611 | } | ||
612 | else | ||
613 | { | ||
614 | ph.current_result = tmp; | ||
615 | //fprintf (stderr,"FULL %u %u\n",ph.current_iteration-1, ph.current_p); | ||
616 | ph.iterations_results[ph.current_iteration - 1].results_array[ph.current_p] = tmp; | ||
617 | } | ||
618 | |||
619 | ph.current_result->addresses = ph.current_a; | ||
620 | ph.current_result->peers = ph.current_p; | ||
621 | ph.current_result->s_total = GNUNET_TIME_absolute_get(); | ||
622 | ph.current_result->d_total_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
623 | ph.current_result->d_setup_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
624 | ph.current_result->d_lp_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
625 | ph.current_result->d_mlp_full = GNUNET_TIME_UNIT_FOREVER_REL; | ||
626 | ph.current_result->info = add; | ||
627 | if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update)) | ||
628 | { | ||
629 | ph.current_result->update = GNUNET_YES; | ||
630 | } | ||
631 | else | ||
632 | { | ||
633 | ph.current_result->update = GNUNET_NO; | ||
634 | } | ||
630 | } | 635 | } |
631 | |||
632 | } | ||
633 | return; | 636 | return; |
637 | |||
634 | case GAS_OP_SOLVE_STOP: | 638 | case GAS_OP_SOLVE_STOP: |
635 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 639 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
636 | "Solver notifies `%s' with result `%s', `%s'\n", "GAS_OP_SOLVE_STOP", | 640 | "Solver notifies `%s' with result `%s', `%s'\n", "GAS_OP_SOLVE_STOP", |
637 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); | 641 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); |
638 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) | 642 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) |
639 | { | 643 | { |
640 | /* We do not expect a solution at the moment */ | 644 | /* We do not expect a solution at the moment */ |
641 | GNUNET_break (0); | 645 | GNUNET_break(0); |
642 | return; | 646 | return; |
643 | } | 647 | } |
644 | 648 | ||
645 | if (GAS_STAT_SUCCESS == stat) | 649 | if (GAS_STAT_SUCCESS == stat) |
646 | ph.current_result->valid = GNUNET_YES; | 650 | ph.current_result->valid = GNUNET_YES; |
@@ -648,143 +652,148 @@ solver_info_cb (void *cls, | |||
648 | ph.current_result->valid = GNUNET_NO; | 652 | ph.current_result->valid = GNUNET_NO; |
649 | 653 | ||
650 | if (NULL != ph.current_result) | 654 | if (NULL != ph.current_result) |
651 | { | 655 | { |
652 | /* Finalize result */ | 656 | /* Finalize result */ |
653 | ph.current_result->e_total = GNUNET_TIME_absolute_get (); | 657 | ph.current_result->e_total = GNUNET_TIME_absolute_get(); |
654 | ph.current_result->d_total_full = GNUNET_TIME_absolute_get_difference ( | 658 | ph.current_result->d_total_full = GNUNET_TIME_absolute_get_difference( |
655 | ph.current_result->s_total, ph.current_result->e_total); | 659 | ph.current_result->s_total, ph.current_result->e_total); |
656 | } | 660 | } |
657 | ph.current_result = NULL; | 661 | ph.current_result = NULL; |
658 | return; | 662 | return; |
659 | 663 | ||
660 | case GAS_OP_SOLVE_SETUP_START: | 664 | case GAS_OP_SOLVE_SETUP_START: |
661 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 665 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
662 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START", | 666 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START", |
663 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 667 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
664 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) | 668 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) |
665 | { | 669 | { |
666 | GNUNET_break(0); | 670 | GNUNET_break(0); |
667 | return; | 671 | return; |
668 | } | 672 | } |
669 | 673 | ||
670 | if (GAS_STAT_SUCCESS == stat) | 674 | if (GAS_STAT_SUCCESS == stat) |
671 | ph.current_result->valid = GNUNET_YES; | 675 | ph.current_result->valid = GNUNET_YES; |
672 | else | 676 | else |
673 | ph.current_result->valid = GNUNET_NO; | 677 | ph.current_result->valid = GNUNET_NO; |
674 | 678 | ||
675 | ph.current_result->s_setup = GNUNET_TIME_absolute_get (); | 679 | ph.current_result->s_setup = GNUNET_TIME_absolute_get(); |
676 | return; | 680 | return; |
677 | 681 | ||
678 | case GAS_OP_SOLVE_SETUP_STOP: | 682 | case GAS_OP_SOLVE_SETUP_STOP: |
679 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 683 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
680 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP", | 684 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP", |
681 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 685 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
682 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) | 686 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) |
683 | { | 687 | { |
684 | GNUNET_break(0); | 688 | GNUNET_break(0); |
685 | return; | 689 | return; |
686 | } | 690 | } |
687 | 691 | ||
688 | if (GAS_STAT_SUCCESS == stat) | 692 | if (GAS_STAT_SUCCESS == stat) |
689 | ph.current_result->valid = GNUNET_YES; | 693 | ph.current_result->valid = GNUNET_YES; |
690 | else | 694 | else |
691 | ph.current_result->valid = GNUNET_NO; | 695 | ph.current_result->valid = GNUNET_NO; |
692 | 696 | ||
693 | ph.current_result->e_setup = GNUNET_TIME_absolute_get (); | 697 | ph.current_result->e_setup = GNUNET_TIME_absolute_get(); |
694 | ph.current_result->d_setup_full = GNUNET_TIME_absolute_get_difference ( | 698 | ph.current_result->d_setup_full = GNUNET_TIME_absolute_get_difference( |
695 | ph.current_result->s_setup, ph.current_result->e_setup); | 699 | ph.current_result->s_setup, ph.current_result->e_setup); |
696 | return; | 700 | return; |
697 | 701 | ||
698 | case GAS_OP_SOLVE_MLP_LP_START: | 702 | case GAS_OP_SOLVE_MLP_LP_START: |
699 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 703 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
700 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START", | 704 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START", |
701 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 705 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
702 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) | 706 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) |
703 | { | 707 | { |
704 | GNUNET_break(0); | 708 | GNUNET_break(0); |
705 | return; | 709 | return; |
706 | } | 710 | } |
707 | 711 | ||
708 | if (GAS_STAT_SUCCESS == stat) | 712 | if (GAS_STAT_SUCCESS == stat) |
709 | ph.current_result->valid = GNUNET_YES; | 713 | ph.current_result->valid = GNUNET_YES; |
710 | else | 714 | else |
711 | ph.current_result->valid = GNUNET_NO; | 715 | ph.current_result->valid = GNUNET_NO; |
712 | 716 | ||
713 | ph.current_result->s_lp = GNUNET_TIME_absolute_get (); | 717 | ph.current_result->s_lp = GNUNET_TIME_absolute_get(); |
714 | return; | 718 | return; |
719 | |||
715 | case GAS_OP_SOLVE_MLP_LP_STOP: | 720 | case GAS_OP_SOLVE_MLP_LP_STOP: |
716 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 721 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
717 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP", | 722 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP", |
718 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 723 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
719 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) | 724 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) |
720 | { | 725 | { |
721 | GNUNET_break(0); | 726 | GNUNET_break(0); |
722 | return; | 727 | return; |
723 | } | 728 | } |
724 | 729 | ||
725 | if (GAS_STAT_SUCCESS == stat) | 730 | if (GAS_STAT_SUCCESS == stat) |
726 | ph.current_result->valid = GNUNET_YES; | 731 | ph.current_result->valid = GNUNET_YES; |
727 | else | 732 | else |
728 | ph.current_result->valid = GNUNET_NO; | 733 | ph.current_result->valid = GNUNET_NO; |
729 | 734 | ||
730 | ph.current_result->e_lp = GNUNET_TIME_absolute_get (); | 735 | ph.current_result->e_lp = GNUNET_TIME_absolute_get(); |
731 | ph.current_result->d_lp_full = GNUNET_TIME_absolute_get_difference ( | 736 | ph.current_result->d_lp_full = GNUNET_TIME_absolute_get_difference( |
732 | ph.current_result->s_lp, ph.current_result->e_lp); | 737 | ph.current_result->s_lp, ph.current_result->e_lp); |
733 | return; | 738 | return; |
734 | 739 | ||
735 | case GAS_OP_SOLVE_MLP_MLP_START: | 740 | case GAS_OP_SOLVE_MLP_MLP_START: |
736 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 741 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
737 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START", | 742 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START", |
738 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 743 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
739 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) | 744 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) |
740 | { | 745 | { |
741 | GNUNET_break(0); | 746 | GNUNET_break(0); |
742 | return; | 747 | return; |
743 | } | 748 | } |
744 | 749 | ||
745 | if (GAS_STAT_SUCCESS == stat) | 750 | if (GAS_STAT_SUCCESS == stat) |
746 | ph.current_result->valid = GNUNET_YES; | 751 | ph.current_result->valid = GNUNET_YES; |
747 | else | 752 | else |
748 | ph.current_result->valid = GNUNET_NO; | 753 | ph.current_result->valid = GNUNET_NO; |
749 | 754 | ||
750 | ph.current_result->s_mlp = GNUNET_TIME_absolute_get (); | 755 | ph.current_result->s_mlp = GNUNET_TIME_absolute_get(); |
751 | return; | 756 | return; |
757 | |||
752 | case GAS_OP_SOLVE_MLP_MLP_STOP: | 758 | case GAS_OP_SOLVE_MLP_MLP_STOP: |
753 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 759 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
754 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP", | 760 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP", |
755 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 761 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
756 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) | 762 | if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) |
757 | { | 763 | { |
758 | GNUNET_break(0); | 764 | GNUNET_break(0); |
759 | return; | 765 | return; |
760 | } | 766 | } |
761 | 767 | ||
762 | if (GAS_STAT_SUCCESS == stat) | 768 | if (GAS_STAT_SUCCESS == stat) |
763 | ph.current_result->valid = GNUNET_YES; | 769 | ph.current_result->valid = GNUNET_YES; |
764 | else | 770 | else |
765 | ph.current_result->valid = GNUNET_NO; | 771 | ph.current_result->valid = GNUNET_NO; |
766 | 772 | ||
767 | ph.current_result->e_mlp = GNUNET_TIME_absolute_get (); | 773 | ph.current_result->e_mlp = GNUNET_TIME_absolute_get(); |
768 | ph.current_result->d_mlp_full = GNUNET_TIME_absolute_get_difference ( | 774 | ph.current_result->d_mlp_full = GNUNET_TIME_absolute_get_difference( |
769 | ph.current_result->s_mlp, ph.current_result->e_mlp); | 775 | ph.current_result->s_mlp, ph.current_result->e_mlp); |
770 | return; | 776 | return; |
777 | |||
771 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: | 778 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: |
772 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 779 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
773 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", | 780 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", |
774 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 781 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
775 | return; | 782 | return; |
783 | |||
776 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: | 784 | case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: |
777 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 785 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
778 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", | 786 | "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", |
779 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); | 787 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); |
780 | if (GAS_STAT_SUCCESS != stat) | 788 | if (GAS_STAT_SUCCESS != stat) |
781 | { | 789 | { |
782 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 790 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
783 | "Solver `%s' failed to update problem with %u peers and %u address!\n", | 791 | "Solver `%s' failed to update problem with %u peers and %u address!\n", |
784 | ph.ats_string, ph.current_p, ph.current_a); | 792 | ph.ats_string, ph.current_p, ph.current_a); |
785 | } | 793 | } |
786 | 794 | ||
787 | return; | 795 | return; |
796 | |||
788 | default: | 797 | default: |
789 | break; | 798 | break; |
790 | } | 799 | } |
@@ -796,82 +805,82 @@ solver_info_cb (void *cls, | |||
796 | * @param iteration the iteration to evaluate | 805 | * @param iteration the iteration to evaluate |
797 | */ | 806 | */ |
798 | static void | 807 | static void |
799 | evaluate (int iteration) | 808 | evaluate(int iteration) |
800 | { | 809 | { |
801 | struct Result *cur; | 810 | struct Result *cur; |
802 | int cp; | 811 | int cp; |
803 | 812 | ||
804 | for (cp = ph.N_peers_start; cp <= ph.N_peers_end; cp ++) | 813 | for (cp = ph.N_peers_start; cp <= ph.N_peers_end; cp++) |
805 | { | ||
806 | cur = ph.iterations_results[ph.current_iteration-1].results_array[cp]; | ||
807 | if (0 == cp) | ||
808 | continue; | ||
809 | if (NULL == cur) | ||
810 | { | 814 | { |
811 | GNUNET_break (0); | 815 | cur = ph.iterations_results[ph.current_iteration - 1].results_array[cp]; |
812 | fprintf (stderr, | 816 | if (0 == cp) |
813 | "Missing result for %u peers\n", cp); | 817 | continue; |
814 | continue; | 818 | if (NULL == cur) |
815 | } | 819 | { |
820 | GNUNET_break(0); | ||
821 | fprintf(stderr, | ||
822 | "Missing result for %u peers\n", cp); | ||
823 | continue; | ||
824 | } | ||
816 | 825 | ||
817 | 826 | ||
818 | if (GNUNET_NO == cur->valid) | 827 | if (GNUNET_NO == cur->valid) |
819 | { | 828 | { |
820 | fprintf (stderr, | 829 | fprintf(stderr, |
821 | "Total time to solve %s for %u peers %u addresses: %s\n", | 830 | "Total time to solve %s for %u peers %u addresses: %s\n", |
822 | (GNUNET_YES == cur->update) ? "updated" : "full", | 831 | (GNUNET_YES == cur->update) ? "updated" : "full", |
823 | cur->peers, cur->addresses, "Failed to solve!"); | 832 | cur->peers, cur->addresses, "Failed to solve!"); |
824 | continue; | 833 | continue; |
825 | } | 834 | } |
826 | 835 | ||
827 | 836 | ||
828 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total_full.rel_value_us) | 837 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total_full.rel_value_us) |
829 | { | 838 | { |
830 | fprintf (stderr, | 839 | fprintf(stderr, |
831 | "Total time to solve %s for %u peers %u addresses: %llu us\n", | 840 | "Total time to solve %s for %u peers %u addresses: %llu us\n", |
832 | (GNUNET_YES == cur->update) ? "updated" : "full", | 841 | (GNUNET_YES == cur->update) ? "updated" : "full", |
833 | cur->peers, cur->addresses, | 842 | cur->peers, cur->addresses, |
834 | (unsigned long long) cur->d_total_full.rel_value_us); | 843 | (unsigned long long)cur->d_total_full.rel_value_us); |
835 | } | 844 | } |
836 | 845 | ||
837 | 846 | ||
838 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup_full.rel_value_us) | 847 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup_full.rel_value_us) |
839 | { | 848 | { |
840 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 849 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
841 | "Total time to setup %s %u peers %u addresses: %llu us\n", | 850 | "Total time to setup %s %u peers %u addresses: %llu us\n", |
842 | (GNUNET_YES == cur->update) ? "updated" : "full", | 851 | (GNUNET_YES == cur->update) ? "updated" : "full", |
843 | cur->peers, cur->addresses, | 852 | cur->peers, cur->addresses, |
844 | (unsigned long long) cur->d_setup_full.rel_value_us); | 853 | (unsigned long long)cur->d_setup_full.rel_value_us); |
845 | } | 854 | } |
846 | 855 | ||
847 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp_full.rel_value_us) | 856 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp_full.rel_value_us) |
848 | { | 857 | { |
849 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 858 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
850 | "Total time to solve %s LP for %u peers %u addresses: %llu us\n", | 859 | "Total time to solve %s LP for %u peers %u addresses: %llu us\n", |
851 | (GNUNET_YES == cur->update) ? "updated" : "full", | 860 | (GNUNET_YES == cur->update) ? "updated" : "full", |
852 | cur->peers, | 861 | cur->peers, |
853 | cur->addresses, | 862 | cur->addresses, |
854 | (unsigned long long )cur->d_lp_full.rel_value_us); | 863 | (unsigned long long )cur->d_lp_full.rel_value_us); |
855 | } | 864 | } |
856 | 865 | ||
857 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp_full.rel_value_us) | 866 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp_full.rel_value_us) |
858 | { | 867 | { |
859 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 868 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
860 | "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", | 869 | "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", |
861 | (GNUNET_YES == cur->update) ? "updated" : "full", | 870 | (GNUNET_YES == cur->update) ? "updated" : "full", |
862 | cur->peers, cur->addresses, | 871 | cur->peers, cur->addresses, |
863 | (unsigned long long )cur->d_mlp_full.rel_value_us); | 872 | (unsigned long long )cur->d_mlp_full.rel_value_us); |
873 | } | ||
864 | } | 874 | } |
865 | } | ||
866 | } | 875 | } |
867 | 876 | ||
868 | 877 | ||
869 | static unsigned int | 878 | static unsigned int |
870 | get_connectivity_cb (void *cls, | 879 | get_connectivity_cb(void *cls, |
871 | const struct GNUNET_PeerIdentity *peer) | 880 | const struct GNUNET_PeerIdentity *peer) |
872 | { | 881 | { |
873 | return GNUNET_CONTAINER_multipeermap_contains (ph.addresses, | 882 | return GNUNET_CONTAINER_multipeermap_contains(ph.addresses, |
874 | peer); | 883 | peer); |
875 | } | 884 | } |
876 | 885 | ||
877 | 886 | ||
@@ -879,7 +888,7 @@ get_connectivity_cb (void *cls, | |||
879 | * Evaluate average results for all iterations | 888 | * Evaluate average results for all iterations |
880 | */ | 889 | */ |
881 | static void | 890 | static void |
882 | write_all_iterations (void) | 891 | write_all_iterations(void) |
883 | { | 892 | { |
884 | int c_iteration; | 893 | int c_iteration; |
885 | int c_peer; | 894 | int c_peer; |
@@ -898,180 +907,179 @@ write_all_iterations (void) | |||
898 | if (GNUNET_NO == ph.create_datafile) | 907 | if (GNUNET_NO == ph.create_datafile) |
899 | return; | 908 | return; |
900 | 909 | ||
901 | GNUNET_asprintf (&data_fn_full, | 910 | GNUNET_asprintf(&data_fn_full, |
902 | "perf_%s_full_%u-%u_%u_%u.data", | 911 | "perf_%s_full_%u-%u_%u_%u.data", |
903 | ph.ats_string, | 912 | ph.ats_string, |
904 | ph.total_iterations, | 913 | ph.total_iterations, |
905 | ph.N_peers_start, | 914 | ph.N_peers_start, |
906 | ph.N_peers_end, | 915 | ph.N_peers_end, |
907 | ph.N_address); | 916 | ph.N_address); |
908 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 917 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
909 | "Using data file `%s'\n", | 918 | "Using data file `%s'\n", |
910 | data_fn_full); | 919 | data_fn_full); |
911 | 920 | ||
912 | f_full = GNUNET_DISK_file_open (data_fn_full, | 921 | f_full = GNUNET_DISK_file_open(data_fn_full, |
913 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 922 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
914 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 923 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
915 | if (NULL == f_full) | 924 | if (NULL == f_full) |
916 | { | 925 | { |
917 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 926 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
918 | "Cannot open data file `%s'\n", | 927 | "Cannot open data file `%s'\n", |
919 | data_fn_full); | 928 | data_fn_full); |
920 | GNUNET_free (data_fn_full); | 929 | GNUNET_free(data_fn_full); |
921 | return; | 930 | return; |
922 | } | 931 | } |
923 | 932 | ||
924 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | 933 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; |
925 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) | 934 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) |
926 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 935 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
927 | "Cannot write data to log file `%s'\n", | 936 | "Cannot write data to log file `%s'\n", |
928 | data_fn_full); | 937 | data_fn_full); |
929 | 938 | ||
930 | data_fn_update = NULL; | 939 | data_fn_update = NULL; |
931 | if (GNUNET_YES == ph.measure_updates) | 940 | if (GNUNET_YES == ph.measure_updates) |
932 | { | ||
933 | GNUNET_asprintf (&data_fn_update, "perf_%s_update_%u-%u_%u_%u.data", | ||
934 | ph.ats_string, | ||
935 | ph.total_iterations, | ||
936 | ph.N_peers_start, | ||
937 | ph.N_peers_end, | ||
938 | ph.N_address); | ||
939 | f_update = GNUNET_DISK_file_open (data_fn_update, | ||
940 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
941 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
942 | if (NULL == f_update) | ||
943 | { | 941 | { |
944 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 942 | GNUNET_asprintf(&data_fn_update, "perf_%s_update_%u-%u_%u_%u.data", |
945 | "Cannot open gnuplot file `%s'\n", data_fn_update); | 943 | ph.ats_string, |
946 | GNUNET_free (data_fn_update); | 944 | ph.total_iterations, |
947 | if (NULL != f_full) | 945 | ph.N_peers_start, |
948 | GNUNET_DISK_file_close (f_full); | 946 | ph.N_peers_end, |
949 | GNUNET_free (data_fn_full); | 947 | ph.N_address); |
950 | return; | 948 | f_update = GNUNET_DISK_file_open(data_fn_update, |
951 | } | 949 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
952 | 950 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | |
953 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 951 | if (NULL == f_update) |
954 | "Using update data file `%s'\n", | 952 | { |
955 | data_fn_update); | 953 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
956 | 954 | "Cannot open gnuplot file `%s'\n", data_fn_update); | |
957 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | 955 | GNUNET_free(data_fn_update); |
958 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data))) | 956 | if (NULL != f_full) |
959 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 957 | GNUNET_DISK_file_close(f_full); |
960 | "Cannot write data to log file `%s'\n", | 958 | GNUNET_free(data_fn_full); |
961 | data_fn_update); | 959 | return; |
962 | } | 960 | } |
963 | |||
964 | for (c_peer = ph.N_peers_start; c_peer <= ph.N_peers_end; c_peer ++) | ||
965 | { | ||
966 | char * data_str; | ||
967 | char * data_tmp; | ||
968 | char * data_upd_str; | ||
969 | char * data_upd_tmp; | ||
970 | GNUNET_asprintf(&data_str, "%u;%u",c_peer, ph.N_address); | ||
971 | if (ph.measure_updates) | ||
972 | GNUNET_asprintf(&data_upd_str, "%u;%u",c_peer, ph.N_address); | ||
973 | for (c_iteration = 0; c_iteration < ph.total_iterations; c_iteration ++) | ||
974 | { | ||
975 | struct Result *cur_full_res; | ||
976 | struct Result *cur_upd_res; | ||
977 | |||
978 | 961 | ||
962 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
963 | "Using update data file `%s'\n", | ||
964 | data_fn_update); | ||
979 | 965 | ||
980 | //fprintf (stderr, "P: %u I: %u == %p \n", c_peer, c_iteration, cur_res); | 966 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; |
981 | cur_full_res = ph.iterations_results[c_iteration].results_array[c_peer]; | 967 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data, strlen(data))) |
982 | if (c_peer == 0) | 968 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
983 | continue; | 969 | "Cannot write data to log file `%s'\n", |
984 | if (NULL == cur_full_res) | 970 | data_fn_update); |
985 | continue; | 971 | } |
986 | 972 | ||
973 | for (c_peer = ph.N_peers_start; c_peer <= ph.N_peers_end; c_peer++) | ||
974 | { | ||
975 | char * data_str; | ||
976 | char * data_tmp; | ||
977 | char * data_upd_str; | ||
978 | char * data_upd_tmp; | ||
979 | GNUNET_asprintf(&data_str, "%u;%u", c_peer, ph.N_address); | ||
987 | if (ph.measure_updates) | 980 | if (ph.measure_updates) |
988 | { | 981 | GNUNET_asprintf(&data_upd_str, "%u;%u", c_peer, ph.N_address); |
989 | cur_upd_res = ph.iterations_results[c_iteration].update_results_array[c_peer]; | 982 | for (c_iteration = 0; c_iteration < ph.total_iterations; c_iteration++) |
990 | data_upd_tmp = GNUNET_strdup (data_upd_str); | ||
991 | GNUNET_free (data_upd_str); | ||
992 | if (GNUNET_YES == cur_full_res->valid) | ||
993 | { | 983 | { |
994 | GNUNET_asprintf (&data_upd_str, "%s;%llu", data_upd_tmp, | 984 | struct Result *cur_full_res; |
995 | (NULL == cur_upd_res) ? 0 : cur_upd_res->d_total_full.rel_value_us); | 985 | struct Result *cur_upd_res; |
986 | |||
987 | |||
988 | |||
989 | //fprintf (stderr, "P: %u I: %u == %p \n", c_peer, c_iteration, cur_res); | ||
990 | cur_full_res = ph.iterations_results[c_iteration].results_array[c_peer]; | ||
991 | if (c_peer == 0) | ||
992 | continue; | ||
993 | if (NULL == cur_full_res) | ||
994 | continue; | ||
995 | |||
996 | if (ph.measure_updates) | ||
997 | { | ||
998 | cur_upd_res = ph.iterations_results[c_iteration].update_results_array[c_peer]; | ||
999 | data_upd_tmp = GNUNET_strdup(data_upd_str); | ||
1000 | GNUNET_free(data_upd_str); | ||
1001 | if (GNUNET_YES == cur_full_res->valid) | ||
1002 | { | ||
1003 | GNUNET_asprintf(&data_upd_str, "%s;%llu", data_upd_tmp, | ||
1004 | (NULL == cur_upd_res) ? 0 : cur_upd_res->d_total_full.rel_value_us); | ||
1005 | } | ||
1006 | else | ||
1007 | { | ||
1008 | GNUNET_asprintf(&data_upd_str, "%s;", data_upd_tmp); | ||
1009 | } | ||
1010 | GNUNET_free(data_upd_tmp); | ||
1011 | } | ||
1012 | |||
1013 | //fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses); | ||
1014 | //fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us); | ||
1015 | |||
1016 | data_tmp = GNUNET_strdup(data_str); | ||
1017 | GNUNET_free(data_str); | ||
1018 | if (GNUNET_YES == cur_full_res->valid) | ||
1019 | { | ||
1020 | GNUNET_asprintf(&data_str, "%s;%llu", data_tmp, | ||
1021 | cur_full_res->d_total_full.rel_value_us); | ||
1022 | } | ||
1023 | else | ||
1024 | { | ||
1025 | GNUNET_asprintf(&data_str, "%s;", data_tmp); | ||
1026 | } | ||
1027 | |||
1028 | GNUNET_free(data_tmp); | ||
996 | } | 1029 | } |
997 | else | 1030 | data_tmp = GNUNET_strdup(data_str); |
998 | { | 1031 | GNUNET_free(data_str); |
999 | GNUNET_asprintf (&data_upd_str, "%s;", data_upd_tmp); | 1032 | GNUNET_asprintf(&data_str, "%s\n", data_tmp); |
1000 | } | 1033 | GNUNET_free(data_tmp); |
1001 | GNUNET_free (data_upd_tmp); | ||
1002 | |||
1003 | } | ||
1004 | |||
1005 | //fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses); | ||
1006 | //fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us); | ||
1007 | |||
1008 | data_tmp = GNUNET_strdup (data_str); | ||
1009 | GNUNET_free (data_str); | ||
1010 | if (GNUNET_YES == cur_full_res->valid) | ||
1011 | { | ||
1012 | GNUNET_asprintf (&data_str, "%s;%llu", data_tmp, | ||
1013 | cur_full_res->d_total_full.rel_value_us); | ||
1014 | } | ||
1015 | else | ||
1016 | { | ||
1017 | GNUNET_asprintf (&data_str, "%s;", data_tmp); | ||
1018 | } | ||
1019 | 1034 | ||
1020 | GNUNET_free (data_tmp); | 1035 | fprintf(stderr, "Result full solution: %s\n", data_str); |
1021 | } | 1036 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data_str, strlen(data_str))) |
1022 | data_tmp = GNUNET_strdup (data_str); | 1037 | GNUNET_break(0); |
1023 | GNUNET_free (data_str); | 1038 | GNUNET_free(data_str); |
1024 | GNUNET_asprintf (&data_str, "%s\n", data_tmp); | ||
1025 | GNUNET_free (data_tmp); | ||
1026 | |||
1027 | fprintf (stderr, "Result full solution: %s\n", data_str); | ||
1028 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data_str, strlen(data_str))) | ||
1029 | GNUNET_break (0); | ||
1030 | GNUNET_free (data_str); | ||
1031 | 1039 | ||
1032 | if (ph.measure_updates) | 1040 | if (ph.measure_updates) |
1033 | { | 1041 | { |
1034 | data_upd_tmp = GNUNET_strdup (data_upd_str); | 1042 | data_upd_tmp = GNUNET_strdup(data_upd_str); |
1035 | GNUNET_free (data_upd_str); | 1043 | GNUNET_free(data_upd_str); |
1036 | GNUNET_asprintf (&data_upd_str, "%s\n", data_upd_tmp); | 1044 | GNUNET_asprintf(&data_upd_str, "%s\n", data_upd_tmp); |
1037 | GNUNET_free (data_upd_tmp); | 1045 | GNUNET_free(data_upd_tmp); |
1038 | 1046 | ||
1039 | fprintf (stderr, "Result updated solution: `%s'\n", data_upd_str); | 1047 | fprintf(stderr, "Result updated solution: `%s'\n", data_upd_str); |
1040 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data_upd_str, strlen(data_upd_str))) | 1048 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data_upd_str, strlen(data_upd_str))) |
1041 | GNUNET_break (0); | 1049 | GNUNET_break(0); |
1042 | GNUNET_free (data_upd_str); | 1050 | GNUNET_free(data_upd_str); |
1051 | } | ||
1043 | } | 1052 | } |
1044 | } | ||
1045 | 1053 | ||
1046 | if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full))) | 1054 | if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close(f_full))) |
1047 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", | 1055 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", |
1048 | data_fn_full); | 1056 | data_fn_full); |
1049 | GNUNET_free_non_null (data_fn_full); | 1057 | GNUNET_free_non_null(data_fn_full); |
1050 | 1058 | ||
1051 | if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update))) | 1059 | if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close(f_update))) |
1052 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", | 1060 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", |
1053 | data_fn_update); | 1061 | data_fn_update); |
1054 | GNUNET_free_non_null (data_fn_update); | 1062 | GNUNET_free_non_null(data_fn_update); |
1055 | } | 1063 | } |
1056 | 1064 | ||
1057 | 1065 | ||
1058 | static int | 1066 | static int |
1059 | do_delete_address (void *cls, | 1067 | do_delete_address(void *cls, |
1060 | const struct GNUNET_PeerIdentity *pid, | 1068 | const struct GNUNET_PeerIdentity *pid, |
1061 | void *value) | 1069 | void *value) |
1062 | { | 1070 | { |
1063 | struct ATS_Address *cur = value; | 1071 | struct ATS_Address *cur = value; |
1064 | 1072 | ||
1065 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1073 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1066 | "Deleting addresses for peer %u\n", | 1074 | "Deleting addresses for peer %u\n", |
1067 | pid); | 1075 | pid); |
1068 | GNUNET_assert (GNUNET_OK == | 1076 | GNUNET_assert(GNUNET_OK == |
1069 | GNUNET_CONTAINER_multipeermap_remove (ph.addresses, | 1077 | GNUNET_CONTAINER_multipeermap_remove(ph.addresses, |
1070 | pid, | 1078 | pid, |
1071 | cur)); | 1079 | cur)); |
1072 | ph.sf->s_del (ph.sf->cls, cur); | 1080 | ph.sf->s_del(ph.sf->cls, cur); |
1073 | GNUNET_free_non_null (cur->atsi); | 1081 | GNUNET_free_non_null(cur->atsi); |
1074 | GNUNET_free (cur); | 1082 | GNUNET_free(cur); |
1075 | return GNUNET_OK; | 1083 | return GNUNET_OK; |
1076 | } | 1084 | } |
1077 | 1085 | ||
@@ -1080,7 +1088,7 @@ do_delete_address (void *cls, | |||
1080 | * Run a performance iteration | 1088 | * Run a performance iteration |
1081 | */ | 1089 | */ |
1082 | static void | 1090 | static void |
1083 | perf_run_iteration (void) | 1091 | perf_run_iteration(void) |
1084 | { | 1092 | { |
1085 | int cp; | 1093 | int cp; |
1086 | int ca; | 1094 | int ca; |
@@ -1089,125 +1097,125 @@ perf_run_iteration (void) | |||
1089 | struct ATS_Address * cur_addr; | 1097 | struct ATS_Address * cur_addr; |
1090 | uint32_t net; | 1098 | uint32_t net; |
1091 | 1099 | ||
1092 | ph.iterations_results[ph.current_iteration-1].results_array = GNUNET_malloc ((count_p + 1) * sizeof (struct Result *)); | 1100 | ph.iterations_results[ph.current_iteration - 1].results_array = GNUNET_malloc((count_p + 1) * sizeof(struct Result *)); |
1093 | if (ph.measure_updates) | 1101 | if (ph.measure_updates) |
1094 | ph.iterations_results[ph.current_iteration-1].update_results_array = GNUNET_malloc ((count_p + 1) * sizeof (struct Result *)); | 1102 | ph.iterations_results[ph.current_iteration - 1].update_results_array = GNUNET_malloc((count_p + 1) * sizeof(struct Result *)); |
1095 | ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); | 1103 | ph.peers = GNUNET_malloc((count_p) * sizeof(struct PerfPeer)); |
1096 | for (cp = 0; cp < count_p; cp++) | 1104 | for (cp = 0; cp < count_p; cp++) |
1097 | perf_create_peer (cp); | 1105 | perf_create_peer(cp); |
1098 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1106 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1099 | "Iteration %u of %u, added %u peers\n", ph.current_iteration, ph.total_iterations, cp); | 1107 | "Iteration %u of %u, added %u peers\n", ph.current_iteration, ph.total_iterations, cp); |
1100 | 1108 | ||
1101 | for (cp = 0; cp < count_p; cp++) | 1109 | for (cp = 0; cp < count_p; cp++) |
1102 | { | ||
1103 | fprintf (stderr,"%u..", cp); | ||
1104 | if (GNUNET_NO == ph.bulk_running) | ||
1105 | { | ||
1106 | ph.bulk_running = GNUNET_YES; | ||
1107 | ph.sf->s_bulk_start (ph.sf->cls); | ||
1108 | } | ||
1109 | ph.current_p = cp + 1; | ||
1110 | for (ca = 0; ca < count_a; ca++) | ||
1111 | { | ||
1112 | cur_addr = perf_create_address (cp, ca); | ||
1113 | /* Add address */ | ||
1114 | |||
1115 | /* Random network selection */ | ||
1116 | //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_NT_COUNT - 1); | ||
1117 | /* Random equally distributed network selection */ | ||
1118 | net = 1 + (ca % (GNUNET_NT_COUNT - 1)); | ||
1119 | /* fprintf (stderr, "Network: %u `%s'\n", | ||
1120 | * mod_net , GNUNET_NT_to_string(mod_net)); */ | ||
1121 | |||
1122 | cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information); | ||
1123 | cur_addr->atsi_count = 1; | ||
1124 | cur_addr->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); | ||
1125 | cur_addr->atsi[0].value = htonl (net); | ||
1126 | ph.sf->s_add (ph.sf->cls, cur_addr, net); | ||
1127 | |||
1128 | ph.current_a = ca + 1; | ||
1129 | perf_address_initial_update (NULL, ph.addresses, cur_addr); | ||
1130 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1131 | "Adding address for peer %u address %u in network %s\n", cp, ca, | ||
1132 | GNUNET_NT_to_string(net)); | ||
1133 | } | ||
1134 | /* Notify solver about request */ | ||
1135 | ph.sf->s_get (ph.sf->cls, &ph.peers[cp].id); | ||
1136 | |||
1137 | if (cp + 1 >= ph.N_peers_start) | ||
1138 | { | 1110 | { |
1139 | /* Disable bulk to solve the problem */ | 1111 | fprintf(stderr, "%u..", cp); |
1140 | if (GNUNET_YES == ph.bulk_running) | 1112 | if (GNUNET_NO == ph.bulk_running) |
1141 | { | ||
1142 | ph.expecting_solution = GNUNET_YES; | ||
1143 | ph.bulk_running = GNUNET_NO; | ||
1144 | ph.sf->s_bulk_stop (ph.sf->cls); | ||
1145 | } | ||
1146 | else | ||
1147 | GNUNET_break (0); | ||
1148 | |||
1149 | /* Problem is solved by the solver here due to unlocking */ | ||
1150 | ph.expecting_solution = GNUNET_NO; | ||
1151 | |||
1152 | /* Update the problem */ | ||
1153 | if ((0 < ph.opt_update_percent) && (GNUNET_YES == ph.measure_updates)) | ||
1154 | { | ||
1155 | /* Update */ | ||
1156 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1157 | "Updating problem with %u peers and %u addresses\n", cp + 1, ca); | ||
1158 | |||
1159 | ph.expecting_solution = GNUNET_YES; | ||
1160 | ph.performed_update = GNUNET_YES; | ||
1161 | if (GNUNET_NO == ph.bulk_running) | ||
1162 | { | 1113 | { |
1163 | ph.bulk_running = GNUNET_YES; | 1114 | ph.bulk_running = GNUNET_YES; |
1164 | ph.sf->s_bulk_start (ph.sf->cls); | 1115 | ph.sf->s_bulk_start(ph.sf->cls); |
1116 | } | ||
1117 | ph.current_p = cp + 1; | ||
1118 | for (ca = 0; ca < count_a; ca++) | ||
1119 | { | ||
1120 | cur_addr = perf_create_address(cp, ca); | ||
1121 | /* Add address */ | ||
1122 | |||
1123 | /* Random network selection */ | ||
1124 | //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_NT_COUNT - 1); | ||
1125 | /* Random equally distributed network selection */ | ||
1126 | net = 1 + (ca % (GNUNET_NT_COUNT - 1)); | ||
1127 | /* fprintf (stderr, "Network: %u `%s'\n", | ||
1128 | * mod_net , GNUNET_NT_to_string(mod_net)); */ | ||
1129 | |||
1130 | cur_addr->atsi = GNUNET_new(struct GNUNET_ATS_Information); | ||
1131 | cur_addr->atsi_count = 1; | ||
1132 | cur_addr->atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE); | ||
1133 | cur_addr->atsi[0].value = htonl(net); | ||
1134 | ph.sf->s_add(ph.sf->cls, cur_addr, net); | ||
1135 | |||
1136 | ph.current_a = ca + 1; | ||
1137 | perf_address_initial_update(NULL, ph.addresses, cur_addr); | ||
1138 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1139 | "Adding address for peer %u address %u in network %s\n", cp, ca, | ||
1140 | GNUNET_NT_to_string(net)); | ||
1141 | } | ||
1142 | /* Notify solver about request */ | ||
1143 | ph.sf->s_get(ph.sf->cls, &ph.peers[cp].id); | ||
1144 | |||
1145 | if (cp + 1 >= ph.N_peers_start) | ||
1146 | { | ||
1147 | /* Disable bulk to solve the problem */ | ||
1148 | if (GNUNET_YES == ph.bulk_running) | ||
1149 | { | ||
1150 | ph.expecting_solution = GNUNET_YES; | ||
1151 | ph.bulk_running = GNUNET_NO; | ||
1152 | ph.sf->s_bulk_stop(ph.sf->cls); | ||
1153 | } | ||
1154 | else | ||
1155 | GNUNET_break(0); | ||
1156 | |||
1157 | /* Problem is solved by the solver here due to unlocking */ | ||
1158 | ph.expecting_solution = GNUNET_NO; | ||
1159 | |||
1160 | /* Update the problem */ | ||
1161 | if ((0 < ph.opt_update_percent) && (GNUNET_YES == ph.measure_updates)) | ||
1162 | { | ||
1163 | /* Update */ | ||
1164 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
1165 | "Updating problem with %u peers and %u addresses\n", cp + 1, ca); | ||
1166 | |||
1167 | ph.expecting_solution = GNUNET_YES; | ||
1168 | ph.performed_update = GNUNET_YES; | ||
1169 | if (GNUNET_NO == ph.bulk_running) | ||
1170 | { | ||
1171 | ph.bulk_running = GNUNET_YES; | ||
1172 | ph.sf->s_bulk_start(ph.sf->cls); | ||
1173 | } | ||
1174 | perf_update_all_addresses(cp + 1, ca, ph.opt_update_percent); | ||
1175 | ph.bulk_running = GNUNET_NO; | ||
1176 | ph.sf->s_bulk_stop(ph.sf->cls); | ||
1177 | /* Problem is solved by the solver here due to unlocking */ | ||
1178 | ph.performed_update = GNUNET_NO; | ||
1179 | ph.expecting_solution = GNUNET_NO; | ||
1180 | } | ||
1181 | GNUNET_assert(GNUNET_NO == ph.bulk_running); | ||
1165 | } | 1182 | } |
1166 | perf_update_all_addresses (cp + 1, ca, ph.opt_update_percent); | ||
1167 | ph.bulk_running = GNUNET_NO; | ||
1168 | ph.sf->s_bulk_stop (ph.sf->cls); | ||
1169 | /* Problem is solved by the solver here due to unlocking */ | ||
1170 | ph.performed_update = GNUNET_NO; | ||
1171 | ph.expecting_solution = GNUNET_NO; | ||
1172 | } | ||
1173 | GNUNET_assert (GNUNET_NO == ph.bulk_running); | ||
1174 | } | 1183 | } |
1175 | } | 1184 | fprintf(stderr, "\n"); |
1176 | fprintf (stderr,"\n"); | ||
1177 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1185 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1178 | "Done, cleaning up addresses\n"); | 1186 | "Done, cleaning up addresses\n"); |
1179 | if (GNUNET_NO == ph.bulk_running) | 1187 | if (GNUNET_NO == ph.bulk_running) |
1180 | { | 1188 | { |
1181 | ph.sf->s_bulk_start (ph.sf->cls); | 1189 | ph.sf->s_bulk_start(ph.sf->cls); |
1182 | ph.bulk_running = GNUNET_YES; | 1190 | ph.bulk_running = GNUNET_YES; |
1183 | } | 1191 | } |
1184 | 1192 | ||
1185 | for (cp = 0; cp < count_p; cp++) | 1193 | for (cp = 0; cp < count_p; cp++) |
1186 | { | 1194 | { |
1187 | GNUNET_CONTAINER_multipeermap_get_multiple (ph.addresses, | 1195 | GNUNET_CONTAINER_multipeermap_get_multiple(ph.addresses, |
1188 | &ph.peers[cp].id, | 1196 | &ph.peers[cp].id, |
1189 | &do_delete_address, | 1197 | &do_delete_address, |
1190 | NULL); | 1198 | NULL); |
1191 | } | 1199 | } |
1192 | if (GNUNET_NO == ph.bulk_running) | 1200 | if (GNUNET_NO == ph.bulk_running) |
1193 | { | 1201 | { |
1194 | ph.sf->s_bulk_stop (ph.sf->cls); | 1202 | ph.sf->s_bulk_stop(ph.sf->cls); |
1195 | ph.bulk_running = GNUNET_NO; | 1203 | ph.bulk_running = GNUNET_NO; |
1196 | } | 1204 | } |
1197 | 1205 | ||
1198 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1206 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1199 | "Iteration done\n"); | 1207 | "Iteration done\n"); |
1200 | GNUNET_free(ph.peers); | 1208 | GNUNET_free(ph.peers); |
1201 | } | 1209 | } |
1202 | 1210 | ||
1203 | 1211 | ||
1204 | static void | 1212 | static void |
1205 | run (void *cls, char * const *args, const char *cfgfile, | 1213 | run(void *cls, char * const *args, const char *cfgfile, |
1206 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1214 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1207 | { | 1215 | { |
1208 | GNUNET_log_setup ("perf-ats-solver", "WARNING", NULL); | 1216 | GNUNET_log_setup("perf-ats-solver", "WARNING", NULL); |
1209 | char *sep; | 1217 | char *sep; |
1210 | char *src_filename = GNUNET_strdup (__FILE__); | 1218 | char *src_filename = GNUNET_strdup(__FILE__); |
1211 | char *test_filename = cls; | 1219 | char *test_filename = cls; |
1212 | char *solver; | 1220 | char *solver; |
1213 | char *plugin; | 1221 | char *plugin; |
@@ -1218,92 +1226,92 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
1218 | int c2; | 1226 | int c2; |
1219 | 1227 | ||
1220 | /* Extract test name */ | 1228 | /* Extract test name */ |
1221 | if (NULL == (sep = (strstr (src_filename,".c")))) | 1229 | if (NULL == (sep = (strstr(src_filename, ".c")))) |
1222 | { | 1230 | { |
1223 | GNUNET_free (src_filename); | 1231 | GNUNET_free(src_filename); |
1224 | GNUNET_break (0); | 1232 | GNUNET_break(0); |
1225 | ret = 1; | 1233 | ret = 1; |
1226 | return ; | 1234 | return; |
1227 | } | 1235 | } |
1228 | sep[0] = '\0'; | 1236 | sep[0] = '\0'; |
1229 | 1237 | ||
1230 | if (NULL != (sep = strstr (test_filename, ".exe"))) | 1238 | if (NULL != (sep = strstr(test_filename, ".exe"))) |
1231 | sep[0] = '\0'; | 1239 | sep[0] = '\0'; |
1232 | 1240 | ||
1233 | if (NULL == (solver = strstr (test_filename, src_filename))) | 1241 | if (NULL == (solver = strstr(test_filename, src_filename))) |
1234 | { | 1242 | { |
1235 | GNUNET_free (src_filename); | 1243 | GNUNET_free(src_filename); |
1236 | GNUNET_break (0); | 1244 | GNUNET_break(0); |
1237 | ret = 1; | 1245 | ret = 1; |
1238 | return ; | 1246 | return; |
1239 | } | 1247 | } |
1240 | solver += strlen (src_filename) +1; | 1248 | solver += strlen(src_filename) + 1; |
1241 | 1249 | ||
1242 | if (0 == strcmp(solver, "proportional")) | 1250 | if (0 == strcmp(solver, "proportional")) |
1243 | { | 1251 | { |
1244 | ph.ats_string = "proportional"; | 1252 | ph.ats_string = "proportional"; |
1245 | } | 1253 | } |
1246 | else if (0 == strcmp(solver, "mlp")) | 1254 | else if (0 == strcmp(solver, "mlp")) |
1247 | { | 1255 | { |
1248 | ph.ats_string = "mlp"; | 1256 | ph.ats_string = "mlp"; |
1249 | } | 1257 | } |
1250 | else if ((0 == strcmp(solver, "ril"))) | 1258 | else if ((0 == strcmp(solver, "ril"))) |
1251 | { | 1259 | { |
1252 | ph.ats_string = "ril"; | 1260 | ph.ats_string = "ril"; |
1253 | } | 1261 | } |
1254 | else | 1262 | else |
1255 | { | 1263 | { |
1256 | GNUNET_free (src_filename); | 1264 | GNUNET_free(src_filename); |
1257 | GNUNET_break (0); | 1265 | GNUNET_break(0); |
1258 | ret = 1; | 1266 | ret = 1; |
1259 | return ; | 1267 | return; |
1260 | } | 1268 | } |
1261 | GNUNET_free (src_filename); | 1269 | GNUNET_free(src_filename); |
1262 | 1270 | ||
1263 | /* Calculcate peers */ | 1271 | /* Calculcate peers */ |
1264 | if ((0 == ph.N_peers_start) && (0 == ph.N_peers_end)) | 1272 | if ((0 == ph.N_peers_start) && (0 == ph.N_peers_end)) |
1265 | { | 1273 | { |
1266 | ph.N_peers_start = DEFAULT_PEERS_START; | 1274 | ph.N_peers_start = DEFAULT_PEERS_START; |
1267 | ph.N_peers_end = DEFAULT_PEERS_END; | 1275 | ph.N_peers_end = DEFAULT_PEERS_END; |
1268 | } | 1276 | } |
1269 | if (0 == ph.N_address) | 1277 | if (0 == ph.N_address) |
1270 | ph.N_address = DEFAULT_ADDRESSES; | 1278 | ph.N_address = DEFAULT_ADDRESSES; |
1271 | 1279 | ||
1272 | 1280 | ||
1273 | if (ph.N_peers_start != ph.N_peers_end) | 1281 | if (ph.N_peers_start != ph.N_peers_end) |
1274 | fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses in %u iterations\n", | 1282 | fprintf(stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses in %u iterations\n", |
1275 | ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address, ph.total_iterations); | 1283 | ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address, ph.total_iterations); |
1276 | else | 1284 | else |
1277 | fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses in %u iterations\n", | 1285 | fprintf(stderr, "Benchmarking solver `%s' with %u peers and %u addresses in %u iterations\n", |
1278 | ph.ats_string, ph.N_peers_end, ph.N_address, ph.total_iterations); | 1286 | ph.ats_string, ph.N_peers_end, ph.N_address, ph.total_iterations); |
1279 | 1287 | ||
1280 | if (0 == ph.opt_update_percent) | 1288 | if (0 == ph.opt_update_percent) |
1281 | ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE; | 1289 | ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE; |
1282 | 1290 | ||
1283 | /* Load quotas */ | 1291 | /* Load quotas */ |
1284 | solver_cfg = GNUNET_CONFIGURATION_create(); | 1292 | solver_cfg = GNUNET_CONFIGURATION_create(); |
1285 | if ((NULL == solver_cfg) || (GNUNET_SYSERR == (GNUNET_CONFIGURATION_load ( solver_cfg, "perf_ats_solver.conf")))) | 1293 | if ((NULL == solver_cfg) || (GNUNET_SYSERR == (GNUNET_CONFIGURATION_load(solver_cfg, "perf_ats_solver.conf")))) |
1286 | { | 1294 | { |
1287 | GNUNET_break(0); | 1295 | GNUNET_break(0); |
1288 | end_now (1); | 1296 | end_now(1); |
1289 | return; | 1297 | return; |
1290 | } | 1298 | } |
1291 | if (GNUNET_NT_COUNT != load_quotas (solver_cfg, | 1299 | if (GNUNET_NT_COUNT != load_quotas(solver_cfg, |
1292 | quotas_out, quotas_in, GNUNET_NT_COUNT)) | 1300 | quotas_out, quotas_in, GNUNET_NT_COUNT)) |
1293 | { | 1301 | { |
1294 | GNUNET_break(0); | 1302 | GNUNET_break(0); |
1295 | end_now (1); | 1303 | end_now(1); |
1296 | return; | 1304 | return; |
1297 | } | 1305 | } |
1298 | 1306 | ||
1299 | /* Create array of DLL to store results for iterations */ | 1307 | /* Create array of DLL to store results for iterations */ |
1300 | ph.iterations_results = GNUNET_malloc (sizeof (struct Iteration) * ph.total_iterations); | 1308 | ph.iterations_results = GNUNET_malloc(sizeof(struct Iteration) * ph.total_iterations); |
1301 | 1309 | ||
1302 | /* Load solver */ | 1310 | /* Load solver */ |
1303 | ph.env.cfg = solver_cfg; | 1311 | ph.env.cfg = solver_cfg; |
1304 | ph.stat = GNUNET_STATISTICS_create ("ats", cfg); | 1312 | ph.stat = GNUNET_STATISTICS_create("ats", cfg); |
1305 | ph.env.stats = ph.stat; | 1313 | ph.env.stats = ph.stat; |
1306 | ph.addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); | 1314 | ph.addresses = GNUNET_CONTAINER_multipeermap_create(128, GNUNET_NO); |
1307 | ph.env.addresses = ph.addresses; | 1315 | ph.env.addresses = ph.addresses; |
1308 | ph.env.bandwidth_changed_cb = bandwidth_changed_cb; | 1316 | ph.env.bandwidth_changed_cb = bandwidth_changed_cb; |
1309 | ph.env.get_connectivity = &get_connectivity_cb; | 1317 | ph.env.get_connectivity = &get_connectivity_cb; |
@@ -1312,75 +1320,75 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
1312 | ph.env.info_cb = &solver_info_cb; | 1320 | ph.env.info_cb = &solver_info_cb; |
1313 | 1321 | ||
1314 | for (c = 0; c < GNUNET_NT_COUNT; c++) | 1322 | for (c = 0; c < GNUNET_NT_COUNT; c++) |
1315 | { | 1323 | { |
1316 | ph.env.out_quota[c] = quotas_out[c]; | 1324 | ph.env.out_quota[c] = quotas_out[c]; |
1317 | ph.env.in_quota[c] = quotas_in[c]; | 1325 | ph.env.in_quota[c] = quotas_in[c]; |
1318 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1326 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1319 | "Loading network quotas: `%s' %llu %llu \n", | 1327 | "Loading network quotas: `%s' %llu %llu \n", |
1320 | GNUNET_NT_to_string (c), | 1328 | GNUNET_NT_to_string(c), |
1321 | ph.env.out_quota[c], | 1329 | ph.env.out_quota[c], |
1322 | ph.env.in_quota[c]); | 1330 | ph.env.in_quota[c]); |
1323 | } | 1331 | } |
1324 | GAS_normalization_start (); | 1332 | GAS_normalization_start(); |
1325 | GAS_preference_init (); | 1333 | GAS_preference_init(); |
1326 | 1334 | ||
1327 | GNUNET_asprintf (&plugin, | 1335 | GNUNET_asprintf(&plugin, |
1328 | "libgnunet_plugin_ats_%s", | 1336 | "libgnunet_plugin_ats_%s", |
1329 | ph.ats_string); | 1337 | ph.ats_string); |
1330 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1338 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1331 | _("Initializing solver `%s'\n"), | 1339 | _("Initializing solver `%s'\n"), |
1332 | ph.ats_string); | 1340 | ph.ats_string); |
1333 | if (NULL == (ph.sf = GNUNET_PLUGIN_load (plugin, &ph.env))) | 1341 | if (NULL == (ph.sf = GNUNET_PLUGIN_load(plugin, &ph.env))) |
1334 | { | 1342 | { |
1335 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1343 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
1336 | _("Failed to initialize solver `%s'!\n"), | 1344 | _("Failed to initialize solver `%s'!\n"), |
1337 | plugin); | 1345 | plugin); |
1338 | ret = 1; | 1346 | ret = 1; |
1339 | return; | 1347 | return; |
1340 | } | 1348 | } |
1341 | 1349 | ||
1342 | /* Do the benchmark */ | 1350 | /* Do the benchmark */ |
1343 | for (ph.current_iteration = 1; ph.current_iteration <= ph.total_iterations; ph.current_iteration++) | 1351 | for (ph.current_iteration = 1; ph.current_iteration <= ph.total_iterations; ph.current_iteration++) |
1344 | { | 1352 | { |
1345 | fprintf (stderr, | 1353 | fprintf(stderr, |
1346 | "Iteration %u of %u starting\n", | 1354 | "Iteration %u of %u starting\n", |
1347 | ph.current_iteration, | 1355 | ph.current_iteration, |
1348 | ph.total_iterations); | 1356 | ph.total_iterations); |
1349 | perf_run_iteration (); | 1357 | perf_run_iteration(); |
1350 | evaluate (ph.current_iteration); | 1358 | evaluate(ph.current_iteration); |
1351 | fprintf (stderr, | 1359 | fprintf(stderr, |
1352 | "Iteration %u of %u done\n", | 1360 | "Iteration %u of %u done\n", |
1353 | ph.current_iteration, | 1361 | ph.current_iteration, |
1354 | ph.total_iterations); | 1362 | ph.total_iterations); |
1355 | } | 1363 | } |
1356 | if (ph.create_datafile) | 1364 | if (ph.create_datafile) |
1357 | write_all_iterations (); | 1365 | write_all_iterations(); |
1358 | 1366 | ||
1359 | /* Unload solver*/ | 1367 | /* Unload solver*/ |
1360 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1368 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1361 | _("Unloading solver `%s'\n"), | 1369 | _("Unloading solver `%s'\n"), |
1362 | ph.ats_string); | 1370 | ph.ats_string); |
1363 | GNUNET_PLUGIN_unload (plugin, ph.sf); | 1371 | GNUNET_PLUGIN_unload(plugin, ph.sf); |
1364 | ph.sf = NULL; | 1372 | ph.sf = NULL; |
1365 | GNUNET_free (plugin); | 1373 | GNUNET_free(plugin); |
1366 | for (c = 0; c < ph.total_iterations; c++ ) | 1374 | for (c = 0; c < ph.total_iterations; c++) |
1367 | { | ||
1368 | for (c2 = ph.N_peers_start; c2 < ph.N_peers_end; c2++ ) | ||
1369 | { | 1375 | { |
1370 | if (0 == c2) | 1376 | for (c2 = ph.N_peers_start; c2 < ph.N_peers_end; c2++) |
1371 | continue; | 1377 | { |
1378 | if (0 == c2) | ||
1379 | continue; | ||
1380 | if (ph.measure_updates) | ||
1381 | GNUNET_free_non_null(ph.iterations_results[c].update_results_array[c2]); | ||
1382 | GNUNET_free(ph.iterations_results[c].results_array[c2]); | ||
1383 | } | ||
1372 | if (ph.measure_updates) | 1384 | if (ph.measure_updates) |
1373 | GNUNET_free_non_null (ph.iterations_results[c].update_results_array[c2]); | 1385 | GNUNET_free(ph.iterations_results[c].update_results_array); |
1374 | GNUNET_free (ph.iterations_results[c].results_array[c2]); | 1386 | GNUNET_free(ph.iterations_results[c].results_array); |
1375 | } | 1387 | } |
1376 | if (ph.measure_updates) | 1388 | GNUNET_free(ph.iterations_results); |
1377 | GNUNET_free (ph.iterations_results[c].update_results_array); | 1389 | |
1378 | GNUNET_free(ph.iterations_results[c].results_array); | 1390 | GNUNET_CONFIGURATION_destroy(solver_cfg); |
1379 | } | 1391 | GNUNET_STATISTICS_destroy(ph.stat, GNUNET_NO); |
1380 | GNUNET_free (ph.iterations_results); | ||
1381 | |||
1382 | GNUNET_CONFIGURATION_destroy (solver_cfg); | ||
1383 | GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO); | ||
1384 | } | 1392 | } |
1385 | 1393 | ||
1386 | 1394 | ||
@@ -1391,7 +1399,7 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
1391 | * @param argv argument values | 1399 | * @param argv argument values |
1392 | */ | 1400 | */ |
1393 | int | 1401 | int |
1394 | main (int argc, char *argv[]) | 1402 | main(int argc, char *argv[]) |
1395 | { | 1403 | { |
1396 | /* extract command line arguments */ | 1404 | /* extract command line arguments */ |
1397 | ph.opt_update_percent = 0; | 1405 | ph.opt_update_percent = 0; |
@@ -1404,46 +1412,45 @@ main (int argc, char *argv[]) | |||
1404 | ph.total_iterations = 1; | 1412 | ph.total_iterations = 1; |
1405 | 1413 | ||
1406 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 1414 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
1407 | 1415 | GNUNET_GETOPT_option_uint('a', | |
1408 | GNUNET_GETOPT_option_uint ('a', | 1416 | "addresses", |
1409 | "addresses", | 1417 | gettext_noop("addresses to use"), |
1410 | gettext_noop ("addresses to use"), | 1418 | &ph.N_address), |
1411 | &ph.N_address), | 1419 | |
1412 | 1420 | GNUNET_GETOPT_option_uint('s', | |
1413 | GNUNET_GETOPT_option_uint ('s', | 1421 | "start", |
1414 | "start", | 1422 | gettext_noop("start with peer"), |
1415 | gettext_noop ("start with peer"), | 1423 | &ph.N_peers_start), |
1416 | &ph.N_peers_start), | 1424 | |
1417 | 1425 | GNUNET_GETOPT_option_uint('e', | |
1418 | GNUNET_GETOPT_option_uint ('e', | 1426 | "end", |
1419 | "end", | 1427 | gettext_noop("end with peer"), |
1420 | gettext_noop ("end with peer"), | 1428 | &ph.N_peers_end), |
1421 | &ph.N_peers_end), | 1429 | |
1422 | 1430 | GNUNET_GETOPT_option_uint('i', | |
1423 | GNUNET_GETOPT_option_uint ('i', | 1431 | "iterations", |
1424 | "iterations", | 1432 | gettext_noop("number of iterations used for averaging (default: 1)"), |
1425 | gettext_noop ("number of iterations used for averaging (default: 1)"), | 1433 | &ph.total_iterations), |
1426 | &ph.total_iterations), | 1434 | |
1427 | 1435 | GNUNET_GETOPT_option_uint('p', | |
1428 | GNUNET_GETOPT_option_uint ('p', | 1436 | "percentage", |
1429 | "percentage", | 1437 | gettext_noop("update a fix percentage of addresses"), |
1430 | gettext_noop ("update a fix percentage of addresses"), | 1438 | &ph.opt_update_percent), |
1431 | &ph.opt_update_percent), | 1439 | |
1432 | 1440 | GNUNET_GETOPT_option_flag('d', | |
1433 | GNUNET_GETOPT_option_flag ('d', | 1441 | "data", |
1434 | "data", | 1442 | gettext_noop("create data file"), |
1435 | gettext_noop ("create data file"), | 1443 | &ph.create_datafile), |
1436 | &ph.create_datafile), | 1444 | |
1437 | 1445 | GNUNET_GETOPT_option_flag('u', | |
1438 | GNUNET_GETOPT_option_flag ('u', | 1446 | "update", |
1439 | "update", | 1447 | gettext_noop("measure updates"), |
1440 | gettext_noop ("measure updates"), | 1448 | &ph.measure_updates), |
1441 | &ph.measure_updates), | 1449 | |
1442 | 1450 | GNUNET_GETOPT_OPTION_END | |
1443 | GNUNET_GETOPT_OPTION_END | ||
1444 | }; | 1451 | }; |
1445 | 1452 | ||
1446 | GNUNET_PROGRAM_run (argc, argv, argv[0], NULL, options, &run, argv[0]); | 1453 | GNUNET_PROGRAM_run(argc, argv, argv[0], NULL, options, &run, argv[0]); |
1447 | return ret; | 1454 | return ret; |
1448 | } | 1455 | } |
1449 | 1456 | ||