2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file transport/test_quota_compliance.c
22 * @brief base test case for transport implementations
24 * This test case tests quota compliance both on core and transport level
27 #include "gnunet_common.h"
28 #include "gnunet_hello_lib.h"
29 #include "gnunet_getopt_lib.h"
30 #include "gnunet_os_lib.h"
31 #include "gnunet_program_lib.h"
32 #include "gnunet_scheduler_lib.h"
33 #include "gnunet_server_lib.h"
34 #include "gnunet_transport_service.h"
35 #include "transport.h"
37 #define VERBOSE GNUNET_NO
39 #define VERBOSE_ARM GNUNET_NO
41 #define START_ARM GNUNET_YES
42 #define DEBUG_MEASUREMENT GNUNET_NO
43 #define DEBUG_CONNECTIONS GNUNET_NO
45 #define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
46 #define MEASUREMENT_MSG_SIZE 1024
47 #define MEASUREMENT_MSG_SIZE_BIG 32768
48 #define MEASUREMENT_MAX_QUOTA 1024 * 1024 * 1024
49 #define MEASUREMENT_MIN_QUOTA 1024
50 #define SEND_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
51 #define MEASUREMENT_SOFT_LIMIT 1024
56 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 200)
64 struct GNUNET_CONFIGURATION_Handle *cfg;
65 struct GNUNET_TRANSPORT_Handle *th;
66 struct GNUNET_PeerIdentity id;
68 struct GNUNET_OS_Process *arm_proc;
73 * Handle for a transmission-ready request.
75 struct GNUNET_TRANSPORT_TransmitHandle
79 * Neighbour for this handle, NULL for control-traffic.
81 struct NeighbourList *neighbour;
84 * Function to call when notify_size bytes are available
87 GNUNET_CONNECTION_TransmitReadyNotify notify;
95 * transmit_ready task Id. The task is used to introduce the
96 * artificial delay that may be required to maintain the bandwidth
97 * limits. Later, this will be the ID of the "transmit_timeout"
98 * task which is used to signal a timeout if the transmission could
99 * not be done in a timely fashion.
101 GNUNET_SCHEDULER_TaskIdentifier notify_delay_task;
104 * Timeout for this request.
106 struct GNUNET_TIME_Absolute timeout;
109 * How many bytes is our notify callback waiting for?
114 * How important is this message?
116 unsigned int priority;
120 static struct PeerContext p1;
122 static struct PeerContext p2;
126 static int connected;
127 static int measurement_running;
128 static int send_running;
129 static int recv_running;
131 static unsigned long long total_bytes_sent;
132 static unsigned long long last_msg_sent;
133 static unsigned long long last_msg_recv;
134 static unsigned long long current_quota_p1;
135 static unsigned long long current_quota_p2;
138 static int is_tcp_nat;
143 static int is_asymmetric_send_constant;
144 static int is_asymmetric_recv_constant;
146 static struct GNUNET_TIME_Absolute start_time;
148 static GNUNET_SCHEDULER_TaskIdentifier die_task;
149 static GNUNET_SCHEDULER_TaskIdentifier measurement_task;
150 static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task;
152 static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
154 #define OKPP do { ok++; } while (0)
167 GNUNET_SCHEDULER_cancel (die_task);
168 die_task = GNUNET_SCHEDULER_NO_TASK;
170 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
172 GNUNET_SCHEDULER_cancel (measurement_task);
173 measurement_task = GNUNET_SCHEDULER_NO_TASK;
175 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
177 GNUNET_SCHEDULER_cancel (measurement_counter_task);
178 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
180 fprintf(stderr,"\n");
181 GNUNET_SCHEDULER_shutdown ();
182 #if DEBUG_CONNECTIONS
183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
185 GNUNET_TRANSPORT_disconnect (p1.th);
186 GNUNET_TRANSPORT_disconnect (p2.th);
187 #if DEBUG_CONNECTIONS
188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
189 "Transports disconnected, returning success!\n");
191 GNUNET_SCHEDULER_shutdown ();
197 stop_arm (struct PeerContext *p)
200 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
201 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
202 GNUNET_OS_process_wait (p->arm_proc);
203 GNUNET_OS_process_close (p->arm_proc);
206 GNUNET_CONFIGURATION_destroy (p->cfg);
211 end_badly (void *cls,
212 const struct GNUNET_SCHEDULER_TaskContext *tc)
214 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
216 GNUNET_SCHEDULER_cancel (measurement_task);
217 measurement_task = GNUNET_SCHEDULER_NO_TASK;
219 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
221 GNUNET_SCHEDULER_cancel (measurement_counter_task);
222 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
226 GNUNET_TRANSPORT_disconnect (p1.th);
228 GNUNET_TRANSPORT_disconnect (p2.th);
234 struct GNUNET_MessageHeader header;
241 return MEASUREMENT_MSG_SIZE + sizeof (struct TestMessage);
245 notify_receive_new (void *cls,
246 const struct GNUNET_PeerIdentity *peer,
247 const struct GNUNET_MessageHeader *message,
248 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
250 const struct TestMessage *hdr;
252 hdr = (const struct TestMessage*) message;
253 if (measurement_running == GNUNET_NO)
255 if (MTYPE != ntohs (message->type))
258 #if DEBUG_MEASUREMENT
259 if (ntohl(hdr->num) % 5000 == 0)
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
262 "Got message %u of size %u\n",
264 ntohs (message->size));
268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
271 last_msg_recv = ntohl (hdr->num);
275 notify_ready (void *cls, size_t size, void *buf)
278 struct TestMessage hdr;
282 transmit_handle = NULL;
284 if (measurement_task == GNUNET_SCHEDULER_NO_TASK)
293 if (measurement_running != GNUNET_YES)
295 send_running = GNUNET_NO;
300 send_running = GNUNET_YES;
303 GNUNET_assert (size >= s);
304 GNUNET_assert (buf != NULL);
309 hdr.header.size = htons (s);
310 hdr.header.type = htons (MTYPE);
311 hdr.num = htonl (last_msg_sent);
312 memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
313 ret += sizeof (struct TestMessage);
314 memset (&cbuf[ret], last_msg_sent, s - sizeof (struct TestMessage));
315 ret += s - sizeof (struct TestMessage);
316 #if DEBUG_MEASUREMENT
319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
320 "Sending message %u\n",n);
324 /* GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
325 "Sending message %u\n",last_msg_sent);*/
328 if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
329 break; /* sometimes pack buffer full, sometimes not */
331 while (size - ret >= s);
332 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
337 total_bytes_sent += s;
341 static void measure (unsigned long long quota_p1, unsigned long long quota_p2 );
343 static void measurement_counter
345 const struct GNUNET_SCHEDULER_TaskContext *tc)
347 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
349 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
353 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
354 &measurement_counter,
359 measurement_end (void *cls,
360 const struct GNUNET_SCHEDULER_TaskContext *tc)
362 static int strike_counter;
363 static int failed_measurement_counter = 1;
364 unsigned long long quota_allowed = 0;
367 measurement_task = GNUNET_SCHEDULER_NO_TASK;
368 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
371 measurement_running = GNUNET_NO;
372 struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
375 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
377 GNUNET_SCHEDULER_cancel (measurement_counter_task);
378 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
381 if (transmit_handle != NULL)
383 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
384 transmit_handle = NULL;
387 if (current_quota_p1 < current_quota_p2)
388 quota_allowed = current_quota_p1;
390 quota_allowed = current_quota_p2;
393 if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/3))
394 delta = MEASUREMENT_SOFT_LIMIT;
396 delta = (quota_allowed/3);
398 /* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */
399 if ((total_bytes_sent/(duration.rel_value / 1000)) < 100)
401 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
402 "\nQuota compliance failed: \n"\
403 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\
404 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\
405 "Throughput : %10llu kB/s (%llu B/s)\n",
406 (quota_allowed / (1024)), quota_allowed,
407 ((quota_allowed+delta) / (1024)), quota_allowed+delta,
408 (total_bytes_sent/(duration.rel_value / 1000)/1024),
409 total_bytes_sent/(duration.rel_value / 1000));
411 failed_measurement_counter--;
412 if (failed_measurement_counter < 0)
414 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
415 "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
420 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
421 "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
424 /* Throughput is bigger than allowed quota + some extra*/
425 if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta))
427 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
428 "\nQuota compliance failed: \n"\
429 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\
430 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\
431 "Throughput : %10llu kB/s (%llu B/s)\n",
432 (quota_allowed / (1024)), quota_allowed,
433 ((quota_allowed+delta) / (1024)), quota_allowed+delta,
434 (total_bytes_sent/(duration.rel_value / 1000)/1024),
435 total_bytes_sent/(duration.rel_value / 1000));
437 failed_measurement_counter--;
438 if (failed_measurement_counter < 0)
440 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
441 "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
446 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
447 "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
451 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
452 "\nQuota compliance ok: \n"\
453 "Quota allowed: %10llu kB/s\n"\
454 "Throughput : %10llu kB/s\n", (quota_allowed / (1024)) , (total_bytes_sent/(duration.rel_value / 1000)/1024));
455 if (failed_measurement_counter < 2)
456 failed_measurement_counter++;
460 if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000))))
462 if (failed_measurement_counter < 2)
463 failed_measurement_counter++;
464 if (strike_counter == 2)
466 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
467 "Maximum transmission rate reached, stopping test\n");
477 if (quota_allowed == MEASUREMENT_MAX_QUOTA)
482 if (is_asymmetric_send_constant == GNUNET_YES)
484 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
485 measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA);
487 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
489 else if (is_asymmetric_recv_constant == GNUNET_YES)
491 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
492 measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2);
494 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
498 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
499 measure ((current_quota_p1) * 2, (current_quota_p2) * 2);
501 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
505 static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
507 current_quota_p1 = quota_p1;
508 current_quota_p2 = quota_p2;
510 if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES))
511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
512 "Starting transport level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024, current_quota_p2 / 1024);
514 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
515 "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p2 / 1024);
518 GNUNET_TRANSPORT_set_quota (p1.th,
520 GNUNET_BANDWIDTH_value_init (current_quota_p1),
521 GNUNET_BANDWIDTH_value_init (current_quota_p1));
522 GNUNET_TRANSPORT_set_quota (p2.th,
524 GNUNET_BANDWIDTH_value_init (current_quota_p2),
525 GNUNET_BANDWIDTH_value_init (current_quota_p2));
526 GNUNET_SCHEDULER_cancel (die_task);
527 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
530 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
531 GNUNET_SCHEDULER_cancel (measurement_counter_task);
532 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
533 &measurement_counter,
535 measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
538 total_bytes_sent = 0;
541 measurement_running = GNUNET_YES;
542 start_time = GNUNET_TIME_absolute_get ();
544 if (transmit_handle != NULL)
545 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
546 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
548 get_size (), 0, SEND_TIMEOUT,
554 notify_connect (void *cls,
555 const struct GNUNET_PeerIdentity *peer,
556 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
560 #if DEBUG_CONNECTIONS
561 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
562 "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
568 #if DEBUG_CONNECTIONS
569 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
570 "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
576 if (is_asymmetric_send_constant == GNUNET_YES)
577 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
578 else if (is_asymmetric_recv_constant == GNUNET_YES)
579 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA);
581 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
587 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
589 #if DEBUG_CONNECTIONS
590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
591 "Peer `%4s' disconnected (%p)!\n",
592 GNUNET_i2s (peer), cls);
598 setup_peer (struct PeerContext *p, const char *cfgname)
600 p->cfg = GNUNET_CONFIGURATION_create ();
602 p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
603 "gnunet-service-arm",
604 "gnunet-service-arm",
608 "-c", cfgname, NULL);
611 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
612 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
617 GNUNET_assert (p->th != NULL);
621 notify_ready_connect (void *cls, size_t size, void *buf)
627 exchange_hello_last (void *cls,
628 const struct GNUNET_MessageHeader *message)
630 struct PeerContext *me = cls;
632 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
634 GNUNET_assert (ok >= 3);
636 GNUNET_assert (message != NULL);
637 GNUNET_assert (GNUNET_OK ==
638 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
641 GNUNET_assert(NULL != (transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
643 sizeof (struct GNUNET_MessageHeader), 0,
645 ¬ify_ready_connect,
648 /* both HELLOs exchanged, get ready to test transmission! */
653 exchange_hello (void *cls,
654 const struct GNUNET_MessageHeader *message)
656 struct PeerContext *me = cls;
658 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
659 GNUNET_assert (ok >= 2);
661 GNUNET_assert (message != NULL);
662 GNUNET_assert (GNUNET_OK ==
663 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
665 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
666 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
672 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
674 GNUNET_assert (ok == 1);
677 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
680 measurement_running = GNUNET_NO;
681 send_running = GNUNET_NO;
682 recv_running = GNUNET_NO;
686 if (is_asymmetric_recv_constant == GNUNET_YES)
687 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n");
688 else if (is_asymmetric_send_constant == GNUNET_YES)
689 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n");
691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP transport plugin\n");
692 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
693 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
697 if (is_asymmetric_recv_constant == GNUNET_YES)
698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n");
699 else if (is_asymmetric_send_constant == GNUNET_YES)
700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n");
702 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTP transport plugin\n");
703 setup_peer (&p1, "test_quota_compliance_http_peer1.conf");
704 setup_peer (&p2, "test_quota_compliance_http_peer2.conf");
708 if (is_asymmetric_recv_constant == GNUNET_YES)
709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n");
710 else if (is_asymmetric_send_constant == GNUNET_YES)
711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n");
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTPS transport plugin\n");
714 setup_peer (&p1, "test_quota_compliance_https_peer1.conf");
715 setup_peer (&p2, "test_quota_compliance_https_peer2.conf");
719 if (is_asymmetric_recv_constant == GNUNET_YES)
720 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n");
721 else if (is_asymmetric_send_constant == GNUNET_YES)
722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n");
724 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for UDP transport plugin\n");
725 setup_peer (&p1, "test_quota_compliance_udp_peer1.conf");
726 setup_peer (&p2, "test_quota_compliance_udp_peer2.conf");
730 if (is_asymmetric_recv_constant == GNUNET_YES)
731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for UNIX transport plugin\n");
732 else if (is_asymmetric_send_constant == GNUNET_YES)
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n");
735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for UNIX transport plugin\n");
736 setup_peer (&p1, "test_quota_compliance_unix_peer1.conf");
737 setup_peer (&p2, "test_quota_compliance_unix_peer2.conf");
741 if (is_asymmetric_recv_constant == GNUNET_YES)
742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n");
743 else if (is_asymmetric_send_constant == GNUNET_YES)
744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n");
746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP NAT transport plugin\n");
747 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
748 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
753 GNUNET_assert(p1.th != NULL);
754 GNUNET_assert(p2.th != NULL);
755 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
759 main (int argc, char *argv[])
763 return GNUNET_SYSERR;
765 if (strstr(argv[0], "tcp_nat") != NULL)
767 is_tcp_nat = GNUNET_YES;
769 else if (strstr(argv[0], "tcp") != NULL)
773 else if (strstr(argv[0], "https") != NULL)
775 is_https = GNUNET_YES;
777 else if (strstr(argv[0], "http") != NULL)
779 is_http = GNUNET_YES;
781 else if (strstr(argv[0], "udp") != NULL)
785 else if (strstr(argv[0], "unix") != NULL)
787 is_unix = GNUNET_YES;
790 if (strstr(argv[0], "asymmetric_recv") != NULL)
792 is_asymmetric_recv_constant = GNUNET_YES;
795 is_asymmetric_recv_constant = GNUNET_NO;
796 if (strstr(argv[0], "asymmetric_send") != NULL)
798 is_asymmetric_send_constant = GNUNET_YES;
801 is_asymmetric_send_constant = GNUNET_NO;
804 if (is_tcp == GNUNET_YES)
806 if (is_asymmetric_recv_constant == GNUNET_YES)
807 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant");
808 else if (is_asymmetric_send_constant == GNUNET_YES)
809 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant");
811 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric");
813 else if (is_udp == GNUNET_YES)
815 if (is_asymmetric_recv_constant == GNUNET_YES)
816 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant");
817 else if (is_asymmetric_send_constant == GNUNET_YES)
818 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant");
820 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric");
822 else if (is_unix == GNUNET_YES)
824 if (is_asymmetric_recv_constant == GNUNET_YES)
825 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_recv_constant");
826 else if (is_asymmetric_send_constant == GNUNET_YES)
827 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_send_constant");
829 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","symmetric");
831 else if (is_http == GNUNET_YES)
833 if (is_asymmetric_recv_constant == GNUNET_YES)
834 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant");
835 else if (is_asymmetric_send_constant == GNUNET_YES)
836 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant");
838 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric");
840 else if (is_https == GNUNET_YES)
842 if (is_asymmetric_recv_constant == GNUNET_YES)
843 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant");
844 else if (is_asymmetric_send_constant == GNUNET_YES)
845 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant");
847 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric");
851 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none");
854 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
855 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
857 fprintf(stderr, "Running `%s'\n", logger);
858 GNUNET_log_setup ("test-quota-compliance",
865 char *const argv1[] = { "test-quota-compliance",
867 "test_quota_compliance_data.conf",
873 struct GNUNET_GETOPT_CommandLineOption options[] = {
874 GNUNET_GETOPT_OPTION_END
877 GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1,
878 argv1, logger , "nohelp",
884 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
885 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
889 /* end of test_quota_compliance.c */