diff options
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r-- | src/transport/test_quota_compliance.c | 88 |
1 files changed, 38 insertions, 50 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index e4638e4fc..bc2aca31b 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -232,8 +232,7 @@ get_size () | |||
232 | } | 232 | } |
233 | 233 | ||
234 | static void | 234 | static void |
235 | notify_receive_new (void *cls, | 235 | notify_receive_new (void *cls, const struct GNUNET_PeerIdentity *peer, |
236 | const struct GNUNET_PeerIdentity *peer, | ||
237 | const struct GNUNET_MessageHeader *message, | 236 | const struct GNUNET_MessageHeader *message, |
238 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 237 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
239 | uint32_t ats_count) | 238 | uint32_t ats_count) |
@@ -250,8 +249,7 @@ notify_receive_new (void *cls, | |||
250 | #if DEBUG_MEASUREMENT | 249 | #if DEBUG_MEASUREMENT |
251 | if (ntohl (hdr->num) % 5000 == 0) | 250 | if (ntohl (hdr->num) % 5000 == 0) |
252 | { | 251 | { |
253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", |
254 | "Got message %u of size %u\n", | ||
255 | ntohl (hdr->num), ntohs (message->size)); | 253 | ntohl (hdr->num), ntohs (message->size)); |
256 | } | 254 | } |
257 | #endif | 255 | #endif |
@@ -309,11 +307,9 @@ notify_ready (void *cls, size_t size, void *buf) | |||
309 | break; /* sometimes pack buffer full, sometimes not */ | 307 | break; /* sometimes pack buffer full, sometimes not */ |
310 | } | 308 | } |
311 | while (size - ret >= s); | 309 | while (size - ret >= s); |
312 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 310 | transmit_handle = |
313 | &p1.id, | 311 | GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, SEND_TIMEOUT, |
314 | s, 0, SEND_TIMEOUT, | 312 | ¬ify_ready, NULL); |
315 | ¬ify_ready, | ||
316 | NULL); | ||
317 | total_bytes_sent += s; | 313 | total_bytes_sent += s; |
318 | return ret; | 314 | return ret; |
319 | } | 315 | } |
@@ -348,9 +344,9 @@ measurement_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
348 | return; | 344 | return; |
349 | 345 | ||
350 | measurement_running = GNUNET_NO; | 346 | measurement_running = GNUNET_NO; |
351 | struct GNUNET_TIME_Relative duration | 347 | struct GNUNET_TIME_Relative duration = |
352 | = GNUNET_TIME_absolute_get_difference (start_time, | 348 | GNUNET_TIME_absolute_get_difference (start_time, |
353 | GNUNET_TIME_absolute_get ()); | 349 | GNUNET_TIME_absolute_get ()); |
354 | 350 | ||
355 | 351 | ||
356 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) | 352 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -435,10 +431,8 @@ measurement_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
435 | else | 431 | else |
436 | { | 432 | { |
437 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 433 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
438 | "\nQuota compliance ok: \n" | 434 | "\nQuota compliance ok: \n" "Quota allowed: %10llu kB/s\n" |
439 | "Quota allowed: %10llu kB/s\n" | 435 | "Throughput : %10llu kB/s\n", (quota_allowed / (1024)), |
440 | "Throughput : %10llu kB/s\n", | ||
441 | (quota_allowed / (1024)), | ||
442 | (total_bytes_sent / (duration.rel_value / 1000) / 1024)); | 436 | (total_bytes_sent / (duration.rel_value / 1000) / 1024)); |
443 | if (failed_measurement_counter < 2) | 437 | if (failed_measurement_counter < 2) |
444 | failed_measurement_counter++; | 438 | failed_measurement_counter++; |
@@ -509,12 +503,10 @@ measure (unsigned long long quota_p1, unsigned long long quota_p2) | |||
509 | current_quota_p2 / 1024); | 503 | current_quota_p2 / 1024); |
510 | 504 | ||
511 | #endif | 505 | #endif |
512 | GNUNET_TRANSPORT_set_quota (p1.th, | 506 | GNUNET_TRANSPORT_set_quota (p1.th, &p2.id, |
513 | &p2.id, | ||
514 | GNUNET_BANDWIDTH_value_init (current_quota_p1), | 507 | GNUNET_BANDWIDTH_value_init (current_quota_p1), |
515 | GNUNET_BANDWIDTH_value_init (current_quota_p1)); | 508 | GNUNET_BANDWIDTH_value_init (current_quota_p1)); |
516 | GNUNET_TRANSPORT_set_quota (p2.th, | 509 | GNUNET_TRANSPORT_set_quota (p2.th, &p1.id, |
517 | &p1.id, | ||
518 | GNUNET_BANDWIDTH_value_init (current_quota_p2), | 510 | GNUNET_BANDWIDTH_value_init (current_quota_p2), |
519 | GNUNET_BANDWIDTH_value_init (current_quota_p2)); | 511 | GNUNET_BANDWIDTH_value_init (current_quota_p2)); |
520 | GNUNET_SCHEDULER_cancel (die_task); | 512 | GNUNET_SCHEDULER_cancel (die_task); |
@@ -535,12 +527,10 @@ measure (unsigned long long quota_p1, unsigned long long quota_p2) | |||
535 | 527 | ||
536 | if (transmit_handle != NULL) | 528 | if (transmit_handle != NULL) |
537 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); | 529 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); |
538 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 530 | transmit_handle = |
539 | &p1.id, | 531 | GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, get_size (), 0, |
540 | get_size (), 0, | 532 | SEND_TIMEOUT, ¬ify_ready, |
541 | SEND_TIMEOUT, | 533 | NULL); |
542 | ¬ify_ready, | ||
543 | NULL); | ||
544 | } | 534 | } |
545 | 535 | ||
546 | 536 | ||
@@ -584,8 +574,7 @@ exchange_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
584 | 574 | ||
585 | 575 | ||
586 | static void | 576 | static void |
587 | notify_connect (void *cls, | 577 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
588 | const struct GNUNET_PeerIdentity *peer, | ||
589 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 578 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
590 | uint32_t ats_count) | 579 | uint32_t ats_count) |
591 | { | 580 | { |
@@ -593,15 +582,15 @@ notify_connect (void *cls, | |||
593 | if (cls == &p1) | 582 | if (cls == &p1) |
594 | { | 583 | { |
595 | #if DEBUG_CONNECTIONS | 584 | #if DEBUG_CONNECTIONS |
596 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 585 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 `%4s' connected to us (%p)!\n", |
597 | "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); | 586 | GNUNET_i2s (peer), cls); |
598 | #endif | 587 | #endif |
599 | } | 588 | } |
600 | else | 589 | else |
601 | { | 590 | { |
602 | #if DEBUG_CONNECTIONS | 591 | #if DEBUG_CONNECTIONS |
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 592 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 `%4s' connected to us (%p)!\n", |
604 | "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); | 593 | GNUNET_i2s (peer), cls); |
605 | #endif | 594 | #endif |
606 | } | 595 | } |
607 | if (connected == 2) | 596 | if (connected == 2) |
@@ -636,8 +625,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
636 | } | 625 | } |
637 | connected--; | 626 | connected--; |
638 | #if DEBUG_CONNECTIONS | 627 | #if DEBUG_CONNECTIONS |
639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", |
640 | "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); | 629 | GNUNET_i2s (peer), cls); |
641 | #endif | 630 | #endif |
642 | } | 631 | } |
643 | 632 | ||
@@ -655,19 +644,18 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
655 | } | 644 | } |
656 | 645 | ||
657 | #if START_ARM | 646 | #if START_ARM |
658 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, | 647 | p->arm_proc = |
659 | "gnunet-service-arm", | 648 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
660 | "gnunet-service-arm", | 649 | "gnunet-service-arm", |
661 | #if VERBOSE_ARM | 650 | #if VERBOSE_ARM |
662 | "-L", "DEBUG", | 651 | "-L", "DEBUG", |
663 | #endif | 652 | #endif |
664 | "-c", cfgname, NULL); | 653 | "-c", cfgname, NULL); |
665 | #endif | 654 | #endif |
666 | 655 | ||
667 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, | 656 | p->th = |
668 | p, | 657 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive_new, |
669 | ¬ify_receive_new, | 658 | ¬ify_connect, ¬ify_disconnect); |
670 | ¬ify_connect, ¬ify_disconnect); | ||
671 | GNUNET_assert (p->th != NULL); | 659 | GNUNET_assert (p->th != NULL); |
672 | } | 660 | } |
673 | 661 | ||
@@ -680,15 +668,15 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
680 | #endif | 668 | #endif |
681 | GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); | 669 | GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); |
682 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); | 670 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); |
683 | tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 671 | tct = |
684 | &try_connect, NULL); | 672 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, |
673 | NULL); | ||
685 | } | 674 | } |
686 | 675 | ||
687 | 676 | ||
688 | static void | 677 | static void |
689 | run (void *cls, | 678 | run (void *cls, char *const *args, const char *cfgfile, |
690 | char *const *args, | 679 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
691 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
692 | { | 680 | { |
693 | GNUNET_assert (ok == 1); | 681 | GNUNET_assert (ok == 1); |
694 | OKPP; | 682 | OKPP; |
@@ -924,8 +912,8 @@ main (int argc, char *argv[]) | |||
924 | GNUNET_GETOPT_OPTION_END | 912 | GNUNET_GETOPT_OPTION_END |
925 | }; | 913 | }; |
926 | ok = 1; | 914 | ok = 1; |
927 | GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, | 915 | GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, argv1, logger, |
928 | argv1, logger, "nohelp", options, &run, &ok); | 916 | "nohelp", options, &run, &ok); |
929 | ret = ok; | 917 | ret = ok; |
930 | stop_arm (&p1); | 918 | stop_arm (&p1); |
931 | stop_arm (&p2); | 919 | stop_arm (&p2); |