2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 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"
36 #include "transport-testing.h"
38 #define VERBOSE GNUNET_NO
40 #define VERBOSE_ARM GNUNET_NO
42 #define START_ARM GNUNET_YES
43 #define DEBUG_MEASUREMENT GNUNET_NO
44 #define DEBUG_CONNECTIONS GNUNET_NO
46 #define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
47 #define MEASUREMENT_MSG_SIZE 1024
48 #define MEASUREMENT_MSG_SIZE_BIG 32768
49 #define MEASUREMENT_MAX_QUOTA 1024 * 1024 * 1024
50 #define MEASUREMENT_MIN_QUOTA 1024
51 #define SEND_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
52 #define MEASUREMENT_SOFT_LIMIT 1024
57 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 200)
64 * Handle for a transmission-ready request.
66 struct GNUNET_TRANSPORT_TransmitHandle
70 * Neighbour for this handle, NULL for control-traffic.
72 struct NeighbourList *neighbour;
75 * Function to call when notify_size bytes are available
78 GNUNET_CONNECTION_TransmitReadyNotify notify;
86 * transmit_ready task Id. The task is used to introduce the
87 * artificial delay that may be required to maintain the bandwidth
88 * limits. Later, this will be the ID of the "transmit_timeout"
89 * task which is used to signal a timeout if the transmission could
90 * not be done in a timely fashion.
92 GNUNET_SCHEDULER_TaskIdentifier notify_delay_task;
95 * Timeout for this request.
97 struct GNUNET_TIME_Absolute timeout;
100 * How many bytes is our notify callback waiting for?
105 * How important is this message?
107 unsigned int priority;
111 static struct PeerContext p1;
113 static struct PeerContext p2;
117 static int connected;
118 static int measurement_running;
119 static int send_running;
120 static int recv_running;
122 static unsigned long long total_bytes_sent;
123 static unsigned long long last_msg_sent;
124 static unsigned long long last_msg_recv;
125 static unsigned long long current_quota_p1;
126 static unsigned long long current_quota_p2;
129 static int is_tcp_nat;
134 static int is_asymmetric_send_constant;
135 static int is_asymmetric_recv_constant;
137 static struct GNUNET_TIME_Absolute start_time;
139 static GNUNET_SCHEDULER_TaskIdentifier die_task;
140 static GNUNET_SCHEDULER_TaskIdentifier tct;
141 static GNUNET_SCHEDULER_TaskIdentifier measurement_task;
142 static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task;
144 static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
146 #define OKPP do { ok++; } while (0)
152 GNUNET_SCHEDULER_cancel (die_task);
153 die_task = GNUNET_SCHEDULER_NO_TASK;
155 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
157 GNUNET_SCHEDULER_cancel (measurement_task);
158 measurement_task = GNUNET_SCHEDULER_NO_TASK;
160 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
162 GNUNET_SCHEDULER_cancel (measurement_counter_task);
163 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
165 fprintf(stderr,"\n");
166 GNUNET_SCHEDULER_shutdown ();
167 #if DEBUG_CONNECTIONS
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
169 "Disconnecting from transports!\n");
171 GNUNET_TRANSPORT_disconnect (p1.th);
172 GNUNET_TRANSPORT_disconnect (p2.th);
173 #if DEBUG_CONNECTIONS
174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
175 "Transports disconnected, returning success!\n");
177 GNUNET_SCHEDULER_shutdown ();
183 stop_arm (struct PeerContext *p)
186 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
187 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
188 GNUNET_OS_process_wait (p->arm_proc);
189 GNUNET_OS_process_close (p->arm_proc);
192 GNUNET_CONFIGURATION_destroy (p->cfg);
197 end_badly (void *cls,
198 const struct GNUNET_SCHEDULER_TaskContext *tc)
200 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
202 GNUNET_SCHEDULER_cancel (measurement_task);
203 measurement_task = GNUNET_SCHEDULER_NO_TASK;
205 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
207 GNUNET_SCHEDULER_cancel (measurement_counter_task);
208 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
211 if (GNUNET_SCHEDULER_NO_TASK != tct)
213 GNUNET_SCHEDULER_cancel (tct);
214 tct = GNUNET_SCHEDULER_NO_TASK;
217 GNUNET_TRANSPORT_disconnect (p1.th);
219 GNUNET_TRANSPORT_disconnect (p2.th);
225 struct GNUNET_MessageHeader header;
233 return MEASUREMENT_MSG_SIZE + sizeof (struct TestMessage);
237 notify_receive_new (void *cls,
238 const struct GNUNET_PeerIdentity *peer,
239 const struct GNUNET_MessageHeader *message,
240 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
242 const struct TestMessage *hdr;
244 GNUNET_assert (message != NULL);
245 hdr = (const struct TestMessage*) message;
246 if (measurement_running == GNUNET_NO)
248 if (MTYPE != ntohs (message->type))
251 #if DEBUG_MEASUREMENT
252 if (ntohl(hdr->num) % 5000 == 0)
254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
255 "Got message %u of size %u\n",
257 ntohs (message->size));
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
264 last_msg_recv = ntohl (hdr->num);
269 notify_ready (void *cls, size_t size, void *buf)
272 struct TestMessage hdr;
276 transmit_handle = NULL;
277 if (measurement_task == GNUNET_SCHEDULER_NO_TASK)
285 if (measurement_running != GNUNET_YES)
287 send_running = GNUNET_NO;
290 send_running = GNUNET_YES;
293 GNUNET_assert (size >= s);
294 GNUNET_assert (buf != NULL);
299 hdr.header.size = htons (s);
300 hdr.header.type = htons (MTYPE);
301 hdr.num = htonl (last_msg_sent);
302 memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
303 ret += sizeof (struct TestMessage);
304 memset (&cbuf[ret], last_msg_sent, s - sizeof (struct TestMessage));
305 ret += s - sizeof (struct TestMessage);
306 #if DEBUG_MEASUREMENT
309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
310 "Sending message %u\n",n);
314 /* GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
315 "Sending message %u\n",last_msg_sent);*/
318 if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
319 break; /* sometimes pack buffer full, sometimes not */
321 while (size - ret >= s);
322 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
327 total_bytes_sent += s;
333 measure (unsigned long long quota_p1, unsigned long long quota_p2);
336 measurement_counter (void *cls,
337 const struct GNUNET_SCHEDULER_TaskContext *tc)
339 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
340 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
344 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
345 &measurement_counter,
351 measurement_end (void *cls,
352 const struct GNUNET_SCHEDULER_TaskContext *tc)
354 static int strike_counter;
355 static int failed_measurement_counter = 1;
356 unsigned long long quota_allowed = 0;
359 measurement_task = GNUNET_SCHEDULER_NO_TASK;
360 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
363 measurement_running = GNUNET_NO;
364 struct GNUNET_TIME_Relative duration
365 = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
368 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
370 GNUNET_SCHEDULER_cancel (measurement_counter_task);
371 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
374 if (transmit_handle != NULL)
376 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
377 transmit_handle = NULL;
380 if (current_quota_p1 < current_quota_p2)
381 quota_allowed = current_quota_p1;
383 quota_allowed = current_quota_p2;
386 if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/3))
387 delta = MEASUREMENT_SOFT_LIMIT;
389 delta = (quota_allowed/3);
391 /* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */
392 if ((total_bytes_sent/(duration.rel_value / 1000)) < 100)
394 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
395 "\nQuota compliance failed: \n" \
396 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \
397 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \
398 "Throughput : %10llu kB/s (%llu B/s)\n",
399 (quota_allowed / (1024)), quota_allowed,
400 ((quota_allowed+delta) / (1024)), quota_allowed+delta,
401 (total_bytes_sent/(duration.rel_value / 1000)/1024),
402 total_bytes_sent/(duration.rel_value / 1000));
404 failed_measurement_counter--;
405 if (failed_measurement_counter < 0)
407 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
408 "\nQuota measurement failed and no free strike: %i\n",
409 failed_measurement_counter);
414 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
415 "\nQuota measurement failed and %i free strikes\n",
416 failed_measurement_counter);
419 /* Throughput is bigger than allowed quota + some extra*/
420 if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta))
422 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
423 "\nQuota compliance failed: \n" \
424 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \
425 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \
426 "Throughput : %10llu kB/s (%llu B/s)\n",
427 (quota_allowed / (1024)), quota_allowed,
428 ((quota_allowed+delta) / (1024)), quota_allowed+delta,
429 (total_bytes_sent/(duration.rel_value / 1000)/1024),
430 total_bytes_sent/(duration.rel_value / 1000));
432 failed_measurement_counter--;
433 if (failed_measurement_counter < 0)
435 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
436 "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
441 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
442 "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
446 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
447 "\nQuota compliance ok: \n" \
448 "Quota allowed: %10llu kB/s\n" \
449 "Throughput : %10llu kB/s\n",
450 (quota_allowed / (1024)),
451 (total_bytes_sent/(duration.rel_value / 1000)/1024));
452 if (failed_measurement_counter < 2)
453 failed_measurement_counter++;
457 if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000))))
459 if (failed_measurement_counter < 2)
460 failed_measurement_counter++;
461 if (strike_counter == 2)
463 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
464 "Maximum transmission rate reached, stopping test\n");
474 if (quota_allowed == MEASUREMENT_MAX_QUOTA)
479 if (is_asymmetric_send_constant == GNUNET_YES)
481 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
482 measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA);
484 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
486 else if (is_asymmetric_recv_constant == GNUNET_YES)
488 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
489 measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2);
491 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
495 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
496 measure ((current_quota_p1) * 2, (current_quota_p2) * 2);
498 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
503 measure (unsigned long long quota_p1, unsigned long long quota_p2)
505 current_quota_p1 = quota_p1;
506 current_quota_p2 = quota_p2;
508 if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES))
509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
510 "Starting transport level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n",
511 MEASUREMENT_INTERVALL.rel_value / 1000 ,
512 current_quota_p1 / 1024,
513 current_quota_p2 / 1024);
515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
516 "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n",
517 MEASUREMENT_INTERVALL.rel_value / 1000,
518 current_quota_p2 / 1024);
521 GNUNET_TRANSPORT_set_quota (p1.th,
523 GNUNET_BANDWIDTH_value_init (current_quota_p1),
524 GNUNET_BANDWIDTH_value_init (current_quota_p1));
525 GNUNET_TRANSPORT_set_quota (p2.th,
527 GNUNET_BANDWIDTH_value_init (current_quota_p2),
528 GNUNET_BANDWIDTH_value_init (current_quota_p2));
529 GNUNET_SCHEDULER_cancel (die_task);
530 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
533 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
534 GNUNET_SCHEDULER_cancel (measurement_counter_task);
535 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
536 &measurement_counter,
538 measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
541 total_bytes_sent = 0;
544 measurement_running = GNUNET_YES;
545 start_time = GNUNET_TIME_absolute_get ();
547 if (transmit_handle != NULL)
548 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
549 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
551 get_size (), 0, SEND_TIMEOUT,
558 exchange_hello_last (void *cls,
559 const struct GNUNET_MessageHeader *message)
561 struct PeerContext *me = cls;
563 GNUNET_assert (message != NULL);
564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
565 "Exchanging HELLO of size %d with peer (%s)!\n",
566 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
567 GNUNET_i2s (&me->id));
568 GNUNET_assert (GNUNET_OK ==
569 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
571 GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
577 exchange_hello (void *cls,
578 const struct GNUNET_MessageHeader *message)
580 struct PeerContext *me = cls;
582 GNUNET_assert (message != NULL);
583 GNUNET_assert (GNUNET_OK ==
584 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
586 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
587 "Exchanging HELLO of size %d from peer %s!\n",
588 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
589 GNUNET_i2s (&me->id));
590 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
595 notify_connect (void *cls,
596 const struct GNUNET_PeerIdentity *peer,
597 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
602 #if DEBUG_CONNECTIONS
603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
604 "Peer 1 `%4s' connected to us (%p)!\n",
611 #if DEBUG_CONNECTIONS
612 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
613 "Peer 2 `%4s' connected to us (%p)!\n",
620 GNUNET_SCHEDULER_cancel (tct);
621 tct = GNUNET_SCHEDULER_NO_TASK;
622 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
623 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
624 if (is_asymmetric_send_constant == GNUNET_YES)
625 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
626 else if (is_asymmetric_recv_constant == GNUNET_YES)
627 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA);
629 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
635 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
638 #if DEBUG_CONNECTIONS
639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
640 "Peer `%4s' disconnected (%p)!\n",
641 GNUNET_i2s (peer), cls);
647 setup_peer (struct PeerContext *p, const char *cfgname)
649 p->cfg = GNUNET_CONFIGURATION_create ();
650 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
651 if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
653 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
654 GNUNET_DISK_directory_remove (p->servicehome);
658 p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
659 "gnunet-service-arm",
660 "gnunet-service-arm",
664 "-c", cfgname, NULL);
667 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
672 GNUNET_assert (p->th != NULL);
677 try_connect (void *cls,
678 const struct GNUNET_SCHEDULER_TaskContext *tc)
680 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
681 "Asking peers to connect...\n");
682 GNUNET_TRANSPORT_try_connect (p2.th,
684 GNUNET_TRANSPORT_try_connect (p1.th,
686 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
695 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
697 GNUNET_assert (ok == 1);
700 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
703 measurement_running = GNUNET_NO;
704 send_running = GNUNET_NO;
705 recv_running = GNUNET_NO;
709 if (is_asymmetric_recv_constant == GNUNET_YES)
710 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
711 "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n");
712 else if (is_asymmetric_send_constant == GNUNET_YES)
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
714 "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n");
716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
717 "Testing symmetric quota compliance for TCP transport plugin\n");
718 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
719 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
723 if (is_asymmetric_recv_constant == GNUNET_YES)
724 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
725 "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n");
726 else if (is_asymmetric_send_constant == GNUNET_YES)
727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
728 "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n");
730 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
731 "Testing symmetric quota compliance for HTTP transport plugin\n");
732 setup_peer (&p1, "test_quota_compliance_http_peer1.conf");
733 setup_peer (&p2, "test_quota_compliance_http_peer2.conf");
737 if (is_asymmetric_recv_constant == GNUNET_YES)
738 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
739 "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n");
740 else if (is_asymmetric_send_constant == GNUNET_YES)
741 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
742 "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n");
744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
745 "Testing symmetric quota compliance for HTTPS transport plugin\n");
746 setup_peer (&p1, "test_quota_compliance_https_peer1.conf");
747 setup_peer (&p2, "test_quota_compliance_https_peer2.conf");
751 if (is_asymmetric_recv_constant == GNUNET_YES)
752 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
753 "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n");
754 else if (is_asymmetric_send_constant == GNUNET_YES)
755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
756 "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n");
758 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
759 "Testing symmetric quota compliance for UDP transport plugin\n");
760 setup_peer (&p1, "test_quota_compliance_udp_peer1.conf");
761 setup_peer (&p2, "test_quota_compliance_udp_peer2.conf");
765 if (is_asymmetric_recv_constant == GNUNET_YES)
766 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
767 "Testing asymmetric quota compliance (receiver quota constant) for UNIX transport plugin\n");
768 else if (is_asymmetric_send_constant == GNUNET_YES)
769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
770 "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n");
772 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
773 "Testing symmetric quota compliance for UNIX transport plugin\n");
774 setup_peer (&p1, "test_quota_compliance_unix_peer1.conf");
775 setup_peer (&p2, "test_quota_compliance_unix_peer2.conf");
779 if (is_asymmetric_recv_constant == GNUNET_YES)
780 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
781 "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n");
782 else if (is_asymmetric_send_constant == GNUNET_YES)
783 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
784 "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n");
786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
787 "Testing symmetric quota compliance for TCP NAT transport plugin\n");
788 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
789 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
794 GNUNET_assert(p1.th != NULL);
795 GNUNET_assert(p2.th != NULL);
796 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
797 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
798 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
803 main (int argc, char *argv[])
806 if (strstr(argv[0], "tcp_nat") != NULL)
808 is_tcp_nat = GNUNET_YES;
813 else if (strstr(argv[0], "tcp") != NULL)
817 else if (strstr(argv[0], "https") != NULL)
819 is_https = GNUNET_YES;
824 else if (strstr(argv[0], "http") != NULL)
826 is_http = GNUNET_YES;
828 else if (strstr(argv[0], "udp") != NULL)
832 else if (strstr(argv[0], "unix") != NULL)
834 is_unix = GNUNET_YES;
837 if (strstr(argv[0], "asymmetric_recv") != NULL)
839 is_asymmetric_recv_constant = GNUNET_YES;
842 is_asymmetric_recv_constant = GNUNET_NO;
843 if (strstr(argv[0], "asymmetric_send") != NULL)
845 is_asymmetric_send_constant = GNUNET_YES;
848 is_asymmetric_send_constant = GNUNET_NO;
851 if (is_tcp == GNUNET_YES)
853 if (is_asymmetric_recv_constant == GNUNET_YES)
854 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant");
855 else if (is_asymmetric_send_constant == GNUNET_YES)
856 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant");
858 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric");
860 else if (is_udp == GNUNET_YES)
862 if (is_asymmetric_recv_constant == GNUNET_YES)
863 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant");
864 else if (is_asymmetric_send_constant == GNUNET_YES)
865 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant");
867 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric");
869 else if (is_unix == GNUNET_YES)
871 if (is_asymmetric_recv_constant == GNUNET_YES)
872 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_recv_constant");
873 else if (is_asymmetric_send_constant == GNUNET_YES)
874 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_send_constant");
876 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","symmetric");
878 else if (is_http == GNUNET_YES)
880 if (is_asymmetric_recv_constant == GNUNET_YES)
881 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant");
882 else if (is_asymmetric_send_constant == GNUNET_YES)
883 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant");
885 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric");
887 else if (is_https == GNUNET_YES)
889 if (is_asymmetric_recv_constant == GNUNET_YES)
890 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant");
891 else if (is_asymmetric_send_constant == GNUNET_YES)
892 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant");
894 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric");
898 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none");
901 fprintf(stderr, "Running `%s'\n", logger);
902 GNUNET_log_setup ("test-quota-compliance",
909 char *const argv1[] = { "test-quota-compliance",
911 "test_quota_compliance_data.conf",
917 struct GNUNET_GETOPT_CommandLineOption options[] = {
918 GNUNET_GETOPT_OPTION_END
921 GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1,
922 argv1, logger , "nohelp",
928 if (p1.servicehome != NULL)
930 GNUNET_DISK_directory_remove (p1.servicehome);
931 GNUNET_free(p1.servicehome);
933 if (p2.servicehome != NULL)
935 GNUNET_DISK_directory_remove (p2.servicehome);
936 GNUNET_free(p2.servicehome);
942 /* end of test_quota_compliance.c */