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;
142 static int is_asymmetric_send_constant;
143 static int is_asymmetric_recv_constant;
145 static struct GNUNET_TIME_Absolute start_time;
147 static GNUNET_SCHEDULER_TaskIdentifier die_task;
148 static GNUNET_SCHEDULER_TaskIdentifier measurement_task;
149 static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task;
151 struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
153 #define OKPP do { ok++; } while (0)
166 GNUNET_SCHEDULER_cancel (die_task);
167 die_task = GNUNET_SCHEDULER_NO_TASK;
169 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
171 GNUNET_SCHEDULER_cancel (measurement_task);
172 measurement_task = GNUNET_SCHEDULER_NO_TASK;
174 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
176 GNUNET_SCHEDULER_cancel (measurement_counter_task);
177 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
179 fprintf(stderr,"\n");
180 GNUNET_SCHEDULER_shutdown ();
181 #if DEBUG_CONNECTIONS
182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
184 GNUNET_TRANSPORT_disconnect (p1.th);
185 GNUNET_TRANSPORT_disconnect (p2.th);
186 #if DEBUG_CONNECTIONS
187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
188 "Transports disconnected, returning success!\n");
190 GNUNET_SCHEDULER_shutdown ();
196 stop_arm (struct PeerContext *p)
199 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
200 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
201 GNUNET_OS_process_wait (p->arm_proc);
202 GNUNET_OS_process_close (p->arm_proc);
205 GNUNET_CONFIGURATION_destroy (p->cfg);
210 end_badly (void *cls,
211 const struct GNUNET_SCHEDULER_TaskContext *tc)
213 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
215 GNUNET_SCHEDULER_cancel (measurement_task);
216 measurement_task = GNUNET_SCHEDULER_NO_TASK;
218 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
220 GNUNET_SCHEDULER_cancel (measurement_counter_task);
221 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
225 GNUNET_TRANSPORT_disconnect (p1.th);
227 GNUNET_TRANSPORT_disconnect (p2.th);
233 struct GNUNET_MessageHeader header;
240 return MEASUREMENT_MSG_SIZE + sizeof (struct TestMessage);
244 notify_receive_new (void *cls,
245 const struct GNUNET_PeerIdentity *peer,
246 const struct GNUNET_MessageHeader *message,
247 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
250 const struct TestMessage *hdr;
252 hdr = (const struct TestMessage*) message;
254 if (measurement_running == GNUNET_NO)
256 if (MTYPE != ntohs (message->type))
259 #if DEBUG_MEASUREMENT
260 if (ntohl(hdr->num) % 5000 == 0)
262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
263 "Got message %u of size %u\n",
265 ntohs (message->size));
269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
272 last_msg_recv = ntohl (hdr->num);
276 notify_ready (void *cls, size_t size, void *buf)
279 struct TestMessage hdr;
283 transmit_handle = NULL;
285 if (measurement_task == GNUNET_SCHEDULER_NO_TASK)
294 if (measurement_running != GNUNET_YES)
296 send_running = GNUNET_NO;
301 send_running = GNUNET_YES;
304 GNUNET_assert (size >= s);
305 GNUNET_assert (buf != NULL);
310 hdr.header.size = htons (s);
311 hdr.header.type = htons (MTYPE);
312 hdr.num = htonl (last_msg_sent);
313 memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
314 ret += sizeof (struct TestMessage);
315 memset (&cbuf[ret], last_msg_sent, s - sizeof (struct TestMessage));
316 ret += s - sizeof (struct TestMessage);
317 #if DEBUG_MEASUREMENT
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
321 "Sending message %u\n",n);
325 /* GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
326 "Sending message %u\n",last_msg_sent);*/
329 if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
330 break; /* sometimes pack buffer full, sometimes not */
332 while (size - ret >= s);
333 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
338 total_bytes_sent += s;
342 static void measure (unsigned long long quota_p1, unsigned long long quota_p2 );
344 static void measurement_counter
346 const struct GNUNET_SCHEDULER_TaskContext *tc)
348 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
350 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
354 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
355 &measurement_counter,
360 measurement_end (void *cls,
361 const struct GNUNET_SCHEDULER_TaskContext *tc)
363 static int strike_counter;
364 static int failed_measurement_counter;
365 unsigned long long quota_allowed = 0;
368 measurement_task = GNUNET_SCHEDULER_NO_TASK;
369 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
372 measurement_running = GNUNET_NO;
373 struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
376 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
378 GNUNET_SCHEDULER_cancel (measurement_counter_task);
379 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
382 if (transmit_handle != NULL)
384 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
385 transmit_handle = NULL;
388 if (current_quota_p1 < current_quota_p2)
389 quota_allowed = current_quota_p1;
391 quota_allowed = current_quota_p2;
394 if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/10))
395 delta = MEASUREMENT_SOFT_LIMIT;
397 delta = (quota_allowed/10);
399 /* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */
400 if ((total_bytes_sent/(duration.rel_value / 1000)) < 100)
402 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
403 "\nQuota compliance failed: \n"\
404 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\
405 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\
406 "Throughput : %10llu kB/s (%llu B/s)\n",
407 (quota_allowed / (1024)), quota_allowed,
408 ((quota_allowed+delta) / (1024)), quota_allowed+delta,
409 (total_bytes_sent/(duration.rel_value / 1000)/1024),
410 total_bytes_sent/(duration.rel_value / 1000));
412 failed_measurement_counter--;
413 if (failed_measurement_counter < 0)
418 /* Throughput is bigger than allowed quota + some extra*/
419 if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta))
421 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
422 "\nQuota compliance failed: \n"\
423 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\
424 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\
425 "Throughput : %10llu kB/s (%llu B/s)\n",
426 (quota_allowed / (1024)), quota_allowed,
427 ((quota_allowed+delta) / (1024)), quota_allowed+delta,
428 (total_bytes_sent/(duration.rel_value / 1000)/1024),
429 total_bytes_sent/(duration.rel_value / 1000));
431 failed_measurement_counter--;
432 if (failed_measurement_counter < 0)
438 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
439 "\nQuota compliance ok: \n"\
440 "Quota allowed: %10llu kB/s\n"\
441 "Throughput : %10llu kB/s\n", (quota_allowed / (1024)) , (total_bytes_sent/(duration.rel_value / 1000)/1024));
442 if (failed_measurement_counter < 2)
443 failed_measurement_counter++;
447 if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000))))
449 if (failed_measurement_counter < 2)
450 failed_measurement_counter++;
451 if (strike_counter == 2)
453 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
454 "Maximum transmission rate reached, stopping test\n");
464 if (quota_allowed == MEASUREMENT_MAX_QUOTA)
469 if (is_asymmetric_send_constant == GNUNET_YES)
471 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
472 measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA);
474 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
476 else if (is_asymmetric_recv_constant == GNUNET_YES)
478 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
479 measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2);
481 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
485 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
486 measure ((current_quota_p1) * 2, (current_quota_p2) * 2);
488 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
492 static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
494 current_quota_p1 = quota_p1;
495 current_quota_p2 = quota_p2;
497 if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES))
498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
499 "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);
501 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
502 "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p2 / 1024);
505 GNUNET_TRANSPORT_set_quota (p1.th,
507 GNUNET_BANDWIDTH_value_init (current_quota_p1 ),
508 GNUNET_BANDWIDTH_value_init (current_quota_p1 ),
509 GNUNET_TIME_UNIT_FOREVER_REL,
511 GNUNET_TRANSPORT_set_quota (p2.th,
513 GNUNET_BANDWIDTH_value_init (current_quota_p2),
514 GNUNET_BANDWIDTH_value_init (current_quota_p2),
515 GNUNET_TIME_UNIT_FOREVER_REL,
518 GNUNET_SCHEDULER_cancel (die_task);
519 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
522 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
523 GNUNET_SCHEDULER_cancel (measurement_counter_task);
524 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
525 &measurement_counter,
527 measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
530 total_bytes_sent = 0;
533 measurement_running = GNUNET_YES;
534 start_time = GNUNET_TIME_absolute_get ();
536 if (transmit_handle != NULL)
537 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
538 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
540 get_size (), 0, SEND_TIMEOUT,
546 notify_connect (void *cls,
547 const struct GNUNET_PeerIdentity *peer,
548 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
552 #if DEBUG_CONNECTIONS
553 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
554 "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
560 #if DEBUG_CONNECTIONS
561 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
562 "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
568 if (is_asymmetric_send_constant == GNUNET_YES)
569 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
570 else if (is_asymmetric_recv_constant == GNUNET_YES)
571 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA);
573 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
579 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
581 #if DEBUG_CONNECTIONS
582 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
583 "Peer `%4s' disconnected (%p)!\n",
584 GNUNET_i2s (peer), cls);
590 setup_peer (struct PeerContext *p, const char *cfgname)
592 p->cfg = GNUNET_CONFIGURATION_create ();
594 p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
595 "gnunet-service-arm",
596 "gnunet-service-arm",
600 "-c", cfgname, NULL);
603 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
604 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
609 GNUNET_assert (p->th != NULL);
614 exchange_hello_last (void *cls,
615 const struct GNUNET_MessageHeader *message)
617 struct PeerContext *me = cls;
619 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
621 GNUNET_assert (ok >= 3);
623 GNUNET_assert (message != NULL);
624 GNUNET_assert (GNUNET_OK ==
625 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
627 /* both HELLOs exchanged, get ready to test transmission! */
632 exchange_hello (void *cls,
633 const struct GNUNET_MessageHeader *message)
635 struct PeerContext *me = cls;
637 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
638 GNUNET_assert (ok >= 2);
640 GNUNET_assert (message != NULL);
641 GNUNET_assert (GNUNET_OK ==
642 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
644 GNUNET_TRANSPORT_offer_hello (p2.th, message);
645 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
651 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
653 GNUNET_assert (ok == 1);
656 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
659 measurement_running = GNUNET_NO;
660 send_running = GNUNET_NO;
661 recv_running = GNUNET_NO;
665 if (is_asymmetric_recv_constant == GNUNET_YES)
666 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n");
667 else if (is_asymmetric_send_constant == GNUNET_YES)
668 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n");
670 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP transport plugin\n");
671 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
672 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
676 if (is_asymmetric_recv_constant == GNUNET_YES)
677 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n");
678 else if (is_asymmetric_send_constant == GNUNET_YES)
679 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n");
681 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTP transport plugin\n");
682 setup_peer (&p1, "test_quota_compliance_http_peer1.conf");
683 setup_peer (&p2, "test_quota_compliance_http_peer2.conf");
687 if (is_asymmetric_recv_constant == GNUNET_YES)
688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n");
689 else if (is_asymmetric_send_constant == GNUNET_YES)
690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n");
692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTPS transport plugin\n");
693 setup_peer (&p1, "test_quota_compliance_https_peer1.conf");
694 setup_peer (&p2, "test_quota_compliance_https_peer2.conf");
698 if (is_asymmetric_recv_constant == GNUNET_YES)
699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n");
700 else if (is_asymmetric_send_constant == GNUNET_YES)
701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n");
703 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for UDP transport plugin\n");
704 setup_peer (&p1, "test_quota_compliance_udp_peer1.conf");
705 setup_peer (&p2, "test_quota_compliance_udp_peer2.conf");
709 if (is_asymmetric_recv_constant == GNUNET_YES)
710 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n");
711 else if (is_asymmetric_send_constant == GNUNET_YES)
712 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n");
714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP NAT transport plugin\n");
715 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
716 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
721 GNUNET_assert(p1.th != NULL);
722 GNUNET_assert(p2.th != NULL);
723 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
727 main (int argc, char *argv[])
731 return GNUNET_SYSERR;
733 if (strstr(argv[0], "tcp_nat") != NULL)
735 is_tcp_nat = GNUNET_YES;
737 else if (strstr(argv[0], "tcp") != NULL)
741 else if (strstr(argv[0], "https") != NULL)
743 is_https = GNUNET_YES;
745 else if (strstr(argv[0], "http") != NULL)
747 is_http = GNUNET_YES;
749 else if (strstr(argv[0], "udp") != NULL)
754 if (strstr(argv[0], "asymmetric_recv") != NULL)
756 is_asymmetric_recv_constant = GNUNET_YES;
759 is_asymmetric_recv_constant = GNUNET_NO;
760 if (strstr(argv[0], "asymmetric_send") != NULL)
762 is_asymmetric_send_constant = GNUNET_YES;
765 is_asymmetric_send_constant = GNUNET_NO;
768 if (is_tcp == GNUNET_YES)
770 if (is_asymmetric_recv_constant == GNUNET_YES)
771 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant");
772 else if (is_asymmetric_send_constant == GNUNET_YES)
773 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant");
775 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric");
777 if (is_udp == GNUNET_YES)
779 if (is_asymmetric_recv_constant == GNUNET_YES)
780 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant");
781 else if (is_asymmetric_send_constant == GNUNET_YES)
782 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant");
784 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric");
786 if (is_http == GNUNET_YES)
788 if (is_asymmetric_recv_constant == GNUNET_YES)
789 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant");
790 else if (is_asymmetric_send_constant == GNUNET_YES)
791 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant");
793 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric");
795 if (is_https == GNUNET_YES)
797 if (is_asymmetric_recv_constant == GNUNET_YES)
798 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant");
799 else if (is_asymmetric_send_constant == GNUNET_YES)
800 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant");
802 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric");
805 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
806 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
808 fprintf(stderr, "Running `%s'\n", logger);
809 GNUNET_log_setup ("test-quota-compliance",
816 char *const argv1[] = { "test-quota-compliance",
818 "test_quota_compliance_data.conf",
824 struct GNUNET_GETOPT_CommandLineOption options[] = {
825 GNUNET_GETOPT_OPTION_END
828 GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1,
829 argv1, logger , "nohelp",
835 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
836 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
840 /* end of test_quota_compliance.c */