diff options
Diffstat (limited to 'src/transport/test_transport_api_unreliability.c')
-rw-r--r-- | src/transport/test_transport_api_unreliability.c | 88 |
1 files changed, 39 insertions, 49 deletions
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c index 88df23eb4..5eed408c0 100644 --- a/src/transport/test_transport_api_unreliability.c +++ b/src/transport/test_transport_api_unreliability.c | |||
@@ -193,8 +193,8 @@ end () | |||
193 | GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), | 193 | GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), |
194 | "kb/s"); | 194 | "kb/s"); |
195 | GNUNET_free (value_name); | 195 | GNUNET_free (value_name); |
196 | fprintf (stderr, | 196 | fprintf (stderr, "\nThroughput was %llu kb/s\n", |
197 | "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); | 197 | total_bytes * 1000 / 1024 / delta); |
198 | ok = result; | 198 | ok = result; |
199 | 199 | ||
200 | } | 200 | } |
@@ -231,8 +231,8 @@ end_unreliably () | |||
231 | "Transports disconnected, returning success!\n"); | 231 | "Transports disconnected, returning success!\n"); |
232 | #endif | 232 | #endif |
233 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; | 233 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
234 | fprintf (stderr, | 234 | fprintf (stderr, "\nThroughput was %llu kb/s\n", |
235 | "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); | 235 | total_bytes * 1000 / 1024 / delta); |
236 | GNUNET_asprintf (&value_name, "unreliable_%s", test_name); | 236 | GNUNET_asprintf (&value_name, "unreliable_%s", test_name); |
237 | GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), | 237 | GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), |
238 | "kb/s"); | 238 | "kb/s"); |
@@ -355,8 +355,7 @@ get_size (unsigned int iter) | |||
355 | 355 | ||
356 | 356 | ||
357 | static void | 357 | static void |
358 | notify_receive (void *cls, | 358 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
359 | const struct GNUNET_PeerIdentity *peer, | ||
360 | const struct GNUNET_MessageHeader *message, | 359 | const struct GNUNET_MessageHeader *message, |
361 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 360 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
362 | uint32_t ats_count) | 361 | uint32_t ats_count) |
@@ -401,8 +400,7 @@ notify_receive (void *cls, | |||
401 | #if VERBOSE | 400 | #if VERBOSE |
402 | if (ntohl (hdr->num) % 5 == 0) | 401 | if (ntohl (hdr->num) % 5 == 0) |
403 | { | 402 | { |
404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", |
405 | "Got message %u of size %u\n", | ||
406 | ntohl (hdr->num), ntohs (message->size)); | 404 | ntohl (hdr->num), ntohs (message->size)); |
407 | } | 405 | } |
408 | #endif | 406 | #endif |
@@ -456,8 +454,8 @@ notify_ready (void *cls, size_t size, void *buf) | |||
456 | #if VERBOSE | 454 | #if VERBOSE |
457 | if (n % 5000 == 0) | 455 | if (n % 5000 == 0) |
458 | { | 456 | { |
459 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u of size %u\n", n, |
460 | "Sending message %u of size %u\n", n, s); | 458 | s); |
461 | } | 459 | } |
462 | #endif | 460 | #endif |
463 | n++; | 461 | n++; |
@@ -468,10 +466,9 @@ notify_ready (void *cls, size_t size, void *buf) | |||
468 | while (size - ret >= s); | 466 | while (size - ret >= s); |
469 | if (n < TOTAL_MSGS) | 467 | if (n < TOTAL_MSGS) |
470 | { | 468 | { |
471 | th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 469 | th_p2 = |
472 | &p1.id, | 470 | GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, TIMEOUT, |
473 | s, 0, TIMEOUT, | 471 | ¬ify_ready, NULL); |
474 | ¬ify_ready, NULL); | ||
475 | msg_scheduled = n; | 472 | msg_scheduled = n; |
476 | } | 473 | } |
477 | else | 474 | else |
@@ -500,8 +497,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
500 | { | 497 | { |
501 | connected--; | 498 | connected--; |
502 | #if VERBOSE | 499 | #if VERBOSE |
503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 500 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", |
504 | "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); | 501 | GNUNET_i2s (peer), cls); |
505 | #endif | 502 | #endif |
506 | if (th_p2 != NULL) | 503 | if (th_p2 != NULL) |
507 | { | 504 | { |
@@ -513,17 +510,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
513 | 510 | ||
514 | 511 | ||
515 | static void | 512 | static void |
516 | notify_connect (void *cls, | 513 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
517 | const struct GNUNET_PeerIdentity *peer, | ||
518 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 514 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
519 | uint32_t ats_count) | 515 | uint32_t ats_count) |
520 | { | 516 | { |
521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 517 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
522 | "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); | 518 | GNUNET_i2s (peer), cls); |
523 | if (cls == &p1) | 519 | if (cls == &p1) |
524 | { | 520 | { |
525 | GNUNET_TRANSPORT_set_quota (p1.th, | 521 | GNUNET_TRANSPORT_set_quota (p1.th, &p2.id, |
526 | &p2.id, | ||
527 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 522 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
528 | 1024), | 523 | 1024), |
529 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 524 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
@@ -533,8 +528,7 @@ notify_connect (void *cls, | |||
533 | } | 528 | } |
534 | else | 529 | else |
535 | { | 530 | { |
536 | GNUNET_TRANSPORT_set_quota (p2.th, | 531 | GNUNET_TRANSPORT_set_quota (p2.th, &p1.id, |
537 | &p1.id, | ||
538 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 532 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
539 | 1024), | 533 | 1024), |
540 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 534 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
@@ -564,10 +558,8 @@ notify_connect (void *cls, | |||
564 | } | 558 | } |
565 | 559 | ||
566 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 560 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
567 | GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 561 | GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, get_size (0), 0, |
568 | &p1.id, | 562 | TIMEOUT, ¬ify_ready, NULL); |
569 | get_size (0), 0, TIMEOUT, | ||
570 | ¬ify_ready, NULL); | ||
571 | 563 | ||
572 | } | 564 | } |
573 | } | 565 | } |
@@ -583,8 +575,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
583 | if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) | 575 | if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) |
584 | { | 576 | { |
585 | GNUNET_assert (GNUNET_OK == | 577 | GNUNET_assert (GNUNET_OK == |
586 | GNUNET_CONFIGURATION_get_value_string (p->cfg, | 578 | GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", |
587 | "PATHS", | ||
588 | "SERVICEHOME", | 579 | "SERVICEHOME", |
589 | &p->servicehome)); | 580 | &p->servicehome)); |
590 | GNUNET_DISK_directory_remove (p->servicehome); | 581 | GNUNET_DISK_directory_remove (p->servicehome); |
@@ -592,19 +583,18 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
592 | 583 | ||
593 | 584 | ||
594 | #if START_ARM | 585 | #if START_ARM |
595 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, | 586 | p->arm_proc = |
596 | "gnunet-service-arm", | 587 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
597 | "gnunet-service-arm", | 588 | "gnunet-service-arm", |
598 | #if VERBOSE_ARM | 589 | #if VERBOSE_ARM |
599 | "-L", "DEBUG", | 590 | "-L", "DEBUG", |
600 | #endif | 591 | #endif |
601 | "-c", cfgname, NULL); | 592 | "-c", cfgname, NULL); |
602 | #endif | 593 | #endif |
603 | 594 | ||
604 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, | 595 | p->th = |
605 | p, | 596 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, |
606 | ¬ify_receive, | 597 | ¬ify_connect, ¬ify_disconnect); |
607 | ¬ify_connect, ¬ify_disconnect); | ||
608 | GNUNET_assert (p->th != NULL); | 598 | GNUNET_assert (p->th != NULL); |
609 | } | 599 | } |
610 | 600 | ||
@@ -694,8 +684,8 @@ check_gnunet_nat_binary (char *binary) | |||
694 | } | 684 | } |
695 | if (0 != STAT (p, &statbuf)) | 685 | if (0 != STAT (p, &statbuf)) |
696 | { | 686 | { |
697 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 687 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, |
698 | _("stat (%s) failed: %s\n"), p, STRERROR (errno)); | 688 | STRERROR (errno)); |
699 | GNUNET_free (p); | 689 | GNUNET_free (p); |
700 | return GNUNET_SYSERR; | 690 | return GNUNET_SYSERR; |
701 | } | 691 | } |
@@ -727,16 +717,16 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
727 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking peers to connect...\n"); | 717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking peers to connect...\n"); |
728 | GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); | 718 | GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); |
729 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); | 719 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); |
730 | tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 720 | tct = |
731 | &try_connect, NULL); | 721 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, |
722 | NULL); | ||
732 | } | 723 | } |
733 | 724 | ||
734 | 725 | ||
735 | 726 | ||
736 | static void | 727 | static void |
737 | run (void *cls, | 728 | run (void *cls, char *const *args, const char *cfgfile, |
738 | char *const *args, | 729 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
739 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
740 | { | 730 | { |
741 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 731 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
742 | if (is_tcp) | 732 | if (is_tcp) |
@@ -814,9 +804,9 @@ check () | |||
814 | return 0; | 804 | return 0; |
815 | } | 805 | } |
816 | 806 | ||
817 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 807 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
818 | argv, "test-transport-api-unreliability", "nohelp", | 808 | "test-transport-api-unreliability", "nohelp", options, |
819 | options, &run, &ok); | 809 | &run, &ok); |
820 | stop_arm (&p1); | 810 | stop_arm (&p1); |
821 | stop_arm (&p2); | 811 | stop_arm (&p2); |
822 | 812 | ||