aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_quota_compliance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-10-29 15:21:37 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-10-29 15:21:37 +0000
commit6cc39bc9d1e13c66495540ecde96414495102d6f (patch)
tree91acbdecdb521722608379a47d06f23e2febd38a /src/transport/test_quota_compliance.c
parentc9147656de9142c516bc4a27b81bf49a683f0fe8 (diff)
downloadgnunet-6cc39bc9d1e13c66495540ecde96414495102d6f.tar.gz
gnunet-6cc39bc9d1e13c66495540ecde96414495102d6f.zip
Added testcases for asymmetric quotas
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r--src/transport/test_quota_compliance.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 087d72da0..3614fa0d7 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -137,6 +137,8 @@ static int is_tcp_nat;
137static int is_http; 137static int is_http;
138static int is_https; 138static int is_https;
139static int is_udp; 139static int is_udp;
140static int is_asymmetric_send_constant;
141static int is_asymmetric_recv_constant;
140 142
141static struct GNUNET_TIME_Absolute start_time; 143static struct GNUNET_TIME_Absolute start_time;
142 144
@@ -397,7 +399,7 @@ measurement_end (void *cls,
397 ok = 0; 399 ok = 0;
398 } 400 }
399 401
400 if (current_quota_p1 < MEASUREMENT_MIN_QUOTA) 402 if ((current_quota_p1 < MEASUREMENT_MIN_QUOTA) || (current_quota_p2 < MEASUREMENT_MIN_QUOTA))
401 { 403 {
402 end(); 404 end();
403 return; 405 return;
@@ -408,7 +410,12 @@ measurement_end (void *cls,
408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
409 "Scheduling next measurement\n"); 411 "Scheduling next measurement\n");
410#endif 412#endif
411 measure (current_quota_p1 / 10, current_quota_p2 / 10); 413 if (is_asymmetric_send_constant == GNUNET_YES)
414 measure (current_quota_p1 / 10, MEASUREMENT_MAX_QUOTA);
415 else if (is_asymmetric_recv_constant == GNUNET_YES)
416 measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 / 10);
417 else
418 measure (current_quota_p1 / 10, current_quota_p2 / 10);
412 } 419 }
413} 420}
414 421
@@ -418,7 +425,7 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
418 current_quota_p2 = quota_p2; 425 current_quota_p2 = quota_p2;
419#if VERBOSE 426#if VERBOSE
420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
421 "Starting transport level measurement for %u seconds and quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024); 428 "Starting transport level measurement for %u seconds and p1 quota %llu kB/s p2 quota %llu\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024, current_quota_p2 / 1024);
422#endif 429#endif
423 GNUNET_TRANSPORT_set_quota (p1.th, 430 GNUNET_TRANSPORT_set_quota (p1.th,
424 &p2.id, 431 &p2.id,
@@ -580,21 +587,25 @@ run (void *cls,
580 587
581 if (is_tcp) 588 if (is_tcp)
582 { 589 {
590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for TCP transport plugin\n");
583 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); 591 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
584 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); 592 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
585 } 593 }
586 else if (is_http) 594 else if (is_http)
587 { 595 {
596 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for HTTP transport plugin\n");
588 setup_peer (&p1, "test_quota_compliance_http_peer1.conf"); 597 setup_peer (&p1, "test_quota_compliance_http_peer1.conf");
589 setup_peer (&p2, "test_quota_compliance_http_peer2.conf"); 598 setup_peer (&p2, "test_quota_compliance_http_peer2.conf");
590 } 599 }
591 else if (is_https) 600 else if (is_https)
592 { 601 {
602 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for HTTPS transport plugin\n");
593 setup_peer (&p1, "test_quota_compliance_https_peer1.conf"); 603 setup_peer (&p1, "test_quota_compliance_https_peer1.conf");
594 setup_peer (&p2, "test_quota_compliance_https_peer2.conf"); 604 setup_peer (&p2, "test_quota_compliance_https_peer2.conf");
595 } 605 }
596 else if (is_udp) 606 else if (is_udp)
597 { 607 {
608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for UDP transport plugin\n");
598 setup_peer (&p1, "test_quota_compliance_udp_peer1.conf"); 609 setup_peer (&p1, "test_quota_compliance_udp_peer1.conf");
599 setup_peer (&p2, "test_quota_compliance_udp_peer2.conf"); 610 setup_peer (&p2, "test_quota_compliance_udp_peer2.conf");
600 } 611 }
@@ -638,6 +649,7 @@ main (int argc, char *argv[])
638 { 649 {
639 is_udp = GNUNET_YES; 650 is_udp = GNUNET_YES;
640 } 651 }
652
641 GNUNET_log_setup ("test-quota-compliance", 653 GNUNET_log_setup ("test-quota-compliance",
642#if VERBOSE 654#if VERBOSE
643 "DEBUG", 655 "DEBUG",
@@ -657,6 +669,18 @@ main (int argc, char *argv[])
657 GNUNET_GETOPT_OPTION_END 669 GNUNET_GETOPT_OPTION_END
658 }; 670 };
659 671
672 if (strstr(argv[0], "asymmetric_recv") != NULL)
673 {
674 is_asymmetric_recv_constant = GNUNET_YES;
675 }
676 else
677 is_asymmetric_recv_constant = GNUNET_NO;
678 if (strstr(argv[0], "asymmetric_send") != NULL)
679 {
680 is_asymmetric_send_constant = GNUNET_YES;
681 }
682 else
683 is_asymmetric_send_constant = GNUNET_NO;
660 ok = 1; 684 ok = 1;
661 GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, 685 GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1,
662 argv1, "test-quota-compliance", "nohelp", 686 argv1, "test-quota-compliance", "nohelp",