diff options
Diffstat (limited to 'src/transport/test_transport_ats_multiple_peers.c')
-rw-r--r-- | src/transport/test_transport_ats_multiple_peers.c | 158 |
1 files changed, 72 insertions, 86 deletions
diff --git a/src/transport/test_transport_ats_multiple_peers.c b/src/transport/test_transport_ats_multiple_peers.c index d060a4d4b..fbc148e10 100644 --- a/src/transport/test_transport_ats_multiple_peers.c +++ b/src/transport/test_transport_ats_multiple_peers.c | |||
@@ -215,15 +215,15 @@ evaluate_measurements () | |||
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] += |
219 | (results_new[c].duration - average[0]); | 219 | (results_new[c].duration - average[0]) * (results_new[c].duration - |
220 | average[0]); | ||
220 | } | 221 | } |
221 | stddev[0] /= c_new; | 222 | stddev[0] /= c_new; |
222 | stddev[0] = sqrt (stddev[0]); | 223 | stddev[0] = sqrt (stddev[0]); |
223 | if (!machine_parsable) | 224 | if (!machine_parsable) |
224 | fprintf (stderr, | 225 | fprintf (stderr, "new, %i measurements, average: %f stddev: %f\n", c_new, |
225 | "new, %i measurements, average: %f stddev: %f\n", | 226 | 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++) |
@@ -235,14 +235,14 @@ evaluate_measurements () | |||
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] += |
239 | (results_modified[c].duration - average[1]); | 239 | (results_modified[c].duration - |
240 | average[1]) * (results_modified[c].duration - average[1]); | ||
240 | } | 241 | } |
241 | stddev[1] /= c_modified; | 242 | stddev[1] /= c_modified; |
242 | stddev[1] = sqrt (stddev[1]); | 243 | stddev[1] = sqrt (stddev[1]); |
243 | if (!machine_parsable) | 244 | if (!machine_parsable) |
244 | fprintf (stderr, | 245 | fprintf (stderr, "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; |
@@ -254,35 +254,31 @@ evaluate_measurements () | |||
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] += |
258 | (results_unmodified[c].duration - average[2]); | 258 | (results_unmodified[c].duration - |
259 | average[2]) * (results_unmodified[c].duration - average[2]); | ||
259 | } | 260 | } |
260 | stddev[2] /= c_unmodified; | 261 | stddev[2] /= c_unmodified; |
261 | stddev[2] = sqrt (stddev[2]); | 262 | stddev[2] = sqrt (stddev[2]); |
262 | 263 | ||
263 | if (!machine_parsable) | 264 | if (!machine_parsable) |
264 | fprintf (stderr, | 265 | fprintf (stderr, "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," "new,%i,%f,%f," "mod,%i,%f,%f," |
271 | "new,%i,%f,%f," | 271 | "unmod,%i,%f,%f\n", peers - 1, |
272 | "mod,%i,%f,%f," | 272 | (unsigned long long) results_unmodified[0].mechs, c_new, |
273 | "unmod,%i,%f,%f\n", | 273 | average[0], stddev[0], c_modified, average[1], stddev[1], |
274 | peers - 1, (unsigned long long) results_unmodified[0].mechs, | ||
275 | c_new, average[0], stddev[0], | ||
276 | c_modified, average[1], stddev[1], | ||
277 | c_unmodified, average[2], stddev[2]); | 274 | c_unmodified, average[2], stddev[2]); |
278 | shutdown_peers (); | 275 | shutdown_peers (); |
279 | } | 276 | } |
280 | 277 | ||
281 | 278 | ||
282 | static int | 279 | static int |
283 | stats_cb (void *cls, | 280 | stats_cb (void *cls, const char *subsystem, const char *name, uint64_t value, |
284 | const char *subsystem, | 281 | int is_persistent) |
285 | const char *name, uint64_t value, int is_persistent) | ||
286 | { | 282 | { |
287 | static int printed = GNUNET_NO; | 283 | static int printed = GNUNET_NO; |
288 | 284 | ||
@@ -330,8 +326,8 @@ stats_cb (void *cls, | |||
330 | s_state = NULL; | 326 | s_state = NULL; |
331 | } | 327 | } |
332 | 328 | ||
333 | if ((measurement_started == GNUNET_NO) && | 329 | if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && |
334 | (0 == strcmp (name, "ATS peers")) && (value == peers - 1)) | 330 | (value == peers - 1)) |
335 | { | 331 | { |
336 | measurement_started = GNUNET_YES; | 332 | measurement_started = GNUNET_YES; |
337 | count = 1; | 333 | count = 1; |
@@ -396,12 +392,11 @@ stats_cb (void *cls, | |||
396 | } | 392 | } |
397 | count++; | 393 | count++; |
398 | #if VERBOSE | 394 | #if VERBOSE |
399 | fprintf (stderr, | 395 | fprintf (stderr, "(new: %i / modified: %i / unmodified: %i) of %i \n", |
400 | "(new: %i / modified: %i / unmodified: %i) of %i \n", | ||
401 | c_new, c_modified, c_unmodified, MEASUREMENTS); | 396 | c_new, c_modified, c_unmodified, MEASUREMENTS); |
402 | #endif | 397 | #endif |
403 | if ((c_modified >= MEASUREMENTS) && | 398 | if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && |
404 | (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)) | 399 | (c_unmodified >= MEASUREMENTS)) |
405 | { | 400 | { |
406 | #if !VERBOSE | 401 | #if !VERBOSE |
407 | if (!machine_parsable) | 402 | if (!machine_parsable) |
@@ -430,32 +425,32 @@ stats_cb (void *cls, | |||
430 | { | 425 | { |
431 | current.solution = value; | 426 | current.solution = value; |
432 | if (printed == GNUNET_NO) | 427 | if (printed == GNUNET_NO) |
433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | 428 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, |
434 | count, name, value); | 429 | value); |
435 | } | 430 | } |
436 | 431 | ||
437 | if (0 == strcmp (name, "ATS peers")) | 432 | if (0 == strcmp (name, "ATS peers")) |
438 | { | 433 | { |
439 | current.peers = value; | 434 | current.peers = value; |
440 | if (printed == GNUNET_NO) | 435 | if (printed == GNUNET_NO) |
441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | 436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, |
442 | count, name, value); | 437 | value); |
443 | } | 438 | } |
444 | 439 | ||
445 | if (0 == strcmp (name, "ATS mechanisms")) | 440 | if (0 == strcmp (name, "ATS mechanisms")) |
446 | { | 441 | { |
447 | current.mechs = value; | 442 | current.mechs = value; |
448 | if (printed == GNUNET_NO) | 443 | if (printed == GNUNET_NO) |
449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | 444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, |
450 | count, name, value); | 445 | value); |
451 | } | 446 | } |
452 | 447 | ||
453 | if (0 == strcmp (name, "ATS duration")) | 448 | if (0 == strcmp (name, "ATS duration")) |
454 | { | 449 | { |
455 | current.duration = value; | 450 | current.duration = value; |
456 | if (printed == GNUNET_NO) | 451 | if (printed == GNUNET_NO) |
457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | 452 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, |
458 | count, name, value); | 453 | value); |
459 | } | 454 | } |
460 | if (0 == strcmp (name, "ATS state")) | 455 | if (0 == strcmp (name, "ATS state")) |
461 | { | 456 | { |
@@ -485,8 +480,8 @@ stats_cb (void *cls, | |||
485 | break; | 480 | break; |
486 | } | 481 | } |
487 | if (printed == GNUNET_NO) | 482 | if (printed == GNUNET_NO) |
488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS state: %s\n", count, |
489 | "[%i] ATS state: %s\n", count, cont); | 484 | cont); |
490 | } | 485 | } |
491 | } | 486 | } |
492 | return GNUNET_OK; | 487 | return GNUNET_OK; |
@@ -500,16 +495,21 @@ stats_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
500 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 495 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
501 | return; | 496 | return; |
502 | 497 | ||
503 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", | 498 | s_time = |
504 | TIMEOUT, NULL, &stats_cb, NULL); | 499 | GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, |
505 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", | 500 | &stats_cb, NULL); |
506 | TIMEOUT, NULL, &stats_cb, NULL); | 501 | s_solution = |
507 | s_duration = GNUNET_STATISTICS_get (stats, "transport", "ATS duration", | 502 | GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, |
508 | TIMEOUT, NULL, &stats_cb, NULL); | 503 | &stats_cb, NULL); |
509 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", | 504 | s_duration = |
510 | TIMEOUT, NULL, &stats_cb, NULL); | 505 | GNUNET_STATISTICS_get (stats, "transport", "ATS duration", TIMEOUT, NULL, |
511 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", | 506 | &stats_cb, NULL); |
512 | TIMEOUT, NULL, &stats_cb, NULL); | 507 | s_peers = |
508 | GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, | ||
509 | &stats_cb, NULL); | ||
510 | s_mechs = | ||
511 | GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, | ||
512 | NULL, &stats_cb, NULL); | ||
513 | s_invalid = | 513 | s_invalid = |
514 | GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", | 514 | GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", |
515 | TIMEOUT, NULL, &stats_cb, NULL); | 515 | TIMEOUT, NULL, &stats_cb, NULL); |
@@ -592,8 +592,7 @@ send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
592 | } | 592 | } |
593 | 593 | ||
594 | if (send_msg == GNUNET_YES) | 594 | if (send_msg == GNUNET_YES) |
595 | t = GNUNET_TRANSPORT_notify_transmit_ready (th, | 595 | t = GNUNET_TRANSPORT_notify_transmit_ready (th, &master_deamon->id, |
596 | &master_deamon->id, | ||
597 | sizeof (struct TestMessage), 0, | 596 | sizeof (struct TestMessage), 0, |
598 | SEND_TIMEOUT, | 597 | SEND_TIMEOUT, |
599 | &send_dummy_data_task, NULL); | 598 | &send_dummy_data_task, NULL); |
@@ -605,8 +604,7 @@ send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
605 | } | 604 | } |
606 | 605 | ||
607 | static void | 606 | static void |
608 | notify_connect (void *cls, | 607 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
609 | const struct GNUNET_PeerIdentity *peer, | ||
610 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 608 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
611 | uint32_t ats_count) | 609 | uint32_t ats_count) |
612 | { | 610 | { |
@@ -633,10 +631,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
633 | } | 631 | } |
634 | 632 | ||
635 | static void | 633 | static void |
636 | daemon_connect_cb (void *cls, | 634 | daemon_connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, |
637 | const struct GNUNET_PeerIdentity *first, | 635 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
638 | const struct GNUNET_PeerIdentity *second, | ||
639 | uint32_t distance, | ||
640 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 636 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
641 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 637 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
642 | struct GNUNET_TESTING_Daemon *first_daemon, | 638 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -647,20 +643,16 @@ daemon_connect_cb (void *cls, | |||
647 | char *secondc = strdup (GNUNET_i2s (second)); | 643 | char *secondc = strdup (GNUNET_i2s (second)); |
648 | 644 | ||
649 | connected++; | 645 | connected++; |
650 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s' (%i/%i)\n", |
651 | "Connected peers `%s'<->`%s' (%i/%i)\n", | ||
652 | firstc, secondc, connected, peers - 1); | 647 | firstc, secondc, connected, peers - 1); |
653 | GNUNET_free (firstc); | 648 | GNUNET_free (firstc); |
654 | GNUNET_free (secondc); | 649 | GNUNET_free (secondc); |
655 | 650 | ||
656 | if (((first_daemon == ping_deamon) || | 651 | if (((first_daemon == ping_deamon) || (second_daemon == ping_deamon)) && |
657 | (second_daemon == ping_deamon)) && | ||
658 | (master_deamon != NULL) && (ping_deamon != NULL)) | 652 | (master_deamon != NULL) && (ping_deamon != NULL)) |
659 | { | 653 | { |
660 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, | 654 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, &ping_deamon->id, NULL, |
661 | &ping_deamon->id, | 655 | NULL, ¬ify_connect, ¬ify_disconnect); |
662 | NULL, NULL, | ||
663 | ¬ify_connect, ¬ify_disconnect); | ||
664 | force_q_updates = GNUNET_YES; | 656 | force_q_updates = GNUNET_YES; |
665 | send_msg = GNUNET_YES; | 657 | send_msg = GNUNET_YES; |
666 | } | 658 | } |
@@ -669,8 +661,7 @@ daemon_connect_cb (void *cls, | |||
669 | 661 | ||
670 | 662 | ||
671 | static void | 663 | static void |
672 | daemon_start_cb (void *cls, | 664 | daemon_start_cb (void *cls, const struct GNUNET_PeerIdentity *id, |
673 | const struct GNUNET_PeerIdentity *id, | ||
674 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 665 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
675 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 666 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
676 | { | 667 | { |
@@ -693,8 +684,8 @@ daemon_start_cb (void *cls, | |||
693 | 684 | ||
694 | if (master_deamon == NULL) | 685 | if (master_deamon == NULL) |
695 | { | 686 | { |
696 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s' '%s'\n", |
697 | "Master peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); | 688 | GNUNET_i2s (id), d->cfgfile); |
698 | master_deamon = d; | 689 | master_deamon = d; |
699 | stats = GNUNET_STATISTICS_create ("transport", master_deamon->cfg); | 690 | stats = GNUNET_STATISTICS_create ("transport", master_deamon->cfg); |
700 | GNUNET_assert (stats != NULL); | 691 | GNUNET_assert (stats != NULL); |
@@ -702,13 +693,10 @@ daemon_start_cb (void *cls, | |||
702 | } | 693 | } |
703 | else | 694 | else |
704 | { | 695 | { |
705 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 696 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", |
706 | "Connecting peer `%s'\n", | ||
707 | GNUNET_i2s (id), GNUNET_i2s (&master_deamon->id)); | 697 | GNUNET_i2s (id), GNUNET_i2s (&master_deamon->id)); |
708 | GNUNET_TESTING_daemons_connect (d, | 698 | GNUNET_TESTING_daemons_connect (d, master_deamon, TIMEOUT, 0, GNUNET_YES, |
709 | master_deamon, | 699 | &daemon_connect_cb, NULL); |
710 | TIMEOUT, | ||
711 | 0, GNUNET_YES, &daemon_connect_cb, NULL); | ||
712 | } | 700 | } |
713 | 701 | ||
714 | if (peers_left == 0) | 702 | if (peers_left == 0) |
@@ -716,8 +704,8 @@ daemon_start_cb (void *cls, | |||
716 | if (ping_deamon == NULL) | 704 | if (ping_deamon == NULL) |
717 | { | 705 | { |
718 | ping_deamon = d; | 706 | ping_deamon = d; |
719 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ping peer `%s' '%s'\n", |
720 | "Ping peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); | 708 | GNUNET_i2s (id), d->cfgfile); |
721 | } | 709 | } |
722 | 710 | ||
723 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully!\n"); | 711 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully!\n"); |
@@ -735,9 +723,8 @@ daemon_start_cb (void *cls, | |||
735 | 723 | ||
736 | 724 | ||
737 | static void | 725 | static void |
738 | run (void *cls, | 726 | run (void *cls, char *const *args, const char *cfgfile, |
739 | char *const *args, | 727 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
740 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
741 | { | 728 | { |
742 | ok = 1; | 729 | ok = 1; |
743 | measurement_started = GNUNET_NO; | 730 | measurement_started = GNUNET_NO; |
@@ -748,9 +735,8 @@ run (void *cls, | |||
748 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ | 735 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ |
749 | peers_left, /* Number of outstanding connections */ | 736 | peers_left, /* Number of outstanding connections */ |
750 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | 737 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ |
751 | TIMEOUT, | 738 | TIMEOUT, NULL, NULL, &daemon_start_cb, |
752 | NULL, NULL, | 739 | NULL, NULL, NULL, NULL); |
753 | &daemon_start_cb, NULL, NULL, NULL, NULL); | ||
754 | GNUNET_assert (pg != NULL); | 740 | GNUNET_assert (pg != NULL); |
755 | } | 741 | } |
756 | 742 | ||
@@ -769,9 +755,9 @@ check () | |||
769 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 755 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
770 | GNUNET_GETOPT_OPTION_END | 756 | GNUNET_GETOPT_OPTION_END |
771 | }; | 757 | }; |
772 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 758 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
773 | argv, "test_transport_ats_multiple_peers", "nohelp", | 759 | "test_transport_ats_multiple_peers", "nohelp", options, |
774 | options, &run, &ok); | 760 | &run, &ok); |
775 | return ok; | 761 | return ok; |
776 | } | 762 | } |
777 | 763 | ||