aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_quota_compliance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-11-17 14:14:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-11-17 14:14:20 +0000
commitb12b0876dddf1db8da7042d1024c8b469831e96e (patch)
tree09aef2e9634f8299f10ebeeca545198d25d8acf1 /src/core/test_core_quota_compliance.c
parenta824ce9ccf24b1c77bbac8b1831c88e8193a0b10 (diff)
downloadgnunet-b12b0876dddf1db8da7042d1024c8b469831e96e.tar.gz
gnunet-b12b0876dddf1db8da7042d1024c8b469831e96e.zip
added tests with limited sender and receiver quotas
Diffstat (limited to 'src/core/test_core_quota_compliance.c')
-rw-r--r--src/core/test_core_quota_compliance.c74
1 files changed, 61 insertions, 13 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index 22f3414dc..a54cf4e0b 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -36,7 +36,11 @@
36#include "gnunet_transport_service.h" 36#include "gnunet_transport_service.h"
37 37
38#define VERBOSE GNUNET_YES 38#define VERBOSE GNUNET_YES
39#define DEBUG_TRANSMISSION GNUNET_YES 39#define DEBUG_TRANSMISSION GNUNET_NO
40
41#define SYMMETRIC 0
42#define ASYMMETRIC_SEND_LIMITED 1
43#define ASYMMETRIC_RECV_LIMITED 2
40 44
41#define START_ARM GNUNET_YES 45#define START_ARM GNUNET_YES
42 46
@@ -95,7 +99,7 @@ static unsigned long long current_quota_p2_in;
95static unsigned long long current_quota_p2_out; 99static unsigned long long current_quota_p2_out;
96 100
97static int ok; 101static int ok;
98 102static int test;
99static int32_t tr_n; 103static int32_t tr_n;
100 104
101static int running; 105static int running;
@@ -152,7 +156,7 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
152{ 156{
153 unsigned long long int delta; 157 unsigned long long int delta;
154 unsigned long long int throughput_out; 158 unsigned long long int throughput_out;
155 unsigned long long int throughput_int; 159 unsigned long long int throughput_in;
156 unsigned long long int max_quota_in; 160 unsigned long long int max_quota_in;
157 unsigned long long int max_quota_out; 161 unsigned long long int max_quota_out;
158 unsigned long long int quota_delta; 162 unsigned long long int quota_delta;
@@ -164,7 +168,7 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
164 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; 168 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
165 169
166 throughput_out = total_bytes_sent * 1000 / 1024 / delta; 170 throughput_out = total_bytes_sent * 1000 / 1024 / delta;
167 throughput_int = total_bytes_recv * 1000 / 1024 / delta; 171 throughput_in = total_bytes_recv * 1000 / 1024 / delta;
168 172
169 if (current_quota_p1_in < current_quota_p2_in) 173 if (current_quota_p1_in < current_quota_p2_in)
170 max_quota_in = current_quota_p1_in; 174 max_quota_in = current_quota_p1_in;
@@ -188,13 +192,25 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
188 { 192 {
189 ok = 1; 193 ok = 1;
190 } 194 }
191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Bytes in: %llu Bytes\n",total_bytes_recv); 195 switch (test)
192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Throughput in: %llu kb/s\n",throughput_out); 196 {
193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu kb/s\n",max_quota_in/1024); 197 case SYMMETRIC:
198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Core quota compliance test with symmetric quotas\n");
199 break;
200 case ASYMMETRIC_SEND_LIMITED:
201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Core quota compliance test with limited sender quota\n",throughput_in,total_bytes_recv, delta/1000);
202 break;
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Core quota compliance test with limited receiver quota\n",throughput_in,total_bytes_recv, delta/1000);
204 case ASYMMETRIC_RECV_LIMITED:
205 break;
206 };
207
208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Peer 1 send rate: %llu kB/s (%llu Bytes in %u sec.)\n",throughput_out,total_bytes_sent, delta/1000);
209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Peer 2 receive rate: %llu kB/s (%llu Bytes in %u sec.)\n",throughput_in,total_bytes_recv, delta/1000);
210
194 211
195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Bytes out: %llu Bytes\n",total_bytes_sent); 212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu kB/s\n",max_quota_in /1024);
196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Throughput out: %llu kb/s\n",throughput_out); 213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu kB/s\n",max_quota_out/1024);
197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu kb/s\n",max_quota_out/1024);
198 214
199 GNUNET_SCHEDULER_cancel (err_task); 215 GNUNET_SCHEDULER_cancel (err_task);
200 GNUNET_SCHEDULER_add_now (&terminate_task, NULL); 216 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
@@ -381,7 +397,7 @@ process_mtype (void *cls,
381 ntohs (message->size)); 397 ntohs (message->size));
382#endif 398#endif
383 n++; 399 n++;
384 if (0 == (n % (TOTAL_MSGS/100))) 400 if (0 == (n % 10))
385 fprintf (stderr, "."); 401 fprintf (stderr, ".");
386 if (n == TOTAL_MSGS) 402 if (n == TOTAL_MSGS)
387 { 403 {
@@ -513,9 +529,23 @@ run (void *cls,
513{ 529{
514 GNUNET_assert (ok == 1); 530 GNUNET_assert (ok == 1);
515 OKPP; 531 OKPP;
516 setup_peer (&p1, "test_core_quota_peer1.conf"); 532 if (test == SYMMETRIC)
517 setup_peer (&p2, "test_core_quota_peer2.conf"); 533 {
534 setup_peer (&p1, "test_core_quota_peer1.conf");
535 setup_peer (&p2, "test_core_quota_peer2.conf");
536 }
537 else if (test == ASYMMETRIC_SEND_LIMITED)
538 {
539 setup_peer (&p1, "test_core_quota_asymmetric_send_limited_peer1.conf");
540 setup_peer (&p2, "test_core_quota_asymmetric_send_limited_peer2.conf");
541 }
542 else if (test == ASYMMETRIC_RECV_LIMITED)
543 {
544 setup_peer (&p1, "test_core_quota_asymmetric_recv_limited_peer1.conf");
545 setup_peer (&p2, "test_core_quota_asymmetric_recv_limited_peer2.conf");
546 }
518 547
548 GNUNET_assert (test != -1);
519 GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p1.cfg, 549 GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p1.cfg,
520 "CORE", 550 "CORE",
521 "TOTAL_QUOTA_IN", 551 "TOTAL_QUOTA_IN",
@@ -563,6 +593,8 @@ stop_arm (struct PeerContext *p)
563static int 593static int
564check () 594check ()
565{ 595{
596
597
566 char *const argv[] = { "test-core-quota-compliance", 598 char *const argv[] = { "test-core-quota-compliance",
567 "-c", 599 "-c",
568 "test_core_api_data.conf", 600 "test_core_api_data.conf",
@@ -587,6 +619,20 @@ main (int argc, char *argv[])
587{ 619{
588 int ret; 620 int ret;
589 621
622 test = -1;
623 if (strstr(argv[0], "_symmetric") != NULL)
624 {
625 test = SYMMETRIC;
626 }
627 else if (strstr(argv[0], "_asymmetric_send") != NULL)
628 {
629 test = ASYMMETRIC_SEND_LIMITED;
630 }
631 else if (strstr(argv[0], "_asymmetric_recv") != NULL)
632 {
633 test = ASYMMETRIC_RECV_LIMITED;
634 }
635 GNUNET_assert (test != -1);
590 GNUNET_log_setup ("test-core-quota-compliance", 636 GNUNET_log_setup ("test-core-quota-compliance",
591#if VERBOSE 637#if VERBOSE
592 "DEBUG", 638 "DEBUG",
@@ -594,6 +640,8 @@ main (int argc, char *argv[])
594 "WARNING", 640 "WARNING",
595#endif 641#endif
596 NULL); 642 NULL);
643 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
644 "argv[0] %s",argv[0]);
597 ret = check (); 645 ret = check ();
598 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); 646 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1");
599 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); 647 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2");